public function processAddAttachmentsAction()
 {
     $fileData = file_get_contents($_FILES["uploadFile"]["tmp_name"]);
     $attachment = new Attachment();
     $attachment->name = $_FILES['uploadFile']['name'];
     $attachment->attachmentReferenceId = preg_replace('[^a-zA-Z0-9-]', '//', $this->_getParam('attachmentReferenceId'));
     $attachment->mimeType = $_FILES['uploadFile']['type'];
     $attachment->md5sum = md5($fileData);
     $attachment->dateTime = date('Y-m-d H:i:s');
     $attachment->persist();
     $attachmentBlobArray = array();
     $attachmentBlobArray['attachmentId'] = $attachment->attachmentId;
     $attachmentBlobArray['data'] = $fileData;
     $db = Zend_Registry::get('dbAdapter');
     $db->insert('attachmentBlobs', $attachmentBlobArray);
     $acj = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $acj->suppressExit = true;
     $jsonData = $acj->direct(array("attachmentId" => $attachment->attachmentId), false);
     $this->getResponse()->setHeader('Content-Type', 'text/html');
     $this->view->result = $jsonData;
     $this->render();
 }
Exemplo n.º 2
0
 public function processAttachToNotesAction()
 {
     $attachmentId = (int) $this->_getParam('attachmentId');
     $attachmentReferenceId = $this->_getParam('attachmentReferenceId');
     $attachment = new Attachment();
     $attachment->attachmentId = $attachmentId;
     $attachment->populate();
     $attachment->attachmentReferenceId = $attachmentReferenceId;
     $attachment->persist();
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(true);
 }
 function flashUploadAction()
 {
     $attachmentReferenceId = (int) $this->_getParam('attachmentReferenceId');
     $fileData = base64_decode($this->_getParam('fileUpload'));
     $attachment = new Attachment();
     if (!isset($_FILES['uploadFile']['name'])) {
         $attachment->name = date('Y-m-d');
     } else {
         $attachment->name = $_FILES['uploadFile']['name'];
     }
     $attachment->attachmentReferenceId = $attachmentReferenceId;
     $attachment->mimeType = 'image/jpeg';
     $attachment->md5sum = md5($fileData);
     $attachment->dateTime = date('Y-m-d H:i:s');
     $attachment->persist();
     $attachmentBlobArray = array();
     $attachmentBlobArray['attachmentId'] = $attachment->attachmentId;
     $attachmentBlobArray['data'] = $fileData;
     $db = Zend_Registry::get('dbAdapter');
     $db->insert('attachmentBlobs', $attachmentBlobArray);
     $person = new Person();
     $person->personId = $attachmentReferenceId;
     $person->populate();
     $person->activePhoto = (int) $attachment->attachmentId;
     $person->persist();
     Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender();
     return;
 }