/**
 * Ajax function to create checkboxes for a new group in $wgGroupPermissions
 *
 * @param String $group new group name
 * @return either <err#> if group already exist or html fragment
 */
function efConfigureAjax($group)
{
    global $wgUser, $wgGroupPermissions;
    if (!$wgUser->isAllowed('configure-all')) {
        return '<err#>';
    }
    if (isset($wgGroupPermissions[$group])) {
        $html = '<err#>';
    } else {
        if (is_callable(array('User', 'getAllRights'))) {
            // 1.13 +
            $all = User::getAllRights();
        } else {
            $all = array();
            foreach ($wgGroupPermissions as $rights) {
                $all = array_merge($all, array_keys($rights));
            }
            $all = array_unique($all);
        }
        $row = '<div style="-moz-column-count:2"><ul>';
        foreach ($all as $right) {
            $id = Sanitizer::escapeId('wpwgGroupPermissions-' . $group . '-' . $right);
            $desc = is_callable(array('User', 'getRightDescription')) ? User::getRightDescription($right) : $right;
            $row .= '<li>' . Xml::checkLabel($desc, $id, $id) . "</li>\n";
        }
        $row .= '</ul></div>';
        $groupName = User::getGroupName($group);
        // Firefox seems to not like that :(
        $html = str_replace('&nbsp;', ' ', $row);
    }
    return $html;
}
 public static function logProjectAssignment(Title $title, $action, User $user, $project, $organization, $group, $reason = null)
 {
     // is this a valid log action for us?
     if (!in_array($action, array('assign', 'reassign', 'unassign'))) {
         return false;
     }
     $projectName = self::isAssignedToProject($title) ? self::getProjectName($title) : $project;
     $logEntry = new ManualLogEntry('approvedrevs', $action);
     $logEntry->setPerformer($user);
     // User object, the user who did this action
     $logEntry->setTarget($title);
     // The page that this log entry affects
     $logEntry->setComment($reason);
     // User provided comment
     $logEntry->setParameters(array('4::project' => $projectName, '5::group' => User::getGroupName($group), '6::organization' => $organization));
     $logid = $logEntry->insert();
     $logEntry->publish($logid);
     return true;
 }
 /**
  * Format a link to a group description page
  *
  * @param string $group
  * @return string
  */
 private static function buildGroupLink($group)
 {
     return User::makeGroupLinkHtml($group, User::getGroupName($group));
 }
 function formatConfigInput($var, $type, $wiki = '')
 {
     global $wgConfigure, $wgRequest;
     $val = $wgConfigure->getSetting($wiki, $var);
     $descr = wfMsg('configurewmf-var-' . strtolower($var));
     $descrlabel = Xml::label($descr, $var);
     $r = "<tr><td class='mw-label'>{$descrlabel}:</td>\n\n<td class='mw-input'>";
     switch ($type) {
         case 'string':
             $r .= Xml::input($var, false, $val);
             break;
         case 'bool':
             $r .= Xml::check($var, $val);
             break;
         case 'stringarray':
             $val = $val ? implode("\n", $val) : '';
             $r .= Xml::textarea($var, $val);
             break;
         case 'logo':
             global $wgConfigureStdlogo;
             $isstd = $val == $wgConfigureStdlogo;
             $r .= '<div>' . Xml::radioLabel(wfMsgHtml('configurewmf-stdlogo'), $var, 'stdlogo', 'wgLogoStdlogo', $isstd) . '</div>';
             $r .= '<div>' . Xml::radioLabel(wfMsgHtml('configurewmf-otherlogo'), $var, 'other', 'wgLogoOther', !$isstd) . '&#160;' . Xml::input("{$var}Other", false, $isstd ? '' : $val) . '</div>';
             break;
         case 'groupperms':
             $groups = $wgConfigure->getGroupPermissions($wiki);
             $group = $wgRequest->getVal('group');
             $perms = isset($groups[$group]) ? $groups[$group] : array();
             $rights = User::getAllRights();
             sort($rights);
             $checkboxes = array();
             foreach ($rights as $right) {
                 $label = wfMsgExt('configurewmf-permission', array('parseinline'), User::getRightDescription($right), $right);
                 $checkboxes[] = Xml::checkLabel($label, "{$var}-{$right}", "{$var}-{$right}", @$perms[$right]);
             }
             $firstCol = round(count($checkboxes) / 2);
             $checkboxes1 = array_slice($checkboxes, 0, $firstCol);
             $checkboxes2 = array_slice($checkboxes, $firstCol);
             $r .= '<table><tbody><tr><td><ul><li>' . implode('</li><li>', $checkboxes1) . '</li></ul></td><td><ul><li>' . implode('</li><li>', $checkboxes2) . '</li></ul></td></tr></tbody></table>';
             $r .= Html::Hidden('group', $group);
             break;
         case 'grouplist':
             $targetgroup = $wgRequest->getVal('group');
             $r .= '<ul>';
             foreach (array_keys($wgConfigure->getGroupPermissions($wiki)) as $group) {
                 if (in_array($group, $wgConfigure->getSetting($wiki, 'wgImplicitGroups'))) {
                     continue;
                 }
                 $checked = isset($val[$targetgroup]) ? in_array($group, $val[$targetgroup]) : false;
                 $checkbox = Xml::checkLabel(User::getGroupName($group), "{$var}-{$group}", "{$var}-{$group}", $checked);
                 $r .= "<li>{$checkbox}</li>\n";
             }
             $r .= '</ul>';
             break;
     }
     return $r . '</td></tr>';
 }
