/**
  * Show a drop down list to select a group as well as a user name
  * search box.
  * @todo localize
  */
 function getPageHeader()
 {
     global $wgScript;
     // Various variables used for the form
     $action = htmlspecialchars($wgScript);
     $title = Title::makeTitle(NS_SPECIAL, 'Listusers');
     $special = htmlspecialchars($title->getPrefixedDBkey());
     // form header
     $out = '<form method="get" action="' . $action . '">' . '<input type="hidden" name="title" value="' . $special . '" />' . wfMsgHtml('groups-editgroup-name') . '<select name="group">';
     // get all group names and IDs
     $groups = User::getAllGroups();
     // we want a default empty group
     $out .= '<option value=""></option>';
     // build the dropdown list menu using datas from the database
     foreach ($groups as $group) {
         $selected = $group == $this->requestedGroup;
         $out .= wfElement('option', array_merge(array('value' => $group), $selected ? array('selected' => 'selected') : array()), User::getGroupName($group));
     }
     $out .= '</select> ';
     $out .= wfMsgHtml('specialloguserlabel') . '<input type="text" name="username" /> ';
     // OK button, end of form.
     $out .= '<input type="submit" /></form>';
     // congratulations the form is now build
     return $out;
 }
 function changeableGroups()
 {
     global $wgUser;
     if ($wgUser->isAllowed('userrights-global')) {
         // all groups can be added globally
         $all = array_merge(User::getAllGroups());
         return array('add' => $all, 'remove' => $all, 'add-self' => array(), 'remove-self' => array());
     } else {
         return array();
     }
 }
示例#3
0
 private static function parseOptions($opts)
 {
     $options = array();
     $segments = explode('|', $opts);
     foreach ($segments as $opt) {
         // Extract key=value pair
         $exploded = explode('=', $opt, 2);
         $key = $exploded[0];
         $value = isset($exploded[1]) ? $exploded[1] : '';
         switch ($key) {
             case 'replace':
                 // Replace the text instead of marking as spam
                 $options['replace'] = $value;
                 break;
             default:
                 if (in_array($key, \User::getAllRights())) {
                     // If the name is a user right
                     if (isset($options['right'])) {
                         $options['right'][] = $key;
                     } else {
                         $options['right'] = array($key);
                     }
                 } else {
                     if (in_array($key, \User::getAllGroups())) {
                         // If the name is a user group
                         if (isset($options['group'])) {
                             $options['group'][] = $key;
                         } else {
                             $options['group'] = array($key);
                         }
                     }
                 }
         }
     }
     return $options;
 }
示例#4
0
 public function execute()
 {
     $username = $this->getArg(0);
     $password = $this->getArg(1);
     $force = $this->hasOption('force');
     $inGroups = [];
     $user = User::newFromName($username);
     if (!is_object($user)) {
         $this->error("invalid username.", true);
     }
     $exists = 0 !== $user->idForName();
     if ($exists && !$force) {
         $this->error("Account exists. Perhaps you want the --force option?", true);
     } elseif (!$exists && !$password) {
         $this->error("Argument <password> required!", false);
         $this->maybeHelp(true);
     } elseif ($exists) {
         $inGroups = $user->getGroups();
     }
     $groups = array_filter(self::$permitRoles, [$this, 'hasOption']);
     if ($this->hasOption('custom-groups')) {
         $allGroups = array_flip(User::getAllGroups());
         $customGroupsText = $this->getOption('custom-groups');
         if ($customGroupsText !== '') {
             $customGroups = explode(',', $customGroupsText);
             foreach ($customGroups as $customGroup) {
                 if (isset($allGroups[$customGroup])) {
                     $groups[] = trim($customGroup);
                 } else {
                     $this->output("{$customGroup} is not a valid group, ignoring!\n");
                 }
             }
         }
     }
     $promotions = array_diff($groups, $inGroups);
     if ($exists && !$password && count($promotions) === 0) {
         $this->output("Account exists and nothing to do.\n");
         return;
     } elseif (count($promotions) !== 0) {
         $promoText = "User:{$username} into " . implode(', ', $promotions) . "...\n";
         if ($exists) {
             $this->output(wfWikiID() . ": Promoting {$promoText}");
         } else {
             $this->output(wfWikiID() . ": Creating and promoting {$promoText}");
         }
     }
     if (!$exists) {
         # Insert the account into the database
         $user->addToDatabase();
         $user->saveSettings();
     }
     if ($password) {
         # Try to set the password
         try {
             $user->setPassword($password);
             if ($exists) {
                 $this->output("Password set.\n");
                 $user->saveSettings();
             }
         } catch (PasswordError $pwe) {
             $this->error($pwe->getText(), true);
         }
     }
     # Promote user
     array_map([$user, 'addGroup'], $promotions);
     if (!$exists) {
         # Increment site_stats.ss_users
         $ssu = new SiteStatsUpdate(0, 0, 0, 0, 1);
         $ssu->doUpdate();
     }
     $this->output("done.\n");
 }
