Ejemplo n.º 1
0
 /**
  * Returns a Horde_Vfs instance.
  *
  * @return Horde_Vfs_Base  A VFS instance.
  */
 protected function _getVfs()
 {
     global $conf, $injector;
     if (!isset($conf['vfs']['type'])) {
         throw new Whups_Exception(_("The VFS backend needs to be configured to enable attachment or message uploads."), 'horde.error');
     }
     try {
         return $injector->getInstance('Horde_Core_Factory_Vfs')->create();
     } catch (Horde_Vfs_Exception $e) {
         throw Whups_Exception($e);
     }
 }
Ejemplo n.º 2
0
 /**
  * Adds a new version to a queue.
  *
  * @param integer $queueId     A queue ID.
  * @param string $name         A version name.
  * @param string $description  A version description.
  * @param boolean $active      Whether the version is active.
  *
  * @return integer  The new version ID.
  * @throws Whups_Exception
  */
 public function addVersion($queueId, $name, $description, $active)
 {
     try {
         return $this->_db->insert('INSERT INTO whups_versions (queue_id, version_name, ' . 'version_description, version_active) ' . 'VALUES (?, ?, ?, ?)', array((int) $queueId, $this->_toBackend($name), $this->_toBackend($description), (bool) $active));
     } catch (Horde_Db_Exception $e) {
         throw Whups_Exception($e);
     }
 }
Ejemplo n.º 3
0
 /**
  * Removes an attachment from this ticket.
  *
  * @param string $attachment_name  The name of the attachment.
  *
  * @throws Whups_Exception
  */
 public function deleteAttachment($attachment_name)
 {
     if (!isset($GLOBALS['conf']['vfs']['type'])) {
         throw new Whups_Exception(_("The VFS backend needs to be configured to enable attachment uploads."), 'horde.error');
     }
     try {
         $vfs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Vfs')->create();
     } catch (Horde_Vfs_Exception $e) {
         throw Whups_Exception($e);
     }
     $dir = Whups::VFS_ATTACH_PATH . '/' . $this->_id;
     if (!$vfs->exists($dir, $attachment_name)) {
         throw new Whups_Exception(sprintf(_("Attachment %s not found."), $attachment_name), 'horde.error');
     }
     try {
         $vfs->deleteFile($dir, $attachment_name);
     } catch (Horde_Vfs_Exception $e) {
         throw new Whups_Exception($e);
     }
 }