Example #5
0
/** Build a select with all defined groups
 * @param $selectname String: name of this element. Name of form is automaticly prefixed.
 * @param $selectmsg String: FIXME
 * @param $selected Array: array of element selected when posted. Only multiples will show them.
 * @param $multiple Boolean: A multiple elements select.
 * @param $size Integer: number of elements to be shown ignored for non-multiple (default 6).
 * @param $reverse Boolean: if true, multiple select will hide selected elements (default false).
 * @todo Document $selectmsg
*/
function HTMLSelectGroups($selectname, $selectmsg, $selected = array(), $multiple = false, $size = 6, $reverse = false)
{
    $groups = User::getAllGroups();
    $out = htmlspecialchars(wfMsg($selectmsg));
    if ($multiple) {
        $attribs = array('name' => $selectname . '[]', 'multiple' => 'multiple', 'size' => $size);
    } else {
        $attribs = array('name' => $selectname);
    }
    $out .= wfElement('select', $attribs, null);
    foreach ($groups as $group) {
        $attribs = array('value' => $group);
        if ($multiple) {
            // for multiple will only show the things we want
            if (!in_array($group, $selected) xor $reverse) {
                continue;
            }
        } else {
            if (in_array($group, $selected)) {
                $attribs['selected'] = 'selected';
            }
        }
        $out .= wfElement('option', $attribs, User::getGroupName($group)) . "\n";
    }
    $out .= "</select>\n";
    return $out;
}
Example #6
0
 /**
  * Format a link to a group description page
  *
  * @param $group string
  * @return string
  */
 private static function buildGroupLink($group)
 {
     static $cache = array();
     if (!isset($cache[$group])) {
         $cache[$group] = User::makeGroupLinkHtml($group, User::getGroupName($group));
     }
     return $cache[$group];
 }
