From fb50bee888a9c273a611362d25abbcae27817423 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 12 Feb 2010 16:47:15 +0000 Subject: [PATCH] Log history of custom fields also --- .../inc/class.addressbook_tracking.inc.php | 17 ++++++++++++++++- addressbook/inc/class.addressbook_ui.inc.php | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/addressbook/inc/class.addressbook_tracking.inc.php b/addressbook/inc/class.addressbook_tracking.inc.php index 9af22ff8a6..26b6d57926 100644 --- a/addressbook/inc/class.addressbook_tracking.inc.php +++ b/addressbook/inc/class.addressbook_tracking.inc.php @@ -46,6 +46,14 @@ class addressbook_tracking extends bo_tracking */ var $field2history = array( ); + + /** + * Translate field name to label + */ + public $field2label = array( + // Custom fields added in constructor + ); + /** * Should the user (passed to the track method or current user if not passed) be used as sender or get_config('sender') * @@ -79,6 +87,13 @@ class addressbook_tracking extends bo_tracking unset($this->field2history['modifier']); unset($this->field2history['etag']); } + $custom = config::get_customfields('addressbook', true); + if(is_array($custom)) { + foreach($custom as $name => $settings) { + $this->field2history['#'.$name] = '#'.$name; + $this->field2label['#'.$name] = $settings['label']; + } + } } /** @@ -241,4 +256,4 @@ class addressbook_tracking extends bo_tracking } return $details; } -} \ No newline at end of file +} diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index a1f82f437c..986544ad88 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -2158,5 +2158,22 @@ class addressbook_ui extends addressbook_bo $content['history']['status-widgets']['tid'][$id] = $settings['name']; } $sel_options['status'] = $this->contact_fields; + foreach($this->tracking->field2label as $field => $label) { + $sel_options['status'][$field] = lang($label); + } + + // Get custom field options + $custom = config::get_customfields('addressbook', true); + if(is_array($custom)) { + foreach($custom as $name => $settings) { + if(!is_array($settings['values'])) { + $content['history']['status-widgets']['#'.$name] = $settings['type']; + } elseif($settings['values']['@']) { + $content['history']['status-widgets']['#'.$name] = customfields_widget::_get_options_from_file($settings['values']['@']); + } else { + $content['history']['status-widgets']['#'.$name] = $settings['values']; + } + } + } } }