forked from extern/egroupware
the best of my and ralfs version
This commit is contained in:
parent
34741ec70c
commit
f354eacf66
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/***************************************************************************\
|
/***************************************************************************\
|
||||||
* eGroupWare - content history class *
|
* eGroupWare - content history class *
|
||||||
* http://www.linux-at-work.de *
|
|
||||||
* http://www.egroupware.org *
|
* http://www.egroupware.org *
|
||||||
* Written by : Lars Kneschke [lkneschke@linux-at-work.de] *
|
* Written by : Lars Kneschke [lkneschke@linux-at-work.de] *
|
||||||
* ------------------------------------------------- *
|
* ------------------------------------------------- *
|
||||||
@ -35,6 +34,32 @@
|
|||||||
$this->table = 'egw_api_content_history';
|
$this->table = 'egw_api_content_history';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mark mapping as expired
|
||||||
|
*
|
||||||
|
* mark a mapping from externel to internal id as expired, when
|
||||||
|
* a egw entry gets deleted
|
||||||
|
*
|
||||||
|
* @param $_appName string the appname example: infolog_notes
|
||||||
|
* @param $_id int the internal egwapp content id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function expireMapping($_appName, $_id)
|
||||||
|
{
|
||||||
|
$where = array (
|
||||||
|
'map_guid' => $GLOBALS['egw']->common->generate_uid($_appName, $_id),
|
||||||
|
);
|
||||||
|
|
||||||
|
$newData = array (
|
||||||
|
'map_expired' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!$this->db->update('egw_contentmap',$newData,$where,__LINE__,__FILE__))
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the timestamp for action
|
* get the timestamp for action
|
||||||
*
|
*
|
||||||
@ -47,35 +72,34 @@
|
|||||||
*/
|
*/
|
||||||
function getHistory($_appName, $_action, $_ts)
|
function getHistory($_appName, $_action, $_ts)
|
||||||
{
|
{
|
||||||
|
$query = "select sync_guid from egw_api_content_history where sync_appname = '".$this->db->db_addslashes($_appName)."' and ";
|
||||||
|
|
||||||
switch($_action)
|
switch($_action)
|
||||||
{
|
{
|
||||||
case 'modify':
|
case 'modify':
|
||||||
$query = "sync_modified > '".$this->db->to_timestamp($_ts)."' AND sync_modified > sync_deleted";
|
$query .= "sync_modified > '".$this->db->to_timestamp($_ts)."' and sync_modified > sync_deleted";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$query = "sync_deleted > '".$this->db->to_timestamp($_ts)."'";
|
$query .= "sync_deleted > '".$this->db->to_timestamp($_ts)."'";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'add':
|
case 'add':
|
||||||
$query = "sync_added > '".$this->db->to_timestamp($_ts)."' AND sync_added > sync_deleted";
|
$query .= "sync_added > '".$this->db->to_timestamp($_ts)."' and sync_added > sync_deleted and sync_added > sync_modified";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// no valid $_action set
|
// no valid $_action set
|
||||||
return array();
|
return array();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->select($this->table,array(
|
$this->db->query($query, __LINE__, __FILE__);
|
||||||
'sync_appname' => $_appName,
|
|
||||||
$query,
|
|
||||||
), __LINE__, __FILE__);
|
|
||||||
|
|
||||||
$guidList = array();
|
$guidList = array();
|
||||||
|
|
||||||
while($this->db->next_record())
|
while($this->db->next_record())
|
||||||
{
|
{
|
||||||
$guidList[] = $this->db->f('sync_guid');
|
$guidList[] = $this->db->f('sync_guid');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $guidList;
|
return $guidList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,12 +123,15 @@
|
|||||||
{
|
{
|
||||||
case 'add':
|
case 'add':
|
||||||
return $this->db->from_timestamp($this->db->f('sync_added'));
|
return $this->db->from_timestamp($this->db->f('sync_added'));
|
||||||
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
return $this->db->from_timestamp($this->db->f('sync_deleted'));
|
return $this->db->from_timestamp($this->db->f('sync_deleted'));
|
||||||
|
break;
|
||||||
case 'modify':
|
case 'modify':
|
||||||
return $this->db->from_timestamp($this->db->f('sync_modified'));
|
return $this->db->from_timestamp($this->db->f('sync_modified'));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +155,7 @@
|
|||||||
'sync_appname' => $_appName,
|
'sync_appname' => $_appName,
|
||||||
'sync_contentid' => $_id,
|
'sync_contentid' => $_id,
|
||||||
'sync_added' => $_ts,
|
'sync_added' => $_ts,
|
||||||
'sync_guid' => $GLOBALS['egw']->common->generate_uid($_appName, $_id),
|
'sync_guid' => $GLOBALS['egw']->common->generate_uid($_appName, $_id),
|
||||||
'sync_changedby' => $GLOBALS['egw_info']['user']['account_id'],
|
'sync_changedby' => $GLOBALS['egw_info']['user']['account_id'],
|
||||||
);
|
);
|
||||||
switch($_action)
|
switch($_action)
|
||||||
@ -162,3 +189,4 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user