]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
hook points for the email settings form
authorEvan Prodromou <evan@status.net>
Tue, 9 Nov 2010 20:00:30 +0000 (15:00 -0500)
committerEvan Prodromou <evan@status.net>
Tue, 9 Nov 2010 20:00:30 +0000 (15:00 -0500)
EVENTS.txt
actions/emailsettings.php

index 675ac5437e5713decef1cb791a7199935a936fb2..fed489705c29a7a26854f7cc70edc9633c3495ac 100644 (file)
@@ -302,6 +302,20 @@ StartProfileSaveForm: before starting to save a profile settings form
 EndProfileSaveForm: after saving a profile settings form (after commit, no profile or user object!)
 - $action: action object being shown
 
+StartEmailFormData: just before showing text entry fields on email settings page
+- $action: action object being shown
+
+EndEmailFormData: just after showing text entry fields on email settings page
+- $action: action object being shown
+
+StartEmailSaveForm: before starting to save a email settings form
+- $action: action object being shown
+- &$user: user being saved
+
+EndEmailSaveForm: after saving a email settings form (after commit)
+- $action: action object being shown
+- &$user: user being saved
+
 StartRegistrationFormData: just before showing text entry fields on registration page
 - $action: action object being shown
 
index 9c250fc8a93a97a77d0fc7e3e3b22da18d1e8f60..5a816e5c0ab17fd4e3107baa7a3b77c0bd136fc4 100644 (file)
@@ -178,51 +178,55 @@ class EmailsettingsAction extends AccountSettingsAction
         $this->element('legend', null, _('Email preferences'));
 
         $this->elementStart('ul', 'form_data');
-        $this->elementStart('li');
-        $this->checkbox('emailnotifysub',
-                        // TRANS: Checkbox label in e-mail preferences form.
-                        _('Send me notices of new subscriptions through email.'),
-                        $user->emailnotifysub);
-        $this->elementEnd('li');
-        $this->elementStart('li');
-        $this->checkbox('emailnotifyfav',
-                        // TRANS: Checkbox label in e-mail preferences form.
-                        _('Send me email when someone '.
-                          'adds my notice as a favorite.'),
-                        $user->emailnotifyfav);
-        $this->elementEnd('li');
-        $this->elementStart('li');
-        $this->checkbox('emailnotifymsg',
-                        // TRANS: Checkbox label in e-mail preferences form.
-                        _('Send me email when someone sends me a private message.'),
-                        $user->emailnotifymsg);
-        $this->elementEnd('li');
-        $this->elementStart('li');
-        $this->checkbox('emailnotifyattn',
-                        // TRANS: Checkbox label in e-mail preferences form.
-                        _('Send me email when someone sends me an "@-reply".'),
-                        $user->emailnotifyattn);
-        $this->elementEnd('li');
-        $this->elementStart('li');
-        $this->checkbox('emailnotifynudge',
-                        // TRANS: Checkbox label in e-mail preferences form.
-                        _('Allow friends to nudge me and send me an email.'),
-                        $user->emailnotifynudge);
-        $this->elementEnd('li');
-        if (common_config('emailpost', 'enabled')) {
-            $this->elementStart('li');
-            $this->checkbox('emailpost',
-                            // TRANS: Checkbox label in e-mail preferences form.
-                            _('I want to post notices by email.'),
-                            $user->emailpost);
-            $this->elementEnd('li');
-        }
-        $this->elementStart('li');
-        $this->checkbox('emailmicroid',
-                        // TRANS: Checkbox label in e-mail preferences form.
-                        _('Publish a MicroID for my email address.'),
-                        $user->emailmicroid);
-        $this->elementEnd('li');
+       
+        if (Event::handle('StartEmailFormData', array($this))) {
+           $this->elementStart('li');
+           $this->checkbox('emailnotifysub',
+                           // TRANS: Checkbox label in e-mail preferences form.
+                           _('Send me notices of new subscriptions through email.'),
+                           $user->emailnotifysub);
+           $this->elementEnd('li');
+           $this->elementStart('li');
+           $this->checkbox('emailnotifyfav',
+                           // TRANS: Checkbox label in e-mail preferences form.
+                           _('Send me email when someone '.
+                             'adds my notice as a favorite.'),
+                           $user->emailnotifyfav);
+           $this->elementEnd('li');
+           $this->elementStart('li');
+           $this->checkbox('emailnotifymsg',
+                           // TRANS: Checkbox label in e-mail preferences form.
+                           _('Send me email when someone sends me a private message.'),
+                           $user->emailnotifymsg);
+           $this->elementEnd('li');
+           $this->elementStart('li');
+           $this->checkbox('emailnotifyattn',
+                           // TRANS: Checkbox label in e-mail preferences form.
+                           _('Send me email when someone sends me an "@-reply".'),
+                           $user->emailnotifyattn);
+           $this->elementEnd('li');
+           $this->elementStart('li');
+           $this->checkbox('emailnotifynudge',
+                           // TRANS: Checkbox label in e-mail preferences form.
+                           _('Allow friends to nudge me and send me an email.'),
+                           $user->emailnotifynudge);
+           $this->elementEnd('li');
+           if (common_config('emailpost', 'enabled')) {
+               $this->elementStart('li');
+               $this->checkbox('emailpost',
+                               // TRANS: Checkbox label in e-mail preferences form.
+                               _('I want to post notices by email.'),
+                               $user->emailpost);
+               $this->elementEnd('li');
+           }
+           $this->elementStart('li');
+           $this->checkbox('emailmicroid',
+                           // TRANS: Checkbox label in e-mail preferences form.
+                           _('Publish a MicroID for my email address.'),
+                           $user->emailmicroid);
+           $this->elementEnd('li');
+           Event::handle('EndEmailFormData', array($this));
+       }
         $this->elementEnd('ul');
         // TRANS: Button label to save e-mail preferences.
         $this->submit('save', _m('BUTTON','Save'));
