update to only use new Api, incl. dependency to only api (no more phpgwapi and etemplate)

This commit is contained in:
Ralf Becker 2016-04-26 18:27:29 +00:00
parent 7bb134b273
commit 8b671d96f1
15 changed files with 218 additions and 233 deletions

View File

@ -5,11 +5,15 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet
* @copyright (c) 2005-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl;
if (!defined('TIMESHEET_APP'))
{
define('TIMESHEET_APP','timesheet');
@ -19,9 +23,9 @@ if (!defined('TIMESHEET_APP'))
/**
* Business object of the TimeSheet
*
* Uses eTemplate's so_sql as storage object (Table: egw_timesheet).
* Uses eTemplate's Api\Storage as storage object (Table: egw_timesheet).
*/
class timesheet_bo extends so_sql_cf
class timesheet_bo extends Api\Storage
{
/**
* Flag for timesheets deleted, but preserved
@ -29,7 +33,7 @@ class timesheet_bo extends so_sql_cf
const DELETED_STATUS = -1;
/**
* Timesheets config data
* Timesheets Api\Config data
*
* @var array
*/
@ -164,7 +168,7 @@ class timesheet_bo extends so_sql_cf
parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id');
if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value';
$this->config_data = config::read(TIMESHEET_APP);
$this->config_data = Api\Config::read(TIMESHEET_APP);
$this->quantity_sum = $this->config_data['quantity_sum'] == 'true';
// Load & process statuses
@ -220,7 +224,7 @@ class timesheet_bo extends so_sql_cf
$this->status_labels = array();
$this->make_status_labels($tree, $this->status_labels);
// Sort config based on tree
// Sort Api\Config based on tree
$sorted = array();
foreach($this->status_labels as $status_id => $label)
{
@ -286,7 +290,7 @@ class timesheet_bo extends so_sql_cf
{
if ($grant & $required)
{
$result[$uid] = common::grab_owner_name($uid);
$result[$uid] = Api\Accounts::username($uid);
}
}
natcasesort($result);
@ -297,7 +301,7 @@ class timesheet_bo extends so_sql_cf
/**
* checks if the user has enough rights for a certain operation
*
* Rights are given via status config admin/noadmin
* Rights are given via status Api\Config admin/noadmin
*
* @param array|int $data =null use $this->data or $this->data['ts_id'] (to fetch the data)
* @param int $user =null for which user to check, default current user
@ -331,9 +335,9 @@ class timesheet_bo extends so_sql_cf
/**
* checks if the user has enough rights for a certain operation
*
* Rights are given via owner grants or role based acl
* Rights are given via owner grants or role based Acl
*
* @param int $required EGW_ACL_READ, EGW_ACL_WRITE, EGW_ACL_ADD, EGW_ACL_DELETE, EGW_ACL_BUDGET, EGW_ACL_EDIT_BUDGET
* @param int $required Acl::READ, EGW_ACL_WRITE, Acl::ADD, Acl::DELETE, EGW_ACL_BUDGET, EGW_ACL_EDIT_BUDGET
* @param array|int $data =null project or project-id to use, default the project in $this->data
* @param int $user =null for which user to check, default current user
* @return boolean true if the rights are ok, null if not found, false if no rights
@ -363,7 +367,7 @@ class timesheet_bo extends so_sql_cf
}
$ret = $data && !!($grants[$data['ts_owner']] & $required);
if(($required & EGW_ACL_DELETE) && $this->config_data['history'] == 'history' &&
if(($required & Acl::DELETE) && $this->config_data['history'] == 'history' &&
$data['ts_status'] == self::DELETED_STATUS)
{
$ret = !!($GLOBALS['egw_info']['user']['apps']['admin']);
@ -382,7 +386,7 @@ class timesheet_bo extends so_sql_cf
*/
function date_filter($name,&$start,&$end)
{
return egw_time::sql_filter($name, $start, $end, 'ts_start', $this->date_filters);
return Api\DateTime::sql_filter($name, $start, $end, 'ts_start', $this->date_filters);
}
/**
@ -479,7 +483,7 @@ class timesheet_bo extends so_sql_cf
$only_summary && is_array($criteria) ? ($filter ? array_merge($criteria, (array)$filter) : $criteria) : $filter,
$only_summary ? '' : $join);
$this->summary = $this->summary[0];
$this->summary['max_modified'] = egw_time::server2user($this->summary['max_modified']);
$this->summary['max_modified'] = Api\DateTime::server2user($this->summary['max_modified']);
if ($only_summary) return $this->summary;
@ -528,7 +532,7 @@ class timesheet_bo extends so_sql_cf
* read a timesheet entry
*
* @param int $ts_id
* @param boolean $ignore_acl =false should the acl be checked
* @param boolean $ignore_acl =false should the Acl be checked
* @return array|boolean array with timesheet entry, null if timesheet not found or false if no rights
*/
function read($ts_id,$ignore_acl=false)
@ -538,7 +542,7 @@ class timesheet_bo extends so_sql_cf
{
return null; // entry not found
}
if (!$ignore_acl && !($ret = $this->check_acl(EGW_ACL_READ)))
if (!$ignore_acl && !($ret = $this->check_acl(Acl::READ)))
{
return false; // no read rights
}
@ -552,14 +556,14 @@ class timesheet_bo extends so_sql_cf
*
* @param array $keys if given $keys are copied to data before saveing => allows a save as
* @param boolean $touch_modified =true should modification date+user be set, default yes
* @param boolean $ignore_acl =false should the acl be checked, returns true if no edit-rigts
* @param boolean $ignore_acl =false should the Acl be checked, returns true if no edit-rigts
* @return int 0 on success and errno != 0 else
*/
function save($keys=null,$touch_modified=true,$ignore_acl=false)
{
if ($keys) $this->data_merge($keys);
if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(EGW_ACL_EDIT))
if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(Acl::EDIT))
{
return true;
}
@ -592,7 +596,7 @@ class timesheet_bo extends so_sql_cf
// Check for restore of deleted contact, restore held links
if($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS)
{
egw_link::restore(TIMESHEET_APP, $new['ts_id']);
Link::restore(TIMESHEET_APP, $new['ts_id']);
}
if (!is_object($this->tracking))
@ -608,7 +612,7 @@ class timesheet_bo extends so_sql_cf
if (!($err = parent::save()))
{
// notify the link-class about the update, as other apps may be subscribt to it
egw_link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
Link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
}
return $err;
@ -618,7 +622,7 @@ class timesheet_bo extends so_sql_cf
* deletes a timesheet entry identified by $keys or the loaded one, reimplemented to notify the link class (unlink)
*
* @param array $keys if given array with col => value pairs to characterise the rows to delete
* @param boolean $ignore_acl =false should the acl be checked, returns false if no delete-rigts
* @param boolean $ignore_acl =false should the Acl be checked, returns false if no delete-rigts
* @return int affected rows, should be 1 if ok, 0 if an error
*/
function delete($keys=null,$ignore_acl=false)
@ -629,7 +633,7 @@ class timesheet_bo extends so_sql_cf
}
$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
if (!$ignore_acl && !$this->check_acl(EGW_ACL_DELETE,$ts_id) || !($old = $this->read($ts_id)))
if (!$ignore_acl && !$this->check_acl(Acl::DELETE,$ts_id) || !($old = $this->read($ts_id)))
{
return false;
}
@ -640,12 +644,12 @@ class timesheet_bo extends so_sql_cf
$delete = $old;
$delete['ts_status'] = self::DELETED_STATUS;
$ret = !($this->save($delete));
egw_link::unlink(0,TIMESHEET_APP,$ts_id,'','','',true);
Link::unlink(0,TIMESHEET_APP,$ts_id,'','','',true);
}
elseif (($ret = parent::delete($keys)) && $ts_id)
{
// delete all links to timesheet entry $ts_id
egw_link::unlink(0,TIMESHEET_APP,$ts_id);
Link::unlink(0,TIMESHEET_APP,$ts_id);
}
return $ret;
}
@ -664,7 +668,7 @@ class timesheet_bo extends so_sql_cf
if (!$new_owner)
{
egw_link::unlink(0, TIMESHEET_APP, '', $account_id);
Link::unlink(0, TIMESHEET_APP, '', $account_id);
parent::delete(array('ts_owner' => $account_id));
}
else
@ -693,7 +697,7 @@ class timesheet_bo extends so_sql_cf
}
$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
if (!$this->check_acl(EGW_ACL_EDIT,$ts_id) || !$this->read($ts_id,true))
if (!$this->check_acl(Acl::EDIT,$ts_id) || !$this->read($ts_id,true))
{
return false;
}
@ -768,7 +772,7 @@ class timesheet_bo extends so_sql_cf
$titles[$entry['ts_id']] = $this->link_title($entry);
}
}
// we assume all not returned entries are not readable by the user, as we notify egw_link about all deletes
// we assume all not returned entries are not readable by the user, as we notify Link about all deletes
foreach($ids as $id)
{
if (!isset($titles[$id]))
@ -809,7 +813,7 @@ class timesheet_bo extends so_sql_cf
* Check access to the file store
*
* @param int|array $id id of entry or entry array
* @param int $check EGW_ACL_READ for read and EGW_ACL_EDIT for write or delete access
* @param int $check Acl::READ for read and Acl::EDIT for write or delete access
* @param string $rel_path =null currently not used in InfoLog
* @param int $user =null for which user to check, default current user
* @return boolean true if access is granted or false otherwise
@ -858,7 +862,7 @@ class timesheet_bo extends so_sql_cf
{
$pm_ids = ExecMethod('projectmanager.projectmanager_bo.children',$pm_id);
$pm_ids[] = $pm_id;
$links = solink::get_links('projectmanager',$pm_ids,'timesheet'); // solink::get_links not egw_links::get_links!
$links = Link\Storage::get_links('projectmanager',$pm_ids,'timesheet'); // Link\Storage::get_links not egw_links::get_links!
if ($links)
{
$links = array_unique(call_user_func_array('array_merge',$links));
@ -884,7 +888,7 @@ class timesheet_bo extends so_sql_cf
if ($data['target_app'] == 'projectmanager' && $this->read($data['id']))
{
$old_title = isset($data['data']) ? $data['data'][egw_link::OLD_LINK_TITLE] : null;
$old_title = isset($data['data']) ? $data['data'][Link::OLD_LINK_TITLE] : null;
switch($data['type'])
{
case 'link':
@ -893,7 +897,7 @@ class timesheet_bo extends so_sql_cf
isset($old_title) && $this->data['ts_project'] === $old_title)
{
$pm_id = $data['target_id'];
$update['ts_project'] = egw_link::title('projectmanager', $pm_id);
$update['ts_project'] = Link::title('projectmanager', $pm_id);
if (isset($old_title) && $this->data['ts_title'] === $old_title)
{
$update['ts_title'] = $update['ts_project'];
@ -914,7 +918,7 @@ class timesheet_bo extends so_sql_cf
{
$this->update($update);
// do NOT notify about title-change, as this will lead to an infinit loop!
// egw_link::notify_update(TIMESHEET_APP, $this->data['ts_id'],$this->data);
// Link::notify_update(TIMESHEET_APP, $this->data['ts_id'],$this->data);
//error_log(__METHOD__."() setting pm_id=$pm_id --> ".array2string($update));
}
}
@ -941,10 +945,10 @@ class timesheet_bo extends so_sql_cf
if (!isset($data['pm_id']) && $data['ts_id'])
{
$first_pm_id = null;
foreach(egw_link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
{
if (!isset($first_pm_id)) $first_pm_id = $pm_id;
if ($data['ts_project'] == egw_link::title('projectmanager', $pm_id))
if ($data['ts_project'] == Link::title('projectmanager', $pm_id))
{
$data['pm_id'] = $pm_id;
$data['ts_project_blur'] = $data['ts_project'];
@ -954,7 +958,7 @@ class timesheet_bo extends so_sql_cf
}
if (!isset($data['pm_id']) && isset($first_pm_id)) $data['pm_id'] = $first_pm_id;
}
elseif ($data['ts_id'] && $data['pm_id'] && egw_link::title('projectmanager', $data['pm_id']) == $data['ts_project'])
elseif ($data['ts_id'] && $data['pm_id'] && Link::title('projectmanager', $data['pm_id']) == $data['ts_project'])
{
$data['ts_project_blur'] = $data['ts_project'];
$data['ts_project'] = '';
@ -980,7 +984,7 @@ class timesheet_bo extends so_sql_cf
// allways store ts_project to be able to search for it, even if no custom project is set
if (empty($data['ts_project']) && !is_null($data['ts_project']))
{
$data['ts_project'] = $data['pm_id'] ? egw_link::title('projectmanager', $data['pm_id']) : '';
$data['ts_project'] = $data['pm_id'] ? Link::title('projectmanager', $data['pm_id']) : '';
}
return parent::data2db($intern ? null : $data); // important to use null, if $intern!
}

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -82,11 +82,13 @@ class timesheet_datasource extends datasource
*
* @param array $element source project element representing an InfoLog entry, $element['pe_app_id'] = info_id
* @param int $target target project id
* @param array $target_data=null data of target-project, atm not used by the infolog datasource
* @return array/boolean array(info_id,link_id) on success, false otherwise
* @param array $extra =null data of target-project, atm not used by the infolog datasource
* @return array|boolean array(info_id,link_id) on success, false otherwise
*/
function copy($element,$target,$extra=null)
{
unset($element,$target,$extra); // not used, but required by function signature
return false;
}

View File

@ -11,6 +11,8 @@
* @version $Id: class.egw_addressbook_record.inc.php 22827 2006-11-10 15:35:35Z nelius_weiss $
*/
use EGroupware\Api\Link;
/**
* class egw_addressbook_record
* compability layer for iface_egw_record needet for importexport
@ -84,7 +86,8 @@ class timesheet_egw_record implements importexport_iface_egw_record
*
*@return string title
*/
public function get_title() {
public function get_title()
{
// TODO get_record gibts nicht ?
// if (empty($this->timesheetentry)) {
// $this->get_record();
@ -102,8 +105,8 @@ class timesheet_egw_record implements importexport_iface_egw_record
$this->timesheetentry = $_record;
// Check for linked project ID
if($this->timesheetentry['ts_project']) {
$links = egw_link::get_links('timesheet', $_record['ts_id'], 'projectmanager');
foreach($links as $link_id => $app_id) {
$links = Link::get_links('timesheet', $_record['ts_id'], 'projectmanager');
foreach($links as $app_id) {
$this->timesheetentry['pm_id'] = $app_id;
break;
}
@ -135,7 +138,7 @@ class timesheet_egw_record implements importexport_iface_egw_record
* @return string identifier
*/
public function save ( $_dst_identifier ) {
unset($_dst_identifier);
}
/**
@ -145,7 +148,7 @@ class timesheet_egw_record implements importexport_iface_egw_record
* @return string dst_identifier
*/
public function copy ( $_dst_identifier ) {
unset($_dst_identifier);
}
/**
@ -156,7 +159,7 @@ class timesheet_egw_record implements importexport_iface_egw_record
* @return string dst_identifier
*/
public function move ( $_dst_identifier ) {
unset($_dst_identifier);
}
/**

View File

@ -9,13 +9,16 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* The timesheet_list_portlet uses a nextmatch / favorite
* to display a list of entries.
*/
class timesheet_favorite_portlet extends home_favorite_portlet
{
/**
* Construct the portlet
*
@ -39,7 +42,7 @@ class timesheet_favorite_portlet extends home_favorite_portlet
);
}
public function exec($id = null, etemplate_new &$etemplate = null)
public function exec($id = null, Etemplate &$etemplate = null)
{
$ui = new timesheet_ui();
@ -51,7 +54,7 @@ class timesheet_favorite_portlet extends home_favorite_portlet
$date_filters['custom'] = 'custom';
$this->context['sel_options']['filter'] = $date_filters;
$this->context['sel_options']['filter2'] = array('No details','Details');
$read_grants = $ui->grant_list(EGW_ACL_READ);
$read_grants = $ui->grant_list(Acl::READ);
$this->context['sel_options'] += array(
'ts_owner' => $read_grants,
'pm_id' => array(lang('No project')),
@ -84,7 +87,7 @@ class timesheet_favorite_portlet extends home_favorite_portlet
* output is handled by parent.
*
* @param type $id
* @param etemplate_new $etemplate
* @param Etemplate $etemplate
*/
public static function process($content = array())
{
@ -109,7 +112,7 @@ class timesheet_favorite_portlet extends home_favorite_portlet
if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
{
$msg = lang('You need to select some entries first!');
egw_json_response::get()->apply('egw.message',array($msg,'error'));
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
}
else
{
@ -119,21 +122,20 @@ class timesheet_favorite_portlet extends home_favorite_portlet
{
$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
egw_json_response::get()->apply('egw.message',array($msg,'success'));
Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
foreach($content['nm']['selected'] as &$id)
{
$id = 'timesheet::'.$id;
}
// Directly request an update - this will get timesheet tab too
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
}
elseif(empty($msg))
{
$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
}
egw_json_response::get()->apply('egw.message',array($msg,'error'));
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
}
}
}
}

View File

@ -10,6 +10,12 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
if (!defined('TIMESHEET_APP'))
{
define('TIMESHEET_APP','timesheet');
@ -74,7 +80,7 @@ class timesheet_hooks
*/
static function cumulate($param)
{
$links = egw_link::get_3links(TIMESHEET_APP,'projectmanager',$param['pm_id']);
$links = Link::get_3links(TIMESHEET_APP,'projectmanager',$param['pm_id']);
$rows = array();
foreach($links as $link)
@ -93,7 +99,7 @@ class timesheet_hooks
}
/**
* hooks to build projectmanager's sidebox-menu plus the admin and preferences sections
* hooks to build projectmanager's sidebox-menu plus the admin and Api\Preferences sections
*
* @param string/array $args hook args
*/
@ -106,32 +112,32 @@ class timesheet_hooks
if ($location == 'sidebox_menu')
{
// Magic etemplate2 favorites menu (from nextmatch widget)
display_sidebox($appname, lang('Favorites'), egw_framework::favorite_list($appname));
display_sidebox($appname, lang('Favorites'), Framework\Favorites::list_favorites($appname));
$file = array(
'Timesheet list' => egw::link('/index.php',array(
'Timesheet list' => Egw::link('/index.php',array(
'menuaction' => 'timesheet.timesheet_ui.index',
'ajax' => 'true')),
array(
'text' => lang('Add %1',lang(egw_link::get_registry($appname, 'entry'))),
'text' => lang('Add %1',lang(Link::get_registry($appname, 'entry'))),
'no_lang' => true,
'link' => "javascript:egw.open('','$appname','add')"
),
);
$file['Placeholders'] = egw::link('/index.php','menuaction=timesheet.timesheet_merge.show_replacements');
$file['Placeholders'] = Egw::link('/index.php','menuaction=timesheet.timesheet_merge.show_replacements');
display_sidebox($appname,$GLOBALS['egw_info']['apps'][$appname]['title'].' '.lang('Menu'),$file);
}
if ($GLOBALS['egw_info']['user']['apps']['admin'])
{
$file = Array(
'Site Configuration' => egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname,'&ajax=true'),
'Custom fields' => egw::link('/index.php','menuaction=admin.customfields.index&appname='.$appname.'&use_private=1'),
'Global Categories' => egw::link('/index.php',array(
'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname,'&ajax=true'),
'Custom fields' => Egw::link('/index.php','menuaction=admin.customfields.index&appname='.$appname.'&use_private=1'),
'Global Categories' => Egw::link('/index.php',array(
'menuaction' => 'admin.admin_categories.index',
'appname' => $appname,
'global_cats'=> True)),
'Edit Status' => egw::link('/index.php','menuaction=timesheet.timesheet_ui.editstatus'),
'Edit Status' => Egw::link('/index.php','menuaction=timesheet.timesheet_ui.editstatus'),
);
if ($location == 'admin')
{
@ -145,7 +151,7 @@ class timesheet_hooks
}
/**
* populates $GLOBALS['settings'] for the preferences
* populates $GLOBALS['settings'] for the Api\Preferences
*/
static function settings()
{
@ -174,7 +180,7 @@ class timesheet_hooks
'name' => 'default_document',
'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.',lang('timesheet')).' '.
lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'ts_title').' '.
lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
'run_lang' => false,
'xmlrpc' => True,
'admin' => False,
@ -186,7 +192,7 @@ class timesheet_hooks
'name' => 'document_dir',
'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the %1 data inserted.', lang('timesheet')).' '.
lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','ts_title').' '.
lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
'run_lang' => false,
'xmlrpc' => True,
'admin' => False,
@ -248,9 +254,9 @@ class timesheet_hooks
unset($params); // not used, but required by function signature
return array(
acl::READ => 'read',
acl::EDIT => 'edit',
acl::DELETE => 'delete',
Acl::READ => 'read',
Acl::EDIT => 'edit',
Acl::DELETE => 'delete',
);
}

View File

@ -11,12 +11,14 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
/**
* class import_csv for timesheet
*/
class timesheet_import_csv implements importexport_iface_import_plugin {
class timesheet_import_csv implements importexport_iface_import_plugin
{
private static $plugin_options = array(
'fieldsep', // char
'charset', // string
@ -146,10 +148,10 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
$_definition->plugin_options['record_owner'] : $this->user;
// Used to try to automatically match names to account IDs
$addressbook = new addressbook_so();
$addressbook = new Api\Contacts\Storage();
// For converting human-friendly lookups
$categories = new categories('timesheet');
$categories = new Api\Categories('timesheet');
$lookups = array(
'ts_status' => $this->bo->status_labels,
// 'cat_id' => $categories->return_sorted_array(0,False,'','','',true)
@ -177,11 +179,11 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']);
if($result) $this->warnings[$import_csv->get_current_position()] = $result;
// Automatically handle text categories without explicit translation
// Automatically handle text Api\Categories without explicit Api\Translation
foreach(array('ts_status','cat_id') as $field) {
if(!is_numeric($record[$field])) {
$translate_key = 'translate'.(substr($field,0,2) == 'ts' ? substr($field,2) : '_cat_id');
if($key = array_search($record[$field], $lookups[$field])) {
if(($key = array_search($record[$field], $lookups[$field]))) {
$record[$field] = $key;
} elseif(array_key_exists($translate_key, $_definition->plugin_options)) {
$t_field = $_definition->plugin_options[$translate_key];
@ -212,11 +214,11 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
'parent' => $parent,
'admin' => false
);
config::save_value('status_labels',$this->bo->status_labels_config,TIMESHEET_APP);
Api\Config::save_value('status_labels',$this->bo->status_labels_config,TIMESHEET_APP);
$lookups[$field][$id] = $name;
$record[$field] = $id;
}
} elseif($key = array_search($t_field, $lookups[$field])) {
} elseif(($key = array_search($t_field, $lookups[$field]))) {
$record[$field] = $key;
} else {
$record[$field] = $t_field;
@ -230,13 +232,13 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
// Set creator, unless it's supposed to come from CSV file
if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner']) {
if(!is_numeric($record['ts_owner'])) {
// Automatically handle text owner without explicit translation
// Automatically handle text owner without explicit Api\Translation
$new_owner = importexport_helper_functions::account_name2id($record['ts_owner']);
if($new_owner == '') {
$this->errors[$import_csv->get_current_position()] = lang(
'Unable to convert "%1" to account ID. Using plugin setting (%2) for %3.',
$record['ts_owner'],
common::grab_owner_name($_definition->plugin_options['record_owner']),
Api\Accounts::username($_definition->plugin_options['record_owner']),
lang($this->bo->field2label['ts_owner'])
);
$record['ts_owner'] = $_definition->plugin_options['record_owner'];
@ -253,13 +255,13 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
if($record[$field] && !is_numeric($record[$field])) {
// Try an automatic conversion
$account_id = importexport_helper_functions::account_name2id($record[$field]);
if($account_id && strtoupper(common::grab_owner_name($account_id)) == strtoupper($record[$field])) {
if($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field])) {
$record[$field] = $account_id;
} else {
$this->errors[$import_csv->get_current_position()] = lang(
'Unable to convert "%1" to account ID. Using plugin setting (%2) for %3.',
$record[$field],
common::grab_owner_name($_definition->plugin_options['record_owner']),
Api\Accounts::username($_definition->plugin_options['record_owner']),
$this->bo->field2label[$field] ? lang($this->bo->field2label[$field]) : $field
);
}
@ -348,9 +350,9 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
// Clear old link, if different
if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id']) {
egw_link::unlink2(0,TIMESHEET_APP,$_data['ts_id'],0,'projectmanager',$old['pm_id']);
Link::unlink2(0,TIMESHEET_APP,$_data['ts_id'],0,'projectmanager',$old['pm_id']);
}
// Fall through
case 'insert' :
if ( $this->dry_run ) {
@ -363,7 +365,7 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
// Set projectmanager link
if ($_data['pm_id']) {
egw_link::link(TIMESHEET_APP,$_data['ts_id'],'projectmanager',$_data['pm_id']);
Link::link(TIMESHEET_APP,$_data['ts_id'],'projectmanager',$_data['pm_id']);
}
if($result) {
@ -378,7 +380,7 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
break;
}
default:
throw new egw_exception('Unsupported action');
throw new Api\Exception('Unsupported action');
}
// Process some additional fields
@ -397,7 +399,7 @@ class timesheet_import_csv implements importexport_iface_import_plugin {
$id = $_data[$field];
}
if ($app && $app_id) {
$link_id = egw_link::link('timesheet',$id,$app,$app_id);
$link_id = Link::link('timesheet',$id,$app,$app_id);
}
}
return $result;

View File

@ -6,16 +6,19 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @author Nathan Gray
* @package timesheet
* @copyright (c) 2007-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright 2011 Nathan Gray
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
/**
* Timesheet - document merge object
*/
class timesheet_merge extends bo_merge
class timesheet_merge extends Api\Storage\Merge
{
/**
* Functions that can be called via menuaction
@ -50,8 +53,8 @@ class timesheet_merge extends bo_merge
{
parent::__construct();
// switch of handling of html formated content, if html is not used
$this->parse_html_styles = egw_customfields::use_html('timesheet');
// switch of handling of Api\Html formated content, if Api\Html is not used
$this->parse_html_styles = Api\Storage\Customfields::use_html('timesheet');
$this->bo = new timesheet_bo();
$this->date_fields += array(
@ -102,7 +105,7 @@ class timesheet_merge extends bo_merge
$info = array();
// Get project manager ID
$links = solink::get_links('timesheet',$id,'projectmanager');
$links = Link\Storage::get_links('timesheet',$id,'projectmanager');
if($links)
{
$record->pm_id = current($links);
@ -152,14 +155,14 @@ class timesheet_merge extends bo_merge
}
/**
* Generate table with replacements for the preferences
* Generate table with replacements for the Api\Preferences
*
*/
public function show_replacements()
{
$GLOBALS['egw_info']['flags']['app_header'] = lang('timesheet').' - '.lang('Replacements for inserting entries into documents');
$GLOBALS['egw_info']['flags']['nonavbar'] = false;
common::egw_header();
$GLOBALS['egw']->framework->header();
echo "<table width='90%' align='center'>\n";
echo '<tr><td colspan="4"><h3>'.lang('Timesheet fields:')."</h3></td></tr>";
@ -223,6 +226,6 @@ class timesheet_merge extends bo_merge
echo "</table>\n";
common::egw_footer();
$GLOBALS['egw']->framework->footer();
}
}

View File

@ -5,15 +5,17 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package tracker
* @copyright (c) 2006-8 by Ralf Becker <RalfBecker-AT-stylite.de>
* @copyright (c) 2006-16 by Ralf Becker <RalfBecker-AT-stylite.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id: class.timesheet_tracking.inc.php 26515 2009-03-24 11:50:16Z leithoff $
*/
use EGroupware\Api;
/**
* Timesheet - tracking object for the tracker
*/
class timesheet_tracking extends bo_tracking
class timesheet_tracking extends Api\Storage\Tracking
{
/**
* Application we are tracking (required!)
@ -62,7 +64,7 @@ class timesheet_tracking extends bo_tracking
/**
* Constructor
*
* @param timesheet_bo $botimesheet
* @param timesheet_bo $bo
* @return timesheet_tracking
*/
function __construct(timesheet_bo $bo)
@ -81,12 +83,12 @@ class timesheet_tracking extends bo_tracking
/**
* Get a notification-config value
*
* @param string $what
* @param string $name
* - 'copy' array of email addresses notifications should be copied too, can depend on $data
* - 'lang' string lang code for copy mail
* - 'sender' string send email address
* @param array $data current entry
* @param array $old=null old/last state of the entry or null for a new entry
* @param array $old =null old/last state of the entry or null for a new entry
* @return mixed
*/
function get_config($name,$data,$old=null)
@ -99,7 +101,7 @@ class timesheet_tracking extends bo_tracking
}
/**
* Get the subject for a given entry, reimplementation for get_subject in bo_tracking
* Get the subject for a given entry, reimplementation for get_subject in Api\Storage\Tracking
*
* Default implementation uses the link-title
*
@ -124,11 +126,11 @@ class timesheet_tracking extends bo_tracking
if (!$data['ts_modified'] || !$old)
{
return lang('New timesheet submitted by %1 at %2',
common::grab_owner_name($data['ts_creator']),
Api\Accounts::username($data['ts_creator']),
$this->datetime($data['ts_created']));
}
return lang('Timesheet modified by %1 at %2',
$data['ts_modifier'] ? common::grab_owner_name($data['ts_modifier']) : lang('Timesheet'),
$data['ts_modifier'] ? Api\Accounts::username($data['ts_modifier']) : lang('Timesheet'),
$this->datetime($data['ts_modified']));
}
}

View File

@ -10,6 +10,12 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Framework;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* User interface object of the TimeSheet
*/
@ -54,7 +60,7 @@ class timesheet_ui extends timesheet_bo
function edit($content = null,$view = false)
{
$etpl = new etemplate_new('timesheet.edit');
$etpl = new Etemplate('timesheet.edit');
if (!is_array($content))
{
if ($_GET['msg']) $msg = strip_tags($_GET['msg']);
@ -63,9 +69,9 @@ class timesheet_ui extends timesheet_bo
{
if (!$this->read((int)$_GET['ts_id']))
{
egw_framework::window_close(lang('Permission denied!!!'));
Framework::window_close(lang('Permission denied!!!'));
}
if (!$view && !$this->check_acl(EGW_ACL_EDIT))
if (!$view && !$this->check_acl(Acl::EDIT))
{
$view = true;
}
@ -75,7 +81,7 @@ class timesheet_ui extends timesheet_bo
$this->data = array(
'ts_start' => $this->today,
'start_time' => '', // force empty start-time
'end_time' => egw_time::to($this->now,'H:i'),
'end_time' => Api\DateTime::to($this->now,'H:i'),
'ts_owner' => $GLOBALS['egw_info']['user']['account_id'],
'cat_id' => (int) $_REQUEST['cat_id'],
'ts_status'=> $GLOBALS['egw_info']['user']['preferences']['timesheet']['predefined_status'],
@ -91,7 +97,7 @@ class timesheet_ui extends timesheet_bo
$only_admin_edit = true;
$msg = lang('only Admin can edit this status');
}
$this->data['ts_project_blur'] = $this->data['pm_id'] ? egw_link::title('projectmanager', $this->data['pm_id']) : '';
$this->data['ts_project_blur'] = $this->data['pm_id'] ? Link::title('projectmanager', $this->data['pm_id']) : '';
}
else
{
@ -113,14 +119,14 @@ class timesheet_ui extends timesheet_bo
if (isset($content['start_time'])) // start-time specified
{
//$content['ts_start'] += $content['start_time'];
$start = new egw_time($content['ts_start']);
$start = new Api\DateTime($content['ts_start']);
$start_time = explode(':',$content['start_time']);
$start->setTime($start_time[0],$start_time[1]);
$content['ts_start'] = $start->format('ts');
}
if (isset($content['end_time'])) // end-time specified
{
$end = new egw_time($content['ts_start']);
$end = new Api\DateTime($content['ts_start']);
$end_time = explode(':',$content['end_time']);
$end->setTime($end_time[0],$end_time[1]);
}
@ -137,14 +143,14 @@ class timesheet_ui extends timesheet_bo
elseif ($content['ts_duration'] && $end) // no start, calculate from end and duration
{
$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".egw_time::to($content['ts_start'])."</p>\n";
//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n";
}
if ($content['ts_duration'] > 0) unset($content['end_time']);
// now we only deal with start (date+time) and duration
list($button) = @each($content['button']);
$view = $content['view'];
$referer = $content['referer'];
$content['ts_project_blur'] = $content['pm_id'] ? egw_link::title('projectmanager', $content['pm_id']) : '';
$content['ts_project_blur'] = $content['pm_id'] ? Link::title('projectmanager', $content['pm_id']) : '';
$this->data = $content;
foreach(array('button','view','referer','tabs','start_time') as $key)
{
@ -153,7 +159,7 @@ class timesheet_ui extends timesheet_bo
switch($button)
{
case 'edit':
if ($this->check_acl(EGW_ACL_EDIT) && !$only_admin_edit) $view = false;
if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false;
break;
case 'undelete':
@ -212,11 +218,11 @@ class timesheet_ui extends timesheet_bo
// update links accordingly
if ($this->data['pm_id'])
{
egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
Link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
}
if ($this->data['old_pm_id'])
{
egw_link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
Link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
unset($this->data['old_pm_id']);
}
}
@ -228,7 +234,7 @@ class timesheet_ui extends timesheet_bo
if ($data['app'] == 'projectmanager')
{
$this->data['pm_id'] = $data['id'];
$this->data['ts_project_blur'] = egw_link::title('projectmanager', $data['id']);
$this->data['ts_project_blur'] = Link::title('projectmanager', $data['id']);
break;
}
}
@ -244,10 +250,10 @@ class timesheet_ui extends timesheet_bo
$msg = lang('Entry saved');
if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
{
egw_link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
Link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
}
}
egw_framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
if ($button == 'apply') break;
if ($button == 'save_new')
{
@ -256,9 +262,9 @@ class timesheet_ui extends timesheet_bo
if (!is_array($content['link_to']['to_id'])) // set links again, so new entry gets the same links as the existing one
{
$content['link_to']['to_id'] = 0;
foreach(egw_link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.egw_link::VFS_APPNAME) as $link)
foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link)
{
egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
}
}
// create a new entry
@ -278,7 +284,7 @@ class timesheet_ui extends timesheet_bo
if ($this->delete())
{
$msg = lang('Entry deleted');
egw_framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], 'delete');
Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], 'delete');
}
else
{
@ -288,7 +294,7 @@ class timesheet_ui extends timesheet_bo
}
// fall-through for save
case 'cancel':
egw_framework::window_close();
Framework::window_close();
}
}
$preserv = $this->data + array(
@ -329,13 +335,13 @@ class timesheet_ui extends timesheet_bo
if(!$n)
{
// get title from first linked app
$preserv['ts_title_blur'] = egw_link::title($link_app,$link_id);
$preserv['ts_title_blur'] = Link::title($link_app,$link_id);
// ask first linked app via "timesheet_set" hook, for further data to set, incl. links
if (($set = $GLOBALS['egw']->hooks->single(array('location'=>'timesheet_set','id'=>$link_id),$link_app)))
if (($set = Api\Hooks::single(array('location'=>'timesheet_set','id'=>$link_id),$link_app)))
{
foreach((array)$set['link_app'] as $i => $l_app)
{
if (($l_id=$set['link_id'][$i])) egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
if ($l_app == 'projectmanager') $links[] = $l_id;
}
unset($set['link_app']);
@ -346,13 +352,13 @@ class timesheet_ui extends timesheet_bo
}
break;
}
egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
}
}
}
elseif ($this->data['ts_id'])
{
$links = egw_link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
$links = Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
}
// make all linked projects availible for the pm-pricelist widget, to be able to choose prices from all
$content['all_pm_ids'] = array_values($links);
@ -385,9 +391,9 @@ class timesheet_ui extends timesheet_bo
// or the preserved project-blur comming from the current selected project
$content['ts_title_blur'] = $preserv['ts_title_blur'] ? $preserv['ts_title_blur'] : $content['ts_project_blur'];
$readonlys = array(
'button[delete]' => !$this->data['ts_id'] || !$this->check_acl(EGW_ACL_DELETE) || $this->data['ts_status'] == self::DELETED_STATUS,
'button[delete]' => !$this->data['ts_id'] || !$this->check_acl(Acl::DELETE) || $this->data['ts_status'] == self::DELETED_STATUS,
'button[undelete]' => $this->data['ts_status'] != self::DELETED_STATUS,
'button[edit]' => !$view || !$this->check_acl(EGW_ACL_EDIT),
'button[edit]' => !$view || !$this->check_acl(Acl::EDIT),
'button[save]' => $view,
'button[save_new]' => $view,
'button[apply]' => $view,
@ -401,7 +407,7 @@ class timesheet_ui extends timesheet_bo
}
$readonlys['start_time'] = $readonlys['end_time'] = true;
}
$edit_grants = $this->grant_list(EGW_ACL_EDIT);
$edit_grants = $this->grant_list(Acl::EDIT);
if (count($edit_grants) == 1)
{
$readonlys['ts_owner'] = true;
@ -409,7 +415,7 @@ class timesheet_ui extends timesheet_bo
// in view mode, we need to add the owner, if it does not exist, otherwise it's displayed empty
if ($view && $content['ts_owner'] && !isset($edit_grants[$content['ts_owner']]))
{
$edit_grants[$content['ts_owner']] = common::grab_owner_name($content['ts_owner']);
$edit_grants[$content['ts_owner']] = Api\Accounts::username($content['ts_owner']);
}
$sel_options['ts_owner'] = $edit_grants;
$sel_options['ts_status'] = $this->status_labels;
@ -454,11 +460,11 @@ class timesheet_ui extends timesheet_bo
/**
* query projects for nextmatch in the projects-list
*
* reimplemented from so_sql to disable action-buttons based on the acl and make some modification on the data
* reimplemented from Api\Storage\Base to disable action-buttons based on the Acl and make some modification on the data
*
* @param array &$query
* @param array &$rows returned rows/cups
* @param array &$readonlys eg. to disable buttons based on acl
* @param array &$readonlys eg. to disable buttons based on Acl
* @param boolean $id_only if true only return (via $rows) an array of contact-ids, dont save state to session
* @return int total number of contacts matching the selection
*/
@ -528,7 +534,7 @@ class timesheet_ui extends timesheet_bo
}
if ((string)$query['col_filter']['pm_id'] != '' && (string)$query['col_filter']['pm_id'] != '0')
{
//$query['col_filter']['ts_id'] = egw_link::get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet');
//$query['col_filter']['ts_id'] = Link::get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet');
$query['col_filter']['ts_id'] = $this->get_ts_links($query['col_filter']['pm_id']);
if (empty($query['col_filter']['ts_id'])) $query['col_filter']['ts_id'] = -1;
if (!$query['col_filter']['ts_id']) $query['col_filter']['ts_id'] = 0;
@ -544,7 +550,7 @@ class timesheet_ui extends timesheet_bo
if ($query['col_filter']['linked'])
{
list($app,$id) = explode(':',$query['col_filter']['linked']);
if (!($links = egw_link::get_links($app,$id,'timesheet')))
if (!($links = Link::get_links($app,$id,'timesheet')))
{
$rows = array(); // no infologs linked to project --> no rows to return
return 0;
@ -606,7 +612,7 @@ class timesheet_ui extends timesheet_bo
$GLOBALS['egw_info']['flags']['app_header'] = lang('timesheet');
if ($query['col_filter']['ts_owner'])
{
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.common::grab_owner_name($query['col_filter']['ts_owner']);
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']);
#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
@ -646,20 +652,20 @@ class timesheet_ui extends timesheet_bo
elseif ($query['startdate'])
{
$df = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . common::show_date($query['startdate']+12*60*60,$df,false);
$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . Api\DateTime::to($query['startdate']+12*60*60, $df);
if ($start != $end)
{
$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.common::show_date($query['enddate']+12*60*60,$df,false);
$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate']+12*60*60, $df);
}
}
}
// Update start / end dates for custom
if($query_in['filter'] != 'custom')
{
egw_json_response::get()->call(
Api\Json\Response::get()->call(
'app.timesheet.update_timespan',
egw_time::to($query['startdate'] ? $query['startdate'] : 'now' , egw_time::ET2),
$query['filter'] ? egw_time::to($query['enddate'], egw_time::ET2) : null
Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now' , Api\DateTime::ET2),
$query['filter'] ? Api\DateTime::to($query['enddate'], Api\DateTime::ET2) : null
);
}
$total = parent::get_rows($query,$rows,$readonlys);
@ -675,7 +681,7 @@ class timesheet_ui extends timesheet_bo
return $this->total; // no need to set other fields or $readonlys
}
$links = array();
$links3 = egw_link::get_links_multiple(TIMESHEET_APP,$ids,true,'projectmanager'); // only check for pm links!
$links3 = Link::get_links_multiple(TIMESHEET_APP,$ids,true,'projectmanager'); // only check for pm links!
//as the full array is expected, we must supply the missing but needed (since expected further down) information
if (is_array($links3))
{
@ -713,8 +719,7 @@ class timesheet_ui extends timesheet_bo
switch($row['ts_id'])
{
case 0: // day-sum
$row['ts_title'] = lang('Sum %1:',lang(date('l',$row['ts_start'])).' '.common::show_date($row['ts_start'],
$GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],false));
$row['ts_title'] = lang('Sum %1:',lang(date('l',$row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
$row['ts_id'] = 'sum-day-'.$row['ts_start'];
break;
case -1: // week-sum
@ -740,7 +745,7 @@ class timesheet_ui extends timesheet_bo
{
$row['ts_quantity'] = round($row['ts_quantity'], 2);
}
if (!$this->check_acl(EGW_ACL_EDIT,$row))
if (!$this->check_acl(Acl::EDIT,$row))
{
$row['class'] .= ' rowNoEdit ';
}
@ -748,7 +753,7 @@ class timesheet_ui extends timesheet_bo
{
$row['class'] .= ' rowNoEdit ';
}
if (!$this->check_acl(EGW_ACL_DELETE,$row))
if (!$this->check_acl(Acl::DELETE,$row))
{
$row['class'] .= ' rowNoDelete ';
}
@ -821,7 +826,7 @@ class timesheet_ui extends timesheet_bo
*/
function index($content = null,$msg='')
{
$etpl = new etemplate_new('timesheet.index');
$etpl = new Etemplate('timesheet.index');
if ($_GET['msg']) $msg = $_GET['msg'];
if ($content['nm']['rows']['delete'])
@ -903,7 +908,7 @@ class timesheet_ui extends timesheet_bo
{
$content['nm']['search'] = $_GET['search'];
}
$read_grants = $this->grant_list(EGW_ACL_READ);
$read_grants = $this->grant_list(Acl::READ);
$content['nm']['no_owner_col'] = count($read_grants) == 1;
if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']) $content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'];
$sel_options = array(
@ -946,10 +951,10 @@ class timesheet_ui extends timesheet_bo
'default' => true,
'allowOnMultiple' => false,
'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
'popup' => egw_link::get_registry('timesheet', 'add_popup'),
'popup' => Link::get_registry('timesheet', 'add_popup'),
'group' => $group=1,
'disableClass' => 'th',
'onExecute' => html::$ua_mobile?'javaScript:app.timesheet.viewEntry':''
'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.timesheet.viewEntry':''
),
/*
'view' => array(
@ -957,14 +962,14 @@ class timesheet_ui extends timesheet_bo
'default' => true,
'allowOnMultiple' => false,
'url' => 'menuaction=timesheet.timesheet_ui.view&ts_id=$id',
'popup' => egw_link::get_registry('timesheet', 'view_popup'),
'popup' => Link::get_registry('timesheet', 'view_popup'),
'group' => $group=1,
),
'edit' => array(
'caption' => 'Edit',
'allowOnMultiple' => false,
'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
'popup' => egw_link::get_registry('timesheet', 'add_popup'),
'popup' => Link::get_registry('timesheet', 'add_popup'),
'group' => $group,
'disableClass' => 'rowNoEdit',
),
@ -972,10 +977,10 @@ class timesheet_ui extends timesheet_bo
'add' => array(
'caption' => 'Add',
'url' => 'menuaction=timesheet.timesheet_ui.edit',
'popup' => egw_link::get_registry('timesheet', 'add_popup'),
'popup' => Link::get_registry('timesheet', 'add_popup'),
'group' => $group,
),
'cat' => etemplate_widget_nextmatch::category_action(
'cat' => Etemplate\Widget\Nextmatch::category_action(
'timesheet',++$group,'Change category','cat_'
),
'status' => array(
@ -988,7 +993,7 @@ class timesheet_ui extends timesheet_bo
),
);
// Other applications
// Other Api\Applications
$group++;
if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
{
@ -1057,7 +1062,7 @@ class timesheet_ui extends timesheet_bo
if ($use_all)
{
// get the whole selection
$query = is_array($session_name) ? $session_name : $GLOBALS['egw']->session->appsession($session_name,'timesheet');
$query = is_array($session_name) ? $session_name : Api\Cache::getSession('timesheet', $session_name);
if ($use_all)
{
@ -1125,7 +1130,7 @@ class timesheet_ui extends timesheet_bo
}
break;
case 'cat':
$cat_name = categories::id2name($settings);
$cat_name = Api\Categories::id2name($settings);
$action_msg = lang('changed category to %1', $cat_name);
foreach((array)$checked as $n => $id) {
$entry = $this->read($id);
@ -1189,8 +1194,8 @@ class timesheet_ui extends timesheet_bo
}
if ($need_update)
{
config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
$this->config_data = config::read(TIMESHEET_APP);
Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
$this->config_data = Api\Config::read(TIMESHEET_APP);
$this->load_statuses();
$msg .= lang('Status updated.');
}
@ -1206,7 +1211,7 @@ class timesheet_ui extends timesheet_bo
if (isset($this->status_labels_config[$id]))
{
unset($this->status_labels_config[$id]);
config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
unset($this->status_labels[$id]);
$msg .= lang('Status deleted.');
}
@ -1231,7 +1236,7 @@ class timesheet_ui extends timesheet_bo
$content['msg'] = $msg;
$preserv = $content;
$sel_options['parent'] = $this->status_labels;
$etpl = new etemplate_new('timesheet.editstatus');
$etpl = new Etemplate('timesheet.editstatus');
$etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,array(),$preserv);
}
}

View File

@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
class timesheet_wizard_export_csv extends importexport_wizard_basic_export_csv
{
public function __construct() {
@ -21,7 +23,7 @@ class timesheet_wizard_export_csv extends importexport_wizard_basic_export_csv
// Custom fields
unset($this->export_fields['customfields']);
$custom = config::get_customfields('timesheet', true);
$custom = Api\Storage\Customfields::get('timesheet', true);
foreach($custom as $name => $data) {
$this->export_fields['#'.$name] = $data['label'];
}

View File

@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
class timesheet_wizard_import_csv extends importexport_wizard_basic_import_csv
{
@ -39,7 +41,7 @@ class timesheet_wizard_import_csv extends importexport_wizard_basic_import_csv
// List each custom field
unset($this->mapping_fields['customfields']);
$custom = config::get_customfields('timesheet');
$custom = Api\Storage\Customfields::get('timesheet');
foreach($custom as $name => $data) {
$this->mapping_fields['#'.$name] = $data['label'];
}
@ -100,7 +102,7 @@ class timesheet_wizard_import_csv extends importexport_wizard_basic_import_csv
'add' => lang('Add'),
);
$set_to = lang('Set to') . ':';
$categories = new categories('','timesheet');
$categories = new Api\Categories('','timesheet');
$cat_list = array();
foreach((array)$categories->return_sorted_array(0,False,'','','',true) as $cat) {
$s = str_repeat('&nbsp;',$cat['level']) . stripslashes($cat['name']);

View File

@ -5,11 +5,13 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api\Framework;
include_once('./setup/setup.inc.php');
$ts_version = $setup_info[TIMESHEET_APP]['version'];
unset($setup_info);
@ -24,14 +26,11 @@ include('../header.inc.php');
if ($ts_version != $GLOBALS['egw_info']['apps'][TIMESHEET_APP]['version'])
{
$GLOBALS['egw']->common->egw_header();
parse_navbar();
echo '<p style="text-align: center; color:red; font-weight: bold;">'.lang('Your database is NOT up to date (%1 vs. %2), please run %3setup%4 to update your database.',
Framework::render('<p style="text-align: center; color:red; font-weight: bold;">'.
lang('Your database is NOT up to date (%1 vs. %2), please run %3setup%4 to update your database.',
$ts_version,$GLOBALS['egw_info']['apps'][TIMESHEET_APP]['version'],
'<a href="../setup/">','</a>')."</p>\n";
$GLOBALS['egw']->common->egw_exit();
'<a href="../setup/">','</a>')."</p>\n", null, true);
exit();
}
//ExecMethod(TIMESHEET_APP.'.pm_admin_prefs_sidebox_hooks.check_set_default_prefs');
$GLOBALS['egw']->redirect_link('/index.php',array('menuaction'=>TIMESHEET_APP.'.timesheet_ui.index'));
Framework::redirect_link('/index.php',array('menuaction'=>TIMESHEET_APP.'.timesheet_ui.index'));

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet
* @subpackage setup
* @copyright (c) 2005-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -17,7 +17,7 @@ if (!defined('TIMESHEET_APP'))
}
$setup_info[TIMESHEET_APP]['name'] = TIMESHEET_APP;
$setup_info[TIMESHEET_APP]['version'] = '14.1';
$setup_info[TIMESHEET_APP]['version'] = '16.1';
$setup_info[TIMESHEET_APP]['app_order'] = 5;
$setup_info[TIMESHEET_APP]['tables'] = array('egw_timesheet','egw_timesheet_extra');
$setup_info[TIMESHEET_APP]['enable'] = 1;
@ -49,10 +49,6 @@ $setup_info[TIMESHEET_APP]['hooks']['acl_rights'] = 'timesheet_hooks::acl_rights
/* Dependencies for this app to work */
$setup_info[TIMESHEET_APP]['depends'][] = array(
'appname' => 'phpgwapi',
'versions' => Array('14.1')
);
$setup_info[TIMESHEET_APP]['depends'][] = array(
'appname' => 'etemplate',
'versions' => Array('14.1')
'appname' => 'api',
'versions' => Array('16.1')
);

View File

@ -6,11 +6,13 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet
* @subpackage setup
* @copyright (c) 2005-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
function timesheet_upgrade0_1_001()
{
$GLOBALS['egw_setup']->oProc->AddColumn('egw_timesheet','pl_id',array(
@ -119,7 +121,13 @@ function timesheet_upgrade1_9_001()
function timesheet_upgrade1_9_002()
{
// switch history / delete prevention on, like for new installs, so only admins can finally delete timesheets
config::save_value('history', 'history', 'timesheet');
Api\Config::save_value('history', 'history', 'timesheet');
return $GLOBALS['setup_info']['timesheet']['currentver'] = '14.1';
}
function timesheet_upgrade14_1()
{
return $GLOBALS['setup_info']['timesheet']['currentver'] = '16.1';
}