aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/email/save.php43
-rw-r--r--engine/lib/notification.php4
-rw-r--r--languages/en.php6
-rw-r--r--views/default/notifications/settings/email.php32
4 files changed, 85 insertions, 0 deletions
diff --git a/actions/email/save.php b/actions/email/save.php
new file mode 100644
index 000000000..97065d8b4
--- /dev/null
+++ b/actions/email/save.php
@@ -0,0 +1,43 @@
+<?php
+ /**
+ * Action for saving a new email address for a user and triggering a confirmation.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ global $CONFIG;
+
+ gatekeeper();
+
+ $email = get_input('email');
+ $user_id = get_input('guid');
+ $user = "";
+
+ if (!$user_id)
+ $user = $_SESSION['user'];
+ else
+ $user = get_entity($user_guid);
+
+ if ($user)
+ {
+ $user->email = $email;
+ if ($user->save())
+ {
+ request_email_validation($user->getGUID());
+ system_message(elgg_echo('email:save:success'));
+ }
+ else
+ system_message(elgg_echo('email:save:fail'));
+ }
+ else
+ system_message(elgg_echo('email:save:fail'));
+
+ forward($_SERVER['HTTP_REFERER']);
+ exit;
+?> \ No newline at end of file
diff --git a/engine/lib/notification.php b/engine/lib/notification.php
index aa2ecbfdd..8a2f2c432 100644
--- a/engine/lib/notification.php
+++ b/engine/lib/notification.php
@@ -248,6 +248,10 @@
// Register a notification handler for the default email method
register_notification_handler("email", "email_notify_handler");
+ // Add email settings
+ extend_elgg_settings_page('notifications/settings/email', 'usersettings/user');
+ register_action("email/save");
+
// Add settings view to user settings & register action
extend_elgg_settings_page('notifications/settings/usersettings', 'usersettings/user');
register_action("notifications/settings/usersettings/save");
diff --git a/languages/en.php b/languages/en.php
index 7b17489dc..d8814f682 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -442,6 +442,12 @@ Alternatively, you can enter your database settings below and we will try and do
/**
* Emails
*/
+ 'email:settings' => "Email settings",
+ 'email:address:label' => "Your email address",
+
+ 'email:save:success' => "New email address saved, verification requested.",
+ 'email:save:fail' => "Your new email address could not be saved.",
+
'email:confirm:success' => "You have confirmed your email address!",
'email:confirm:fail' => "Your email address could not be verified...",
diff --git a/views/default/notifications/settings/email.php b/views/default/notifications/settings/email.php
new file mode 100644
index 000000000..fdd509cba
--- /dev/null
+++ b/views/default/notifications/settings/email.php
@@ -0,0 +1,32 @@
+<?php
+ /**
+ * Provide a way of setting your email
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ $user = $_SESSION['user'];
+
+ if ($user) {
+?>
+ <h2><?php echo elgg_echo('email:settings'); ?></h2>
+ <form action="<?php echo $vars['url']; ?>action/email/save" method="post">
+ <p>
+ <?php echo elgg_echo('email:address:label'); ?> : <input type="text" name="email" value="<?php echo $user->email; ?>" />
+ </p>
+
+ <p>
+ <input type="submit" value="<?php
+
+ echo elgg_echo('save');
+
+ ?>" />
+ </p>
+ </form>
+
+<?php } ?> \ No newline at end of file