mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:07 +01:00
Fix merge from listview, and handle merging from listview into a template designed for the other views (range tag, no pagerepeat)
This commit is contained in:
parent
a1cc41d0ae
commit
3286642374
@ -92,11 +92,53 @@ class calendar_merge extends bo_merge
|
||||
foreach(self::$relative as $day) {
|
||||
$this->table_plugins[$day] = 'day'; // Current day
|
||||
}
|
||||
$this->query = $GLOBALS['egw']->session->appsession('session_data','calendar');
|
||||
$this->query['users'] = explode(',', $this->query['owner']);
|
||||
$this->query = is_array($this->bo->cal_prefs['saved_states']) ?
|
||||
$this->bo->cal_prefs['saved_states'] : unserialize($this->bo->cal_prefs['saved_states']);
|
||||
|
||||
$this->query['users'] = is_array($this->query['owner']) ? $this->query['owner'] : explode(',', $this->query['owner']);
|
||||
$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 +175,7 @@ class calendar_merge extends bo_merge
|
||||
// Keep ids for future use
|
||||
$this->ids[] = $event['id'];
|
||||
}
|
||||
$id = array($id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -852,8 +852,16 @@ class calendar_ui
|
||||
));
|
||||
}
|
||||
$merge = new calendar_merge();
|
||||
return $merge->download($_GET['merge'], $timespan, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']);
|
||||
$error = $merge->download($_GET['merge'], $timespan, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']);
|
||||
// Here? Doesn't actually give the message
|
||||
egw_framework::refresh_opener($error, 'calendar');
|
||||
}
|
||||
return false;
|
||||
unset($_GET['merge']);
|
||||
|
||||
// This doesn't give message either, but at least it doesn't give a blank screen
|
||||
egw_framework::redirect_link('/index.php', array(
|
||||
'msg' => $error,
|
||||
'cd' => 'yes'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -590,6 +590,7 @@ class calendar_uilist extends calendar_ui
|
||||
$document_merge = new calendar_merge();
|
||||
$msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']);
|
||||
$failed = count($checked);
|
||||
error_log($msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -162,6 +162,12 @@ class calendar_uiviews extends calendar_ui
|
||||
// for a single owner we add it's name to the app-header
|
||||
(count(explode(',',$this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : '');
|
||||
|
||||
// Check for GET message (from merge)
|
||||
if($_GET['msg'])
|
||||
{
|
||||
egw_framework::message($_GET['msg']);
|
||||
unset($_GET['msg']);
|
||||
}
|
||||
// standard params for calling bocal::search for all views
|
||||
$this->owner = str_replace('%2C',',',$this->owner);
|
||||
$this->search_params = array(
|
||||
|
@ -1641,6 +1641,10 @@ app.classes.calendar = AppJS.extend(
|
||||
|
||||
var nm = view.etemplates[0].widgetContainer.getWidgetById('nm');
|
||||
nm.applyFilters(state.state);
|
||||
if(!state.state.end_date && nm.activeFilters.enddate)
|
||||
{
|
||||
this.state.last = nm.activeFilters.enddate;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update re-orderable calendars */
|
||||
|
@ -53,7 +53,7 @@ if(view_change >= 0) {update.view = app.calendar.sidebox_changes_views[view_chan
|
||||
<taglist id="owner" class="et2_fullWidth" onchange="app.calendar.update_state({owner: widget.getValue()});" autocomplete_params=''/>
|
||||
-->
|
||||
<select id="filter" no_lang="true" class="et2_fullWidth" onchange="app.calendar.update_state({filter: widget.getValue()});"/>
|
||||
<select id="merge" empty_label="Insert in document" onchange="if(widget.getValue()) {widget.getInstanceManager().postSubmit();}window.setTimeout(function() {widget.set_value('');},100);return false;" class="et2_fullWidth"/>/>
|
||||
<select id="merge" empty_label="Insert in document" onchange="if(widget.getValue()) {widget.getRoot().getWidgetById('first').set_value(app.calendar.state.first);widget.getRoot().getWidgetById('last').set_value(app.calendar.state.last); widget.getInstanceManager().postSubmit();} window.setTimeout(function() {widget.set_value('');},100);return false;" class="et2_fullWidth"/>/>
|
||||
</vbox>
|
||||
<iframe id="iframe" width="100%" height="100%"/>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user