[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16110] more on rental
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16110] more on rental |
Date: |
Wed, 21 Dec 2016 20:03:24 +0000 (UTC) |
Revision: 16110
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16110
Author: sigurdne
Date: 2016-12-21 20:03:24 +0000 (Wed, 21 Dec 2016)
Log Message:
-----------
more on rental
Modified Paths:
--------------
trunk/eventplanner/inc/class.uicommon.inc.php
trunk/phpgwapi/inc/class.socommon.inc.php
trunk/phpgwapi/templates/mobilefrontend/navbar.inc.php
Added Paths:
-----------
trunk/mobilefrontend/rental/class.uimovein.inc.php
Modified: trunk/eventplanner/inc/class.uicommon.inc.php
===================================================================
--- trunk/eventplanner/inc/class.uicommon.inc.php 2016-12-21 20:03:02 UTC
(rev 16109)
+++ trunk/eventplanner/inc/class.uicommon.inc.php 2016-12-21 20:03:24 UTC
(rev 16110)
@@ -141,6 +141,8 @@
{
if($object->store($object))
{
+ $this->_handle_files($object->get_id());
+
if($ajax)
{
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
@@ -218,4 +220,195 @@
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
Added: trunk/mobilefrontend/rental/class.uimovein.inc.php
===================================================================
--- trunk/mobilefrontend/rental/class.uimovein.inc.php
(rev 0)
+++ trunk/mobilefrontend/rental/class.uimovein.inc.php 2016-12-21 20:03:24 UTC
(rev 16110)
@@ -0,0 +1,39 @@
+<?php
+ /**
+ * phpGroupWare - rental: a part of a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2011,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 rental
+ * @subpackage movein
+ * @version $Id: class.uitts.inc.php 14728 2016-02-11 22:28:46Z
sigurdne $
+ */
+ phpgw::import_class('rental.uimovein');
+
+ class mobilefrontend_uimovein extends rental_uimovein
+ {
+
+ public function __construct()
+ {
+ parent::__construct();
+ $GLOBALS['phpgw_info']['flags']['nonavbar'] = true;
+ }
+ }
\ No newline at end of file
Modified: trunk/phpgwapi/inc/class.socommon.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.socommon.inc.php 2016-12-21 20:03:02 UTC (rev
16109)
+++ trunk/phpgwapi/inc/class.socommon.inc.php 2016-12-21 20:03:24 UTC (rev
16110)
@@ -669,6 +669,7 @@
$value_set[$entry['name']] =
$entry['value'];
}
}
+ $object->values_attribute = $values_attribute;
// update with converted
}
$sql = "UPDATE {$this->table_name} SET "
Modified: trunk/phpgwapi/templates/mobilefrontend/navbar.inc.php
===================================================================
--- trunk/phpgwapi/templates/mobilefrontend/navbar.inc.php 2016-12-21
20:03:02 UTC (rev 16109)
+++ trunk/phpgwapi/templates/mobilefrontend/navbar.inc.php 2016-12-21
20:03:24 UTC (rev 16110)
@@ -20,6 +20,8 @@
$tts_text = lang('ticket');
$condition_survey_url = $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'property.uicondition_survey.index'));
$condition_survey_text =
$GLOBALS['phpgw']->translation->translate('condition survey', array(), false,
'property');
+ $movein_url = $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'rental.uimovein.index'));
+ $movein_text =
$GLOBALS['phpgw']->translation->translate('movein', array(), false, 'rental');
$moveout_url = $GLOBALS['phpgw']->link('/index.php',
array('menuaction' => 'rental.uimoveout.index'));
$moveout_text =
$GLOBALS['phpgw']->translation->translate('moveout', array(), false, 'rental');
@@ -39,6 +41,9 @@
<a href="{$condition_survey_url}"
class="pure-menu-link">{$condition_survey_text}</a>
</li>
<li class="pure-menu-item">
+ <a href="{$movein_url}"
class="pure-menu-link">{$movein_text}</a>
+ </li>
+ <li class="pure-menu-item">
<a href="{$moveout_url}"
class="pure-menu-link">{$moveout_text}</a>
</li>
</ul>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16110] more on rental,
sigurdne <=