示例#5
0
 /**
  * Returns an array of groups that this user can add and remove
  * @return Array array( 'add' => array( addablegroups ),
  *  'remove' => array( removablegroups ),
  *  'add-self' => array( addablegroups to self),
  *  'remove-self' => array( removable groups from self) )
  */
 public function changeableGroups()
 {
     if ($this->isAllowed('userrights')) {
         // This group gives the right to modify everything (reverse-
         // compatibility with old "userrights lets you change
         // everything")
         // Using array_merge to make the groups reindexed
         $all = array_merge(User::getAllGroups());
         return array('add' => $all, 'remove' => $all, 'add-self' => array(), 'remove-self' => array());
     }
     // Okay, it's not so simple, we will have to go through the arrays
     $groups = array('add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array());
     $addergroups = $this->getEffectiveGroups();
     foreach ($addergroups as $addergroup) {
         $groups = array_merge_recursive($groups, $this->changeableByGroup($addergroup));
         $groups['add'] = array_unique($groups['add']);
         $groups['remove'] = array_unique($groups['remove']);
         $groups['add-self'] = array_unique($groups['add-self']);
         $groups['remove-self'] = array_unique($groups['remove-self']);
     }
     return $groups;
 }
 public function getAllowedParams()
 {
     return array('user' => array(ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true), 'add' => array(ApiBase::PARAM_TYPE => User::getAllGroups(), ApiBase::PARAM_ISMULTI => true), 'remove' => array(ApiBase::PARAM_TYPE => User::getAllGroups(), ApiBase::PARAM_ISMULTI => true), 'token' => array(ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true), 'reason' => array(ApiBase::PARAM_DFLT => ''));
 }
示例#7
0
 public function getAllowedParams()
 {
     $userGroups = User::getAllGroups();
     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 => $userGroups, ApiBase::PARAM_ISMULTI => true), 'excludegroup' => array(ApiBase::PARAM_TYPE => $userGroups, ApiBase::PARAM_ISMULTI => true), 'rights' => array(ApiBase::PARAM_TYPE => User::getAllRights(), ApiBase::PARAM_ISMULTI => true), 'prop' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => array('blockinfo', 'groups', 'implicitgroups', 'rights', 'editcount', 'registration')), '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), 'witheditsonly' => false, 'activeusers' => false);
 }
示例#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;
 }
 /**
  * Helper function for updateUser() and initUser(). Adds users into MediaWiki security groups
  * based upon groups retreived from LDAP.
  *
  * @param User $user
  * @access private
  */
 function setGroups(&$user)
 {
     global $wgGroupPermissions;
     // TODO: this is *really* ugly code. clean it up!
     $this->printDebug("Entering setGroups.", NONSENSITIVE);
     # Add ldap groups as local groups
     if ($this->getConf('GroupsPrevail')) {
         $this->printDebug("Adding all groups to wgGroupPermissions: ", SENSITIVE, $this->allLDAPGroups);
         foreach ($this->allLDAPGroups["short"] as $ldapgroup) {
             if (!array_key_exists($ldapgroup, $wgGroupPermissions)) {
                 $wgGroupPermissions[$ldapgroup] = array();
             }
         }
     }
     # add groups permissions
     $localAvailGrps = $user->getAllGroups();
     $localUserGrps = $user->getEffectiveGroups();
     $defaultLocallyManagedGrps = array('bot', 'sysop', 'bureaucrat');
     $locallyManagedGrps = $this->getConf('LocallyManagedGroups');
     if ($locallyManagedGrps) {
         $locallyManagedGrps = array_unique(array_merge($defaultLocallyManagedGrps, $locallyManagedGrps));
         $this->printDebug("Locally managed groups: ", SENSITIVE, $locallyManagedGrps);
     } else {
         $locallyManagedGrps = $defaultLocallyManagedGrps;
         $this->printDebug("Locally managed groups is unset, using defaults: ", SENSITIVE, $locallyManagedGrps);
     }
     $this->printDebug("Available groups are: ", NONSENSITIVE, $localAvailGrps);
     $this->printDebug("Effective groups are: ", NONSENSITIVE, $localUserGrps);
     # note: $localUserGrps does not need to be updated with $cGroup added,
     #       as $localAvailGrps contains $cGroup only once.
     foreach ($localAvailGrps as $cGroup) {
         # did we once add the user to the group?
         if (in_array($cGroup, $localUserGrps)) {
             $this->printDebug("Checking to see if we need to remove user from: {$cGroup}", NONSENSITIVE);
             if (!$this->hasLDAPGroup($cGroup) && !in_array($cGroup, $locallyManagedGrps)) {
                 $this->printDebug("Removing user from: {$cGroup}", NONSENSITIVE);
                 # the ldap group overrides the local group
                 # so as the user is currently not a member of the ldap group, he shall be removed from the local group
                 $user->removeGroup($cGroup);
             }
         } else {
             # no, but maybe the user has recently been added to the ldap group?
             $this->printDebug("Checking to see if user is in: {$cGroup}", NONSENSITIVE);
             if ($this->hasLDAPGroup($cGroup)) {
                 $this->printDebug("Adding user to: {$cGroup}", NONSENSITIVE);
                 $user->addGroup($cGroup);
             }
         }
     }
 }
