getVFS() public method

Returns a {@link VFS} instance.
public getVFS ( ) : VFS
return VFS A VFS instance.
コード例 #1
0
ファイル: Driver.php プロジェクト: horde/horde
 /**
  * Saves the message.
  *
  * @param array $info  Array containing all the message data to save.
  *
  * @return mixed  Message ID on success or PEAR_Error on failure.
  * @throws Agora_Exception
  */
 public function saveMessage($info)
 {
     /* Check if the thread is locked before changing anything. */
     if ($info['message_parent_id'] && $this->isThreadLocked($info['message_parent_id'])) {
         return PEAR::raiseError(_("This thread has been locked."));
     }
     /* Check post permissions. */
     if (!$this->hasPermission(Horde_Perms::EDIT)) {
         return PEAR::raiseError(sprintf(_("You don't have permission to post messages in forum %s."), $this->_forum_id));
     }
     if (empty($info['message_id'])) {
         /* Get thread parents */
         // TODO message_thread is always parent root, probably can use it here.
         if ($info['message_parent_id'] > 0) {
             $parents = $this->_db->selectValue('SELECT parents FROM ' . $this->_threads_table . ' WHERE message_id = ?', array($info['message_parent_id']));
             $info['parents'] = $parents . ':' . $info['message_parent_id'];
             $info['message_thread'] = $this->getThreadRoot($info['message_parent_id']);
         } else {
             $info['parents'] = '';
             $info['message_thread'] = 0;
         }
         /* Create new message */
         $sql = 'INSERT INTO ' . $this->_threads_table . ' (forum_id, message_thread, parents, ' . 'message_author, message_subject, body, attachments, ' . 'message_timestamp, message_modifystamp, ip) ' . ' VALUES (?, ?, ?, ?, ?, ?, 0, ?, ?, ?)';
         $author = $GLOBALS['registry']->getAuth() ? $GLOBALS['registry']->getAuth() : $info['posted_by'];
         $values = array($this->_forum_id, $info['message_thread'], $info['parents'], $author, $this->convertToDriver($info['message_subject']), $this->convertToDriver($info['message_body']), $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], $_SERVER['REMOTE_ADDR']);
         try {
             $info['message_id'] = $this->_db->insert($sql, $values);
         } catch (Horde_Db_Exception $e) {
             throw new Agora_Exception($e->getMessage());
         }
         /* Update last message in forum, but only if it is not moderated */
         if (!$this->_forum['forum_moderated']) {
             // Send the new post to the distribution address
             if ($this->_forum['forum_distribution_address']) {
                 Agora::distribute($info['message_id']);
             }
             /* Update cached message/thread counts and last poster */
             $this->_lastInForum($this->_forum_id, $info['message_id'], $author, $_SERVER['REQUEST_TIME']);
             $this->_forumSequence($this->_forum_id, 'message', '+');
             if ($info['message_thread']) {
                 $this->_sequence($info['message_thread'], '+');
                 $this->_lastInThread($info['message_thread'], $info['message_id'], $author, $_SERVER['REQUEST_TIME']);
             } else {
                 $this->_forumSequence($this->_forum_id, 'thread', '+');
             }
         }
     } else {
         // TODO clearing cache for editing doesn't work
         /* Update message data */
         $sql = 'UPDATE ' . $this->_threads_table . ' SET ' . 'message_subject = ?, body = ?, message_modifystamp = ? WHERE message_id = ?';
         $values = array($this->convertToDriver($info['message_subject']), $this->convertToDriver($info['message_body']), $_SERVER['REQUEST_TIME'], $info['message_id']);
         try {
             $this->_db->execute($sql, $values);
         } catch (Horde_Db_Exception $e) {
             throw new Agora_Exception($e->getMessage());
         }
         /* Get message thread for cache expiration */
         $info['message_thread'] = $this->getThreadRoot($info['message_id']);
     }
     /* Handle attachment saves or deletions. */
     if (!empty($info['message_attachment']) || !empty($info['attachment_delete'])) {
         $vfs = Agora::getVFS();
         if ($vfs instanceof PEAR_Error) {
             return $vfs;
         }
         $vfs_dir = Agora::VFS_PATH . $this->_forum_id . '/' . $info['message_id'];
         /* Check if delete requested or new attachment loaded, and delete
          * any existing one. */
         if (!empty($info['attachment_delete'])) {
             $sql = 'SELECT file_id FROM agore_files WHERE message_id = ?';
             foreach ($this->_db->selectValues($sql, array($info['message_id'])) as $file_id) {
                 if ($vfs->exists($vfs_dir, $file_id)) {
                     $delete = $vfs->deleteFile($vfs_dir, $file_id);
                     if ($delete instanceof PEAR_Error) {
                         return $delete;
                     }
                 }
             }
             try {
                 $this->_db->execute('DELETE FROM agore_files WHERE message_id = ?', array($info['message_id']));
             } catch (Horde_Db_Exception $e) {
                 throw new Agora_Exception($e->getMessage());
             }
             $attachments = 0;
         }
         /* Save new attachment information. */
         if (!empty($info['message_attachment'])) {
             $file_sql = 'INSERT INTO agora_files (file_name, file_type, file_size, message_id) VALUES (?, ?, ?, ?)';
             $file_data = array($info['message_attachment']['name'], $info['message_attachment']['type'], $info['message_attachment']['size'], $info['message_id']);
             try {
                 $file_id = $this->_db->insert($file_sql, $file_data);
             } catch (Horde_Db_Exception $e) {
                 throw new Agora_Exception($e->getMessage());
             }
             $result = $vfs->write($vfs_dir, $file_id, $info['message_attachment']['file'], true);
             if ($result instanceof PEAR_Error) {
                 return $result;
             }
             $attachments = 1;
         }
         $sql = 'UPDATE ' . $this->_threads_table . ' SET attachments = ? WHERE message_id = ?';
         try {
             $this->_db->execute($sql, array($attachments, $info['message_id']));
         } catch (Horde_Db_Exception $e) {
             throw new Agora_Exception($e->getMessage());
         }
     }
     /* Update cache */
     $this->_updateCacheState($info['message_thread']);
     return $info['message_id'];
 }
