Beispiel #1
0
 /**
  * Calls the VoodooPrivileges to see if you have rights on given environment
  * 
  * @see VoodooPrivileges
  * @param string $access // The users current accesslevel 
  * @param string $action // admin,wiki,etc
  * @param string $type // view,modify,create,delete
  * @param string $subject
  */
 function hasRights($access, $action, $type, $subject = '')
 {
     $privs = $this->conf['privileges'];
     return $this->privs->hasRights($access, $type, $action, $privs, $subject);
 }
 /**
  * @param array $actionlist
  * @return array(title,content)
  */
 function dispatch($actionlist)
 {
     // Less than two params is NOT a valid attachment handler
     // Example of valids:
     //  * /attachment/Wiki/WikiAttachmentExample
     //  * /attachment/Wiki/WikiAttachmentExample/test.jpg
     if (count($actionlist) < 2) {
         return array('Attachment Error', VoodooError::displayError('Incorrect SubController Actionlist'));
     }
     // We default to not having an attachment set
     $attachment = false;
     if (count($actionlist) == 3) {
         // The third action from the actionlist is the attachment
         list($controller, $action, $attachment) = $actionlist;
     } else {
         list($controller, $action) = $actionlist;
     }
     $this->cont = $controller;
     $this->action = $action;
     $lookup = $controller . ($attachment ? '.' . $attachment : '');
     // We need at least view rights to continue
     if (!$this->privs->hasRights($_SESSION['access'], 'view', 'attachment', $this->conf['privileges'], $lookup)) {
         return array('Attachment Error', VoodooError::displayError('Permission Denied'));
     }
     require_once ATTACHMENT_CLASSES . 'Attachment.php';
     $class = 'AttachmentLink';
     // The controller is enabled.
     $uc = strtoupper($controller);
     // Lets see if the linked object has its own linked attachment object
     if (defined($uc . '_CLASSES')) {
         $conf = VoodooIni::load($controller);
         if (!isset($conf['attachment']) || !$conf['attachment']['attachment']) {
             return array('Attachment Error', VoodooError::displayError('This Controller Doesnt Support Attachments'));
         }
         if (isset($conf['attachment']['class'])) {
             if (!is_file(constant($uc . '_CLASSES') . $conf['attachment']['class'])) {
                 return array('Attachment Error', VoodooError::displayError('This Controller Attachment Class doesnt exist.'));
             }
             require_once constant($uc . '_CLASSES') . $conf['attachment']['class'];
             $class = ucfirst($controller) . 'Attachment';
         }
     }
     // Lets init a new link object
     $al = new $class($this->controller->DBConnect(), $uc);
     if (isset($_REQUEST['action'])) {
         switch ($_REQUEST['action']) {
             case 'download':
                 $ad = new AttachmentDownload($this, $attachment, $al);
                 return $ad->execute();
                 break;
             case 'create':
                 $ac = new AttachmentCreate($this, $attachment, $al);
                 return $ac->execute();
                 break;
             case 'delete':
                 $ad = new AttachmentDelete($this, $attachment, $al);
                 return $ad->execute();
                 break;
             case 'modify':
                 break;
         }
     }
     // Display the attachment information, dont auto download
     $av = new AttachmentView($this, $attachment, $al);
     return $av->execute();
 }
Beispiel #3
0
 /**
  * Gets the menu listed in the conf file
  * TODO: create nested menu's and mkpretty
  */
 function getMenu($conf, $privs)
 {
     $p = new VoodooPrivileges($this);
     $rv = array();
     foreach ($conf as $menu => $title) {
         if (!isset($privs['menu.' . $menu]) || !empty($_SESSION) && $p->hasRights($_SESSION['access'], $menu, 'menu', $privs)) {
             $rv[] = array('link' => $menu, 'title' => $title, 'class' => '');
         }
     }
     return $rv;
 }
Beispiel #4
0
 /**
  * @see VoodooPrivileges::hasRights()
  * @param int $access
  * @param string $type
  * @param string $page
  */
 function hasRights($access, $type, $page = '')
 {
     return $this->privs->hasRights($access, $type, 'wiki', $this->dispatcher->conf['privileges'], $page);
 }