当前位置: 首页>>代码示例>>PHP>>正文


PHP UserRights::getGlobalGroups方法代码示例

本文整理汇总了PHP中UserRights::getGlobalGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRights::getGlobalGroups方法的具体用法?PHP UserRights::getGlobalGroups怎么用?PHP UserRights::getGlobalGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserRights的用法示例。


在下文中一共展示了UserRights::getGlobalGroups方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateUserGroups

 public function updateUserGroups($user, $addgroup = array(), $removegroup = array())
 {
     wfProfileIn(__METHOD__);
     if (!$user instanceof User) {
         wfProfileOut(__METHOD__);
         return true;
     }
     $user_id = $user->getID();
     $dbr = wfGetDB(DB_SLAVE, array(), $this->mDBh);
     $where = array("user_id" => $user_id, "wiki_id" => $this->mCityId);
     $oRow = $dbr->selectRow(array($this->mTable), array("all_groups"), $where, __METHOD__);
     $groups = array();
     if ($oRow !== false) {
         $tmp = explode(";", $oRow->all_groups);
         if (!empty($tmp)) {
             foreach ($tmp as $g) {
                 if (!empty($g)) {
                     $groups[] = $g;
                 }
             }
         }
     }
     $central_groups = array();
     if (class_exists('UserRights')) {
         if (!UserRights::isCentralWiki()) {
             $central_groups = UserRights::getGlobalGroups($user);
         }
     }
     # add groups
     if (!empty($addgroup)) {
         $groups = array_unique(array_merge($groups, $addgroup));
     }
     # remove groups
     if (!empty($removegroup)) {
         $groups = array_unique(array_diff($groups, $removegroup));
     }
     #central groups
     if (!empty($central_groups)) {
         $groups = array_unique(array_merge($groups, $central_groups));
     }
     if (!empty($groups)) {
         sort($groups);
     }
     $elements = count($groups);
     $singlegroup = $elements > 0 ? $groups[$elements - 1] : "";
     $allgroups = $elements > 0 ? implode(";", $groups) : "";
     $dbw = wfGetDB(DB_MASTER, array(), $this->mDBh);
     if (empty($oRow)) {
         $edits = User::edits($user_id);
         $dbr = wfGetDB(DB_SLAVE);
         $revRow = $dbr->selectRow('revision', array('rev_id', 'rev_timestamp'), array('rev_user' => $user_id), __METHOD__, array('ORDER BY' => 'rev_timestamp DESC'));
         if (empty($revRow)) {
             $editdate = '0000-00-00 00:00:00';
             $lastrev = 0;
         } else {
             $editdate = wfTimestamp(TS_DB, $revRow->rev_timestamp);
             $lastrev = $revRow->rev_id;
         }
         $dbw->replace($this->mTable, array('wiki_id', 'user_id', 'user_name'), array("wiki_id" => $this->mCityId, "user_id" => $user_id, "user_name" => $user->getName(), "last_ip" => 0, "edits" => $edits, "editdate" => $editdate, "last_revision" => intval($lastrev), "cnt_groups" => $elements, "single_group" => $singlegroup, "all_groups" => $allgroups), __METHOD__);
     } else {
         $dbw->update($this->mTable, array("cnt_groups" => $elements, "single_group" => $singlegroup, "all_groups" => $allgroups), $where, __METHOD__);
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:yusufchang,项目名称:app,代码行数:65,代码来源:SpecialListusers_helper.php

示例2: isGroupForRemoval

 /**
  * Checks if removal of a property should remove a group
  * and if a user still has a PowerUser type that qualifies him
  * to have the 'poweruser' group
  *
  * @param string $sProperty One of the types in consts
  * @return bool
  */
 public function isGroupForRemoval($sProperty)
 {
     foreach (self::$aPowerUserProperties as $sPowerUserProperty) {
         if ($sPowerUserProperty !== $sProperty && $this->oUser->isSpecificPowerUser($sPowerUserProperty)) {
             return false;
         }
     }
     return in_array(self::GROUP_NAME, \UserRights::getGlobalGroups($this->oUser));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:17,代码来源:PowerUser.class.php


注:本文中的UserRights::getGlobalGroups方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。