protected function getMessageParameters()
 {
     $params = parent::getMessageParameters();
     // Really old entries
     if (!isset($params[3]) && !isset($params[4])) {
         return $params;
     }
     $oldGroups = $this->makeGroupArray($params[3]);
     $newGroups = $this->makeGroupArray($params[4]);
     $userName = $this->entry->getTarget()->getText();
     if (!$this->plaintext && count($oldGroups)) {
         foreach ($oldGroups as &$group) {
             $group = User::getGroupMember($group, $userName);
         }
     }
     if (!$this->plaintext && count($newGroups)) {
         foreach ($newGroups as &$group) {
             $group = User::getGroupMember($group, $userName);
         }
     }
     $lang = $this->context->getLanguage();
     if (count($oldGroups)) {
         $params[3] = $lang->listToText($oldGroups);
     } else {
         $params[3] = $this->msg('rightsnone')->text();
     }
     if (count($newGroups)) {
         // Array_values is used here because of bug 42211
         // see use of array_unique in UserrightsPage::doSaveUserGroups on $newGroups.
         $params[4] = $lang->listToText(array_values($newGroups));
     } else {
         $params[4] = $this->msg('rightsnone')->text();
     }
     return $params;
 }
Example #2
0
 /**
  * Format a link to a group description page
  *
  * @param $group String: group name
  * @return string
  */
 protected static function buildGroupLink($group)
 {
     static $cache = array();
     if (!isset($cache[$group])) {
         $cache[$group] = User::makeGroupLinkHtml($group, htmlspecialchars(User::getGroupMember($group)));
     }
     return $cache[$group];
 }
    function doGET()
    {
        global $wgLang, $wgOut, $wgUser, $wgAuth;
        $user = $this->validateGETParams();
        $searchFormHTML = $this->getSearchFormHTML(wfMsg('uadm-finduserlabel'));
        $returnToHTML = '';
        $backHTML = '';
        if (!empty($this->returnto)) {
            $returnToHTML = self::parse(wfMsg('uadm-returntomsg', $this->returnto));
            $backHTML = $this->parse("[[{$this->returnto}|< {$this->backactionlabel}]] | ");
        }
        if (!is_object($user)) {
            return <<<EOT
{$searchFormHTML}
{$returnToHTML}
EOT;
        }
        // Suppress search form if editing a user and returnto specified
        if (!empty($this->returnto)) {
            $searchFormHTML = '';
        }
        $id = $user->getId();
        $this->userid = $id;
        $this->mParams['userid'] = $id;
        // user editable parameters
        $userName = $user->getName();
        $realName = $user->getRealName();
        $email = $user->getEmail();
        $groups = $user->getGroups();
        // If userid was used to load the user then prefer URL
        // query parameters to preserve unsaved changes since preview
        // POST was selected then redirected back to GET
        if (!empty($this->userid)) {
            if (!empty($this->username)) {
                $userName = $this->username = strtoupper(substr($this->username, 0, 1)) . substr($this->username, 1);
            }
            // db stores first character as uppercase
            if (!empty($this->realname)) {
                $realName = $this->realname;
            }
            if (!empty($this->email)) {
                $email = $this->email;
            }
            if (!empty($this->groups)) {
                $groups = $this->groups;
            }
        }
        $emailAuthDate = $user->getEmailAuthenticationTimestamp();
        $groupsHTML = '';
        foreach (User::getAllGroups() as $groupName) {
            $checked = in_array($groupName, $groups) ? 'checked' : '';
            $localName = User::getGroupMember($groupName);
            $groupsHTML .= <<<EOT
<input id="grp{$groupName}" type="checkbox" name="groups[]" value="{$groupName}" {$checked}/> <label for="grp{$groupName}">{$localName}</label><br/>
EOT;
        }
        $unconfirmed = $user->isEmailConfirmationPending() ? '[' . $this->pendinglabel . ']' : '';
        $userPageURL = $user->getUserPage()->getLocalURL();
        $editCount = $user->getEditCount();
        $userTouchedDate = $user->getTouched();
        $userTouchedDate = $wgLang->timeanddate($userTouchedDate, true);
        $createDate = $user->getRegistration();
        $createDate = $wgLang->timeanddate($createDate, true);
        if ($editCount > 0) {
            $lastEditDate = self::getUserLastEditTimestamp($user);
            $lastEditDate = $wgLang->timeanddate($lastEditDate, true);
        } else {
            $lastEditDate = '';
        }
        $contribsHref = $this->getSpecialPageURL('Contributions', $userName);
        $logsHref = $this->getSpecialPageURL('Log', $userName);
        $groupsHref = $this->getSpecialPageURL('UserRights', $userName);
        $userPageHref = $user->getUserPage()->getLocalURL();
        $userTalkPageHref = $user->getUserPage()->getTalkPage()->getLocalURL();
        $blockHref = $this->getSpecialPageURL('Block', $userName);
        $purgeHref = $this->getSpecialPageURL('PurgeUser', $userName);
        $logsHref = $this->getSpecialPageURL('Log', $userName);
        $checkuserHref = $this->getSpecialPageURL('CheckUser', $userName);
        $pwdtitleHref = Title::newFromText('passwordremindertitle', NS_MEDIAWIKI)->getLocalURL();
        $pwdtextHref = Title::newFromText('passwordremindertext', NS_MEDIAWIKI)->getLocalURL();
        $welcomeTitleHref = Title::newFromText('createaccount-title', NS_MEDIAWIKI)->getLocalURL();
        $welcomeTextHref = Title::newFromText('createaccount-text', NS_MEDIAWIKI)->getLocalURL();
        $returnToHTML = '';
        $backHTML = '';
        if (!empty($this->returnto)) {
            $returnToHTML = self::parse(wfMsg('uadm-returntomsg', $this->returnto));
            $searchFormHTML = '';
            $backHTML = $this->parse("[[{$this->returnto}|< {$this->backactionlabel}]] | ");
        }
        $postURL = $this->getURL($this->mParams);
        $editToken = $wgUser->editToken($this->userid);
        //    $previewPasswordEmailHref = $this->getURL(array('preview' => 'password') + $this->mParams);
        //    $previewWelcomeEmailHref = $this->getURL(array('preview' => 'welcome') + $this->mParams);
        $previewPasswordEmailHTML = '';
        $previewWelcomeEmailHTML = '';
        if (!empty($this->preview)) {
            switch ($this->preview) {
                case 'password':
                    list($subject, $body) = $this->getPasswordMailMessage($user);
                    break;
                case 'welcome':
                    list($subject, $body) = $this->getWelcomeMailMessage($user);
                    break;
            }
            $previewHTML = <<<EOT
<table>
  <tr>
    <td>{$this->subjectlabel}</td>
    <td><input value="{$subject}" size="70" disabled="disabled"/></td>
  <tr>
    <td colspan="2"><textarea rows="10" cols="80" disabled="disabled">{$body}</textarea></td>
  </tr>
</table>
EOT;
            switch ($this->preview) {
                case 'password':
                    $previewPasswordEmailHTML = $previewHTML;
                    break;
                case 'welcome':
                    $previewWelcomeEmailHTML = $previewHTML;
                    break;
            }
        }
        $pwdSetPasswordChecked = '';
        $pwdEmailPasswordChecked = '';
        $pwdEmailWelcomeChecked = '';
        $pwdNoChangeChecked = '';
        switch ($this->pwdaction) {
            case 'manual':
                $pwdSetPasswordChecked = 'checked';
                break;
            case 'email':
                $pwdEmailPasswordChecked = 'checked';
                break;
            case 'emailwelcome':
                $pwdEmailWelcomeChecked = 'checked';
                break;
            case 'nochange':
                $pwdNoChangeChecked = 'checked';
                break;
        }
        $subtitle = <<<EOT
{$backHTML}<a href="{$userPageHref}"><b>{$userName}</b></a> (<a href="{$userTalkPageHref}">{$this->talkactionlabel}</a> | <a href="{$blockHref}">{$this->blockactionlabel}</a> | <a href="{$purgeHref}">{$this->purgeactionlabel}</a> | <a href="{$logsHref}">{$this->logsactionlabel}</a> | <a href="{$contribsHref}">{$this->contributionsactionlabel}</a> | <a href="{$checkuserHref}">{$this->ipsactionlabel}</a>) 
EOT;
        $wgOut->setSubtitle($subtitle);
        # Hack to detect if domain is needed
        $domainHTML = '';
        $template = new UsercreateTemplate();
        $temp = 'signup';
        // Bug fix. This does nothing.
        $wgAuth->autoCreate();
        // The first time wgAuth is called, some PHP auto-magic involving StubObject
        // occurs to "unstub" wgAuth AND call the function invoked. If the below
        // call is made as written, the call is actually made by calling
        // call_user_func_array and the arguments are passed by value even though
        // the modifyUITemplate expects them to be by reference.
        // This use to be a non issue since call-time pass-by-reference was allowed
        // $wgAuth->modifyUITemplate(&$template, &$temp);
        // This generates warnings now. Solution is to perform a no-op call to
        // wgAuth to "unstub" it so that the below call will be made directly and
        // not by call_user_func_array
        $wgAuth->modifyUITemplate($template, $temp);
        if (isset($template->data['usedomain']) && $template->data['usedomain'] == true) {
            $domainHTML = <<<EOT
      <tr>
        <td><label for="domain">{$this->domainfield}</label></td>
        <td><input id="domain" type="text" name="domain" size="30" value="{$this->domain}"/><br/></td>
      </tr>
EOT;
        }
        return <<<EOT
<form id="edituserform" name="input" action="{$postURL}" method="post" class="visualClear">
  <input type="hidden" name="edittoken" value="{$editToken}"/>
  <fieldset>
    <legend>{$this->edituserlabel}:</legend>
    <table>
      <tr>
        <td><label for="userid">{$this->useridfield}:</label></td>
        <td><input id="userid" type="text" name="userid" value="{$id}" disabled="disabled" size="30"/><br/></td>
      </tr>
      <tr>
        <td><label for="username">{$this->usernamefield}:</label></td>
        <td><input id="username" type="text" name="username" value="{$userName}" size="30"/> {$this->requiredlabel}<br/></td>
      </tr>
{$domainHTML}
      <tr>
        <td><label for="realname">{$this->realnamefield}:</label></td>
        <td><input id="realname" type="text" name="realname" value="{$realName}" size="30"/><br/></td>
      </tr>
      <tr>
        <td><label for="email">{$this->emailfield}:</label></td>
        <td><input id="email" type="text" name="email" value="{$email}" size="30"/> {$this->requiredlabel}<br/></td>
      </tr>
      <tr>
        <td><label for="emailauthdate">{$this->emailauthdatefield}:</label></td>
        <td><input id="emailauthdate" type="text" value="{$emailAuthDate}" size="30" disabled="disabled"/><br/></td>
      </tr>
      <tr>
        <td><label for="createdate">{$this->createddatefield}:</label></td>
        <td><input id="createdate" type="text" value="{$createDate}" disabled="disabled" size="30"/><br/></td>
      </tr>
      <tr>
        <td><label for="usertouched">{$this->usertoucheddatefield}:</label></td>
        <td><input id="usertouched" type="text" value="{$userTouchedDate}" disabled="disabled" size="30"/><br/></td>
      </tr>
      <tr>
        <td><label for="lasteditdate">{$this->lasteditdatefield}:</label></td>
        <td><input id="lasteditdate" type="text" value="{$lastEditDate}" disabled="disabled" size="30"/><br/></td>
      </tr>
      <tr>
        <td><label for="editcount">{$this->editcountfield}:</label></td>
        <td><input id="editcount" type="text" value="{$editCount}" disabled="disabled" size="30"/><br/></td>
      </tr>
    </table>
    <fieldset>
      <legend>{$this->editgroupslabel}:</legend>
      {$groupsHTML}
    </fieldset>
    <fieldset>
      <legend>{$this->editpasswordlabel}:</legend>
      <input id="pwdmanual" type="radio" name="pwdaction" value="manual" {$pwdSetPasswordChecked}/> <label for="pwdmanual">{$this->setpasswordforuserlabel}:</label><br/>
        <table>
          <tr>
            <td><label for="password1">{$this->passwordlabel}:</label></td>
            <td><input id="password1" type="password" name="password1" size="30"/></td>
          </tr>
          <tr>
            <td><label for="password2">{$this->verifypasswordlabel}:</label></td>
            <td><input id="password2" type="password" name="password2" size="30"/></td>
          </tr>
        </table>
      <input id="pwdemail" type="radio" name="pwdaction" value="email" {$pwdEmailPasswordChecked}/> <label for="pwdemail">{$this->emailpasswordlabel}</label> <button type="submit" name="action" value="emailpwdpreview">{$this->previewactionlabel}</button>(<a href="{$pwdtitleHref}">{$this->subjectlabel}</a> | <a href="{$pwdtextHref}">{$this->bodylabel}</a>)<br/>
      {$previewPasswordEmailHTML}
      <input id="pwdemailwelcome" type="radio" name="pwdaction" value="emailwelcome" {$pwdEmailWelcomeChecked}/> <label for="pwdemailwelcome">{$this->emailwelcomelabel}</label> <button type="submit" name="action" value="emailwelcomepreview">{$this->previewactionlabel}</button>(<a href="{$welcomeTitleHref}">{$this->subjectlabel}</a> | <a href="{$welcomeTextHref}">{$this->bodylabel}</a>)<br/>
      {$previewWelcomeEmailHTML}
      <input id="pwdnochange" type="radio" name="pwdaction" value="nochange" {$pwdNoChangeChecked}/> <label for="pwdnochange">{$this->nochangetopasswordlabel}</label><br/>
    </fieldset>
    <label for="reason">{$this->reasonlabel}:</label> <input id="reason" type="text" name="reason" size="60" maxlength="255" value="{$this->reason}"/> {$this->requiredlabel}<br/>
    <button type="submit" name="action" value="saveuser">{$this->saveuserlabel}</button>
  </fieldset>
</form>
{$searchFormHTML}
{$returnToHTML}
EOT;
    }
 /**
  * @param $group
  */
 function buildGroupView($group)
 {
     $editable = $this->userCanEdit($this->getUser());
     $subtitleMessage = $editable ? 'centralauth-editgroup-subtitle' : 'centralauth-editgroup-subtitle-readonly';
     $this->getOutput()->setSubtitle($this->msg($subtitleMessage, $group));
     $fieldsetClass = $editable ? 'mw-centralauth-editgroup' : 'mw-centralauth-editgroup-readonly';
     $html = Xml::fieldset($this->msg('centralauth-editgroup-fieldset', $group)->text(), false, array('class' => $fieldsetClass));
     if ($editable) {
         $html .= Xml::openElement('form', array('method' => 'post', 'action' => SpecialPage::getTitleFor('GlobalGroupPermissions', $group)->getLocalUrl(), 'name' => 'centralauth-globalgroups-newgroup'));
         $html .= Html::hidden('wpGroup', $group);
         $html .= Html::hidden('wpEditToken', $this->getUser()->getEditToken());
     }
     $fields = array();
     if ($editable) {
         $fields['centralauth-editgroup-name'] = Xml::input('wpGlobalGroupName', 50, $group);
     } else {
         $fields['centralauth-editgroup-name'] = $group;
     }
     if ($this->getUser()->isAllowed('editinterface')) {
         # Show edit link only to user with the editinterface right
         $fields['centralauth-editgroup-display'] = $this->msg('centralauth-editgroup-display-edit', $group, User::getGroupName($group))->parse();
         $fields['centralauth-editgroup-member'] = $this->msg('centralauth-editgroup-member-edit', $group, User::getGroupMember($group))->parse();
     } else {
         $fields['centralauth-editgroup-display'] = User::getGroupName($group);
         $fields['centralauth-editgroup-member'] = User::getGroupMember($group);
     }
     $fields['centralauth-editgroup-members'] = $this->msg('centralauth-editgroup-members-link', $group, User::getGroupMember($group))->parse();
     $fields['centralauth-editgroup-restrictions'] = $this->buildWikiSetSelector($group);
     $fields['centralauth-editgroup-perms'] = $this->buildCheckboxes($group);
     if ($editable) {
         $fields['centralauth-editgroup-reason'] = Xml::input('wpReason', 60);
     }
     $html .= Xml::buildForm($fields, $editable ? 'centralauth-editgroup-submit' : null);
     if ($editable) {
         $html .= Xml::closeElement('form');
     }
     $html .= Xml::closeElement('fieldset');
     $this->getOutput()->addHTML($html);
     $this->showLogFragment($group, $this->getOutput());
 }
 /**
  * Format a link to a group description page
  *
  * @param string $group
  * @param string $username
  * @return string
  */
 protected static function buildGroupLink($group, $username = '******')
 {
     static $cache = array();
     if (!isset($cache[$group])) {
         $cache[$group] = User::makeGroupLinkHtml($group, User::getGroupMember($group, $username));
     }
     return $cache[$group];
 }
