Merge branch '0.9.x' into emailsummary

This commit is contained in:
Evan Prodromou 2010-11-09 15:01:07 -05:00
commit 41a0f18301
3 changed files with 117 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!) EndProfileSaveForm: after saving a profile settings form (after commit, no profile or user object!)
- $action: action object being shown - $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 StartRegistrationFormData: just before showing text entry fields on registration page
- $action: action object being shown - $action: action object being shown

View File

@ -178,51 +178,55 @@ class EmailsettingsAction extends AccountSettingsAction
$this->element('legend', null, _('Email preferences')); $this->element('legend', null, _('Email preferences'));
$this->elementStart('ul', 'form_data'); $this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->checkbox('emailnotifysub', if (Event::handle('StartEmailFormData', array($this))) {
// TRANS: Checkbox label in e-mail preferences form. $this->elementStart('li');
_('Send me notices of new subscriptions through email.'), $this->checkbox('emailnotifysub',
$user->emailnotifysub); // TRANS: Checkbox label in e-mail preferences form.
$this->elementEnd('li'); _('Send me notices of new subscriptions through email.'),
$this->elementStart('li'); $user->emailnotifysub);
$this->checkbox('emailnotifyfav', $this->elementEnd('li');
// TRANS: Checkbox label in e-mail preferences form. $this->elementStart('li');
_('Send me email when someone '. $this->checkbox('emailnotifyfav',
'adds my notice as a favorite.'), // TRANS: Checkbox label in e-mail preferences form.
$user->emailnotifyfav); _('Send me email when someone '.
$this->elementEnd('li'); 'adds my notice as a favorite.'),
$this->elementStart('li'); $user->emailnotifyfav);
$this->checkbox('emailnotifymsg', $this->elementEnd('li');
// TRANS: Checkbox label in e-mail preferences form. $this->elementStart('li');
_('Send me email when someone sends me a private message.'), $this->checkbox('emailnotifymsg',
$user->emailnotifymsg); // TRANS: Checkbox label in e-mail preferences form.
$this->elementEnd('li'); _('Send me email when someone sends me a private message.'),
$this->elementStart('li'); $user->emailnotifymsg);
$this->checkbox('emailnotifyattn', $this->elementEnd('li');
// TRANS: Checkbox label in e-mail preferences form. $this->elementStart('li');
_('Send me email when someone sends me an "@-reply".'), $this->checkbox('emailnotifyattn',
$user->emailnotifyattn); // TRANS: Checkbox label in e-mail preferences form.
$this->elementEnd('li'); _('Send me email when someone sends me an "@-reply".'),
$this->elementStart('li'); $user->emailnotifyattn);
$this->checkbox('emailnotifynudge', $this->elementEnd('li');
// TRANS: Checkbox label in e-mail preferences form. $this->elementStart('li');
_('Allow friends to nudge me and send me an email.'), $this->checkbox('emailnotifynudge',
$user->emailnotifynudge); // TRANS: Checkbox label in e-mail preferences form.
$this->elementEnd('li'); _('Allow friends to nudge me and send me an email.'),
if (common_config('emailpost', 'enabled')) { $user->emailnotifynudge);
$this->elementStart('li'); $this->elementEnd('li');
$this->checkbox('emailpost', if (common_config('emailpost', 'enabled')) {
// TRANS: Checkbox label in e-mail preferences form. $this->elementStart('li');
_('I want to post notices by email.'), $this->checkbox('emailpost',
$user->emailpost); // TRANS: Checkbox label in e-mail preferences form.
$this->elementEnd('li'); _('I want to post notices by email.'),
} $user->emailpost);
$this->elementStart('li'); $this->elementEnd('li');
$this->checkbox('emailmicroid', }
// TRANS: Checkbox label in e-mail preferences form. $this->elementStart('li');
_('Publish a MicroID for my email address.'), $this->checkbox('emailmicroid',
$user->emailmicroid); // TRANS: Checkbox label in e-mail preferences form.
$this->elementEnd('li'); _('Publish a MicroID for my email address.'),
$user->emailmicroid);
$this->elementEnd('li');
Event::handle('EndEmailFormData', array($this));
}
$this->elementEnd('ul'); $this->elementEnd('ul');
// TRANS: Button label to save e-mail preferences. // TRANS: Button label to save e-mail preferences.
$this->submit('save', _m('BUTTON','Save')); $this->submit('save', _m('BUTTON','Save'));
@ -299,43 +303,48 @@ class EmailsettingsAction extends AccountSettingsAction
function savePreferences() function savePreferences()
{ {
$emailnotifysub = $this->boolean('emailnotifysub'); $user = common_current_user();
$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(); if (Event::handle('StartEmailSaveForm', array($this, &$user))) {
assert(!is_null($user)); // should already be checked $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->query('BEGIN'); assert(!is_null($user)); // should already be checked
$original = clone($user); $user->query('BEGIN');
$user->emailnotifysub = $emailnotifysub; $original = clone($user);
$user->emailnotifyfav = $emailnotifyfav;
$user->emailnotifymsg = $emailnotifymsg;
$user->emailnotifynudge = $emailnotifynudge;
$user->emailnotifyattn = $emailnotifyattn;
$user->emailmicroid = $emailmicroid;
$user->emailpost = $emailpost;
$result = $user->update($original); $user->emailnotifysub = $emailnotifysub;
$user->emailnotifyfav = $emailnotifyfav;
$user->emailnotifymsg = $emailnotifymsg;
$user->emailnotifynudge = $emailnotifynudge;
$user->emailnotifyattn = $emailnotifyattn;
$user->emailmicroid = $emailmicroid;
$user->emailpost = $emailpost;
if ($result === false) { $result = $user->update($original);
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'); 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;
}
// TRANS: Confirmation message for successful e-mail preferences save. $user->query('COMMIT');
$this->showForm(_('Email preferences saved.'), true);
Event::handle('EndEmailSaveForm', array($this));
// TRANS: Confirmation message for successful e-mail preferences save.
$this->showForm(_('Email preferences saved.'), true);
}
} }
/** /**

View File

@ -107,3 +107,15 @@ create table group_alias (
index group_alias_group_id_idx (group_id) index group_alias_group_id_idx (group_id)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
create table session (
id varchar(32) primary key comment 'session ID',
session_data text comment 'session data',
created datetime not null comment 'date this record was created',
modified timestamp comment 'date this record was modified',
index session_modified_idx (modified)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;