/** * Returns an instance of class (singleton pattern implementation). * * @return UHEADER_BOL_TemplateRoleDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
public function saveRoleIdsForTemplateId($templateId, $roleIds) { $allRoles = BOL_AuthorizationService::getInstance()->findNonGuestRoleList(); $allRoleIds = array(); foreach ($allRoles as $role) { $allRoleIds[] = $role->id; } $this->templateRoleDao->deleteByTemplateId($templateId); if (!array_diff($allRoleIds, $roleIds)) { return; } foreach ($roleIds as $roleId) { $tmpRoleDto = new UHEADER_BOL_TemplateRole(); $tmpRoleDto->templateId = $templateId; $tmpRoleDto->roleId = $roleId; $this->templateRoleDao->save($tmpRoleDto); } }
public function findListForAllUsers() { $templateRoleDao = UHEADER_BOL_TemplateRoleDao::getInstance(); $query = "SELECT DISTINCT t.* FROM " . $this->getTableName() . " t \n LEFT JOIN " . $templateRoleDao->getTableName() . " tr ON t.id = tr.templateId\n WHERE tr.id IS NULL ORDER BY t.timeStamp DESC"; return $this->dbo->queryForObjectList($query, $this->getDtoClassName()); }