Example #6
0
 function formatResult($skin, $result)
 {
     $userPage = Title::makeTitle($result->namespace, $result->title);
     $name = $skin->makeLinkObj($userPage, htmlspecialchars($userPage->getText()));
     $groups = null;
     if (!isset($result->numgroups) || $result->numgroups > 0) {
         $dbr =& wfGetDB(DB_SLAVE);
         $result = $dbr->select('user_groups', array('ug_group'), array('ug_user' => $result->user_id), 'ListUsersPage::formatResult');
         $groups = array();
         while ($row = $dbr->fetchObject($result)) {
             $groups[$row->ug_group] = User::getGroupMember($row->ug_group);
         }
         $dbr->freeResult($result);
         if (count($groups) > 0) {
             foreach ($groups as $group => $desc) {
                 if ($page = User::getGroupPage($group)) {
                     $list[] = $skin->makeLinkObj($page, htmlspecialchars($desc));
                 } else {
                     $list[] = htmlspecialchars($desc);
                 }
             }
             $groups = implode(', ', $list);
         } else {
             $groups = '';
         }
     }
     return wfSpecialList($name, $groups);
 }
    function getUserRowHTML($user)
    {
        global $wgLang;
        $id = $user->getId();
        $userName = $user->getName();
        $realName = $user->getRealName();
        $email = $user->getEmail();
        $emailHTML = strlen($email) > 0 ? "<a href=\"mailto:{$email}\">{$email}</a>" : '';
        $groups = array_diff($user->getEffectiveGroups(), $user->getImplicitGroups());
        $groupsHTML = '';
        foreach ($groups as $group) {
            $groupsHTML .= User::makeGroupLinkHtml($group, htmlspecialchars(User::getGroupMember($group))) . ', ';
        }
        $groupsHTML = substr($groupsHTML, 0, strlen($groupsHTML) - 2);
        $unconfirmed = $user->isEmailConfirmationPending() ? wfMsg('') : '';
        $userPageURL = $user->getUserPage()->getLocalURL();
        $editCount = $user->getEditCount();
        $createDate = $user->getRegistration();
        $createDate = $wgLang->timeanddate($createDate, true);
        $userTouchedDate = $user->getTouched();
        $userTouchedDate = $wgLang->timeanddate($userTouchedDate, true);
        if ($editCount > 0) {
            $lastEditDate = self::getUserLastEditTimestamp($user);
            $lastEditDate = $wgLang->timeanddate($lastEditDate, true);
        } else {
            $lastEditDate = '';
        }
        $editHref = $this->getSpecialPageURL('EditUser', $userName, array('returnto' => $this->getTitle()->getPrefixedText()));
        $contribsHref = $this->getSpecialPageURL('Contributions', $userName);
        $logsHref = $this->getSpecialPageURL('Log', $userName);
        return <<<EOT
<tr>
    <td><input type="checkbox" name="userids[]" value="{$id}" checked/></td>
    <td>{$id}</td>
    <td><a href="{$userPageURL}">{$userName}</a> <a href="{$editHref}">({$this->editactionlabel}</a> | <a href="{$contribsHref}">{$this->contributionsactionlabel}</a> | <a href="{$logsHref}">{$this->logsactionlabel}</a>) </td>
    <td>{$realName}</td>
    <td>{$emailHTML}{$unconfirmed}</a></td>
    <td>{$groupsHTML}</td>
    <td>{$createDate}</td>
    <td>{$userTouchedDate}</td>
    <td>{$lastEditDate}</td>
    <td>{$editCount}</td>
</tr>
EOT;
    }
 /**
  * Adds a table with checkboxes where you can select what groups to add/remove
  *
  * @todo Just pass the username string?
  * @param array $usergroups Groups the user belongs to
  * @param User $user
  * @return string XHTML table element with checkboxes
  */
 private function groupCheckboxes($usergroups, $user)
 {
     $allgroups = $this->getAllGroups();
     $ret = '';
     // Put all column info into an associative array so that extensions can
     // more easily manage it.
     $columns = array('unchangeable' => array(), 'changeable' => array());
     foreach ($allgroups as $group) {
         $set = in_array($group, $usergroups);
         // Should the checkbox be disabled?
         $disabled = !($set && $this->canRemove($group) || !$set && $this->canAdd($group));
         // Do we need to point out that this action is irreversible?
         $irreversible = !$disabled && ($set && !$this->canAdd($group) || !$set && !$this->canRemove($group));
         $checkbox = array('set' => $set, 'disabled' => $disabled, 'irreversible' => $irreversible);
         if ($disabled) {
             $columns['unchangeable'][$group] = $checkbox;
         } else {
             $columns['changeable'][$group] = $checkbox;
         }
     }
     // Build the HTML table
     $ret .= Xml::openElement('table', array('class' => 'mw-userrights-groups')) . "<tr>\n";
     foreach ($columns as $name => $column) {
         if ($column === array()) {
             continue;
         }
         // Messages: userrights-changeable-col, userrights-unchangeable-col
         $ret .= Xml::element('th', null, $this->msg('userrights-' . $name . '-col', count($column))->text());
     }
     $ret .= "</tr>\n<tr>\n";
     foreach ($columns as $column) {
         if ($column === array()) {
             continue;
         }
         $ret .= "\t<td style='vertical-align:top;'>\n";
         foreach ($column as $group => $checkbox) {
             $attr = $checkbox['disabled'] ? array('disabled' => 'disabled') : array();
             $member = User::getGroupMember($group, $user->getName());
             if ($checkbox['irreversible']) {
                 $text = $this->msg('userrights-irreversible-marker', $member)->text();
             } else {
                 $text = $member;
             }
             $checkboxHtml = Xml::checkLabel($text, "wpGroup-" . $group, "wpGroup-" . $group, $checkbox['set'], $attr);
             $ret .= "\t\t" . ($checkbox['disabled'] ? Xml::tags('span', array('class' => 'mw-userrights-disabled'), $checkboxHtml) : $checkboxHtml) . "<br />\n";
         }
         $ret .= "\t</td>\n";
     }
     $ret .= Xml::closeElement('tr') . Xml::closeElement('table');
     return $ret;
 }
