예제 #1
0
 protected function hasPermission($permission, Model $requester)
 {
     // find permission verified in find()
     if ($permission == 'find' && $requester->isLoggedIn()) {
         return true;
     }
     // create permission verified in preCreateHook()
     if ($permission == 'create' && $requester->isLoggedIn()) {
         return true;
     }
     $orgModel = $this->relation('organization');
     if (in_array($permission, ['view', 'edit', 'delete']) && $orgModel && $orgModel->getRoleOfUser($requester) == Volunteer::ROLE_ADMIN) {
         return true;
     }
     return $requester->isAdmin();
 }
 protected function hasPermission($permission, Model $requester)
 {
     if ($permission == 'create') {
         return $requester->isLoggedIn();
     }
     if ($requester->id() == $this->uid) {
         return true;
     }
     return $requester->isAdmin();
 }
예제 #3
0
 protected function hasPermission($permission, Model $requester)
 {
     // find permission verified in find()
     if ($permission == 'find' && $requester->isLoggedIn()) {
         return true;
     }
     // create permission verified in preCreateHook()
     if ($permission == 'create' && $requester->isLoggedIn()) {
         return true;
     }
     // allow user's to edit their own hours (for the purpose of changing balance)
     if ($permission == 'edit' && $requester->id() == $this->relation('uid')->id()) {
         return true;
     }
     $orgModel = $this->relation('organization');
     if (in_array($permission, ['view', 'edit', 'delete']) && $orgModel && $orgModel->getRoleOfUser($requester) == Volunteer::ROLE_ADMIN) {
         return true;
     }
     return $requester->isAdmin();
 }
예제 #4
0
 protected function hasPermission($permission, Model $requester)
 {
     // find permission verified in find()
     if ($permission == 'find' && $requester->isLoggedIn()) {
         return true;
     }
     // create permission verified in preCreateHook()
     if ($permission == 'create' && $requester->isLoggedIn()) {
         return true;
     }
     // users can edit their own volunteer model
     if ($permission == 'edit' && $this->uid == $this->app['user']->id()) {
         return true;
     }
     $orgModel = $this->relation('organization');
     if (in_array($permission, ['view', 'edit', 'delete']) && is_object($orgModel) && $orgModel->getRoleOfUser($requester) == self::ROLE_ADMIN) {
         return true;
     }
     return $requester->isAdmin();
 }