示例#10
0
    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;
    }
 /**
  * Return an array of subpages beginning with $search that this special page will accept.
  *
  * @param string $search Prefix to search for
  * @param int $limit Maximum number of results to return
  * @return string[] Matching subpages
  */
 public function prefixSearchSubpages($search, $limit = 10)
 {
     $subpages = User::getAllGroups();
     return self::prefixSearchArray($search, $limit, $subpages);
 }
示例#12
0
 /**
  * Helper function for updateUser() and initUser(). Adds users into MediaWiki security groups
  * based upon groups retreived from LDAP.
  *
  * @param User $user
  * @access private
  */
 function setGroups(&$user)
 {
     $this->printDebug("Pulling groups from LDAP.", 1);
     # add groups permissions
     $localAvailGrps = $user->getAllGroups();
     $localUserGrps = $user->getEffectiveGroups();
     $this->printDebug("Available groups are: " . implode(",", $localAvailGrps) . "", 1);
     $this->printDebug("Effective groups are: " . implode(",", $localUserGrps) . "", 1);
     # note: $localUserGrps does not need to be updated with $cGroup added,
     #       as $localAvailGrps contains $cGroup only once.
     foreach ($localAvailGrps as $cGroup) {
         # did we once add the user to the group?
         if (in_array($cGroup, $localUserGrps)) {
             $this->printDebug("Checking to see if we need to remove user from: {$cGroup}", 1);
             if (!$this->hasLDAPGroup($cGroup) && $this->isLDAPGroup($cGroup)) {
                 $this->printDebug("Removing user from: {$cGroup}", 1);
                 # the ldap group overrides the local group
                 # so as the user is currently not a member of the ldap group, he shall be removed from the local group
                 $user->removeGroup($cGroup);
             }
         } else {
             # no, but maybe the user has recently been added to the ldap group?
             $this->printDebug("Checking to see if user is in: {$cGroup}", 1);
             if ($this->hasLDAPGroup($cGroup)) {
                 $this->printDebug("Adding user to: {$cGroup}", 1);
                 # so use the addGroup function
                 $user->addGroup($cGroup);
                 # completedfor $cGroup.
             }
         }
     }
 }
示例#13
0
 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;
 }
 /**
  * Returns an array of the groups that a particular group can add/remove.
  *
  * @param String $group The group to check for whether it can add/remove
  * @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ) )
  */
 private function changeableByGroup($group)
 {
     global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups;
     if (empty($wgGroupPermissions[$group]['userrights'])) {
         // This group doesn't give the right to modify anything
         return array('add' => array(), 'remove' => array());
     }
     if (empty($wgAddGroups[$group]) and empty($wgRemoveGroups[$group])) {
         // This group gives the right to modify everything (reverse-
         // compatibility with old "userrights lets you change
         // everything")
         return array('add' => User::getAllGroups(), 'remove' => User::getAllGroups());
     }
     // Okay, it's not so simple, we have to go through the arrays
     $groups = array('add' => array(), 'remove' => array());
     if (empty($wgAddGroups[$group])) {
         // Don't add anything to $groups
     } elseif ($wgAddGroups[$group] === true) {
         // You get everything
         $groups['add'] = User::getAllGroups();
     } elseif (is_array($wgAddGroups[$group])) {
         $groups['add'] = $wgAddGroups[$group];
     }
     // Same thing for remove
     if (empty($wgRemoveGroups[$group])) {
     } elseif ($wgRemoveGroups[$group] === true) {
         $groups['remove'] = User::getAllGroups();
     } elseif (is_array($wgRemoveGroups[$group])) {
         $groups['remove'] = $wgRemoveGroups[$group];
     }
     return $groups;
 }
