From d7a6328c122fcb6bb6ea5a115a01ec5b0263425d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 19 Apr 2011 18:53:31 +0000 Subject: [PATCH] using new historylog custom field stuff, specially logging each custome field separate --- timesheet/inc/class.timesheet_bo.inc.php | 69 +++++++------------ .../inc/class.timesheet_tracking.inc.php | 11 +-- timesheet/inc/class.timesheet_ui.inc.php | 12 ++-- 3 files changed, 39 insertions(+), 53 deletions(-) diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index 65425dc0a8..33dfb72623 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -142,12 +142,6 @@ class timesheet_bo extends so_sql_cf //'link_to' => 'Attachments & Links', 'customfields' => 'Custom fields', ); - /** - * setting field-name from DB to history status - * - * @var array - */ - var $field2history = array(); /** * Name of the timesheet table storing custom fields */ @@ -214,10 +208,6 @@ class timesheet_bo extends so_sql_cf $GLOBALS['timesheet_bo'] =& $this; } $this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP); - //set fields for tracking - $this->field2history = array_keys($this->db_cols); - $this->field2history = array_diff(array_combine($this->field2history,$this->field2history),array('ts_modified')); - $this->field2history += array('customfields' => '#c'); //add custom fields for history } /** @@ -496,43 +486,32 @@ class timesheet_bo extends so_sql_cf } // check if we have a real modification - // read the old record - $new =& $this->data; - unset($this->data); - $this->read($new['ts_id']); - $old =& $this->data; - $this->data =& $new; - $changed[] = array(); - if (isset($old)) foreach($old as $name => $value) - { - if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; - } - if (!$changed) - { - return false; - } + // read the old record + $new =& $this->data; + unset($this->data); + $this->read($new['ts_id']); + $old =& $this->data; + $this->data =& $new; + $changed[] = array(); + if (isset($old)) foreach($old as $name => $value) + { + if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; + } + if (!$changed) + { + return false; + } - if (!is_object($this->tracking)) - { - $this->tracking = new timesheet_tracking($this); + if (!is_object($this->tracking)) + { + $this->tracking = new timesheet_tracking($this); - $this->tracking->html_content_allow = true; - } - if ($this->customfields) - { - $data_custom = $old_custom = array(); - foreach($this->customfields as $name => $custom) - { - if (isset($this->data['#'.$name]) && (string)$this->data['#'.$name]!=='') $data_custom[] = $custom['label'].': '.$this->data['#'.$name]; - if (isset($old['#'.$name]) && (string)$old['#'.$name]!=='') $old_custom[] = $custom['label'].': '.$old['#'.$name]; - } - $this->data['customfields'] = implode("\n",$data_custom); - $old['customfields'] = implode("\n",$old_custom); - } - if (!$this->tracking->track($this->data,$old,$this->user)) - { - return implode(', ',$this->tracking->errors); - } + $this->tracking->html_content_allow = true; + } + if ($this->tracking->track($this->data,$old,$this->user) === false) + { + return implode(', ',$this->tracking->errors); + } if (!($err = parent::save())) { // notify the link-class about the update, as other apps may be subscribt to it diff --git a/timesheet/inc/class.timesheet_tracking.inc.php b/timesheet/inc/class.timesheet_tracking.inc.php index 69e2530df5..7b9565e51d 100644 --- a/timesheet/inc/class.timesheet_tracking.inc.php +++ b/timesheet/inc/class.timesheet_tracking.inc.php @@ -65,14 +65,17 @@ class timesheet_tracking extends bo_tracking * @param timesheet_bo $botimesheet * @return timesheet_tracking */ - function __construct($bo) + function __construct(timesheet_bo $bo) { - parent::__construct(); // calling the constructor of the extended class - $this->bo = $bo; - $this->field2history = $this->bo->field2history; + //set fields for tracking + $this->field2history = array_keys($this->bo->db_cols); + $this->field2history = array_diff(array_combine($this->field2history,$this->field2history),array('ts_modified')); + $this->field2history += array('customfields' => '#c'); // to display old customfield data in history + // custom fields are now handled by parent::__construct('tracker') + parent::__construct('timesheet'); } /** diff --git a/timesheet/inc/class.timesheet_ui.inc.php b/timesheet/inc/class.timesheet_ui.inc.php index 52b53fad7e..e593b70220 100644 --- a/timesheet/inc/class.timesheet_ui.inc.php +++ b/timesheet/inc/class.timesheet_ui.inc.php @@ -84,6 +84,7 @@ class timesheet_ui extends timesheet_bo } $referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] : (strpos($_SERVER['HTTP_REFERER'],'/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index'); + if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $this->data['ts_status']) { if ($this->status_labels_config[$this->data['ts_status']]['admin']) @@ -352,10 +353,8 @@ class timesheet_ui extends timesheet_bo 'cat_id' => 'select-cat', ), ); - foreach($this->field2history as $field => $status) - { - $sel_options['status'][$status] = $this->field2label[$field]; - } + $sel_options['status'] = $this->field2label; + // the actual title-blur is either the preserved title blur (if we are called from infolog entry), // or the preserved project-blur comming from the current selected project $content['ts_title_blur'] = $preserv['ts_title_blur'] ? $preserv['ts_title_blur'] : $preserv['ts_project_blur']; @@ -380,6 +379,11 @@ class timesheet_ui extends timesheet_bo { $readonlys['ts_owner'] = true; } + // 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']); + } $sel_options['ts_owner'] = $edit_grants; $sel_options['ts_status'] = $this->status_labels; $GLOBALS['egw_info']['flags']['app_header'] = lang('timesheet').' - '.