/**
  * Returns membership type list
  *
  * @param $accTypeId
  * @return array
  */
 public function getAllTypeList($accTypeId)
 {
     $roleDao = BOL_AuthorizationRoleDao::getInstance();
     $accTypeCond = !empty($accTypeId) ? " WHERE `mt`.`accountTypeId` = " . $this->dbo->escapeString($accTypeId) : "";
     $query = "SELECT `mt`.* FROM `" . $this->getTableName() . "` AS `mt`\n            LEFT JOIN `" . $roleDao->getTableName() . "` AS `r` ON(`mt`.`roleId`=`r`.`id`) " . $accTypeCond . "\n            GROUP BY `mt`.`roleId`\n            ORDER BY `r`.`sortOrder` ASC";
     return $this->dbo->queryForObjectList($query, $this->getDtoClassName());
 }
Example #2
0
 public function findMassMailingUserCount($ignoreUnsubscribe = false, $userRoles = array())
 {
     $join = '';
     $where = '';
     $queryParts = $this->getUserQueryFilter("u", "id", array("method" => "BOL_UserDao::findMassMailingUserCount"));
     if ($ignoreUnsubscribe !== true) {
         $join .= " LEFT JOIN `" . BOL_PreferenceDataDao::getInstance()->getTableName() . "` AS `preference`\n                    ON (`u`.`id` = `preference`.`userId` AND `preference`.`key` = 'mass_mailing_subscribe') ";
         $where .= " AND  ( `preference`.`value` = 'true' OR `preference`.`id` IS NULL ) ";
     }
     if (!empty($userRoles) && is_array($userRoles)) {
         $join .= " INNER JOIN `" . BOL_AuthorizationUserRoleDao::getInstance()->getTableName() . "` AS `userRole`\n                    ON (`u`.`id` = `userRole`.`userId`)\n                    INNER JOIN `" . BOL_AuthorizationRoleDao::getInstance()->getTableName() . "` AS `role`\n                        ON (`userRole`.`roleId` = `role`.`id`) ";
         $where .= " AND  ( `role`.`name` IN ( " . OW::getDbo()->mergeInClause($userRoles) . " ) ) ";
     }
     $query = "\n            SELECT  COUNT( DISTINCT `u`.`id`) FROM `{$this->getTableName()}` AS `u`\n                {$queryParts["join"]}\n                {$join}\n            WHERE {$queryParts["where"]}  {$where} ";
     return $this->dbo->queryForColumn($query);
 }
 public function getRoleListOfUsers(array $idList, $displayLabel)
 {
     if (count($idList) < 1) {
         return array();
     }
     $idList = array_map('intval', $idList);
     $idsToRequire = array();
     $result = array();
     $var = null;
     foreach ($idList as $id) {
         if (array_key_exists($id, $this->cachedItems)) {
             if ($this->cachedItems[$id] !== null) {
                 $result[$id] = $this->cachedItems[$id];
             }
         } else {
             $idsToRequire[] = $id;
         }
     }
     $items = array();
     if (!empty($idsToRequire)) {
         $roleTable = BOL_AuthorizationRoleDao::getInstance()->getTableName();
         $labelCond = $displayLabel ? ' AND r.displayLabel=1 ' : '';
         $query = "SELECT `userId`,`name`,`custom` FROM {$this->getTableName()} ur \n                  INNER JOIN {$roleTable} r ON ur.roleId=r.id\n                  WHERE ur.userId IN({$this->dbo->mergeInClause($idsToRequire)}) " . $labelCond . "\n                  ORDER BY sortOrder DESC";
         $items = $this->dbo->queryForList($query);
     }
     foreach ($items as $key => $item) {
         if (key_exists($item['userId'], $result)) {
             continue;
         }
         $result[(int) $item['userId']] = $item;
         $this->cachedItems[(int) $item['userId']] = $item;
     }
     return $result;
 }
Example #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();
 }
Example #5
0
 /**
  * Returns membership type list
  * 
  * @return array
  */
 public function getAllTypeList()
 {
     $roleDao = BOL_AuthorizationRoleDao::getInstance();
     $query = "SELECT `mt`.* FROM `" . $this->getTableName() . "` AS `mt`\n            LEFT JOIN `" . $roleDao->getTableName() . "` AS `r` ON(`mt`.`roleId`=`r`.`id`) ORDER BY `r`.`sortOrder` ASC";
     return $this->dbo->queryForObjectList($query, $this->getDtoClassName());
 }