示例#15
0
 /**
  * Returns an array of all groups that may be edited
  * @return array Array of groups that may be edited.
  */
 protected static function getAllGroups()
 {
     // add our wikiHow staff groups [sc - 1/16/2014]
     global $wgGroupPermissions;
     $wgGroupPermissions['staff_widget'] = $wgGroupPermissions['user'];
     $wgGroupPermissions['translator'] = $wgGroupPermissions['user'];
     return User::getAllGroups();
 }
 /**
  * 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;
 }
 /**
  * Create a user-readable list of permissions from the given array.
  *
  * @param array $permissions Array of permission => bool (from $wgGroupPermissions items)
  * @param array $revoke Array of permission => bool (from $wgRevokePermissions items)
  * @param array $add Array of groups this group is allowed to add or true
  * @param array $remove Array of groups this group is allowed to remove or true
  * @param array $addSelf Array of groups this group is allowed to add to self or true
  * @param array $removeSelf Array of group this group is allowed to remove from self or true
  * @return string List of all granted permissions, separated by comma separator
  */
 private function formatPermissions($permissions, $revoke, $add, $remove, $addSelf, $removeSelf)
 {
     $r = [];
     foreach ($permissions as $permission => $granted) {
         // show as granted only if it isn't revoked to prevent duplicate display of permissions
         if ($granted && (!isset($revoke[$permission]) || !$revoke[$permission])) {
             $r[] = $this->msg('listgrouprights-right-display', User::getRightDescription($permission), '<span class="mw-listgrouprights-right-name">' . $permission . '</span>')->parse();
         }
     }
     foreach ($revoke as $permission => $revoked) {
         if ($revoked) {
             $r[] = $this->msg('listgrouprights-right-revoked', User::getRightDescription($permission), '<span class="mw-listgrouprights-right-name">' . $permission . '</span>')->parse();
         }
     }
     sort($r);
     $lang = $this->getLanguage();
     $allGroups = User::getAllGroups();
     $changeGroups = ['addgroup' => $add, 'removegroup' => $remove, 'addgroup-self' => $addSelf, 'removegroup-self' => $removeSelf];
     foreach ($changeGroups as $messageKey => $changeGroup) {
         if ($changeGroup === true) {
             // For grep: listgrouprights-addgroup-all, listgrouprights-removegroup-all,
             // listgrouprights-addgroup-self-all, listgrouprights-removegroup-self-all
             $r[] = $this->msg('listgrouprights-' . $messageKey . '-all')->escaped();
         } elseif (is_array($changeGroup)) {
             $changeGroup = array_intersect(array_values(array_unique($changeGroup)), $allGroups);
             if (count($changeGroup)) {
                 // For grep: listgrouprights-addgroup, listgrouprights-removegroup,
                 // listgrouprights-addgroup-self, listgrouprights-removegroup-self
                 $r[] = $this->msg('listgrouprights-' . $messageKey, $lang->listToText(array_map(['User', 'makeGroupLinkWiki'], $changeGroup)), count($changeGroup))->parse();
             }
         }
     }
     if (empty($r)) {
         return '';
     } else {
         return '<ul><li>' . implode("</li>\n<li>", $r) . '</li></ul>';
     }
 }
 /**
  * Returns an array of the groups that a particular group can add/remove.
  *
  * @param String $group The group to check for whether it can add/remove
  * @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ) )
  */
 private function changeableByGroup($group)
 {
     global $wgAddGroups, $wgRemoveGroups;
     $groups = array('add' => array(), 'remove' => array());
     if (empty($wgAddGroups[$group])) {
         // Don't add anything to $groups
     } elseif ($wgAddGroups[$group] === true) {
         // You get everything
         $groups['add'] = User::getAllGroups();
     } elseif (is_array($wgAddGroups[$group])) {
         $groups['add'] = $wgAddGroups[$group];
     }
     // Same thing for remove
     if (empty($wgRemoveGroups[$group])) {
     } elseif ($wgRemoveGroups[$group] === true) {
         $groups['remove'] = User::getAllGroups();
     } elseif (is_array($wgRemoveGroups[$group])) {
         $groups['remove'] = $wgRemoveGroups[$group];
     }
     return $groups;
 }
