From: <nat...@us...> - 2015-10-09 19:48:36
|
Author: nathangray Date: Fri Oct 9 21:48:28 2015 New Revision: 53900 URL: http://svn.stylite.de/viewvc/egroupware?rev=53900&view=rev Log: Fix merge from listview, and handle merging from listview into a template designed for the other views (range tag, no pagerepeat) Modified: trunk/calendar/inc/class.calendar_merge.inc.php trunk/calendar/inc/class.calendar_ui.inc.php trunk/calendar/inc/class.calendar_uilist.inc.php trunk/calendar/inc/class.calendar_uiviews.inc.php trunk/calendar/js/app.js trunk/calendar/templates/default/sidebox.xet Modified: trunk/calendar/inc/class.calendar_merge.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/calendar/inc/class.calendar_merge.inc.php?rev=53900&r1=53899&r2=53900&view=diff ============================================================================== --- trunk/calendar/inc/class.calendar_merge.inc.php (original) +++ trunk/calendar/inc/class.calendar_merge.inc.php Fri Oct 9 21:48:28 2015 @@ -92,9 +92,51 @@ 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); } /** @@ -133,6 +175,7 @@ // Keep ids for future use $this->ids[] = $event['id']; } + $id = array($id); } else { Modified: trunk/calendar/inc/class.calendar_ui.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/calendar/inc/class.calendar_ui.inc.php?rev=53900&r1=53899&r2=53900&view=diff ============================================================================== --- trunk/calendar/inc/class.calendar_ui.inc.php (original) +++ trunk/calendar/inc/class.calendar_ui.inc.php Fri Oct 9 21:48:28 2015 @@ -852,8 +852,16 @@ )); } $merge = new calendar_merge(); - return $merge->download($_GET['merge'], $timespan, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']); - } - return false; + $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'); + } + 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' + )); } } Modified: trunk/calendar/inc/class.calendar_uilist.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/calendar/inc/class.calendar_uilist.inc.php?rev=53900&r1=53899&r2=53900&view=diff ============================================================================== --- trunk/calendar/inc/class.calendar_uilist.inc.php (original) +++ trunk/calendar/inc/class.calendar_uilist.inc.php Fri Oct 9 21:48:28 2015 @@ -590,6 +590,7 @@ $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; } Modified: trunk/calendar/inc/class.calendar_uiviews.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/calendar/inc/class.calendar_uiviews.inc.php?rev=53900&r1=53899&r2=53900&view=diff ============================================================================== --- trunk/calendar/inc/class.calendar_uiviews.inc.php (original) +++ trunk/calendar/inc/class.calendar_uiviews.inc.php Fri Oct 9 21:48:28 2015 @@ -162,6 +162,12 @@ // 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( Modified: trunk/calendar/js/app.js URL: http://svn.stylite.de/viewvc/egroupware/trunk/calendar/js/app.js?rev=53900&r1=53899&r2=53900&view=diff ============================================================================== --- trunk/calendar/js/app.js (original) +++ trunk/calendar/js/app.js Fri Oct 9 21:48:28 2015 @@ -1641,6 +1641,10 @@ 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 */ Modified: trunk/calendar/templates/default/sidebox.xet URL: http://svn.stylite.de/viewvc/egroupware/trunk/calendar/templates/default/sidebox.xet?rev=53900&r1=53899&r2=53900&view=diff ============================================================================== --- trunk/calendar/templates/default/sidebox.xet (original) +++ trunk/calendar/templates/default/sidebox.xet Fri Oct 9 21:48:28 2015 @@ -53,7 +53,7 @@ <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> |