Example #9
0
 /**
  * Generate text for a log entry. 
  * Only LogFormatter should call this function.
  *
  * @param $type String: log type
  * @param $action String: log action
  * @param $title Mixed: Title object or null
  * @param $skin Mixed: Skin object or null. If null, we want to use the wiki
  *              content language, since that will go to the IRC feed.
  * @param $params Array: parameters
  * @param $filterWikilinks Boolean: whether to filter wiki links
  * @return HTML string
  */
 public static function actionText($type, $action, $title = null, $skin = null, $params = array(), $filterWikilinks = false)
 {
     global $wgLang, $wgContLang, $wgLogActions;
     if (is_null($skin)) {
         $langObj = $wgContLang;
         $langObjOrNull = null;
     } else {
         $langObj = $wgLang;
         $langObjOrNull = $wgLang;
     }
     $key = "{$type}/{$action}";
     if (isset($wgLogActions[$key])) {
         if (is_null($title)) {
             $rv = wfMessage($wgLogActions[$key])->inLanguage($langObj)->escaped();
         } else {
             $titleLink = self::getTitleLink($type, $langObjOrNull, $title, $params);
             if (preg_match('/^rights\\/(rights|autopromote)/', $key)) {
                 $rightsnone = wfMessage('rightsnone')->inLanguage($langObj)->text();
                 if ($skin) {
                     $username = $title->getText();
                     foreach ($params as &$param) {
                         $groupArray = array_map('trim', explode(',', $param));
                         foreach ($groupArray as &$group) {
                             $group = User::getGroupMember($group, $username);
                         }
                         $param = $wgLang->listToText($groupArray);
                     }
                 }
                 if (!isset($params[0]) || trim($params[0]) == '') {
                     $params[0] = $rightsnone;
                 }
                 if (!isset($params[1]) || trim($params[1]) == '') {
                     $params[1] = $rightsnone;
                 }
             }
             if (count($params) == 0) {
                 $rv = wfMessage($wgLogActions[$key])->rawParams($titleLink)->inLanguage($langObj)->escaped();
             } else {
                 $details = '';
                 array_unshift($params, $titleLink);
                 // User suppression
                 if (preg_match('/^(block|suppress)\\/(block|reblock)$/', $key)) {
                     if ($skin) {
                         $params[1] = '<span class="blockExpiry" dir="ltr" title="' . htmlspecialchars($params[1]) . '">' . $wgLang->translateBlockExpiry($params[1]) . '</span>';
                     } else {
                         $params[1] = $wgContLang->translateBlockExpiry($params[1]);
                     }
                     $params[2] = isset($params[2]) ? self::formatBlockFlags($params[2], $langObj) : '';
                     // Page protections
                 } elseif ($type == 'protect' && count($params) == 3) {
                     // Restrictions and expiries
                     if ($skin) {
                         $details .= $wgLang->getDirMark() . htmlspecialchars(" {$params[1]}");
                     } else {
                         $details .= " {$params[1]}";
                     }
                     // Cascading flag...
                     if ($params[2]) {
                         $details .= ' [' . wfMessage('protect-summary-cascade')->inLanguage($langObj)->text() . ']';
                     }
                 }
                 $rv = wfMessage($wgLogActions[$key])->rawParams($params)->inLanguage($langObj)->escaped() . $details;
             }
         }
     } else {
         global $wgLogActionsHandlers;
         if (isset($wgLogActionsHandlers[$key])) {
             $args = func_get_args();
             $rv = call_user_func_array($wgLogActionsHandlers[$key], $args);
         } else {
             wfDebug("LogPage::actionText - unknown action {$key}\n");
             $rv = "{$action}";
         }
     }
     // For the perplexed, this feature was added in r7855 by Erik.
     // The feature was added because we liked adding [[$1]] in our log entries
     // but the log entries are parsed as Wikitext on RecentChanges but as HTML
     // on Special:Log. The hack is essentially that [[$1]] represented a link
     // to the title in question. The first parameter to the HTML version (Special:Log)
     // is that link in HTML form, and so this just gets rid of the ugly [[]].
     // However, this is a horrible hack and it doesn't work like you expect if, say,
     // you want to link to something OTHER than the title of the log entry.
     // The real problem, which Erik was trying to fix (and it sort-of works now) is
     // that the same messages are being treated as both wikitext *and* HTML.
     if ($filterWikilinks) {
         $rv = str_replace('[[', '', $rv);
         $rv = str_replace(']]', '', $rv);
     }
     return $rv;
 }
 function showCredentials()
 {
     $reqUser = $this->getUser();
     $out = $this->getOutput();
     $titleObj = SpecialPage::getTitleFor('UserCredentials');
     $row = $this->getAccountData();
     if (!$row) {
         $out->addHTML($this->msg('usercredentials-badid')->escaped());
         return;
     }
     $out->addWikiMsg('usercredentials-text');
     $user = User::newFromName($this->target);
     $list = array();
     foreach ($user->getGroups() as $group) {
         $list[] = User::makeGroupLinkHTML($group, User::getGroupMember($group, $user->getName()));
     }
     $grouplist = '';
     if (count($list) > 0) {
         $grouplist = '<tr><td>' . $this->msg('usercredentials-member')->escaped() . '</td><td>' . implode(', ', $list) . '</td></tr>';
     }
     $form = "<fieldset>";
     $form .= '<legend>' . $this->msg('usercredentials-leg-user')->escaped() . '</legend>';
     $form .= '<table style="padding:4px;">';
     $form .= "<tr><td>" . $this->msg('username')->escaped() . "</td>";
     $form .= "<td>" . Linker::makeLinkObj($user->getUserPage(), htmlspecialchars($user->getUserPage()->getText())) . "</td></tr>\n";
     $econf = $row->acd_email_authenticated ? ' <strong>' . $this->msg('confirmaccount-econf')->escaped() . '</strong>' : '';
     $form .= "<tr><td>" . $this->msg('usercredentials-email')->escaped() . "</td>";
     $form .= "<td>" . htmlspecialchars($row->acd_email) . $econf . "</td></tr>\n";
     $form .= $grouplist;
     $form .= '</table></fieldset>';
     $areaSet = UserAccountRequest::expandAreas($row->acd_areas);
     $userAreas = ConfirmAccount::getUserAreaConfig();
     if (count($userAreas) > 0) {
         $form .= '<fieldset>';
         $form .= '<legend>' . $this->msg('confirmaccount-leg-areas')->escaped() . '</legend>';
         $form .= "<div style='height:150px; overflow:scroll; background-color:#f9f9f9;'>";
         $form .= "<table style='border-spacing:5px; padding:0px; background-color:#f9f9f9;'><tr style='vertical-align: top;'>";
         $count = 0;
         $att = array('disabled' => 'disabled');
         foreach ($userAreas as $name => $conf) {
             $count++;
             if ($count > 5) {
                 $form .= "</tr><tr style='vertical-align: top;'>";
                 $count = 1;
             }
             $formName = "wpArea-" . htmlspecialchars(str_replace(' ', '_', $name));
             if ($conf['project'] != '') {
                 $pg = Linker::linkKnown(Title::newFromText($name), $this->msg('requestaccount-info')->escaped());
             } else {
                 $pg = '';
             }
             $form .= "<td>" . Xml::checkLabel($name, $formName, $formName, in_array($formName, $areaSet), $att) . " {$pg}</td>\n";
         }
         $form .= "</tr></table></div>";
         $form .= '</fieldset>';
     }
     $form .= '<fieldset>';
     $form .= '<legend>' . $this->msg('usercredentials-leg-person')->escaped() . '</legend>';
     $form .= '<table style="padding:4px;">';
     $form .= "<tr><td>" . $this->msg('usercredentials-real')->escaped() . "</td>";
     $form .= "<td>" . htmlspecialchars($row->acd_real_name) . "</td></tr>\n";
     $form .= '</table>';
     $form .= "<p>" . $this->msg('usercredentials-bio')->escaped() . "</p>";
     $form .= "<p><textarea tabindex='1' readonly='readonly' name='wpBio' id='wpNewBio' rows='10' cols='80' style='width:100%'>" . htmlspecialchars($row->acd_bio) . "</textarea></p>\n";
     $form .= '</fieldset>';
     $form .= '<fieldset>';
     $form .= '<legend>' . $this->msg('usercredentials-leg-other')->escaped() . '</legend>';
     if ($this->hasItem('CV') || $this->hasItem('Notes') || $this->hasItem('Links')) {
         $form .= '<p>' . $this->msg('usercredentials-attach')->escaped() . ' ';
         if ($row->acd_filename) {
             $form .= Linker::makeKnownLinkObj($titleObj, htmlspecialchars($row->acd_filename), 'file=' . $row->acd_storage_key);
         } else {
             $form .= $this->msg('confirmaccount-none-p')->escaped();
         }
         $form .= "</p><p>" . $this->msg('usercredentials-notes')->escaped() . "</p>\n";
         $form .= "<p><textarea tabindex='1' readonly='readonly' name='wpNotes' id='wpNotes' rows='3' cols='80' style='width:100%'>" . htmlspecialchars($row->acd_notes) . "</textarea></p>\n";
         $form .= "<p>" . $this->msg('usercredentials-urls')->escaped() . "</p>\n";
         $form .= ConfirmAccountsPage::parseLinks($row->acd_urls);
     }
     $form .= '</fieldset>';
     if ($reqUser->isAllowed('requestips')) {
         $form .= '<fieldset>';
         $form .= '<legend>' . $this->msg('usercredentials-leg-ip')->escaped() . '</legend>';
         $form .= "<p>" . $this->msg('usercredentials-ip')->escaped() . " " . htmlspecialchars($row->acd_ip) . "</p>\n";
         if ($row->acd_xff) {
             $form .= "<p>" . $this->msg('usercredentials-xff')->escaped() . " " . htmlspecialchars($row->acd_xff) . "</p>\n";
         }
         if ($row->acd_agent) {
             $form .= "<p>" . $this->msg('usercredentials-agent')->escaped() . " " . htmlspecialchars($row->acd_agent) . "</p>\n";
         }
         $form .= '</fieldset>';
     }
     $out->addHTML($form);
 }
 /**
  * Adds a table with checkboxes where you can select what groups to add/remove
  *
  * @param $usergroups Array: groups the user belongs to
  * @return string XHTML table element with checkboxes
  */
 private function groupCheckboxes($usergroups)
 {
     $allgroups = $this->getAllGroups();
     $ret = '';
     $column = 1;
     $settable_col = '';
     $unsettable_col = '';
     foreach ($allgroups as $group) {
         $set = in_array($group, $usergroups);
         $attr = array();
         $text = User::getGroupMember($group);
         $checkbox = Xml::checkLabel($text, "wpGroup-{$group}", "wpGroup-{$group}", $set, $attr);
         $settable_col .= "{$checkbox}<br />\n";
     }
     if ($column) {
         $ret .= Xml::openElement('table', array('border' => '0', 'class' => 'mw-userrights-groups')) . "<tr>";
         if ($settable_col !== '') {
             $ret .= xml::element('th', null, wfMsg('userrights-changeable-col'));
         }
         if ($unsettable_col !== '') {
             $ret .= xml::element('th', null, wfMsg('userrights-unchangeable-col'));
         }
         $ret .= "</tr>\n\t\t\t\t<tr>";
         if ($settable_col !== '') {
             $ret .= "\n\t\t\t\t\t<td style='vertical-align:top;'>\n\t\t\t\t\t\t{$settable_col}\n\t\t\t\t\t</td>";
         }
         if ($unsettable_col !== '') {
             $ret .= "\n\t\t\t\t\t<td style='vertical-align:top;'>\n\t\t\t\t\t\t{$unsettable_col}\n\t\t\t\t\t</td>";
         }
         $ret .= Xml::closeElement('tr') . Xml::closeElement('table');
     }
     return $ret;
 }
 protected function getAddRow()
 {
     $user = $this->getUser();
     $lang = $this->getLanguage();
     $add = Html::hidden('title', $this->getPageTitle()->getPrefixedDBKey()) . Html::hidden('token', $user->getEditToken('is')) . Html::hidden('do', 'add') . Xml::submitButton($this->msg('is-add')->text());
     $attribs = array('method' => 'post', 'action' => $this->getPageTitle()->getLocalUrl());
     $groupChecks = array();
     foreach ($this->groups as $group) {
         $groupChecks[] = Xml::checkLabel(User::getGroupMember($group), "group-{$group}", "group-{$group}");
     }
     $row = Html::openElement('tr') . Html::openElement('form', $attribs) . Html::element('td', null, $lang->userTimeAndDate(wfTimestamp(), $user)) . Html::rawElement('td', null, Xml::input('email')) . Html::element('td', null, $user->getName()) . Html::element('td', null, '') . Html::rawElement('td', null, implode(' ', $groupChecks)) . Html::rawElement('td', null, $add) . Html::closeElement('form') . Html::closeElement('tr');
     return $row;
 }
 /**
  * @param $row
  * @return bool|string
  */
 protected function getUserGroups($row)
 {
     if (!$row->gug_numgroups) {
         return false;
     }
     if ($row->gug_numgroups == 1) {
         return User::makeGroupLinkWiki($row->gug_singlegroup, User::getGroupMember($row->gug_singlegroup));
     }
     $result = $this->mDb->select('global_user_groups', 'gug_group', array('gug_user' => $row->gu_id), __METHOD__);
     $rights = array();
     foreach ($result as $row2) {
         $rights[] = User::makeGroupLinkWiki($row2->gug_group, User::getGroupMember($row2->gug_group));
     }
     return implode(', ', $rights);
 }
 /**
  * Format a link to a group description page
  *
  * @param string $group
  * @return string
  */
 private static function buildGroupLink($group)
 {
     static $cache = array();
     if (!isset($cache[$group])) {
         $cache[$group] = User::makeGroupLinkHtml($group, User::getGroupMember($group));
     }
     return $cache[$group];
 }
