public function actionMarkRead($threads, $params)
 {
     global $wgUser;
     $result = array();
     if (in_array('all', $threads)) {
         NewMessages::markAllReadByUser($wgUser);
         $result[] = array('result' => 'Success', 'action' => 'markread', 'threads' => 'all');
     } else {
         foreach ($threads as $t) {
             NewMessages::markThreadAsReadByUser($t, $wgUser);
             $result[] = array('result' => 'Success', 'action' => 'markread', 'id' => $t->id(), 'title' => $t->title()->getPrefixedText());
         }
     }
     $this->getResult()->setIndexedTagName($result, 'thread');
     $this->getResult()->addValue(null, 'threadactions', $result);
 }
Esempio n. 2
0
 public function actionMarkRead($threads, $params)
 {
     $user = $this->getUser();
     $result = array();
     if (in_array('all', $threads)) {
         NewMessages::markAllReadByUser($user);
         $result[] = array('result' => 'Success', 'action' => 'markread', 'threads' => 'all', 'unreadlink' => array('href' => SpecialPage::getTitleFor('NewMessages')->getLocalURL(), 'text' => wfMessage('lqt_newmessages')->text(), 'active' => false));
     } else {
         foreach ($threads as $t) {
             NewMessages::markThreadAsReadByUser($t, $user);
             $result[] = array('result' => 'Success', 'action' => 'markread', 'id' => $t->id(), 'title' => $t->title()->getPrefixedText());
         }
         $newMessagesCount = NewMessages::newMessageCount($user, DB_MASTER);
         $result[count($result) - 1]['unreadlink'] = array('href' => SpecialPage::getTitleFor('NewMessages')->getLocalURL(), 'text' => wfMessage($newMessagesCount ? 'lqt-newmessages-n' : 'lqt_newmessages')->numParams($newMessagesCount)->text(), 'active' => $newMessagesCount > 0);
     }
     $this->getResult()->setIndexedTagName($result, 'thread');
     $this->getResult()->addValue(null, 'threadactions', $result);
 }
 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));
     }
 }