/**
  * @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);
 }
 function doSubmit($group)
 {
     // Paranoia -- the edit token shouldn't match anyway
     if (!$this->userCanEdit($this->getUser())) {
         return;
     }
     $newRights = array();
     $addRights = array();
     $removeRights = array();
     $oldRights = $this->getAssignedRights($group);
     $allRights = User::getAllRights();
     $reason = $this->getRequest()->getVal('wpReason', '');
     foreach ($allRights as $right) {
         $alreadyAssigned = in_array($right, $oldRights);
         if ($this->getRequest()->getCheck("wpRightAssigned-{$right}")) {
             $newRights[] = $right;
         }
         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->addLogEntry($group, $addRights, $removeRights, $reason);
     }
     // Change set
     $current = WikiSet::getWikiSetForGroup($group);
     $new = $this->getRequest()->getVal('set');
     if ($current != $new) {
         $this->setRestrictions($group, $new);
         $this->addLogEntry2($group, $current, $new, $reason);
     }
     $this->invalidateRightsCache($group);
     // Display success
     $this->getOutput()->setSubTitle(wfMsg('centralauth-editgroup-success'));
     $this->getOutput()->addWikiMsg('centralauth-editgroup-success-text', $group);
 }