function showOnce()
 {
     NewMessages::recacheMessageCount($this->user->getId());
     $this->user->setNewtalk(false);
     if ($this->methodApplies('mark_as_unread')) {
         $ids = explode(',', $this->request->getVal('lqt_operand', ''));
         if ($ids !== false) {
             foreach ($ids as $id) {
                 $tmp_thread = Threads::withId($id);
                 if ($tmp_thread) {
                     NewMessages::markThreadAsUnReadByUser($tmp_thread, $this->user);
                 }
             }
             $this->output->redirect($this->title->getLocalURL());
         }
     } elseif ($this->methodApplies('mark_as_read')) {
         $ids = explode(',', $this->request->getVal('lqt_operand'));
         if ($ids !== false) {
             foreach ($ids as $id) {
                 if ($id == 'all') {
                     NewMessages::markAllReadByUser($this->user);
                 } else {
                     $tmp_thread = Threads::withId($id);
                     if ($tmp_thread) {
                         NewMessages::markThreadAsReadByUser($tmp_thread, $this->user);
                     }
                 }
             }
             $query = 'lqt_method=undo_mark_as_read&lqt_operand=' . implode(',', $ids);
             $this->output->redirect($this->title->getLocalURL($query));
         }
     } elseif ($this->methodApplies('undo_mark_as_read')) {
         $ids = explode(',', $this->request->getVal('lqt_operand', ''));
         $this->output->addHTML($this->getUndoButton($ids));
     }
 }
 /**
  * Write a user_message_state for each user who is watching the thread.
  * If the thread is on a user's talkpage, set that user's newtalk.
  */
 static function writeMessageStateForUpdatedThread($t, $type, $changeUser)
 {
     wfDebugLog('LiquidThreads', 'Doing notifications');
     wfProfileIn(__METHOD__);
     // Pull users to update the message state for, including whether or not a
     //  user_message_state row exists for them, and whether or not to send an email
     //  notification.
     $userIds = array();
     $notifyUsers = array();
     $res = self::getRowsObject($t);
     foreach ($res as $row) {
         // Don't notify yourself
         if ($changeUser->getId() == $row->wl_user) {
             continue;
         }
         if (!$row->ums_user || $row->ums_read_timestamp) {
             $userIds[] = $row->wl_user;
             NewMessages::recacheMessageCount($row->wl_user);
         }
         $wantsTalkNotification = true;
         $wantsTalkNotification = $wantsTalkNotification && User::getDefaultOption('lqtnotifytalk');
         if ($wantsTalkNotification || $row->up_value) {
             $notifyUsers[] = $row->wl_user;
         }
     }
     // Add user talk notification
     if ($t->getTitle()->getNamespace() == NS_USER_TALK) {
         $name = $t->getTitle()->getText();
         $user = User::newFromName($name);
         if ($user && $user->getName() != $changeUser->getName()) {
             $user->setNewtalk(true);
             $userIds[] = $user->getId();
             if ($user->getOption('enotifusertalkpages')) {
                 $notifyUsers[] = $user->getId();
             }
         }
     }
     // Do the actual updates
     if (count($userIds)) {
         foreach ($userIds as $u) {
             $insertRows[] = array('ums_user' => $u, 'ums_thread' => $t->id(), 'ums_read_timestamp' => null, 'ums_conversation' => $t->topmostThread()->id());
         }
         $dbw = wfGetDB(DB_MASTER);
         $dbw->replace('user_message_state', array(array('ums_user', 'ums_thread')), $insertRows, __METHOD__);
     }
     global $wgLqtEnotif;
     if (count($notifyUsers) && $wgLqtEnotif) {
         self::notifyUsersByMail($t, $notifyUsers, wfTimestampNow(), $type);
     }
     wfProfileOut(__METHOD__);
 }
Esempio n. 3
0
 static function getNotifyUsers($t, $changeUser)
 {
     // Pull users to update the message state for, including whether or not a
     //  user_message_state row exists for them, and whether or not to send an email
     //  notification.
     $userIds = array();
     $notifyUsers = array();
     $res = self::getRowsObject($t);
     foreach ($res as $row) {
         // Don't notify yourself
         if ($changeUser->getId() == $row->wl_user) {
             continue;
         }
         if (!$row->ums_user || $row->ums_read_timestamp) {
             $userIds[] = $row->wl_user;
             NewMessages::recacheMessageCount($row->wl_user);
         }
         global $wgHiddenPrefs;
         if (!in_array('lqtnotifytalk', $wgHiddenPrefs) && isset($row->up_value)) {
             $wantsTalkNotification = (bool) $row->wl_user;
         } else {
             $wantsTalkNotification = User::getDefaultOption('lqtnotifytalk');
         }
         if ($wantsTalkNotification) {
             $notifyUsers[] = $row->wl_user;
         }
     }
     // Add user talk notification
     if ($t->getTitle()->getNamespace() == NS_USER_TALK) {
         $name = $t->getTitle()->getText();
         $user = User::newFromName($name);
         if ($user && $user->getName() != $changeUser->getName()) {
             $user->setNewtalk(true);
             $userIds[] = $user->getId();
             if ($user->getOption('enotifusertalkpages')) {
                 $notifyUsers[] = $user->getId();
             }
         }
     }
     return array('notify' => $userIds, 'email' => $notifyUsers);
 }