コード例 #1
0
ファイル: user_dao.php プロジェクト: hardikamutech/loov
 public function countByRoleId($roleId)
 {
     $query = "SELECT COUNT(*)\n    \t\t FROM `{$this->getTableName()}` as `u`\n\n    \t\t INNER JOIN `" . BOL_AuthorizationUserRoleDao::getInstance()->getTableName() . "` as `ur`\n    \t\t \tON( `u`.`id` = `ur`.`userId` )\n    \t\t WHERE `ur`.`roleId` = ? ";
     return $this->dbo->queryForColumn($query, array($roleId));
 }
コード例 #2
0
 public function addRoleByAccountType(BOL_QuestionAccountType $accountType)
 {
     if (empty($accountType)) {
         return;
     }
     $sql = " REPLACE INTO `" . BOL_AuthorizationUserRoleDao::getInstance()->getTableName() . "` ( `userId`, `roleId` ) " . "SELECT u.id, :role FROM " . BOL_UserDao::getInstance()->getTableName() . " u " . " INNER JOIN " . BOL_QuestionAccountTypeDao::getInstance()->getTableName() . " `accountType` ON ( accountType.name = u.accountType ) " . " WHERE  u.accountType = :account ";
     $this->dbo->query($sql, array('account' => $accountType->name, 'role' => $accountType->roleId));
 }
コード例 #3
0
ファイル: user_dao.php プロジェクト: vazahat/dudex
 public function findByRoleIds($count, $roles, $withPhoto = true)
 {
     if (empty($roles)) {
         return array();
     }
     $avatarJoin = !$withPhoto ? '' : "INNER JOIN `" . BOL_AvatarDao::getInstance()->getTableName() . "` as `a`\n    \t\t\tON( `u`.`id` = `a`.`userId` )";
     $query = "\n            SELECT DISTINCT `u`.*\n            FROM `{$this->getTableName()}` AS `u`\n\n    \t\tLEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s`\n    \t\t\tON( `u`.`id` = `s`.`userId` )\n\n    \t\tLEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d`\n    \t\t\tON( `u`.`id` = `d`.`userId` )\n\n                {$avatarJoin}\n                    \n                INNER JOIN `" . BOL_AuthorizationUserRoleDao::getInstance()->getTableName() . "` as `ur`\n    \t\t \tON( `u`.`id` = `ur`.`userId` )\n\n    \t\tWHERE `s`.`id` IS NULL AND `d`.`id` IS NULL AND `ur`.`roleId` IN ( '" . implode("', '", $roles) . "' )\n\n            ORDER BY `u`.`activityStamp` DESC\n            LIMIT ?, ?\n            ";
     return $this->dbo->queryForObjectList($query, $this->getDtoClassName(), array(0, $count));
 }
コード例 #4
0
 private function __construct()
 {
     $this->roleDao = BOL_AuthorizationRoleDao::getInstance();
     $this->userRoleDao = BOL_AuthorizationUserRoleDao::getInstance();
     $this->actionDao = BOL_AuthorizationActionDao::getInstance();
     $this->groupDao = BOL_AuthorizationGroupDao::getInstance();
     $this->permissionDao = BOL_AuthorizationPermissionDao::getInstance();
     $this->moderatorDao = BOL_AuthorizationModeratorDao::getInstance();
     $this->moderatorPermissionDao = BOL_AuthorizationModeratorPermissionDao::getInstance();
     $this->groupDaoCache = $this->groupDao->findAll();
     foreach ($this->groupDaoCache as $group) {
         /* @var $group BOL_AuthorizationGroup */
         $this->groupCache[$group->name] = $group->id;
     }
     $moderatorDaoCache = $this->moderatorDao->findAll();
     $this->superModeratorUserId = 0;
     foreach ($moderatorDaoCache as $moderator) {
         /* @var $moderator BOL_AuthorizationModerator */
         $this->moderatorCache[$moderator->userId] = $moderator->id;
         if ($this->superModeratorUserId === 0 || (int) $this->moderatorCache[$moderator->userId] < (int) $this->moderatorCache[$this->superModeratorUserId]) {
             $this->superModeratorUserId = (int) $moderator->userId;
         }
     }
     $moderatorPermissionDaoCache = $this->moderatorPermissionDao->findAll();
     foreach ($moderatorPermissionDaoCache as $perm) {
         /* @var $perm BOL_AuthorizationModeratorPermission */
         $this->moderatorPermissionCache[$perm->moderatorId][$perm->groupId] = $perm->id;
     }
     $this->actionDaoCache = $this->actionDao->findAll();
     foreach ($this->actionDaoCache as $action) {
         /* @var $action BOL_AuthorizationAction */
         $this->actionCache[$action->name][$action->groupId] = $action->id;
     }
     $this->userRolesCache = array();
     if (OW::getUser()->isAuthenticated()) {
         $this->userRolesCache[OW::getUser()->getId()] = $this->userRoleDao->getRoleIdList(OW::getUser()->getId());
     }
     $permissionDaoCache = $this->permissionDao->findAll();
     foreach ($permissionDaoCache as $permission) {
         /* @var $permission BOL_AuthorizationPermission */
         $this->permissionCache[$permission->actionId][$permission->roleId] = $permission->id;
     }
     $this->roleDaoCache = $this->roleDao->findAll();
     $this->guestRoleId = $this->getGuestRoleId();
 }
コード例 #5
0
 public function findUserRoleList($userId)
 {
     $query = "SELECT `r`.* FROM `{$this->getTableName()}` as `r`\r\n\t\tINNER JOIN `" . BOL_AuthorizationUserRoleDao::getInstance()->getTableName() . "` as `ur`\r\n\t\t\tON(`r`.`id` = `ur`.`roleId`)\r\n\t\tWHERE `ur`.`userId` = ? ORDER BY `sortOrder` ASC\r\n\t\t";
     return $this->dbo->queryForObjectList($query, $this->getDtoClassName(), array($userId));
 }