mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-27 13:22:06 +02:00
Allow the check only readable items in content history
This commit is contained in:
parent
13cf31924f
commit
da41f40507
@ -58,32 +58,49 @@ class contenthistory
|
|||||||
* @param string$_appName the appname example: infolog_notes
|
* @param string$_appName the appname example: infolog_notes
|
||||||
* @param string $_action can be modify, add or delete
|
* @param string $_action can be modify, add or delete
|
||||||
* @param string $_ts timestamp where to start searching from
|
* @param string $_ts timestamp where to start searching from
|
||||||
|
* @param array $readableItems (optional) readable items of current user
|
||||||
* @return array containing contentIds with changes
|
* @return array containing contentIds with changes
|
||||||
*/
|
*/
|
||||||
function getHistory($_appName, $_action, $_ts)
|
function getHistory($_appName, $_action, $_ts, $readableItems = false)
|
||||||
{
|
{
|
||||||
$where = array('sync_appname' => $_appName);
|
$where = array('sync_appname' => $_appName);
|
||||||
|
$ts = $this->db->to_timestamp($_ts);
|
||||||
|
$idList = array();
|
||||||
|
|
||||||
switch($_action)
|
switch($_action)
|
||||||
{
|
{
|
||||||
case 'modify':
|
case 'modify':
|
||||||
$where[] = "sync_modified > '".$this->db->to_timestamp($_ts)."' AND sync_deleted IS NULL";
|
$where[] = "sync_modified > '".$ts."' AND sync_deleted IS NULL";
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$where[] = "sync_deleted > '".$this->db->to_timestamp($_ts)."'";
|
$where[] = "sync_deleted > '".$ts."'";
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
$where[] = "sync_added > '".$this->db->to_timestamp($_ts)."' AND sync_deleted IS NULL AND sync_modified IS NULL";
|
$where[] = "sync_added > '".$ts."' AND sync_deleted IS NULL AND sync_modified IS NULL";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// no valid $_action set
|
// no valid $_action set
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$idList = array();
|
|
||||||
|
if (is_array($readableItems))
|
||||||
|
{
|
||||||
|
foreach ($readableItems as $id)
|
||||||
|
{
|
||||||
|
$where['sync_contentid'] = $id;
|
||||||
|
if (!$this->db->select(self::TABLE,'sync_contentid',$where,__LINE__,__FILE__))
|
||||||
|
{
|
||||||
|
$idList[] = $id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
foreach ($this->db->select(self::TABLE,'sync_contentid',$where,__LINE__,__FILE__) as $row)
|
foreach ($this->db->select(self::TABLE,'sync_contentid',$where,__LINE__,__FILE__) as $row)
|
||||||
{
|
{
|
||||||
$idList[] = $row['sync_contentid'];
|
$idList[] = $row['sync_contentid'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $idList;
|
return $idList;
|
||||||
}
|
}
|
||||||
@ -116,6 +133,7 @@ class contenthistory
|
|||||||
'sync_contentid' => $_id,
|
'sync_contentid' => $_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$ts = false;
|
||||||
if (($ts = $this->db->select(self::TABLE,$col,$where,__LINE__,__FILE__)->fetchColumn()))
|
if (($ts = $this->db->select(self::TABLE,$col,$where,__LINE__,__FILE__)->fetchColumn()))
|
||||||
{
|
{
|
||||||
$ts = $this->db->from_timestamp($ts);
|
$ts = $this->db->from_timestamp($ts);
|
||||||
@ -165,9 +183,6 @@ class contenthistory
|
|||||||
'sync_changedby' => $GLOBALS['egw_info']['user']['account_id'],
|
'sync_changedby' => $GLOBALS['egw_info']['user']['account_id'],
|
||||||
$_action == 'delete' ? 'sync_deleted' : 'sync_modified' => $this->db->to_timestamp($_ts),
|
$_action == 'delete' ? 'sync_deleted' : 'sync_modified' => $this->db->to_timestamp($_ts),
|
||||||
);
|
);
|
||||||
// if deleted entry get's modified, removed deleted timestamp, as it got recovered
|
|
||||||
if ($_action == 'modify') $newData['sync_deleted'] = null;
|
|
||||||
|
|
||||||
$this->db->update(self::TABLE, $newData, $where,__LINE__,__FILE__);
|
$this->db->update(self::TABLE, $newData, $where,__LINE__,__FILE__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user