예제 #1
0
 /**
  * Whether the page can be viewed.
  *
  * @param Person $person
  * @param Page   $page
  *
  * @return bool
  */
 public function view(Person $person, Page $page)
 {
     if (!$page->aclEnabled()) {
         return true;
     }
     if ($page->wasCreatedBy($person) || $this->managesPages()) {
         return true;
     }
     $aclGroupIds = $page->getAclGroupIds();
     if (empty($aclGroupIds)) {
         return true;
     }
     $groups = $person->getGroups();
     foreach ($groups as $group) {
         if (in_array($group->getId(), $aclGroupIds)) {
             return true;
         }
     }
     return false;
 }
예제 #2
0
 /**
  * Returns whether or not the logged in user can edit the content of a page.
  * 
  * A page can be edited if it was created by a user or they have edit permissions for the page.
  * 
  * @param Page $page
  *
  * @return bool
  */
 public function isEditable(Page $page)
 {
     return $page->wasCreatedBy($this->auth->getPerson()) || $this->auth->loggedIn('edit_page_content', $page);
 }
예제 #3
0
 /**
  * Determines whether the current user can delete a given page.
  *
  * @param Page $page
  *
  * @return bool
  */
 public function canDelete(Page $page)
 {
     return $page->wasCreatedBy($this->getPerson()) || $this->loggedIn('delete_page', $page) || $this->loggedIn('manage_pages');
 }
예제 #4
0
 public function __construct(Request $request)
 {
     $this->request = $request;
     $this->page = $this->request->route()->getParameter('page');
     $this->page->wasCreatedBy(Auth::getPerson()) || parent::authorization('edit_page_content', $this->page);
 }