Example #7
0
 /**
  * Can $user perform $action on this page? This is an internal function,
  * which checks ONLY that previously checked by userCan (i.e. it leaves out
  * checks on wfReadOnly() and blocks)
  *
  * @param string $action action that permission needs to be checked for
  * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
  * @return array Array of arrays of the arguments to wfMsg to explain permissions problems.
  */
 private function getUserPermissionsErrorsInternal($action, $user, $doExpensiveQueries = true)
 {
     wfProfileIn(__METHOD__);
     $errors = array();
     // Use getUserPermissionsErrors instead
     if (!wfRunHooks('userCan', array(&$this, &$user, $action, &$result))) {
         return $result ? array() : array(array('badaccess-group0'));
     }
     if (!wfRunHooks('getUserPermissionsErrors', array(&$this, &$user, $action, &$result))) {
         if ($result != array() && is_array($result) && !is_array($result[0])) {
             $errors[] = $result;
         } else {
             if (is_array($result) && is_array($result[0])) {
                 $errors = array_merge($errors, $result);
             } else {
                 if ($result != '' && $result != null && $result !== true && $result !== false) {
                     $errors[] = array($result);
                 } else {
                     if ($result === false) {
                         $errors[] = array('badaccess-group0');
                     }
                 }
             }
         }
         # a generic "We don't want them to do that"
     }
     if ($doExpensiveQueries && !wfRunHooks('getUserPermissionsErrorsExpensive', array(&$this, &$user, $action, &$result))) {
         if ($result != array() && is_array($result) && !is_array($result[0])) {
             $errors[] = $result;
         } else {
             if (is_array($result) && is_array($result[0])) {
                 $errors = array_merge($errors, $result);
             } else {
                 if ($result != '' && $result != null && $result !== true && $result !== false) {
                     $errors[] = array($result);
                 } else {
                     if ($result === false) {
                         $errors[] = array('badaccess-group0');
                     }
                 }
             }
         }
         # a generic "We don't want them to do that"
     }
     if (NS_SPECIAL == $this->mNamespace) {
         $errors[] = array('ns-specialprotected');
     }
     if ($this->isNamespaceProtected() && $action != 'patrol') {
         $ns = $this->getNamespace() == NS_MAIN ? wfMsg('nstab-main') : $this->getNsText();
         $errors[] = NS_MEDIAWIKI == $this->mNamespace ? array('protectedinterface') : array('namespaceprotected', $ns);
     }
     if ($this->mDbkeyform == '-') {
         # FIXME: Is this necessary? Shouldn't be allowed anyway...
         $errors[] = array('badaccess-group0');
     }
     # protect css/js subpages of user pages
     # XXX: this might be better using restrictions
     # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working
     if ($this->isCssJsSubpage() && !$user->isAllowed('editusercssjs') && !preg_match('/^' . preg_quote($user->getName(), '/') . '\\//', $this->mTextform)) {
         $errors[] = array('customcssjsprotected');
     }
     if ($doExpensiveQueries && !$this->isCssJsSubpage()) {
         # We /could/ use the protection level on the source page, but it's fairly ugly
         #  as we have to establish a precedence hierarchy for pages included by multiple
         #  cascade-protected pages. So just restrict it to people with 'protect' permission,
         #  as they could remove the protection anyway.
         list($cascadingSources, $restrictions) = $this->getCascadeProtectionSources();
         # Cascading protection depends on more than this page...
         # Several cascading protected pages may include this page...
         # Check each cascading level
         # This is only for protection restrictions, not for all actions
         if ($cascadingSources > 0 && isset($restrictions[$action])) {
             foreach ($restrictions[$action] as $right) {
                 $right = $right == 'sysop' ? 'protect' : $right;
                 if ('' != $right && !$user->isAllowed($right)) {
                     $pages = '';
                     foreach ($cascadingSources as $page) {
                         $pages .= '* [[:' . $page->getPrefixedText() . "]]\n";
                     }
                     $errors[] = array('cascadeprotected', count($cascadingSources), $pages);
                 }
             }
         }
     }
     foreach ($this->getRestrictions($action) as $right) {
         // Backwards compatibility, rewrite sysop -> protect
         if ($right == 'sysop') {
             $right = 'protect';
         }
         if ('' != $right && !$user->isAllowed($right)) {
             $errors[] = array('protectedpagetext', $right);
         }
     }
     if ($action == 'protect') {
         if ($this->getUserPermissionsErrors('edit', $user) != array()) {
             $errors[] = array('protect-cantedit');
             // If they can't edit, they shouldn't protect.
         }
     }
     if ($action == 'create') {
         $title_protection = $this->getTitleProtection();
         if (is_array($title_protection)) {
             extract($title_protection);
             if ($pt_create_perm == 'sysop') {
                 $pt_create_perm = 'protect';
             }
             if ($pt_create_perm == '' || !$user->isAllowed($pt_create_perm)) {
                 $errors[] = array('titleprotected', User::whoIs($pt_user), $pt_reason);
             }
         }
         if ($this->isTalkPage() && !$user->isAllowed('createtalk') || !$this->isTalkPage() && !$user->isAllowed('createpage')) {
             $errors[] = $user->isAnon() ? array('nocreatetext') : array('nocreate-loggedin');
         }
     } elseif ($action == 'move' && !($this->isMovable() && $user->isAllowed('move'))) {
         $errors[] = $user->isAnon() ? array('movenologintext') : array('movenotallowed');
     } elseif (!$user->isAllowed($action)) {
         $return = null;
         $groups = array();
         global $wgGroupPermissions;
         foreach ($wgGroupPermissions as $key => $value) {
             if (isset($value[$action]) && $value[$action] == true) {
                 $groupName = User::getGroupName($key);
                 $groupPage = User::getGroupPage($key);
                 if ($groupPage) {
                     $groups[] = '[[' . $groupPage->getPrefixedText() . '|' . $groupName . ']]';
                 } else {
                     $groups[] = $groupName;
                 }
             }
         }
         $n = count($groups);
         $groups = implode(', ', $groups);
         switch ($n) {
             case 0:
             case 1:
             case 2:
                 $return = array("badaccess-group{$n}", $groups);
                 break;
             default:
                 $return = array('badaccess-groups', $groups);
         }
         $errors[] = $return;
     }
     wfProfileOut(__METHOD__);
     return $errors;
 }
