fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [14913] rework vfs to get files by id rather than nam


From: Sigurd Nes
Subject: [Fmsystem-commits] [14913] rework vfs to get files by id rather than names
Date: Mon, 11 Apr 2016 12:27:37 +0000

Revision: 14913
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14913
Author:   sigurdne
Date:     2016-04-11 12:27:37 +0000 (Mon, 11 Apr 2016)
Log Message:
-----------
rework vfs to get files by id rather than names

Modified Paths:
--------------
    trunk/bim/inc/class.sovfs.inc.php
    trunk/helpdesk/inc/class.uitts.inc.php
    trunk/phpgwapi/inc/class.vfs_sql.inc.php
    trunk/property/inc/class.bofiles.inc.php
    trunk/property/inc/class.uiagreement.inc.php
    trunk/property/inc/class.uicondition_survey.inc.php
    trunk/property/inc/class.uientity.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/inc/class.uirequest.inc.php
    trunk/property/inc/class.uis_agreement.inc.php
    trunk/property/inc/class.uitenant_claim.inc.php
    trunk/property/inc/class.uitts.inc.php
    trunk/property/inc/class.uiwo_hour.inc.php
    trunk/property/inc/class.uiworkorder.inc.php

Modified: trunk/bim/inc/class.sovfs.inc.php
===================================================================
--- trunk/bim/inc/class.sovfs.inc.php   2016-04-10 14:07:24 UTC (rev 14912)
+++ trunk/bim/inc/class.sovfs.inc.php   2016-04-11 12:27:37 UTC (rev 14913)
@@ -209,8 +209,6 @@
                                $errorString = $errorString . 
"filename:$this->filename \n";
                                throw new 
InvalidArgumentException($errorString);
                        }
-                       $file = array();
-                       $file['file_action'][0] = $this->filename;
                        if($this->subModule)
                        {
                                $path = "/$this->subModule/";
@@ -219,7 +217,32 @@
                        {
                                $path = "/";
                        }
-                       $recieve = $this->bofiles->delete_file($path, $file);
+
+                       $file = 
"{$this->bofiles->fakebase}{$path}{$this->filename}";
+
+                       if ($this->bofiles->vfs->file_exists(array(
+                                       'string' => $file,
+                                       'relatives' => array(RELATIVE_NONE)
+                               )))
+                       {
+                               $this->bofiles->vfs->override_acl = 1;
+
+                               if (!$this->bofiles->vfs->rm(array(
+                                               'string' => $file,
+                                               'relatives' => array(
+                                                       RELATIVE_NONE
+                                               )
+                                       )))
+                               {
+                                       $recieve['error'][] = array('msg' => 
lang('failed to delete file') . ' :' . $this->bofiles->fakebase . $path . 
$this->filename);
+                               }
+                               else
+                               {
+                                       $recieve['message'][] = array('msg' => 
lang('file deleted') . ' :' . $this->bofiles->fakebase . $path . 
$this->filename);
+                               }
+                               $this->bofiles->vfs->override_acl = 0;
+                       }
+
                        if($recieve['message'])
                        {
                                $result = $recieve['message'][0]["msg"];

Modified: trunk/helpdesk/inc/class.uitts.inc.php
===================================================================
--- trunk/helpdesk/inc/class.uitts.inc.php      2016-04-10 14:07:24 UTC (rev 
14912)
+++ trunk/helpdesk/inc/class.uitts.inc.php      2016-04-11 12:27:37 UTC (rev 
14913)
@@ -1903,7 +1903,7 @@
                                if(isset($values['file_attach']) && 
is_array($values['file_attach']))
                                {
 //                                     $bofiles        = 
CreateObject('helpdesk.bofiles' '/helpdesk');
-                                       $attachments = 
$bofiles->get_attachments("/{$id}/", $values['file_attach']);
+                                       $attachments = 
$bofiles->get_attachments($values['file_attach']);
                                        $attachment_log = ' ' . 
lang('attachments') . ' : ' . implode(', ',$values['file_attach']);
                                }
                                if 
(isset($GLOBALS['phpgw_info']['server']['smtp_server']) && 
$GLOBALS['phpgw_info']['server']['smtp_server'])
@@ -2090,22 +2090,13 @@
                                );      
 
 
-                       $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').'" 
style="cursor:help">'.$ticket['files'][$z]['name'].'</a>';
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="'.$link_view_file.'&amp;file_name='.$ticket['files'][$z]['file_name'].'" 
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').'">';
+                               $content_files[$z]['file_name'] = '<a 
href="'.$link_view_file.'&amp;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]['file_id'].'" title="'.lang('Check to delete 
file').'">';
+                               $content_files[$z]['attach_file'] = '<input 
type="checkbox" name="values[file_attach][]" 
value="'.$ticket['files'][$z]['file_id'].'" title="'.lang('Check to attach 
file').'">';
                        }                                                       
 
                        $datavalues[2] = array
