Exemple #1
0
 function execute($par)
 {
     global $wgOut, $wgUser;
     $this->setHeaders();
     if (!$wgUser->isAllowed('stafflog')) {
         throw new PermissionsError('stafflog');
     }
     $pager = new StaffLoggerPager("");
     $sTypesDropDown = XML::openElement('select', array('name' => 'type', 'id' => 'StaffLogFilterType'));
     foreach ($this->aTypes as $k => $v) {
         $sTypesDropDown .= XML::option($v, $k, $k == $this->request->getText('type', ''));
     }
     $sTypesDropDown .= XML::closeElement('select');
     $wgOut->addHTML(XML::openElement('form', array('method' => 'get', 'action' => $this->getTitle()->getLocalURL())) . XML::openElement('fieldset') . XML::element('legend', null, wfMsg('stafflog-filter-label'), false) . XML::inputLabel(wfMsg('stafflog-filter-user'), 'user', 'StaffLogFilterUser', false, htmlspecialchars($this->request->getText('user', ''), ENT_QUOTES, 'UTF-8')) . XML::label(wfMsg('stafflog-filter-type'), 'StaffLogFilterType') . ' ' . $sTypesDropDown . ' ' . XML::submitButton(wfMsg('stafflog-filter-apply')) . XML::closeElement('fieldset') . XML::closeElement('form') . XML::openElement('div', array('class' => 'mw-spcontent')) . $pager->getNavigationBar() . '<ul>' . $pager->getBody() . '</ul>' . $pager->getNavigationBar() . XML::closeElement('div'));
 }
 /**
  * Retrieves and shows the gathered info to the user
  * @param $target Mixed: user whose info we're looking up
  */
 function showInfo($target, $emailUser = "")
 {
     global $wgOut, $wgLang, $wgScript, $wgEnableWallExt, $wgEnableUserLoginExt;
     //Small Stuff Week - adding table from Special:LookupContribs --nAndy
     global $wgExtensionsPath, $wgJsMimeType, $wgResourceBasePath, $wgEnableLookupContribsExt;
     /**
      * look for @ in username
      */
     $count = 0;
     $aUsers = array();
     $userTarget = "";
     if (strpos($target, '@') !== false) {
         /**
          * find username by email
          */
         $emailUser = htmlspecialchars($emailUser);
         $dbr = wfGetDB(DB_SLAVE);
         $oRes = $dbr->select("user", "user_name", array("user_email" => $target), __METHOD__);
         $loop = 0;
         while ($oRow = $dbr->fetchObject($oRes)) {
             if ($loop === 0) {
                 $userTarget = $oRow->user_name;
             }
             if (!empty($emailUser) && $emailUser == $oRow->user_name) {
                 $userTarget = $emailUser;
             }
             $aUsers[] = $oRow->user_name;
             $loop++;
         }
         $count = $loop;
     }
     $user = User::newFromName(!empty($userTarget) ? $userTarget : $target);
     $tempUser = false;
     if ($user == null || $user->getId() == 0) {
         // Check if a temporary user is at this name
         if (!empty($wgEnableUserLoginExt)) {
             $tempUser = TempUser::getTempUserFromName(!empty($userTarget) ? $userTarget : $target);
         }
         if ($tempUser) {
             $user = $tempUser->mapTempUserToUser(false);
         } else {
             $wgOut->addWikiText('<span class="error">' . wfMsg('lookupuser-nonexistent', $target) . '</span>');
             return;
         }
     }
     if ($count > 1) {
         $options = array();
         if (!empty($aUsers) && is_array($aUsers)) {
             foreach ($aUsers as $id => $userName) {
                 $options[] = XML::option($userName, $userName, $userName == $userTarget);
             }
         }
         $selectForm = Xml::openElement('select', array('id' => 'email_user', 'name' => "email_user"));
         $selectForm .= "\n" . implode("\n", $options) . "\n";
         $selectForm .= Xml::closeElement('select');
         $selectForm .= "({$count})";
         $wgOut->addHTML(Xml::openElement('fieldset') . "\n" . Xml::openElement('form', array('method' => 'get', 'action' => $wgScript)) . "\n" . Html::hidden('title', $this->getTitle()->getPrefixedText()) . "\n" . Html::hidden('target', $target) . "\n" . Xml::openElement('table', array('border' => '0')) . "\n" . Xml::openElement('tr') . "\n" . Xml::openElement('td', array('align' => 'right')) . wfMsgHtml('lookupuser-foundmoreusers') . Xml::closeElement('td') . "\n" . Xml::openElement('td', array('align' => 'left')) . "\n" . $selectForm . Xml::closeElement('td') . "\n" . Xml::openElement('td', array('colspan' => '2', 'align' => 'center')) . Xml::submitButton(wfMsgHtml('go')) . Xml::closeElement('td') . "\n" . Xml::closeElement('tr') . "\n" . Xml::closeElement('table') . "\n" . Xml::closeElement('form') . "\n" . Xml::closeElement('fieldset'));
     }
     $authTs = $user->getEmailAuthenticationTimestamp();
     if ($authTs) {
         $authenticated = wfMsg('lookupuser-authenticated', $wgLang->timeanddate($authTs));
     } else {
         $authenticated = wfMsg('lookupuser-not-authenticated');
     }
     $optionsString = '';
     foreach ($user->getOptions() as $name => $value) {
         $optionsString .= "{$name} = {$value} <br />";
     }
     $name = $user->getName();
     if ($user->getEmail()) {
         $email = $user->getEmail();
         $email_output = wfMsg('lookupuser-email', $email, $name);
     } else {
         $email_output = wfMsg('lookupuser-no-email');
     }
     if ($user->getRegistration()) {
         $registration = $wgLang->timeanddate($user->getRegistration());
     } else {
         $registration = wfMsg('lookupuser-no-registration');
     }
     $wgOut->addWikiText('*' . wfMsg('username') . ' [[User:'******'|' . $name . ']] (' . $wgLang->pipeList(array('<span id="lu-tools">[[' . (!empty($wgEnableWallExt) ? 'Message Wall:' . $name . '|' . wfMsg('wall-message-wall-shorten') : 'User talk:' . $name . '|' . wfMsg('talkpagelinktext')) . ']]', '[[Special:Contributions/' . $name . '|' . wfMsg('contribslink') . ']]</span>)')));
     $wgOut->addWikiText('*' . wfMsgForContent('lookupuser-toollinks', $name, urlencode($name)));
     $wgOut->addWikiText('*' . wfMsg('lookupuser-id', $user->getId()));
     if (!empty($tempUser)) {
         $userStatus = wfMsg('lookupuser-account-status-tempuser');
     } else {
         $userStatus = wfMsg('lookupuser-account-status-realuser');
     }
     $wgOut->addWikiText('*' . wfMsg('lookupuser-account-status') . $userStatus);
     $wgOut->addWikiText('*' . $email_output);
     $wgOut->addWikiText('*' . wfMsg('lookupuser-realname', $user->getRealName()));
     $wgOut->addWikiText('*' . wfMsg('lookupuser-registration', $registration));
     $wgOut->addWikiText('*' . wfMsg('lookupuser-touched', $wgLang->timeanddate($user->mTouched)));
     $wgOut->addWikiText('*' . wfMsg('lookupuser-info-authenticated', $authenticated));
     //Begin: Small Stuff Week - adding table from Special:LookupContribs --nAndy
     if (!empty($wgEnableLookupContribsExt)) {
         $wgOut->addExtensionStyle("{$wgExtensionsPath}/wikia/LookupContribs/css/table.css");
         $wgOut->addExtensionStyle("{$wgExtensionsPath}/wikia/LookupUser/css/lookupuser.css");
         $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgResourceBasePath}/resources/wikia/libraries/jquery/datatables/jquery.dataTables.min.js\"></script>\n");
         //checking and setting User::mBlockedGlobally if needed
         //only for this instance of class User
         if (class_exists('UserBlock')) {
             UserBlock::blockCheck($user);
         }
         $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
         $oTmpl->set_vars(array('username' => $name, 'isUsernameGloballyBlocked' => $user->isBlockedGlobally()));
         $wgOut->addHTML($oTmpl->render('contribution.table'));
     } else {
         $wgOut->addWikiText('*' . wfMsg('lookupuser-table-cannot-be-displayed'));
     }
     //End: Small Stuff Week
     $wgOut->addWikiText('*' . wfMsg('lookupuser-useroptions') . '<br />' . $optionsString);
 }