Example #8
0
 /**
  * Show a drop down list to select a group as well as a user name
  * search box.
  * @todo localize
  */
 function getPageHeader()
 {
     $self = $this->getTitle();
     # Form tag
     $out = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
     # Group drop-down list
     $out .= wfElement('label', array('for' => 'group'), wfMsg('group')) . ' ';
     $out .= wfOpenElement('select', array('name' => 'group'));
     $out .= wfElement('option', array('value' => ''), wfMsg('group-all'));
     # Item for "all groups"
     $groups = User::getAllGroups();
     foreach ($groups as $group) {
         $attribs = array('value' => $group);
         if ($group == $this->requestedGroup) {
             $attribs['selected'] = 'selected';
         }
         $out .= wfElement('option', $attribs, User::getGroupName($group));
     }
     $out .= wfCloseElement('select') . ' ';
     # . wfElement( 'br' );
     # Username field
     $out .= wfElement('label', array('for' => 'username'), wfMsg('specialloguserlabel')) . ' ';
     $out .= wfElement('input', array('type' => 'text', 'id' => 'username', 'name' => 'username', 'value' => $this->requestedUser)) . ' ';
     # Preserve offset and limit
     if ($this->offset) {
         $out .= wfElement('input', array('type' => 'hidden', 'name' => 'offset', 'value' => $this->offset));
     }
     if ($this->limit) {
         $out .= wfElement('input', array('type' => 'hidden', 'name' => 'limit', 'value' => $this->limit));
     }
     # Submit button and form bottom
     $out .= wfElement('input', array('type' => 'submit', 'value' => wfMsg('allpagessubmit')));
     $out .= wfCloseElement('form');
     return $out;
 }
 /**
  * @return array
  */
 private function getInfoFields()
 {
     $globalUser = $this->mGlobalUser;
     $reg = $globalUser->getRegistration();
     $age = $this->prettyTimespan(wfTimestamp(TS_UNIX) - wfTimestamp(TS_UNIX, $reg));
     $attribs = array('username' => $globalUser->getName(), 'registered' => htmlspecialchars($this->getLanguage()->timeanddate($reg, true) . " ({$age})"), 'editcount' => htmlspecialchars($this->getLanguage()->formatNum($this->evaluateTotalEditcount())), 'attached' => htmlspecialchars($this->getLanguage()->formatNum(count($this->mAttachedLocalAccounts))));
     if (count($this->mUnattachedLocalAccounts)) {
         $attribs['unattached'] = htmlspecialchars($this->getLanguage()->formatNum(count($this->mUnattachedLocalAccounts)));
     }
     if ($globalUser->isLocked()) {
         $attribs['locked'] = $this->msg('centralauth-admin-yes')->escaped();
     }
     if ($this->mCanOversight) {
         $attribs['hidden'] = $this->formatHiddenLevel($globalUser->getHiddenLevel());
     }
     $groups = $globalUser->getGlobalGroups();
     if ($groups) {
         $groups = array_map(function ($group) {
             return Linker::link(SpecialPage::getTitleFor('GlobalGroupPermissions', $group), htmlspecialchars(User::getGroupName($group)));
         }, $groups);
         $attribs['groups'] = $this->getLanguage()->commaList($groups);
     }
     return $attribs;
 }
 /**
  * @return array
  */
 public function getAllGroups()
 {
     $result = array();
     foreach (CentralAuthUser::availableGlobalGroups() as $group) {
         $result[$group] = User::getGroupName($group);
     }
     return $result;
 }
 /**
  * Adds the <select> thingie where you can select what groups to add/remove
  *
  * @param array  $groups The groups that can be added/removed
  * @param string $name   'removable' or 'available'
  * @return string XHTML <select> element
  */
 private function doSelect($groups, $name)
 {
     $ret = wfMsgHtml("{$this->mName}-groups{$name}") . Xml::openElement('select', array('name' => "{$name}[]", 'multiple' => 'multiple', 'size' => '6', 'style' => 'width: 100%;'));
     foreach ($groups as $group) {
         $ret .= Xml::element('option', array('value' => $group), User::getGroupName($group));
     }
     $ret .= Xml::closeElement('select');
     return $ret;
 }
 private function loadGroups()
 {
     global $wgContLang, $wgMemc;
     wfProfileIn(__METHOD__);
     $memkey = wfForeignMemcKey($this->mCityId, null, Listusers::TITLE, "groups", $wgContLang->getCode());
     $cached = $wgMemc->get($memkey);
     if (empty($cached)) {
         $this->mGroups[Listusers::DEF_GROUP_NAME] = array('name' => wfMsg('listusersnogroup'), 'count' => 0);
         $groups = User::getAllGroups();
         if (is_array($groups) && !empty($groups)) {
             foreach ($groups as $group) {
                 $this->mGroups[$group] = array('name' => User::getGroupName($group), 'count' => 0);
             }
         }
         if (!empty($this->mGroups)) {
             $records = $this->groupRecords();
             if (!empty($records)) {
                 foreach ($records as $key => $count) {
                     $this->mGroups[$key]['count'] = $count;
                 }
             }
         }
     } else {
         $this->mGroups = $cached;
     }
     wfProfileOut(__METHOD__);
     return $this->mGroups;
 }
 /**
  * @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());
 }
 /**
  * Build an input for an array setting
  *
  * @param str $conf setting name
  * @param mixed $default current value (but should be array :)
  * @param bool $allowed
  */
 protected function buildArrayInput($conf, $default, $allowed)
 {
     if (!isset(self::$arrayDefs[$conf]) || self::$arrayDefs[$conf] == 'array') {
         return $allowed ? '<span class="array">(array)</span>' : '<span class="array-disabled">(array)</span>';
     }
     $type = self::$arrayDefs[$conf];
     if ($type == 'simple') {
         if (!$allowed) {
             return "<pre>\n" . htmlspecialchars(is_array($default) ? implode("\n", $default) : $default) . "\n</pre>";
         }
         $text = "<textarea id='wp{$conf}' name='wp{$conf}' cols='30' rows='8'>";
         if (is_array($default)) {
             $text .= implode("\n", $default);
         }
         $text .= "</textarea>\n";
         return $text;
     }
     if ($type == 'assoc') {
         $keydesc = wfMsgHtml('configure-desc-key');
         $valdesc = wfMsgHtml('configure-desc-val');
         $class = !$allowed ? array('class' => 'disabled') : array();
         $encConf = htmlspecialchars($conf);
         $text = "<table class='assoc' id='{$encConf}'>\n<tr><th>{$keydesc}</th><th>{$valdesc}</th></tr>\n";
         if (is_array($default) && count($default) > 0) {
             $i = 0;
             foreach ($default as $key => $val) {
                 $text .= '<tr>' . Xml::openElement('td', $class);
                 if ($allowed) {
                     $text .= Xml::element('input', array('name' => 'wp' . $conf . "-key-{$i}", 'type' => 'text', 'value' => $key)) . "<br/>\n";
                 } else {
                     $text .= htmlspecialchars($key);
                 }
                 $text .= '</td>' . Xml::openElement('td', $class);
                 if ($allowed) {
                     $text .= Xml::element('input', array('name' => 'wp' . $conf . "-val-{$i}", 'type' => 'text', 'value' => $val)) . "<br/>\n";
                 } else {
                     $text .= htmlspecialchars($val);
                 }
                 $text .= '</td></tr>';
                 $i++;
             }
         } else {
             if ($allowed) {
                 $text .= '<tr><td>';
                 $text .= Xml::element('input', array('name' => 'wp' . $conf . "-key-0", 'type' => 'text', 'value' => '')) . "<br/>\n";
                 $text .= '</td><td>';
                 $text .= Xml::element('input', array('name' => 'wp' . $conf . "-val-0", 'type' => 'text', 'value' => '')) . "<br/>\n";
                 $text .= '</td></tr>';
             } else {
                 $text .= "<tr><td class='disabled' style='width:10em; height:1.5em;'><hr /></td><td class='disabled' style='width:10em; height:1.5em;'><hr /></td></tr>\n";
             }
         }
         $text .= '</table>';
         return $text;
     }
     if ($type == 'simple-dual') {
         $var = array();
         foreach ($default as $arr) {
             $var[] = implode(',', $arr);
         }
         if (!$allowed) {
             return "<pre>\n" . htmlspecialchars(implode("\n", $var)) . "\n</pre>";
         }
         $text = "<textarea id='wp{$conf}' name='wp{$conf}' cols='30' rows='8'>";
         if (is_array($var)) {
             $text .= implode("\n", $var);
         }
         $text .= "</textarea>\n";
         return $text;
     }
     if ($type == 'ns-bool') {
         global $wgContLang;
         $text = '';
         $attr = !$allowed ? array('disabled' => 'disabled') : array();
         foreach ($wgContLang->getNamespaces() as $ns => $name) {
             $name = str_replace('_', ' ', $name);
             if ('' == $name) {
                 $name = wfMsgExt('blanknamespace', array('parseinline'));
             }
             $text .= Xml::checkLabel($name, "wp{$conf}-ns{$ns}", "wp{$conf}-ns{$ns}", isset($default[$ns]) && $default[$ns], $attr) . "\n";
         }
         return $text;
     }
     if ($type == 'ns-text') {
         global $wgContLang;
         $nsdesc = wfMsgHtml('configure-desc-ns');
         $valdesc = wfMsgHtml('configure-desc-val');
         $text = "<table class='ns-text'>\n<tr><th>{$nsdesc}</th><th>{$valdesc}</th></tr>\n";
         foreach ($wgContLang->getNamespaces() as $ns => $name) {
             $name = str_replace('_', ' ', $name);
             if ('' == $name) {
                 $name = wfMsgExt('blanknamespace', array('parseinline'));
             }
             $text .= '<tr><td>' . $name . '</td><td>';
             if ($allowed) {
                 $text .= Xml::element('input', array('name' => "wp{$conf}-ns{$ns}", 'type' => 'text', 'value' => isset($default[$ns]) ? $default[$ns] : '')) . "\n";
             } else {
                 $text .= htmlspecialchars(isset($default[$ns]) ? $default[$ns] : '');
             }
             $text .= '</td></tr>';
         }
         $text .= '</table>';
         return $text;
     }
     if ($type == 'ns-array') {
         global $wgContLang;
         $nsdesc = wfMsgHtml('configure-desc-ns');
         $valdesc = wfMsgHtml('configure-desc-val');
         $text = "<table class='ns-array'>\n<tr><th>{$nsdesc}</th><th>{$valdesc}</th></tr>\n";
         foreach ($wgContLang->getNamespaces() as $ns => $name) {
             if ($ns < 0) {
                 continue;
             }
             $name = str_replace('_', ' ', $name);
             if ('' == $name) {
                 $name = wfMsgExt('blanknamespace', array('parseinline'));
             }
             $text .= '<tr><td>' . $name . '</td><td>';
             if ($allowed) {
                 $text .= Xml::openElement('textarea', array('name' => "wp{$conf}-ns{$ns}", 'id' => "wp{$conf}-ns{$ns}", 'cols' => 30, 'rows' => 5)) . (isset($default[$ns]) ? implode("\n", $default[$ns]) : '') . Xml::closeElement('textarea') . "<br/>\n";
             } else {
                 $text .= "<pre>\n" . (isset($default[$ns]) ? htmlspecialchars(implode("\n", $default[$ns])) : '') . "\n</pre>";
             }
             $text .= '</td></tr>';
         }
         $text .= '</table>';
         return $text;
     }
     if ($type == 'group-bool' || $type == 'group-array') {
         $all = array();
         $attr = !$allowed ? array('disabled' => 'disabled') : array();
         if ($type == 'group-bool') {
             if (is_callable(array('User', 'getAllRights'))) {
                 // 1.13 +
                 $all = User::getAllRights();
             } else {
                 foreach ($default as $rights) {
                     $all = array_merge($all, array_keys($rights));
                 }
                 $all = array_unique($all);
             }
             $iter = $default;
         } else {
             $all = array_keys($this->getSettingValue('wgGroupPermissions'));
             $iter = array();
             foreach ($all as $group) {
                 $iter[$group] = isset($default[$group]) && is_array($default[$group]) ? $default[$group] : array();
             }
             if ($this->isSettingAvailable('wgImplicitGroups')) {
                 // 1.12 +
                 $all = array_diff($all, $this->getSettingValue('wgImplicitGroups'));
             } else {
                 $all = array_diff($all, User::getImplicitGroups());
             }
         }
         $groupdesc = wfMsgHtml('configure-desc-group');
         $valdesc = wfMsgHtml('configure-desc-val');
         $encConf = htmlspecialchars($conf);
         $text = "<table id= '{$encConf}' class='{$type}'>\n<tr><th>{$groupdesc}</th><th>{$valdesc}</th></tr>\n";
         foreach ($iter as $group => $levs) {
             $row = '<div style="-moz-column-count:2"><ul>';
             foreach ($all as $right) {
                 if ($type == 'group-bool') {
                     $checked = isset($levs[$right]) && $levs[$right];
                 } else {
                     $checked = in_array($right, $levs);
                 }
                 $id = Sanitizer::escapeId('wp' . $conf . '-' . $group . '-' . $right);
                 $desc = $type == 'group-bool' && is_callable(array('User', 'getRightDescription')) ? User::getRightDescription($right) : $right;
                 $row .= '<li>' . Xml::checkLabel($desc, $id, $id, $checked, $attr) . "</li>\n";
             }
             $row .= '</ul></div>';
             $groupName = User::getGroupName($group);
             $encId = Sanitizer::escapeId('wp' . $conf . '-' . $group);
             $text .= "<tr id=\"{$encId}\">\n<td>{$groupName}</td>\n<td>{$row}</td>\n</tr>";
         }
         $text .= '</table>';
         return $text;
     }
 }
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 */
     }
 }
 /**
  * Get a list of all explicit groups
  * Do we need implicit groups as well?
  * @return array
  */
 private static function getAllGroups()
 {
     $result = array();
     foreach (User::getAllGroups() as $group) {
         $result[User::getGroupName($group)] = $group;
     }
     asort($result);
     return $result;
 }
