Exemplo n.º 1
0
 /**
  * given a User, get their User_im_prefs
  *
  * @param User $user
  *
  * @return User_im_prefs user_im_prefs of that user
  */
 function getUserImPrefsFromUser($user)
 {
     $user_im_prefs = User_im_prefs::pkeyGet(array('transport' => $this->transport, 'user_id' => $user->id));
     if ($user_im_prefs) {
         return $user_im_prefs;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Content area of the page
  *
  * We make different sections of the form for the different kinds of
  * functions, and have submit buttons with different names. These
  * are muxed by handlePost() to see what the user really wants to do.
  *
  * @return void
  */
 function showContent()
 {
     $transports = array();
     Event::handle('GetImTransports', array(&$transports));
     if (!$transports) {
         $this->element('div', array('class' => 'error'), _('IM is not available.'));
         return;
     }
     $user = common_current_user();
     $user_im_prefs_by_transport = array();
     foreach ($transports as $transport => $transport_info) {
         $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_im', 'class' => 'form_settings', 'action' => common_local_url('imsettings')));
         $this->elementStart('fieldset', array('id' => 'settings_im_address'));
         // TRANS: Form legend for IM settings form.
         $this->element('legend', null, $transport_info['display']);
         $this->hidden('token', common_session_token());
         $this->hidden('transport', $transport);
         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);
             $this->element('p', 'form_note', 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 {
             try {
                 $confirm = $this->getConfirmation($transport);
                 $this->element('p', 'form_unconfirmed', $confirm->address);
                 // TRANS: Form note in IM settings form.
                 $this->element('p', 'form_note', sprintf(_('Awaiting confirmation on this address. ' . 'Check your %1$s account for a ' . 'message with further instructions. ' . '(Did you add %2$s to your buddy list?)'), $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'));
             } catch (NoResultException $e) {
                 $this->elementStart('ul', 'form_data');
                 $this->elementStart('li');
                 // TRANS: Field label for IM address.
                 $this->input('screenname', _('IM address'), $this->arg('screenname') ? $this->arg('screenname') : null, sprintf(_('%s screenname.'), $transport_info['display']));
                 $this->elementEnd('li');
                 $this->elementEnd('ul');
                 // TRANS: Button label for adding an IM address in IM settings form.
                 $this->submit('add', _m('BUTTON', 'Add'));
             }
         }
         $this->elementEnd('fieldset');
         $this->elementEnd('form');
     }
     if ($user_im_prefs_by_transport) {
         $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_im', 'class' => 'form_settings', 'action' => common_local_url('imsettings')));
         $this->elementStart('fieldset', array('id' => 'settings_im_preferences'));
         // TRANS: Header for IM preferences form.
         $this->element('legend', null, _('IM Preferences'));
         $this->hidden('token', common_session_token());
         $this->elementStart('table');
         $this->elementStart('tr');
         foreach ($user_im_prefs_by_transport as $transport => $user_im_prefs) {
             $this->element('th', null, $transports[$transport]['display']);
         }
         $this->elementEnd('tr');
         $preferences = array(array('name' => 'notify', 'description' => _('Send me notices')), array('name' => 'updatefrompresence', 'description' => _('Post a notice when my status changes.')), array('name' => 'replies', 'description' => _('Send me replies ' . 'from people I\'m not subscribed to.')));
         foreach ($preferences as $preference) {
             $this->elementStart('tr');
             foreach ($user_im_prefs_by_transport as $transport => $user_im_prefs) {
                 $preference_name = $preference['name'];
                 $this->elementStart('td');
                 $this->checkbox($transport . '_' . $preference['name'], $preference['description'], $user_im_prefs->{$preference_name});
                 $this->elementEnd('td');
             }
             $this->elementEnd('tr');
         }
         $this->elementEnd('table');
         // TRANS: Button label to save IM preferences.
         $this->submit('save', _m('BUTTON', 'Save'));
         $this->elementEnd('fieldset');
         $this->elementEnd('form');
     }
 }