/** * Get list of roles * * @service * @anonym * @param Gpf_Rpc_Params $parmas */ public function getRolesList(Gpf_Rpc_Params $params) { if (!Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Gpf_Privileges::P_READ) && !Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Pap_Privileges::P_READ_OWN)) { throw new Gpf_Rpc_PermissionDeniedException('Gpf_Db_Table_Roles', 'getRolesList'); } $sql = new Gpf_SqlBuilder_SelectBuilder(); $sql->from->add(Gpf_Db_Table_Roles::getName()); $sql->select->addAll(Gpf_Db_Table_Roles::getInstance()); $accountCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); if (Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Gpf_Privileges::P_READ)) { $accountCondition->add(Gpf_Db_Table_Accounts::ID, '!=', '', 'OR'); } else { $accountCondition->add(Gpf_Db_Table_Accounts::ID, '=', Gpf_Session::getInstance()->getAuthUser()->getAccountId(), 'OR'); } $accountCondition->add(Gpf_Db_Table_Accounts::ID, '=', null, 'OR'); $sql->where->addCondition($accountCondition); if ($params->exists('roleTypes') && $params->get('roleTypes') !== '') { $sql->where->add(Gpf_Db_Table_Roles::TYPE, 'IN', explode(',', $params->get('roleTypes'))); } $sql->orderBy->add(Gpf_Db_Table_Accounts::ID); $sql->orderBy->add(Gpf_Db_Table_Roles::NAME); return $sql->getAllRows(); }
function init() { $this->setTable(Gpf_Db_Table_Roles::getInstance()); parent::init(); }