public function messageDeleted()
 {
     $id = $this->app->wg->Title->getText();
     $wm = WallMessage::newFromId($id);
     if (empty($wm)) {
         $this->response->setVal('wallOwner', '');
         $this->response->setVal('wallUrl', '');
     } else {
         $user = $wm->getWallOwner();
         $user_displayname = $user->getName();
         $this->response->setVal('wallOwner', $user_displayname);
         $this->response->setVal('wallUrl', $wm->getArticleTitle()->getFullURL());
         $this->response->setVal('showViewLink', $wm->canViewDeletedMessage($this->app->wg->User));
         $this->response->setVal('viewUrl', $this->app->wg->Title->getFullUrl('show=1'));
         $this->response->setVal('returnTo', wfMsg('wall-deleted-msg-return-to', $user_displayname));
         wfRunHooks('WallMessageDeleted', array(&$wm, &$this->response));
     }
 }
示例#2
0
 public function getThreadMainMsg()
 {
     return WallMessage::newFromId($this->mThreadId);
 }
示例#3
0
 public function getLastMessage()
 {
     $key = wfMemcKey(__CLASS__, '-thread-lastreply-key', $this->mThreadId);
     $threadId = $this->mThreadId;
     $data = WikiaDataAccess::cache($key, 30 * 24 * 60 * 60, function () use($threadId) {
         $db = wfGetDB(DB_SLAVE);
         $row = $db->selectRow(array('comments_index'), array('max(first_rev_id) rev_id'), array('parent_comment_id' => $threadId, 'archived' => 0, 'deleted' => 0, 'removed' => 0), __METHOD__);
         return $row;
     });
     // get last post info
     $revision = Revision::newFromId($data->rev_id);
     if ($revision instanceof Revision) {
         $title = $revision->getTitle();
         $wallMessage = WallMessage::newFromId($title->getArticleId());
         if (!empty($wallMessage)) {
             $wallMessage->load();
             return $wallMessage;
         }
     }
     return null;
 }
 public static function onChangesListItemGroupRegular(&$link, &$rcObj)
 {
     if (WallHelper::isWallNamespace(intval($rcObj->getAttribute('rc_namespace')))) {
         $wallMsg = WallMessage::newFromId($rcObj->getAttribute('rc_cur_id'));
         if (!empty($wallMsg)) {
             /* @var $wallMsg Wall */
             $url = $wallMsg->getMessagePageUrl();
             $link = '<a href="' . $url . '">' . $rcObj->timestamp . '</a>';
             $rcObj->curlink = '<a href="' . $url . '">' . wfMessage('cur')->escaped() . '</a>';
         }
     }
     return true;
 }
示例#5
0
 protected function formatData($row)
 {
     $user = null;
     if ($row['post_user_id'] > 0) {
         $user = User::newFromID($row['post_user_id']);
     } else {
         $user = User::newFromName($this->long2ip($row['post_user_ip']), false);
     }
     $message = WallMessage::newFromId($row['page_id']);
     if (empty($message)) {
         return;
     }
     $title = $message->getTitle();
     if ($title instanceof Title && $message instanceof WallMessage) {
         return array('user' => $user, 'event_date' => $row['event_date'], 'event_iso' => wfTimestamp(TS_ISO_8601, $row['event_date']), 'event_mw' => wfTimestamp(TS_MW, $row['event_date']), 'display_username' => $user->getId() == 0 ? wfMsg('oasis-anon-user') : $user->getName(), 'metatitle' => $row['metatitle'], 'page_id' => $row['page_id'], 'title' => $title, 'is_reply' => $row['is_reply'], 'action' => $row['action'], 'reason' => $row['reason'], 'revision_id' => $row['revision_id'], 'wall_message' => $message);
     } else {
         //it happened once on devbox when master&slave weren't sync'ed
         wfDebug(__METHOD__ . ": Seems like master&slave are not sync'ed\n");
     }
 }
