Since: 3.0.0
Author: Jack P.
Inheritance: extends Avalon\Database\Model
Exemplo n.º 1
0
 /**
  * New tab.
  */
 public function action_new()
 {
     $tab = new CustomTab();
     // Check if the form has been submitted.
     if (Request::method() == 'post') {
         $tab->set(array('label' => Request::post('label'), 'url' => Request::post('url'), 'groups' => implode(',', Request::post('groups', \traq\models\Group::all_group_ids())), 'display_order' => Request::post('display_order', 0), 'project_id' => Request::post('project_id', 0)));
         // Save and reidrect
         if ($tab->save()) {
             Request::redirectTo('/admin/custom_tabs');
         }
     }
     View::set(compact('tab'));
 }
Exemplo n.º 2
0
 /**
  * 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());
 }
Exemplo n.º 3
0
 /**
  * Insert user groups.
  */
 public function insertGroups()
 {
     $groups = ['Admin' => true, 'Members' => false, 'Guests' => false];
     foreach ($groups as $name => $isAdmin) {
         $model = new Group(['name' => $name, 'is_admin' => $isAdmin]);
         $model->save();
     }
 }
Exemplo n.º 4
0
function createGroup()
{
    $group = new Group(['name' => 'group-' . mkRandomHash(5) . '-name']);
    $group->save();
    return $group;
}