aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-25 19:21:21 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-25 19:21:21 +0000
commit401fd957b30219a610014d4236de35b6220fd310 (patch)
tree072d7ef4b88000ff20df90724e4f798bf5448b74
parentfb24a60da5ea1627c8336e387217bd6ca2b45f74 (diff)
downloadelgg-401fd957b30219a610014d4236de35b6220fd310.tar.gz
elgg-401fd957b30219a610014d4236de35b6220fd310.tar.bz2
Closes #79: Email confirmation on registration & email change
http://trac.elgg.org/elgg/ticket/79 git-svn-id: https://code.elgg.org/elgg/trunk@1137 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--actions/email/confirm.php12
-rw-r--r--actions/register.php2
-rw-r--r--engine/lib/notification.php7
-rw-r--r--engine/lib/sites.php6
-rw-r--r--engine/lib/users.php8
-rw-r--r--languages/en.php4
6 files changed, 26 insertions, 13 deletions
diff --git a/actions/email/confirm.php b/actions/email/confirm.php
index d967f7c1e..8ba54347e 100644
--- a/actions/email/confirm.php
+++ b/actions/email/confirm.php
@@ -11,9 +11,7 @@
*/
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- // Ensure we are logged in
- gatekeeper();
+ global $CONFIG;
// Get user id
$user_guid = (int)get_input('u');
@@ -24,9 +22,13 @@
if ( ($code) && ($user) )
{
- if (validate_email($user_guid, $code))
+ if (validate_email($user_guid, $code)) {
system_message(elgg_echo('email:confirm:success'));
- else
+
+ $user = get_entity($user_guid);
+ notify_user($user_guid, $CONFIG->site->guid, elgg_echo('email:validate:success:subject'), sprintf(elgg_echo('email:validate:success:body'), $user->username), NULL, 'email');
+
+ } else
system_message(elgg_echo('email:confirm:fail'));
}
else
diff --git a/actions/register.php b/actions/register.php
index dd573aa77..88cbf0348 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -10,6 +10,8 @@
* @copyright Curverider Ltd 2008
* @link http://elgg.org/
*/
+
+ require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
// Get variables
$username = get_input('username');
diff --git a/engine/lib/notification.php b/engine/lib/notification.php
index 145f9a4a0..aa2ecbfdd 100644
--- a/engine/lib/notification.php
+++ b/engine/lib/notification.php
@@ -110,7 +110,7 @@
throw new NotificationException(sprintf(elgg_echo('NotificationException:NoHandlerFound'), $method));
if ($CONFIG->debug)
- error_log("Sending message to $guid using $method");
+ error_log("Sending message to $guid using $method");
// Trigger handler and retrieve result.
$result[$guid][$method] = $handler(
@@ -226,7 +226,10 @@
if ($from->email)
$from = $from->email; // Handle users
else if ($from->url)
- $from = 'noreply@' . parse_url($from->url, 'host'); // Handle anything with a url
+ {
+ $breakdown = parse_url($from->url);
+ $from = 'noreply@' . $breakdown['host']; // Handle anything with a url
+ }
else {
$from = 'noreply@' . get_site_domain($CONFIG->site_guid); // Handle a fallback
}
diff --git a/engine/lib/sites.php b/engine/lib/sites.php
index 441a649ad..40ff02f6c 100644
--- a/engine/lib/sites.php
+++ b/engine/lib/sites.php
@@ -554,8 +554,10 @@
$guid = (int)$guid;
$site = get_entity($site);
- if ($site instanceof ElggSite)
- return parse_url($site->url, 'host');
+ if ($site instanceof ElggSite) {
+ $breakdown = parse_url($site->url);
+ return $breakdown['host'];
+ }
return false;
}
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 5dc382670..c090f3267 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -784,10 +784,10 @@
$user->validated_email = false;
// Work out validate link
- $link = $CONFIG->site->url . "action/email/confirm/?u=$user_guid&c=" . generate_email_validation_code($user_guid, $user->email);
-
+ $link = $CONFIG->site->url . "action/email/confirm?u=$user_guid&c=" . generate_email_validation_code($user_guid, $user->email);
+
// Send validation email
- return notify_user($user->guid, $CONFIG->site_guid, elgg_echo('email:validate:subject'), sprintf(elgg_echo('email:validate:body'), $user->username, $link), NULL, 'email');
+ return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:validate:subject'), sprintf(elgg_echo('email:validate:body'), $user->username, $link), NULL, 'email');
}
@@ -899,7 +899,7 @@
register_action("register",true);
register_action("friends/add");
register_action("friends/remove");
-
+ register_action("email/confirm");
}
//register actions *************************************************************
diff --git a/languages/en.php b/languages/en.php
index cf94ecd1a..7b17489dc 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -460,6 +460,10 @@ Please confirm your email address by clicking on the link below:
%s
",
+ 'email:validate:success:subject' => "Email validated!",
+ 'email:validate:success:body' => "Hi %s,
+
+Congratulations, you have successfully validated your email address.",
/**
* XML-RPC