/**
  * Adds a page.
  *
  * @param Page $page the page
  * @throws Exception if a page with the same ID already exists
  */
 public function addPage(Page $page)
 {
     if (isset($this->pages[$page->getID()])) {
         throw new Exception("Page {$page->getID()} already exists");
     }
     $this->pages[$page->getID()]['id'] = $page->getID();
     $this->pages[$page->getID()]['title'] = $page->getTitle();
     $this->pages[$page->getID()]['module'] = $page->getModule();
     $this->pages[$page->getID()]['defaultTask'] = $page->getDefaultTask();
     $this->pages[$page->getID()]['defaultParameter'] = $page->getDefaultParameter();
     $this->pages[$page->getID()]['defaultFormat'] = $page->getDefaultFormat();
     $this->pages[$page->getID()]['template'] = $page->getTemplate();
     $this->pages[$page->getID()]['needsHTTPS'] = $page->needsHTTPS();
     $gid = $page->getGID();
     if ($gid === null) {
         $gid = $this->gid->encode($this->gid->getType('page'), $page->getID());
     }
     $this->pages[$page->getID()]['gid'] = $gid;
     $this->store();
 }
Beispiel #2
0
 /**
  * Authorizes a user.
  *
  * This function requires the page and the task ID to be set.
  *
  * @param User $user the user to authorize
  * @throws LogicException if page or task ID have not been set
  * @throws InvalidConfigurationValueException
  */
 protected function authorize($user)
 {
     if ($this->page === null || $this->taskID === null) {
         throw new LogicException('Cannot call ' . __METHOD__ . ' before setting app ID');
     }
     $authorization = $this->getAuthorization();
     $authSubjectFlavor = $this->getConfigurationManager()->getFlavorsConfiguration()->authorizationSubject;
     $reflection = new ReflectionClass($user);
     try {
         $method = $reflection->getMethod('get' . ucfirst($authSubjectFlavor));
         $authSubject = $method->invoke($user);
     } catch (ReflectionException $e) {
         throw new InvalidConfigurationValueException("Invalid authorization subject {$authSubjectFlavor}");
     }
     if (empty($authSubject)) {
         $authSubject = null;
     }
     return $authorization->authorize($authSubject, $this->page->getID(), $this->taskID);
 }