/** * @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(); }