public function thread()
 {
     wfProfileIn(__METHOD__);
     $this->addAsset();
     $title = $this->request->getVal('title', $this->app->wg->Title);
     $id = $this->request->getVal('id', null);
     $this->getThread($id);
     $this->response->setVal('showNewMessage', false);
     $this->response->setVal('type', 'Thread');
     $this->response->setVal('condenseMessage', false);
     if (count($this->threads) > 0) {
         $wn = new WallNotifications();
         foreach ($this->threads as $key => $val) {
             $all = $wn->markRead($this->wg->User->getId(), $this->wg->CityId, $key);
             break;
         }
     }
     $this->response->setVal('renderUserTalkArchiveAnchor', false);
     $this->response->setVal('greeting', '');
     $title = Title::newFromId($id);
     if (!empty($title) && $title->exists() && in_array(MWNamespace::getSubject($title->getNamespace()), $this->app->wg->WallNS)) {
         $wallMessage = WallMessage::newFromTitle($title);
         $wallMessage->load();
         $this->app->wg->Out->setPageTitle($wallMessage->getMetaTitle());
     }
     // TODO: keep the varnish cache and do purging on post
     $this->response->setCacheValidity(WikiaResponse::CACHE_DISABLED);
     wfProfileOut(__METHOD__);
 }
 public function markAsRead()
 {
     global $wgUser, $wgCityId;
     $id = $this->request->getVal('id');
     $wn = new WallNotifications();
     $ret = $wn->markRead($wgUser->getId(), $wgCityId, $id);
     $this->response->setVal('wasUnread', $ret);
     $this->response->setVal('status', true);
     return true;
 }
 public function replyToMessage()
 {
     $this->response->setVal('status', true);
     $parentId = $this->request->getVal('parent');
     $parentTitle = Title::newFromId($parentId);
     $debugParentDB = 'from slave';
     // tracing bug 95249
     if (empty($parentTitle)) {
         // try again from master
         $parentTitle = Title::newFromId($parentId, Title::GAID_FOR_UPDATE);
         $debugParentDB = 'from master';
     }
     if (empty($parentTitle)) {
         $this->response->setVal('status', false);
         return true;
     }
     Wikia::log(__METHOD__, false, 'Wall::replyToMessage for parent ' . $parentTitle->getFullUrl() . ' (parentId: ' . $parentId . ') ' . $debugParentDB, true);
     /**
      * @var $wallMessage WallMessage
      */
     $wallMessage = WallMessage::newFromTitle($parentTitle);
     $body = $this->getConvertedContent($this->request->getVal('body'));
     $reply = $wallMessage->addNewReply($body, $this->wg->User);
     if ($reply === false) {
         $this->response->setVal('status', false);
         return true;
     }
     $quotedFrom = $this->request->getVal('quotedFrom');
     if (!empty($quotedFrom)) {
         $reply->setQuoteOf($quotedFrom);
     }
     $this->replyToMessageBuildResponse($this, $reply);
     // after successfully posting a reply
     // remove notification for this thread (if user is following it)
     /**
      * @var $wn WallNotifications
      */
     $wn = new WallNotifications();
     $wn->markRead($this->wg->User->getId(), $this->wg->CityId, $this->request->getVal('parent'));
 }