function buildMainView()
 {
     global $wgScript;
     $groups = CentralAuthUser::availableGlobalGroups();
     // Existing groups
     $html = Xml::fieldset(wfMsg('centralauth-existinggroup-legend'));
     $this->getOutput()->addHTML($html);
     if (count($groups)) {
         $this->getOutput()->addWikiMsg('centralauth-globalgroupperms-grouplist');
         $this->getOutput()->addHTML('<ul>');
         foreach ($groups as $group) {
             $text = wfMsgExt('centralauth-globalgroupperms-grouplistitem', array('parseinline'), User::getGroupName($group), $group, '<span class="centralauth-globalgroupperms-groupname">' . $group . '</span>');
             $this->getOutput()->addHTML("<li> {$text} </li>");
         }
     } else {
         $this->getOutput()->addWikiMsg('centralauth-globalgroupperms-nogroups');
     }
     $this->getOutput()->addHTML(Xml::closeElement('ul') . Xml::closeElement('fieldset'));
     if ($this->userCanEdit($this->getUser())) {
         // "Create a group" prompt
         $html = Xml::fieldset(wfMsg('centralauth-newgroup-legend'));
         $html .= wfMsgExt('centralauth-newgroup-intro', array('parse'));
         $html .= Xml::openElement('form', array('method' => 'post', 'action' => $wgScript, 'name' => 'centralauth-globalgroups-newgroup'));
         $html .= Html::hidden('title', SpecialPage::getTitleFor('GlobalGroupPermissions')->getPrefixedText());
         $fields = array('centralauth-globalgroupperms-newgroupname' => Xml::input('wpGroup'));
         $html .= Xml::buildForm($fields, 'centralauth-globalgroupperms-creategroup-submit');
         $html .= Xml::closeElement('form');
         $html .= Xml::closeElement('fieldset');
         $this->getOutput()->addHTML($html);
     }
 }
 /**
  * @param $group string
  */
 function doSubmit($group)
 {
     // Paranoia -- the edit token shouldn't match anyway
     if (!$this->userCanEdit($this->getUser())) {
         return;
     }
     $reason = $this->getRequest()->getVal('wpReason', '');
     // Current name of the group
     $group = Title::newFromText($group);
     if (!$group) {
         $this->getOutput()->addWikiMsg('centralauth-editgroup-invalid-name');
         return;
     }
     $group = $group->getUserCaseDBKey();
     // (Potentially) New name of the group
     $newname = $this->getRequest()->getVal('wpGlobalGroupName', $group);
     $newname = Title::newFromText($newname);
     if (!$newname) {
         $this->getOutput()->addWikiMsg('centralauth-editgroup-invalid-name');
         return;
     }
     $newname = $newname->getUserCaseDBKey();
     if ($group != $newname) {
         if (in_array($newname, CentralAuthUser::availableGlobalGroups())) {
             $this->getOutput()->addWikiMsg('centralauth-editgroup-rename-taken', $newname);
             return;
         }
         $dbw = CentralAuthUser::getCentralDB();
         $updates = array('global_group_permissions' => 'ggp_group', 'global_group_restrictions' => 'ggr_group', 'global_user_groups' => 'gug_group');
         foreach ($updates as $table => $field) {
             $dbw->update($table, array($field => $newname), array($field => $group), __METHOD__);
         }
         $this->addRenameLog($group, $newname, $reason);
         // The rest of the changes here will be performed on the "new" group
         $group = $newname;
     }
     // Permissions
     $addRights = array();
     $removeRights = array();
     $oldRights = $this->getAssignedRights($group);
     $allRights = User::getAllRights();
     foreach ($allRights as $right) {
         $alreadyAssigned = in_array($right, $oldRights);
         if (!$alreadyAssigned && $this->getRequest()->getCheck("wpRightAssigned-{$right}")) {
             $addRights[] = $right;
         } elseif ($alreadyAssigned && !$this->getRequest()->getCheck("wpRightAssigned-{$right}")) {
             $removeRights[] = $right;
         }
         # Otherwise, do nothing.
     }
     // Assign the rights.
     if (count($addRights) > 0) {
         $this->grantRightsToGroup($group, $addRights);
     }
     if (count($removeRights) > 0) {
         $this->revokeRightsFromGroup($group, $removeRights);
     }
     // Log it
     if (!(count($addRights) == 0 && count($removeRights) == 0)) {
         $this->addPermissionLog($group, $addRights, $removeRights, $reason);
     }
     // Change set
     $current = WikiSet::getWikiSetForGroup($group);
     $new = $this->getRequest()->getVal('set');
     if ($current != $new) {
         $this->setRestrictions($group, $new);
         $this->addWikiSetLog($group, $current, $new, $reason);
     }
     $this->invalidateRightsCache($group);
     // Display success
     $this->getOutput()->setSubTitle($this->msg('centralauth-editgroup-success'));
     $this->getOutput()->addWikiMsg('centralauth-editgroup-success-text', $group);
 }
 /**
  * @static
  * @return array
  */
 protected static function getAllGroups()
 {
     return CentralAuthUser::availableGlobalGroups();
 }
 public function getAllowedParams()
 {
     $globalGroups = CentralAuthUser::availableGlobalGroups();
     return array('from' => null, 'to' => null, 'prefix' => null, 'dir' => array(ApiBase::PARAM_DFLT => 'ascending', ApiBase::PARAM_TYPE => array('ascending', 'descending')), 'group' => array(ApiBase::PARAM_TYPE => $globalGroups, ApiBase::PARAM_ISMULTI => true), 'excludegroup' => array(ApiBase::PARAM_TYPE => $globalGroups, ApiBase::PARAM_ISMULTI => true), 'prop' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => array('lockinfo', 'groups', 'existslocally')), 'limit' => array(ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2));
 }
 /**
  * @return array
  */
 public function getAllGroups()
 {
     $result = array();
     foreach (CentralAuthUser::availableGlobalGroups() as $group) {
         $result[$group] = User::getGroupName($group);
     }
     return $result;
 }