/** * 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()); }
/** * Returns an instance of class (singleton pattern implementation). * * @return BOL_AuthorizationRoleDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
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; }
public function saveRole(BOL_AuthorizationRole $role) { $this->roleDao->save($role); }
/** * 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()); }