@@ -2301,8 +2292,7 @@
                                
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=> 
'helpdesk.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
                        }
 
-                       $bofiles        = 
CreateObject('property.bofiles','/helpdesk');
-                       $bofiles->view_file('fmticket');
+                       ExecMethod('property.bofiles.get_file', 
phpgw::get_var('file_id', 'int'));
                }
 
                protected function _generate_tabs($history='')

Modified: trunk/phpgwapi/inc/class.vfs_sql.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.vfs_sql.inc.php    2016-04-10 14:07:24 UTC (rev 
14912)
+++ trunk/phpgwapi/inc/class.vfs_sql.inc.php    2016-04-11 12:27:37 UTC (rev 
14913)
@@ -755,9 +755,11 @@
                }
 
                /*
-                * get file by id
+                * get file info by id
+                *
+                * @return Array of file information.
                 */
-               function get($file_id)
+               function get_info( $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__);
@@ -773,19 +775,26 @@
                                        'checksubdirs' => false,
                                        'nofiles' => true
                                ));
+                       
+                       return isset($ls_array[0]) && $ls_array[0] ? 
$ls_array[0] : array();
+               }
 
-                       $content =  $this->read(array(
-                                       'string' => "{$directory}/$name",
+               /*
+                * get file by id
+                *
+                * @return Array of file information and file content
+                */
+               function get($file_id)
+               {
+                       $file_info = $this->get_info( $file_id );
+
+                       $file_info['content'] =  $this->read(array(
+                                       'string' => 
"{$file_info['directory']}/{$file_info['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
-                       );
+                       return $file_info;
                }
                /*
                 * See vfs_shared

Modified: trunk/property/inc/class.bofiles.inc.php
===================================================================
--- trunk/property/inc/class.bofiles.inc.php    2016-04-10 14:07:24 UTC (rev 
14912)
+++ trunk/property/inc/class.bofiles.inc.php    2016-04-11 12:27:37 UTC (rev 
14913)
@@ -150,17 +150,24 @@
                 *
                 * @return array Array with result on the 
action(failed/success) for each file
                 */
-               function delete_file( $path, $values )
+               function delete_file($path, $values )
                {
                        $receipt = array();
 
-                       foreach ($values['file_action'] as $file_name)
+                       foreach ($values['file_action'] as $file_id)
                        {
-                               $file_name = html_entity_decode($file_name);
-                               $file_name = 
$this->strip_entities_from_name($file_name);
+                               $file_info = $this->vfs->get_info($file_id);
 
-                               $file = "{$this->fakebase}{$path}{$file_name}";
+                               $check_path = trim("{$this->fakebase}{$path}", 
"/");
 
+                               $file = 
"{$file_info['directory']}/{$file_info['name']}";
+
+                               if($check_path != trim($file_info['directory'], 
"/"))
+                               {
+                                       phpgwapi_cache::message_set( "deleting 
file from wrong location", 'error');
+                                       return false;
+                               }
+
                                if ($this->vfs->file_exists(array(
                                                'string' => $file,
                                                'relatives' => 
array(RELATIVE_NONE)
@@ -175,11 +182,11 @@
                                                        )
                                                )))
                                        {
-                                               $receipt['error'][] = 
array('msg' => lang('failed to delete file') . ' :' . $this->fakebase . $path . 
$file_name);
+                                               
phpgwapi_cache::message_set(lang('failed to delete file') . ' :' .$file, 
'error');
                                        }
                                        else
                                        {
-                                               $receipt['message'][] = 
array('msg' => lang('file deleted') . ' :' . $this->fakebase . $path . 
$file_name);
+                                               
phpgwapi_cache::message_set(lang('file deleted') . ' :' . $file, 'message');
                                        }
                                        $this->vfs->override_acl = 0;
                                }
@@ -194,21 +201,43 @@
                 *
                 * @return null
                 */
-               function get_file( $file_id )
+               function get_file( $file_id, $jasper = false )
                {
                        $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);
+                       if (!$jasper)
+                       {
+                               $this->vfs->override_acl = 1;
 
-                       $this->vfs->override_acl = 0;
+                               $document = $this->vfs->get($file_id);
 
-                       $browser = CreateObject('phpgwapi.browser');
-                       $browser->content_header($document['name'], 
$document['mime_type'], $document['size']);
-                       echo $document['content'];
+                               $this->vfs->override_acl = 0;
+                               $browser = CreateObject('phpgwapi.browser');
+                               $browser->content_header($document['name'], 
$document['mime_type'], $document['size']);
+                               echo $document['content'];
+                       }
+                       else //Execute the jasper report
+                       {
+                               $output_type = 'PDF';
+                               $file_info = $this->vfs->get_info($file_id);
+                               $file = 
"{$file_info['directory']}/{$file_info['name']}";
+
+                               $report_source = "{$this->rootdir}{$file}";
+                               $jasper_wrapper = 
CreateObject('phpgwapi.jasper_wrapper');
+                               try
+                               {
+                                       $jasper_wrapper->execute('', 
$output_type, $report_source);
+                               }
+                               catch (Exception $e)
+                               {
+                                       $error = $e->getMessage();
+                                       //FIXME Do something clever with the 
error
+                                       echo "<H1>{$error}</H1>";
+                               }
+                       }
                }
 
                /**
@@ -293,28 +322,21 @@
                 *
                 * @return array Array with filecontent
                 */
-               function get_attachments( $path, $values )
+               function get_attachments( $values )
                {
-                       $mime_magic = createObject('phpgwapi.mime_magic');
                        $attachments = array();
-                       foreach ($values as $file_name)
+                       foreach ($values as $file_id)
                        {
-                               $file_name = 
$this->strip_entities_from_name($file_name);
-                               $file = "{$this->fakebase}{$path}{$file_name}";
+                               $file_info = $this->vfs->get_info($file_id);
 
-                               if ($this->vfs->file_exists(array(
-                                               'string' => $file,
-                                               'relatives' => 
array(RELATIVE_NONE))))
-                               {
-                                       $mime = 
$mime_magic->filename2mime($file_name);
+                               $file = 
"{$file_info['directory']}/{$file_info['name']}";
 
-                                       $attachments[] = array
-                                               (
-                                               'file' => 
"{$GLOBALS['phpgw_info']['server']['files_dir']}{$file}",
-                                               'name' => $file_name,
-                                               'type' => $mime
-                                       );
-                               }
+                               $attachments[] = array
+                                       (
+                                       'file' => 
"{$GLOBALS['phpgw_info']['server']['files_dir']}{$file}",
+                                       'name' => $file_info['name'],
+                                       'type' => $file_info['mime_type']
+                               );
                        }
                        return $attachments;
                }

Modified: trunk/property/inc/class.uiagreement.inc.php
===================================================================
--- trunk/property/inc/class.uiagreement.inc.php        2016-04-10 14:07:24 UTC 
(rev 14912)
+++ trunk/property/inc/class.uiagreement.inc.php        2016-04-11 12:27:37 UTC 
(rev 14913)
@@ -172,8 +172,7 @@
                                        'perm' => 1, 'acl_location' => 
$this->acl_location));
                        }
 
