fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16118] refactor


From: sigurdne
Subject: [Fmsystem-commits] [16118] refactor
Date: Thu, 29 Dec 2016 11:00:30 +0000 (UTC)

Revision: 16118
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16118
Author:   sigurdne
Date:     2016-12-29 11:00:30 +0000 (Thu, 29 Dec 2016)
Log Message:
-----------
refactor

Modified Paths:
--------------
    trunk/eventplanner/inc/class.boapplication.inc.php
    trunk/eventplanner/inc/class.bobooking.inc.php
    trunk/eventplanner/inc/class.bocustomer.inc.php
    trunk/eventplanner/inc/class.boresource.inc.php
    trunk/eventplanner/inc/class.bovendor.inc.php
    trunk/eventplanner/inc/class.bovendor_report.inc.php
    trunk/eventplanner/inc/class.uiapplication.inc.php
    trunk/eventplanner/inc/class.uibooking.inc.php
    trunk/eventplanner/inc/class.uicustomer.inc.php
    trunk/eventplanner/inc/class.uiresource.inc.php
    trunk/eventplanner/inc/class.uivendor.inc.php
    trunk/eventplanner/inc/class.uivendor_report.inc.php
    trunk/phpgwapi/inc/class.uicommon.inc.php

Added Paths:
-----------
    trunk/phpgwapi/inc/class.bocommon.inc.php

Removed Paths:
-------------
    trunk/eventplanner/inc/class.bocommon.inc.php
    trunk/eventplanner/inc/class.uicommon.inc.php

Modified: trunk/eventplanner/inc/class.boapplication.inc.php
===================================================================
--- trunk/eventplanner/inc/class.boapplication.inc.php  2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.boapplication.inc.php  2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
           along with this program.  If not, see <http://www.gnu.org/licenses/>.
         */
 
-       phpgw::import_class('eventplanner.bocommon');
+       phpgw::import_class('phpgwapi.bocommon');
        phpgw::import_class('eventplanner.soapplication');
 
        include_class('eventplanner', 'application', 'inc/model/');
 