@@ -299,43 +303,48 @@ class EmailsettingsAction extends AccountSettingsAction
 
     function savePreferences()
     {
-        $emailnotifysub   = $this->boolean('emailnotifysub');
-        $emailnotifyfav   = $this->boolean('emailnotifyfav');
-        $emailnotifymsg   = $this->boolean('emailnotifymsg');
-        $emailnotifynudge = $this->boolean('emailnotifynudge');
-        $emailnotifyattn  = $this->boolean('emailnotifyattn');
-        $emailmicroid     = $this->boolean('emailmicroid');
-        $emailpost        = $this->boolean('emailpost');
-
-        $user = common_current_user();
-
-        assert(!is_null($user)); // should already be checked
-
-        $user->query('BEGIN');
-
-        $original = clone($user);
-
-        $user->emailnotifysub   = $emailnotifysub;
-        $user->emailnotifyfav   = $emailnotifyfav;
-        $user->emailnotifymsg   = $emailnotifymsg;
-        $user->emailnotifynudge = $emailnotifynudge;
-        $user->emailnotifyattn  = $emailnotifyattn;
-        $user->emailmicroid     = $emailmicroid;
-        $user->emailpost        = $emailpost;
-
-        $result = $user->update($original);
-
-        if ($result === false) {
-            common_log_db_error($user, 'UPDATE', __FILE__);
-            // TRANS: Server error thrown on database error updating e-mail preferences.
-            $this->serverError(_('Couldn\'t update user.'));
-            return;
-        }
-
-        $user->query('COMMIT');
-
-        // TRANS: Confirmation message for successful e-mail preferences save.
-        $this->showForm(_('Email preferences saved.'), true);
+       $user = common_current_user();
+       
+       if (Event::handle('StartEmailSaveForm', array($this, &$user))) {
+           
+           $emailnotifysub   = $this->boolean('emailnotifysub');
+           $emailnotifyfav   = $this->boolean('emailnotifyfav');
+           $emailnotifymsg   = $this->boolean('emailnotifymsg');
+           $emailnotifynudge = $this->boolean('emailnotifynudge');
+           $emailnotifyattn  = $this->boolean('emailnotifyattn');
+           $emailmicroid     = $this->boolean('emailmicroid');
+           $emailpost        = $this->boolean('emailpost');
+           
+           assert(!is_null($user)); // should already be checked
+           
+           $user->query('BEGIN');
+           
+           $original = clone($user);
+           
+           $user->emailnotifysub   = $emailnotifysub;
+           $user->emailnotifyfav   = $emailnotifyfav;
+           $user->emailnotifymsg   = $emailnotifymsg;
+           $user->emailnotifynudge = $emailnotifynudge;
+           $user->emailnotifyattn  = $emailnotifyattn;
+           $user->emailmicroid     = $emailmicroid;
+           $user->emailpost        = $emailpost;
+           
+           $result = $user->update($original);
+           
+           if ($result === false) {
+               common_log_db_error($user, 'UPDATE', __FILE__);
+               // TRANS: Server error thrown on database error updating e-mail preferences.
+               $this->serverError(_('Couldn\'t update user.'));
+               return;
+           }
+           
+           $user->query('COMMIT');
+           
+           Event::handle('EndEmailSaveForm', array($this));
+           
+           // TRANS: Confirmation message for successful e-mail preferences save.
+           $this->showForm(_('Email preferences saved.'), true);
+       }
     }
 
     /**