public function getTokenSalt() { $params = $this->extractRequestParams(); if (is_null($params['user'])) { $this->dieUsageMsg(array('missingparam', 'user')); } $form = new UserrightsPage(); $user = $form->fetchUser($params['user']); if ($user instanceof WikiErrorMsg) { $this->dieUsageMsg(array_merge((array) $user->getMessageKey(), $user->getMessageArgs())); } return $user->getName(); }
/** * @param array $params * @return User */ private function getUrUser(array $params) { if ($this->mUser !== null) { return $this->mUser; } $this->requireOnlyOneParameter($params, 'user', 'userid'); $user = isset($params['user']) ? $params['user'] : '******' . $params['userid']; $form = new UserrightsPage(); $form->setContext($this->getContext()); $status = $form->fetchUser($user); if (!$status->isOK()) { $this->dieStatus($status); } $this->mUser = $status->value; return $status->value; }
protected function showEditUserGroupsForm($user, $groups) { // override the $groups that is passed, which will be // the user's local groups $groups = efGURgetGroups($user); parent::showEditUserGroupsForm($user, $groups); }
/** * @return User */ private function getUrUser() { if ($this->mUser !== null) { return $this->mUser; } $params = $this->extractRequestParams(); $form = new UserrightsPage(); $status = $form->fetchUser($params['user']); if (!$status->isOK()) { $errors = $status->getErrorsArray(); $this->dieUsageMsg($errors[0]); } else { $user = $status->value; } $this->mUser = $user; return $user; }
/** * @return User */ private function getUrUser() { if ( $this->mUser !== null ) { return $this->mUser; } $params = $this->extractRequestParams(); $form = new UserrightsPage; $form->setContext( $this->getContext() ); $status = $form->fetchUser( $params['user'] ); if ( !$status->isOK() ) { $this->dieStatus( $status ); } else { $user = $status->value; } $this->mUser = $user; return $user; }
/** * Generates the subheading with links * @param $userObj User object for the target * @return String: appropriately-escaped HTML to be output literally * @todo FIXME: Almost the same as contributionsSub in SpecialContributions.php. Could be combined. */ function getSubTitle( $userObj ) { if ( $userObj->isAnon() ) { $user = htmlspecialchars( $userObj->getName() ); } else { $user = Linker::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) ); } $links = ''; $nt = $userObj->getUserPage(); $id = $userObj->getID(); $talk = $nt->getTalkPage(); if ( $talk ) { # Talk page link $tools[] = Linker::link( $talk, $this->msg( 'sp-contributions-talk' )->escaped() ); if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) { # Block / Change block / Unblock links if ( $this->getUser()->isAllowed( 'block' ) ) { if ( $userObj->isBlocked() ) { $tools[] = Linker::linkKnown( # Change block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), $this->msg( 'change-blocklink' )->escaped() ); $tools[] = Linker::linkKnown( # Unblock link SpecialPage::getTitleFor( 'BlockList' ), $this->msg( 'unblocklink' )->escaped(), array(), array( 'action' => 'unblock', 'ip' => $nt->getDBkey() ) ); } else { # User is not blocked $tools[] = Linker::linkKnown( # Block link SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ), $this->msg( 'blocklink' )->escaped() ); } } # Block log link $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'sp-contributions-blocklog' )->escaped(), array(), array( 'type' => 'block', 'page' => $nt->getPrefixedText() ) ); } # Uploads $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Listfiles', $userObj->getName() ), $this->msg( 'sp-contributions-uploads' )->escaped() ); # Other logs link $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'sp-contributions-logs' )->escaped(), array(), array( 'user' => $nt->getText() ) ); # Link to contributions $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ), $this->msg( 'sp-deletedcontributions-contribs' )->escaped() ); # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); $userrightsPage->setContext( $this->getContext() ); if ( $userrightsPage->userCanChangeRights( $userObj ) ) { $tools[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ), $this->msg( 'sp-contributions-userrights' )->escaped() ); } wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) ); $links = $this->getLanguage()->pipeList( $tools ); // Show a note if the user is blocked and display the last block log entry. if ( $userObj->isBlocked() ) { // LogEventsList::showLogExtract() wants the first parameter by ref $out = $this->getOutput(); LogEventsList::showLogExtract( $out, 'block', $nt, '', array( 'lim' => 1, 'showIfEmpty' => false, 'msgKey' => array( 'sp-contributions-blocked-notice', $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice' ), 'offset' => '' # don't use $this->getRequest() parameter offset ) ); } } return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() ); }
/** * 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; }
/** * Generates the subheading with links * @param Title $nt @see Title object for the target * @param integer $id User ID 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($nt, $id) { global $wgSysopUserBans, $wgLang, $wgUser, $wgOut; $sk = $wgUser->getSkin(); if ($id === null) { $user = htmlspecialchars($nt->getText()); } else { $user = $sk->link($nt, htmlspecialchars($nt->getText())); } $userObj = User::newFromName($nt->getText(), false); $talk = $nt->getTalkPage(); if ($talk) { # Talk page link $tools[] = $sk->link($talk, wfMsgHtml('sp-contributions-talk')); if ($id !== null && $wgSysopUserBans || $id === null && IP::isIPAddress($nt->getText())) { if ($wgUser->isAllowed('block')) { # Block / Change block / Unblock links if ($userObj->isBlocked()) { $tools[] = $sk->linkKnown(SpecialPage::getTitleFor('Blockip', $nt->getDBkey()), wfMsgHtml('change-blocklink')); $tools[] = $sk->linkKnown(SpecialPage::getTitleFor('BlockList'), wfMsgHtml('unblocklink'), array(), array('action' => 'unblock', 'ip' => $nt->getDBkey())); } else { # User is not blocked $tools[] = $sk->linkKnown(SpecialPage::getTitleFor('Blockip', $nt->getDBkey()), wfMsgHtml('blocklink')); } } # Block log link $tools[] = $sk->linkKnown(SpecialPage::getTitleFor('Log'), wfMsgHtml('sp-contributions-blocklog'), array(), array('type' => 'block', 'page' => $nt->getPrefixedText())); } # Other logs link $tools[] = $sk->linkKnown(SpecialPage::getTitleFor('Log'), wfMsgHtml('sp-contributions-logs'), array(), array('user' => $nt->getText())); # Add link to deleted user contributions for priviledged users if ($wgUser->isAllowed('deletedhistory')) { $tools[] = $sk->linkKnown(SpecialPage::getTitleFor('DeletedContributions', $nt->getDBkey()), wfMsgHtml('sp-contributions-deleted')); } # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); if ($id !== null && $userrightsPage->userCanChangeRights(User::newFromId($id))) { $tools[] = $sk->linkKnown(SpecialPage::getTitleFor('Userrights', $nt->getDBkey()), wfMsgHtml('sp-contributions-userrights')); } wfRunHooks('ContributionsToolLinks', array($id, $nt, &$tools)); $links = $wgLang->pipeList($tools); // Show a note if the user is blocked and display the last block log entry. if ($userObj->isBlocked()) { LogEventsList::showLogExtract($wgOut, 'block', $nt->getPrefixedText(), '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('sp-contributions-blocked-notice', $nt->getText()), 'offset' => '')); } } // Old message 'contribsub' had one parameter, but that doesn't work for // languages that want to put the "for" bit right after $user but before // $links. If 'contribsub' is around, use it for reverse compatibility, // otherwise use 'contribsub2'. if (wfEmptyMsg('contribsub', wfMsg('contribsub'))) { return wfMsgHtml('contribsub2', $user, $links); } else { return wfMsgHtml('contribsub', "{$user} ({$links})"); } }
function view() { global $wgOut, $wgUser, $wgHuijiprefix, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline; $wgOut->setPageTitle($this->mTitle->getPrefixedText()); // No need to display noarticletext, we use our own message if (!$this->user_id) { parent::view(); return ''; } $staff = ''; $bureaucrat = ''; $sysop = ''; $rollback = ''; $autoconfirmed = ''; if (in_array('staff', $this->user->getEffectiveGroups(true))) { $staff = '<li>职员</li> '; } if (in_array('bot', $this->user->getEffectiveGroups(true))) { $staff = '<li>机器人</li> '; } if (in_array('bureaucrat', $this->user->getEffectiveGroups(true))) { $bureaucrat = '<li>行政员</li> '; } if (in_array('sysop', $this->user->getEffectiveGroups(true))) { $sysop = '<li>管理员</li> '; } if (in_array('rollback', $this->user->getEffectiveGroups(true))) { $rollback = '<li>回退员</li> '; } if (in_array('autoconfirmed', $this->user->getEffectiveGroups(true))) { $autoconfirmed = '<li>自动确认用户</li> '; } $usf = new UserSiteFollow(); $uuf = new UserUserFollow(); $topFollowedSites = $usf->getTopFollowedSitesWithDetails($wgUser->getId(), $this->user_id); // $temp = array(); // $res = array(); // foreach( $topFollowedSites as $value ){ // // if ( $wgUser->isLoggedIn() ) { // $user = User::newFromName( $this->user_name ); // // } // $temp['url'] = HuijiPrefix::prefixToUrl($value); // $temp['name'] = HuijiPrefix::prefixToSiteName($value); // $temp['count'] = UserStats::getSiteEditsCount($user,$value); // $res[] = $temp; // } //sort by edit num $count = array(); foreach ($topFollowedSites as $val) { $count[] = $val['count']; } array_multisort($count, SORT_DESC, $topFollowedSites); $userCount = UserSiteFollow::getFollowingCount($this->user); if ($this->isOwner()) { $target = SpecialPage::getTitleFor('ViewFollows'); $query = array('user' => $this->user_name, 'rel_type' => 1); $button1 = '<li class="mw-ui-button">' . Linker::LinkKnown($target, '<i class="fa fa-users"></i>朋友', array(), $query) . '</li> '; } elseif ($uuf->checkUserUserFollow($wgUser, $this->user)) { $button1 = '<li id="user-user-follow" class="unfollow mw-ui-button"><a><i class="fa fa-minus-square-o"></i>取关</a></li> '; } else { $button1 = '<li id="user-user-follow" class="mw-ui-button"><i class="fa fa-plus-square-o"></i></i>关注</li> '; } if ($this->isOwner()) { $target = SpecialPage::getTitleFor('ViewGifts'); $query = array('user' => $this->user_name); $button2 = '<li class="mw-ui-button">' . Linker::LinkKnown($target, '<i class="fa fa-gift"></i>礼物</a>', array(), $query) . '</li> '; } else { $target = SpecialPage::getTitleFor('GiveGift'); $query = array('user' => $this->user_name); $button2 = '<li class="mw-ui-button">' . Linker::LinkKnown($target, '<i class="fa fa-gift"></i>赠送</a>', array(), $query) . '</li> '; } $contributions = SpecialPage::getTitleFor('Contributions'); $watchlist = SpecialPage::getTitleFor('Watchlist'); $send_message = SpecialPage::getTitleFor('UserBoard'); $user_safe = urlencode($this->user); $tools = array(); if ($wgUser->isLoggedIn()) { if (!$this->isOwner()) { $tools[] = '<li><a href="' . htmlspecialchars($send_message->getFullURL('user='******'&conv=' . $user_safe)) . '" rel="nofollow">' . wfMessage('user-send-message')->escaped() . '</a></li>'; if ($wgUser->isAllowed('block')) { # Block / Change block / Unblock links if ($this->user->isBlocked() && $this->user->getBlock()->getType() != Block::TYPE_AUTO) { $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('Block', $this->user_name), wfMessage('change-blocklink')->escaped()) . '</li>'; $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('Unblock', $this->user_name), wfMessage('unblocklink')->escaped()) . '</li>'; } else { $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('Block', $this->user_name), wfMessage('blocklink')->escaped()) . '</li>'; } } # Block log link $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('Log', 'block'), wfMessage('sp-contributions-blocklog'), array(), array('page' => $this->mTitle->getPrefixedText())) . '</li>'; # Suppression log link if ($wgUser->isAllowed('suppressionlog')) { $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('Log', 'suppress'), wfMessage('sp-contributions-suppresslog')->escaped(), array(), array('offender' => $this->user_name)) . '</li>'; } } # Uploads $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('Listfiles', $this->user_name), wfMessage('sp-contributions-uploads')->escaped()) . '</li>'; # Other logs link $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('Log', $this->user_name), wfMessage('sp-contributions-logs')->escaped()) . '</li>'; # Add link to deleted user contributions for priviledged users if ($wgUser->isAllowed('deletedhistory')) { $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('DeletedContributions', $this->user_name), wfMessage('sp-contributions-deleted')->escaped()) . '</li>'; } # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); $userrightsPage->setContext($this->getContext()); if ($userrightsPage->userCanChangeRights($this->user)) { $tools[] = '<li>' . Linker::linkKnown(SpecialPage::getTitleFor('Userrights', $this->user_name), wfMessage('sp-contributions-userrights')->escaped()) . '</li>'; } if ($this->isOwner()) { $tools[] = '<li><a href="' . htmlspecialchars($watchlist->getFullURL()) . '">' . wfMessage('user-watchlist')->escaped() . '</a></li>'; } } //user isonline // $_SESSION['username'] = $wgUser->getName(); // $user = User::newFromName( $this->user_name ); // $isonline = OnlineStatusBar_StatusCheck::getStatus( $user ); // if($isonline === 'online'){ // $online = '在线'; // }else{ // $online = '未知'; // } // $wgOut->addModuleScripts( 'ext.socialprofile.useruserfollows.js' ); #this script is already added globally // $wgOut->addHTML($wgAjaxExportList); # What is that for?? $wgOut->addHTML('<div class="profile-page"><div id="profile-top" class="jumbotron row">'); $wgOut->addHTML($this->getProfileTop($this->user_id, $this->user_name)); $wgOut->addHTML(' <div class="col-md-6 col-sm-12 col-xs-12 profile-top-right"> <div class="profile-top-right-top"> <div><h4><span class="icon-huiji"></span>在本wiki</h4></div> <ul>' . $staff . $bureaucrat . $sysop . $rollback . $autoconfirmed . '</ul> </div> <div class="profile-top-right-bottom"> <ul>'); foreach ($topFollowedSites as $value) { $Turl[] = HuijiPrefix::prefixToUrl($value['key']); $Tname[] = $value['val']; $Tcount[] = $value['count']; } if (isset($Tname)) { $num = count($Tname) > 3 ? 3 : count($Tname); for ($i = 0; $i < $num; $i++) { $wgOut->addHTML('<li><a href="' . $Turl[$i] . '">' . $Tname[$i] . '</a></li>'); } } $wgOut->addHTML(' </ul> '); if ($this->isOwner()) { $wgOut->addHTML('<a >查看我关注的<i id="site-following-count">' . $userCount . '</i>个wiki</a>'); } else { $wgOut->addHTML('<a >关注了<i>' . $userCount . '</i>个wiki</a>'); } $wgOut->addHTML(' <div> <ul class="profile-interactive">' . $button1 . $button2 . '<li class="dropdown-toggle mw-ui-button" data-toggle="dropdown" aria-expanded="false"><span class="glyphicon glyphicon-align-justify"></span></li> <ul class="dropdown-menu" role="menu"> ' . implode('', $tools) . ' <li><a href="' . htmlspecialchars($contributions->getFullURL('target=' . $user_safe . '&contribs=user')) . '" rel="nofollow">' . wfMessage('user-contributions')->escaped() . '</a></li> </ul> </ul> </div> </div> </div> '); $wgOut->addHTML('<div class="cleared"></div></div>'); // // User does not want social profile for User:user_name, so we just // // show header + page content // if ( // $this->getTitle()->getNamespace() == NS_USER && // $this->profile_data['user_id'] && // $this->profile_data['user_page_type'] == 0 // ) // { // parent::view(); // return ''; // } $ueb = new UserEditBox(); $editBox = $editData = array(); $userEditInfo = $ueb->getUserEditInfo($this->user_id); $maxlen = $currentMaxlen = 0; //init variables. if ($userEditInfo != false) { $wgOut->addHTML('<div id="user-page-center" class="col-md-12 hidden-xs"> <div class="panel panel-default"><div class="user-section-heading panel-heading"> <div class="user-section-title">贡献</div> <div class="action-right"></div> <div class="cleared"></div></div><div class="user-gift-container panel-body check-body">'); foreach ($userEditInfo as $value) { if (is_object($value) && !empty($value->_id) && $value->value > 0) { $editBox[$value->_id] = $value->value; $editData[] = $value->_id; //echo $value->_id.'->'.$value->value.'<br>'; } } $today = date("Y-m-d"); $yesterday = date("Y-m-d", strtotime("-1 day")); $editBox[$today] = UserEditBox::getTodayEdit($this->user_id); if (!empty($editBox[$today])) { $editData[] = $today; } $totalEdit = count($editData); if ($totalEdit > 0) { $resArr[] = strtotime($editData[0]); $maxlen = 1; } for ($k = 1; $k < count($editData); $k++) { if (in_array(strtotime($editData[$k]) - 86400, $resArr)) { $resArr[] = strtotime($editData[$k]); if (count($resArr) > $maxlen) { $maxlen = count($resArr); } } else { $resArr = array(); $resArr[] = strtotime($editData[$k]); } if ($resArr[count($resArr) - 1] == strtotime($today) || $resArr[count($resArr) - 1] == strtotime($yesterday)) { $currentMaxlen = count($resArr); } else { $currentMaxlen = 0; } } $usg = new UserSystemGifts($this->user->getName()); if ($maxlen == 2) { $usg->sendSystemGift(33); } elseif ($maxlen == 3) { $usg->sendSystemGift(34); } elseif ($maxlen == 7) { $usg->sendSystemGift(35); } elseif ($maxlen == 13) { $usg->sendSystemGift(36); } elseif ($maxlen == 23) { $usg->sendSystemGift(37); } elseif ($maxlen == 61) { $usg->sendSystemGift(38); } elseif ($maxlen == 109) { $usg->sendSystemGift(39); } elseif ($maxlen == 199) { $usg->sendSystemGift(40); } elseif ($maxlen == 367) { $usg->sendSystemGift(41); } elseif ($maxlen == 727) { $usg->sendSystemGift(42); } elseif ($maxlen == 1213) { $usg->sendSystemGift(43); } elseif ($maxlen == 1579) { $usg->sendSystemGift(44); } elseif ($maxlen == 1949) { $usg->sendSystemGift(45); } elseif ($maxlen == 2333) { $usg->sendSystemGift(46); } $wgOut->addHTML(' <div class="check-wrapper"><svg width="725" height="110" class=" "> <g transform="translate(20, 20)"> '); $n = 676 / 13; $dateArr = array(); for ($k = 0; $k < 365; $k++) { $dateArr[] = date('Y-m-d', strtotime("-{$k} day")); } $desdateArr = array_reverse($dateArr); $translate = array(); for ($i = 0; $i <= $n; $i++) { $trani = $i * 13; $wgOut->addHTML(' <g transform="translate(' . $trani . ', 0)">'); $dayofweek = date('w', strtotime($desdateArr[0])); if ($i == 0) { $j = $dayofweek; $start = 0; $m = 7 - $dayofweek; } else { $j = 0; $m = 7; $start = $i * 7 - $dayofweek; } $zoneDate = array_slice($desdateArr, $start, $m); foreach ($zoneDate as $val) { $arrDate[$j] = $val; $y = $j * 13; $dataCount = isset($editBox[$val]) ? $editBox[$val] : 0; if ($dataCount == 0) { $color = '#eee'; } elseif ($dataCount > 0 && $dataCount <= 8) { $color = '#86beee'; } elseif ($dataCount > 8 && $dataCount <= 21) { $color = '#5ea2de'; } elseif ($dataCount > 21 && $dataCount <= 55) { $color = '#256fb1'; } else { $color = '#0d5493'; } $wgOut->addHTML('<rect class="day" width="11" height="11" y="' . $y . '" fill="' . $color . '" data-count="' . $dataCount . '" data-date="' . $val . '" title="' . $val . ' 编辑' . $dataCount . '次"></rect>'); $j = $j >= 7 ? 0 : $j + 1; } if (!empty($arrDate[0])) { $translate[$arrDate[0]] = $trani; } $wgOut->addHTML('</g>'); } $moninit = 1; for ($p = 0; $p < 12; $p++) { $year = date('Y') - 1; $mon = date('m') + $p + 1; if ($mon > 12) { $mon = $moninit++; $year = date('Y'); } $sunDay = UserEditBox::getSunday($mon, $year); $Stime = strtotime($sunDay); $sunDay = date('Y-m-d', $Stime); if (!isset($translate[$sunDay])) { $Suntime = strtotime($sunDay); $Sundate = date('Y', $Suntime) - 1; $sunDay = UserEditBox::getSunday($mon, $Sundate); } foreach ($translate as $key => $value) { if (strtotime($key) == strtotime($sunDay)) { $x = $value; } } $wgOut->addHTML('<text x="' . $x . '" y="-5" class="' . $year . '">' . $mon . '月</text>'); } $wgOut->addHTML(' <text text-anchor="middle" class="wday" dx="-10" dy="9" style="display: none;">S</text> <text text-anchor="middle" class="wday" dx="-10" dy="22">M</text> <text text-anchor="middle" class="wday" dx="-10" dy="35" style="display: none;">T</text> <text text-anchor="middle" class="wday" dx="-10" dy="48">W</text> <text text-anchor="middle" class="wday" dx="-10" dy="61" style="display: none;">T</text> <text text-anchor="middle" class="wday" dx="-10" dy="74">F</text> <text text-anchor="middle" class="wday" dx="-10" dy="87" style="display: none;">S</text> </g> </svg> <div class="legend-intro"> <span><b>编辑数</b> 低</span> <ul class="legend"> <li style="background-color: #eee"></li> <li style="background-color: #86beee"></li> <li style="background-color: #5ea2de"></li> <li style="background-color: #256fb1"></li> <li style="background-color: #0d5493"></li> </ul> <span>高</span> </div> <div class="edit-statistics"><p>连续编辑纪录<span>' . $maxlen . '</span></p><p>总编辑天数<span>' . $totalEdit . '</span></p><p>当前连续编辑<span>' . $currentMaxlen . '<span></p></div> </div>'); $wgOut->addHTML('</div></div></div>'); } // Left side $wgOut->addHTML('<div id="user-page-left" class="col-md-6">'); if (!wfRunHooks('UserProfileBeginLeft', array(&$this))) { wfDebug(__METHOD__ . ": UserProfileBeginLeft messed up profile!\n"); } if ($this->user_id != $wgUser->getId()) { $wgOut->addHTML($this->getCommonInterest($wgUser->getId(), $this->user_id)); } $wgOut->addHTML($this->getRelationships($this->user_name, 1)); $wgOut->addHTML($this->getRelationships($this->user_name, 2)); $wgOut->addHTML($this->getGifts($this->user_name)); $wgOut->addHTML($this->getCustomInfo($this->user_name)); $wgOut->addHTML($this->getInterests($this->user_name)); $wgOut->addHTML($this->getFanBoxes($this->user_name)); $wgOut->addHTML($this->getUserStats($this->user_id, $this->user_name)); $wgOut->addHTML($this->getEditingActivity($this->user_name)); $wgOut->addHTML($this->getNonEditingActivity($this->user_name)); if (!wfRunHooks('UserProfileEndLeft', array(&$this))) { wfDebug(__METHOD__ . ": UserProfileEndLeft messed up profile!\n"); } $wgOut->addHTML('</div>'); wfDebug("profile start right\n"); // Right side $wgOut->addHTML('<div id="user-page-right" class="col-md-6">'); if (!wfRunHooks('UserProfileBeginRight', array(&$this))) { wfDebug(__METHOD__ . ": UserProfileBeginRight messed up profile!\n"); } $wgOut->addHTML($this->getAwards($this->user_name)); $wgOut->addHTML($this->getPersonalInfo($this->user_id, $this->user_name)); // Hook for BlogPage if (!wfRunHooks('UserProfileRightSideAfterActivity', array($this))) { wfDebug(__METHOD__ . ": UserProfileRightSideAfterActivity hook messed up profile!\n"); } $wgOut->addHTML($this->getCasualGames($this->user_id, $this->user_name)); $wgOut->addHTML($this->getUserBoard($this->user_id, $this->user_name)); if (!wfRunHooks('UserProfileEndRight', array(&$this))) { wfDebug(__METHOD__ . ": UserProfileEndRight messed up profile!\n"); } $wgOut->addHTML('</div><div class="cleared"></div></div>'); }
public function execute() { $params = $this->extractRequestParams(); if (!is_null($params['prop'])) { $this->prop = array_flip($params['prop']); } else { $this->prop = array(); } $users = (array) $params['users']; $goodNames = $done = array(); $result = $this->getResult(); // Canonicalize user names foreach ($users as $u) { $n = User::getCanonicalName($u); if ($n === false || $n === '') { $vals = array('name' => $u, 'invalid' => ''); $fit = $result->addValue(array('query', $this->getModuleName()), null, $vals); if (!$fit) { $this->setContinueEnumParameter('users', implode('|', array_diff($users, $done))); $goodNames = array(); break; } $done[] = $u; } else { $goodNames[] = $n; } } if (count($goodNames)) { $this->addTables('user', 'u1'); $this->addFields('u1.*'); $this->addWhereFld('u1.user_name', $goodNames); if (isset($this->prop['groups'])) { $this->addTables('user_groups'); $this->addJoinConds(array('user_groups' => array('LEFT JOIN', 'ug_user=u1.user_id'))); $this->addFields('ug_group'); } $this->showHiddenUsersAddBlockInfo(isset($this->prop['blockinfo'])); $data = array(); $res = $this->select(__METHOD__); foreach ($res as $row) { $user = User::newFromRow($row); $name = $user->getName(); $data[$name]['name'] = $name; if (isset($this->prop['editcount'])) { $data[$name]['editcount'] = intval($user->getEditCount()); } if (isset($this->prop['registration'])) { $data[$name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $user->getRegistration()); } if (isset($this->prop['groups']) && !is_null($row->ug_group)) { // This row contains only one group, others will be added from other rows $data[$name]['groups'][] = $row->ug_group; } if (isset($this->prop['rights']) && !is_null($row->ug_group)) { if (!isset($data[$name]['rights'])) { $data[$name]['rights'] = User::getGroupPermissions(User::getImplicitGroups()); } $data[$name]['rights'] = array_unique(array_merge($data[$name]['rights'], User::getGroupPermissions(array($row->ug_group)))); $result->setIndexedTagName($data[$name]['rights'], 'r'); } if ($row->ipb_deleted) { $data[$name]['hidden'] = ''; } if (isset($this->prop['blockinfo']) && !is_null($row->ipb_by_text)) { $data[$name]['blockedby'] = $row->ipb_by_text; $data[$name]['blockreason'] = $row->ipb_reason; $data[$name]['blockexpiry'] = $row->ipb_expiry; } if (isset($this->prop['emailable']) && $user->canReceiveEmail()) { $data[$name]['emailable'] = ''; } if (isset($this->prop['gender'])) { $gender = $user->getOption('gender'); if (strval($gender) === '') { $gender = 'unknown'; } $data[$name]['gender'] = $gender; } if (!is_null($params['token'])) { $tokenFunctions = $this->getTokenFunctions(); foreach ($params['token'] as $t) { $val = call_user_func($tokenFunctions[$t], $user); if ($val === false) { $this->setWarning("Action '{$t}' is not allowed for the current user"); } else { $data[$name][$t . 'token'] = $val; } } } } } // Second pass: add result data to $retval foreach ($goodNames as $u) { if (!isset($data[$u])) { $data[$u] = array('name' => $u); $urPage = new UserrightsPage(); $iwUser = $urPage->fetchUser($u); if ($iwUser instanceof UserRightsProxy) { $data[$u]['interwiki'] = ''; if (!is_null($params['token'])) { $tokenFunctions = $this->getTokenFunctions(); foreach ($params['token'] as $t) { $val = call_user_func($tokenFunctions[$t], $iwUser); if ($val === false) { $this->setWarning("Action '{$t}' is not allowed for the current user"); } else { $data[$u][$t . 'token'] = $val; } } } } else { $data[$u]['missing'] = ''; } } else { if (isset($this->prop['groups']) && isset($data[$u]['groups'])) { $autolist = ApiQueryUsers::getAutoGroups(User::newFromName($u)); $data[$u]['groups'] = array_merge($autolist, $data[$u]['groups']); $this->getResult()->setIndexedTagName($data[$u]['groups'], 'g'); } } $fit = $result->addValue(array('query', $this->getModuleName()), null, $data[$u]); if (!$fit) { $this->setContinueEnumParameter('users', implode('|', array_diff($users, $done))); break; } $done[] = $u; } return $this->getResult()->setIndexedTagName_internal(array('query', $this->getModuleName()), 'user'); }
public function execute() { global $wgUser, $wgRequest; $this->getMain()->requestWriteMode(); if (wfReadOnly()) { $this->dieUsage('The wiki is in read-only mode', 'readonly'); } $params = $this->extractRequestParams(); $ur = new UserrightsPage($wgRequest); $allowed = $ur->changeableGroups(); $res = array(); $u = $ur->fetchUser_real($params['user']); if (is_array($u)) { switch ($u[0]) { case UserrightsPage::FETCHUSER_NO_INTERWIKI: $this->dieUsage("You don't have permission to change users' rights on other wikis", 'nointerwiki'); case UserrightsPage::FETCHUSER_NO_DATABASE: $this->dieUsage("Database ``{$u[1]}'' does not exist or is not local", 'nosuchdatabase'); case UserrightsPage::FETCHUSER_NO_USER: $this->dieUsage("You specified an empty username, or none at all", 'emptyuser'); case UserrightsPage::FETCHUSER_NOSUCH_USERID: $this->dieUsage("There is no user with ID ``{$u[1]}''", 'nosuchuserid'); case UserrightsPage::FETCHUSER_NOSUCH_USERNAME: $this->dieUsage("There is no user with username ``{$u[1]}''", 'nosuchusername'); default: $this->dieDebug(__METHOD__, "UserrightsPage::fetchUser_real() returned an unknown error ({$u[0]})"); } } $curgroups = $u->getGroups(); if ($params['listgroups']) { $res['user'] = $u->getName(); $res['allowedgroups'] = $allowed; $res['ingroups'] = $curgroups; $this->getResult()->setIndexedTagName($res['ingroups'], 'group'); $this->getResult()->setIndexedTagName($res['allowedgroups']['add'], 'group'); $this->getResult()->setIndexedTagName($res['allowedgroups']['remove'], 'group'); } if ($params['gettoken']) { $res['changerightstoken'] = $wgUser->editToken($u->getName()); $this->getResult()->addValue(null, $this->getModuleName(), $res); return; } if (empty($params['addto']) && empty($params['rmfrom'])) { $this->dieUsage('At least one of the addto and rmfrom parameters must be set', 'noaddrm'); } if (is_null($params['token'])) { $this->dieUsage('The token parameter must be set', 'notoken'); } if (!$wgUser->matchEditToken($params['token'], $u->getName())) { $this->dieUsage('Invalid token', 'badtoken'); } $dbw = wfGetDb(DB_MASTER); $dbw->begin(); $ur->saveUserGroups($u, $params['rmfrom'], $params['addto'], $params['reason']); $dbw->commit(); $res['user'] = $u->getName(); $res['addedto'] = (array) $params['addto']; $res['removedfrom'] = (array) $params['rmfrom']; $res['reason'] = $params['reason']; $this->getResult()->setIndexedTagName($res['addedto'], 'group'); $this->getResult()->setIndexedTagName($res['removedfrom'], 'group'); $this->getResult()->addValue(null, $this->getModuleName(), $res); }
/** * Generates the subheading with links * @param $userObj User object for the target * @return String: appropriately-escaped HTML to be output literally * @todo FIXME: Almost the same as contributionsSub in SpecialContributions.php. Could be combined. */ function getSubTitle($userObj) { if ($userObj->isAnon()) { $user = htmlspecialchars($userObj->getName()); } else { $user = Linker::link($userObj->getUserPage(), htmlspecialchars($userObj->getName())); } $links = ''; $nt = $userObj->getUserPage(); $id = $userObj->getID(); $talk = $nt->getTalkPage(); if ($talk) { # Talk page link $tools[] = Linker::link($talk, $this->msg('sp-contributions-talk')->escaped()); if ($id !== null || $id === null && IP::isIPAddress($nt->getText())) { if ($this->getUser()->isAllowed('block')) { # Block / Change block / Unblock links if ($userObj->isBlocked()) { $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Block', $nt->getDBkey()), $this->msg('change-blocklink')->escaped()); $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('BlockList'), $this->msg('unblocklink')->escaped(), array(), array('action' => 'unblock', 'ip' => $nt->getDBkey())); } else { # User is not blocked $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Block', $nt->getDBkey()), $this->msg('blocklink')->escaped()); } } # Block log link $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Log'), $this->msg('sp-contributions-blocklog')->escaped(), array(), array('type' => 'block', 'page' => $nt->getPrefixedText())); } # Uploads $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Listfiles', $userObj->getName()), $this->msg('sp-contributions-uploads')->escaped()); # Other logs link $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Log'), $this->msg('sp-contributions-logs')->escaped(), array(), array('user' => $nt->getText())); # Link to contributions $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Contributions', $nt->getDBkey()), $this->msg('sp-deletedcontributions-contribs')->escaped()); # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); $userrightsPage->setContext($this->getContext()); if ($userrightsPage->userCanChangeRights($userObj)) { $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Userrights', $nt->getDBkey()), $this->msg('sp-contributions-userrights')->escaped()); } wfRunHooks('ContributionsToolLinks', array($id, $nt, &$tools)); $links = $this->getLanguage()->pipeList($tools); // Show a note if the user is blocked and display the last block log entry. if ($userObj->isBlocked()) { $out = $this->getOutput(); // LogEventsList::showLogExtract() wants the first parameter by ref LogEventsList::showLogExtract($out, 'block', $nt, '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('sp-contributions-blocked-notice', $nt->getText()), 'offset' => '')); } } // Old message 'contribsub' had one parameter, but that doesn't work for // languages that want to put the "for" bit right after $user but before // $links. If 'contribsub' is around, use it for reverse compatibility, // otherwise use 'contribsub2'. $oldMsg = $this->msg('contribsub'); if ($oldMsg->exists()) { return $oldMsg->rawParams("{$user} ({$links})"); } else { return $this->msg('contribsub2')->rawParams($user, $links); } }
function doPOST() { global $wgUser, $wgAuth; switch ($this->action) { default: throw new InvalidPOSTParamException(wfMsg('uadm-formsubmissionerrormsg')); case 'emailwelcomepreview': $this->pwdaction = 'emailwelcome'; $newParams = array('preview' => 'welcome') + $this->mParams; $newParams = array_intersect_key($newParams, $this->getParamsGET()); return $this->getURL($newParams); case 'adduser': break; } $this->validatePOSTParams(); if ($this->domain != 'local' && $this->domain != '') { if (!$wgAuth->canCreateAccounts()) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-createextacctfailmsg')); } } $logRights = new LogPage('rights'); $user = new User(); $user->setName($wgAuth->getCanonicalName($this->username)); $user->setRealName($this->realname); $user->setEmail($this->email); $successWikiText = array(); $successWikiText[] = wfMsg('uadm-newusersuccessmsg', $this->username); $userPassword = ''; switch ($this->pwdaction) { case 'manual': try { $user->setPassword($this->password1); $userPassword = $this->password1; } catch (PasswordError $pe) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-passworderrormsg') . $pe->getText()); } $successWikiText[] = wfMsg('uadm-passwordchangesuccessmsg', $this->username); break; case 'emailwelcome': $result = self::mailWelcomeAndPassword($user); if ($result->isGood()) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-mailerror', $result->getMessage())); } $successWikiText[] = wfMsg('uadm-welcomeemailsuccessmsg', $this->username, $this->email); break; } $user->setToken(); $wgAuth->initUser($user, false); $abortError = ''; if (!wfRunHooks('AbortNewAccount', array($user, &$abortError))) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-hookblocknewusermsg', $abortError)); } if (!$wgAuth->addUser($user, $userPassword, $this->email, $this->realname)) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-wgauthaddfailmsg', $abortError)); } $user->addToDatabase(); $user->addNewUserLogEntry(); if (count($this->groups) > 0) { $userrightsPage = new UserrightsPage(); $userrightsPage->doSaveUserGroups($user, $this->groups, array(), $this->newuserreasonmsg); wfRunHooks('UserRights', array($user, $add, $remove)); $successWikiText[] = wfMsg('uadm-changestogroupsuccessmsg', $this->username); } $successWikiText = implode('<br/>', $successWikiText); wfRunHooks('AddNewAccount', array($user, true)); $ssUpdate = new SiteStatsUpdate(0, 0, 0, 0, 1); $ssUpdate->doUpdate(); # password log entry switch ($this->pwdaction) { case 'manual': $logRights->addEntry('uadm-changeduserpasswordlog', $user->getUserPage(), $this->newuserreasonmsg, array()); break; case 'emailwelcome': $logRights->addEntry('uadm-emailwelcomelog', $user->getUserPage(), $this->newuserreasonmsg, array()); break; } // Redirect to EditUser special page instead of AddUser to allow editing of // user just added return $this->getSpecialPageURL('EditUser', $this->username, array('statusmsg' => base64_encode($successWikiText), 'statusok' => true, 'returnto' => $this->returnto)); }
/** * Enhanced user tool links, with javascript functionality. */ public function userToolLinks($userId, $userText) { global $wgUser, $wgDisableAnonTalk; $talkable = !($wgDisableAnonTalk && 0 == $userId); /* * Assign each different user a running id. This is used to show user tool * links on demand with javascript, to reduce page size when one user has * multiple changes. * * $linkindex is the running id, and $users contain username -> html snippet * for javascript. */ static $linkindex = 0; $linkindex++; static $users = array(); $userindex = array_search($userText, $users, true); if ($userindex === false) { $users[] = $userText; $userindex = count($users) - 1; } global $wgStylePath; $image = Xml::element('img', array('src' => $wgStylePath . '/common/images/magnify-clip.png', 'alt' => wfMsg('cleanchanges-showuserlinks'), 'title' => wfMsg('cleanchanges-showuserlinks'), 'height' => '12')); $rci = 'RCUI' . $userindex; $rcl = 'RCUL' . $linkindex; $rcm = 'RCUM' . $linkindex; $toggleLink = "javascript:showUserInfo('wgUserInfo{$rci}', '{$rcl}' )"; $tl = Xml::tags('span', array('id' => $rcm), Xml::tags('a', array('href' => $toggleLink), $image)); $tl .= Xml::element('span', array('id' => $rcl), ' '); $items = array(); if ($talkable) { $items[] = $this->skin->userTalkLink($userId, $userText); } if ($userId) { $targetPage = SpecialPage::getTitleFor('Contributions', $userText); $items[] = $this->skin->makeKnownLinkObj($targetPage, wfMsgHtml('contribslink')); } if ($wgUser->isAllowed('block')) { $items[] = $this->skin->blockLink($userId, $userText); } if ($userId) { $userrightsPage = new UserrightsPage(); if ($userrightsPage->userCanChangeRights(User::newFromId($userId))) { $targetPage = SpecialPage::getTitleFor('Userrights', $userText); $items[] = $this->skin->makeKnownLinkObj($targetPage, wfMsgHtml('cleanchanges-changerightslink')); } } if ($items) { global $wgLang; $data = array("wgUserInfo{$rci}" => '(' . $wgLang->pipeList($items) . ')'); return array($tl, $data); } else { return ''; } }
/** * build array of common navigation links * @return array */ protected function buildNavUrls() { global $wgUploadNavigationUrl; $out = $this->getOutput(); $request = $this->getRequest(); $nav_urls = array(); $nav_urls['mainpage'] = array('href' => self::makeMainPageUrl()); if ($wgUploadNavigationUrl) { $nav_urls['upload'] = array('href' => $wgUploadNavigationUrl); } elseif (UploadBase::isEnabled() && UploadBase::isAllowed($this->getUser()) === true) { $nav_urls['upload'] = array('href' => self::makeSpecialUrl('Upload')); } else { $nav_urls['upload'] = false; } $nav_urls['specialpages'] = array('href' => self::makeSpecialUrl('Specialpages')); $nav_urls['print'] = false; $nav_urls['permalink'] = false; $nav_urls['info'] = false; $nav_urls['whatlinkshere'] = false; $nav_urls['recentchangeslinked'] = false; $nav_urls['contributions'] = false; $nav_urls['log'] = false; $nav_urls['blockip'] = false; $nav_urls['emailuser'] = false; $nav_urls['userrights'] = false; // A print stylesheet is attached to all pages, but nobody ever // figures that out. :) Add a link... if (!$out->isPrintable() && ($out->isArticle() || $this->getTitle()->isSpecialPage())) { $nav_urls['print'] = array('text' => $this->msg('printableversion')->text(), 'href' => $this->getTitle()->getLocalURL($request->appendQueryValue('printable', 'yes', true))); } if ($out->isArticle()) { // Also add a "permalink" while we're at it $revid = $this->getRevisionId(); if ($revid) { $nav_urls['permalink'] = array('text' => $this->msg('permalink')->text(), 'href' => $this->getTitle()->getLocalURL("oldid={$revid}")); } // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals Hooks::run('SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array(&$this, &$nav_urls, &$revid, &$revid)); } if ($out->isArticleRelated()) { $nav_urls['whatlinkshere'] = array('href' => SpecialPage::getTitleFor('Whatlinkshere', $this->thispage)->getLocalURL()); $nav_urls['info'] = array('text' => $this->msg('pageinfo-toolboxlink')->text(), 'href' => $this->getTitle()->getLocalURL("action=info")); if ($this->getTitle()->exists()) { $nav_urls['recentchangeslinked'] = array('href' => SpecialPage::getTitleFor('Recentchangeslinked', $this->thispage)->getLocalURL()); } } $user = $this->getRelevantUser(); if ($user) { $rootUser = $user->getName(); $nav_urls['contributions'] = array('text' => $this->msg('contributions', $rootUser)->text(), 'href' => self::makeSpecialUrlSubpage('Contributions', $rootUser)); $nav_urls['log'] = array('href' => self::makeSpecialUrlSubpage('Log', $rootUser)); if ($this->getUser()->isAllowed('block')) { $nav_urls['blockip'] = array('text' => $this->msg('blockip', $rootUser)->text(), 'href' => self::makeSpecialUrlSubpage('Block', $rootUser)); } if ($this->showEmailUser($user)) { $nav_urls['emailuser'] = array('href' => self::makeSpecialUrlSubpage('Emailuser', $rootUser)); } if (!$user->isAnon()) { $sur = new UserrightsPage(); $sur->setContext($this->getContext()); if ($sur->userCanExecute($this->getUser())) { $nav_urls['userrights'] = array('href' => self::makeSpecialUrlSubpage('Userrights', $rootUser)); } } } return $nav_urls; }
/** * Generates the subheading with links * @param Title $nt Title object for the target * @param integer $id User ID for the target * @return String: appropriately-escaped HTML to be output literally */ protected function contributionsSub($nt, $id) { global $wgSysopUserBans, $wgLang, $wgUser; $sk = $wgUser->getSkin(); if (0 == $id) { $user = $nt->getText(); } else { $user = $sk->makeLinkObj($nt, htmlspecialchars($nt->getText())); } $talk = $nt->getTalkPage(); if ($talk) { # Talk page link $tools[] = $sk->makeLinkObj($talk, wfMsgHtml('talkpagelinktext')); if ($id != 0 && $wgSysopUserBans || $id == 0 && IP::isIPAddress($nt->getText())) { # Block link if ($wgUser->isAllowed('block')) { $tools[] = $sk->makeKnownLinkObj(SpecialPage::getTitleFor('Blockip', $nt->getDBkey()), wfMsgHtml('blocklink')); } # Block log link $tools[] = $sk->makeKnownLinkObj(SpecialPage::getTitleFor('Log'), wfMsgHtml('sp-contributions-blocklog'), 'type=block&page=' . $nt->getPrefixedUrl()); } # Other logs link $tools[] = $sk->makeKnownLinkObj(SpecialPage::getTitleFor('Log'), wfMsg('sp-contributions-logs'), 'user='******'deletedhistory')) { $tools[] = $sk->makeKnownLinkObj(SpecialPage::getTitleFor('DeletedContributions', $nt->getDBkey()), wfMsgHtml('deletedcontributions')); } # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); if (0 !== $id && $userrightsPage->userCanChangeRights(User::newFromId($id))) { $tools[] = $sk->makeKnownLinkObj(SpecialPage::getTitleFor('Userrights', $nt->getDBkey()), wfMsgHtml('userrights')); } wfRunHooks('ContributionsToolLinks', array($id, $nt, &$tools)); $links = $wgLang->pipeList($tools); } // Old message 'contribsub' had one parameter, but that doesn't work for // languages that want to put the "for" bit right after $user but before // $links. If 'contribsub' is around, use it for reverse compatibility, // otherwise use 'contribsub2'. if (wfEmptyMsg('contribsub', wfMsg('contribsub'))) { return wfMsgHtml('contribsub2', $user, $links); } else { return wfMsgHtml('contribsub', "{$user} ({$links})"); } }
/** * Links to different places. * @param $userpage Title: Target user page * @param $talkpage Title: Talk page * @param $target User: Target user object * @return array */ public function getUserLinks(Title $userpage, Title $talkpage, User $target) { $id = $target->getId(); $username = $target->getName(); $tools[] = Linker::link($talkpage, $this->msg('sp-contributions-talk')->escaped()); if ($id !== null || $id === null && IP::isIPAddress($username)) { if ($this->getUser()->isAllowed('block')) { # Block / Change block / Unblock links if ($target->isBlocked()) { $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Block', $username), $this->msg('change-blocklink')->escaped()); $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Unblock', $username), $this->msg('unblocklink')->escaped()); } else { # User is not blocked $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Block', $username), $this->msg('blocklink')->escaped()); } } # Block log link $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Log', 'block'), $this->msg('sp-contributions-blocklog')->escaped(), array(), array('page' => $userpage->getPrefixedText())); } # Uploads $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Listfiles', $username), $this->msg('sp-contributions-uploads')->escaped()); # Other logs link $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Log', $username), $this->msg('sp-contributions-logs')->escaped()); # Add link to deleted user contributions for priviledged users if ($this->getUser()->isAllowed('deletedhistory')) { $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('DeletedContributions', $username), $this->msg('sp-contributions-deleted')->escaped()); } # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); $userrightsPage->setContext($this->getContext()); if ($userrightsPage->userCanChangeRights($target)) { $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Userrights', $username), $this->msg('sp-contributions-userrights')->escaped()); } wfRunHooks('ContributionsToolLinks', array($id, $userpage, &$tools)); return $tools; }
/** * 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 contributionsSub in SpecialContributions.php. Could be combined. */ function getSubTitle($userObj) { if ($userObj->isAnon()) { $user = htmlspecialchars($userObj->getName()); } else { $user = Linker::link($userObj->getUserPage(), htmlspecialchars($userObj->getName())); } $links = ''; $nt = $userObj->getUserPage(); $id = $userObj->getID(); $talk = $nt->getTalkPage(); if ($talk) { # Talk page link $tools[] = Linker::link($talk, $this->msg('sp-contributions-talk')->escaped()); if ($id !== null || $id === null && IP::isIPAddress($nt->getText())) { # Block / Change block / Unblock links if ($this->getUser()->isAllowed('block')) { if ($userObj->isBlocked()) { $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Block', $nt->getDBkey()), $this->msg('change-blocklink')->escaped()); $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('BlockList'), $this->msg('unblocklink')->escaped(), array(), array('action' => 'unblock', 'ip' => $nt->getDBkey())); } else { # User is not blocked $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Block', $nt->getDBkey()), $this->msg('blocklink')->escaped()); } } # Block log link $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Log'), $this->msg('sp-contributions-blocklog')->escaped(), array(), array('type' => 'block', 'page' => $nt->getPrefixedText())); # Suppression log link (bug 59120) if ($this->getUser()->isAllowed('suppressionlog')) { $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Log', 'suppress'), $this->msg('sp-contributions-suppresslog')->escaped(), array(), array('offender' => $userObj->getName())); } } # Uploads $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Listfiles', $userObj->getName()), $this->msg('sp-contributions-uploads')->escaped()); # Other logs link $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Log'), $this->msg('sp-contributions-logs')->escaped(), array(), array('user' => $nt->getText())); # Link to contributions $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Contributions', $nt->getDBkey()), $this->msg('sp-deletedcontributions-contribs')->escaped()); # Add a link to change user rights for privileged users $userrightsPage = new UserrightsPage(); $userrightsPage->setContext($this->getContext()); if ($userrightsPage->userCanChangeRights($userObj)) { $tools[] = Linker::linkKnown(SpecialPage::getTitleFor('Userrights', $nt->getDBkey()), $this->msg('sp-contributions-userrights')->escaped()); } Hooks::run('ContributionsToolLinks', array($id, $nt, &$tools)); $links = $this->getLanguage()->pipeList($tools); // Show a note if the user is blocked and display the last block log entry. $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(); } // LogEventsList::showLogExtract() wants the first parameter by ref $out = $this->getOutput(); LogEventsList::showLogExtract($out, 'block', $nt, '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('sp-contributions-blocked-notice', $userObj->getName()), 'offset' => '')); } } return $this->msg('contribsub2')->rawParams($user, $links)->params($userObj->getName()); }
public function execute() { $params = $this->extractRequestParams(); if (!is_null($params['prop'])) { $this->prop = array_flip($params['prop']); } else { $this->prop = []; } $users = (array) $params['users']; $goodNames = $done = []; $result = $this->getResult(); // Canonicalize user names foreach ($users as $u) { $n = User::getCanonicalName($u); if ($n === false || $n === '') { $vals = ['name' => $u, 'invalid' => true]; $fit = $result->addValue(['query', $this->getModuleName()], null, $vals); if (!$fit) { $this->setContinueEnumParameter('users', implode('|', array_diff($users, $done))); $goodNames = []; break; } $done[] = $u; } else { $goodNames[] = $n; } } $result = $this->getResult(); if (count($goodNames)) { $this->addTables('user'); $this->addFields(User::selectFields()); $this->addWhereFld('user_name', $goodNames); $this->showHiddenUsersAddBlockInfo(isset($this->prop['blockinfo'])); $data = []; $res = $this->select(__METHOD__); $this->resetQueryParams(); // get user groups if needed if (isset($this->prop['groups']) || isset($this->prop['rights'])) { $userGroups = []; $this->addTables('user'); $this->addWhereFld('user_name', $goodNames); $this->addTables('user_groups'); $this->addJoinConds(['user_groups' => ['INNER JOIN', 'ug_user=user_id']]); $this->addFields(['user_name', 'ug_group']); $userGroupsRes = $this->select(__METHOD__); foreach ($userGroupsRes as $row) { $userGroups[$row->user_name][] = $row->ug_group; } } foreach ($res as $row) { // create user object and pass along $userGroups if set // that reduces the number of database queries needed in User dramatically if (!isset($userGroups)) { $user = User::newFromRow($row); } else { if (!isset($userGroups[$row->user_name]) || !is_array($userGroups[$row->user_name])) { $userGroups[$row->user_name] = []; } $user = User::newFromRow($row, ['user_groups' => $userGroups[$row->user_name]]); } $name = $user->getName(); $data[$name]['userid'] = $user->getId(); $data[$name]['name'] = $name; if (isset($this->prop['editcount'])) { $data[$name]['editcount'] = $user->getEditCount(); } if (isset($this->prop['registration'])) { $data[$name]['registration'] = wfTimestampOrNull(TS_ISO_8601, $user->getRegistration()); } if (isset($this->prop['groups'])) { $data[$name]['groups'] = $user->getEffectiveGroups(); } if (isset($this->prop['implicitgroups'])) { $data[$name]['implicitgroups'] = $user->getAutomaticGroups(); } if (isset($this->prop['rights'])) { $data[$name]['rights'] = $user->getRights(); } if ($row->ipb_deleted) { $data[$name]['hidden'] = true; } if (isset($this->prop['blockinfo']) && !is_null($row->ipb_by_text)) { $data[$name]['blockid'] = (int) $row->ipb_id; $data[$name]['blockedby'] = $row->ipb_by_text; $data[$name]['blockedbyid'] = (int) $row->ipb_by; $data[$name]['blockedtimestamp'] = wfTimestamp(TS_ISO_8601, $row->ipb_timestamp); $data[$name]['blockreason'] = $row->ipb_reason; $data[$name]['blockexpiry'] = $row->ipb_expiry; } if (isset($this->prop['emailable'])) { $data[$name]['emailable'] = $user->canReceiveEmail(); } if (isset($this->prop['gender'])) { $gender = $user->getOption('gender'); if (strval($gender) === '') { $gender = 'unknown'; } $data[$name]['gender'] = $gender; } if (isset($this->prop['centralids'])) { $data[$name] += ApiQueryUserInfo::getCentralUserInfo($this->getConfig(), $user, $params['attachedwiki']); } if (!is_null($params['token'])) { $tokenFunctions = $this->getTokenFunctions(); foreach ($params['token'] as $t) { $val = call_user_func($tokenFunctions[$t], $user); if ($val === false) { $this->setWarning("Action '{$t}' is not allowed for the current user"); } else { $data[$name][$t . 'token'] = $val; } } } } } $context = $this->getContext(); // Second pass: add result data to $retval foreach ($goodNames as $u) { if (!isset($data[$u])) { $data[$u] = ['name' => $u]; $urPage = new UserrightsPage(); $urPage->setContext($context); $iwUser = $urPage->fetchUser($u); if ($iwUser instanceof UserRightsProxy) { $data[$u]['interwiki'] = true; if (!is_null($params['token'])) { $tokenFunctions = $this->getTokenFunctions(); foreach ($params['token'] as $t) { $val = call_user_func($tokenFunctions[$t], $iwUser); if ($val === false) { $this->setWarning("Action '{$t}' is not allowed for the current user"); } else { $data[$u][$t . 'token'] = $val; } } } } else { $data[$u]['missing'] = true; if (isset($this->prop['cancreate'])) { $status = MediaWiki\Auth\AuthManager::singleton()->canCreateAccount($u); $data[$u]['cancreate'] = $status->isGood(); if (!$status->isGood()) { $data[$u]['cancreateerror'] = $this->getErrorFormatter()->arrayFromStatus($status); } } } } else { if (isset($this->prop['groups']) && isset($data[$u]['groups'])) { ApiResult::setArrayType($data[$u]['groups'], 'array'); ApiResult::setIndexedTagName($data[$u]['groups'], 'g'); } if (isset($this->prop['implicitgroups']) && isset($data[$u]['implicitgroups'])) { ApiResult::setArrayType($data[$u]['implicitgroups'], 'array'); ApiResult::setIndexedTagName($data[$u]['implicitgroups'], 'g'); } if (isset($this->prop['rights']) && isset($data[$u]['rights'])) { ApiResult::setArrayType($data[$u]['rights'], 'array'); ApiResult::setIndexedTagName($data[$u]['rights'], 'r'); } } $fit = $result->addValue(['query', $this->getModuleName()], null, $data[$u]); if (!$fit) { $this->setContinueEnumParameter('users', implode('|', array_diff($users, $done))); break; } $done[] = $u; } $result->addIndexedTagName(['query', $this->getModuleName()], 'user'); }
function doPOST() { global $wgUser, $wgAuth; switch ($this->action) { case 'emailpwdpreview': return $this->getURL(array('preview' => 'password', 'pwdaction' => 'email') + $this->mParams); case 'emailwelcomepreview': return $this->getURL(array('preview' => 'welcome', 'pwdaction' => 'emailwelcome') + $this->mParams); default: throw new InvalidPOSTParamException(wfMsg('uadm-formsubmissionerrormsg')); case 'saveuser': break; } $user = $this->validatePOSTParams(); $log = new LogPage('rights'); $changesMade = false; $userName = $user->getName(); // Apply parameters that have changed if ($user->getName() != $this->username) { $oldName = $user->getName(); $user->setName($wgAuth->getCanonicalName($this->username)); $newName = $user->getName(); $log->addEntry('uadm-changedusernamelog', $user->getUserPage(), $this->reason, array($this->userid, $oldName, $newName)); $changesMade = true; } if ($user->getRealName() != $this->realname) { $oldRealName = $user->getRealName(); $user->setRealName($this->realname); $newRealName = $user->getRealName(); $log->addEntry('uadm-changeduserrealnamelog', $user->getUserPage(), $this->reason, array($oldRealName, $newRealName)); $changesMade = true; } if ($user->getEmail() != $this->email) { $oldEmail = $user->getEmail(); $user->setEmail($this->email); $newEmail = $user->getEmail(); $log->addEntry('uadm-changeduseremaillog', $user->getUserPage(), $this->reason, array($oldEmail, $newEmail)); $changesMade = true; } $successWikiText = array(); if ($changesMade) { $successWikiText[] = wfMsg('uadm-changestousersuccessmsg', $this->username); } switch ($this->pwdaction) { case 'manual': try { $user->setPassword($this->password1); $changesMade = true; } catch (PasswordError $pe) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-passworderrormsg') . $pe->getText()); } $log->addEntry('uadm-changeduserpasswordlog', $user->getUserPage(), $this->reason, array()); $successWikiText[] = wfMsg('uadm-passwordchangesuccessmsg', $this->username); break; case 'email': $result = self::mailPassword($user); if ($result->isGood()) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-mailerrormsg', $result->getMessage())); } $changesMade = true; $log->addEntry('uadm-emailpasswordlog', $user->getUserPage(), $this->reason, array()); $successWikiText[] = wfMsg('uadm-passwordemailsuccessmsg', $this->username, $this->email); break; case 'emailwelcome': $result = self::mailWelcomeAndPassword($user); if ($result->isGood()) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-mailerrormsg', $result->getMessage())); } $changesMade = true; $log->addEntry('uadm-emailwelcomelog', $user->getUserPage(), $this->reason, array()); $successWikiText[] = wfMsg('uadm-welcomeemailsuccessmsg', $this->username, $this->email); break; } if ($changesMade) { if (!$wgAuth->updateExternalDB($user)) { return $this->getPOSTRedirectURL(false, wfMsg('uadm-externalupdateerrormsg')); } $user->saveSettings(); } # Update groups if needed $currentGroups = $user->getGroups(); $remove = array(); $add = array(); foreach ($currentGroups as $groupName) { if (!in_array($groupName, $this->groups)) { $remove[] = $groupName; } } foreach ($this->groups as $groupName) { if (!in_array($groupName, $currentGroups)) { $add[] = $groupName; } } if (count($remove) > 0 || count($add) > 0) { $userrightsPage = new UserrightsPage(); $userrightsPage->doSaveUserGroups($user, $add, $remove, $this->reason); wfRunHooks('UserRights', array($user, $add, $remove)); $successWikiText[] = wfMsg('uadm-changestogroupsuccessmsg', $this->username); } $successWikiText = implode('<br/>', $successWikiText); return $this->getPOSTRedirectURL(true, $successWikiText); }