Esempio n. 1
0
 public function testInit()
 {
     $this->assertEquals(0, User::objects()->count());
     $this->assertEquals(0, Group::objects()->count());
     $this->assertEquals(0, Permission::objects()->count());
     $this->assertEquals(0, UserPermission::objects()->count());
     $this->assertEquals(0, GroupPermission::objects()->count());
     $this->assertEquals(0, Key::objects()->count());
     $this->assertEquals(0, Session::objects()->count());
 }
Esempio n. 2
0
 /**
  * Получение данных по правам доступа, по правам групп и по пользователей.
  */
 public function getInitialData()
 {
     $dbPermissions = Permission::objects()->asArray()->all();
     $permissionsCount = count($dbPermissions);
     for ($i = 0; $i < $permissionsCount; $i++) {
         $this->_permissions[$dbPermissions[$i]['code']] = array('bizrule' => $dbPermissions[$i]['bizrule'], 'name' => $dbPermissions[$i]['name'], 'id' => $dbPermissions[$i]['id'], 'is_global' => $dbPermissions[$i]['is_global']);
     }
     $userPerms = UserPermission::objects()->filter(['permission__code__isnull' => false])->all();
     foreach ($userPerms as $perm) {
         $code = $perm->permission->code;
         $this->_userPerms[$code][] = $perm->user_id;
     }
     $groupPerms = GroupPermission::objects()->filter(['permission__code__isnull' => false])->all();
     foreach ($groupPerms as $perm) {
         $code = $perm->permission->code;
         $this->_groupPerms[$code][] = $perm->group_id;
     }
 }