/**
  * Render the special page boddy
  * @param string $par The username
  */
 public function executeWhenAvailable($par = '')
 {
     $this->offset = $this->getRequest()->getVal('offset', false);
     if ($par) {
         // enter article history view
         $this->user = User::newFromName($par, false);
         if ($this->user && ($this->user->idForName() || User::isIP($par))) {
             // set page title as on desktop site - bug 66656
             $username = $this->user->getName();
             $out = $this->getOutput();
             $out->addModuleStyles(array('mobile.pagelist.styles', 'mobile.pagesummary.styles'));
             $out->setHTMLTitle($this->msg('pagetitle', $this->msg('contributions-title', $username)->plain())->inContentLanguage());
             if (User::isIP($par)) {
                 $this->renderHeaderBar($par);
             } else {
                 $this->renderHeaderBar($this->user->getUserPage());
             }
             $res = $this->doQuery();
             $out->addHtml(Html::openElement('div', array('class' => 'content-unstyled')));
             $this->showContributions($res);
             $out->addHtml(Html::closeElement('div'));
             return;
         }
     }
     $this->showPageNotFound();
 }
 /**
  * Get the footer with user information (when joined, how
  * many edits/uploads, visit user page and talk page)
  * @return string
  */
 protected function getUserFooterData()
 {
     $fromDate = $this->targetUser->getRegistration();
     $ts = new MWTimestamp(wfTimestamp(TS_UNIX, $fromDate));
     $diff = $ts->diff(new MWTimestamp());
     if ($fromDate === null) {
         // User was registered in pre-historic times when registration wasn't recorded
         $msg = 'mobile-frontend-profile-footer-ancient';
         $units = 0;
         $fromDate = '20010115000000';
         // No users before that date
     } elseif ($diff->y) {
         $msg = 'mobile-frontend-profile-footer-years';
         $units = $diff->y;
     } elseif ($diff->m) {
         $msg = 'mobile-frontend-profile-footer-months';
         $units = $diff->m;
     } else {
         $msg = 'mobile-frontend-profile-footer-days';
         $units = $diff->d;
     }
     $editCount = $this->targetUser->getEditCount();
     $uploadCount = $this->userInfo->countRecentUploads($fromDate);
     // Ensure that the upload count is compatible with the i18n message
     if ($uploadCount > 500) {
         $uploadCount = 500;
     }
     $username = $this->targetUser->getName();
     return array('editsSummary' => $this->msg($msg, $username)->numParams($units, $editCount, $uploadCount)->parse(), 'linkUserPage' => Linker::link($this->targetUser->getUserPage(), $this->msg('mobile-frontend-profile-userpage-link', $username)->escaped()), 'linkTalk' => $this->getTalkLink());
 }
 public function execute($par)
 {
     $out = $this->getOutput();
     $out->addModuleStyles('mediawiki.special');
     $this->mTarget = is_null($par) ? $this->getRequest()->getVal('wpTarget', $this->getRequest()->getVal('target', '')) : $par;
     // This needs to be below assignment of $this->mTarget because
     // getDescription() needs it to determine the correct page title.
     $this->setHeaders();
     $this->outputHeader();
     // error out if sending user cannot do this
     $error = self::getPermissionsError($this->getUser(), $this->getRequest()->getVal('wpEditToken'));
     switch ($error) {
         case null:
             # Wahey!
             break;
         case 'badaccess':
             throw new PermissionsError('sendemail');
         case 'blockedemailuser':
             throw new UserBlockedError($this->getUser()->mBlock);
         case 'actionthrottledtext':
             throw new ThrottledError();
         case 'mailnologin':
         case 'usermaildisabled':
             throw new ErrorPageError($error, "{$error}text");
         default:
             # It's a hook error
             list($title, $msg, $params) = $error;
             throw new ErrorPageError($title, $msg, $params);
     }
     // Got a valid target user name? Else ask for one.
     $ret = self::getTarget($this->mTarget);
     if (!$ret instanceof User) {
         if ($this->mTarget != '') {
             $ret = $ret == 'notarget' ? 'emailnotarget' : $ret . 'text';
             $out->wrapWikiMsg("<p class='error'>\$1</p>", $ret);
         }
         $out->addHTML($this->userForm($this->mTarget));
         return false;
     }
     $this->mTargetObj = $ret;
     $context = new DerivativeContext($this->getContext());
     $context->setTitle($this->getPageTitle());
     // Remove subpage
     $form = new HTMLForm($this->getFormFields(), $context);
     // By now we are supposed to be sure that $this->mTarget is a user name
     $form->addPreText($this->msg('emailpagetext', $this->mTarget)->parse());
     $form->setSubmitTextMsg('emailsend');
     $form->setSubmitCallback(array(__CLASS__, 'uiSubmit'));
     $form->setWrapperLegendMsg('email-legend');
     $form->loadData();
     if (!wfRunHooks('EmailUserForm', array(&$form))) {
         return false;
     }
     $result = $form->show();
     if ($result === true || $result instanceof Status && $result->isGood()) {
         $out->setPageTitle($this->msg('emailsent'));
         $out->addWikiMsg('emailsenttext', $this->mTarget);
         $out->returnToMain(false, $this->mTargetObj->getUserPage());
     }
 }
 /**
  * Deletes a user page if it exists.
  * This is needed especially when deleting sandbox users
  * that were created as part of the integration tests.
  * @param User $user
  */
 protected function deleteUserPage($user)
 {
     $userpage = WikiPage::factory($user->getUserPage());
     if ($userpage->exists()) {
         $dummyError = '';
         $userpage->doDeleteArticleReal(wfMessage('tsb-delete-userpage-summary')->inContentLanguage()->text(), false, 0, true, $dummyError, $this->getUser());
     }
 }
 protected function invalidateCache()
 {
     $title = $this->user->getUserPage();
     $title->invalidateCache();
     $title->purgeSquid();
     $article = new Article($title);
     $article->doPurge();
 }
 function __construct(User $userObj, $score, $currentRanking = null, $previousRanking = null)
 {
     wfProfileIn(__METHOD__);
     $this->mUserId = $userObj->getID();
     $this->mUsername = $userObj->getName();
     $this->mScore = $score;
     $this->mUserPageUrl = $userObj->getUserPage()->getLocalURL();
     $this->mCurrentRanking = $currentRanking;
     $this->mPreviousRanking = $previousRanking;
     wfProfileOut(__METHOD__);
 }
 /**
  * This method actually generates the output
  * @param array $params List of parameters
  * @return string HTML output
  */
 public function execute($params = false)
 {
     if ($this->oUser instanceof User === false) {
         $this->oUser = User::newFromName($this->sUserName);
     }
     //In some rare cases (LDAPAuth + special characters in username)
     //the username isn't saved correctly to the DB, causing '
     //User::newFromName' to return false.
     //TODO: Find and fix real issue
     if ($this->oUser instanceof User === false) {
         return '';
     }
     if (empty($this->sUserDisplayName)) {
         $this->sUserDisplayName = $this->oUser->getName();
     }
     $aOut = array();
     $aOut[] = '<li>';
     $aOut[] = Linker::link($this->oUser->getUserPage(), $this->sUserDisplayName);
     $aOut[] = '</li>';
     return implode("", $aOut);
 }
 /**
  * Generate user page content for non-existent user pages
  *
  * @param OutputPage $output
  * @param User $pageUser owner of the user page
  * @return string
  */
 public static function getUserPageContent($output, $pageUser)
 {
     $context = MobileContext::singleton();
     $pageUsername = $pageUser->getName();
     // Is the current user viewing their own page?
     $isCurrentUser = $output->getUser()->getName() === $pageUsername;
     $data['ctaHeading'] = $isCurrentUser ? $context->msg('mobile-frontend-user-page-no-owner-page-yet')->text() : $context->msg('mobile-frontend-user-page-no-page-yet', $pageUsername)->parse();
     $data['ctaDescription'] = $isCurrentUser ? $context->msg('mobile-frontend-user-page-describe-yourself', $context->msg('mobile-frontend-user-page-describe-yourself-editors')->text())->text() : $context->msg('mobile-frontend-user-page-desired-action', $pageUsername)->parse();
     $data['createPageLinkLabel'] = $isCurrentUser ? $context->msg('mobile-frontend-user-page-create-owner-page-link-label')->text() : $context->msg('mobile-frontend-user-page-create-user-page-link-label', $pageUser->getUserPage()->getBaseTitle())->parse();
     $data['createPageLinkAdditionalClasses'] = $isCurrentUser ? 'mw-ui-button' : '';
     $templateParser = new TemplateParser(__DIR__);
     return $templateParser->processTemplate('user_page_cta', $data);
 }
 /**
  * Render the special page boddy
  * @param string $par The username
  */
 public function executeWhenAvailable($par = '')
 {
     $this->offset = $this->getRequest()->getVal('offset', false);
     if ($par) {
         // enter article history view
         $this->user = User::newFromName($par, false);
         if ($this->user && ($this->user->idForName() || User::isIP($par))) {
             // set page title as on desktop site - bug 66656
             $username = $this->user->getName();
             $out = $this->getOutput();
             $out->setHTMLTitle($this->msg('pagetitle', $this->msg('contributions-title', $username)->plain())->inContentLanguage());
             if (User::isIP($par)) {
                 $this->renderHeaderBar($par);
             } else {
                 $this->renderHeaderBar($this->user->getUserPage());
             }
             $res = $this->doQuery();
             $this->showContributions($res);
             return;
         }
     }
     $this->showPageNotFound();
 }
 /**
  * Queue up jobs to move pages
  */
 public function movePages(User $oldUser)
 {
     $from = $this->params['from'];
     $to = $this->params['to'];
     $fromTitle = $oldUser->getUserPage();
     $toTitle = Title::makeTitleSafe(NS_USER, $to);
     $dbr = wfGetDB(DB_SLAVE);
     $rows = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace IN (' . NS_USER . ',' . NS_USER_TALK . ')', '(page_title ' . $dbr->buildLike($fromTitle->getDBkey() . '/', $dbr->anyString()) . ' OR page_title = ' . $dbr->addQuotes($fromTitle->getDBkey()) . ')'), __METHOD__);
     $jobParams = array('to' => $to, 'from' => $from, 'renamer' => $this->getRenameUser()->getName(), 'suppressredirects' => $this->params['suppressredirects']);
     if (isset($this->params['session'])) {
         $jobParams['session'] = $this->params['session'];
     }
     $jobs = array();
     foreach ($rows as $row) {
         $oldPage = Title::newFromRow($row);
         $newPage = Title::makeTitleSafe($row->page_namespace, preg_replace('!^[^/]+!', $toTitle->getDBkey(), $row->page_title));
         $jobs[] = new LocalPageMoveJob(Title::newFromText('LocalRenameUserJob'), $jobParams + array('old' => array($oldPage->getNamespace(), $oldPage->getDBkey()), 'new' => array($newPage->getNamespace(), $newPage->getDBkey())));
     }
     JobQueueGroup::singleton()->push($jobs);
 }
 private function awardNotInTrackBadge($badge_type_id, $badge_lap = null)
 {
     wfProfileIn(__METHOD__);
     global $wgRequest;
     // can be platinum or static
     $notInTrackStatic = AchConfig::getInstance()->getNotInTrackStatic();
     if (isset($notInTrackStatic[$badge_type_id])) {
         $badge_level = $notInTrackStatic[$badge_type_id]['level'];
     } else {
         $badge_level = BADGE_LEVEL_PLATINUM;
     }
     $this->mNewBadges[] = array('badge_type_id' => $badge_type_id, 'badge_lap' => $badge_lap, 'badge_level' => $badge_level);
     if (!isset($this->mBadges[$badge_type_id])) {
         $this->mBadges[$badge_type_id] = 0;
     }
     $this->mBadges[$badge_type_id]++;
     if ($badge_type_id == BADGE_WELCOME) {
         if (!isMsgEmpty('welcome-user-page')) {
             $userPageTitle = $this->mUser->getUserPage();
             if ($userPageTitle) {
                 $userPageArticle = new Article($userPageTitle, 0);
                 if (!$userPageArticle->exists()) {
                     $userWikia = User::newFromName('Wikia');
                     //#60032: forcing IP for bot since this code is run in a real user session and not from a maintenance script
                     $origIP = $wgRequest->getIP();
                     $wgRequest->setIP('127.0.0.1');
                     //fixme. following functionality is done by HAWelcome extension...
                     $userPageArticle->doEdit(wfMsgForContentNoTrans('welcome-user-page', $userPageTitle->getText()), '', $userWikia->isAllowed('bot') ? EDIT_FORCE_BOT : 0, false, $userWikia);
                     //restore original IP from user session
                     $wgRequest->setIP($origIP);
                 }
             }
         }
     }
     wfProfileOut(__METHOD__);
 }
