/** * Sets header to the mime type of the attachment as queried from the * database and tries to send the file contents to the client. * To identify the attachment, the action needs the parameters "key" * and "id" as found in the data model of the attachments. * */ public function downloadAttachmentAction() { $attachmentId = $this->_request->getParam('id'); $attachmentKey = $this->_request->getParam('key'); $userId = $this->_helper->registryAccess->getUserId(); $downloadCookieName = $this->_request->getParam('downloadCookieName'); /** * @see Conjoon_Modules_Groupware_Email_Attachment_Facade */ require_once 'Conjoon/Modules/Groupware/Email/Attachment/Facade.php'; $facade = Conjoon_Modules_Groupware_Email_Attachment_Facade::getInstance(); $data = $facade->getAttachmentDownloadDataForUserId($attachmentKey, $attachmentId, $userId); if (!$data) { /** * @see Conjoon_Exception */ require_once 'Conjoon/Exception.php'; // we'll throw an exception, that's okay for now throw new Conjoon_Exception("Sorry, but the requested attachment is not available."); return; } $this->_helper->viewRenderer->setNoRender(); $response = $this->getResponse(); $response->clearAllHeaders(); setcookie($downloadCookieName, 'downloading', 0, '/'); $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true)->setHeader('Pragma', 'no-cache', true)->setHeader('Content-Description', $data['fileName'], true)->setHeader('Content-Type', $data['mimeType'], true)->setHeader('Content-Transfer-Encoding', 'binary', true)->setHeader('Content-Disposition', 'attachment; filename="' . addslashes($data['fileName']) . '"', true); $response->sendHeaders(); $response->setBody($data['content']); }
public static function getInstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
/** * Constructor. * Private to enforce singleton behavior. * * */ private function __construct() { $context = Conjoon_Filter_Input::CONTEXT_CREATE; $this->_filterAttachment = new Conjoon_Modules_Groupware_Email_Attachment_Filter_Attachment(array(), $context); $this->_filterFlag = new Conjoon_Modules_Groupware_Email_Item_Filter_Flag(array(), $context); $this->_filterItem = new Conjoon_Modules_Groupware_Email_Item_Filter_Item(array(), $context); $this->_filterInbox = new Conjoon_Modules_Groupware_Email_Item_Filter_Inbox(array(), $context); $this->_modelAttachment = new Conjoon_Modules_Groupware_Email_Attachment_Model_Attachment(); $this->_modelFlag = new Conjoon_Modules_Groupware_Email_Item_Model_Flag(); $this->_modelItem = new Conjoon_Modules_Groupware_Email_Item_Model_Item(); $this->_modelInbox = new Conjoon_Modules_Groupware_Email_Item_Model_Inbox(); $this->_modelFolder = new Conjoon_Modules_Groupware_Email_Folder_Model_Folder(); $this->_attachmentFacade = Conjoon_Modules_Groupware_Email_Attachment_Facade::getInstance(); }