コード例 #2
0
ファイル: prefs.php プロジェクト: raz0rsdge/horde
 */
$prefGroups['display_avatar'] = array('column' => _("My Information"), 'label' => _("Avatar"), 'desc' => _("Set the avatar image that is shown with your posts."), 'members' => array('avatar_path', 'avatar_link'), 'suppress' => function () {
    return !empty($GLOBALS['conf']['avatar']['allow_avatars']);
});
$prefGroups['display_forums'] = array('column' => _("Display Preferences"), 'label' => _("Forums View"), 'desc' => _("Set your preferences for the forums view."), 'members' => array('forums_sortby', 'forums_sortdir', 'forums_per_page'));
$prefGroups['display_threads'] = array('column' => _("Display Preferences"), 'label' => _("Threads View"), 'desc' => _("Set your preferences for the threads view."), 'members' => array('threads_sortby', 'threads_sortdir', 'threads_hot', 'threads_per_page'));
$prefGroups['display_thread'] = array('column' => _("Display Preferences"), 'label' => _("Single Thread View"), 'desc' => _("Set your preferences for the single thread view."), 'members' => array('thread_sortby', 'thread_sortdir', 'thread_view_bodies', 'thread_per_page'));
$prefGroups['display_message'] = array('column' => _("Display Preferences"), 'label' => _("Message View"), 'desc' => _("Set your preferences for the message view."), 'members' => array('message_emoticons'));
$prefGroups['display_comments'] = array('column' => _("Display Preferences"), 'label' => _("Comments view"), 'desc' => _("Set your preferences for the single thread view."), 'members' => array('comments_sortby', 'comments_sortdir', 'comments_view_bodies', 'comments_per_page'));
/* Avatar */
$_prefs['avatar_path'] = array('value' => '', 'type' => 'text', 'desc' => _("The location of your avatar image."));
if ($GLOBALS['conf']['avatar']['allow_avatars'] && $GLOBALS['conf']['avatar']['enable_image_tests']) {
    $_prefs['avatar_path']['desc'] .= ' ' . sprintf(_("Avatars must be smaller than %s by %s pixels and less than %sKb in size."), $GLOBALS['conf']['avatar']['max_width'], $GLOBALS['conf']['avatar']['max_height'], $GLOBALS['conf']['avatar']['max_size']);
}
$_prefs['avatar_link'] = array('type' => 'rawhtml', 'suppress' => function () {
    $vfs = Agora::getVFS();
    return $vfs instanceof PEAR_Error || !$GLOBALS['conf']['avatar']['enable_gallery'] || !$vfs->isFolder(Agora::AVATAR_PATH, 'gallery');
});
/* Forums */
$_prefs['forums_sortby'] = array('value' => 'forum_name', 'type' => 'enum', 'enum' => array('forum_name' => _("Forum"), 'message_count' => _("Messages"), 'message_subject' => _("Last Message"), 'message_author' => _("Posted by"), 'message_date' => _("Date")), 'desc' => _("Default forums view sort:"));
$_prefs['forums_sortdir'] = array('value' => 0, 'type' => 'enum', 'enum' => array(0 => _("Ascending"), 1 => _("Descending")), 'desc' => _("Default sorting direction:"));
$_prefs['forums_per_page'] = array('value' => 20, 'type' => 'enum', 'enum' => array(5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25), 'desc' => _("Number of forums to display on each page"));
/* Threads */
$_prefs['threads_sortby'] = array('value' => 'message_modifystamp', 'type' => 'enum', 'enum' => array('message_thread' => _("Thread"), 'message_subject' => _("Subject"), 'message_author' => _("Posted by"), 'message_seq' => _("Posts"), 'message_timestamp' => _("Date"), 'message_modifystamp' => _("Last post")), 'desc' => _("Default threads view sort:"));
$_prefs['threads_sortdir'] = array('value' => 1, 'type' => 'enum', 'enum' => array(0 => _("Ascending"), 1 => _("Descending")), 'desc' => _("Default sorting direction:"));
$_prefs['threads_hot'] = array('value' => 20, 'type' => 'number', 'desc' => _("Number of views in 24hrs to trigger a 'hot-thread':"));
$_prefs['threads_per_page'] = array('value' => 10, 'type' => 'enum', 'enum' => array(5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25), 'desc' => _("Number of messages to display on each page"));
/* Thread */
$_prefs['thread_sortby'] = array('value' => 'message_timestamp', 'type' => 'enum', 'enum' => array('message_thread' => _("Thread"), 'message_subject' => _("Subject"), 'message_author' => _("Posted by"), 'message_timestamp' => _("Date")), 'desc' => _("Default thread view sort:"));
$_prefs['thread_sortdir'] = array('value' => 0, 'type' => 'enum', 'enum' => array(0 => _("Ascending"), 1 => _("Descending")), 'desc' => _("Default sorting direction:"));
$_prefs['thread_view_bodies'] = array('value' => 0, 'type' => 'enum', 'enum' => array(0 => _("No"), 1 => _("Yes"), 2 => _("Yes, and don't thread them")), 'desc' => _("Display full message bodies in the thread list view?"));