Example #1
0
 /**
  * Get the list of implicit group memberships this user has.
  * This includes 'user' if logged in, '*' for all accounts,
  * and autopromoted groups
  * @param $recache Bool Whether to avoid the cache
  * @return Array of String internal group names
  */
 public function getAutomaticGroups($recache = false)
 {
     if ($recache || is_null($this->mImplicitGroups)) {
         wfProfileIn(__METHOD__);
         $this->mImplicitGroups = array('*');
         if ($this->getId()) {
             $this->mImplicitGroups[] = 'user';
             $this->mImplicitGroups = array_unique(array_merge($this->mImplicitGroups, Autopromote::getAutopromoteGroups($this)));
         }
         if ($recache) {
             # Assure data consistency with rights/groups,
             # as getEffectiveGroups() depends on this function
             $this->mEffectiveGroups = null;
         }
         wfProfileOut(__METHOD__);
     }
     return $this->mImplicitGroups;
 }
 /**
  * Show the form to edit group memberships.
  *
  * @param User|UserRightsProxy $user User or UserRightsProxy you're editing
  * @param array $groups Array of groups the user is in
  */
 protected function showEditUserGroupsForm($user, $groups)
 {
     $list = array();
     $membersList = array();
     foreach ($groups as $group) {
         $list[] = self::buildGroupLink($group);
         $membersList[] = self::buildGroupMemberLink($group);
     }
     $autoList = array();
     $autoMembersList = array();
     if ($user instanceof User) {
         foreach (Autopromote::getAutopromoteGroups($user) as $group) {
             $autoList[] = self::buildGroupLink($group);
             $autoMembersList[] = self::buildGroupMemberLink($group);
         }
     }
     $language = $this->getLanguage();
     $displayedList = $this->msg('userrights-groupsmember-type')->rawParams($language->listToText($list), $language->listToText($membersList))->escaped();
     $displayedAutolist = $this->msg('userrights-groupsmember-type')->rawParams($language->listToText($autoList), $language->listToText($autoMembersList))->escaped();
     $grouplist = '';
     $count = count($list);
     if ($count > 0) {
         $grouplist = $this->msg('userrights-groupsmember')->numParams($count)->params($user->getName())->parse();
         $grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
     }
     $count = count($autoList);
     if ($count > 0) {
         $autogrouplistintro = $this->msg('userrights-groupsmember-auto')->numParams($count)->params($user->getName())->parse();
         $grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
     }
     $userToolLinks = Linker::userToolLinks($user->getId(), $user->getName(), false, Linker::TOOL_LINKS_EMAIL);
     $this->getOutput()->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $this->getPageTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2')) . Html::hidden('user', $this->mTarget) . Html::hidden('wpEditToken', $this->getUser()->getEditToken($this->mTarget)) . Html::hidden('conflictcheck-originalgroups', implode(',', $user->getGroups())) . Xml::openElement('fieldset') . Xml::element('legend', array(), $this->msg('userrights-editusergroup', $user->getName())->text()) . $this->msg('editinguser')->params(wfEscapeWikiText($user->getName()))->rawParams($userToolLinks)->parse() . $this->msg('userrights-groups-help', $user->getName())->parse() . $grouplist . $this->groupCheckboxes($groups, $user) . Xml::openElement('table', array('id' => 'mw-userrights-table-outer')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('userrights-reason')->text(), 'wpReason') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('user-reason', 60, $this->getRequest()->getVal('user-reason', false), array('id' => 'wpReason', 'maxlength' => 255)) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton($this->msg('saveusergroups')->text(), array('name' => 'saveusergroups') + Linker::tooltipAndAccesskeyAttribs('userrights-set')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . "\n" . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n");
 }
