[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14912] get files by id
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14912] get files by id |
Date: |
Sun, 10 Apr 2016 14:07:25 +0000 |
Revision: 14912
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14912
Author: sigurdne
Date: 2016-04-10 14:07:24 +0000 (Sun, 10 Apr 2016)
Log Message:
-----------
get files by id
Modified Paths:
--------------
trunk/phpgwapi/inc/class.vfs_sql.inc.php
trunk/property/inc/class.bofiles.inc.php
trunk/property/inc/class.uitts.inc.php
Modified: trunk/phpgwapi/inc/class.vfs_sql.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.vfs_sql.inc.php 2016-04-09 11:40:37 UTC (rev
14911)
+++ trunk/phpgwapi/inc/class.vfs_sql.inc.php 2016-04-10 14:07:24 UTC (rev
14912)
@@ -755,6 +755,39 @@
}
/*
+ * get file by id
+ */
+ function get($file_id)
+ {
+ $file_id = (int) $file_id;
+ $query = $GLOBALS['phpgw']->db->query("SELECT
directory, name FROM phpgw_vfs WHERE file_id={$file_id}", __LINE__, __FILE__);
+ $GLOBALS['phpgw']->db->next_record();
+ $directory = $GLOBALS['phpgw']->db->f('directory');
+ $name = $GLOBALS['phpgw']->db->f('name');
+
+ $file = "{$directory}/{$name}";
+
+ $ls_array = $this->ls(array(
+ 'string' => $file,
+ 'relatives' => array(RELATIVE_NONE),
+ 'checksubdirs' => false,
+ 'nofiles' => true
+ ));
+
+ $content = $this->read(array(
+ 'string' => "{$directory}/$name",
+ 'relatives' => array(RELATIVE_NONE)
+ )
+ );
+
+ return array(
+ 'name' => $ls_array[0]['name'],
+ 'mime_type' => $ls_array[0]['mime_type'],
+ 'size' => $ls_array[0]['size'],
+ 'content' => $content
+ );
+ }
+ /*
* See vfs_shared
*/
function read($data)
Modified: trunk/property/inc/class.bofiles.inc.php
===================================================================
--- trunk/property/inc/class.bofiles.inc.php 2016-04-09 11:40:37 UTC (rev
14911)
+++ trunk/property/inc/class.bofiles.inc.php 2016-04-10 14:07:24 UTC (rev
14912)
@@ -190,6 +190,30 @@
/**
* View File - echo (or download) to browser.
*
+ * @param intenger $file_id
+ *
+ * @return null
+ */
+ function get_file( $file_id )
+ {
+ $GLOBALS['phpgw_info']['flags']['noheader'] = true;
+ $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+
+ $this->vfs->override_acl = 1;
+
+ $document = $this->vfs->get($file_id);
+
+ $this->vfs->override_acl = 0;
+
+ $browser = CreateObject('phpgwapi.browser');
+ $browser->content_header($document['name'],
$document['mime_type'], $document['size']);
+ echo $document['content'];
+ }
+
+ /**
+ * View File - echo (or download) to browser.
+ *
* @param string $type part of path where to look for files
* @param string $file optional filename
*
@@ -295,8 +319,9 @@
return $attachments;
}
- function strip_entities_from_name($file_name)
+ function strip_entities_from_name( $file_name )
{
- return str_replace(array('(',
')','−−'),array('(', ')', '--'), $file_name);
+ return str_replace(array('(', ')',
'−−'), array('(', ')',
+ '--'), $file_name);
}
}
\ No newline at end of file
Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php 2016-04-09 11:40:37 UTC (rev
14911)
+++ trunk/property/inc/class.uitts.inc.php 2016-04-10 14:07:24 UTC (rev
14912)
@@ -1467,10 +1467,8 @@
$link_file_data = array
(
'menuaction' => 'property.uitts.view_file',
- 'id' => $id
);
- $link_to_files =
isset($this->bo->config->config_data['files_url']) ?
$this->bo->config->config_data['files_url'] : '';
$link_view_file = $GLOBALS['phpgw']->link('/index.php',
$link_file_data);
$values = $this->bo->read_single($id);
@@ -1481,7 +1479,7 @@
{
$content_files[] = array
(
- 'file_name' => '<a href="' .
$link_view_file . '&file_name=' . $_entry['name'] . '" target="_blank"
title="' . lang('click to view file') . '">' . $_entry['name'] . '</a>',
+ 'file_name' => '<a href="' .
$link_view_file . '&file_id=' . $_entry['file_id'] . '" target="_blank"
title="' . lang('click to view file') . '">' . $_entry['name'] . '</a>',
'delete_file' => '<input
type="checkbox" name="values[file_action][]" value="' . $_entry['name'] . '"
title="' . lang('Check to delete file') . '">',
'attach_file' => '<input
type="checkbox" name="values[file_attach][]" value="' . $_entry['name'] . '"
title="' . lang('Check to attach file') . '">'
);
@@ -2340,20 +2338,12 @@
)
);
- $link_to_files =
(isset($this->bo->config->config_data['files_url']) ?
$this->bo->config->config_data['files_url'] : '');
$link_view_file = $GLOBALS['phpgw']->link('/index.php',
$link_file_data);
for ($z = 0; $z < count($ticket['files']); $z++)
{
- if ($link_to_files != '')
- {
- $content_files[$z]['file_name'] = '<a
href="' . $link_to_files . '/' . $ticket['files'][$z]['directory'] . '/' .
$ticket['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click
to view file') . '">' . $ticket['files'][$z]['name'] . '</a>';
- }
- else
- {
- $content_files[$z]['file_name'] = '<a
href="' . $link_view_file . '&file_name=' .
$ticket['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click
to view file') . '">' . $ticket['files'][$z]['name'] . '</a>';
- }
+ $content_files[$z]['file_name'] = '<a href="' .
$link_view_file . '&file_id=' . $ticket['files'][$z]['file_id'] . '"
target="_blank" title="' . lang('click to view file') . '">' .
$ticket['files'][$z]['name'] . '</a>';
$content_files[$z]['delete_file'] = '<input
type="checkbox" name="values[file_action][]" value="' .
$ticket['files'][$z]['name'] . '" title="' . lang('Check to delete file') .
'">';
$content_files[$z]['attach_file'] = '<input
type="checkbox" name="values[file_attach][]" value="' .
$ticket['files'][$z]['name'] . '" title="' . lang('Check to attach file') .
'">';
}
@@ -2665,8 +2655,7 @@
'perm' => 1, 'acl_location' =>
$this->acl_location));
}
- $bofiles = CreateObject('property.bofiles');
- $bofiles->view_file('fmticket');
+ ExecMethod('property.bofiles.get_file',
phpgw::get_var('file_id', 'int'));
}
protected function _generate_tabs( $history = '' )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14912] get files by id,
Sigurd Nes <=