Log history of custom fields also

This commit is contained in:
Nathan Gray 2010-02-12 16:47:15 +00:00
parent 989bba917f
commit fb50bee888
2 changed files with 33 additions and 1 deletions

View File

@ -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;
}
}
}

View File

@ -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'];
}
}
}
}
}