* Calendar: fixed various issues with history in calendar: id display, unecessary stuff loged, ...

This commit is contained in:
Ralf Becker 2011-08-04 14:00:15 +00:00
parent c1718a29ad
commit 3819816248
6 changed files with 66 additions and 40 deletions

View File

@ -1020,8 +1020,6 @@ class calendar_boupdate extends calendar_bo
// Update history // Update history
$tracking = new calendar_tracking($this); $tracking = new calendar_tracking($this);
$event['category'] = implode(',', $this->get_categories($event['category']));
$old_event['category'] = implode(',', $this->get_categories($old_event['category']));
if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
$tracking->track($event, $old_event); $tracking->track($event, $old_event);

View File

@ -6,7 +6,7 @@
* @author Nathan Gray * @author Nathan Gray
* @package calendar * @package calendar
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id: class.addressbook_tracking.inc.php 29164 2010-02-09 21:56:39Z jlehrke $ * @version $Id$
*/ */
/** /**
@ -52,7 +52,6 @@ class calendar_tracking extends bo_tracking
'description' => 'description', 'description' => 'description',
'location' => 'location', 'location' => 'location',
'reference' => 'reference', 'reference' => 'reference',
'modifier' => 'modifier',
'non_blocking' => 'non_blocking', 'non_blocking' => 'non_blocking',
'special' => 'special', 'special' => 'special',
'creator' => 'creator', 'creator' => 'creator',
@ -64,13 +63,14 @@ class calendar_tracking extends bo_tracking
'participants' => array('user_id', 'status', 'role', 'recur'), 'participants' => array('user_id', 'status', 'role', 'recur'),
'participants-c' => array('user_id', 'status', 'quantity', 'role', 'recur'), 'participants-c' => array('user_id', 'status', 'quantity', 'role', 'recur'),
'participants-r' => array('user_id', 'status', 'quantity', 'role', 'recur'),
// Custom fields added in constructor // Custom fields added in constructor
); );
/** /**
* Translate field name to label * Translate field name to label
*/ */
public $field2label = array( public $field2label = array(
'owner' => 'owner', 'owner' => 'owner',
'category' => 'category', 'category' => 'category',
@ -80,18 +80,18 @@ class calendar_tracking extends bo_tracking
'description' => 'description', 'description' => 'description',
'location' => 'location', 'location' => 'location',
'reference' => 'reference', 'reference' => 'reference',
'modifier' => 'modifier',
'non_blocking' => 'non blocking', 'non_blocking' => 'non blocking',
'special' => 'special', 'special' => 'special',
'creator' => 'creator', 'creator' => 'creator',
'recurrence' => 'recurrence', 'recurrence'=> 'recurrence',
'tz_id' => 'tz_id', 'tz_id' => 'timezone',
'start' => 'start', 'start' => 'start',
'end' => 'end', 'end' => 'end',
'participants' => 'Participants: User, Status, Role', 'participants' => 'Participants: User, Status, Role',
'participants-c'=> 'Participants: User, Status, Quantity, Role' 'participants-c'=> 'Participants: User, Status, Quantity, Role',
'participants-r'=> 'Participants: Resource, Status, Quantity',
// Custom fields added in constructor // Custom fields added in constructor
); );
@ -114,14 +114,15 @@ class calendar_tracking extends bo_tracking
} }
/** /**
* Tracks the changes in one entry $data, by comparing it with the last version in $old * Tracks the changes in one entry $data, by comparing it with the last version in $old
* Overrides parent to reformat participants into a format parent can handle * Overrides parent to reformat participants into a format parent can handle
*/ */
public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null) public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null)
{ {
// Don't try to track dates on recurring events. // Don't try to track dates on recurring events.
// It won't change for the base event, and any change to the time creates an exception // It won't change for the base event, and any change to the time creates an exception
if($data['recur_type']) { if($data['recur_type'])
{
unset($data['start']); unset($data['end']); unset($data['start']); unset($data['end']);
unset($old['start']); unset($old['end']); unset($old['start']); unset($old['end']);
} }
@ -132,14 +133,17 @@ class calendar_tracking extends bo_tracking
* filter by it later. * filter by it later.
*/ */
$recur_prefix = $data['recur_date'] ? $data['recur_date'] : ''; $recur_prefix = $data['recur_date'] ? $data['recur_date'] : '';
if(is_array($data['participants'])) { if(is_array($data['participants']))
{
$participants = $data['participants']; $participants = $data['participants'];
$data['participants'] = array(); $data['participants'] = array();
foreach($participants as $id => $status) { foreach($participants as $uid => $status)
{
calendar_so::split_status($status, $quantity, $role); calendar_so::split_status($status, $quantity, $role);
$field = ($id[0] == 'c' ? 'participants-c' : 'participants'); calendar_so::split_user($uid, $user_type, $user_id);
$field = is_numeric($uid) ? 'participants' : 'participants-'.$user_type;
$data[$field][] = array( $data[$field][] = array(
'user_id' => $id[0] == 'c' ? substr($id,1) : $id, 'user_id' => $user_id,
'status' => $status, 'status' => $status,
'quantity' => $quantity, 'quantity' => $quantity,
'role' => $role, 'role' => $role,
@ -147,14 +151,17 @@ class calendar_tracking extends bo_tracking
); );
} }
} }
if(is_array($old['participants'])) { if(is_array($old['participants']))
{
$participants = $old['participants']; $participants = $old['participants'];
$old['participants'] = array(); $old['participants'] = array();
foreach($participants as $id => $status) { foreach($participants as $uid => $status)
{
calendar_so::split_status($status, $quantity, $role); calendar_so::split_status($status, $quantity, $role);
$field = ($id[0] == 'c' ? 'participants-c' : 'participants'); calendar_so::split_user($uid, $user_type, $user_id);
$field = is_numeric($uid) ? 'participants' : 'participants-'.$user_type;
$old[$field][] = array( $old[$field][] = array(
'user_id' => $id[0] == 'c' ? substr($id,1) : $id, 'user_id' => $user_id,
'status' => $status, 'status' => $status,
'quantity' => $quantity, 'quantity' => $quantity,
'role' => $role, 'role' => $role,
@ -166,9 +173,10 @@ class calendar_tracking extends bo_tracking
} }
/** /**
* Overrides parent because calendar_boupdates handles the notifications * Overrides parent because calendar_boupdates handles the notifications
*/ */
public function do_notifications($data,$old,$deleted=null) { public function do_notifications($data,$old,$deleted=null)
{
return true; return true;
} }
} }

View File

@ -2260,13 +2260,16 @@ function replace_eTemplate_onsubmit()
$content['history'] = array( $content['history'] = array(
'id' => $content['id'], 'id' => $content['id'],
'app' => 'calendar', 'app' => 'calendar',
'status-widgets' => array( 'status-widgets' => array(
'owner' => 'select-account', 'owner' => 'select-account',
'cat_id' => 'select-cat', 'creator' => 'select-account',
'non_blocking' => array(''=>lang('No'), 1=>lang('Yes')), 'category' => 'select-cat',
'non_blocking' => array(''=>lang('No'), 1=>lang('Yes')),
'public' => array(''=>lang('No'), 1=>lang('Yes')),
'start' => 'date-time', 'start' => 'date-time',
'end' => 'date-time', 'end' => 'date-time',
'tz_id' => 'select-timezone',
// Participants // Participants
'participants' => array( 'participants' => array(
@ -2280,12 +2283,19 @@ function replace_eTemplate_onsubmit()
'label', 'label',
$sel_options['role'] $sel_options['role']
), ),
'participants-r' => array(
'link:resources',
$sel_options['status'],
'label',
$sel_options['role']
),
), ),
); );
// Get participants for only this one, if it's recurring. The date is on the end of the value. // Get participants for only this one, if it's recurring. The date is on the end of the value.
if($content['recur_type'] || $content['recurrence']) { if($content['recur_type'] || $content['recurrence'])
{
$content['history']['filter'] = array( $content['history']['filter'] = array(
'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND ( '(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
@ -2295,7 +2305,8 @@ function replace_eTemplate_onsubmit()
// Translate labels // Translate labels
$tracking = new calendar_tracking(); $tracking = new calendar_tracking();
foreach($tracking->field2label as $field => $label) { foreach($tracking->field2label as $field => $label)
{
$sel_options[$status][$field] = lang($label); $sel_options[$status][$field] = lang($label);
} }
// custom fields are now "understood" directly by historylog widget // custom fields are now "understood" directly by historylog widget

View File

@ -1,10 +1,10 @@
<?php <?php
/** /**
* eGroupWare EditableTemplates - Business Objects * EGroupware EditableTemplates - Business Objects
* *
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de> * @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-10 by RalfBecker@outdoor-training.de * @copyright 2002-11 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate * @package etemplate
* @subpackage api * @subpackage api
@ -488,7 +488,15 @@ class boetemplate extends soetemplate
*/ */
public function widgetExists($type) public function widgetExists($type)
{ {
return isset(self::$types[$type]) || $this->haveExtension($type); if (isset(self::$types[$type])) return true;
list($main,$sub) = explode('-',$type);
if ($this->haveExtension($main) && $this->loadExtension($main) && ($extension = self::$extensions[$main]))
{
return $type == $main || is_array($extension->human_name) && isset($extension->human_name[$type]);
}
return false;
} }
/** /**

View File

@ -79,14 +79,15 @@ class historylog_widget
if($type == 'select-cat') if($type == 'select-cat')
{ {
list($rows,$type1,$type2,$type3,$type4,$type5,$type6) = explode(',',$options); list($rows,$type1,$type2,$type3,$type4,$type5,$type6) = explode(',',$options);
$type6 = true; $type6 = 2;
$options = implode(',',array($rows,$type1,$type2,$type3,$type4,$type5,$type6)); $options = implode(',',array($rows,$type1,$type2,$type3,$type4,$type5,$type6));
} }
$cell = etemplate::empty_cell($type,$cell['name'],array('readonly' => true,'size' => $options)); $cell = etemplate::empty_cell($type,$cell['name'],array('readonly' => true,'size' => $options));
if (is_array($type)) if (is_array($type))
{ {
list($t) = explode(':',$type[0]);
if (isset($type[0]) && // numeric indexed array --> multiple values of 1:N releation if (isset($type[0]) && // numeric indexed array --> multiple values of 1:N releation
$tmpl->widgetExists($type[0])) $tmpl->widgetExists($t))
{ {
$cell['type'] = 'vbox'; $cell['type'] = 'vbox';
$cell['size'] = '0,,0,0'; $cell['size'] = '0,,0,0';

View File

@ -189,7 +189,7 @@ class select_widget
} }
elseif ($id) // Display id of no longer existing cat elseif ($id) // Display id of no longer existing cat
{ {
$cell['sel_options'][$id] = lang('Missing: %1',$id); $cell['sel_options'][$id] = $type6 == '2' ? $id : lang('Missing: %1',$id);
} }
} }
} }