Handle merging from listview into a template designed for the other views (range tag, no pagerepeat)

This commit is contained in:
Nathan Gray 2015-10-13 16:41:52 +00:00
parent 8b68269874
commit 740a5085a0

View File

@ -97,6 +97,46 @@ class calendar_merge extends bo_merge
$this->query['num_rows'] = -1;
}
/**
* Merges a given document with contact data
*
* Overridden from parent to be able to change a list of events into a range,
* if the target document has no pagerepeat tag. Otherwise, parent::merge_string()
* would fail because we're trying to merge multiple records with no pagerepeat tag.
*
*
* @param string $content
* @param array $ids array with contact id(s)
* @param string &$err error-message on error
* @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf
* @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
* @param string $charset=null charset to override default set by mimetype or export charset
* @return string|boolean merged document or false on error
*/
function merge_string($content,$ids,$err,$mimetype,$fix)
{
// Handle merging a list of events into a document with range instead of pagerepeat
if(strpos($content, '$$pagerepeat') === false && count($ids) > 1)
{
// Merging more than one something will fail without pagerepeat
if (is_array($ids) && $ids[0]['id'])
{
// Passed an array of events, to be handled like a date range
$events = $ids;
$ids = array('start' => PHP_INT_MAX, 'end' => 0);
$this->ids = array();
foreach($events as $event) {
if($event['start'] && egw_time::to($event['start'],'ts') < $ids['start']) $ids['start'] = egw_time::to($event['start'],'ts');
if($event['end'] && egw_time::to($event['end'],'ts') > $ids['end']) $ids['end'] = egw_time::to($event['end'],'ts');
// Keep ids for future use
$this->ids[] = $event['id'];
}
$ids = array($ids);
}
}
return parent::merge_string($content, $ids, $err, $mimetype,$fix);
}
/**
* Get replacements
*
@ -133,6 +173,7 @@ class calendar_merge extends bo_merge
// Keep ids for future use
$this->ids[] = $event['id'];
}
$id = array($id);
}
else
{