Change calendar merging to be able to handle merging a range into a document with only pagerepeat

This commit is contained in:
Nathan Gray 2015-12-02 17:34:06 +00:00
parent 60539797af
commit ecb2003f4f
3 changed files with 23 additions and 2 deletions

View File

@ -117,6 +117,7 @@ class calendar_merge extends bo_merge
*/
function merge_string($content,$ids,$err,$mimetype,$fix)
{
error_log(__METHOD__ . ' IDs: ' . array2string($ids));
// Handle merging a list of events into a document with range instead of pagerepeat
if(strpos($content, '$$pagerepeat') === false && strpos($content, '{{pagerepeat') === false && count($ids) > 1)
{
@ -136,6 +137,22 @@ class calendar_merge extends bo_merge
$ids = array($ids);
}
}
// Handle merging a range of events into a document with pagerepeat instead of range
else if ((strpos($content, '$$pagerepeat') !== false || strpos($content, '{{pagerepeat') !== false) && is_array($ids) && $ids[0] && !$id[0]['id'])
{
// Passed a range, needs to be expanded
$events = $this->bo->search($this->query + $ids[0] + array(
'offset' => 0,
'enum_recuring' => true,
'order' => 'cal_start',
'cfs' => strpos($content, '#') !== false ? array_keys(config::get_customfields('calendar')) : null
));
$ids = array();
foreach($events as $event) {
$ids[] = $event;
}
}
return parent::merge_string($content, $ids, $err, $mimetype,$fix);
}

View File

@ -622,7 +622,9 @@ class calendar_ui
}
if($content['last'])
{
$this->last = egw_time::to($content['last'],'ts');
$this->last = new egw_time($content['last']);
$this->last->setTime(23, 59, 59);
$this->last = $this->last->format('ts');
}
$_GET['merge'] = $content['merge'];
$this->merge();

View File

@ -1939,7 +1939,9 @@ app.classes.calendar = AppJS.extend(
state.state.enddate = state.state.startdate;
}
nm.applyFilters(state.state);
if(!state.state.end_date && nm.activeFilters.enddate)
// Try to keep last value up to date with what's in nextmatch
if(nm.activeFilters.enddate)
{
this.state.last = nm.activeFilters.enddate;
}