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

This commit is contained in:
Ralf Becker 2011-08-04 14:05:40 +00:00
parent cf620d45d4
commit b27a67ee66
6 changed files with 80 additions and 40 deletions

View File

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

View File

@ -6,7 +6,7 @@
* @author Nathan Gray
* @package calendar
* @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',
'location' => 'location',
'reference' => 'reference',
'modifier' => 'modifier',
'non_blocking' => 'non_blocking',
'special' => 'special',
'creator' => 'creator',
@ -64,13 +63,14 @@ class calendar_tracking extends bo_tracking
'participants' => array('user_id', 'status', '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
);
/**
* Translate field name to label
*/
* Translate field name to label
*/
public $field2label = array(
'owner' => 'owner',
'category' => 'category',
@ -80,18 +80,18 @@ class calendar_tracking extends bo_tracking
'description' => 'description',
'location' => 'location',
'reference' => 'reference',
'modifier' => 'modifier',
'non_blocking' => 'non blocking',
'special' => 'special',
'creator' => 'creator',
'recurrence' => 'recurrence',
'tz_id' => 'tz_id',
'recurrence'=> 'recurrence',
'tz_id' => 'timezone',
'start' => 'start',
'end' => 'end',
'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
);
@ -122,14 +122,15 @@ class calendar_tracking extends bo_tracking
}
/**
* 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
*/
* 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
*/
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.
// 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($old['start']); unset($old['end']);
}
@ -140,14 +141,17 @@ class calendar_tracking extends bo_tracking
* filter by it later.
*/
$recur_prefix = $data['recur_date'] ? $data['recur_date'] : '';
if(is_array($data['participants'])) {
if(is_array($data['participants']))
{
$participants = $data['participants'];
$data['participants'] = array();
foreach($participants as $id => $status) {
foreach($participants as $uid => $status)
{
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(
'user_id' => $id[0] == 'c' ? substr($id,1) : $id,
'user_id' => $user_id,
'status' => $status,
'quantity' => $quantity,
'role' => $role,
@ -155,14 +159,17 @@ class calendar_tracking extends bo_tracking
);
}
}
if(is_array($old['participants'])) {
if(is_array($old['participants']))
{
$participants = $old['participants'];
$old['participants'] = array();
foreach($participants as $id => $status) {
foreach($participants as $uid => $status)
{
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(
'user_id' => $id[0] == 'c' ? substr($id,1) : $id,
'user_id' => $user_id,
'status' => $status,
'quantity' => $quantity,
'role' => $role,
@ -174,9 +181,10 @@ class calendar_tracking extends bo_tracking
}
/**
* Overrides parent because calendar_boupdates handles the notifications
*/
public function do_notifications($data,$old,$deleted=null) {
* Overrides parent because calendar_boupdates handles the notifications
*/
public function do_notifications($data,$old,$deleted=null)
{
return true;
}
}

View File

@ -2106,13 +2106,16 @@ function replace_eTemplate_onsubmit()
$content['history'] = array(
'id' => $content['id'],
'app' => 'calendar',
'status-widgets' => array(
'owner' => 'select-account',
'cat_id' => 'select-cat',
'non_blocking' => array(''=>lang('No'), 1=>lang('Yes')),
'status-widgets' => array(
'owner' => 'select-account',
'creator' => 'select-account',
'category' => 'select-cat',
'non_blocking' => array(''=>lang('No'), 1=>lang('Yes')),
'public' => array(''=>lang('No'), 1=>lang('Yes')),
'start' => 'date-time',
'end' => 'date-time',
'start' => 'date-time',
'end' => 'date-time',
'tz_id' => 'select-timezone',
// Participants
'participants' => array(
@ -2126,12 +2129,19 @@ function replace_eTemplate_onsubmit()
'label',
$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.
if($content['recur_type'] || $content['recurrence']) {
if($content['recur_type'] || $content['recurrence'])
{
$content['history']['filter'] = array(
'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
@ -2141,7 +2151,8 @@ function replace_eTemplate_onsubmit()
// Translate labels
$tracking = new calendar_tracking();
foreach($tracking->field2label as $field => $label) {
foreach($tracking->field2label as $field => $label)
{
$sel_options[$status][$field] = lang($label);
}
// Get custom field options

View File

@ -1,10 +1,10 @@
<?php
/**
* eGroupWare EditableTemplates - Business Objects
* EGroupware EditableTemplates - Business Objects
*
* @link http://www.egroupware.org
* @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
* @package etemplate
* @subpackage api
@ -488,7 +488,15 @@ class boetemplate extends soetemplate
*/
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

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

View File

@ -173,7 +173,14 @@ class select_widget
}
else
{
unset($value[$key]); // remove not (longer) existing or inaccessible cats
if(!$type6)
{
unset($value[$key]); // remove not (longer) existing or inaccessible cats
}
elseif ($id) // Display id of no longer existing cat
{
$cell['sel_options'][$id] = $type6 == '2' ? $id : lang('Missing: %1',$id);
}
}
}
}