Example #17
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 formatResult($skin, $result)
 {
     global $wgContLang;
     $userPage = Title::makeTitle($result->namespace, $result->title);
     $name = $skin->makeLinkObj($userPage, htmlspecialchars($userPage->getText()));
     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[] = User::getGroupName($row->ug_group);
         }
         $dbr->freeResult($result);
         if (count($groups) > 0) {
             $name .= ' (' . $skin->makeLink(wfMsgForContent('administrators'), htmlspecialchars(implode(', ', $groups))) . ')';
         }
     }
     return $name;
 }
 /**
  * Get a list of all explicit groups
  * @return array
  */
 function getAllGroups()
 {
     $result = array();
     foreach (User::getAllGroups() as $group) {
         $result[$group] = User::getGroupName($group);
     }
     asort($result);
     return $result;
 }
Example #20
0
 /**
  * Display an error page noting that a given permission bit is required.
  * @param string $permission key required
  */
 function permissionRequired($permission)
 {
     global $wgGroupPermissions, $wgUser;
     $this->setPageTitle(wfMsg('badaccess'));
     $this->setHTMLTitle(wfMsg('errorpagetitle'));
     $this->setRobotpolicy('noindex,nofollow');
     $this->setArticleRelated(false);
     $this->mBodytext = '';
     $groups = array();
     foreach ($wgGroupPermissions as $key => $value) {
         if (isset($value[$permission]) && $value[$permission] == true) {
             $groupName = User::getGroupName($key);
             $groupPage = User::getGroupPage($key);
             if ($groupPage) {
                 $skin =& $wgUser->getSkin();
                 $groups[] = '"' . $skin->makeLinkObj($groupPage, $groupName) . '"';
             } else {
                 $groups[] = '"' . $groupName . '"';
             }
         }
     }
     $n = count($groups);
     $groups = implode(', ', $groups);
     switch ($n) {
         case 0:
         case 1:
         case 2:
             $message = wfMsgHtml("badaccess-group{$n}", $groups);
             break;
         default:
             $message = wfMsgHtml('badaccess-groups', $groups);
     }
     $this->addHtml($message);
     $this->returnToMain(false);
 }
