/** * * @param IXP_Form_Meeting_Item $form * @param \Entities\MeetingItem $object * @param bool $isEdit */ protected function addPreFlush($form, $object, $isEdit) { $object->setUpdatedBy($this->getUser()->getId()); $object->setUpdatedAt(new DateTime()); if (!$isEdit) { $object->setCreatedBy($this->getUser()->getId()); $object->setCreatedAt(new DateTime()); } // is there a file upload? if ($form->getValue('presentation') != '') { // lets make more memory available for large files ini_set('memory_limit', '512M'); $this->getLogger()->debug('Received upload of file: ' . $form->getValue('presentation')); // Zend sticks the original filename in the form variable $object->setFilename($form->getValue('presentation')); // make sure meetings exists if (!is_dir(self::getMeetingsDirectory()) && !@mkdir(self::getMeetingsDirectory())) { $this->getLogger()->crit('Could not create presentations directory.'); throw new IXP_Exception('Presentations directory does not exist and could not be created.'); } // now, create a directory for this meeting if it does not already exists $meeting_dir = self::getMeetingsDirectory() . DIRECTORY_SEPARATOR . $object->getMeeting()->getId(); if (!is_dir($meeting_dir) && !@mkdir($meeting_dir)) { $this->getLogger()->crit('Could not create meeting directory.'); throw new IXP_Exception('Meeting directory does not exist and could not be created.'); } // get the extension for this presentation if (strrpos($object->getFilename(), '.') === false) { $exten = ''; } else { $exten = substr($object->getFilename(), strrpos($object->getFilename(), '.')); } // we need the row ID so we'll do a save if (!$isEdit) { $this->getD2EM()->persist($object); } $this->getD2EM()->flush(); $object->setPresentation($object->getId() . $exten); $this->getLogger()->debug('Uploaded file will be saved as: ' . $object->getPresentation()); // delete an existing file in case we're updating $ePres = $meeting_dir . DIRECTORY_SEPARATOR . $object->getPresentation(); if (@file_exists($ePres)) { $this->getLogger()->debug('Pre-existing file exists so deleting'); @unlink($ePres); } @rename($form->getElement('presentation')->getFilename(), $ePres); } return true; }
public function getFilename() { $this->__load(); return parent::getFilename(); }