Exemple #1
0
 public function registerMarkupTags()
 {
     return ['functions' => ['can' => function ($can) {
         return UserGroup::can($can);
     }, 'hasRole' => function ($can) {
         return UserGroup::hasRole($can);
     }]];
 }
Exemple #2
0
 public function index_onDelete()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $roleId) {
             if (!($role = UserGroup::find($roleId))) {
                 continue;
             }
             $role->delete();
         }
         Flash::success('The role has been deleted successfully.');
     }
     return $this->listRefresh();
 }
Exemple #3
0
 public function onRun()
 {
     $userPermision = $this->property('permission');
     if ($userPermision) {
         if (!UserGroup::can($userPermision)) {
             return;
         }
     }
     $person = user::find(intval($this->property('SLSlug')));
     if ($person) {
         $filename = $person->surname . '_' . $person->name . '.vcf';
         return response($this->renderPartial('@vcard', ['person' => $person]))->header('Content-Type', 'text/directory')->header('Content-Disposition', 'attachment; filename=' . $filename)->header('Pragma', 'public');
     }
 }
Exemple #4
0
 public static function can($permissions)
 {
     $account = new Account();
     $permissions = !is_array($permissions) ? [$permissions] : $permissions;
     if (Auth::check()) {
         $roles = json_decode(User::find($account->user()->id)->groups);
         foreach ($roles as $role) {
             foreach (UserGroup::find($role->id)->perms as $perm) {
                 if (in_array($perm->name, $permissions)) {
                     return true;
                 }
             }
         }
     }
 }
Exemple #5
0
 public function getPrimaryUsergroupOptions()
 {
     return UserGroup::lists('name', 'id');
 }
Exemple #6
0
 public function getPrimaryUsergroups()
 {
     $this->userGroups = UserGroup::lists('name', 'id');
     $this->page['userGroups'] = $this->userGroups;
 }