fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15595] more on helpdesk


From: sigurdne
Subject: [Fmsystem-commits] [15595] more on helpdesk
Date: Tue, 6 Sep 2016 11:24:19 +0000 (UTC)

Revision: 15595
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15595
Author:   sigurdne
Date:     2016-09-06 11:24:19 +0000 (Tue, 06 Sep 2016)
Log Message:
-----------
more on helpdesk

Modified Paths:
--------------
    trunk/helpdesk/inc/class.uitts.inc.php

Modified: trunk/helpdesk/inc/class.uitts.inc.php
===================================================================
--- trunk/helpdesk/inc/class.uitts.inc.php      2016-09-06 09:18:38 UTC (rev 
15594)
+++ trunk/helpdesk/inc/class.uitts.inc.php      2016-09-06 11:24:19 UTC (rev 
15595)
@@ -50,7 +50,8 @@
                                '_print'                        => true,
                                'columns'                       => true,
                                'update_data'           => true,
-                               'upload_clip'           => true
+                               'upload_clip'           => true,
+                               'view_image'            => true
                        );
 
                /**
@@ -1309,6 +1310,68 @@
                        }
                }
 
+               function view_image()
+               {
+                       $GLOBALS['phpgw_info']['flags']['noheader'] = true;
+                       $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+
+                       if (!$this->acl_read)
+                       {
+                               $GLOBALS['phpgw']->common->phpgw_exit();
+                       }
+
+                       $thumb = phpgw::get_var('thumb', 'bool');
+                       $img_id = phpgw::get_var('img_id', 'int');
+
+                       $bofiles = CreateObject('property.bofiles');
+
+                       if($img_id)
+                       {
+                               $file_info = $bofiles->vfs->get_info($img_id);
+                               $file = 
"{$file_info['directory']}/{$file_info['name']}";
+                       }
+                       else
+                       {
+                               $file = urldecode(phpgw::get_var('file'));
+                       }
+
+                       $source = "{$bofiles->rootdir}{$file}";
+                       $thumbfile = "$source.thumb";
+
+                       // prevent path traversal
+                       if (preg_match('/\.\./', $source))
+                       {
+                               return false;
+                       }
+
+                       $uigallery = CreateObject('property.uigallery');
+
+                       $re_create = false;
+                       if ($uigallery->is_image($source) && $thumb && 
$re_create)
+                       {
+                               $uigallery->create_thumb($source, $thumbfile, 
$thumb_size = 50);
+                               readfile($thumbfile);
+                       }
+                       else if ($thumb && is_file($thumbfile))
+                       {
+                               readfile($thumbfile);
+                       }
+                       else if ($uigallery->is_image($source) && $thumb)
+                       {
+                               $uigallery->create_thumb($source, $thumbfile, 
$thumb_size = 50);
+                               readfile($thumbfile);
+                       }
+                       else if ($img_id)
+                       {
+                               $bofiles->get_file($img_id);
+                       }
+                       else
+                       {
+                               $bofiles->view_file('', $file);
+                       }
+               }
+
                function get_files()
                {
                        $id = phpgw::get_var('id', 'int');
@@ -1328,15 +1391,32 @@
                        $values = $this->bo->read_single($id);
 
                        $content_files = array();
+                       $img_types = array(
+                               'image/jpeg',
+                               'image/png',
+                               'image/gif'
+                       );
 
+                       $z = 0;
                        foreach ($values['files'] as $_entry)
                        {
-                               $content_files[] = array
-                                       (
+                               $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['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') . '">'
                                );
+                               if ( in_array($_entry['mime_type'], $img_types))
+                               {
+                                       $content_files[$z]['file_name'] = 
$_entry['name'];
+                                       $content_files[$z]['img_id'] = 
$_entry['file_id'];
+                                       $content_files[$z]['img_url'] = 
self::link(array(
+                                                       'menuaction' => 
'helpdesk.uitts.view_image',
+                                                       'img_id'        =>  
$_entry['file_id'],
+                                                       'file' => 
$_entry['directory'] . '/' . $_entry['file_name']
+                                       ));
+                                       $content_files[$z]['thumbnail_flag'] = 
'thumb=1';
+                               }
+                               $z ++;
                        }
 
                        if (phpgw::get_var('phpgw_return_as') == 'json')
@@ -1636,17 +1716,41 @@
 
                        $link_view_file = $GLOBALS['phpgw']->link('/index.php', 
array('menuaction' => 'helpdesk.uitts.view_file'));
 
-                       for ($z = 0; $z < count($ticket['files']); $z++)
+                       $img_types = array(
+                               'image/jpeg',
+                               'image/png',
+                               'image/gif'
+                       );
+
+                       $content_files = array();
+
+                       $z = 0;
+                       foreach ($ticket['files'] as $_entry)
                        {
-                               $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') . 
'">';
+                               $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['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') . '">'
+                               );
+                               if ( in_array($_entry['mime_type'], $img_types))
+                               {
+                                       $content_files[$z]['file_name'] = 
$_entry['name'];
+                                       $content_files[$z]['img_id'] = 
$_entry['file_id'];
+                                       $content_files[$z]['img_url'] = 
self::link(array(
+                                                       'menuaction' => 
'helpdesk.uitts.view_image',
+                                                       'img_id'        =>  
$_entry['file_id'],
+                                                       'file' => 
$_entry['directory'] . '/' . $_entry['file_name']
+                                       ));
+                                       $content_files[$z]['thumbnail_flag'] = 
'thumb=1';
+                               }
+                               $z ++;
                        }
 
-
                        $attach_file_def = array(
                                array('key' => 'file_name', 'label' => 
lang('Filename'), 'sortable' => false,
                                        'resizeable' => true),
+                               array('key' => 'picture', 'label' => 
lang('picture'), 'sortable' => false,
+                                       'resizeable' => true, 'formatter' => 
'JqueryPortico.showPicture'),
                                array('key' => 'delete_file', 'label' => 
lang('Delete file'), 'sortable' => false,
                                        'resizeable' => true, 'formatter' => 
'FormatterCenter'),
                        );




reply via email to

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