Example #12
0
 /**
  * Get a link to $user's user page
  * @param User $user
  * @return string Html
  */
 protected function link(User $user)
 {
     if ($this->canShowRealUserName() && !$user->isAnon()) {
         $real = $user->getRealName();
     } else {
         $real = false;
     }
     $page = $user->isAnon() ? SpecialPage::getTitleFor('Contributions', $user->getName()) : $user->getUserPage();
     return Linker::link($page, htmlspecialchars($real ? $real : $user->getName()));
 }
Example #13
0
 /**
  * Special page main function
  */
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgTitle;
     wfReviewExtensionInitMessages();
     $out = "";
     $skin =& $wgUser->getSkin();
     $mode = $wgRequest->getText('mode', 'view_page_statistics');
     $page_id = $wgRequest->getInt('page_id', 0);
     $rev_id = $wgRequest->getInt('rev_id', 0);
     $user_id = $wgRequest->getInt('user_id', 0);
     $user_ip = $wgRequest->getText('user_ip', "");
     $error = false;
     if ($user_id != 0 or $user_ip != "") {
         $theuser = new User();
         if ($user_id == 0) {
             $theuser->setName($user_ip);
         } else {
             $theuser->setID($user_id);
             $theuser->loadFromDatabase();
         }
     }
     if ($page_id == 0) {
         if ($par != '') {
             $title = Title::newFromURL($par);
             $page_id = $title->getArticleID();
         } else {
             $title = null;
         }
     } else {
         $title = Title::newFromID($page_id);
     }
     # Info ahead
     $o = array();
     if ($page_id != 0) {
         $link = $skin->makeLinkObj($title);
         $o[] = wfMsgForContent('review_concerns_page', $link);
     }
     if (isset($theuser)) {
         $link = $skin->makeLinkObj($theuser->getUserPage(), $theuser->getName());
         $o[] = wfMsgForContent('review_concerns_user', $link);
     }
     if ($page_id > 0 and $rev_id > 0) {
         $link = $skin->makeLinkObj($wgTitle, wfMsgForContent('revision_review_this_page_version_link'), "&mode=review&page_id={$page_id}&rev_id={$rev_id}");
         $o[] = $link;
     }
     if (count($o) > 0) {
         $out .= "<ul><li>" . implode("</li>\n<li>", $o) . "</li></ul>";
     }
     // FIXME: use private methods!
     # Modes
     if ($mode == 'view_page_statistics' && $title != null) {
         # View statistics for one page
         $revisions = $this->get_reviewed_revisions($title);
         arsort($revisions);
         # Newest first
         if (count($revisions) == 0) {
             $out .= wfMsgForContent('review_no_reviews_for_page', $skin->makeLinkObj($title));
         } else {
             # Load review data for each version separately to avoid memory apocalypse
             $statistics = array();
             $out .= "<table id='review_statistics_table'>\n";
             $out .= $this->get_revision_statistics_row($title, -1, $statistics);
             $out2 = "";
             foreach ($revisions as $revision) {
                 $reviews = $this->get_reviews_for_revision($title, $revision);
                 $data = $this->analyze_review_data($title, $revision, $reviews, $statistics);
                 $out2 .= $this->get_revision_statistics_row($title, $revision, $data);
             }
             $out .= $this->get_revision_statistics_row($title, 0, $statistics);
             $out .= $out2;
             $out .= "</table>\n";
         }
         $page_title = wfMsgForContent('review_for_page', $title->getPrefixedText());
     } else {
         if ($mode == 'view_version_statistics' && $title != null) {
             # View statistics for a specific version of a page
             $data = array();
             $out .= "<table id='review_statistics_table'>\n";
             $out .= $this->get_revision_statistics_row($title, -2, $data);
             $reviews = $this->get_reviews_for_revision($title, $rev_id);
             $this->analyze_review_data($title, $rev_id, $reviews, $data);
             $out .= $this->get_revision_statistics_row($title, 0, $data);
             # Statistics for the revision
             $data = $this->group_data_by_user($reviews);
             foreach ($data as $entry) {
                 $out .= $this->get_revision_statistics_row($title, 1, $entry, true);
             }
             $out .= "</table>\n";
             $page_title = wfMsgForContent('review_for_page', $title->getPrefixedText());
         } else {
             if ($mode == 'view_user_reviews' and isset($theuser)) {
                 if ($page_id != 0) {
                     # View the reviews of a user for a specific page
                     global $wgReviewFeatureSingleUserMode;
                     $wgReviewFeatureSingleUserMode = true;
                     $revisions = wfReviewExtensionGetUserRatingsForPage($title, $theuser);
                     $statistics = array();
                     $out .= "<table id='review_statistics_table'>\n";
                     $out .= $this->get_revision_statistics_row($title, -1, $statistics);
                     $out2 = "";
                     foreach ($revisions as $revision => $reviews) {
                         $data = $this->analyze_review_data($title, $revision, $reviews, $statistics);
                         $out2 .= $this->get_revision_statistics_row($title, $revision, $data);
                     }
                     $out .= $this->get_revision_statistics_row($title, 0, $statistics);
                     $out .= $out2;
                     $out .= "</table>\n";
                     $wgReviewFeatureSingleUserMode = false;
                 } else {
                     # View the pages reviewed by a user
                     $data = $this->get_list_of_pages_reviewed_by_user($theuser);
                     $out .= "<h2>" . wfMsgExt('review_user_page_list', array('content', 'parsemag'), $theuser->getName()) . "</h2>\n";
                     $data2 = array();
                     if ($user_id == 0) {
                         $user_link = "user_ip=" . $user_ip;
                     } else {
                         $user_link = "user_id=" . $user_id;
                     }
                     foreach ($data as $pid) {
                         $t = Title::newFromID($pid);
                         $link1 = $skin->makeLinkObj($t);
                         $link2 = $skin->makeLinkObj($wgTitle, wfMsgForContent('review_user_details_link'), "mode=view_user_reviews&" . $user_link . "&page_id={$pid}");
                         $data2[] = $link1 . " " . $link2;
                     }
                     asort($data2);
                     if (count($data2) > 0) {
                         $out .= "<ol><li>" . implode("</li>\n<li>", $data2) . "</li></ul>";
                     }
                 }
                 $page_title = wfMsgForContent('review_for_user', $theuser->getName());
             } else {
                 if ($mode == 'review') {
                     $out = $this->review_page($page_id, $rev_id);
                     $page_title = wfMsgForContent('review_page_review', $title->getPrefixedText());
                 } else {
                     $error = true;
                 }
             }
         }
     }
     $this->setHeaders();
     if ($error) {
         $wgOut->addHTML(wfMsgForContent('review_error'));
     } else {
         $wgOut->setPageTitle($page_title);
         $wgOut->addHTML($out);
     }
 }
