<?xml version="1.0"?>
-<!-- $Id$ -->
+<!-- $Horde: news/config/conf.xml,v 1.2 2004/01/20 18:17:25 jan Exp $ -->
<configuration>
<configtab name="storage" desc="Storage Settings">
<configboolean name="ansel-images" desc="Link to Ansel galleries">TRUE</configboolean>
<configstring name="ansel-url" desc="Ansel images url">TRUE</configstring>
<configboolean name="tags" desc="Use tags">false</configboolean>
- <configstring name="attachments" desc="Attachments dir"></configstring>
+ <configboolean name="attachments" desc="Allow attachments">true</configboolean>
<configmultienum name="languages" desc="Select all languages that should be activated">
<values>
<configspecial name="list-horde-languages" />
switch ($actionID) {
case 'download_file':
+ $data = News::getFile($file_id);
+ if ($data instanceof PEAR_Error) {
+ if (Auth::isAdmin('news:admin')) {
+ Horde::fatal($data, __FILE__, __LINE__);
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ echo '<h1>HTTP/1.0 404 Not Found</h1>';
+ }
+ exit;
+ }
+
$browser->downloadHeaders($file_name, $file_type, false, $file_size);
- readfile($conf['attributes']['attachments'] . '/' . $file_id);
+ echo $data;
break;
case 'view_file':
- $data = file_get_contents($conf['attributes']['attachments'] . '/' . $file_id);
- if ($data === false) {
- header('HTTP/1.0 404 Not Found');
- echo 'HTTP/1.0 404 Not Found';
+ $data = News::getFile($file_id);
+ if ($data instanceof PEAR_Error) {
+ if (Auth::isAdmin('news:admin')) {
+ Horde::fatal($data, __FILE__, __LINE__);
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ echo '<h1>HTTP/1.0 404 Not Found</h1>';
+ }
exit;
}
$file_id = sprintf(_("FilesOfNews-%s"), $news_id);
$zipfiles = array();
foreach ($news->getFiles($news_id) as $file) {
-
- $file_path = $conf['attributes']['attachments'] . '/' . $file['file_id'];
- if (!file_exists($file_path)) {
+ $data = News::getFile($file_id);
+ if ($data instanceof PEAR_Error) {
continue;
}
$zipfiles[] = array('data' => $file_path,
case 'download_zip':
- $zipfiles = array('data' => file_get_contents($conf['attributes']['attachments'] . '/' . $file_id),
- 'name' => $file_id);
-
- if ($zipfiles[0]['data'] === false) {
- header('HTTP/1.0 404 Not Found');
- echo 'HTTP/1.0 404 Not Found';
+ $data = News::getFile($file_id);
+ if ($data instanceof PEAR_Error) {
+ if (Auth::isAdmin('news:admin')) {
+ Horde::fatal($data, __FILE__, __LINE__);
+ } else {
+ header('HTTP/1.0 404 Not Found');
+ echo '<h1>HTTP/1.0 404 Not Found</h1>';
+ }
exit;
}
+ $zipfiles = array('data' => $data, 'name' => $file_id);
$zip = Horde_Compress::singleton('zip');
$body = @$zip->compress($zipfiles);
$browser->downloadHeaders($file_id . '.zip', 'application/zip', false, strlen($body));
/**
* Store file
*
- * @param $file_id Image owner record id
+ * @param $file_id File id
* @param $file_src File path
*/
static public function saveFile($file_id, $file_src)
}
/**
+ * Get file contents
+ *
+ * @param $file_id File ID
+ */
+ static public function getFile($file_id)
+ {
+ $vfs = self::loadVFS();
+ if ($vfs instanceof PEAR_Error) {
+ return $vfs;
+ }
+
+ return $vfs->read(self::VFS_PATH . '/files/', $file_id);
+ }
+
+ /**
* Delete file
*
- * @param $id Image owner record id
+ * @param $id File ID
*/
static public function deleteFile($file_id)
{