コード例 #1
0
 /**
  * Loads group data from cache.
  */
 protected function loadGroupData()
 {
     if ($this->groupData !== null) {
         return;
     }
     // work-around for setup process (package wcf does not exist yet)
     if (!PACKAGE_ID) {
         $groupIDs = array();
         $sql = "SELECT\tgroupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_group\n\t\t\t\tWHERE\tuserID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->user->userID));
         while ($row = $statement->fetchArray()) {
             $groupIDs[] = $row['groupID'];
         }
     } else {
         $groupIDs = $this->user->getGroupIDs();
     }
     $groups = implode(',', $groupIDs);
     $groupsFileName = StringUtil::getHash($groups);
     // register cache resource
     $cacheName = 'groups-' . PACKAGE_ID . '-' . $groups;
     CacheHandler::getInstance()->addResource($cacheName, WCF_DIR . 'cache/cache.groups-' . PACKAGE_ID . '-' . $groupsFileName . '.php', 'wcf\\system\\cache\\builder\\UserGroupPermissionCacheBuilder');
     // get group data from cache
     $this->groupData = CacheHandler::getInstance()->get($cacheName);
     if (isset($this->groupData['groupIDs']) && $this->groupData['groupIDs'] != $groups) {
         $this->groupData = array();
     }
 }
コード例 #2
0
 /**
  * @see	\wcf\system\condition\IUserCondition::checkUser()
  */
 public function checkUser(Condition $condition, User $user)
 {
     $groupIDs = $user->getGroupIDs();
     if (!empty($condition->conditionData['groupIDs']) && count(array_diff($condition->conditionData['groupIDs'], $groupIDs))) {
         return false;
     }
     if (!empty($condition->conditionData['notGroupIDs']) && count(array_intersect($condition->conditionData['notGroupIDs'], $groupIDs))) {
         return false;
     }
     return true;
 }
コード例 #3
0
 /**
  * Loads group data from cache.
  */
 protected function loadGroupData()
 {
     if ($this->groupData !== null) {
         return;
     }
     // work-around for setup process (package wcf does not exist yet)
     if (!PACKAGE_ID) {
         $groupIDs = array();
         $sql = "SELECT\tgroupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_group\n\t\t\t\tWHERE\tuserID = ?";
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute(array($this->user->userID));
         while ($row = $statement->fetchArray()) {
             $groupIDs[] = $row['groupID'];
         }
     } else {
         $groupIDs = $this->user->getGroupIDs();
     }
     // get group data from cache
     $this->groupData = UserGroupPermissionCacheBuilder::getInstance()->getData($groupIDs);
     if (isset($this->groupData['groupIDs']) && $this->groupData['groupIDs'] != $groupIDs) {
         $this->groupData = array();
     }
 }