Example #3
0
 /**
  * Get the list of implicit group memberships this user has.
  * This includes all explicit groups, plus 'user' if logged in,
  * '*' for all accounts and autopromoted groups
  * @param boolean $recache Don't use the cache
  * @return array of strings
  */
 function getEffectiveGroups($recache = false)
 {
     if ($recache || is_null($this->mEffectiveGroups)) {
         $this->load();
         $this->mEffectiveGroups = $this->mGroups;
         $this->mEffectiveGroups[] = '*';
         if ($this->mId) {
             $this->mEffectiveGroups[] = 'user';
             $this->mEffectiveGroups = array_unique(array_merge($this->mEffectiveGroups, Autopromote::getAutopromoteGroups($this)));
             # Hook for additional groups
             wfRunHooks('UserEffectiveGroups', array(&$this, &$this->mEffectiveGroups));
         }
     }
     return $this->mEffectiveGroups;
 }
Example #4
0
 /**
  * Show the form to edit group memberships.
  *
  * @param $user      User or UserRightsProxy you're editing
  * @param $groups    Array:  Array of groups the user is in
  */
 protected function showEditUserGroupsForm($user, $groups)
 {
     /* Wikia change begin - @author: Marooned */
     /* This hook was invalid in this version of the code and in the current (2010-05-18) MW trunk it even doesn't exist */
     /* We need it to alter displayed list without alter real groups */
     wfRunHooks('UserRights::showEditUserGroupsForm', array(&$user, &$groups));
     /* Wikia change end */
     $list = array();
     foreach ($groups as $group) {
         $list[] = self::buildGroupLink($group);
     }
     $autolist = array();
     if ($user instanceof User) {
         foreach (Autopromote::getAutopromoteGroups($user) as $group) {
             $autolist[] = self::buildGroupLink($group);
         }
     }
     $grouplist = '';
     $count = count($list);
     if ($count > 0) {
         $grouplist = wfMessage('userrights-groupsmember', $count)->parse();
         $grouplist = '<p>' . $grouplist . ' ' . $this->getLanguage()->listToText($list) . "</p>\n";
     }
     $count = count($autolist);
     if ($count > 0) {
         $autogrouplistintro = wfMessage('userrights-groupsmember-auto', $count)->parse();
         $grouplist .= '<p>' . $autogrouplistintro . ' ' . $this->getLanguage()->listToText($autolist) . "</p>\n";
     }
     $userToolLinks = Linker::userToolLinks($user->getId(), $user->getName(), false, Linker::TOOL_LINKS_EMAIL);
     $this->getOutput()->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2')) . Html::hidden('user', $this->mTarget) . Html::hidden('wpEditToken', $this->getUser()->getEditToken($this->mTarget)) . Xml::openElement('fieldset') . Xml::element('legend', array(), wfMessage('userrights-editusergroup', $user->getName())->text()) . wfMessage('editinguser')->params(wfEscapeWikiText($user->getName()))->rawParams($userToolLinks)->parse() . wfMessage('userrights-groups-help', $user->getName())->parse() . $grouplist . Xml::tags('p', null, $this->groupCheckboxes($groups, $user)) . Xml::openElement('table', array('border' => '0', 'id' => 'mw-userrights-table-outer')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('userrights-reason'), 'wpReason') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('user-reason', 60, $this->getRequest()->getVal('user-reason', false), array('id' => 'wpReason', 'maxlength' => 255)) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('saveusergroups'), array('name' => 'saveusergroups') + Linker::tooltipAndAccesskeyAttribs('userrights-set')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . "\n" . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n");
 }