示例#19
0
 protected function appendUserGroups($property, $numberInGroup)
 {
     $config = $this->getConfig();
     $data = array();
     $result = $this->getResult();
     $allGroups = User::getAllGroups();
     foreach ($config->get('GroupPermissions') as $group => $permissions) {
         $arr = array('name' => $group, 'rights' => array_keys($permissions, true));
         if ($numberInGroup) {
             $autopromote = $config->get('Autopromote');
             if ($group == 'user') {
                 $arr['number'] = SiteStats::users();
                 // '*' and autopromote groups have no size
             } elseif ($group !== '*' && !isset($autopromote[$group])) {
                 $arr['number'] = SiteStats::numberInGroup($group);
             }
         }
         $groupArr = array('add' => $config->get('AddGroups'), 'remove' => $config->get('RemoveGroups'), 'add-self' => $config->get('GroupsAddToSelf'), 'remove-self' => $config->get('GroupsRemoveFromSelf'));
         foreach ($groupArr as $type => $rights) {
             if (isset($rights[$group])) {
                 $groups = array_intersect($rights[$group], $allGroups);
                 if ($groups) {
                     $arr[$type] = $groups;
                     ApiResult::setIndexedTagName($arr[$type], 'group');
                 }
             }
         }
         ApiResult::setIndexedTagName($arr['rights'], 'permission');
         $data[] = $arr;
     }
     ApiResult::setIndexedTagName($data, 'group');
     return $result->addValue('query', $property, $data);
 }
 public function getAllowedParams()
 {
     $userGroups = User::getAllGroups();
     $userRights = User::getAllRights();
     return array('group' => array(ApiBase::PARAM_TYPE => $userGroups, ApiBase::PARAM_ISMULTI => true), 'excludegroup' => array(ApiBase::PARAM_TYPE => $userGroups, ApiBase::PARAM_ISMULTI => true), 'rights' => array(ApiBase::PARAM_TYPE => $userRights, ApiBase::PARAM_ISMULTI => true), 'excluderights' => array(ApiBase::PARAM_TYPE => $userRights, ApiBase::PARAM_ISMULTI => true), '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), 'continue' => null);
 }
 /**
  * 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;
 }
 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;
 }
 /**
  * Return an array of subpages that this special page will accept.
  *
  * @return string[] subpages
  */
 public function getSubpagesForPrefixSearch()
 {
     return User::getAllGroups();
 }
示例#24
0
 public function getAllowedParams()
 {
     $userGroups = User::getAllGroups();
     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 => $userGroups, ApiBase::PARAM_ISMULTI => true), 'excludegroup' => array(ApiBase::PARAM_TYPE => $userGroups, ApiBase::PARAM_ISMULTI => true), 'rights' => array(ApiBase::PARAM_TYPE => User::getAllRights(), ApiBase::PARAM_ISMULTI => true), 'prop' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => array('blockinfo', 'groups', 'implicitgroups', 'rights', 'editcount', 'registration', 'centralids'), ApiBase::PARAM_HELP_MSG_PER_VALUE => array()), '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), 'witheditsonly' => false, 'activeusers' => array(ApiBase::PARAM_DFLT => false, ApiBase::PARAM_HELP_MSG => array('apihelp-query+allusers-param-activeusers', $this->getConfig()->get('ActiveUserDays'))), 'attachedwiki' => null);
 }
 public function getAllowedParams()
 {
     $userGroups = User::getAllGroups();
     $userRights = User::getAllRights();
     return ['group' => [ApiBase::PARAM_TYPE => $userGroups, ApiBase::PARAM_ISMULTI => true], 'excludegroup' => [ApiBase::PARAM_TYPE => $userGroups, ApiBase::PARAM_ISMULTI => true], 'rights' => [ApiBase::PARAM_TYPE => $userRights, ApiBase::PARAM_ISMULTI => true], 'excluderights' => [ApiBase::PARAM_TYPE => $userRights, ApiBase::PARAM_ISMULTI => true], 'limit' => [ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2], 'continue' => [ApiBase::PARAM_HELP_MSG => 'api-help-param-continue']];
 }
示例#26
0
 public function getAllowedParams()
 {
     return array('from' => null, 'prefix' => null, 'group' => array(ApiBase::PARAM_TYPE => User::getAllGroups()), 'prop' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => array('editcount', 'groups', 'registration')), '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));
 }
