Пример #1
0
 protected function doPost()
 {
     $upp = User_poll_prefs::getKV('user_id', $this->scoped->getID());
     $orig = null;
     if ($upp instanceof User_poll_prefs) {
         $orig = clone $upp;
     } else {
         $upp = new User_poll_prefs();
         $upp->user_id = $this->scoped->getID();
         $upp->created = common_sql_now();
     }
     $upp->hide_responses = $this->boolean('hide_responses');
     $upp->modified = common_sql_now();
     if ($orig instanceof User_poll_prefs) {
         $upp->update($orig);
     } else {
         $upp->insert();
     }
     // TRANS: Confirmation shown when user profile settings are saved.
     return _('Settings saved.');
 }
Пример #2
0
 /**
  * Handler method
  *
  * @param array $argarray is ignored since it's now passed in in prepare()
  *
  * @return void
  */
 function handlePost()
 {
     $user = common_current_user();
     $upp = User_poll_prefs::getKV('user_id', $user->id);
     $orig = null;
     if (!empty($upp)) {
         $orig = clone $upp;
     } else {
         $upp = new User_poll_prefs();
         $upp->user_id = $user->id;
         $upp->created = common_sql_now();
     }
     $upp->hide_responses = $this->boolean('hide_responses');
     $upp->modified = common_sql_now();
     if (!empty($orig)) {
         $upp->update($orig);
     } else {
         $upp->insert();
     }
     // TRANS: Confirmation shown when user profile settings are saved.
     $this->showForm(_('Settings saved.'), true);
     return;
 }
Пример #3
0
 function onEndNoticeWhoGets($notice, &$ni)
 {
     if ($notice->object_type == self::POLL_RESPONSE_OBJECT) {
         foreach ($ni as $id => $source) {
             $user = User::getKV('id', $id);
             if (!empty($user)) {
                 $pollPrefs = User_poll_prefs::getKV('user_id', $user->id);
                 if (!empty($pollPrefs) && $pollPrefs->hide_responses) {
                     unset($ni[$id]);
                 }
             }
         }
     }
     return true;
 }