Example #15
0
 /**
  * @param $user User
  * @param $context IContextSource
  * @param $defaultPreferences
  * @return void
  */
 static function profilePreferences($user, IContextSource $context, &$defaultPreferences)
 {
     global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode, $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars, $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication, $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress;
     ## User info #####################################
     // Information panel
     $defaultPreferences['username'] = array('type' => 'info', 'label-message' => 'username', 'default' => $user->getName(), 'section' => 'personal/info');
     $defaultPreferences['userid'] = array('type' => 'info', 'label-message' => 'uid', 'default' => $user->getId(), 'section' => 'personal/info');
     # Get groups to which the user belongs
     $userEffectiveGroups = $user->getEffectiveGroups();
     $userGroups = $userMembers = array();
     foreach ($userEffectiveGroups as $ueg) {
         if ($ueg == '*') {
             // Skip the default * group, seems useless here
             continue;
         }
         $groupName = User::getGroupName($ueg);
         $userGroups[] = User::makeGroupLinkHTML($ueg, $groupName);
         $memberName = User::getGroupMember($ueg, $user->getName());
         $userMembers[] = User::makeGroupLinkHTML($ueg, $memberName);
     }
     asort($userGroups);
     asort($userMembers);
     $lang = $context->getLanguage();
     $defaultPreferences['usergroups'] = array('type' => 'info', 'label' => $context->msg('prefs-memberingroups')->numParams(count($userGroups))->parse(), 'default' => $context->msg('prefs-memberingroups-type', $lang->commaList($userGroups), $lang->commaList($userMembers))->plain(), 'raw' => true, 'section' => 'personal/info');
     $defaultPreferences['editcount'] = array('type' => 'info', 'label-message' => 'prefs-edits', 'default' => $lang->formatNum($user->getEditCount()), 'section' => 'personal/info');
     if ($user->getRegistration()) {
         $displayUser = $context->getUser();
         $userRegistration = $user->getRegistration();
         $defaultPreferences['registrationdate'] = array('type' => 'info', 'label-message' => 'prefs-registration', 'default' => $context->msg('prefs-registration-date-time', $lang->userTimeAndDate($userRegistration, $displayUser), $lang->userDate($userRegistration, $displayUser), $lang->userTime($userRegistration, $displayUser))->parse(), 'section' => 'personal/info');
     }
     // Actually changeable stuff
     $defaultPreferences['realname'] = array('type' => $wgAuth->allowPropChange('realname') ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname');
     $defaultPreferences['gender'] = array('type' => 'select', 'section' => 'personal/info', 'options' => array($context->msg('gender-male')->text() => 'male', $context->msg('gender-female')->text() => 'female', $context->msg('gender-unknown')->text() => 'unknown'), 'label-message' => 'yourgender', 'help-message' => 'prefs-help-gender');
     if ($wgAuth->allowPasswordChange()) {
         $link = Linker::link(SpecialPage::getTitleFor('ChangePassword'), $context->msg('prefs-resetpass')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
         $defaultPreferences['password'] = array('type' => 'info', 'raw' => true, 'default' => $link, 'label-message' => 'yourpassword', 'section' => 'personal/info');
     }
     if ($wgCookieExpiration > 0) {
         $defaultPreferences['rememberpassword'] = array('type' => 'toggle', 'label' => $context->msg('tog-rememberpassword')->numParams(ceil($wgCookieExpiration / (3600 * 24)))->text(), 'section' => 'personal/info');
     }
     // Language
     /** WIKIA CHANGE BEGIN **/
     $languages = wfGetFixedLanguageNames();
     /** WIKIA CHANGE END **/
     if (!array_key_exists($wgLanguageCode, $languages)) {
         $languages[$wgLanguageCode] = $wgLanguageCode;
     }
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $display = wfBCP47($code) . ' - ' . $name;
         $options[$display] = $code;
     }
     $defaultPreferences['language'] = array('type' => 'select', 'section' => 'personal/i18n', 'options' => $options, 'label-message' => 'yourlanguage');
     /* see if there are multiple language variants to choose from*/
     $variantArray = array();
     if (!$wgDisableLangConversion) {
         $variants = $wgContLang->getVariants();
         foreach ($variants as $v) {
             $v = str_replace('_', '-', strtolower($v));
             $variantArray[$v] = $wgContLang->getVariantname($v, false);
         }
         $options = array();
         foreach ($variantArray as $code => $name) {
             $display = wfBCP47($code) . ' - ' . $name;
             $options[$display] = $code;
         }
         if (count($variantArray) > 1) {
             $defaultPreferences['variant'] = array('label-message' => 'yourvariant', 'type' => 'select', 'options' => $options, 'section' => 'personal/i18n', 'help-message' => 'prefs-help-variant');
         }
     }
     if (count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
         $defaultPreferences['noconvertlink'] = array('type' => 'toggle', 'section' => 'personal/i18n', 'label-message' => 'tog-noconvertlink');
     }
     // show a preview of the old signature first
     $oldsigWikiText = $wgParser->preSaveTransform("~~~", $context->getTitle(), $user, ParserOptions::newFromContext($context));
     $oldsigHTML = $context->getOutput()->parseInline($oldsigWikiText, true, true);
     $defaultPreferences['oldsig'] = array('type' => 'info', 'raw' => true, 'label-message' => 'tog-oldsig', 'default' => $oldsigHTML, 'section' => 'personal/signature');
     $defaultPreferences['nickname'] = array('type' => $wgAuth->allowPropChange('nickname') ? 'text' : 'info', 'maxlength' => $wgMaxSigChars, 'label-message' => 'yournick', 'validation-callback' => array('Preferences', 'validateSignature'), 'section' => 'personal/signature', 'filter-callback' => array('Preferences', 'cleanSignature'));
     $defaultPreferences['fancysig'] = array('type' => 'toggle', 'label-message' => 'tog-fancysig', 'help-message' => 'prefs-help-signature', 'section' => 'personal/signature');
     ## Email stuff
     if ($wgEnableEmail) {
         $helpMessages[] = $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email';
         if ($wgEnableUserEmail) {
             // additional messages when users can send email to each other
             $helpMessages[] = 'prefs-help-email-others';
         }
         $link = Linker::link(SpecialPage::getTitleFor('ChangeEmail'), $context->msg($user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
         $emailAddress = $user->getEmail() ? htmlspecialchars($user->getEmail()) : '';
         if ($wgAuth->allowPropChange('emailaddress')) {
             $emailAddress .= $emailAddress == '' ? $link : " ({$link})";
         }
         $defaultPreferences['emailaddress'] = array('type' => 'info', 'raw' => true, 'default' => $emailAddress, 'label-message' => 'youremail', 'section' => 'personal/email', 'help-messages' => $helpMessages);
         $disableEmailPrefs = false;
         if ($wgEmailAuthentication) {
             /* Wikia change - begin */
             $emailauthenticated = '';
             wfRunHooks('PreferencesGetEmailAuthentication', array(&$user, $context, &$disableEmailPrefs, &$emailauthenticated));
             if (empty($emailauthenticated)) {
                 /* Wikia change - end */
                 if ($user->getEmail()) {
                     if ($user->getEmailAuthenticationTimestamp()) {
                         // date and time are separate parameters to facilitate localisation.
                         // $time is kept for backward compat reasons.
                         // 'emailauthenticated' is also used in SpecialConfirmemail.php
                         $displayUser = $context->getUser();
                         $emailTimestamp = $user->getEmailAuthenticationTimestamp();
                         $time = $lang->userTimeAndDate($emailTimestamp, $displayUser);
                         $d = $lang->userDate($emailTimestamp, $displayUser);
                         $t = $lang->userTime($emailTimestamp, $displayUser);
                         $emailauthenticated = $context->msg('emailauthenticated', $time, $d, $t)->parse() . '<br />';
                         $disableEmailPrefs = false;
                     } else {
                         $disableEmailPrefs = true;
                         $emailauthenticated = $context->msg('emailnotauthenticated')->parse() . '<br />' . Linker::linkKnown(SpecialPage::getTitleFor('Confirmemail'), $context->msg('emailconfirmlink')->escaped()) . '<br />';
                     }
                 } else {
                     $disableEmailPrefs = true;
                     $emailauthenticated = $context->msg('noemailprefs')->escaped();
                 }
             }
             $defaultPreferences['emailauthentication'] = array('type' => 'info', 'raw' => true, 'section' => 'personal/email', 'label-message' => 'prefs-emailconfirm-label', 'default' => $emailauthenticated);
         }
         if ($wgEnableUserEmail && $user->isAllowed('sendemail')) {
             $defaultPreferences['disablemail'] = array('type' => 'toggle', 'invert' => true, 'section' => 'personal/email', 'label-message' => 'allowemail', 'disabled' => $disableEmailPrefs);
             $defaultPreferences['ccmeonemails'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-ccmeonemails', 'disabled' => $disableEmailPrefs);
         }
         if ($wgEnotifWatchlist) {
             $defaultPreferences['enotifwatchlistpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifwatchlistpages', 'disabled' => $disableEmailPrefs);
         }
         if ($wgEnotifUserTalk) {
             $defaultPreferences['enotifusertalkpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifusertalkpages', 'disabled' => $disableEmailPrefs);
         }
         if ($wgEnotifUserTalk || $wgEnotifWatchlist) {
             $defaultPreferences['enotifminoredits'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifminoredits', 'disabled' => $disableEmailPrefs);
             if ($wgEnotifRevealEditorAddress) {
                 $defaultPreferences['enotifrevealaddr'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifrevealaddr', 'disabled' => $disableEmailPrefs);
             }
         }
         /* Wikia change begin - @author: Inez */
         $defaultPreferences['marketingallowed'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-marketingallowed');
         /* Wikia change end */
     }
 }
Example #16
0
 /**
  * Adds a table with checkboxes where you can select what groups to add/remove
  *
  * @todo Just pass the username string?
  * @param $usergroups Array: groups the user belongs to
  * @param $user User a user object
  * @return string XHTML table element with checkboxes
  */
 private function groupCheckboxes($usergroups, $user)
 {
     $allgroups = $this->getAllGroups();
     $ret = '';
     # Put all column info into an associative array so that extensions can
     # more easily manage it.
     $columns = array('unchangeable' => array(), 'changeable' => array());
     foreach ($allgroups as $group) {
         $set = in_array($group, $usergroups);
         # Should the checkbox be disabled?
         $disabled = !($set && $this->canRemove($group) || !$set && $this->canAdd($group));
         # Do we need to point out that this action is irreversible?
         $irreversible = !$disabled && ($set && !$this->canAdd($group) || !$set && !$this->canRemove($group));
         /* Wikia change begin - @author: Marooned */
         /* Because of "return all" in changeableGroups() hook UserrightsChangeableGroups is not invoked - this hook is to fill this gap */
         wfRunHooks('UserRights::groupCheckboxes', array($group, &$disabled, &$irreversible));
         /* Wikia change end */
         $checkbox = array('set' => $set, 'disabled' => $disabled, 'irreversible' => $irreversible);
         if ($disabled) {
             $columns['unchangeable'][$group] = $checkbox;
         } else {
             $columns['changeable'][$group] = $checkbox;
         }
     }
     # Build the HTML table
     $ret .= Xml::openElement('table', array('border' => '0', 'class' => 'mw-userrights-groups')) . "<tr>\n";
     foreach ($columns as $name => $column) {
         if ($column === array()) {
             continue;
         }
         $ret .= Xml::element('th', null, wfMessage('userrights-' . $name . '-col', count($column))->text());
     }
     $ret .= "</tr>\n<tr>\n";
     foreach ($columns as $column) {
         if ($column === array()) {
             continue;
         }
         $ret .= "\t<td style='vertical-align:top;'>\n";
         foreach ($column as $group => $checkbox) {
             $attr = $checkbox['disabled'] ? array('disabled' => 'disabled') : array();
             $member = User::getGroupMember($group, $user->getName());
             if ($checkbox['irreversible']) {
                 $text = wfMessage('userrights-irreversible-marker', $member)->escaped();
             } else {
                 $text = htmlspecialchars($member);
             }
             $checkboxHtml = Xml::checkLabel($text, "wpGroup-" . $group, "wpGroup-" . $group, $checkbox['set'], $attr);
             $ret .= "\t\t" . ($checkbox['disabled'] ? Xml::tags('span', array('class' => 'mw-userrights-disabled'), $checkboxHtml) : $checkboxHtml) . "<br />\n";
         }
         $ret .= "\t</td>\n";
     }
     $ret .= Xml::closeElement('tr') . Xml::closeElement('table');
     return $ret;
 }
 /**
  * @param $group
  */
 function buildGroupView($group)
 {
     $editable = $this->userCanEdit($this->getUser());
     $this->getOutput()->setSubtitle(wfMsg('centralauth-editgroup-subtitle', $group));
     $html = Xml::fieldset(wfMsg('centralauth-editgroup-fieldset', $group));
     if ($editable) {
         $html .= Xml::openElement('form', array('method' => 'post', 'action' => SpecialPage::getTitleFor('GlobalGroupPermissions', $group)->getLocalUrl(), 'name' => 'centralauth-globalgroups-newgroup'));
         $html .= Html::hidden('wpGroup', $group);
         $html .= Html::hidden('wpEditToken', $this->getUser()->getEditToken());
     }
     $fields = array();
     $fields['centralauth-editgroup-name'] = $group;
     $fields['centralauth-editgroup-display'] = wfMsgExt('centralauth-editgroup-display-edit', array('parseinline'), $group, User::getGroupName($group));
     $fields['centralauth-editgroup-member'] = wfMsgExt('centralauth-editgroup-member-edit', array('parseinline'), $group, User::getGroupMember($group));
     $fields['centralauth-editgroup-members'] = wfMsgExt('centralauth-editgroup-members-link', array('parseinline'), $group, User::getGroupMember($group));
     $fields['centralauth-editgroup-restrictions'] = $this->buildWikiSetSelector($group);
     $fields['centralauth-editgroup-perms'] = $this->buildCheckboxes($group);
     if ($editable) {
         $fields['centralauth-editgroup-reason'] = Xml::input('wpReason', 60);
     }
     $html .= Xml::buildForm($fields, $editable ? 'centralauth-editgroup-submit' : null);
     if ($editable) {
         $html .= Xml::closeElement('form');
     }
     $html .= Xml::closeElement('fieldset');
     $this->getOutput()->addHTML($html);
     $this->showLogFragment($group, $this->getOutput());
 }
 /**
  * Adds a table with checkboxes where you can select what groups to add/remove
  *
  * @return string XHTML table element with checkboxes
  */
 private function groupCheckboxes()
 {
     $usergroups = array();
     // kinda a hack... this array holds "selected" groups... of which there shouldn't be any for this SpecialPage
     $allgroups = self::$grantableUserGroups;
     $ret = '';
     $column = 1;
     $settable_col = '';
     $unsettable_col = '';
     foreach ($allgroups as $group) {
         $set = false;
         # Should the checkbox be disabled?
         $disabled = !(!$set && $this->canAdd($group));
         # Do we need to point out that this action is irreversible?
         $irreversible = !$disabled && ($set && !$this->canAdd($group) || !$set && !$this->canRemove($group));
         /* Wikia change begin - @author: Marooned */
         /* Because of "return all" in changeableGroups() hook UserrightsChangeableGroups is not invoked - this hook is to fill this gap */
         wfRunHooks('UserRights::groupCheckboxes', array($group, &$disabled, &$irreversible));
         /* Wikia change end */
         $attr = $disabled ? array('disabled' => 'disabled') : array();
         $attr['title'] = $group;
         $text = $irreversible ? wfMsgHtml('userrights-irreversible-marker', User::getGroupMember($group)) : User::getGroupMember($group);
         $checkbox = Xml::checkLabel($text, "wpGroup-{$group}", "wpGroup-{$group}", $set, $attr);
         $checkbox = $disabled ? Xml::tags('span', array('class' => 'mw-userrights-disabled'), $checkbox) : $checkbox;
         if ($disabled) {
             $unsettable_col .= "{$checkbox}<br />\n";
         } else {
             $settable_col .= "{$checkbox}<br />\n";
         }
     }
     if ($column) {
         $ret .= Xml::openElement('table', array('border' => '0', 'class' => 'mw-userrights-groups')) . "<tr>\n";
         if ($settable_col !== '') {
             $ret .= Xml::element('th', null, wfMsg('userrights-changeable-col'));
         }
         if ($unsettable_col !== '') {
             $ret .= Xml::element('th', null, wfMsg('userrights-unchangeable-col'));
         }
         $ret .= "</tr>\n\t\t\t\t<tr>\n";
         if ($settable_col !== '') {
             $ret .= "\t\t\t\t\t<td style='vertical-align:top;'>\n\t\t\t\t\t\t{$settable_col}\n\t\t\t\t\t</td>\n";
         }
         if ($unsettable_col !== '') {
             $ret .= "\t\t\t\t\t<td style='vertical-align:top;'>\n\t\t\t\t\t\t{$unsettable_col}\n\t\t\t\t\t</td>\n";
         }
         $ret .= Xml::closeElement('tr') . Xml::closeElement('table');
     }
     return $ret;
 }
 /**
  * Get the list of groups of user
  * @param User $user The user object to get the list from
  * @return string comma separated list of user groups
  */
 function listGroups(User $user)
 {
     # Get groups to which the user belongs
     $userGroups = $user->getGroups();
     $userMembers = array();
     foreach ($userGroups as $n => $ug) {
         $memberName = User::getGroupMember($ug, $user->getName());
         if ($n == 0) {
             $memberName = $this->getLanguage()->ucfirst($memberName);
         }
         $userMembers[] = User::makeGroupLinkHTML($ug, $memberName);
     }
     return $this->getLanguage()->commaList($userMembers);
 }
Example #20
0
 /**
  * @param $user User
  * @param $defaultPreferences
  * @return void
  */
 static function profilePreferences($user, &$defaultPreferences)
 {
     global $wgLang, $wgUser;
     ## User info #####################################
     // Information panel
     $defaultPreferences['username'] = array('type' => 'info', 'label-message' => 'username', 'default' => $user->getName(), 'section' => 'personal/info');
     $defaultPreferences['userid'] = array('type' => 'info', 'label-message' => 'uid', 'default' => $user->getId(), 'section' => 'personal/info');
     # Get groups to which the user belongs
     $userEffectiveGroups = $user->getEffectiveGroups();
     $userGroups = $userMembers = array();
     foreach ($userEffectiveGroups as $ueg) {
         if ($ueg == '*') {
             // Skip the default * group, seems useless here
             continue;
         }
         $groupName = User::getGroupName($ueg);
         $userGroups[] = User::makeGroupLinkHTML($ueg, $groupName);
         $memberName = User::getGroupMember($ueg);
         $userMembers[] = User::makeGroupLinkHTML($ueg, $memberName);
     }
     asort($userGroups);
     asort($userMembers);
     $defaultPreferences['usergroups'] = array('type' => 'info', 'label' => wfMsgExt('prefs-memberingroups', 'parseinline', $wgLang->formatNum(count($userGroups))), 'default' => wfMsgExt('prefs-memberingroups-type', array(), $wgLang->commaList($userGroups), $wgLang->commaList($userMembers)), 'raw' => true, 'section' => 'personal/info');
     $defaultPreferences['editcount'] = array('type' => 'info', 'label-message' => 'prefs-edits', 'default' => $wgLang->formatNum($user->getEditCount()), 'section' => 'personal/info');
     if ($user->getRegistration()) {
         $defaultPreferences['registrationdate'] = array('type' => 'info', 'label-message' => 'prefs-registration', 'default' => wfMsgExt('prefs-registration-date-time', 'parsemag', $wgLang->timeanddate($user->getRegistration(), true), $wgLang->date($user->getRegistration(), true), $wgLang->time($user->getRegistration(), true)), 'section' => 'personal/info');
     }
     // Actually changeable stuff
     global $wgAuth;
     $defaultPreferences['realname'] = array('type' => $wgAuth->allowPropChange('realname') ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname');
     $defaultPreferences['gender'] = array('type' => 'select', 'section' => 'personal/info', 'options' => array(wfMsg('gender-male') => 'male', wfMsg('gender-female') => 'female', wfMsg('gender-unknown') => 'unknown'), 'label-message' => 'yourgender', 'help-message' => 'prefs-help-gender');
     if ($wgAuth->allowPasswordChange()) {
         $link = $wgUser->getSkin()->link(SpecialPage::getTitleFor('ChangePassword'), wfMsgHtml('prefs-resetpass'), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
         $defaultPreferences['password'] = array('type' => 'info', 'raw' => true, 'default' => $link, 'label-message' => 'yourpassword', 'section' => 'personal/info');
     }
     global $wgCookieExpiration;
     if ($wgCookieExpiration > 0) {
         $defaultPreferences['rememberpassword'] = array('type' => 'toggle', 'label' => wfMsgExt('tog-rememberpassword', array('parsemag'), $wgLang->formatNum(ceil($wgCookieExpiration / (3600 * 24)))), 'section' => 'personal/info');
     }
     // Language
     global $wgLanguageCode;
     $languages = Language::getLanguageNames(false);
     if (!array_key_exists($wgLanguageCode, $languages)) {
         $languages[$wgLanguageCode] = $wgLanguageCode;
     }
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $display = wfBCP47($code) . ' - ' . $name;
         $options[$display] = $code;
     }
     $defaultPreferences['language'] = array('type' => 'select', 'section' => 'personal/i18n', 'options' => $options, 'label-message' => 'yourlanguage');
     global $wgContLang, $wgDisableLangConversion;
     global $wgDisableTitleConversion;
     /* see if there are multiple language variants to choose from*/
     $variantArray = array();
     if (!$wgDisableLangConversion) {
         $variants = $wgContLang->getVariants();
         $languages = Language::getLanguageNames(true);
         foreach ($variants as $v) {
             $v = str_replace('_', '-', strtolower($v));
             if (array_key_exists($v, $languages)) {
                 // If it doesn't have a name, we'll pretend it doesn't exist
                 $variantArray[$v] = $languages[$v];
             }
         }
         $options = array();
         foreach ($variantArray as $code => $name) {
             $display = wfBCP47($code) . ' - ' . $name;
             $options[$display] = $code;
         }
         if (count($variantArray) > 1) {
             $defaultPreferences['variant'] = array('label-message' => 'yourvariant', 'type' => 'select', 'options' => $options, 'section' => 'personal/i18n');
         }
     }
     if (count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
         $defaultPreferences['noconvertlink'] = array('type' => 'toggle', 'section' => 'personal/i18n', 'label-message' => 'tog-noconvertlink');
     }
     global $wgMaxSigChars, $wgOut, $wgParser;
     // show a preview of the old signature first
     $oldsigWikiText = $wgParser->preSaveTransform("~~~", new Title(), $user, new ParserOptions());
     $oldsigHTML = $wgOut->parseInline($oldsigWikiText);
     $defaultPreferences['oldsig'] = array('type' => 'info', 'raw' => true, 'label-message' => 'tog-oldsig', 'default' => $oldsigHTML, 'section' => 'personal/signature');
     $defaultPreferences['nickname'] = array('type' => $wgAuth->allowPropChange('nickname') ? 'text' : 'info', 'maxlength' => $wgMaxSigChars, 'label-message' => 'yournick', 'validation-callback' => array('Preferences', 'validateSignature'), 'section' => 'personal/signature', 'filter-callback' => array('Preferences', 'cleanSignature'));
     $defaultPreferences['fancysig'] = array('type' => 'toggle', 'label-message' => 'tog-fancysig', 'help-message' => 'prefs-help-signature', 'section' => 'personal/signature');
     ## Email stuff
     global $wgEnableEmail;
     if ($wgEnableEmail) {
         global $wgEmailConfirmToEdit;
         global $wgEnableUserEmail;
         $helpMessages[] = $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email';
         if ($wgEnableUserEmail) {
             // additional messages when users can send email to each other
             $helpMessages[] = 'prefs-help-email-others';
         }
         $defaultPreferences['emailaddress'] = array('type' => $wgAuth->allowPropChange('emailaddress') ? 'email' : 'info', 'default' => $user->getEmail(), 'section' => 'personal/email', 'label-message' => 'youremail', 'help-messages' => $helpMessages, 'validation-callback' => array('Preferences', 'validateEmail'));
         global $wgEmailAuthentication;
         $disableEmailPrefs = false;
         if ($wgEmailAuthentication) {
             if ($user->getEmail()) {
                 if ($user->getEmailAuthenticationTimestamp()) {
                     // date and time are separate parameters to facilitate localisation.
                     // $time is kept for backward compat reasons.
                     // 'emailauthenticated' is also used in SpecialConfirmemail.php
                     $time = $wgLang->timeAndDate($user->getEmailAuthenticationTimestamp(), true);
                     $d = $wgLang->date($user->getEmailAuthenticationTimestamp(), true);
                     $t = $wgLang->time($user->getEmailAuthenticationTimestamp(), true);
                     $emailauthenticated = wfMsgExt('emailauthenticated', 'parseinline', array($time, $d, $t)) . '<br />';
                     $disableEmailPrefs = false;
                 } else {
                     $disableEmailPrefs = true;
                     $skin = $wgUser->getSkin();
                     $emailauthenticated = wfMsgExt('emailnotauthenticated', 'parseinline') . '<br />' . $skin->link(SpecialPage::getTitleFor('Confirmemail'), wfMsg('emailconfirmlink'), array(), array(), array('known', 'noclasses')) . '<br />';
                 }
             } else {
                 $disableEmailPrefs = true;
                 $emailauthenticated = wfMsgHtml('noemailprefs');
             }
             $defaultPreferences['emailauthentication'] = array('type' => 'info', 'raw' => true, 'section' => 'personal/email', 'label-message' => 'prefs-emailconfirm-label', 'default' => $emailauthenticated);
         }
         if ($wgEnableUserEmail && $user->isAllowed('sendemail')) {
             $defaultPreferences['disablemail'] = array('type' => 'toggle', 'invert' => true, 'section' => 'personal/email', 'label-message' => 'allowemail', 'disabled' => $disableEmailPrefs);
             $defaultPreferences['ccmeonemails'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-ccmeonemails', 'disabled' => $disableEmailPrefs);
         }
         global $wgEnotifWatchlist;
         if ($wgEnotifWatchlist) {
             $defaultPreferences['enotifwatchlistpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifwatchlistpages', 'disabled' => $disableEmailPrefs);
         }
         global $wgEnotifUserTalk;
         if ($wgEnotifUserTalk) {
             $defaultPreferences['enotifusertalkpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifusertalkpages', 'disabled' => $disableEmailPrefs);
         }
         if ($wgEnotifUserTalk || $wgEnotifWatchlist) {
             $defaultPreferences['enotifminoredits'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifminoredits', 'disabled' => $disableEmailPrefs);
             global $wgEnotifRevealEditorAddress;
             if ($wgEnotifRevealEditorAddress) {
                 $defaultPreferences['enotifrevealaddr'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifrevealaddr', 'disabled' => $disableEmailPrefs);
             }
         }
     }
 }
    function doGET()
    {
        global $wgLang, $wgOut, $wgUser, $wgAuth;
        $this->validateGETParams();
        $groupsHTML = '';
        foreach (User::getAllGroups() as $groupName) {
            $localName = User::getGroupMember($groupName);
            $groupsHTML .= <<<EOT
<input id="grp{$groupName}" type="checkbox" name="groups[]" value="{$groupName}"/> <label for="grp{$groupName}">{$localName}</label><br/>
EOT;
        }
        $pwdtitleHref = Title::newFromText('passwordremindertitle', NS_MEDIAWIKI)->getLocalURL();
        $pwdtextHref = Title::newFromText('passwordremindertext', NS_MEDIAWIKI)->getLocalURL();
        $welcomeTitleHref = Title::newFromText('createaccount-title', NS_MEDIAWIKI)->getLocalURL();
        $welcomeTextHref = Title::newFromText('createaccount-text', NS_MEDIAWIKI)->getLocalURL();
        $returnToHTML = '';
        if (!empty($this->returnto)) {
            $returnToHTML = self::parse(wfMsg('uadm-returntomsg', $this->returnto));
        }
        $postURL = $this->getURL($this->mParams);
        $editToken = $wgUser->editToken('adduser' . $wgUser->getName());
        $previewPasswordEmailHref = $this->getURL(array('preview' => 'password') + $this->mParams);
        $previewWelcomeEmailHref = $this->getURL(array('preview' => 'welcome') + $this->mParams);
        $previewPasswordEmailHTML = '';
        $previewWelcomeEmailHTML = '';
        $setPasswordChecked = 'checked';
        $emailPasswordChecked = '';
        $emailWelcomeChecked = '';
        if (!empty($this->preview)) {
            $tempUser = new User();
            $tempUser->setName($this->username);
            $tempUser->setRealName($this->realname);
            $tempUser->setEmail($this->email);
            switch ($this->preview) {
                case 'welcome':
                    list($subject, $body) = $this->getWelcomeMailMessage($tempUser);
                    break;
            }
            $previewHTML = <<<EOT
<table>
  <tr>
    <td>{$this->subjectlabel}</td>
    <td><input value="{$subject}" size="70" disabled="disabled"/></td>
  <tr>
    <td colspan="2"><textarea rows="10" cols="80" disabled="disabled">{$body}</textarea></td>
  </tr>
</table>
EOT;
            switch ($this->preview) {
                case 'welcome':
                    $previewWelcomeEmailHTML = $previewHTML;
                    $setPasswordChecked = '';
                    $emailWelcomeChecked = 'checked';
                    break;
            }
        }
        # Hack to detect if domain is needed
        $domainHTML = '';
        $template = new UsercreateTemplate();
        $temp = 'signup';
        // Bug fix. This does nothing.
        $wgAuth->autoCreate();
        // The first time wgAuth is called, some PHP auto-magic involving StubObject
        // occurs to "unstub" wgAuth AND call the function invoked. If the below
        // call is made as written, the call is actually made by calling
        // call_user_func_array and the arguments are passed by value even though
        // the modifyUITemplate expects them to be by reference.
        // This use to be a non issue since call-time pass-by-reference was allowed
        // $wgAuth->modifyUITemplate(&$template, &$temp);
        // This generates warnings now. Solution is to perform a no-op call to
        // wgAuth to "unstub" it so that the below call will be made directly and
        // not by call_user_func_array
        $wgAuth->modifyUITemplate($template, $temp);
        if (isset($template->data['usedomain']) && $template->data['usedomain'] == true) {
            $domainHTML = <<<EOT
      <tr>
        <td><label for="domain">{$this->domainfield}</label></td>
        <td><input id="domain" type="text" name="domain" size="30" value="{$this->domain}"/><br/></td>
      </tr>
EOT;
        }
        return <<<EOT
<form id="adduserform" name="input" action="{$postURL}" method="post" class="visualClear">
  <input type="hidden" name="edittoken" value="{$editToken}"/>
  <fieldset>
    <legend>{$this->adduserlabel}</legend>
    <table>
      <tr>
        <td><label for="username">{$this->usernamefield}</label></td>
        <td><input id="username" type="text" name="username" size="30" value="{$this->username}"/> {$this->requiredlabel}<br/></td>
      </tr>
{$domainHTML}
      <tr>
        <td><label for="realname">{$this->realnamefield}</label></td>
        <td><input id="realname" type="text" name="realname" size="30" value="{$this->realname}"/><br/></td>
      </tr>
      <tr>
        <td><label for="email">{$this->emailfield}</label></td>
        <td><input id="email" type="text" name="email" size="30" value="{$this->email}"/> {$this->requiredlabel}<br/></td>
      </tr>
    </table>
    <fieldset>
      <legend>{$this->editgroupslabel}</legend>
      {$groupsHTML}
    </fieldset>
    <fieldset>
      <legend>{$this->editpasswordlabel}</legend>
      <input id="pwdmanual" type="radio" name="pwdaction" value="manual" {$setPasswordChecked}/> <label for="pwdmanual">{$this->setpasswordforuserlabel}</label><br/>
        <table>
          <tr>
            <td><label for="password1">{$this->passwordlabel}</label></td>
            <td><input id="password1" type="password" name="password1" size="30"/></td>
          </tr>
          <tr>
            <td><label for="password2">{$this->verifypasswordlabel}</label></td>
            <td><input id="password2" type="password" name="password2" size="30"/></td>
          </tr>
        </table>
      <input id="pwdemailwelcome" type="radio" name="pwdaction" value="emailwelcome" {$emailWelcomeChecked}/> <label for="pwdemailwelcome">{$this->emailwelcomelabel}</label> <button type="submit" name="action" value="emailwelcomepreview">{$this->previewactionlabel}</button> (<a href="{$welcomeTitleHref}">{$this->subjectlabel}</a> | <a href="{$welcomeTextHref}">{$this->bodylabel}</a>)<br/>
      {$previewWelcomeEmailHTML}
    </fieldset>
    <button type="submit" name="action" value="adduser">{$this->adduserlabel}</button>
  </fieldset>
</form>
{$returnToHTML}
EOT;
    }
 /**
  * Format a link to a group description page
  *
  * @param string $group Group name
  * @param string $username Username
  * @return string
  */
 protected static function buildGroupLink($group, $username)
 {
     return User::makeGroupLinkHtml($group, User::getGroupMember($group, $username));
 }
 /**
  * @param $row
  * @return bool|string
  */
 protected function getUserGroups($row)
 {
     if (!$row->gug_numgroups) {
         return false;
     }
     $result = $this->mDb->select('global_user_groups', 'gug_group', array('gug_user' => $row->gu_id), __METHOD__);
     $globalgroups = array();
     foreach ($result as $row2) {
         if (!isset($this->wikiSets[$row2->gug_group])) {
             // We don't need to get the sets of groups we already know about.
             $globalgroups[] = $row2->gug_group;
         }
     }
     if (count($globalgroups) != 0) {
         $wikiSetQuery = $this->mDb->select(array('global_group_restrictions', 'wikiset'), array('ggr_group', 'ws_id', 'ws_name', 'ws_type', 'ws_wikis'), array('ggr_set=ws_id', 'ggr_group' => $globalgroups), __METHOD__);
         foreach ($wikiSetQuery as $wikiSetRow) {
             $this->wikiSets[$wikiSetRow->ggr_group] = WikiSet::newFromRow($wikiSetRow);
         }
     }
     $rights = array();
     foreach ($result as $row2) {
         if (isset($this->wikiSets[$row2->gug_group]) && !$this->wikiSets[$row2->gug_group]->inSet()) {
             $group = User::makeGroupLinkWiki($row2->gug_group, User::getGroupMember($row2->gug_group));
             $rights[] = Html::element('span', array('class' => 'groupnotappliedhere'), $group);
         } else {
             $rights[] = User::makeGroupLinkWiki($row2->gug_group, User::getGroupMember($row2->gug_group));
         }
     }
     return $this->getLanguage()->listToText($rights);
 }
Example #24
0
 /**
  * Adds a table with checkboxes where you can select what groups to add/remove
  *
  * @param $usergroups Array: groups the user belongs to
  * @return string XHTML table element with checkboxes
  */
 private function groupCheckboxes($usergroups)
 {
     $allgroups = $this->getAllGroups();
     $ret = '';
     $column = 1;
     $settable_col = '';
     $unsettable_col = '';
     foreach ($allgroups as $group) {
         $set = in_array($group, $usergroups);
         # Should the checkbox be disabled?
         $disabled = !($set && $this->canRemove($group) || !$set && $this->canAdd($group));
         # Do we need to point out that this action is irreversible?
         $irreversible = !$disabled && ($set && !$this->canAdd($group) || !$set && !$this->canRemove($group));
         $attr = $disabled ? array('disabled' => 'disabled') : array();
         $text = $irreversible ? wfMsgHtml('userrights-irreversible-marker', User::getGroupMember($group)) : User::getGroupMember($group);
         $checkbox = Xml::checkLabel($text, "wpGroup-{$group}", "wpGroup-{$group}", $set, $attr);
         $checkbox = $disabled ? Xml::tags('span', array('class' => 'mw-userrights-disabled'), $checkbox) : $checkbox;
         if ($disabled) {
             $unsettable_col .= "{$checkbox}<br />\n";
         } else {
             $settable_col .= "{$checkbox}<br />\n";
         }
     }
     if ($column) {
         $ret .= Xml::openElement('table', array('border' => '0', 'class' => 'mw-userrights-groups')) . "<tr>\n";
         if ($settable_col !== '') {
             $ret .= xml::element('th', null, wfMsg('userrights-changeable-col'));
         }
         if ($unsettable_col !== '') {
             $ret .= xml::element('th', null, wfMsg('userrights-unchangeable-col'));
         }
         $ret .= "</tr>\n\t\t\t\t<tr>\n";
         if ($settable_col !== '') {
             $ret .= "\t\t\t\t\t<td style='vertical-align:top;'>\n\t\t\t\t\t\t{$settable_col}\n\t\t\t\t\t</td>\n";
         }
         if ($unsettable_col !== '') {
             $ret .= "\t\t\t\t\t<td style='vertical-align:top;'>\n\t\t\t\t\t\t{$unsettable_col}\n\t\t\t\t\t</td>\n";
         }
         $ret .= Xml::closeElement('tr') . Xml::closeElement('table');
     }
     return $ret;
 }
 protected function getMessageParameters()
 {
     $params = parent::getMessageParameters();
     // Really old entries
     if (!isset($params[3]) && !isset($params[4])) {
         return $params;
     }
     $oldGroups = $params[3];
     $newGroups = $params[4];
     // Less old entries
     if ($oldGroups === '') {
         $oldGroups = array();
     } elseif (is_string($oldGroups)) {
         $oldGroups = array_map('trim', explode(',', $oldGroups));
     }
     if ($newGroups === '') {
         $newGroups = array();
     } elseif (is_string($newGroups)) {
         $newGroups = array_map('trim', explode(',', $newGroups));
     }
     $userName = $this->entry->getTarget()->getText();
     if (!$this->plaintext && count($oldGroups)) {
         foreach ($oldGroups as &$group) {
             $group = User::getGroupMember($group, $userName);
         }
     }
     if (!$this->plaintext && count($newGroups)) {
         foreach ($newGroups as &$group) {
             $group = User::getGroupMember($group, $userName);
         }
     }
     $lang = $this->context->getLanguage();
     if (count($oldGroups)) {
         $params[3] = $lang->listToText($oldGroups);
     } else {
         $params[3] = $this->msg('rightsnone')->text();
     }
     if (count($newGroups)) {
         $params[4] = $lang->listToText($newGroups);
     } else {
         $params[4] = $this->msg('rightsnone')->text();
     }
     return $params;
 }
Example #26
0
	/**
	 * @param $user User
	 * @param $context IContextSource
	 * @param $defaultPreferences
	 * @return void
	 */
	static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) {
		global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode,
			$wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars,
			$wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
			$wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress,
			$wgSecureLogin;

		// retrieving user name for GENDER and misc.
		$userName = $user->getName();

		## User info #####################################
		// Information panel
		$defaultPreferences['username'] = array(
			'type' => 'info',
			'label-message' => array( 'username', $userName ),
			'default' => $userName,
			'section' => 'personal/info',
		);

		$defaultPreferences['userid'] = array(
			'type' => 'info',
			'label-message' => array( 'uid', $userName ),
			'default' => $user->getId(),
			'section' => 'personal/info',
		);

		# Get groups to which the user belongs
		$userEffectiveGroups = $user->getEffectiveGroups();
		$userGroups = $userMembers = array();
		foreach ( $userEffectiveGroups as $ueg ) {
			if ( $ueg == '*' ) {
				// Skip the default * group, seems useless here
				continue;
			}
			$groupName = User::getGroupName( $ueg );
			$userGroups[] = User::makeGroupLinkHTML( $ueg, $groupName );

			$memberName = User::getGroupMember( $ueg, $userName );
			$userMembers[] = User::makeGroupLinkHTML( $ueg, $memberName );
		}
		asort( $userGroups );
		asort( $userMembers );

		$lang = $context->getLanguage();

		$defaultPreferences['usergroups'] = array(
			'type' => 'info',
			'label' => $context->msg( 'prefs-memberingroups' )->numParams(
				count( $userGroups ) )->params( $userName )->parse(),
			'default' => $context->msg( 'prefs-memberingroups-type',
				$lang->commaList( $userGroups ),
				$lang->commaList( $userMembers )
			)->plain(),
			'raw' => true,
			'section' => 'personal/info',
		);

		$editCount = Linker::link( SpecialPage::getTitleFor( "Contributions", $userName ),
			$lang->formatNum( $user->getEditCount() ) );

		$defaultPreferences['editcount'] = array(
			'type' => 'info',
			'raw' => true,
			'label-message' => 'prefs-edits',
			'default' => $editCount,
			'section' => 'personal/info',
		);

		if ( $user->getRegistration() ) {
			$displayUser = $context->getUser();
			$userRegistration = $user->getRegistration();
			$defaultPreferences['registrationdate'] = array(
				'type' => 'info',
				'label-message' => 'prefs-registration',
				'default' => $context->msg(
					'prefs-registration-date-time',
					$lang->userTimeAndDate( $userRegistration, $displayUser ),
					$lang->userDate( $userRegistration, $displayUser ),
					$lang->userTime( $userRegistration, $displayUser )
				)->parse(),
				'section' => 'personal/info',
			);
		}

		$canViewPrivateInfo = $user->isAllowed( 'viewmyprivateinfo' );
		$canEditPrivateInfo = $user->isAllowed( 'editmyprivateinfo' );

		// Actually changeable stuff
		$defaultPreferences['realname'] = array(
			// (not really "private", but still shouldn't be edited without permission)
			'type' => $canEditPrivateInfo && $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info',
			'default' => $user->getRealName(),
			'section' => 'personal/info',
			'label-message' => 'yourrealname',
			'help-message' => 'prefs-help-realname',
		);

		if ( $canEditPrivateInfo && $wgAuth->allowPasswordChange() ) {
			$link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ),
				$context->msg( 'prefs-resetpass' )->escaped(), array(),
				array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) );

			$defaultPreferences['password'] = array(
				'type' => 'info',
				'raw' => true,
				'default' => $link,
				'label-message' => 'yourpassword',
				'section' => 'personal/info',
			);
		}
		if ( $wgCookieExpiration > 0 ) {
			$defaultPreferences['rememberpassword'] = array(
				'type' => 'toggle',
				'label' => $context->msg( 'tog-rememberpassword' )->numParams(
					ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )->text(),
				'section' => 'personal/info',
			);
		}
		// Only show preferhttps if secure login is turned on
		if ( $wgSecureLogin && wfCanIPUseHTTPS( $context->getRequest()->getIP() ) ) {
			$defaultPreferences['prefershttps'] = array(
				'type' => 'toggle',
				'label-message' => 'tog-prefershttps',
				'help-message' => 'prefs-help-prefershttps',
				'section' => 'personal/info'
			);
		}

		// Language
		$languages = Language::fetchLanguageNames( null, 'mw' );
		if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
			$languages[$wgLanguageCode] = $wgLanguageCode;
		}
		ksort( $languages );

		$options = array();
		foreach ( $languages as $code => $name ) {
			$display = wfBCP47( $code ) . ' - ' . $name;
			$options[$display] = $code;
		}
		$defaultPreferences['language'] = array(
			'type' => 'select',
			'section' => 'personal/i18n',
			'options' => $options,
			'label-message' => 'yourlanguage',
		);

		$defaultPreferences['gender'] = array(
			'type' => 'radio',
			'section' => 'personal/i18n',
			'options' => array(
				$context->msg( 'parentheses',
					$context->msg( 'gender-unknown' )->text()
				)->text() => 'unknown',
				$context->msg( 'gender-female' )->text() => 'female',
				$context->msg( 'gender-male' )->text() => 'male',
			),
			'label-message' => 'yourgender',
			'help-message' => 'prefs-help-gender',
		);

		// see if there are multiple language variants to choose from
		if ( !$wgDisableLangConversion ) {
			foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
				if ( $langCode == $wgContLang->getCode() ) {
					$variants = $wgContLang->getVariants();

					if ( count( $variants ) <= 1 ) {
						continue;
					}

					$variantArray = array();
					foreach ( $variants as $v ) {
						$v = str_replace( '_', '-', strtolower( $v ) );
						$variantArray[$v] = $lang->getVariantname( $v, false );
					}

					$options = array();
					foreach ( $variantArray as $code => $name ) {
						$display = wfBCP47( $code ) . ' - ' . $name;
						$options[$display] = $code;
					}

					$defaultPreferences['variant'] = array(
						'label-message' => 'yourvariant',
						'type' => 'select',
						'options' => $options,
						'section' => 'personal/i18n',
						'help-message' => 'prefs-help-variant',
					);

					if ( !$wgDisableTitleConversion ) {
						$defaultPreferences['noconvertlink'] = array(
							'type' => 'toggle',
							'section' => 'personal/i18n',
							'label-message' => 'tog-noconvertlink',
						);
					}
				} else {
					$defaultPreferences["variant-$langCode"] = array(
						'type' => 'api',
					);
				}
			}
		}

		// Stuff from Language::getExtraUserToggles()
		// FIXME is this dead code? $extraUserToggles doesn't seem to be defined for any language
		$toggles = $wgContLang->getExtraUserToggles();

		foreach ( $toggles as $toggle ) {
			$defaultPreferences[$toggle] = array(
				'type' => 'toggle',
				'section' => 'personal/i18n',
				'label-message' => "tog-$toggle",
			);
		}

		// show a preview of the old signature first
		$oldsigWikiText = $wgParser->preSaveTransform( "~~~", $context->getTitle(), $user, ParserOptions::newFromContext( $context ) );
		$oldsigHTML = $context->getOutput()->parseInline( $oldsigWikiText, true, true );
		$defaultPreferences['oldsig'] = array(
			'type' => 'info',
			'raw' => true,
			'label-message' => 'tog-oldsig',
			'default' => $oldsigHTML,
			'section' => 'personal/signature',
		);
		$defaultPreferences['nickname'] = array(
			'type' => $wgAuth->allowPropChange( 'nickname' ) ? 'text' : 'info',
			'maxlength' => $wgMaxSigChars,
			'label-message' => 'yournick',
			'validation-callback' => array( 'Preferences', 'validateSignature' ),
			'section' => 'personal/signature',
			'filter-callback' => array( 'Preferences', 'cleanSignature' ),
		);
		$defaultPreferences['fancysig'] = array(
			'type' => 'toggle',
			'label-message' => 'tog-fancysig',
			'help-message' => 'prefs-help-signature', // show general help about signature at the bottom of the section
			'section' => 'personal/signature'
		);

		## Email stuff

		if ( $wgEnableEmail ) {
			if ( $canViewPrivateInfo ) {
				$helpMessages[] = $wgEmailConfirmToEdit
						? 'prefs-help-email-required'
						: 'prefs-help-email';

				if ( $wgEnableUserEmail ) {
					// additional messages when users can send email to each other
					$helpMessages[] = 'prefs-help-email-others';
				}

				$emailAddress = $user->getEmail() ? htmlspecialchars( $user->getEmail() ) : '';
				if ( $canEditPrivateInfo && $wgAuth->allowPropChange( 'emailaddress' ) ) {
					$link = Linker::link(
						SpecialPage::getTitleFor( 'ChangeEmail' ),
						$context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->escaped(),
						array(),
						array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) );

					$emailAddress .= $emailAddress == '' ? $link : (
						$context->msg( 'word-separator' )->plain()
						. $context->msg( 'parentheses' )->rawParams( $link )->plain()
					);
				}

				$defaultPreferences['emailaddress'] = array(
					'type' => 'info',
					'raw' => true,
					'default' => $emailAddress,
					'label-message' => 'youremail',
					'section' => 'personal/email',
					'help-messages' => $helpMessages,
					# 'cssclass' chosen below
				);
			}

			$disableEmailPrefs = false;

			if ( $wgEmailAuthentication ) {
				$emailauthenticationclass = 'mw-email-not-authenticated';
				if ( $user->getEmail() ) {
					if ( $user->getEmailAuthenticationTimestamp() ) {
						// date and time are separate parameters to facilitate localisation.
						// $time is kept for backward compat reasons.
						// 'emailauthenticated' is also used in SpecialConfirmemail.php
						$displayUser = $context->getUser();
						$emailTimestamp = $user->getEmailAuthenticationTimestamp();
						$time = $lang->userTimeAndDate( $emailTimestamp, $displayUser );
						$d = $lang->userDate( $emailTimestamp, $displayUser );
						$t = $lang->userTime( $emailTimestamp, $displayUser );
						$emailauthenticated = $context->msg( 'emailauthenticated',
							$time, $d, $t )->parse() . '<br />';
						$disableEmailPrefs = false;
						$emailauthenticationclass = 'mw-email-authenticated';
					} else {
						$disableEmailPrefs = true;
						$emailauthenticated = $context->msg( 'emailnotauthenticated' )->parse() . '<br />' .
							Linker::linkKnown(
								SpecialPage::getTitleFor( 'Confirmemail' ),
								$context->msg( 'emailconfirmlink' )->escaped()
							) . '<br />';
						$emailauthenticationclass = "mw-email-not-authenticated";
					}
				} else {
					$disableEmailPrefs = true;
					$emailauthenticated = $context->msg( 'noemailprefs' )->escaped();
					$emailauthenticationclass = 'mw-email-none';
				}

				if ( $canViewPrivateInfo ) {
					$defaultPreferences['emailauthentication'] = array(
						'type' => 'info',
						'raw' => true,
						'section' => 'personal/email',
						'label-message' => 'prefs-emailconfirm-label',
						'default' => $emailauthenticated,
						# Apply the same CSS class used on the input to the message:
						'cssclass' => $emailauthenticationclass,
					);
					$defaultPreferences['emailaddress']['cssclass'] = $emailauthenticationclass;
				}
			}

			if ( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) {
				$defaultPreferences['disablemail'] = array(
					'type' => 'toggle',
					'invert' => true,
					'section' => 'personal/email',
					'label-message' => 'allowemail',
					'disabled' => $disableEmailPrefs,
				);
				$defaultPreferences['ccmeonemails'] = array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'tog-ccmeonemails',
					'disabled' => $disableEmailPrefs,
				);
			}

			if ( $wgEnotifWatchlist ) {
				$defaultPreferences['enotifwatchlistpages'] = array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'tog-enotifwatchlistpages',
					'disabled' => $disableEmailPrefs,
				);
			}
			if ( $wgEnotifUserTalk ) {
				$defaultPreferences['enotifusertalkpages'] = array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'tog-enotifusertalkpages',
					'disabled' => $disableEmailPrefs,
				);
			}
			if ( $wgEnotifUserTalk || $wgEnotifWatchlist ) {
				$defaultPreferences['enotifminoredits'] = array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'tog-enotifminoredits',
					'disabled' => $disableEmailPrefs,
				);

				if ( $wgEnotifRevealEditorAddress ) {
					$defaultPreferences['enotifrevealaddr'] = array(
						'type' => 'toggle',
						'section' => 'personal/email',
						'label-message' => 'tog-enotifrevealaddr',
						'disabled' => $disableEmailPrefs,
					);
				}
			}
		}
	}
	/**
	 * Get the link to the specified user's userpage and group membership
	 * for administrators and ShoutWiki staff.
	 * For anonymous users, no link is generated, only the system message
	 * is returned.
	 *
	 * @param $username String: username
	 * @return HTML
	 */
	public static function getUserLink( $username ) {
		global $wgContLang, $wgUser;

		if ( $username ) {
			$retVal = Linker::link(
				Title::newFromText( $wgContLang->getNsText( NS_USER ) . ':' . $username ),
				htmlspecialchars( $username ) // @todo FIXME/CHECKME: double-escaping or not?
			);

			$groups = User::newFromName( $username )->getEffectiveGroups();
			// @todo FIXME: this code is horrible, it basically does
			// special-casing for staff and sysop groups
			// instead it should handle only staff as a special case
			// and treat bureaucrat, sysop etc. normally
			//
			// Staff tag for staff members
			// This is a horrible, ShoutWiki-specific hack
			$isStaff = in_array( 'staff', $groups );
			if ( $isStaff && function_exists( 'wfStaffSig' ) ) {
				global $wgOut;
				$staffSig = $wgOut->parse( '<staff />' );
				// copied from extensions/Comments/CommentClass.php
				// really bad hack because we want to parse=firstline, but
				// don't want wrapping <p> tags
				if ( substr( $staffSig, 0 , 3 ) == '<p>' ) {
					$staffSig = substr( $staffSig, 3 );
				}

				if ( substr( $staffSig, strlen( $staffSig ) - 4, 4 ) == '</p>' ) {
					$staffSig = substr( $staffSig, 0, strlen( $staffSig ) - 4 );
				}
				// end copied bad hack
				$retVal = $retVal . $staffSig;
			} elseif ( in_array( 'sysop', $groups ) && !$isStaff ) {
				// we <3 i18n
				$retVal = $retVal . wfMsg( 'word-separator' ) .
					wfMsg(
						'parentheses',
						User::makeGroupLinkHTML( 'sysop', User::getGroupMember( 'sysop', $username ) )
					);
			} elseif ( in_array( 'forumadmin', $groups ) && !$isStaff ) {
				// this madness has to stop...really...
				$retVal = $retVal . wfMsg( 'word-separator' ) .
					wfMsg(
						'parentheses',
						User::makeGroupLinkHTML( 'forumadmin', User::getGroupMember( 'forumadmin', $username ) )
					);
			}
			return $retVal;
		} else {
			return wfMsg( 'wikiforum-anonymous' );
		}
	}