示例#27
0
 /**
  * Returns an array of the groups that a particular group can add/remove.
  *
  * @param $group String: the group to check for whether it can add/remove
  * @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ) , 'add-self' => array( addablegroups to self), 'remove-self' => array( removable groups from self) )
  */
 private function changeableByGroup($group)
 {
     global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
     $groups = array('add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array());
     if (empty($wgAddGroups[$group])) {
         // Don't add anything to $groups
     } elseif ($wgAddGroups[$group] === true) {
         // You get everything
         $groups['add'] = User::getAllGroups();
     } elseif (is_array($wgAddGroups[$group])) {
         $groups['add'] = $wgAddGroups[$group];
     }
     // Same thing for remove
     if (empty($wgRemoveGroups[$group])) {
     } elseif ($wgRemoveGroups[$group] === true) {
         $groups['remove'] = User::getAllGroups();
     } elseif (is_array($wgRemoveGroups[$group])) {
         $groups['remove'] = $wgRemoveGroups[$group];
     }
     // Re-map numeric keys of AddToSelf/RemoveFromSelf to the 'user' key for backwards compatibility
     if (empty($wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true) {
         foreach ($wgGroupsAddToSelf as $key => $value) {
             if (is_int($key)) {
                 $wgGroupsAddToSelf['user'][] = $value;
             }
         }
     }
     if (empty($wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true) {
         foreach ($wgGroupsRemoveFromSelf as $key => $value) {
             if (is_int($key)) {
                 $wgGroupsRemoveFromSelf['user'][] = $value;
             }
         }
     }
     // Now figure out what groups the user can add to him/herself
     if (empty($wgGroupsAddToSelf[$group])) {
     } elseif ($wgGroupsAddToSelf[$group] === true) {
         // No idea WHY this would be used, but it's there
         $groups['add-self'] = User::getAllGroups();
     } elseif (is_array($wgGroupsAddToSelf[$group])) {
         $groups['add-self'] = $wgGroupsAddToSelf[$group];
     }
     if (empty($wgGroupsRemoveFromSelf[$group])) {
     } elseif ($wgGroupsRemoveFromSelf[$group] === true) {
         $groups['remove-self'] = User::getAllGroups();
     } elseif (is_array($wgGroupsRemoveFromSelf[$group])) {
         $groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
     }
     return $groups;
 }
示例#28
0
 /**
  * Get all available groups.
  * @return array
  */
 protected function getAllGroups()
 {
     return User::getAllGroups();
 }
示例#29
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;
}
);

$edits_body = "<table cellpadding='5'><tr><td><b>Edited Questions on answer.wikia.com</b><br><br></td></tr>
	<tr><td><a href=\"" . htmlspecialchars(SpecialPage::getTitleFor( 'Recentchanges' )->getFullURL()) . "\">" . wfMsg("see_all_changes") . "</a><br><br></td></tr>";

$edits = array();
while ($row = $dbr->fetchObject( $res ) ) {
	$title = Title::newFromDBKey( $row->page_title );
	if( in_array( $row->page_title, $edits ) ) continue;
	$edits_body .= "<tr><td height='30' style='border-bottom:1px solid #eeeeee'>* <b><a href=\"" . htmlspecialchars($title->getFullURL()) . "\">" . $title->getText() . "</a></b> | <a href=\"" . htmlspecialchars($title->getFullURL("action=edit")) . "\">" . wfMsg("answer_this_question") . "</a> | <a href=\"" . htmlspecialchars(SpecialPage::getTitleFor( 'Movepage', $title->getText() )->getFullURL()) . "\">" . wfMsg("movepagebtn") . "</a> | <a href=\"" . htmlspecialchars($title->getFullURL("action=delete")) . "\">" . wfMsg("delete") . "</a></td></tr>\n";
	$edits[] = $row->page_title;
}
$edits_body .= "</table>";

//BUILD LIST OF ALL USERS IN THIS GROUP
$groups = User::getAllGroups();
if( !in_array( $group, $groups ) ){
	//die("Group '$group' does not exist!\n");
}

list ($user,$user_groups) = $dbr->tableNamesN('user','user_groups');
$res = $dbr->select( "$user_groups  LEFT JOIN $user ON user_id=ug_user",
		array( 'user_name','user_id' ),
	array("ug_group"=>$group ), __METHOD__,
	""
);

$emails_sent = 0;
while ($row = $dbr->fetchObject( $res ) ) {

	$user = User::newFromName( $row->user_name );