-                       $bofiles = CreateObject('property.bofiles');
-                       $bofiles->view_file('agreement');
+                       ExecMethod('property.bofiles.get_file', 
phpgw::get_var('file_id', 'int'));
                }
 
                private function _get_Filters()
@@ -1427,8 +1426,8 @@
 
                        for ($z = 0; $z < count($agreement['files']); $z++)
                        {
-                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_name=' . $agreement['files'][$z]['file_name'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$agreement['files'][$z]['name'] . '</a>';
-                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$agreement['files'][$z]['name'] . '" title="' . lang('Check to delete file') . 
'">';
+                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_id=' . $agreement['files'][$z]['file_id'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$agreement['files'][$z]['name'] . '</a>';
+                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$agreement['files'][$z]['file_id'] . '" title="' . lang('Check to delete file') 
. '">';
                        }
 
                        $myColumnDefs2 = array
@@ -2232,14 +2231,7 @@
 
                        for ($z = 0; $z < count($agreement['files']); $z++)
                        {
-                               if ($link_to_files != '')
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_to_files . '/' . $agreement['files'][$z]['directory'] . '/' . 
$agreement['files'][$z]['file_name'] . '" target="_blank" title="' . 
lang('click to view file') . '">' . $agreement['files'][$z]['name'] . '</a>';
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_view_file . '&amp;file_name=' . 
$agreement['files'][$z]['file_name'] . '" target="_blank" title="' . 
lang('click to view file') . '">' . $agreement['files'][$z]['name'] . '</a>';
-                               }
+                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_id=' . $agreement['files'][$z]['file_id'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$agreement['files'][$z]['name'] . '</a>';
                        }
 
                        $myColumnDefs2 = array

Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2016-04-10 14:07:24 UTC 
(rev 14912)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2016-04-11 12:27:37 UTC 
(rev 14913)
@@ -681,8 +681,8 @@
                        {
                                $values[] = array
                                        (
-                                       'file_name' => "<a 
href='{$link_view_file}&amp;file_name={$_entry['name']}' target='_blank' 
title='{$lang_view}'>{$_entry['name']}</a>",
-                                       'delete_file' => "<input 
type='checkbox' name='file_action[]' value='{$_entry['name']}' 
title='$lang_delete'>",
+                                       'file_name' => "<a 
href='{$link_view_file}&amp;file_id={$_entry['file_id']}' target='_blank' 
title='{$lang_view}'>{$_entry['name']}</a>",
+                                       'delete_file' => "<input 
type='checkbox' name='file_action[]' value='{$_entry['file_id']}' 
title='$lang_delete'>",
                                );
                        }
 