Example #14
0
 /**
  * Generate the generic "this page has been changed" e-mail text.
  */
 private function composeCommonMailtext()
 {
     global $wgPasswordSender, $wgNoReplyAddress;
     global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
     global $wgEnotifImpersonal, $wgEnotifUseRealName;
     $this->composed_common = true;
     # You as the WikiAdmin and Sysops can make use of plenty of
     # named variables when composing your notification emails while
     # simply editing the Meta pages
     $keys = array();
     $postTransformKeys = array();
     $pageTitleUrl = $this->title->getCanonicalURL();
     $pageTitle = $this->title->getPrefixedText();
     if ($this->oldid) {
         // Always show a link to the diff which triggered the mail. See bug 32210.
         $keys['$NEWPAGE'] = "\n\n" . wfMessage('enotif_lastdiff', $this->title->getCanonicalURL(array('diff' => 'next', 'oldid' => $this->oldid)))->inContentLanguage()->text();
         if (!$wgEnotifImpersonal) {
             // For personal mail, also show a link to the diff of all changes
             // since last visited.
             $keys['$NEWPAGE'] .= "\n\n" . wfMessage('enotif_lastvisited', $this->title->getCanonicalURL(array('diff' => '0', 'oldid' => $this->oldid)))->inContentLanguage()->text();
         }
         $keys['$OLDID'] = $this->oldid;
         // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
         $keys['$CHANGEDORCREATED'] = wfMessage('changed')->inContentLanguage()->text();
     } else {
         # clear $OLDID placeholder in the message template
         $keys['$OLDID'] = '';
         $keys['$NEWPAGE'] = '';
         // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
         $keys['$CHANGEDORCREATED'] = wfMessage('created')->inContentLanguage()->text();
     }
     $keys['$PAGETITLE'] = $this->title->getPrefixedText();
     $keys['$PAGETITLE_URL'] = $this->title->getCanonicalURL();
     $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMessage('minoredit')->inContentLanguage()->text() : '';
     $keys['$UNWATCHURL'] = $this->title->getCanonicalURL('action=unwatch');
     if ($this->editor->isAnon()) {
         # real anon (user:xxx.xxx.xxx.xxx)
         $keys['$PAGEEDITOR'] = wfMessage('enotif_anon_editor', $this->editor->getName())->inContentLanguage()->text();
         $keys['$PAGEEDITOR_EMAIL'] = wfMessage('noemailtitle')->inContentLanguage()->text();
     } else {
         $keys['$PAGEEDITOR'] = $wgEnotifUseRealName && $this->editor->getRealName() !== '' ? $this->editor->getRealName() : $this->editor->getName();
         $emailPage = SpecialPage::getSafeTitleFor('Emailuser', $this->editor->getName());
         $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
     }
     $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalURL();
     $keys['$HELPPAGE'] = wfExpandUrl(Skin::makeInternalOrExternalUrl(wfMessage('helppage')->inContentLanguage()->text()));
     # Replace this after transforming the message, bug 35019
     $postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary;
     // Now build message's subject and body
     // Messages:
     // enotif_subject_deleted, enotif_subject_created, enotif_subject_moved,
     // enotif_subject_restored, enotif_subject_changed
     $this->subject = wfMessage('enotif_subject_' . $this->pageStatus)->inContentLanguage()->params($pageTitle, $keys['$PAGEEDITOR'])->text();
     // Messages:
     // enotif_body_intro_deleted, enotif_body_intro_created, enotif_body_intro_moved,
     // enotif_body_intro_restored, enotif_body_intro_changed
     $keys['$PAGEINTRO'] = wfMessage('enotif_body_intro_' . $this->pageStatus)->inContentLanguage()->params($pageTitle, $keys['$PAGEEDITOR'], $pageTitleUrl)->text();
     $body = wfMessage('enotif_body')->inContentLanguage()->plain();
     $body = strtr($body, $keys);
     $body = MessageCache::singleton()->transform($body, false, null, $this->title);
     $this->body = wordwrap(strtr($body, $postTransformKeys), 72);
     # Reveal the page editor's address as REPLY-TO address only if
     # the user has not opted-out and the option is enabled at the
     # global configuration level.
     $adminAddress = new MailAddress($wgPasswordSender, wfMessage('emailsender')->inContentLanguage()->text());
     if ($wgEnotifRevealEditorAddress && $this->editor->getEmail() != '' && $this->editor->getOption('enotifrevealaddr')) {
         $editorAddress = MailAddress::newFromUser($this->editor);
         if ($wgEnotifFromEditor) {
             $this->from = $editorAddress;
         } else {
             $this->from = $adminAddress;
             $this->replyto = $editorAddress;
         }
     } else {
         $this->from = $adminAddress;
         $this->replyto = new MailAddress($wgNoReplyAddress);
     }
 }