-       class eventplanner_boapplication extends eventplanner_bocommon
+       class eventplanner_boapplication extends phpgwapi_bocommon
        {
                protected static
                        $bo,

Modified: trunk/eventplanner/inc/class.bobooking.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bobooking.inc.php      2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.bobooking.inc.php      2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
           along with this program.  If not, see <http://www.gnu.org/licenses/>.
         */
 
-       phpgw::import_class('eventplanner.bocommon');
+       phpgw::import_class('phpgwapi.bocommon');
        phpgw::import_class('eventplanner.sobooking');
 
        include_class('eventplanner', 'booking', 'inc/model/');
 
-       class eventplanner_bobooking extends eventplanner_bocommon
+       class eventplanner_bobooking extends phpgwapi_bocommon
        {
                protected static
                        $bo,

Deleted: trunk/eventplanner/inc/class.bocommon.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bocommon.inc.php       2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.bocommon.inc.php       2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -1,177 +0,0 @@
-<?php
-       /**
-        * phpGroupWare
-        *
-        * @author Sigurd Nes <address@hidden>
-        * @copyright Copyright (C) 2016 Free Software Foundation 
http://www.fsf.org/
-        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License v2 or later
-        * @internal
-        * @package eventplanner
-        * @subpackage application
-        * @version $Id:$
-        */
-
-       /*
-          This program is free software: you can redistribute it and/or modify
-          it under the terms of the GNU General Public License as published by
-          the Free Software Foundation, either version 2 of the License, or
-          (at your option) any later version.
-
-          This program is distributed in the hope that it will be useful,
-          but WITHOUT ANY WARRANTY; without even the implied warranty of
-          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-          GNU Lesser General Public License for more details.
-
-          You should have received a copy of the GNU General Public License
-          along with this program.  If not, see <http://www.gnu.org/licenses/>.
-        */
-
-
-       abstract class eventplanner_bocommon
-       {
-
-               protected static
-                       $fields,
-                       $acl_location;
-
-
-               public function __construct()
-               {
-               }
-
-
-               /*
-                * Get the filters and search parametres for table-listings
-                */
-               public function build_default_read_params()
-               {
-                       $fields = $this->fields;
-
-                       $search = phpgw::get_var('search');
-                       $query =  phpgw::get_var('query');
-                       $order = phpgw::get_var('order');
-                       $draw = phpgw::get_var('draw', 'int');
-                       $columns = phpgw::get_var('columns');
-
-                       $params = array(
-                               'start' => phpgw::get_var('start', 'int', 
'REQUEST', 0),
-                               'results' => phpgw::get_var('length', 'int', 
'REQUEST', 0),
-                               'query' => $query ? $query : $search['value'],
-                               'sort' => $columns[$order[0]['column']]['data'],
-                               'dir' => $order[0]['dir'],
-                               'allrows' => phpgw::get_var('length', 'int') == 
-1,
-                       );
-
-                       foreach ($fields as $field => $_params)
-                       {
-                               if (!empty($_REQUEST["filter_$field"]))
-                               {
-                                       $params['filters'][$field] = 
phpgw::get_var("filter_$field", $_params['type']);
-                               }
-                       }
-
-                       return $params;
-               }
-
-               /**
-                * Insert values prosted from form
-                * @param object $object
-                * @return object
-                */
-               public function populate($object)
-               {
-                       $fields = $this->fields;
-
-                       foreach ($fields as $field      => $field_info)
-                       {
-                               if(($field_info['action'] & PHPGW_ACL_ADD) ||  
($field_info['action'] & PHPGW_ACL_EDIT))
-                               {
-                                       if($field_info['type'] == 'json')
-                                       {
-                                               $values = array();
-                                               $custom_fields = 
$object->get_custom_fields();
-                                               $values_attribute = 
phpgw::get_var('values_attribute');
-
-                                               foreach ($custom_fields as $key 
=> $custom_field)
-                                               {
-                                                       
$values[$custom_field['name']] = $values_attribute[$key]['value'];
-                                               }
-                                               $object->set_field( $field, 
$values);
-                                       }
-                                       else
-                                       {
-                                               $object->set_field( $field, 
phpgw::get_var($field, $field_info['type'] ) );
-                                       }
-                               }
-                       }
-                       $values_attribute = phpgw::get_var('values_attribute');
-                       $object->set_field( 'values_attribute', 
$values_attribute);
-
-                       return $object;
-               }
-
-               public abstract function store( $object );
-
-
-               /**
-                * Perform custom actions defined per location before storing 
object to database
-                * @param object $object
-                */
-               public function store_pre_commit( &$object )
-               {
-                       $criteria = array(
-                               'appname' => 'eventplanner',
-                               'location' => $this->acl_location,
-                               'pre_commit' => true,
-                               'allrows' => true
-                       );
-
-                       $custom_functions = 
$GLOBALS['phpgw']->custom_functions->find($criteria);
-
-                       foreach ($custom_functions as $entry)
-                       {
-                               // prevent path traversal
-                               if (preg_match('/\.\./', $entry['file_name']))
-                               {
-                                       continue;
-                               }
-
-                               $file = PHPGW_SERVER_ROOT . 
"/eventplanner/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
-                               if ($entry['active'] && is_file($file) && 
!$entry['client_side'] && $entry['pre_commit'])
-                               {
-                                       require $file;
-                               }
-                       }
-               }
-
-               /**
-                * Perform custom actions defined per location after storing 
object to database
-                * @param object $object
-                */
-               public function store_post_commit( &$object )
-               {
-                       $criteria = array(
-                               'appname' => 'eventplanner',
-                               'location' => $this->acl_location,
-                               'allrows' => true
-                       );
-
-                       $custom_functions = 
$GLOBALS['phpgw']->custom_functions->find($criteria);
-
-
-                       foreach ($custom_functions as $entry)
-                       {
-                               // prevent path traversal
-                               if (preg_match('/\.\./', $entry['file_name']))
-                               {
-                                       continue;
-                               }
-
-                               $file = PHPGW_SERVER_ROOT . 
"/eventplanner/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
-                               if ($entry['active'] && is_file($file) && 
!$entry['client_side'] && !$entry['pre_commit'])
-                               {
-                                       require $file;
-                               }
-                       }
-               }
-       }
\ No newline at end of file

Modified: trunk/eventplanner/inc/class.bocustomer.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bocustomer.inc.php     2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.bocustomer.inc.php     2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
           along with this program.  If not, see <http://www.gnu.org/licenses/>.
         */
 
-       phpgw::import_class('eventplanner.bocommon');
+       phpgw::import_class('phpgwapi.bocommon');
        phpgw::import_class('eventplanner.socustomer');
 
        include_class('eventplanner', 'customer', 'inc/model/');
 
-       class eventplanner_bocustomer extends eventplanner_bocommon
+       class eventplanner_bocustomer extends phpgwapi_bocommon
        {
                protected static
                        $bo,

Modified: trunk/eventplanner/inc/class.boresource.inc.php
===================================================================
--- trunk/eventplanner/inc/class.boresource.inc.php     2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.boresource.inc.php     2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
           along with this program.  If not, see <http://www.gnu.org/licenses/>.
         */
 
-       phpgw::import_class('eventplanner.bocommon');
+       phpgw::import_class('phpgwapi.bocommon');
        phpgw::import_class('eventplanner.soresource');
 
        include_class('eventplanner', 'resource', 'inc/model/');
 
-       class eventplanner_boresource extends eventplanner_bocommon
+       class eventplanner_boresource extends phpgwapi_bocommon
        {
                protected static
                        $bo,

Modified: trunk/eventplanner/inc/class.bovendor.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bovendor.inc.php       2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.bovendor.inc.php       2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
           along with this program.  If not, see <http://www.gnu.org/licenses/>.
         */
 
-       phpgw::import_class('eventplanner.bocommon');
+       phpgw::import_class('phpgwapi.bocommon');
        phpgw::import_class('eventplanner.sovendor');
 
        include_class('eventplanner', 'vendor', 'inc/model/');
 
-       class eventplanner_bovendor extends eventplanner_bocommon
+       class eventplanner_bovendor extends phpgwapi_bocommon
        {
                protected static
                        $bo,

Modified: trunk/eventplanner/inc/class.bovendor_report.inc.php
===================================================================
--- trunk/eventplanner/inc/class.bovendor_report.inc.php        2016-12-29 
10:59:33 UTC (rev 16117)
+++ trunk/eventplanner/inc/class.bovendor_report.inc.php        2016-12-29 
11:00:30 UTC (rev 16118)
@@ -26,12 +26,12 @@
           along with this program.  If not, see <http://www.gnu.org/licenses/>.
         */
 
-       phpgw::import_class('eventplanner.bocommon');
+       phpgw::import_class('phpgwapi.bocommon');
        phpgw::import_class('eventplanner.sovendor_report');
 
        include_class('eventplanner', 'vendor_report', 'inc/model/');
 
-       class eventplanner_bovendor_report extends eventplanner_bocommon
+       class eventplanner_bovendor_report extends phpgwapi_bocommon
        {
                protected static
                        $bo,

Modified: trunk/eventplanner/inc/class.uiapplication.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uiapplication.inc.php  2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.uiapplication.inc.php  2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
         * @subpackage application
         * @version $Id: $
         */
-       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.uicommon');
        phpgw::import_class('phpgwapi.datetime');
 
        include_class('eventplanner', 'application', 'inc/model/');
 
-       class eventplanner_uiapplication extends eventplanner_uicommon
+       class eventplanner_uiapplication extends phpgwapi_uicommon
        {
 
                public $public_functions = array(

Modified: trunk/eventplanner/inc/class.uibooking.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uibooking.inc.php      2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.uibooking.inc.php      2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
         * @subpackage booking
         * @version $Id: $
         */
-       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.uicommon');
        phpgw::import_class('phpgwapi.datetime');
 
        include_class('eventplanner', 'booking', 'inc/model/');
 
-       class eventplanner_uibooking extends eventplanner_uicommon
+       class eventplanner_uibooking extends phpgwapi_uicommon
        {
 
                public $public_functions = array(

Deleted: trunk/eventplanner/inc/class.uicommon.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uicommon.inc.php       2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.uicommon.inc.php       2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -1,414 +0,0 @@
-<?php
-/**
-        * phpGroupWare - eventplanner: a part of a Facilities Management 
System.
-        *
-        * @author Sigurd Nes <address@hidden>
-        * @copyright Copyright (C) 2016 Free Software Foundation, Inc. 
http://www.fsf.org/
-        * This file is part of phpGroupWare.
-        *
-        * phpGroupWare is free software; you can redistribute it and/or modify
-        * it under the terms of the GNU General Public License as published by
-        * the Free Software Foundation; either version 2 of the License, or
-        * (at your option) any later version.
-        *
-        * phpGroupWare is distributed in the hope that it will be useful,
-        * but WITHOUT ANY WARRANTY; without even the implied warranty of
-        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-        * GNU General Public License for more details.
-        *
-        * You should have received a copy of the GNU General Public License
-        * along with phpGroupWare; if not, write to the Free Software
-        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
-        *
-        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset
-        * @package eventplanner
-        * @subpackage common
-        * @version $Id: $
-        */
-       phpgw::import_class('phpgwapi.uicommon_jquery');
-       phpgw::import_class('phpgwapi.datetime');
-
-
-       class eventplanner_uicommon extends phpgwapi_uicommon_jquery
-       {
-
-               public $public_functions = array(
-                       'add' => true,
-                       'index' => true,
-                       'query' => true,
-                       'view' => true,
-                       'edit' => true,
-                       'save' => true,
-               );
-
-               protected
-                       $fields,
-                       $composite_types,
-                       $payment_methods,
-                       $permissions,
-                       $called_class_arr;
-
-               public function __construct()
-               {
-                       parent::__construct();
-                       $called_class = get_called_class();
-                       $this->called_class_arr = explode('_', $called_class, 
2);
-               }
-
-
-               protected function _get_fields()
-               {
-                       $values = array();
-                       foreach ($this->fields as $field => $field_info)
-                       {
-                               if($field_info['action'] & PHPGW_ACL_READ)
-                               {
-                                       $label = 
!empty($field_info['translated_label'])  ? $field_info['translated_label'] :'';
-                                       if(!$label)
-                                       {
-                                               $label 
=!empty($field_info['label']) ? lang($field_info['label']) : $field;
-                                       }
-
-                                       $data = array(
-                                               'key' => $field,
-                                               'label' =>  $label,
-                                               'sortable' => 
!empty($field_info['sortable']) ? true : false,
-                                               'hidden' => 
!empty($field_info['hidden']) ? true : false,
-                                       );
-
-                                       if(!empty($field_info['formatter']))
-                                       {
-                                               $data['formatter'] = 
$field_info['formatter'];
-                                       }
-
-                                       $values[] = $data;
-                               }
-                       }
-                       return $values;
-               }
-
-               /*
-                * View the price item with the id given in the http variable 
'id'
-                */
-
-               public function view()
-               {
-                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('view');
-
-                       if (empty($this->permissions[PHPGW_ACL_READ]))
-                       {
-                               phpgw::no_access();
-                       }
-
-                       $this->edit(array(), 'view');
-               }
-       /*
-                * To be removed
-                * Add a new  item to the database.  Requires only a title.
-                */
-
-               public function add()
-               {
-                       if (empty($this->permissions[PHPGW_ACL_ADD]))
-                       {
-                               phpgw::no_access();
-                       }
-
-                       $this->edit();
-               }
-
-               public function save($ajax = false)
-               {
-                       $called_class = get_called_class();
-
-                       if (empty($this->permissions[PHPGW_ACL_ADD]))
-                       {
-                               phpgw::no_access();
-                       }
-                       $active_tab = phpgw::get_var('active_tab', 'string', 
'REQUEST', 'first_tab');
-
-                       $id = phpgw::get_var('id', 'int');
-
-                       $object = $this->bo->read_single($id, true);
-
-                       /*
-                        * Overrides with incoming data from POST
-                        */
-                       $object = $this->bo->populate($object);
-
-                       if($object->validate())
-                       {
-                               if($object->store($object))
-                               {
-                                       $this->_handle_files($object->get_id());
-
-                                       if($ajax)
-                                       {
-                                               
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
-                                               return array(
-                                                       'status_kode' => 'ok',
-                                                       'status' => lang('ok'),
-                                                       'msg' => 
lang('messages_saved_form')
-                                               );
-                                       }
-                                       else
-                                       {
-                                               
phpgwapi_cache::message_set(lang('messages_saved_form'), 'message');
-                                               self::redirect(array(
-                                                       'menuaction' => 
"{$this->called_class_arr[0]}.{$this->called_class_arr[1]}.edit",
-                                                       'id'            => 
$object->get_id(),
-                                                       'active_tab' => 
$active_tab
-                                                       )
-                                               );
-                                       }
-                               }
-                               else
-                               {
-                                       if($ajax)
-                                       {
-                                               
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
-                                               return array(
-                                                       'status_kode' => 
'error',
-                                                       'status' => 
lang('error'),
-                                                       'msg' => 
lang('messages_form_error')
-                                               );
-                                       }
-                                       else
-                                       {
-                                               
phpgwapi_cache::message_set(lang('messages_form_error'), 'error');
-                                               $this->edit(array('object'      
=> $object, 'active_tab' => $active_tab));
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               if($ajax)
-                               {
-                                       
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
-                                       return array(
-                                               'status_kode' => 'error',
-                                               'status' => lang('error'),
-                                               'msg' => lang('Did not 
validate')
-                                       );
-                               }
-                               else
-                               {
-                                       foreach ($this->fields as $field => 
$field_info)
-                                       {
-                                               $_temp = $object->$field;
-                                               if($_temp && !is_array($_temp))
-                                               {
-                                                       $object->$field = 
htmlspecialchars_decode(str_replace(array('&amp;','&#40;', '&#41;', 
'&#61;','&#8722;&#8722;','&#59;'), array('&','(', ')', '=', '--',';'), 
$_temp),ENT_QUOTES);
-                                               }
-                                       }
-
-                                       $this->edit(array('object'      => 
$object, 'active_tab' => $active_tab));
-                               }
-                       }
-               }
-
-               /**
-                * (non-PHPdoc)
-                * @see eventplanner/inc/eventplanner_uicommon#query()
-                */
-               public function query()
-               {
-                       $params = $this->bo->build_default_read_params();
-                       $values = $this->bo->read($params);
-                       array_walk($values["results"], array($this, 
"_add_links"), 
"{$this->called_class_arr[0]}.{$this->called_class_arr[1]}.edit");
-
-                       return $this->jquery_results($values);
-               }
-
-               /**
-                * Called from  subclasses
-                * @param type $id
-                */
-               protected function _handle_files( $fakebase, $sub_module, $id  )
-               {
-                       $id = (int)$id;
-                       if (!$id)
-                       {
-                               throw new Exception(__CLASS__.'::' . 
__FUNCTION__.'() - missing id');
-                       }
-                       if (!$sub_module)
-                       {
-                               throw new Exception(__CLASS__.'::' . 
__FUNCTION__.'() - missing sub_module');
-                       }
-                       if (!$fakebase)
-                       {
-                               throw new Exception(__CLASS__.'::' . 
__FUNCTION__.'() - missing fakebase');
-                       }
-
-                       $bofiles = CreateObject('property.bofiles', '/' . 
ltrim($fakebase, '/'));
-
-                       if (isset($_POST['delete_file']) && 
is_array($_POST['delete_file']))
-                       {
-                               
$bofiles->delete_file("/{$sub_module}/{$id}/",array('file_action' => 
$_POST['delete_file']));
-                       }
-                       $file_name = str_replace(' ', '_', 
$_FILES['file']['name']);
-
-                       if ($file_name)
-                       {
-                               if (!is_file($_FILES['file']['tmp_name']))
-                               {
-                                       
phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
-                                       return;
-                               }
-
-                               $to_file = 
"{$bofiles->fakebase}/{$sub_module}/{$id}/{$file_name}";
-                               if ($bofiles->vfs->file_exists(array(
-                                               'string' => $to_file,
-                                               'relatives' => 
Array(RELATIVE_NONE)
-                                       )))
-                               {
-                                       phpgwapi_cache::message_set(lang('This 
file already exists !'), 'error');
-                               }
-                               else
-                               {
-                                       
$bofiles->create_document_dir("{$sub_module}/{$id}");
-                                       $bofiles->vfs->override_acl = 1;
-
-                                       if (!$bofiles->vfs->cp(array(
-                                                       'from' => 
$_FILES['file']['tmp_name'],
-                                                       'to' => $to_file,
-                                                       'relatives' => 
array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL))))
-                                       {
-                                               
phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
-                                       }
-                                       $bofiles->vfs->override_acl = 0;
-                               }
-                       }
-               }
-
-               public function get_files($fakebase, $sub_module, $menuaction,  
$id)
-               {
-
-                       if (empty($this->permissions[PHPGW_ACL_READ]))
-                       {
-                               phpgw::no_access();
-                       }
-
-                       $id = (int)$id;
-
-                       $vfs = CreateObject('phpgwapi.vfs');
-                       $vfs->override_acl = 1;
-
-                       $values = (array)$vfs->ls (array(
-                               'string' => "/{$fakebase}/{$sub_module}/{$id}",
-                               'relatives' => array(RELATIVE_NONE)));
-
-                       $vfs->override_acl = 0;
-
-                       $link_view_file = self::link(array('menuaction' => 
$menuaction));
-
-                       $content_files = array();
-                       $img_types = array(
-                               'image/jpeg',
-                               'image/png',
-                               'image/gif'
-                       );
-
-                       $lang_view =  lang('click to view file');
-                       $lang_delete =  lang('Check to delete file');
-                       $z = 0;
-                       foreach ($values as $_entry)
-                       {
-                               $content_files[] = array(
-                                       'file_name' => "<a 
href=\"{$link_view_file}&file_id={$_entry['file_id']}\" target=\"_blank\" 
title=\"{$lang_view}\">{$_entry['name']}</a>",
-                                       'delete_file' => "<input 
type=\"checkbox\" name=\"delete_file[]\" value=\"{$_entry['file_id']}\" 
title=\"{$lang_delete}\">",
-                               );
-                               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' => 
$menuaction,
-                                                       'file_id'       =>  
$_entry['file_id'],
-                                                       'file' => 
$_entry['directory'] . '/' . urlencode($_entry['name'])
-                                       ));
-                                       $content_files[$z]['thumbnail_flag'] = 
'thumb=1';
-                               }
-                               $z ++;
-                       }
-
-                       if (phpgw::get_var('phpgw_return_as') == 'json')
-                       {
-
-                               $total_records = count($content_files);
-
-                               return array
-                                       (
-                                       'data' => $content_files,
-                                       'draw' => phpgw::get_var('draw', 'int'),
-                                       'recordsTotal' => $total_records,
-                                       'recordsFiltered' => $total_records
-                               );
-                       }
-                       return $content_files;
-               }
-
-               public function view_file()
-               {
-                       $GLOBALS['phpgw_info']['flags']['noheader'] = true;
-                       $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
-                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
-
-                       if (empty($this->permissions[PHPGW_ACL_READ]))
-                       {
-                               phpgw::no_access();
-                       }
-
-                       $thumb = phpgw::get_var('thumb', 'bool');
-                       $file_id = phpgw::get_var('file_id', 'int');
-
-                       $bofiles = CreateObject('property.bofiles');
-
-                       if($file_id)
-                       {
-                               $file_info = $bofiles->vfs->get_info($file_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 ($file_id)
-                       {
-                               $bofiles->get_file($file_id);
-                       }
-                       else
-                       {
-                               $bofiles->view_file('', $file);
-                       }
-               }
-
-       }
\ No newline at end of file

Modified: trunk/eventplanner/inc/class.uicustomer.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uicustomer.inc.php     2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.uicustomer.inc.php     2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
         * @subpackage customer
         * @version $Id: $
         */
-       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.uicommon');
        phpgw::import_class('phpgwapi.datetime');
 
        include_class('eventplanner', 'customer', 'inc/model/');
 
-       class eventplanner_uicustomer extends eventplanner_uicommon
+       class eventplanner_uicustomer extends phpgwapi_uicommon
        {
 
                public $public_functions = array(

Modified: trunk/eventplanner/inc/class.uiresource.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uiresource.inc.php     2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.uiresource.inc.php     2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,13 +26,13 @@
         * @subpackage resource
         * @version $Id: $
         */
-       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.uicommon');
        phpgw::import_class('phpgwapi.datetime');
 
        include_class('eventplanner', 'resource', 'inc/model/');
        use eventplanner_resource;
 
-       class eventplanner_uiresource extends eventplanner_uicommon
+       class eventplanner_uiresource extends phpgwapi_uicommon
        {
 
                public $public_functions = array(

Modified: trunk/eventplanner/inc/class.uivendor.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uivendor.inc.php       2016-12-29 10:59:33 UTC 
(rev 16117)
+++ trunk/eventplanner/inc/class.uivendor.inc.php       2016-12-29 11:00:30 UTC 
(rev 16118)
@@ -26,12 +26,12 @@
         * @subpackage vendor
         * @version $Id: $
         */
-       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.uicommon');
        phpgw::import_class('phpgwapi.datetime');
 
        include_class('eventplanner', 'vendor', 'inc/model/');
 
-       class eventplanner_uivendor extends eventplanner_uicommon
+       class eventplanner_uivendor extends phpgwapi_uicommon
        {
 
                public $public_functions = array(

Modified: trunk/eventplanner/inc/class.uivendor_report.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uivendor_report.inc.php        2016-12-29 
10:59:33 UTC (rev 16117)
+++ trunk/eventplanner/inc/class.uivendor_report.inc.php        2016-12-29 
11:00:30 UTC (rev 16118)
@@ -26,12 +26,12 @@
         * @subpackage vendor_report
         * @version $Id: $
         */
-       phpgw::import_class('eventplanner.uicommon');
+       phpgw::import_class('phpgwapi.uicommon');
        phpgw::import_class('phpgwapi.datetime');
 
        include_class('eventplanner', 'vendor_report', 'inc/model/');
 
-       class eventplanner_uivendor_report extends eventplanner_uicommon
+       class eventplanner_uivendor_report extends phpgwapi_uicommon
        {
 
                public $public_functions = array(

Added: trunk/phpgwapi/inc/class.bocommon.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.bocommon.inc.php                           (rev 0)
+++ trunk/phpgwapi/inc/class.bocommon.inc.php   2016-12-29 11:00:30 UTC (rev 
16118)
@@ -0,0 +1,177 @@
+<?php
+       /**
+        * phpGroupWare
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2016 Free Software Foundation 
http://www.fsf.org/
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License v2 or later
+        * @internal
+        * @package phpgwapi
+        * @subpackage utilities
+        * @version $Id:$
+        */
+
+       /*
+          This program is free software: you can redistribute it and/or modify
+          it under the terms of the GNU General Public License as published by
+          the Free Software Foundation, either version 2 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU Lesser General Public License for more details.
+
+          You should have received a copy of the GNU General Public License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+
+       abstract class phpgwapi_bocommon
+       {
+
+               protected static
+                       $fields,
+                       $acl_location;
+
+
+               public function __construct()
+               {
+               }
+
+
+               /*
+                * Get the filters and search parametres for table-listings
+                */
+               public function build_default_read_params()
+               {
+                       $fields = $this->fields;
+
+                       $search = phpgw::get_var('search');
+                       $query =  phpgw::get_var('query');
+                       $order = phpgw::get_var('order');
+                       $draw = phpgw::get_var('draw', 'int');
+                       $columns = phpgw::get_var('columns');
+
+                       $params = array(
+                               'start' => phpgw::get_var('start', 'int', 
'REQUEST', 0),
+                               'results' => phpgw::get_var('length', 'int', 
'REQUEST', 0),
+                               'query' => $query ? $query : $search['value'],
+                               'sort' => $columns[$order[0]['column']]['data'],
+                               'dir' => $order[0]['dir'],
+                               'allrows' => phpgw::get_var('length', 'int') == 
-1,
+                       );
+
+                       foreach ($fields as $field => $_params)
+                       {
+                               if (!empty($_REQUEST["filter_$field"]))
+                               {
+                                       $params['filters'][$field] = 
phpgw::get_var("filter_$field", $_params['type']);
+                               }
+                       }
+
+                       return $params;
+               }
+
+               /**
+                * Insert values prosted from form
+                * @param object $object
+                * @return object
+                */
+               public function populate($object)
+               {
+                       $fields = $this->fields;
+
+                       foreach ($fields as $field      => $field_info)
+                       {
+                               if(($field_info['action'] & PHPGW_ACL_ADD) ||  
($field_info['action'] & PHPGW_ACL_EDIT))
+                               {
+                                       if($field_info['type'] == 'json')
+                                       {
+                                               $values = array();
+                                               $custom_fields = 
$object->get_custom_fields();
+                                               $values_attribute = 
phpgw::get_var('values_attribute');
+
+                                               foreach ($custom_fields as $key 
=> $custom_field)
+                                               {
+                                                       
$values[$custom_field['name']] = $values_attribute[$key]['value'];
+                                               }
+                                               $object->set_field( $field, 
$values);
+                                       }
+                                       else
+                                       {
+                                               $object->set_field( $field, 
phpgw::get_var($field, $field_info['type'] ) );
+                                       }
+                               }
+                       }
+                       $values_attribute = phpgw::get_var('values_attribute');
+                       $object->set_field( 'values_attribute', 
$values_attribute);
+
+                       return $object;
+               }
+
+               public abstract function store( $object );
+
+
+               /**
+                * Perform custom actions defined per location before storing 
object to database
+                * @param object $object
+                */
+               public function store_pre_commit( &$object )
+               {
+                       $criteria = array(
+                               'appname' => 'eventplanner',
+                               'location' => $this->acl_location,
+                               'pre_commit' => true,
+                               'allrows' => true
+                       );
+
+                       $custom_functions = 
$GLOBALS['phpgw']->custom_functions->find($criteria);
+
+                       foreach ($custom_functions as $entry)
+                       {
+                               // prevent path traversal
+                               if (preg_match('/\.\./', $entry['file_name']))
+                               {
+                                       continue;
+                               }
+
+                               $file = PHPGW_SERVER_ROOT . 
"/eventplanner/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+                               if ($entry['active'] && is_file($file) && 
!$entry['client_side'] && $entry['pre_commit'])
+                               {
+                                       require $file;
+                               }
+                       }
+               }
+
+               /**
+                * Perform custom actions defined per location after storing 
object to database
+                * @param object $object
+                */
+               public function store_post_commit( &$object )
+               {
+                       $criteria = array(
+                               'appname' => 'eventplanner',
+                               'location' => $this->acl_location,
+                               'allrows' => true
+                       );
+
+                       $custom_functions = 
$GLOBALS['phpgw']->custom_functions->find($criteria);
+
+
+                       foreach ($custom_functions as $entry)
+                       {
+                               // prevent path traversal
+                               if (preg_match('/\.\./', $entry['file_name']))
+                               {
+                                       continue;
+                               }
+
+                               $file = PHPGW_SERVER_ROOT . 
"/eventplanner/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+                               if ($entry['active'] && is_file($file) && 
!$entry['client_side'] && !$entry['pre_commit'])
+                               {
+                                       require $file;
+                               }
+                       }
+               }
+       }
\ No newline at end of file

Modified: trunk/phpgwapi/inc/class.uicommon.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.uicommon.inc.php   2016-12-29 10:59:33 UTC (rev 
16117)
+++ trunk/phpgwapi/inc/class.uicommon.inc.php   2016-12-29 11:00:30 UTC (rev 
16118)
@@ -1,40 +1,414 @@
 <?php
-       /**
-       * phpGroupWare
-       *
-       * @author Erink Holm-Larsen <address@hidden>
-       * @author Torstein Vadla <address@hidden>
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2012 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare is free software; you can redistribute it and/or modify
-       * it under the terms of the GNU General Public License as published by
-       * the Free Software Foundation; either version 2 of the License, or
-       * (at your option) any later version.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
-       * @package phpgwapi
-       * @subpackage utilities
-       * @version $Id$
-       */      
-
+/**
+        * phpGroupWare
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2016 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/ and Nordlandssykehuset HF
+        * @package phpgwapi
+        * @subpackage utilities
+        * @version $Id$
+        */
        phpgw::import_class('phpgwapi.uicommon_jquery');
+       phpgw::import_class('phpgwapi.datetime');
 
-       abstract class phpgwapi_uicommon extends phpgwapi_uicommon_jquery
-                       {
+
+       class phpgwapi_uicommon extends phpgwapi_uicommon_jquery
+       {
+
+               public $public_functions = array(
+                       'add' => true,
+                       'index' => true,
+                       'query' => true,
+                       'view' => true,
+                       'edit' => true,
+                       'save' => true,
+               );
+
+               protected
+                       $fields,
+                       $composite_types,
+                       $payment_methods,
+                       $permissions,
+                       $called_class_arr;
+
                public function __construct()
                {
                        parent::__construct();
+                       $called_class = get_called_class();
+                       $this->called_class_arr = explode('_', $called_class, 
2);
                }
-       }
+
+
+               protected function _get_fields()
+               {
+                       $values = array();
+                       foreach ($this->fields as $field => $field_info)
+                       {
+                               if($field_info['action'] & PHPGW_ACL_READ)
+                               {
+                                       $label = 
!empty($field_info['translated_label'])  ? $field_info['translated_label'] :'';
+                                       if(!$label)
+                                       {
+                                               $label 
=!empty($field_info['label']) ? lang($field_info['label']) : $field;
+                                       }
+
+                                       $data = array(
+                                               'key' => $field,
+                                               'label' =>  $label,
+                                               'sortable' => 
!empty($field_info['sortable']) ? true : false,
+                                               'hidden' => 
!empty($field_info['hidden']) ? true : false,
+                                       );
+
+                                       if(!empty($field_info['formatter']))
+                                       {
+                                               $data['formatter'] = 
$field_info['formatter'];
+                                       }
+
+                                       $values[] = $data;
+                               }
+                       }
+                       return $values;
+               }
+
+               /*
+                * View the price item with the id given in the http variable 
'id'
+                */
+
+               public function view()
+               {
+                       $GLOBALS['phpgw_info']['flags']['app_header'] .= '::' . 
lang('view');
+
+                       if (empty($this->permissions[PHPGW_ACL_READ]))
+                       {
+                               phpgw::no_access();
+                       }
+
+                       $this->edit(array(), 'view');
+               }
+       /*
+                * To be removed
+                * Add a new  item to the database.  Requires only a title.
+                */
+
+               public function add()
+               {
+                       if (empty($this->permissions[PHPGW_ACL_ADD]))
+                       {
+                               phpgw::no_access();
+                       }
+
+                       $this->edit();
+               }
+
+               public function save($ajax = false)
+               {
+                       $called_class = get_called_class();
+
+                       if (empty($this->permissions[PHPGW_ACL_ADD]))
+                       {
+                               phpgw::no_access();
+                       }
+                       $active_tab = phpgw::get_var('active_tab', 'string', 
'REQUEST', 'first_tab');
+
+                       $id = phpgw::get_var('id', 'int');
+
+                       $object = $this->bo->read_single($id, true);
+
+                       /*
+                        * Overrides with incoming data from POST
+                        */
+                       $object = $this->bo->populate($object);
+
+                       if($object->validate())
+                       {
+                               if($object->store($object))
+                               {
+                                       $this->_handle_files($object->get_id());
+
+                                       if($ajax)
+                                       {
+                                               
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                               return array(
+                                                       'status_kode' => 'ok',
+                                                       'status' => lang('ok'),
+                                                       'msg' => 
lang('messages_saved_form')
+                                               );
+                                       }
+                                       else
+                                       {
+                                               
phpgwapi_cache::message_set(lang('messages_saved_form'), 'message');
+                                               self::redirect(array(
+                                                       'menuaction' => 
"{$this->called_class_arr[0]}.{$this->called_class_arr[1]}.edit",
+                                                       'id'            => 
$object->get_id(),
+                                                       'active_tab' => 
$active_tab
+                                                       )
+                                               );
+                                       }
+                               }
+                               else
+                               {
+                                       if($ajax)
+                                       {
+                                               
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                               return array(
+                                                       'status_kode' => 
'error',
+                                                       'status' => 
lang('error'),
+                                                       'msg' => 
lang('messages_form_error')
+                                               );
+                                       }
+                                       else
+                                       {
+                                               
phpgwapi_cache::message_set(lang('messages_form_error'), 'error');
+                                               $this->edit(array('object'      
=> $object, 'active_tab' => $active_tab));
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               if($ajax)
+                               {
+                                       
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                       return array(
+                                               'status_kode' => 'error',
+                                               'status' => lang('error'),
+                                               'msg' => lang('Did not 
validate')
+                                       );
+                               }
+                               else
+                               {
+                                       foreach ($this->fields as $field => 
$field_info)
+                                       {
+                                               $_temp = $object->$field;
+                                               if($_temp && !is_array($_temp))
+                                               {
+                                                       $object->$field = 
htmlspecialchars_decode(str_replace(array('&amp;','&#40;', '&#41;', 
'&#61;','&#8722;&#8722;','&#59;'), array('&','(', ')', '=', '--',';'), 
$_temp),ENT_QUOTES);
+                                               }
+                                       }
+
+                                       $this->edit(array('object'      => 
$object, 'active_tab' => $active_tab));
+                               }
+                       }
+               }
+
+               /**
+                * (non-PHPdoc)
+                * @see eventplanner/inc/eventplanner_uicommon#query()
+                */
+               public function query()
+               {
+                       $params = $this->bo->build_default_read_params();
+                       $values = $this->bo->read($params);
+                       array_walk($values["results"], array($this, 
"_add_links"), 
"{$this->called_class_arr[0]}.{$this->called_class_arr[1]}.edit");
+
+                       return $this->jquery_results($values);
+               }
+
+               /**
+                * Called from  subclasses
+                * @param type $id
+                */
+               protected function _handle_files( $fakebase, $sub_module, $id  )
+               {
+                       $id = (int)$id;
+                       if (!$id)
+                       {
+                               throw new Exception(__CLASS__.'::' . 
__FUNCTION__.'() - missing id');
+                       }
+                       if (!$sub_module)
+                       {
+                               throw new Exception(__CLASS__.'::' . 
__FUNCTION__.'() - missing sub_module');
+                       }
+                       if (!$fakebase)
+                       {
+                               throw new Exception(__CLASS__.'::' . 
__FUNCTION__.'() - missing fakebase');
+                       }
+
+                       $bofiles = CreateObject('property.bofiles', '/' . 
ltrim($fakebase, '/'));
+
+                       if (isset($_POST['delete_file']) && 
is_array($_POST['delete_file']))
+                       {
+                               
$bofiles->delete_file("/{$sub_module}/{$id}/",array('file_action' => 
$_POST['delete_file']));
+                       }
+                       $file_name = str_replace(' ', '_', 
$_FILES['file']['name']);
+
+                       if ($file_name)
+                       {
+                               if (!is_file($_FILES['file']['tmp_name']))
+                               {
+                                       
phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
+                                       return;
+                               }
+
+                               $to_file = 
"{$bofiles->fakebase}/{$sub_module}/{$id}/{$file_name}";
+                               if ($bofiles->vfs->file_exists(array(
+                                               'string' => $to_file,
+                                               'relatives' => 
Array(RELATIVE_NONE)
+                                       )))
+                               {
+                                       phpgwapi_cache::message_set(lang('This 
file already exists !'), 'error');
+                               }
+                               else
+                               {
+                                       
$bofiles->create_document_dir("{$sub_module}/{$id}");
+                                       $bofiles->vfs->override_acl = 1;
+
+                                       if (!$bofiles->vfs->cp(array(
+                                                       'from' => 
$_FILES['file']['tmp_name'],
+                                                       'to' => $to_file,
+                                                       'relatives' => 
array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL))))
+                                       {
+                                               
phpgwapi_cache::message_set(lang('Failed to upload file !'), 'error');
+                                       }
+                                       $bofiles->vfs->override_acl = 0;
+                               }
+                       }
+               }
+
+               public function get_files($fakebase, $sub_module, $menuaction,  
$id)
+               {
+
+                       if (empty($this->permissions[PHPGW_ACL_READ]))
+                       {
+                               phpgw::no_access();
+                       }
+
+                       $id = (int)$id;
+
+                       $vfs = CreateObject('phpgwapi.vfs');
+                       $vfs->override_acl = 1;
+
+                       $values = (array)$vfs->ls (array(
+                               'string' => "/{$fakebase}/{$sub_module}/{$id}",
+                               'relatives' => array(RELATIVE_NONE)));
+
+                       $vfs->override_acl = 0;
+
+                       $link_view_file = self::link(array('menuaction' => 
$menuaction));
+
+                       $content_files = array();
+                       $img_types = array(
+                               'image/jpeg',
+                               'image/png',
+                               'image/gif'
+                       );
+
+                       $lang_view =  lang('click to view file');
+                       $lang_delete =  lang('Check to delete file');
+                       $z = 0;
+                       foreach ($values as $_entry)
+                       {
+                               $content_files[] = array(
+                                       'file_name' => "<a 
href=\"{$link_view_file}&file_id={$_entry['file_id']}\" target=\"_blank\" 
title=\"{$lang_view}\">{$_entry['name']}</a>",
+                                       'delete_file' => "<input 
type=\"checkbox\" name=\"delete_file[]\" value=\"{$_entry['file_id']}\" 
title=\"{$lang_delete}\">",
+                               );
+                               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' => 
$menuaction,
+                                                       'file_id'       =>  
$_entry['file_id'],
+                                                       'file' => 
$_entry['directory'] . '/' . urlencode($_entry['name'])
+                                       ));
+                                       $content_files[$z]['thumbnail_flag'] = 
'thumb=1';
+                               }
+                               $z ++;
+                       }
+
+                       if (phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+
+                               $total_records = count($content_files);
+
+                               return array
+                                       (
+                                       'data' => $content_files,
+                                       'draw' => phpgw::get_var('draw', 'int'),
+                                       'recordsTotal' => $total_records,
+                                       'recordsFiltered' => $total_records
+                               );
+                       }
+                       return $content_files;
+               }
+
+               public function view_file()
+               {
+                       $GLOBALS['phpgw_info']['flags']['noheader'] = true;
+                       $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
+                       $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+
+                       if (empty($this->permissions[PHPGW_ACL_READ]))
+                       {
+                               phpgw::no_access();
+                       }
+
+                       $thumb = phpgw::get_var('thumb', 'bool');
+                       $file_id = phpgw::get_var('file_id', 'int');
+
+                       $bofiles = CreateObject('property.bofiles');
+
+                       if($file_id)
+                       {
+                               $file_info = $bofiles->vfs->get_info($file_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 ($file_id)
+                       {
+                               $bofiles->get_file($file_id);
+                       }
+                       else
+                       {
+                               $bofiles->view_file('', $file);
+                       }
+               }
+
+       }
\ No newline at end of file




reply via email to

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