/** * Add all Roles to Zend_Acl. * * @return void */ private function _registerRoles() { $roles = new Phprojekt_Role_Role(); foreach ($roles->fetchAll() as $role) { if ($role->parent < 1) { $role->parent = null; } $this->addRole(new Zend_Acl_Role($role->id), $role->parent); } }
/** * Return all the roles in an array and their relations if exists. * * @param integer $projectId The Project ID. * * @return array Array with 'id', 'name' and 'users'. */ function getProjectRoleUserPermissions($projectId) { $roles = array(); $model = new Phprojekt_Role_Role(); foreach ($model->fetchAll(null, 'name ASC') as $role) { $roles['data'][$role->id] = array(); $roles['data'][$role->id]['id'] = (int) $role->id; $roles['data'][$role->id]['name'] = $role->name; $roles['data'][$role->id]['users'] = array(); } $select = Phprojekt::getInstance()->getDb()->select(); $select->from(array('prup' => 'project_role_user_permissions'), array('roleId' => 'role_id', 'userId' => 'user_id'))->where('prup.project_id = ?', (int) $projectId)->joinLeft(array('u' => 'user'), 'u.id = prup.user_id', array('username', 'firstname', 'lastname'))->order('prup.user_id ASC'); $display = Phprojekt_User_User::getDisplay(); foreach ($select->query()->fetchAll(Zend_Db::FETCH_OBJ) as $right) { $userDisplay = Phprojekt_User_User::applyDisplay($display, $right); $roles['data'][$right->roleId]['users'][] = array('id' => (int) $right->userId, 'display' => $userDisplay); } return $roles; }