Example #15
0
 function execute($par)
 {
     global $wgOut, $wgUser, $wgShowRatings, $wgRequest, $wgLang;
     $err = "";
     $target = isset($par) ? $par : $wgRequest->getVal('target');
     $restore = $wgRequest->getVal('restore', null);
     $sk = $wgUser->getSkin();
     $wgOut->setHTMLTitle('Clear Ratings - Accuracy Patrol');
     $t = Title::newFromText($target);
     if ($t == '') {
         $wgOut->addHTML(wfMsg('clearratings_notitle'));
         $this->addClearForm($target);
         return;
     }
     $me = SpecialPage::getTitleFor('Clearratings', $t->getText());
     if ($wgUser->getID() == 0) {
         return;
     }
     if ($wgRequest->wasPosted()) {
         // clearing ratings
         $clear = $wgRequest->getVal('clear', null);
         $confirm = $wgRequest->getVal('confirm', null);
         if ($clear != null && $confirm == null && false) {
             $id = $t->getArticleID();
             $wgOut->addHTML(wfMsg('clearratings_clear_confirm_prompt', $sk->makeLinkObj($t, $t->getFullText())) . "\n\t\t\t\t\t\t<br/><br/>\n\t\t\t\t\t\t<form  id='clear_ratings' method='POST'>\n\t\t\t\t\t\t\t<input type=hidden value='{$id}' name='clear'>\n\t\t\t\t\t\t\t<input type=hidden value='true' name='confirm'>\n\t\t\t\t\t\t\t<input type=hidden value='" . htmlspecialchars($target) . "' name='target'>\n\t\t\t\t\t\t\t<input type=submit value='" . wfMsg('clearratings_clear_confirm') . "'>\n\t\t\t\t\t\t</form>");
             return;
         } else {
             if ($clear != null) {
                 RateArticle::clearRatingForPage($clear, $t, $wgUser);
                 $wgOut->addHTML(wfMsg('clearratings_clear_finished') . "<br/><br/>");
             }
         }
     }
     if ($restore != null && $wgRequest->getVal('reason', null) == null) {
         $wgOut->addHTML(wfMsg('clearreating_reason_restore') . "<br/><br/>");
         $wgOut->addHTML("<form  id='clear_ratings' method='POST' action='{$me->getFullURL()}'>");
         $wgOut->addHTML(wfMsg('clearratings_reason') . " <input type='text' name='reason' size='40'><br/><br/>");
         foreach ($_GET as $k => $v) {
             $wgOut->addHTML("<input type='hidden' value='{$v}' name='{$k}'/>");
         }
         $wgOut->addHTML("<input type='submit' value='" . wfMsg('clearratings_submit') . "'/>");
         $wgOut->addHTML("</form>");
         return;
     } else {
         if ($restore != null) {
             $dbw =& wfGetDB(DB_MASTER);
             $user = $wgRequest->getVal('user');
             $page = $wgRequest->getVal('page');
             $u = new User();
             $u->setID($user);
             $up = $u->getUserPage();
             $hi = $wgRequest->getVal('hi');
             $low = $wgRequest->getVal('low');
             $count = $dbw->selectField('rating', 'count(*)', array("rat_page={$page}", "rat_isdeleted=1"));
             $sql = "update rating set rat_isdeleted= 0 where rat_user_deleted = {$user} and rat_page={$page} and rat_id <= {$hi} and rat_id >= {$low};";
             $dbw->query($sql);
             $wgOut->addHTML("<br/><br/>" . wfMsg('clearratings_clear_restored', $sk->makeLinkObj($up, $u->getName()), $when) . "<br/><br/>");
             // add the log entry
             $t = Title::newFromId($page);
             $params = array($page, $min, $max);
             $log = new LogPage('accuracy', true);
             $reason = $wgRequest->getVal('reason');
             $log->addEntry('accuracy', $t, wfMsg('clearratings_logrestore', $reason, $t->getFullText(), $count), $params);
         }
     }
     if ($target != null) {
         $t = Title::newFromText($target);
         $id = $t->getArticleID();
         if ($id == 0) {
             $err = wfMsg('clearratings_no_such_title', $wgRequest->getVal('target'));
         } else {
             if ($t->getNamespace() != NS_MAIN) {
                 $err = wfMsg('clearratings_only_main', $wgRequest->getVal('target'));
             } else {
                 // clearing info
                 $dbr =& wfGetDB(DB_MASTER);
                 //  get log
                 $res = $dbr->select(array('logging'), array('log_timestamp', 'log_user', 'log_comment', 'log_params'), array('log_type' => 'accuracy', "log_title" => $t->getDBKey()), "wfSpecialClearratings");
                 $count = 0;
                 $wgOut->addHTML(wfMsg('clearratings_previous_clearings') . "<ul>");
                 while ($row = $dbr->fetchObject($res)) {
                     $d = $wgLang->date($row->log_timestamp);
                     $u = new User();
                     $u->setID($row->log_user);
                     $up = $u->getUserPage();
                     $params = split("\n", $row->log_params);
                     $wgOut->addHTML("<li>" . $sk->makeLinkObj($up, $u->getName()) . " ({$d}): ");
                     $wgOut->addHTML(preg_replace('/<?p>/', '', $wgOut->parse($row->log_comment)));
                     $wgOut->addHTML("</i>");
                     if (strpos($row->log_comment, wfMsg('clearratings_restore')) === false) {
                         $wgOut->addHTML("(" . $sk->makeLinkObj($me, wfMsg('clearratings_previous_clearings_restore'), "page={$id}&hi={$params[2]}&low={$params[1]}&target={$target}&user={$row->log_user}&restore=1") . ")");
                     }
                     $wgOut->addHTML("</li>");
                     $count++;
                 }
                 $wgOut->addHTML("</ul>");
                 if ($count == 0) {
                     $wgOut->addHTML(wfMsg('clearratings_previous_clearings_none') . "<br/><br/>");
                 }
                 $dbr->freeResult($res);
                 $res = $dbr->select(array("rating"), array("COUNT(*) AS C", "AVG(rat_rating) AS R"), array("rat_page" => $id, "rat_isdeleted" => "0"), __METHOD__);
                 if ($row = $dbr->fetchObject($res)) {
                     $percent = $row->R * 100;
                     $wgOut->addHTML($sk->makeLinkObj($t, $t->getFullText()) . "<br/><br/>" . wfMsg('clearratings_number_votes') . " {$row->C}<br/>" . wfMsg('clearratings_avg_rating') . " {$percent} %<br/><br/>\n\t\t\t\t\t\t<form  id='clear_ratings' method='POST' action='{$me->getFullURL()}'>\n\t\t\t\t\t\t\t<input type=hidden value='{$id}' name='clear'>\n\t\t\t\t\t\t\t<input type=hidden value='" . htmlspecialchars($target) . "' name='target'>\n\t\t\t\t\t\t\t" . wfMsg('clearratings_reason') . " <input type='text' name='reason' size='40'><br/><br/>\n\t\t\t\t\t\t\t<input type=submit value='" . wfMsg('clearratings_clear_submit') . "'>\n\t\t\t\t\t\t</form><br/><br/>\n\t\t\t\t\t\t");
                 }
                 $dbr->freeResult($res);
                 $ap = Title::makeTitle(NS_SPECIAL, "AccuracyPatrol");
                 $wgOut->addHTML($sk->makeLinkObj($ap, "Return to accuracy patrol"));
             }
         }
     }
     $this->addClearForm($target);
 }
 /**
  * Get a link to $user's user page
  * @param $user User object
  * @return String: html
  */
 protected function link(User $user)
 {
     global $wgHiddenPrefs;
     if (!in_array('realname', $wgHiddenPrefs) && !$user->isAnon()) {
         $real = $user->getRealName();
     } else {
         $real = false;
     }
     $page = $user->isAnon() ? SpecialPage::getTitleFor('Contributions', $user->getName()) : $user->getUserPage();
     return Linker::link($page, htmlspecialchars($real ? $real : $user->getName()));
 }
 /**
  * Generates the subheading with links
  * @param User $userObj User object for the target
  * @return string Appropriately-escaped HTML to be output literally
  * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php.
  * Could be combined.
  */
 protected function contributionsSub($userObj)
 {
     if ($userObj->isAnon()) {
         // Show a warning message that the user being searched for doesn't exists
         if (!User::isIP($userObj->getName())) {
             $this->getOutput()->wrapWikiMsg("<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>", ['contributions-userdoesnotexist', wfEscapeWikiText($userObj->getName())]);
             if (!$this->including()) {
                 $this->getOutput()->setStatusCode(404);
             }
         }
         $user = htmlspecialchars($userObj->getName());
     } else {
         $user = Linker::link($userObj->getUserPage(), htmlspecialchars($userObj->getName()));
     }
     $nt = $userObj->getUserPage();
     $talk = $userObj->getTalkPage();
     $links = '';
     if ($talk) {
         $tools = $this->getUserLinks($nt, $talk, $userObj);
         $links = $this->getLanguage()->pipeList($tools);
         // Show a note if the user is blocked and display the last block log entry.
         // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
         // and also this will display a totally irrelevant log entry as a current block.
         if (!$this->including()) {
             $block = Block::newFromTarget($userObj, $userObj);
             if (!is_null($block) && $block->getType() != Block::TYPE_AUTO) {
                 if ($block->getType() == Block::TYPE_RANGE) {
                     $nt = MWNamespace::getCanonicalName(NS_USER) . ':' . $block->getTarget();
                 }
                 $out = $this->getOutput();
                 // showLogExtract() wants first parameter by reference
                 LogEventsList::showLogExtract($out, 'block', $nt, '', ['lim' => 1, 'showIfEmpty' => false, 'msgKey' => [$userObj->isAnon() ? 'sp-contributions-blocked-notice-anon' : 'sp-contributions-blocked-notice', $userObj->getName()], 'offset' => '']);
             }
         }
     }
     return $this->msg('contribsub2')->rawParams($user, $links)->params($userObj->getName());
 }
 /**
  * @param User $user
  * @param array $oldGroups
  * @param array $newGroups
  * @param string $reason
  */
 function addLogEntry($user, $oldGroups, $newGroups, $reason)
 {
     $log = new LogPage('gblrights');
     $log->addEntry('usergroups', $user->getUserPage(), $reason, array($this->makeGroupNameList($oldGroups), $this->makeGroupNameList($newGroups)));
 }
 /**
  * NAB user flagged this article as a rising star in the Action section
  * of NAB'ing an article.
  */
 private function flagRisingStar($title)
 {
     global $wgLang, $wgUser, $wgRequest;
     if ($wgRequest->getVal('cb_risingstar', null) != "on") {
         return;
     }
     $dateStr = $wgLang->timeanddate(wfTimestampNow());
     $patrollerName = $wgUser->getName();
     $patrollerRealName = User::whoIsReal($wgUser->getID());
     if (!$patrollerRealName) {
         $patrollerRealName = $patrollerName;
     }
     // post to user talk page
     $contribUsername = $wgRequest->getVal('prevuser', '');
     if ($contribUsername) {
         $this->notifyUserOfRisingStar($title, $contribUsername);
     }
     // Give user a thumbs up. Set oldId to -1 as this should be the
     // first revision
     //if (class_exists('ThumbsUp')) {
     //	ThumbsUp::thumbNAB(-1, $title->getLatestRevID(), $title->getArticleID());
     //}
     // post to article discussion page
     $wikitext = "";
     $article = "";
     $contribUser = new User();
     $contribUser->setName($contribUsername);
     $contribUserPage = $contribUser->getUserPage();
     $contribUserName = $contribUser->getName();
     $patrolUserPage = $wgUser->getUserPage();
     $patrolUserName = $wgUser->getName();
     $talkPage = $title->getTalkPage();
     $comment = '{{Rising-star-discussion-msg-2|[[' . $contribUserPage . '|' . $contribUserName . ']]|[[' . $patrolUserPage . '|' . $patrolUserName . ']]}}' . "\n";
     $formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $patrollerName, $patrollerRealName, $comment);
     wfRunHooks("MarkTitleAsRisingStar", array($title));
     if ($talkPage->getArticleId() > 0) {
         $rev = Revision::newFromTitle($talkPage);
         $wikitext = $rev->getText();
     }
     $article = new Article($talkPage);
     $wikitext = "{$comment}\n\n" . $wikitext;
     $watch = false;
     if ($wgUser->getID() > 0) {
         $watch = $wgUser->isWatched($talkPage);
     }
     if ($talkPage->getArticleId() > 0) {
         $article->updateArticle($wikitext, wfMsg('nab-rs-discussion-editsummary'), true, $watch);
     } else {
         $article->insertNewArticle($wikitext, wfMsg('nab-rs-discussion-editsummary'), true, $watch, false, false, true);
     }
     // add to fs feed page
     $wikitext = "";
     $article = "";
     $fsfeed = Title::newFromURL('wikiHow:Rising-star-feed');
     $rev = Revision::newFromTitle($fsfeed);
     $article = new Article($fsfeed);
     $wikitext = $rev->getText();
     $watch = false;
     if ($wgUser->getID() > 0) {
         $watch = $wgUser->isWatched($title->getTalkPage());
     }
     $wikitext .= "\n" . date('==Y-m-d==') . "\n" . $title->getFullURL() . "\n";
     $article->updateArticle($wikitext, wfMsg('nab-rs-feed-editsummary'), true, $watch);
 }
