示例#1
0
 /**
  * Get a revision-deletion link, or disabled link, or nothing, depending
  * on user permissions & the settings on the revision.
  *
  * Will use forward-compatible revision ID in the Special:RevDelete link
  * if possible, otherwise the timestamp-based ID which may break after
  * undeletion.
  *
  * @param User $user
  * @param Revision $rev
  * @param Revision $title
  * @return string HTML fragment
  */
 public static function getRevDeleteLink(User $user, Revision $rev, Title $title)
 {
     $canHide = $user->isAllowed('deleterevision');
     if (!$canHide && !($rev->getVisibility() && $user->isAllowed('deletedhistory'))) {
         return '';
     }
     if (!$rev->userCan(Revision::DELETED_RESTRICTED, $user)) {
         return Linker::revDeleteLinkDisabled($canHide);
         // revision was hidden from sysops
     } else {
         if ($rev->getId()) {
             // RevDelete links using revision ID are stable across
             // page deletion and undeletion; use when possible.
             $query = array('type' => 'revision', 'target' => $title->getPrefixedDBkey(), 'ids' => $rev->getId());
         } else {
             // Older deleted entries didn't save a revision ID.
             // We have to refer to these by timestamp, ick!
             $query = array('type' => 'archive', 'target' => $title->getPrefixedDBkey(), 'ids' => $rev->getTimestamp());
         }
         return Linker::revDeleteLink($query, $rev->isDeleted(Revision::DELETED_RESTRICTED), $canHide);
     }
 }
 /**
  * @brief Adjusting Special:Contributions
  *
  * @param ContribsPager $contribsPager
  * @param String $ret string passed to wgOutput
  * @param Object $row Std Object with values from database table
  *
  * @return true
  */
 public function onContributionsLineEnding(&$contribsPager, &$ret, $row)
 {
     wfProfileIn(__METHOD__);
     $app = F::app();
     if (isset($row->page_namespace) && in_array(MWNamespace::getSubject($row->page_namespace), $app->wg->WallNS)) {
         $topmarktext = '';
         $rev = new Revision($row);
         $page = $rev->getTitle();
         $page->resetArticleId($row->rev_page);
         $skin = $app->wg->User->getSkin();
         $wfMsgOptsBase = $this->getMessageOptions(null, $row, true);
         $isThread = $wfMsgOptsBase['isThread'];
         $isNew = $wfMsgOptsBase['isNew'];
         $wfMsgOptsBase['createdAt'] = Xml::element('a', array('href' => $wfMsgOptsBase['articleUrl']), $app->wg->Lang->timeanddate($app->wf->Timestamp(TS_MW, $row->rev_timestamp), true));
         if ($isNew) {
             $wfMsgOptsBase['DiffLink'] = $app->wf->Msg('diff');
         } else {
             $query = array('diff' => 'prev', 'oldid' => $row->rev_id);
             $wfMsgOptsBase['DiffLink'] = Xml::element('a', array('href' => $rev->getTitle()->getLocalUrl($query)), $app->wf->Msg('diff'));
         }
         $wallMessage = F::build('WallMessage', array($page));
         $historyLink = $wallMessage->getMessagePageUrl(true) . '?action=history';
         $wfMsgOptsBase['historyLink'] = Xml::element('a', array('href' => $historyLink), $app->wf->Msg('hist'));
         // Don't show useless link to people who cannot hide revisions
         $canHide = $app->wg->User->isAllowed('deleterevision');
         if ($canHide || $rev->getVisibility() && $app->wg->User->isAllowed('deletedhistory')) {
             if (!$rev->userCan(Revision::DELETED_RESTRICTED)) {
                 $del = $skin->revDeleteLinkDisabled($canHide);
                 // revision was hidden from sysops
             } else {
                 $query = array('type' => 'revision', 'target' => $page->getPrefixedDbkey(), 'ids' => $rev->getId());
                 $del = $skin->revDeleteLink($query, $rev->isDeleted(Revision::DELETED_RESTRICTED), $canHide);
             }
             $del .= ' ';
         } else {
             $del = '';
         }
         $ret = $del;
         if (wfRunHooks('WallContributionsLine', array(MWNamespace::getSubject($row->page_namespace), $wallMessage, $wfMsgOptsBase, &$ret))) {
             $wfMsgOpts = array($wfMsgOptsBase['articleUrl'], $wfMsgOptsBase['articleTitleTxt'], $wfMsgOptsBase['wallPageUrl'], $wfMsgOptsBase['wallPageName'], $wfMsgOptsBase['createdAt'], $wfMsgOptsBase['DiffLink'], $wfMsgOptsBase['historyLink']);
             if ($isThread && $isNew) {
                 $wfMsgOpts[7] = Xml::element('strong', array(), wfMsg('newpageletter') . ' ');
             } else {
                 $wfMsgOpts[7] = '';
             }
             $ret .= $app->wf->Msg('wall-contributions-wall-line', $wfMsgOpts);
         }
         if (!$isNew) {
             $summary = $rev->getComment();
             if (empty($summary)) {
                 $msg = $app->wf->MsgForContent($this->getMessagePrefix($row->page_namespace) . '-edit');
             } else {
                 $msg = $app->wf->MsgForContent('wall-recentchanges-summary', $summary);
             }
             $ret .= ' ' . Xml::openElement('span', array('class' => 'comment')) . $msg . Xml::closeElement('span');
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
 public function getBits()
 {
     return $this->revision->getVisibility();
 }
 /**
  * @param string $timestamp Timestamp of the recent change to occur in TS_MW format
  * @param Title $categoryTitle Title of the category a page is being added to or removed from
  * @param User $user User object of the user that made the change
  * @param string $comment Change summary
  * @param Title $pageTitle Title of the page that is being added or removed
  * @param string $lastTimestamp Parent revision timestamp of this change in TS_MW format
  * @param Revision|null $revision
  *
  * @throws MWException
  */
 private function notifyCategorization($timestamp, Title $categoryTitle, User $user = null, $comment, Title $pageTitle, $lastTimestamp, $revision)
 {
     $deleted = $revision ? $revision->getVisibility() & Revision::SUPPRESSED_USER : 0;
     $newRevId = $revision ? $revision->getId() : 0;
     /**
      * T109700 - Default bot flag to true when there is no corresponding RC entry
      * This means all changes caused by parser functions & Lua on reparse are marked as bot
      * Also in the case no RC entry could be found due to replica DB lag
      */
     $bot = 1;
     $lastRevId = 0;
     $ip = '';
     # If no revision is given, the change was probably triggered by parser functions
     if ($revision !== null) {
         $correspondingRc = $this->revision->getRecentChange();
         if ($correspondingRc === null) {
             $correspondingRc = $this->revision->getRecentChange(Revision::READ_LATEST);
         }
         if ($correspondingRc !== null) {
             $bot = $correspondingRc->getAttribute('rc_bot') ?: 0;
             $ip = $correspondingRc->getAttribute('rc_ip') ?: '';
             $lastRevId = $correspondingRc->getAttribute('rc_last_oldid') ?: 0;
         }
     }
     /** @var RecentChange $rc */
     $rc = call_user_func_array($this->newForCategorizationCallback, [$timestamp, $categoryTitle, $user, $comment, $pageTitle, $lastRevId, $newRevId, $lastTimestamp, $bot, $ip, $deleted]);
     $rc->save();
 }
示例#5
0
 /**
  * Get a revision-deletion link, or disabled link, or nothing, depending
  * on user permissions & the settings on the revision.
  *
  * Will use forward-compatible revision ID in the Special:RevDelete link
  * if possible, otherwise the timestamp-based ID which may break after
  * undeletion.
  *
  * @param Revision $rev
  * @return string HTML fragment
  */
 function revDeleteLink($rev)
 {
     $canHide = $this->getUser()->isAllowed('deleterevision');
     if ($canHide || $rev->getVisibility() && $this->getUser()->isAllowed('deletedhistory')) {
         if (!$rev->userCan(Revision::DELETED_RESTRICTED)) {
             $revdlink = Linker::revDeleteLinkDisabled($canHide);
             // revision was hidden from sysops
         } else {
             if ($rev->getId()) {
                 // RevDelete links using revision ID are stable across
                 // page deletion and undeletion; use when possible.
                 $query = array('type' => 'revision', 'target' => $this->mTargetObj->getPrefixedDBkey(), 'ids' => $rev->getId());
             } else {
                 // Older deleted entries didn't save a revision ID.
                 // We have to refer to these by timestamp, ick!
                 $query = array('type' => 'archive', 'target' => $this->mTargetObj->getPrefixedDBkey(), 'ids' => $rev->getTimestamp());
             }
             return Linker::revDeleteLink($query, $rev->isDeleted(File::DELETED_RESTRICTED), $canHide);
         }
     } else {
         return '';
     }
 }