@@ -792,9 +792,7 @@
                        {
                                return lang('no access');
                        }
-
-                       $bofiles = CreateObject('property.bofiles');
-                       $bofiles->view_file('condition_survey');
+                       ExecMethod('property.bofiles.get_file', 
phpgw::get_var('file_id', 'int'));
                }
 
                /**
@@ -815,7 +813,7 @@
 
                        if (isset($_POST['file_action']) && 
is_array($_POST['file_action']))
                        {
-                               
$bofiles->delete_file("/condition_survey/{$id}/", array('file_action' => 
$_POST['file_action']));
+                               
$bofiles->delete_file("/condition_survey/{$id}/",array('file_action' => 
$_POST['file_action']));
                        }
                        $file_name = str_replace(' ', '_', 
$_FILES['file']['name']);
 

Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php   2016-04-10 14:07:24 UTC (rev 
14912)
+++ trunk/property/inc/class.uientity.inc.php   2016-04-11 12:27:37 UTC (rev 
14913)
@@ -277,13 +277,13 @@
                        $bofiles = CreateObject('property.bofiles');
                        if (isset($values['file_action']) && 
is_array($values['file_action']))
                        {
-                               
$bofiles->delete_file("/{$this->category_dir}/{$loc1}/{$id}/", $values);
+                               
$bofiles->delete_file("/{$this->category_dir}/{$loc1}/{$id}/" ,$values);
                        }
 
                        if (isset($values['file_jasperaction']) && 
is_array($values['file_jasperaction']))
                        {
                                $values['file_action'] = 
$values['file_jasperaction'];
-                               
$bofiles->delete_file("/{$this->category_dir}/{$loc1}/{$id}/", $values);
+                               
$bofiles->delete_file("{$this->category_dir}/{$loc1}/{$id}/" ,$values);
                        }
 
                        $files = array();
@@ -953,8 +953,8 @@
                        {
                                $content_files[] = array
                                        (
-                                       'file_name' => '<a href="' . 
$GLOBALS['phpgw']->link('/index.php', $link_file_data) . '&amp;file_name=' . 
urlencode($_entry['name']) . '" 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') . '">'
+                                       'file_name' => '<a href="' . 
$GLOBALS['phpgw']->link('/index.php', $link_file_data) . '&amp;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['file_id'] . '" 
title="' . lang('Check to delete file') . '">'
                                );
                        }
 
@@ -1051,17 +1051,11 @@
                                        'perm' => 1, 'acl_location' => 
$this->acl_location));
                        }
 
-                       $file_name = urldecode(phpgw::get_var('file_name'));
-                       $loc1 = phpgw::get_var('loc1', 'string', 'REQUEST', 
'dummy');
-                       if ($this->type_app[$this->type] == 'catch')
-                       {
-                               $loc1 = 'dummy';
-                       }
-                       $id = phpgw::get_var('id', 'int');
+                       $file_id = phpgw::get_var('file_id', 'int');
                        $jasper = phpgw::get_var('jasper', 'bool');
 
                        $bofiles = CreateObject('property.bofiles');
-                       $bofiles->view_file("{$this->category_dir}/{$loc1}", 
'', $jasper);
+                       $bofiles->get_file($file_id, $jasper);
                }
 
                function index()

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2016-04-10 14:07:24 UTC (rev 
14912)
+++ trunk/property/inc/class.uiproject.inc.php  2016-04-11 12:27:37 UTC (rev 
14913)
@@ -160,8 +160,7 @@
                                $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uilocation.stop',
                                        'perm' => 1, 'acl_location' => 
$this->acl_location));
                        }
-                       $bofiles = CreateObject('property.bofiles');
-                       $bofiles->view_file('project');
+                       ExecMethod('property.bofiles.get_file', 
phpgw::get_var('file_id', 'int'));
                }
 
                function columns()
@@ -1835,8 +1834,6 @@
                                'id' => $id
                        );
 
-                       $link_to_files = 
(isset($config->config_data['files_url']) ? $config->config_data['files_url'] : 
'');
-
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
$link_file_data);
 
                        $_files = $this->bo->get_files($id);
@@ -1847,15 +1844,8 @@
                        $content_files = array();
                        foreach ($_files as $_file)
                        {
-                               if ($link_to_files)
-                               {
-                                       $content_files[$z]['file_name'] = "<a 
href='{$link_to_files}/{$_file['directory']}/{$_file['file_name']}' 
target=\"_blank\" title='{$lang_view_file}'>{$_file['name']}</a>";
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = "<a 
href=\"{$link_view_file}&amp;file_name={$_file['file_name']}\" 
target=\"_blank\" title=\"{$lang_view_file}\">{$_file['name']}</a>";
-                               }
-                               $content_files[$z]['delete_file'] = "<input 
type=\"checkbox\" name=\"values[file_action][]\" value=\"{$_file['name']}\" 
title=\"{$lang_delete_file}\">";
+                               $content_files[$z]['file_name'] = "<a 
href=\"{$link_view_file}&amp;file_id={$_file['file_id']}\" target=\"_blank\" 
title=\"{$lang_view_file}\">{$_file['name']}</a>";
+                               $content_files[$z]['delete_file'] = "<input 
type=\"checkbox\" name=\"values[file_action][]\" value=\"{$_file['file_id']}\" 
title=\"{$lang_delete_file}\">";
                                $z++;
                        }
 

Modified: trunk/property/inc/class.uirequest.inc.php
===================================================================
--- trunk/property/inc/class.uirequest.inc.php  2016-04-10 14:07:24 UTC (rev 
14912)
+++ trunk/property/inc/class.uirequest.inc.php  2016-04-11 12:27:37 UTC (rev 
14913)
@@ -580,10 +580,7 @@
                                        'perm' => 1, 'acl_location' => 
$this->acl_location));
                        }
 
-                       $location_code = phpgw::get_var('location_code');
-
-                       $bofiles = CreateObject('property.bofiles');
-                       $bofiles->view_file('request');
+                       ExecMethod('property.bofiles.get_file', 
phpgw::get_var('file_id', 'int'));
                }
 
                function download()
@@ -1316,7 +1313,6 @@
                                'id' => $id
                        );
 
-                       $link_to_files = 
$this->config->config_data['files_url'];
 
                        $j = count($values['files']);
                        for ($i = 0; $i < $j; $i++)
@@ -1351,15 +1347,8 @@
 
                        for ($z = 0; $z < count($values['files']); $z++)
                        {
-                               if ($link_to_files != '')
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_to_files . '/' . $values['files'][$z]['directory'] . '/' . 
$values['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click 
to view file') . '">' . $values['files'][$z]['name'] . '</a>';
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_view_file . '&amp;file_name=' . 
$values['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click 
to view file') . '">' . $values['files'][$z]['name'] . '</a>';
-                               }
-                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$values['files'][$z]['name'] . '" title="' . lang('Check to delete file') . '" 
>';
+                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_id=' . $values['files'][$z]['file_id'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$values['files'][$z]['name'] . '</a>';
+                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$values['files'][$z]['file_id'] . '" title="' . lang('Check to delete file') . 
'" >';
                        }
 
                        $datatable_def[] = array

Modified: trunk/property/inc/class.uis_agreement.inc.php
===================================================================
--- trunk/property/inc/class.uis_agreement.inc.php      2016-04-10 14:07:24 UTC 
(rev 14912)
+++ trunk/property/inc/class.uis_agreement.inc.php      2016-04-11 12:27:37 UTC 
(rev 14913)
@@ -174,8 +174,7 @@
                                        'perm' => 1, 'acl_location' => 
$this->acl_location));
                        }
 
-                       $bofiles = CreateObject('property.bofiles');
-                       $bofiles->view_file('service_agreement');
+                       ExecMethod('property.bofiles.get_file', 
phpgw::get_var('file_id', 'int'));
                }
 
                private function _get_Filters()
@@ -977,7 +976,6 @@
                        phpgwapi_jquery::load_widget('core');
 //                     $active_tab             = phpgw::get_var('tab', 
'string', 'REQUEST', 'general');
 
-                       $config = CreateObject('phpgwapi.config', 'property');
                        $boalarm = CreateObject('property.boalarm');
                        $get_items = false;
 
@@ -1083,8 +1081,6 @@
                                'id' => $id
                        );
 
-                       $config->read();
-                       $link_to_files = $config->config_data['files_url'];
 
                        $j = count($values['files']);
                        for ($i = 0; $i < $j; $i++)
@@ -1302,15 +1298,8 @@
 
                        for ($z = 0; $z < count($values['files']); $z++)
                        {
-                               if ($link_to_files != '')
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_to_files . '/' . $values['files'][$z]['directory'] . '/' . 
$values['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click 
to view file') . '">' . $values['files'][$z]['name'] . '</a>';
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_view_file . '&amp;file_name=' . 
$values['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click 
to view file') . '">' . $values['files'][$z]['name'] . '</a>';
-                               }
-                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$values['files'][$z]['name'] . '" title="' . lang('Check to delete file') . 
'">';
+                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_id=' . $values['files'][$z]['file_id'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$values['files'][$z]['name'] . '</a>';
+                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$values['files'][$z]['file_id'] . '" title="' . lang('Check to delete file') . 
'">';
                        }
 
                        $myColumnDefs2 = array
@@ -2247,7 +2236,6 @@
                        }
 
                        $s_agreement_id = phpgw::get_var('id'); // in case of 
bigint
-                       $config = CreateObject('phpgwapi.config', 'property');
 
                        $tabs = array();
                        $tabs['general'] = array('label' => lang('general'), 
'link' => '#general');
@@ -2326,10 +2314,6 @@
                                'id' => $s_agreement_id
                        );
 
-
-                       $config->read();
-                       $link_to_files = $config->config_data['files_url'];
-
                        $j = count($s_agreement['files']);
                        for ($i = 0; $i < $j; $i++)
                        {
@@ -2450,14 +2434,7 @@
 
                        for ($z = 0; $z < count($s_agreement['files']); $z++)
                        {
-                               if ($link_to_files != '')
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_to_files . '/' . $s_agreement['files'][$z]['directory'] . '/' . 
$s_agreement['files'][$z]['file_name'] . '" target="_blank" title="' . 
lang('click to view file') . '">' . $s_agreement['files'][$z]['name'] . '</a>';
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_view_file . '&amp;file_name=' . 
$s_agreement['files'][$z]['file_name'] . '" target="_blank" title="' . 
lang('click to view file') . '">' . $s_agreement['files'][$z]['name'] . '</a>';
-                               }
+                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_id=' . $s_agreement['files'][$z]['file_id'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$s_agreement['files'][$z]['name'] . '</a>';
                        }
 
                        $myColumnDefs2 = array

Modified: trunk/property/inc/class.uitenant_claim.inc.php
===================================================================
--- trunk/property/inc/class.uitenant_claim.inc.php     2016-04-10 14:07:24 UTC 
(rev 14912)
+++ trunk/property/inc/class.uitenant_claim.inc.php     2016-04-11 12:27:37 UTC 
(rev 14913)
@@ -108,8 +108,7 @@
                                $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uilocation.stop',
                                        'perm' => PHPGW_ACL_READ, 
'acl_location' => $this->acl_location));
                        }
-                       $bofiles = CreateObject('property.bofiles');
-                       $bofiles->view_file('tenant_claim');
+                       ExecMethod('property.bofiles.get_file', 
phpgw::get_var('file_id', 'int'));
                }
 
                private function _get_filter_tenant()
@@ -751,8 +750,6 @@
                                'id' => $claim_id
                        );
 
-                       $link_to_files = 
(isset($config->config_data['files_url']) ? $config->config_data['files_url'] : 
'');
-
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
$link_file_data);
 
                        $_files = $this->bo->get_files($claim_id);
@@ -763,15 +760,8 @@
                        $content_files = array();
                        foreach ($_files as $_file)
                        {
-                               if ($link_to_files)
-                               {
-                                       $content_files[$z]['file_name'] = "<a 
href='{$link_to_files}/{$_file['directory']}/{$_file['file_name']}' 
target=\"_blank\" title='{$lang_view_file}'>{$_file['name']}</a>";
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = "<a 
href=\"{$link_view_file}&amp;file_name={$_file['file_name']}\" 
target=\"_blank\" title=\"{$lang_view_file}\">{$_file['name']}</a>";
-                               }
-                               $content_files[$z]['delete_file'] = "<input 
type=\"checkbox\" name=\"values[file_action][]\" value=\"{$_file['name']}\" 
title=\"{$lang_delete_file}\">";
+                               $content_files[$z]['file_name'] = "<a 
href=\"{$link_view_file}&amp;file_id={$_file['file_id']}\" target=\"_blank\" 
title=\"{$lang_view_file}\">{$_file['name']}</a>";
+                               $content_files[$z]['delete_file'] = "<input 
type=\"checkbox\" name=\"values[file_action][]\" value=\"{$_file['file_id']}\" 
title=\"{$lang_delete_file}\">";
                                $z++;
                        }
 

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2016-04-10 14:07:24 UTC (rev 
14912)
+++ trunk/property/inc/class.uitts.inc.php      2016-04-11 12:27:37 UTC (rev 
14913)
@@ -1480,8 +1480,8 @@
                                $content_files[] = array
                                        (
                                        'file_name' => '<a href="' . 
$link_view_file . '&amp;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') . '">'
+                                       'delete_file' => '<input 
type="checkbox" name="values[file_action][]" value="' . $_entry['file_id'] . '" 
title="' . lang('Check to delete file') . '">',
+                                       'attach_file' => '<input 
type="checkbox" name="values[file_attach][]" value="' . $_entry['file_id'] . '" 
title="' . lang('Check to attach file') . '">'
                                );
                        }
 
@@ -2101,8 +2101,13 @@
                                if (isset($values['file_attach']) && 
is_array($values['file_attach']))
                                {
                                        $bofiles = 
CreateObject('property.bofiles');
-                                       $attachments = 
$bofiles->get_attachments("/fmticket/{$id}/", $values['file_attach']);
-                                       $attachment_log = ' ' . 
lang('attachments') . ' : ' . implode(', ', $values['file_attach']);
+                                       $attachments = 
$bofiles->get_attachments($values['file_attach']);
+                                       $_attachment_log = array();
+                                       foreach ($attachments as $_attachment)
+                                       {
+                                               $_attachment_log[] = 
$_attachment['name'];
+                                       }
+                                       $attachment_log = ' ' . 
lang('attachments') . ' : ' . implode(', ', $_attachment_log);
                                }
 
                                if (isset($values['send_order_format']) && 
$values['send_order_format'] == 'pdf')
@@ -2344,8 +2349,8 @@
                        for ($z = 0; $z < count($ticket['files']); $z++)
                        {
                                $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;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') . 
'">';
+                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$ticket['files'][$z]['file_id'] . '" title="' . lang('Check to delete file') . 
'">';
+                               $content_files[$z]['attach_file'] = '<input 
type="checkbox" name="values[file_attach][]" value="' . 
$ticket['files'][$z]['file_id'] . '" title="' . lang('Check to attach file') . 
'">';
                        }
 
 

Modified: trunk/property/inc/class.uiwo_hour.inc.php
===================================================================
--- trunk/property/inc/class.uiwo_hour.inc.php  2016-04-10 14:07:24 UTC (rev 
14912)
+++ trunk/property/inc/class.uiwo_hour.inc.php  2016-04-11 12:27:37 UTC (rev 
14913)
@@ -1433,9 +1433,15 @@
                                        if (isset($values['file_action']) && 
is_array($values['file_action']))
                                        {
                                                $bofiles = 
CreateObject('property.bofiles');
-                                               $attachments = 
$bofiles->get_attachments("/project/{$project['project_id']}/", 
$values['file_action']['project']);
-                                               $attachments = 
array_merge($attachments, 
$bofiles->get_attachments("/workorder/{$workorder_id}/", 
$values['file_action']['workorder']));
-                                               $attachment_log = 
lang('attachments') . ': ' . implode(', ', $values['file_action']['project']) . 
', ' . implode(', ', $values['file_action']['workorder']);
+                                               $attachments = 
$bofiles->get_attachments($values['file_action']['project']);
+                                               $attachments = 
array_merge($attachments, 
$bofiles->get_attachments($values['file_action']['workorder']));
+                                               $_attachment_log = array();
+                                               foreach ($attachments as 
$_attachment)
+                                               {
+                                                       $_attachment_log[] = 
$_attachment['name'];
+                                               }
+
+                                               $attachment_log = 
lang('attachments') . ': ' . implode(', ', $_attachment_log);
                                        }
 
                                        if ($send_as_pdf)
@@ -1614,7 +1620,6 @@
                        );
 
                        $content_files = array();
-                       $link_to_files = 
(isset($this->config->config_data['files_url']) ? 
$this->config->config_data['files_url'] : '');
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
$link_file_data);
 
                        $files = $workorder['files'] ? $workorder['files'] : 
array();
@@ -1623,15 +1628,8 @@
 
                        for ($z = 0; $z < count($files); $z++)
                        {
-                               if ($link_to_files)
-                               {
-                                       $content_files[$z]['file_name'] = "<a 
href='{$link_to_files}/{$files[$z]['directory']}/{$files[$z]['file_name']} 
target='_blank' title='{$lang_view_file}'>{$files[$z]['name']}</a>";
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = "<a 
href='{$link_view_file}&amp;file_name={$files[$z]['file_name']}' 
target='_blank' title='{$lang_view_file}'>{$files[$z]['name']}</a>";
-                               }
-                               $content_files[$z]['select_file'] = "<input 
type='checkbox' name='values[file_action][workorder][]' 
value='{$files[$z]['name']}' title='{$lang_select_file}'>";
+                               $content_files[$z]['file_name'] = "<a 
href='{$link_view_file}&amp;file_id={$files[$z]['file_id']}' target='_blank' 
title='{$lang_view_file}'>{$files[$z]['name']}</a>";
+                               $content_files[$z]['select_file'] = "<input 
type='checkbox' name='values[file_action][workorder][]' 
value='{$files[$z]['file_id']}' title='{$lang_select_file}'>";
                        }
 
                        $project_link_file_data = array
@@ -1647,15 +1645,8 @@
                        $i = $z;
                        for ($z = 0; $z < count($files); $z++)
                        {
-                               if ($link_to_files)
-                               {
-                                       $content_files[$i]['file_name'] = "<a 
href='{$link_to_files}/{$files[$z]['directory']}/{$files[$z]['file_name']} 
target='_blank' title='{$lang_view_file}'>{$files[$z]['name']}</a>";
-                               }
-                               else
-                               {
-                                       $content_files[$i]['file_name'] = "<a 
href='{$link_view_file}&amp;file_name={$files[$z]['file_name']}' 
target='_blank' title='{$lang_view_file}'>{$files[$z]['name']}</a>";
-                               }
-                               $content_files[$i]['select_file'] = "<input 
type='checkbox' name='values[file_action][project][]' 
value='{$files[$z]['name']}' title='{$lang_select_file}'>";
+                               $content_files[$i]['file_name'] = "<a 
href='{$link_view_file}&amp;file_id={$files[$z]['file_id']}' target='_blank' 
title='{$lang_view_file}'>{$files[$z]['name']}</a>";
+                               $content_files[$i]['select_file'] = "<input 
type='checkbox' name='values[file_action][project][]' 
value='{$files[$z]['file_id']}' title='{$lang_select_file}'>";
                                $i ++;
                        }
 

Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php        2016-04-10 14:07:24 UTC 
(rev 14912)
+++ trunk/property/inc/class.uiworkorder.inc.php        2016-04-11 12:27:37 UTC 
(rev 14913)
@@ -153,8 +153,7 @@
                                        'perm' => 1,
                                        'acl_location' => $this->acl_location));
                        }
-                       $bofiles = CreateObject('property.bofiles');
-                       $bofiles->view_file('workorder');
+                       ExecMethod('property.bofiles.get_file', 
phpgw::get_var('file_id', 'int'));
                }
 
                function columns()
@@ -1651,22 +1650,13 @@
                                )
                        );
 
-                       $link_to_files = 
(isset($config->config_data['files_url']) ? $config->config_data['files_url'] : 
'');
-
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
$link_file_data);
 
                        $content_files = array();
                        for ($z = 0; $z < count($values['files']); $z++)
                        {
-                               if ($link_to_files)
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_to_files . '/' . $values['files'][$z]['directory'] . '/' . 
$values['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click 
to view file') . '">' . $values['files'][$z]['name'] . '</a>';
-                               }
-                               else
-                               {
-                                       $content_files[$z]['file_name'] = '<a 
href="' . $link_view_file . '&amp;file_name=' . 
$values['files'][$z]['file_name'] . '" target="_blank" title="' . lang('click 
to view file') . '">' . $values['files'][$z]['name'] . '</a>';
-                               }
-                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$values['files'][$z]['name'] . '" title="' . lang('Check to delete file') . 
'">';
+                               $content_files[$z]['file_name'] = '<a href="' . 
$link_view_file . '&amp;file_id=' . $values['files'][$z]['file_id'] . '" 
target="_blank" title="' . lang('click to view file') . '">' . 
$values['files'][$z]['name'] . '</a>';
+                               $content_files[$z]['delete_file'] = '<input 
type="checkbox" name="values[file_action][]" value="' . 
$values['files'][$z]['file_id'] . '" title="' . lang('Check to delete file') . 
'">';
                        }
 
                        $files_def = array




reply via email to

[Prev in Thread] Current Thread [Next in Thread]