Example #5
0
 /**
  * Gets all the groups that a user is automatically a member of
  * @return array
  */
 public static function getAutoGroups($user)
 {
     $groups = array('*');
     if (!$user->isAnon()) {
         $groups[] = 'user';
     }
     return array_merge($groups, Autopromote::getAutopromoteGroups($user));
 }
 /**
  * Show the form to edit group memberships.
  *
  * @param $user      User or UserRightsProxy you're editing
  * @param $groups    Array:  Array of groups the user is in
  */
 protected function showEditUserGroupsForm($user, $groups)
 {
     global $wgOut, $wgUser, $wgLang, $wgRequest;
     $list = array();
     foreach ($groups as $group) {
         $list[] = self::buildGroupLink($group);
     }
     $autolist = array();
     if ($user instanceof User) {
         foreach (Autopromote::getAutopromoteGroups($user) as $group) {
             $autolist[] = self::buildGroupLink($group);
         }
     }
     $grouplist = '';
     $count = count($list);
     if ($count > 0) {
         $grouplist = wfMessage('userrights-groupsmember', $count)->parse();
         $grouplist = '<p>' . $grouplist . ' ' . $wgLang->listToText($list) . "</p>\n";
     }
     $count = count($autolist);
     if ($count > 0) {
         $autogrouplistintro = wfMessage('userrights-groupsmember-auto', $count)->parse();
         $grouplist .= '<p>' . $autogrouplistintro . ' ' . $wgLang->listToText($autolist) . "</p>\n";
     }
     $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2')) . Html::hidden('user', $this->mTarget) . Html::hidden('wpEditToken', $wgUser->editToken($this->mTarget)) . Xml::openElement('fieldset') . Xml::element('legend', array(), wfMsg('userrights-editusergroup')) . wfMsgExt('editinguser', array('parse'), wfEscapeWikiText($user->getName())) . wfMsgExt('userrights-groups-help', array('parse')) . $grouplist . Xml::tags('p', null, $this->groupCheckboxes($groups)) . Xml::openElement('table', array('border' => '0', 'id' => 'mw-userrights-table-outer')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('userrights-reason'), 'wpReason') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('user-reason', 60, $wgRequest->getVal('user-reason', false), array('id' => 'wpReason', 'maxlength' => 255)) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('saveusergroups'), array('name' => 'saveusergroups') + Linker::tooltipAndAccesskeyAttribs('userrights-set')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . "\n" . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n");
 }
Example #7
0
 /**
  * Get the list of implicit group memberships this user has.
  * This includes all explicit groups, plus 'user' if logged in,
  * '*' for all accounts and autopromoted groups
  * @param $recache \bool Whether to avoid the cache
  * @return \type{\arrayof{\string}} Array of internal group names
  */
 function getEffectiveGroups($recache = false)
 {
     if ($recache || is_null($this->mEffectiveGroups)) {
         wfProfileIn(__METHOD__);
         $this->mEffectiveGroups = $this->getGroups();
         $this->mEffectiveGroups[] = '*';
         if ($this->getId()) {
             $this->mEffectiveGroups[] = 'user';
             $this->mEffectiveGroups = array_unique(array_merge($this->mEffectiveGroups, Autopromote::getAutopromoteGroups($this)));
             # Hook for additional groups
             wfRunHooks('UserEffectiveGroups', array(&$this, &$this->mEffectiveGroups));
         }
         wfProfileOut(__METHOD__);
     }
     return $this->mEffectiveGroups;
 }
Example #8
0
 /**
  * Get the list of implicit group memberships this user has.
  * This includes 'user' if logged in, '*' for all accounts,
  * and autopromoted groups
  * @param bool $recache Whether to avoid the cache
  * @return array Array of String internal group names
  */
 public function getAutomaticGroups($recache = false)
 {
     if ($recache || is_null($this->mImplicitGroups)) {
         $this->mImplicitGroups = ['*'];
         if ($this->getId()) {
             $this->mImplicitGroups[] = 'user';
             $this->mImplicitGroups = array_unique(array_merge($this->mImplicitGroups, Autopromote::getAutopromoteGroups($this)));
         }
         if ($recache) {
             // Assure data consistency with rights/groups,
             // as getEffectiveGroups() depends on this function
             $this->mEffectiveGroups = null;
         }
     }
     return $this->mImplicitGroups;
 }