Example #20
0
 protected function person($name, User $user)
 {
     if ($user->isAnon()) {
         $this->element($name, wfMsgExt('anonymous', array('parsemag'), 1));
     } else {
         $real = $user->getRealName();
         if ($real) {
             $this->element($name, $real);
         } else {
             $userName = $user->getName();
             $this->pageOrString($name, $user->getUserPage(), wfMsgExt('siteuser', 'parsemag', $userName, $userName));
         }
     }
 }
Example #21
0
 /**
  * Fetch additional information that is related to the saving that has just happened,
  * e.g. regarding the last edit date. In runs where this hook is not triggered, the
  * last DB entry (of MW) will be used to fill such properties.
  *
  * @note This method directly accesses a member of Article that is informally declared to
  * be private. However, there is no way to otherwise access an article's parseroutput for
  * the purpose of adding information there. If the private access ever becomes a problem,
  * a global/static variable appears to be the only way to get more article data to
  * LinksUpdate.
  *
  * @param WikiPage|Article $article WikiPage on 1.19 and later
  * @param Revision $rev
  * @param integer $baseID
  * @param User $user
  *
  * @return true
  */
 public static function onNewRevisionFromEditComplete($article, Revision $rev, $baseID, User $user)
 {
     global $smwgPageSpecialProperties;
     if ($article->mPreparedEdit && $article->mPreparedEdit->output instanceof ParserOutput) {
         $output = $article->mPreparedEdit->output;
         $title = $article->getTitle();
         if (!isset($title)) {
             return true;
             // nothing we can do
         }
         if (!isset($output->mSMWData)) {
             // no data container yet, make one
             $output->mSMWData = new SMWSemanticData(new SMWDIWikiPage($title->getDBkey(), $title->getNamespace(), $title->getInterwiki()));
         }
         $semdata = $output->mSMWData;
     } else {
         // give up, just keep the old data
         return true;
     }
     if (in_array('_MDAT', $smwgPageSpecialProperties)) {
         $timestamp = $article->getTimestamp();
         $di = self::getDataItemFromMWTimestamp($timestamp);
         if (!is_null($di)) {
             $semdata->addPropertyObjectValue(new SMWDIProperty('_MDAT'), $di);
         }
     }
     if (in_array('_LEDT', $smwgPageSpecialProperties)) {
         $di = SMWDIWikiPage::newFromTitle($user->getUserPage());
         if (!is_null($di)) {
             $semdata->addPropertyObjectValue(new SMWDIProperty('_LEDT'), $di);
         }
     }
     if (in_array('_NEWP', $smwgPageSpecialProperties)) {
         $semdata->addPropertyObjectValue(new SMWDIProperty('_NEWP'), new SMWDIBoolean(is_null($rev->getParentId())));
     }
     return true;
 }
