// TRANS: [instant messages] is link text, "(%%doc.im%%)" is the link.
// TRANS: the order and formatting of link text and link should remain unchanged.
return _('You can send and receive notices through '.
// TRANS: [instant messages] is link text, "(%%doc.im%%)" is the link.
// TRANS: the order and formatting of link text and link should remain unchanged.
return _('You can send and receive notices through '.
if ($user_im_prefs = User_im_prefs::pkeyGet( array('transport' => $transport, 'user_id' => $user->id) )) {
$user_im_prefs_by_transport[$transport] = $user_im_prefs;
$this->element('p', 'form_confirmed', $user_im_prefs->screenname);
if ($user_im_prefs = User_im_prefs::pkeyGet( array('transport' => $transport, 'user_id' => $user->id) )) {
$user_im_prefs_by_transport[$transport] = $user_im_prefs;
$this->element('p', 'form_confirmed', $user_im_prefs->screenname);
sprintf(_('Current confirmed %s address.'),$transport_info['display']));
$this->hidden('screenname', $user_im_prefs->screenname);
// TRANS: Button label to remove a confirmed IM address.
$this->submit('remove', _m('BUTTON','Remove'));
} else {
sprintf(_('Current confirmed %s address.'),$transport_info['display']));
$this->hidden('screenname', $user_im_prefs->screenname);
// TRANS: Button label to remove a confirmed IM address.
$this->submit('remove', _m('BUTTON','Remove'));
} else {
$this->element('p', 'form_unconfirmed', $confirm->address);
// TRANS: Form note in IM settings form.
$this->element('p', 'form_note',
// TRANS: Form note in IM settings form.
$this->element('p', 'form_unconfirmed', $confirm->address);
// TRANS: Form note in IM settings form.
$this->element('p', 'form_note',
// TRANS: Form note in IM settings form.
$transport_info['display'],
$transport_info['daemonScreenname']));
$this->hidden('screenname', $confirm->address);
// TRANS: Button label to cancel an IM address confirmation procedure.
$this->submit('cancel', _m('BUTTON','Cancel'));
$transport_info['display'],
$transport_info['daemonScreenname']));
$this->hidden('screenname', $confirm->address);
// TRANS: Button label to cancel an IM address confirmation procedure.
$this->submit('cancel', _m('BUTTON','Cancel'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->input('screenname', _('IM address'),
($this->arg('screenname')) ? $this->arg('screenname') : null,
$this->input('screenname', _('IM address'),
($this->arg('screenname')) ? $this->arg('screenname') : null,
sprintf(_('%s screenname.'),
$transport_info['display']));
$this->elementEnd('li');
sprintf(_('%s screenname.'),
$transport_info['display']));
$this->elementEnd('li');
// TRANS: Checkbox label in IM preferences form.
array('name'=>'replies', 'description'=>_('Send me replies '.
'from people I\'m not subscribed to.')),
// TRANS: Checkbox label in IM preferences form.
array('name'=>'replies', 'description'=>_('Send me replies '.
'from people I\'m not subscribed to.')),
- /**
- * Handle posts to this form
- *
- * Based on the button that was pressed, muxes out to other functions
- * to do the actual task requested.
- *
- * All sub-functions reload the form with a message -- success or failure.
- *
- * @return void
- */
- function handlePost()
+ protected function doPost()
- // CSRF protection
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
- $this->showForm(_('There was a problem with your session token. '.
- 'Try again, please.'));
- return;
- }
-
- $this->removeAddress();
- } else {
- // TRANS: Message given submitting a form with an unknown action in Instant Messaging settings.
- $this->showForm(_('Unexpected form submission.'));
+ return $this->removeAddress();
- $preferences = array('notify', 'updatefrompresence', 'replies', 'microid');
+ $preferences = array('notify', 'updatefrompresence', 'replies');
}
}while($user_im_prefs->fetch());
}
$user_im_prefs->query('COMMIT');
// TRANS: Confirmation message for successful IM preferences save.
}
}while($user_im_prefs->fetch());
}
$user_im_prefs->query('COMMIT');
// TRANS: Confirmation message for successful IM preferences save.
}
$valid = false;
Event::handle('ValidateImScreenname', array($transport, $screenname, &$valid));
if (!$valid) {
// TRANS: Message given saving IM address that not valid.
}
$valid = false;
Event::handle('ValidateImScreenname', array($transport, $screenname, &$valid));
if (!$valid) {
// TRANS: Message given saving IM address that not valid.
} else if ($this->screennameExists($transport, $screenname)) {
// TRANS: Message given saving IM address that is already set for another user.
} else if ($this->screennameExists($transport, $screenname)) {
// TRANS: Message given saving IM address that is already set for another user.
}
$confirm = new Confirm_address();
$confirm->address = $screenname;
$confirm->address_type = $transport;
}
$confirm = new Confirm_address();
$confirm->address = $screenname;
$confirm->address_type = $transport;
$confirm->code = common_confirmation_code(64);
$confirm->sent = common_sql_now();
$confirm->claimed = common_sql_now();
$confirm->code = common_confirmation_code(64);
$confirm->sent = common_sql_now();
$confirm->claimed = common_sql_now();
common_log_db_error($confirm, 'INSERT', __FILE__);
// TRANS: Server error thrown on database error adding Instant Messaging confirmation code.
$this->serverError(_('Could not insert confirmation code.'));
common_log_db_error($confirm, 'INSERT', __FILE__);
// TRANS: Server error thrown on database error adding Instant Messaging confirmation code.
$this->serverError(_('Could not insert confirmation code.'));
- Event::handle('SendImConfirmationCode', array($transport, $screenname, $confirm->code, $user));
+ Event::handle('SendImConfirmationCode', array($transport, $screenname, $confirm->code, $this->scoped));
- $msg = _('A confirmation code was sent '.
- 'to the IM address you added.');
-
- $this->showForm($msg, true);
+ return _('A confirmation code was sent to the IM address you added.');
- $confirm = $this->getConfirmation($transport);
-
- if (!$confirm) {
+ try {
+ $confirm = $this->getConfirmation($transport);
+ if ($confirm->address != $screenname) {
+ // TRANS: Message given canceling IM address confirmation for the wrong IM address.
+ throw new ClientException(_('That is the wrong IM address.'));
+ }
+ } catch (NoResultException $e) {
- $this->showForm(_('No pending confirmation to cancel.'));
- return;
- }
- if ($confirm->address != $screenname) {
- // TRANS: Message given canceling IM address confirmation for the wrong IM address.
- $this->showForm(_('That is the wrong IM address.'));
- return;
+ throw new AlreadyFulfilledException(_('No pending confirmation to cancel.'));
common_log_db_error($confirm, 'DELETE', __FILE__);
// TRANS: Server error thrown on database error canceling IM address confirmation.
common_log_db_error($confirm, 'DELETE', __FILE__);
// TRANS: Server error thrown on database error canceling IM address confirmation.
$screenname = $this->trimmed('screenname');
$transport = $this->trimmed('transport');
// Maybe an old tab open...?
$user_im_prefs = new User_im_prefs();
$screenname = $this->trimmed('screenname');
$transport = $this->trimmed('transport');
// Maybe an old tab open...?
$user_im_prefs = new User_im_prefs();
- $user_im_prefs->user_id = $user->id;
- if(! ($user_im_prefs->find() && $user_im_prefs->fetch())) {
+ $user_im_prefs->user_id = $this->scoped->getID();
+ $user_im_prefs->transport = $transport;
+ if (!$user_im_prefs->find(true)) {
// TRANS: Message given trying to remove an IM address that is not
// TRANS: registered for the active user.
// TRANS: Message given trying to remove an IM address that is not
// TRANS: registered for the active user.
- if (!$result) {
- common_log_db_error($user, 'UPDATE', __FILE__);
+ if ($result === false) {
+ common_log_db_error($user_im_prefs, 'UPDATE', __FILE__);
}
// XXX: unsubscribe to the old address
// TRANS: Message given after successfully removing a registered Instant Messaging address.
}
// XXX: unsubscribe to the old address
// TRANS: Message given after successfully removing a registered Instant Messaging address.
$user_im_prefs = new User_im_prefs();
$user_im_prefs->transport = $transport;
$user_im_prefs->screenname = $screenname;
$user_im_prefs = new User_im_prefs();
$user_im_prefs->transport = $transport;
$user_im_prefs->screenname = $screenname;