/** * Fetches all the data for the permission listing page. */ private function permissions_for($type) { // Fetch groups, set permissions and actions arrays if ($type == 'usergroup') { $groups = Group::select()->where('is_admin', 1, '!=')->exec()->fetch_all(); $groups = array_merge(array(new Group(array('id' => 0, 'name' => l('defaults')))), $groups); } elseif ($type == 'role') { $groups = ProjectRole::select()->custom_sql("WHERE project_id = 0 OR project_id = {$this->project->id}")->exec()->fetch_all(); $groups = array_merge(array(new ProjectRole(array('id' => 0, 'name' => l('defaults'), 'project_id' => 0))), $groups); } $permissions = array(); // Loop over the groups foreach ($groups as $group) { // Set the group array in the permissions array if (!isset($permissions[$group->id])) { $permissions[$group->id] = array(); } // Loop over the permissions for the group foreach (Permission::get_permissions($this->project->id, $group->id, $type) as $action => $perm) { // Add the permission object to the permissions array $permissions[$group->id][$action] = $perm; } } // Send it all the to view. View::set('groups', $groups); View::set('permissions', $permissions); View::set('actions', permission_actions()); }
protected function getAllRows() { return ProjectRole::select('project_role.*', 'project.name AS project_name')->leftJoin('project_role', PREFIX . 'projects', 'project', 'project.id = project_role.project_id')->execute()->fetchAll(); }