Example #22
0
 public function getLeaderboard(&$dbr)
 {
     global $wgUser;
     $sk = $wgUser->getSkin();
     $startdate = strtotime('7 days ago');
     $starttimestamp = date('YmdG', $startdate) . floor(date('i', $startdate) / 10) . '00000';
     $data = $this->getLeaderboardData($dbr, $starttimestamp);
     $count = 0;
     $leaderboardData = array();
     foreach ($data as $key => $value) {
         $u = new User();
         $u->setName($key);
         if ($value > 0 && $key != '' && $u->getName() != "WRM") {
             $leaderboardData[$count] = array();
             $img = Avatar::getPicture($u->getName(), true);
             if ($img == '') {
                 $img = Avatar::getDefaultPicture();
             }
             $leaderboardData[$count]['img'] = $img;
             $leaderboardData[$count]['user'] = $sk->makeLinkObj($u->getUserPage(), $u->getName());
             $leaderboardData[$count]['count'] = $value;
             $data[$key] = $value * -1;
             $count++;
             if ($count >= 6) {
                 break;
             }
         }
     }
     $html = "";
     $count = 0;
     foreach ($leaderboardData as $leader) {
         if ($count == 0) {
             $html .= "<tr class='first'>";
         } else {
             $html .= "<tr>";
         }
         $html .= "<td class='cd-avatar'>" . $leader['img'] . "</td>";
         $html .= "<td class='cd-user'>" . $leader['user'] . "</td>";
         $html .= "<td class='cd-count'>" . $leader['count'] . "</td>";
         $html .= "</tr>";
         $count++;
     }
     $jsondata = array();
     $jsondata['leaderboard'] = $html;
     return json_encode($jsondata);
 }
 protected function person($name, User $user)
 {
     if ($user->isAnon()) {
         $this->element($name, wfMessage('anonymous')->numParams(1)->text());
     } else {
         $real = $user->getRealName();
         if ($real) {
             $this->element($name, $real);
         } else {
             $userName = $user->getName();
             $this->pageOrString($name, $user->getUserPage(), wfMessage('siteuser', $userName, $userName)->text());
         }
     }
 }
 protected function getFormFields()
 {
     return array('From' => array('type' => 'info', 'raw' => 1, 'default' => Linker::link($this->getUser()->getUserPage(), htmlspecialchars($this->getUser()->getName())), 'label-message' => 'emailfrom', 'id' => 'mw-emailuser-sender'), 'To' => array('type' => 'info', 'raw' => 1, 'default' => Linker::link($this->mTargetObj->getUserPage(), htmlspecialchars($this->mTargetObj->getName())), 'label-message' => 'emailto', 'id' => 'mw-emailuser-recipient'), 'Target' => array('type' => 'hidden', 'default' => $this->mTargetObj->getName()), 'Subject' => array('type' => 'text', 'default' => $this->msg('defemailsubject', $this->getUser()->getName())->inContentLanguage()->text(), 'label-message' => 'emailsubject', 'maxlength' => 200, 'size' => 60, 'required' => true), 'Text' => array('type' => 'textarea', 'rows' => 20, 'label-message' => 'emailmessage', 'required' => true), 'CCMe' => array('type' => 'check', 'label-message' => 'emailccme', 'default' => $this->getUser()->getBoolOption('ccmeonemails')));
 }
 function getMetadata($rev_id, &$article)
 {
     global $wgUser;
     $sk = $wgUser->getSkin();
     $metadata = "";
     $x = $this->getRevisionFromId($rev_id);
     $metadata .= wfTimestamp(TS_DB, $x->rev_timestamp);
     $metadata .= " by ";
     if ($x->rev_user == 0) {
         $metadata .= $x->rev_user_text;
     } else {
         $u = new User();
         $u->setId($x->rev_user);
         $u->setName($x->rev_user_text);
         $nt = $u->getUserPage();
         $metadata .= $sk->makeKnownLinkObj($nt, htmlspecialchars($nt->getText()));
     }
     $metadata .= ': ' . $sk->commentBlock($x->rev_comment, $article->getTitle());
     return $metadata;
 }
 protected function createUserPage(User $user)
 {
     global $wgMakeUserPageFromBio, $wgAutoUserBioText;
     global $wgConfirmAccountSortkey, $wgContLang;
     $body = '';
     // page text
     if ($wgMakeUserPageFromBio) {
         # Add account request bio to userpage
         $body .= $this->bio;
         # Add any automatic text for all confirmed accounts
         if ($wgAutoUserBioText != '') {
             $body .= "\n\n{$wgAutoUserBioText}";
         }
     }
     # Add any automatic text for confirmed accounts of this type
     $autoText = self::getAutoTextFromType($this->type);
     if ($autoText != '') {
         $body .= "\n\n{$autoText}";
     }
     # Add any areas of interest categories...
     foreach (ConfirmAccount::getUserAreaConfig() as $name => $conf) {
         if (in_array($name, $this->areas)) {
             # General userpage text for anyone with this interest
             if ($conf['userText'] != '') {
                 $body .= $conf['userText'];
             }
             # Message for users with this interested with the given account type
             if (isset($conf['grpUserText'][$this->type]) && $conf['grpUserText'][$this->type] != '') {
                 $body .= $conf['grpUserText'];
             }
         }
     }
     # Set sortkey and use it on userpage. This can be used to
     # normalize things like firstname, lastname and so fourth.
     if (!empty($wgConfirmAccountSortkey)) {
         $sortKey = preg_replace($wgConfirmAccountSortkey[0], $wgConfirmAccountSortkey[1], $user->getUserPage()->getText());
         $body .= "\n{{DEFAULTSORT:{$sortKey}}}";
         # Clean up any other categories...
         $catNS = $wgContLang->getNSText(NS_CATEGORY);
         $replace = '/\\[\\[' . preg_quote($catNS) . ':([^\\]]+)\\]\\]/i';
         // [[Category:x]]
         $with = "[[{$catNS}:\$1|" . str_replace('$', '\\$', $sortKey) . "]]";
         // [[Category:x|sortkey]]
         $body = preg_replace($replace, $with, $body);
     }
     # Create userpage!
     $article = new WikiPage($user->getUserPage());
     $article->doEdit($body, wfMsg('confirmaccount-summary'), EDIT_MINOR);
 }
 /**
  * Get a user page target for things like logs.
  * This handles account and IP range targets.
  * @param User|string $target
  * @return Title|null
  */
 protected static function getTargetUserTitle($target)
 {
     if ($target instanceof User) {
         return $target->getUserPage();
     } elseif (IP::isIPAddress($target)) {
         return Title::makeTitleSafe(NS_USER, $target);
     }
     return null;
 }
 /**
  * Links to different places.
  *
  * @note This function is also called in DeletedContributionsPage
  * @param SpecialPage $sp SpecialPage instance, for context
  * @param User $target Target user object
  * @return array
  */
 public static function getUserLinks(SpecialPage $sp, User $target)
 {
     $id = $target->getId();
     $username = $target->getName();
     $userpage = $target->getUserPage();
     $talkpage = $target->getTalkPage();
     $linkRenderer = $sp->getLinkRenderer();
     $tools['user-talk'] = $linkRenderer->makeLink($talkpage, $sp->msg('sp-contributions-talk')->text());
     if ($id !== null || $id === null && IP::isIPAddress($username)) {
         if ($sp->getUser()->isAllowed('block')) {
             # Block / Change block / Unblock links
             if ($target->isBlocked() && $target->getBlock()->getType() != Block::TYPE_AUTO) {
                 $tools['block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Block', $username), $sp->msg('change-blocklink')->text());
                 $tools['unblock'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Unblock', $username), $sp->msg('unblocklink')->text());
             } else {
                 # User is not blocked
                 $tools['block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Block', $username), $sp->msg('blocklink')->text());
             }
         }
         # Block log link
         $tools['log-block'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', 'block'), $sp->msg('sp-contributions-blocklog')->text(), [], ['page' => $userpage->getPrefixedText()]);
         # Suppression log link (bug 59120)
         if ($sp->getUser()->isAllowed('suppressionlog')) {
             $tools['log-suppression'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', 'suppress'), $sp->msg('sp-contributions-suppresslog', $username)->text(), [], ['offender' => $username]);
         }
     }
     # Uploads
     $tools['uploads'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Listfiles', $username), $sp->msg('sp-contributions-uploads')->text());
     # Other logs link
     $tools['logs'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Log', $username), $sp->msg('sp-contributions-logs')->text());
     # Add link to deleted user contributions for priviledged users
     if ($sp->getUser()->isAllowed('deletedhistory')) {
         $tools['deletedcontribs'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('DeletedContributions', $username), $sp->msg('sp-contributions-deleted', $username)->text());
     }
     # Add a link to change user rights for privileged users
     $userrightsPage = new UserrightsPage();
     $userrightsPage->setContext($sp->getContext());
     if ($userrightsPage->userCanChangeRights($target)) {
         $tools['userrights'] = $linkRenderer->makeKnownLink(SpecialPage::getTitleFor('Userrights', $username), $sp->msg('sp-contributions-userrights')->text());
     }
     Hooks::run('ContributionsToolLinks', [$id, $userpage, &$tools, $sp]);
     return $tools;
 }
 /**
  * Add a newuser log entry for the user
  *
  * @param User $user
  * @param bool $byEmail account made by email?
  *
  * @return bool
  */
 public function addNewUserLogEntry($user, $byEmail = false)
 {
     if (empty($this->wg->NewUserLog)) {
         return true;
         // disabled
     }
     if (!$byEmail) {
         $action = 'create';
         $doer = $user;
     } else {
         $action = 'create2';
         $doer = null;
     }
     $log = new LogPage('newusers');
     $log->addEntry($action, $user->getUserPage(), '', array($user->getId()), $doer);
     return true;
 }
Example #30
0
 /**
  * Generate the generic "this page has been changed" e-mail text.
  */
 private function composeCommonMailtext()
 {
     $this->composedCommon = true;
     $action = strtolower($this->action);
     $subject = wfMessage('enotif_subject_' . $action)->inContentLanguage()->text();
     if (wfEmptyMsg('enotif_subject_' . $action, $subject)) {
         $subject = wfMessage('enotif_subject')->inContentLanguage()->text();
     }
     list($body, $bodyHTML) = wfMsgHTMLwithLanguageAndAlternative('enotif_body' . ($action == '' ? '' : '_' . $action), 'enotif_body', F::app()->wg->LanguageCode);
     # You as the WikiAdmin and Sysops can make use of plenty of
     # named variables when composing your notification emails while
     # simply editing the Meta pages
     $keys = [];
     $postTransformKeys = [];
     if ($this->isNewPage()) {
         // watchlist link tracking
         list($keys['$NEWPAGE'], $keys['$NEWPAGEHTML']) = wfMsgHTMLwithLanguageAndAlternative('enotif_lastvisited', 'enotif_lastvisited', F::app()->wg->LanguageCode, [], $this->title->getFullUrl('s=wldiff&diff=0&previousRevId=' . $this->previousRevId));
         $keys['$OLDID'] = $this->previousRevId;
         $keys['$CHANGEDORCREATED'] = wfMessage('changed')->inContentLanguage()->plain();
     } else {
         if ($action == '') {
             // no previousRevId + empty action = create edit, ok to use newpagetext
             $keys['$NEWPAGEHTML'] = $keys['$NEWPAGE'] = wfMessage('enotif_newpagetext')->inContentLanguage()->plain();
         } else {
             // no previousRevId + action = event, dont show anything, confuses users
             $keys['$NEWPAGEHTML'] = $keys['$NEWPAGE'] = '';
         }
         # clear $OLDID placeholder in the message template
         $keys['$OLDID'] = '';
         $keys['$CHANGEDORCREATED'] = wfMessage('created')->inContentLanguage()->plain();
     }
     $keys['$PAGETITLE'] = $this->title->getPrefixedText();
     $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl('s=wl');
     $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMessage('minoredit')->inContentLanguage()->plain() : '';
     $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl('action=unwatch');
     $keys['$ACTION'] = $this->action;
     // Hook registered in FollowHelper -- used for blogposts and categoryAdd
     wfRunHooks('MailNotifyBuildKeys', [&$keys, $this->action, $this->otherParam]);
     if ($this->editor->isAnon()) {
         # real anon (user:xxx.xxx.xxx.xxx)
         $keys['$PAGEEDITOR'] = wfMessage('enotif_anon_editor', $this->editor->getName())->inContentLanguage()->plain();
         $keys['$PAGEEDITOR_EMAIL'] = wfMessage('noemailtitle')->inContentLanguage()->plain();
     } else {
         $keys['$PAGEEDITOR'] = F::app()->wg->EnotifUseRealName ? $this->editor->getRealName() : $this->editor->getName();
         $emailPage = SpecialPage::getSafeTitleFor('Emailuser', $this->editor->getName());
         $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl();
     }
     $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalUrl();
     $summary = $this->summary == '' ? wfMessage('enotif_no_summary')->inContentLanguage()->plain() : '"' . $this->summary . '"';
     $postTransformKeys['$PAGESUMMARY'] = $summary;
     // Now build message's subject and body
     // ArticleComment -- updates subject and $keys['$PAGEEDITOR'] if anon editor
     // EmailTemplatesHooksHelper -- updates subject if blogpost
     // TopListHelper -- updates subject if title is toplist
     wfRunHooks('ComposeCommonSubjectMail', [$this->title, &$keys, &$subject, $this->editor]);
     $subject = strtr($subject, $keys);
     $subject = MessageCache::singleton()->transform($subject, false, null, $this->title);
     $this->subject = strtr($subject, $postTransformKeys);
     // ArticleComment -- updates body and $keys['$PAGEEDITOR'] if anon editor
     // EmailTemplatesHooksHelper -- changes body to blog post. EmailTemplates only enabled on community and messaging so this tranforms
     //     any watched page email coming from Community to a blog post (I think)
     // TopListHelper -- updates body if title is toplist
     wfRunHooks('ComposeCommonBodyMail', [$this->title, &$keys, &$body, $this->editor, &$bodyHTML, &$postTransformKeys]);
     $body = strtr($body, $keys);
     $body = MessageCache::singleton()->transform($body, false, null, $this->title);
     $this->body = wordwrap(strtr($body, $postTransformKeys), 72);
     if ($bodyHTML) {
         $bodyHTML = strtr($bodyHTML, $keys);
         $bodyHTML = MessageCache::singleton()->transform($bodyHTML, false, null, $this->title);
         $this->bodyHTML = strtr($bodyHTML, $postTransformKeys);
     }
 }