/**
  * Setup notification fields and pass various dependencies to the View.
  */
 public function render()
 {
     $gateway = new NotificationGateway($this->component->getDb());
     $select = $gateway->selectByComponent($this->component->getFullyQualifiedName());
     $fields = $gateway->buildFields($this->component->url('notification-edit'), $this->component->getFields());
     $this->view->assign(['fields' => $fields, 'listing' => new Listing($select, $gateway->field('dewdrop_notification_subscription_id')), 'component' => $this->component, 'componentModel' => $this->component->getPrimaryModel()]);
     return $this->renderView();
 }
Exemple #2
0
 /**
  * Check to see if the given permission is granted to the current user (or
  * anonymous users, if no user resource is available in Pimple.  You can optionally
  * choose to just throw an exception to halt execution when the user doesn't
  * have the requested permission.  This can be convenient when the user
  * can only reach the point where this permission is checked by circumventing
  * the normal navigation provided in the UI (e.g. by manipulating the URL).
  *
  * @throws Exception
  * @param string $name
  * @param boolean $throwExceptionOnFail
  * @return boolean
  */
 public function can($name, $throwExceptionOnFail = false)
 {
     if (!array_key_exists($name, $this->registeredPermissions)) {
         throw new Exception("Could not find permission with name '{$name}'");
     }
     $can = $this->settings[$name];
     if (is_array($can)) {
         $allowedRoles = $can;
         $can = false;
         $user = null;
         if ($this->component->hasPimpleResource('user')) {
             $user = $this->component->getPimpleResource('user');
         }
         foreach ($allowedRoles as $role) {
             if ($user && in_array($role, $this->getUserRoleValues($user))) {
                 $can = true;
                 break;
             }
         }
     }
     if (!$can && $throwExceptionOnFail) {
         throw new Exception("Permission denied: {$this->component->getFullyQualifiedName()}/{$name}.");
     }
     return $can;
 }
Exemple #3
0
 public function getUploadPath()
 {
     if (!$this->uploadPath) {
         /* @var $paths \Dewdrop\Paths */
         $paths = Pimple::getResource('paths');
         $root = $paths->getAppRoot();
         $this->uploadPath = $root . '/private-uploads/dewdrop-import/' . str_replace('/', '__', $this->component->getFullyQualifiedName());
     }
     return $this->uploadPath;
 }