hook points for the email settings form

This commit is contained in:
Evan Prodromou 2010-11-09 15:00:30 -05:00
parent 9ea1a9c631
commit a988e2e97b
2 changed files with 105 additions and 82 deletions

View 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

View File

@ -178,6 +178,8 @@ class EmailsettingsAction extends AccountSettingsAction
$this->element('legend', null, _('Email preferences'));
$this->elementStart('ul', 'form_data');
if (Event::handle('StartEmailFormData', array($this))) {
$this->elementStart('li');
$this->checkbox('emailnotifysub',
// TRANS: Checkbox label in e-mail preferences form.
@ -223,6 +225,8 @@ class EmailsettingsAction extends AccountSettingsAction
_('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,6 +303,10 @@ class EmailsettingsAction extends AccountSettingsAction
function savePreferences()
{
$user = common_current_user();
if (Event::handle('StartEmailSaveForm', array($this, &$user))) {
$emailnotifysub = $this->boolean('emailnotifysub');
$emailnotifyfav = $this->boolean('emailnotifyfav');
$emailnotifymsg = $this->boolean('emailnotifymsg');
@ -307,8 +315,6 @@ class EmailsettingsAction extends AccountSettingsAction
$emailmicroid = $this->boolean('emailmicroid');
$emailpost = $this->boolean('emailpost');
$user = common_current_user();
assert(!is_null($user)); // should already be checked
$user->query('BEGIN');
@ -334,9 +340,12 @@ class EmailsettingsAction extends AccountSettingsAction
$user->query('COMMIT');
Event::handle('EndEmailSaveForm', array($this));
// TRANS: Confirmation message for successful e-mail preferences save.
$this->showForm(_('Email preferences saved.'), true);
}
}
/**
* Add the address passed in by the user