forked from extern/egroupware
Add history logging to addressbook
This commit is contained in:
parent
df51d3a409
commit
0db5355347
@ -126,6 +126,13 @@ class addressbook_bo extends addressbook_so
|
|||||||
*/
|
*/
|
||||||
var $categories;
|
var $categories;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracking changes
|
||||||
|
*
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
|
protected $tracking;
|
||||||
|
|
||||||
function __construct($contact_app='addressbook')
|
function __construct($contact_app='addressbook')
|
||||||
{
|
{
|
||||||
parent::__construct($contact_app);
|
parent::__construct($contact_app);
|
||||||
@ -253,6 +260,8 @@ class addressbook_bo extends addressbook_so
|
|||||||
$this->org_fields = unserialize($GLOBALS['egw_info']['server']['org_fileds_to_update']);
|
$this->org_fields = unserialize($GLOBALS['egw_info']['server']['org_fileds_to_update']);
|
||||||
}
|
}
|
||||||
$this->categories = new categories($this->user,'addressbook');
|
$this->categories = new categories($this->user,'addressbook');
|
||||||
|
|
||||||
|
$this->tracking = new addressbook_tracking($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -650,6 +659,7 @@ class addressbook_bo extends addressbook_so
|
|||||||
{
|
{
|
||||||
egw_link::unlink(0,'addressbook',$id);
|
egw_link::unlink(0,'addressbook',$id);
|
||||||
$GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $id, 'delete', time());
|
$GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $id, 'delete', time());
|
||||||
|
$this->tracking->track(array('id' => $id), array('id' => $id), null, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -736,6 +746,10 @@ class addressbook_bo extends addressbook_so
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get old record for tracking changes
|
||||||
|
$old = $this->read($contact['id']);
|
||||||
|
|
||||||
// we dont update the content-history, if we run inside setup (admin-account-creation)
|
// we dont update the content-history, if we run inside setup (admin-account-creation)
|
||||||
if(!($this->error = parent::save($to_write)) && is_object($GLOBALS['egw']->contenthistory))
|
if(!($this->error = parent::save($to_write)) && is_object($GLOBALS['egw']->contenthistory))
|
||||||
{
|
{
|
||||||
@ -754,6 +768,9 @@ class addressbook_bo extends addressbook_so
|
|||||||
$to_write['location'] = 'editaccountcontact';
|
$to_write['location'] = 'editaccountcontact';
|
||||||
$GLOBALS['egw']->hooks->process($to_write,False,True); // called for every app now, not only enabled ones));
|
$GLOBALS['egw']->hooks->process($to_write,False,True); // called for every app now, not only enabled ones));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Record change history
|
||||||
|
$this->tracking->track($to_write, $old);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->error ? false : $contact['id'];
|
return $this->error ? false : $contact['id'];
|
||||||
|
@ -53,10 +53,6 @@ class addressbook_contactform
|
|||||||
$contact = new addressbook_bo();
|
$contact = new addressbook_bo();
|
||||||
if ($content['owner']) // save the contact in the addressbook
|
if ($content['owner']) // save the contact in the addressbook
|
||||||
{
|
{
|
||||||
if ($content['email_contactform']) // only necessary as long addressbook is not doing this itself
|
|
||||||
{
|
|
||||||
$tracking = new addressbook_tracking($contact);
|
|
||||||
}
|
|
||||||
if (($id = $contact->save($content)))
|
if (($id = $contact->save($content)))
|
||||||
{
|
{
|
||||||
// check for fileuploads and attach the found files
|
// check for fileuploads and attach the found files
|
||||||
@ -67,9 +63,6 @@ class addressbook_contactform
|
|||||||
egw_link::link('addressbook',$id,egw_link::VFS_APPNAME,$value,$name);
|
egw_link::link('addressbook',$id,egw_link::VFS_APPNAME,$value,$name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($content['modified']); unset($content['modifier']); // not interesting for new entries
|
|
||||||
|
|
||||||
$tracking->do_notifications($content,null); // only necessary as long addressbook is not doing this itself
|
|
||||||
|
|
||||||
return '<p align="center">'.$content['msg'].'</p>';
|
return '<p align="center">'.$content['msg'].'</p>';
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,13 @@ class addressbook_tracking extends bo_tracking
|
|||||||
parent::__construct(); // calling the constructor of the extended class
|
parent::__construct(); // calling the constructor of the extended class
|
||||||
|
|
||||||
$this->contacts =& $bocontacts;
|
$this->contacts =& $bocontacts;
|
||||||
|
|
||||||
|
if(is_object($bocontacts->somain)) {
|
||||||
|
$this->field2history = array_combine($bocontacts->somain->db_cols, $bocontacts->somain->db_cols);
|
||||||
|
unset($this->field2history['modified']);
|
||||||
|
unset($this->field2history['modifier']);
|
||||||
|
unset($this->field2history['etag']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,4 +241,4 @@ class addressbook_tracking extends bo_tracking
|
|||||||
}
|
}
|
||||||
return $details;
|
return $details;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1456,6 +1456,10 @@ class addressbook_ui extends addressbook_bo
|
|||||||
'to_app' => 'addressbook',
|
'to_app' => 'addressbook',
|
||||||
'to_id' => $content['link_to']['to_id'],
|
'to_id' => $content['link_to']['to_id'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Enable history
|
||||||
|
$this->setup_history($content, $sel_options);
|
||||||
|
|
||||||
$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo');
|
$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo');
|
||||||
|
|
||||||
if ($content['private']) $content['owner'] .= 'p';
|
if ($content['private']) $content['owner'] .= 'p';
|
||||||
@ -1666,6 +1670,10 @@ class addressbook_ui extends addressbook_bo
|
|||||||
{
|
{
|
||||||
$content['owner'] .= 'p';
|
$content['owner'] .= 'p';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable history
|
||||||
|
$this->setup_history($content, $sel_options);
|
||||||
|
|
||||||
// disable not needed tabs
|
// disable not needed tabs
|
||||||
$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
|
$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
|
||||||
$readonlys['tabs']['custom'] = !$this->customfields;
|
$readonlys['tabs']['custom'] = !$this->customfields;
|
||||||
@ -2132,4 +2140,23 @@ class addressbook_ui extends addressbook_bo
|
|||||||
$this->tmpl->read('addressbook.index.cat_add');
|
$this->tmpl->read('addressbook.index.cat_add');
|
||||||
return $this->tmpl->exec('addressbook.addressbook_ui.cat_add',$content,$sel_options,$readonlys,$content, 2);
|
return $this->tmpl->exec('addressbook.addressbook_ui.cat_add',$content,$sel_options,$readonlys,$content, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up history log widget
|
||||||
|
*/
|
||||||
|
protected function setup_history(&$content, &$sel_options) {
|
||||||
|
$content['history'] = array(
|
||||||
|
'id' => $content['id'],
|
||||||
|
'app' => 'addressbook',
|
||||||
|
'status-widgets' => array(
|
||||||
|
'owner' => 'select-account',
|
||||||
|
'cat_id' => 'select-cat',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($this->content_types as $id => $settings) {
|
||||||
|
$content['history']['status-widgets']['tid'][$id] = $settings['name'];
|
||||||
|
}
|
||||||
|
$sel_options['status'] = $this->contact_fields;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user