示例#6
0
$history = new WallHistory();
$dbw = $history->getDatawareDB();
$res = $dbw->select('wall_history', array('post_user_id', 'post_user_ip', 'is_reply', 'post_ns', 'page_id', 'parent_page_id', 'metatitle', 'deleted_or_removed', 'event_date', 'reason', 'action', 'revision_id', 'deleted_or_removed'), array('migrated' => 0, 'wiki_id' => $wgCityId), __METHOD__);
$in = array();
$db = $history->getDB(DB_MASTER);
$dir = dirname(__FILE__);
if (!$db->tableExists('wall_history')) {
    echo "Try to create table\\'n";
    $db->sourceFile($IP . "/extensions/wikia/Wall/sql/wall_history_local.sql");
}
while ($row = $dbw->fetchRow($res)) {
    if ($row['action'] == WH_NEW || $row['action'] == WH_EDIT) {
        $pagesRow = $db->selectRow('revision', array('rev_timestamp'), array('rev_id' => $row['revision_id']));
        $row['event_date'] = wfTimestamp(TS_DB, $pagesRow->rev_timestamp);
    }
    $mw = WallMessage::newFromId($row['page_id']);
    if (empty($mw)) {
        continue;
    }
    /*	$history->internalAdd( 
    	$parentPageId, 
    	$postUserId, 
    	$postUserName, $
    	isReply, $commentId, $ns, $parentCommentId, $metatitle, $action, $reason, $revId, $deletedOrRemoved );
    */
    if ($mw->isMain()) {
        $parentCommentId = $row['page_id'];
        $commentId = $row['page_id'];
    } else {
        $parentCommentId = $row['parent_page_id'];
        $commentId = $row['page_id'];
 /**
  * Updates topics list to given message id.  It will completely override.
  * @param string $messageId - numeric id
  * @param array $relatedTopics - list of topics (article names)
  * @return string status - success/failure
  */
 public function updateTopics()
 {
     $messageId = $this->request->getVal('msgid', '');
     $relatedTopics = $this->request->getVal('relatedTopics', array());
     // place holder data, replace this with magic
     $status = 'success';
     $topics = array();
     if (!is_array($relatedTopics)) {
         $relatedTopics = array();
     }
     // cut more then 4
     $relatedTopics = array_slice($relatedTopics, 0, 4);
     // save
     /**
      * @var $mw WallMessage
      */
     $mw = WallMessage::newFromId($messageId);
     if (!empty($mw)) {
         $mw->load();
         $mw->setRelatedTopics($this->wg->User, $relatedTopics);
     }
     foreach ($relatedTopics as $topic) {
         $topicTitle = Title::newFromURL($topic);
         $topics[] = array('topic' => $topic, 'url' => WallHelper::getTopicPageURL($topicTitle));
         // I have no idea what the url will be, just a placeholder for now
     }
     // end place holder
     $this->response->setVal('status', $status);
     $this->response->setVal('topics', $topics);
 }
示例#8
0
 /**
  * Provided a page, returns the string value of that page's title
  * This allows us to accommodate unconventional locations for titles
  * @param \Title $title
  * @return string
  */
 protected function getTitleString(\Title $title)
 {
     wfProfileIn(__METHOD__);
     if (in_array($title->getNamespace(), array(NS_WIKIA_FORUM_BOARD_THREAD, NS_USER_WALL_MESSAGE))) {
         $wm = \WallMessage::newFromId($title->getArticleID());
         if ($wm) {
             $wm->load();
             if (!$wm->isMain() && ($main = $wm->getTopParentObj()) && !empty($main)) {
                 $main->load();
                 $wm = $main;
             }
             wfProfileOut(__METHOD__);
             return (string) $wm->getMetaTitle();
         } else {
             \Wikia\Logger\WikiaLogger::instance()->warning('Null WallMessage', ['message_id' => $title->getArticleID()]);
         }
     }
     wfProfileOut(__METHOD__);
     return $title->getFullText();
 }
 public function forumRelatedThreads()
 {
     $title = F::build('Title', array($this->app->wg->Title->getText()), 'newFromId');
     $this->response->setVal('showModule', false);
     if (!empty($title) && $title->getNamespace() == NS_WIKIA_FORUM_BOARD_THREAD) {
         $rp = new WallRelatedPages();
         $out = $rp->getMessageRelatetMessageIds(array($title->getArticleId()));
         $messages = array();
         $count = 0;
         foreach ($out as $key => $val) {
             if ($title->getArticleId() == $val['comment_id']) {
                 continue;
             }
             $msg = WallMessage::newFromId($val['comment_id']);
             if (!empty($msg)) {
                 $msg->load();
                 $message = array('message' => $msg);
                 if (!empty($val['last_child'])) {
                     $childMsg = WallMessage::newFromId($val['last_child']);
                     if (!empty($childMsg)) {
                         $childMsg->load();
                         $message['reply'] = $childMsg;
                     }
                 }
                 $messages[] = $message;
                 $count++;
                 if ($count == 5) {
                     break;
                 }
             }
         }
         $this->response->setVal('showModule', !empty($messages));
         $this->response->setVal('messages', $messages);
     }
 }
示例#10
0
 public function setQuoteOf($id)
 {
     if ($this->isMain()) {
         return false;
     }
     $msgParent = $this->getTopParentObj();
     /**
      * @var $quotedMsg WallMessage
      */
     $quotedMsg = WallMessage::newFromId($id, true);
     if (empty($quotedMsg)) {
         return false;
     }
     if ($quotedMsg->isMain()) {
         if ($quotedMsg->getId() != $msgParent->getId()) {
             return false;
         }
     } else {
         $quotedMsgParent = $quotedMsg->getTopParentObj();
         if ($quotedMsgParent->getId() != $msgParent->getId()) {
             return false;
         }
     }
     $this->setInProps(WPP_WALL_QUOTE_OF, $id);
     return true;
 }
示例#11
0
 /**
  * @param null $rc
  * @param array $row [ page_title, page_namespace, rev_user_text?, page_is_new?, rev_parent_id? ]
  * @return array|bool
  */
 public static function getWallTitleData($rc = null, $row = null)
 {
     wfProfileIn(__METHOD__);
     if (is_object($row)) {
         $objTitle = Title::newFromText($row->page_title, $row->page_namespace);
         $userText = !empty($row->rev_user_text) ? $row->rev_user_text : '';
         $isNew = !empty($row->page_is_new) && $row->page_is_new === '1' ? true : false;
         if (!$isNew) {
             $isNew = isset($row->rev_parent_id) && $row->rev_parent_id === '0' ? true : false;
         }
     } else {
         $objTitle = $rc->getTitle();
         $userText = $rc->getAttribute('rc_user_text');
         $isNew = false;
         // it doesn't metter for rc -- we've got there rc_log_action
     }
     if (!$objTitle instanceof Title) {
         // it can be media wiki deletion of an article -- we ignore them
         Wikia::log(__METHOD__, false, "WALL_NOTITLE_FOR_MSG_OPTS " . print_r(array($rc, $row), true));
         wfProfileOut(__METHOD__);
         return true;
     }
     $wm = WallMessage::newFromId($objTitle->getArticleId());
     if (empty($wm)) {
         // it can be media wiki deletion of an article -- we ignore them
         Wikia::log(__METHOD__, false, "WALL_NOTITLE_FOR_MSG_OPTS " . print_r(array($rc, $row), true));
         wfProfileOut(__METHOD__);
         return true;
     }
     $wm->load();
     if (!$wm->isMain()) {
         $wmw = $wm->getTopParentObj();
         if (empty($wmw)) {
             wfProfileOut(__METHOD__);
             return true;
         }
         $wmw->load();
     }
     if (!empty($wmw)) {
         $articleTitleTxt = $wmw->getMetaTitle();
         $articleId = $wmw->getId();
     } else {
         $articleTitleTxt = $wm->getMetaTitle();
         $articleId = $wm->getId();
     }
     // XSS vulnerable (MAIN-1412)
     if (!empty($articleTitleTxt)) {
         $articleTitleTxt = strip_tags($articleTitleTxt);
     }
     $ci = $wm->getCommentsIndex();
     if (empty($ci) && $row->page_namespace == NS_USER_WALL) {
         // change in NS_USER_WALL namespace mean that wall page was created (bugid:95249)
         $title = Title::newFromText($row->page_title, NS_USER_WALL);
         $out = array('articleTitle' => $title->getPrefixedText(), 'articleFullUrl' => $title->getFullUrl(), 'articleTitleVal' => '', 'articleTitleTxt' => wfMessage('wall-recentchanges-wall-created-title')->text(), 'wallTitleTxt' => $title->getPrefixedText(), 'wallPageFullUrl' => $title->getFullUrl(), 'wallPageName' => $row->page_title, 'actionUser' => $userText, 'isThread' => $wm->isMain(), 'isNew' => $isNew);
     } else {
         $title = Title::newFromText($articleId, NS_USER_WALL_MESSAGE);
         $out = array('articleTitle' => $title->getPrefixedText(), 'articleFullUrl' => $wm->getMessagePageUrl(), 'articleTitleVal' => $articleTitleTxt, 'articleTitleTxt' => empty($articleTitleTxt) ? wfMessage('wall-recentchanges-deleted-reply-title')->text() : $articleTitleTxt, 'wallTitleTxt' => $wm->getArticleTitle()->getPrefixedText(), 'wallPageFullUrl' => $wm->getArticleTitle()->getFullUrl(), 'wallPageName' => $wm->getArticleTitle()->getText(), 'actionUser' => $userText, 'isThread' => $wm->isMain(), 'isNew' => $isNew);
     }
     wfProfileOut(__METHOD__);
     return $out;
 }
 /**
  * This method does the brunt of the work for populating an array with the values
  * we need when servicing the backend search indexer processes
  * @see WikiaSearchIndexer::getPages()
  * @see WikiaSearchController::getPage()
  * @param int $pageId
  * @throws WikiaException
  * @return array result
  */
 public function getPage($pageId)
 {
     wfProfileIn(__METHOD__);
     $result = array();
     $page = F::build('Article', array($pageId), 'newFromID');
     if (!$page instanceof Article) {
         throw new WikiaException('Invalid Article ID');
     }
     if (!$this->parserHookActive) {
         $this->app->registerHook('ParserClearState', 'WikiaSearchIndexer', 'onParserClearState');
         $this->parserHookActive = true;
     }
     // hack: setting wgTitle as rendering fails otherwise
     $wgTitle = $this->wg->Title;
     $this->wg->Title = $page->getTitle();
     // hack: setting action=render to exclude "Related Pages" and other unwanted stuff
     $wgRequest = $this->wg->Request;
     $this->wg->Request->setVal('action', 'render');
     if ($page->isRedirect()) {
         $redirectPage = F::build('Article', array($page->getRedirectTarget()));
         $redirectPage->loadContent();
         // hack: setting wgTitle as rendering fails otherwise
         $this->wg->Title = $page->getRedirectTarget();
         $redirectPage->render();
         $canonical = $page->getRedirectTarget()->getPrefixedText();
     } else {
         $page->render();
         $canonical = '';
     }
     $html = $this->wg->Out->getHTML();
     $namespace = $this->wg->Title->getNamespace();
     $isVideo = false;
     $isImage = false;
     if ($namespace == NS_FILE && ($file = $this->wf->findFile($this->wg->Title->getText()))) {
         $detail = WikiaFileHelper::getMediaDetail($this->wg->Title);
         $isVideo = WikiaFileHelper::isVideoFile($file);
         $isImage = $detail['mediaType'] == 'image' && !$isVideo;
         $metadata = $file->getMetadata();
         if ($metadata !== "0") {
             $metadata = unserialize($metadata);
             $fileParams = array('description', 'keywords') + ($isVideo ? array('movieTitleAndYear', 'videoTitle') : array());
             foreach ($fileParams as $datum) {
                 $html .= isset($metadata[$datum]) ? ' ' . $metadata[$datum] : '';
             }
         }
     }
     $title = $page->getTitle()->getText();
     if (in_array($namespace, array(NS_WIKIA_FORUM_BOARD_THREAD, NS_USER_WALL_MESSAGE))) {
         $wm = WallMessage::newFromId($page->getId());
         $wm->load();
         if ($wm->isMain()) {
             $title = $wm->getMetaTitle();
         } else {
             if ($main = $wm->getTopParentObj() and !empty($main)) {
                 $main->load();
                 $title = $main->getMetaTitle();
             }
         }
     }
     // clear output buffer in case we want get more pages
     $this->wg->Out->clearHTML();
     $result['wid'] = empty($this->wg->ExternalSharedDB) ? $this->wg->SearchWikiId : (int) $this->wg->CityId;
     $result['pageid'] = $pageId;
     $result['id'] = $result['wid'] . '_' . $result['pageid'];
     $result['title'] = $title;
     $result['canonical'] = $canonical;
     $result['html'] = html_entity_decode($html, ENT_COMPAT, 'UTF-8');
     $result['url'] = $page->getTitle()->getFullUrl();
     $result['ns'] = $page->getTitle()->getNamespace();
     $result['host'] = substr($this->wg->Server, 7);
     $result['lang'] = $this->wg->Lang->mCode;
     # these need to be strictly typed as bool strings since they're passed via http when in the hands of the worker
     $result['iscontent'] = in_array($result['ns'], $this->wg->ContentNamespaces) ? 'true' : 'false';
     $result['is_main_page'] = $page->getId() == Title::newMainPage()->getArticleId() && $page->getId() != 0 ? 'true' : 'false';
     $result['is_redirect'] = $canonical == '' ? 'false' : 'true';
     $result['is_video'] = $isVideo ? 'true' : 'false';
     $result['is_image'] = $isImage ? 'true' : 'false';
     if ($this->wg->EnableBacklinksExt && $this->wg->IndexBacklinks) {
         $result['backlink_text'] = Backlinks::getForArticle($page);
     }
     $result = array_merge($result, $this->getPageMetaData($page));
     // restore global state
     $this->wg->Title = $wgTitle;
     $this->wg->Request = $wgRequest;
     wfProfileOut(__METHOD__);
     return $result;
 }