Since: 3.0.0
Author: Jack P.
Inheritance: extends Avalon\Database\Model
コード例 #1
0
ファイル: custom_tabs.php プロジェクト: dasklney/traq
 /**
  * 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'));
 }
コード例 #2
0
ファイル: permissions.php プロジェクト: dasklney/traq
 /**
  * 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());
 }
コード例 #3
0
ファイル: Seeder.php プロジェクト: nirix/traq
 /**
  * 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();
     }
 }
コード例 #4
0
ファイル: models.php プロジェクト: nirix/traq
function createGroup()
{
    $group = new Group(['name' => 'group-' . mkRandomHash(5) . '-name']);
    $group->save();
    return $group;
}