Example #21
0
 public function ShowUserListing($list = 1, $search_by = 'name', $input = false)
 {
     global $bd_users, $bd_names;
     if ($input == 'banned') {
         $input = 0;
     }
     switch ($search_by) {
         case 'name':
             $sql = "SELECT `{$bd_users['id']}` FROM `{$bd_names['users']}` " . "WHERE {$bd_users['login']} LIKE :input " . "ORDER BY {$bd_users['login']} LIMIT " . 10 * ($list - 1) . ",10";
             $countSql = "SELECT COUNT(*) FROM `{$bd_names['users']}` WHERE {$bd_users['login']} LIKE :input";
             $input = array('input' => '%' . $input . '%');
             $result = getDB()->ask($sql, $input);
             break;
         case 'none':
             $sql = "SELECT `{$bd_users['id']}` FROM `{$bd_names['users']}` " . "ORDER BY {$bd_users['login']} LIMIT " . 10 * ($list - 1) . ",10";
             $countSql = "SELECT COUNT(*) FROM `{$bd_names['users']}`";
             $input = false;
             $result = getDB()->ask($sql);
             break;
         case 'ip':
             $sql = "SELECT `{$bd_users['id']}` FROM `{$bd_names['users']}` " . "WHERE {$bd_users['ip']} LIKE :input " . "ORDER BY {$bd_users['login']} LIMIT " . 10 * ($list - 1) . ",10";
             $countSql = "SELECT COUNT(*) FROM `{$bd_names['users']}` WHERE {$bd_users['ip']} LIKE :input";
             $input = array('input' => '%' . $input . '%');
             $result = getDB()->ask($sql, $input);
             break;
         case 'lvl':
             $result = getDB()->fetchRow("SELECT `id` FROM `{$bd_names['groups']}` WHERE `lvl`=':input'", $input, 'num');
             $input = $result[0];
             $sql = "SELECT `{$bd_users['id']}` FROM `{$bd_names['users']}` " . "WHERE `{$bd_users['group']}` = ':input' " . "ORDER BY {$bd_users['login']} LIMIT " . 10 * ($list - 1) . ",10";
             $countSql = "SELECT COUNT(*) FROM `{$bd_names['users']}` WHERE `{$bd_users['group']}`=':input'";
             $input = array('input' => $input);
             $result = getDB()->ask($sql, $input);
             break;
     }
     ob_start();
     while ($line = $result->fetch('num')) {
         if (!isset($found)) {
             include $this->GetView('admin/user/user_find_header.html');
             $found = true;
         }
         $inf_user = new User($line[0]);
         $user_name = $inf_user->name();
         $user_id = $inf_user->id();
         $user_ip = $inf_user->ip();
         $user_lvl = $inf_user->getGroupName();
         $user_lvl_id = $inf_user->group();
         unset($inf_user);
         include $this->GetView('admin/user/user_find_string.html');
     }
     if (!isset($found)) {
         include $this->GetView('admin/user/user_not_found.html');
         return ob_get_clean();
     }
     include $this->GetView('admin/user/user_find_footer.html');
     $html = ob_get_clean();
     $line = getDB()->fetchRow($countSql, $input, 'num');
     $html .= $this->arrowsGenerator($this->work_skript, $list, $line[0], 10);
     return $html;
 }
 function getPageHeader()
 {
     global $wgScript, $wgRequest;
     $self = $this->getTitle();
     # Form tag
     $out = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript)) . '<fieldset>' . Xml::element('legend', array(), wfMsg('listusers'));
     $out .= Xml::hidden('title', $self->getPrefixedDbKey());
     # Username field
     $out .= Xml::label(wfMsg('listusersfrom'), 'offset') . ' ' . Xml::input('username', 20, $this->requestedUser, array('id' => 'offset')) . ' ';
     # Group drop-down list
     $out .= Xml::label(wfMsg('group'), 'group') . ' ' . Xml::openElement('select', array('name' => 'group', 'id' => 'group')) . Xml::option(wfMsg('group-all'), '');
     foreach (User::getAllGroups() as $group) {
         $out .= Xml::option(User::getGroupName($group), $group, $group == $this->requestedGroup);
     }
     $out .= Xml::closeElement('select') . ' ';
     # Submit button and form bottom
     if ($this->mLimit) {
         $out .= Xml::hidden('limit', $this->mLimit);
     }
     $out .= Xml::submitButton(wfMsg('allpagessubmit')) . '</fieldset>' . Xml::closeElement('form');
     return $out;
 }
 /**
  * @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());
 }
Example #24
0
         case 1901:
             $message .= lng('INCORRECT') . '. (' . lng('EMAIL') . ')';
             break;
         case 1902:
             $message .= lng('AUTH_EXIST_EMAIL');
             break;
         default:
             $modifed = false;
             break;
     }
     if ($modifed) {
         $message .= "\n";
     }
 }
 $ajax_message['name'] = $mod_user->name();
 $ajax_message['group'] = $mod_user->getGroupName();
 $ajax_message['id'] = $mod_user->id();
 $ajax_message['skin_link'] = $mod_user->getSkinLink(false, '&', true);
 $ajax_message['mskin_link'] = $mod_user->getSkinLink(true, '&', true);
 if (file_exists($mod_user->getCloakFName())) {
     $ajax_message['cloak'] = 1;
 }
 if ($mod_user->defaultSkinTrigger()) {
     $ajax_message['skin'] = 1;
 }
 if ($message) {
     aExit(2, $message);
 } elseif (!$rnum) {
     aExit(100, $message);
 } else {
     aExit(0, lng('PROFILE_COMPLITE'));
Example #25
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,
					);
				}
			}
		}
	}
 /**
  * Build a row for group-bool or group-array array type, taken out of
  * buildArrayInput() to called with ajax
  * @param $conf String: setting name
  * @param $type String: array type
  * @param $all Array: all avialable rights
  * @param $allowed Boolean
  * @param $group String: group name
  * @param $levs Array: rights given to $group
  * @return String: XHTML
  */
 public static function buildGroupSettingRow($conf, $type, $all, $allowed, $group, $levs)
 {
     $attr = !$allowed ? array('disabled' => 'disabled') : array();
     $row = Html::openElement('div', array('class' => 'configure-biglist ' . $type . '-element')) . Html::openElement('ul');
     foreach ($all as $right) {
         if ($type == 'group-bool') {
             $checked = isset($levs[$right]) && $levs[$right];
         } else {
             $checked = in_array($right, $levs);
         }
         $id = Sanitizer::escapeId('wp' . $conf . '-' . $group . '-' . $right);
         if ($type == 'group-bool') {
             $desc = User::getRightDescription($right) . " (" . Html::element('tt', array('class' => 'configure-right-id'), $right) . ")";
         } else {
             $desc = User::getGroupName($right);
         }
         $checkedArr = $checked ? array('checked' => 'checked') : array();
         $row .= Html::rawElement('li', array(), Html::input($id, '1', 'checkbox', $attr + array('id' => $id) + $checkedArr) . '&#160;' . Html::rawElement('label', array('for' => $id), $desc)) . "\n";
     }
     $row .= Html::closeElement('ul') . Html::closeElement('div');
     return $row;
 }