From 1985580304e5d93d2664a088ffa8d837c861f31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Wed, 12 May 2010 11:15:45 +0000 Subject: [PATCH] New Delete Series Dialog --- calendar/inc/class.calendar_uiforms.inc.php | 84 ++++++++++++++++++++- calendar/setup/etemplates.inc.php | 20 ++++- 2 files changed, 100 insertions(+), 4 deletions(-) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index b5ecbbf4f7..c1d1f94ddd 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -170,6 +170,8 @@ class calendar_uiforms extends calendar_ui { return $this->edit(null,null,strip_tags($_GET['msg'])); } + $messages = null; + $msg_permission_denied_added = false; $referer = !empty($content['referer']) ? $content['referer'] : '/index.php?menuaction='.$this->view_menuaction; list($button) = @each($content['button']); if (!$button && $content['action']) $button = $content['action']; // action selectbox @@ -591,14 +593,34 @@ class calendar_uiforms extends calendar_ui { if ($content['reference'] == 0 && !$content['edit_single']) { - // We delete a whole series + $msg = lang('Series deleted'); + $exceptions_kept = false; + // Handle the exceptions $recur_exceptions = $this->bo->so->get_related($event['uid']); foreach ($recur_exceptions as $id) { - $this->bo->delete($id); + if (empty($content['exceptions'])) + { + if (!($exception = $this->bo->read($id))) continue; + $exception['uid'] = common::generate_uid('calendar', $id); + $exception['reference'] = $exception['recurrence'] = 0; + $this->bo->update($exception, true); + $exceptions_kept = true; + } + else + { + $this->bo->delete($id); + } + } + if ($exceptions_kept) + { + $msg .= lang(', exceptions preserved'); } } - $msg = lang('Event deleted'); + else + { + $msg = lang('Event deleted'); + } $js = 'opener.location.href=\''.addslashes(egw::link($referer,array( 'msg' => $msg, ))).'\';'; @@ -855,6 +877,10 @@ class calendar_uiforms extends calendar_ui $msg = $this->_create_exception($event,$preserv); } } + if ($event['recur_type'] != MCAL_RECUR_NONE) + { + //$js .= $this->delete_series(); + } // set new start and end if given by $_GET if(isset($_GET['start'])) { $event['start'] = $_GET['start']; } if(isset($_GET['end'])) { $event['end'] = $_GET['end']; } @@ -1098,6 +1124,7 @@ class calendar_uiforms extends calendar_ui if ($event['recur_type'] != MCAL_RECUR_NONE) { $onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); + // $onclick = 'delete_series('.$event['id'].');'; $onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); // some fundamental values of an existing series should not be changed by the user @@ -1186,6 +1213,23 @@ class calendar_uiforms extends calendar_ui else { $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserv,$preserv['no_popup'] ? 0 : 2); + /* + $html = $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserv,-1); + if (!$preserv['no_popup']) + { + $this->do_header(); + } + + if ($event['recur_type'] != MCAL_RECUR_NONE) + { + $html .= ''; + $tpl = new etemplate('calendar.delete_series'); + $html .= $tpl->show(array()); + } + + $html .= ''; + echo $html; + */ } } @@ -1824,4 +1868,38 @@ class calendar_uiforms extends calendar_ui } } } + + /** + * Return HTML and Javascript to query user how to handle the exceptions while deleting the series + * + * Layout is defined in eTemplate 'calendar.delete_series' + * + * @param string $link=null url without cal_id and date GET parameters, default calendar.calendar_uiforms.edit + * @param string $target='_blank' target + * @return string + */ + function delete_series($link=null, $target='_blank') + { + if (is_null($link)) $link = egw::link('/index.php',array('menuaction'=>'calendar.calendar_uiforms.edit')); + + return ' +var calendar_edit_id; +function delete_series(id) +{ + calendar_edit_id = id; + + document.getElementById("delete_series").style.display = "inline"; + + return false; +} +function delete_exceptions(delete) +{ + document.getElementById("delete_series").style.display = "none"; + + var extra = "&cal_id="+calendar_edit_id+"&action=delete"; + if (delete) extra += "&exceptions=1"; + + '.$this->popup($link."'+extra+'").'; +}'; + } } diff --git a/calendar/setup/etemplates.inc.php b/calendar/setup/etemplates.inc.php index de395d72e9..675ddaa8f6 100644 --- a/calendar/setup/etemplates.inc.php +++ b/calendar/setup/etemplates.inc.php @@ -2,7 +2,7 @@ /** * eGroupWare - eTemplates for Application calendar * http://www.egroupware.org - * generated by soetemplate::dump4setup() 2010-04-28 15:34 + * generated by soetemplate::dump4setup() 2010-05-12 12:23 * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package calendar @@ -16,6 +16,24 @@ $templ_data[] = array('name' => 'calendar.cat_acl','template' => '','lang' => '' $templ_data[] = array('name' => 'calendar.conflicts','template' => '','lang' => '','group' => '0','version' => '1.0.1.001','data' => 'a:3:{i:0;a:3:{s:4:"type";s:5:"label";s:5:"label";s:20:" Scheduling conflict";s:4:"span";s:9:",size120b";}i:1;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:1:{s:2:"c1";s:4:",top";}i:1;a:4:{s:1:"A";a:4:{s:4:"type";s:5:"image";s:4:"name";s:34:"conflicts[$row][icon_participants]";s:5:"label";s:38:"@conflicts[$row][tooltip_participants]";s:7:"no_lang";s:1:"1";}s:1:"B";a:4:{s:4:"type";s:5:"image";s:4:"name";s:27:"conflicts[$row][icon_recur]";s:5:"label";s:28:"@conflicts[$row][text_recur]";s:7:"no_lang";s:1:"1";}s:1:"C";a:3:{s:4:"type";s:5:"label";s:4:"name";s:21:"conflicts[$row][time]";s:7:"no_lang";s:1:"1";}s:1:"D";a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:6:"2,,0,0";i:1;a:4:{s:4:"type";s:5:"label";s:4:"name";s:22:"conflicts[$row][title]";s:7:"no_lang";s:1:"1";s:4:"size";s:1:"b";}i:2;a:3:{s:4:"type";s:5:"label";s:4:"name";s:41:"conflicts[$row][conflicting_participants]";s:7:"no_lang";s:1:"1";}s:4:"help";s:23:"conflict[$row][tooltip]";}}}s:4:"rows";i:1;s:4:"cols";i:4;}i:2;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:15:"Ignore conflict";s:4:"name";s:14:"button[ignore]";s:4:"help";s:37:"Saves the event ignoring the conflict";}i:2;a:4:{s:4:"type";s:6:"button";s:4:"name";s:14:"button[reedit]";s:5:"label";s:13:"Re-Edit event";s:4:"help";s:30:"Allows to edit the event again";}i:3;a:4:{s:4:"type";s:6:"button";s:5:"label";s:15:"Freetime search";s:4:"name";s:16:"button[freetime]";s:4:"help";s:88:"Find free timeslots where the selected participants are availible for the given timespan";}}}','size' => '','style' => '','modified' => '1119080124',); +$templ_data[] = array('name' => 'calendar.delete_series','template' => '','lang' => '','group' => '0','version' => '1.7.003','data' => 'a:1:{i:0;a:8:{s:4:"type";s:4:"vbox";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:1:"2";i:1;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"1";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:30:"This event is part of a series";}s:4:"name";s:13:"dialog-header";s:4:"span";s:13:",promptheader";}i:2;a:6:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:59:"Do you want to keep the series exceptions in your calendar?";}s:4:"span";s:7:",prompt";s:4:"name";s:14:"dialog-content";i:2;a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:4:{s:4:"type";s:10:"buttononly";s:5:"label";s:15:"Keep exceptions";s:7:"onclick";s:25:"delete_exceptions(false);";s:4:"help";s:48:"All exceptions are converted into single events.";}i:2;a:4:{s:4:"type";s:10:"buttononly";s:5:"label";s:17:"Delete exceptions";s:7:"onclick";s:24:"delete_exceptions(true);";s:4:"help";s:52:"The exceptions are deleted together with the series.";}i:3;a:3:{s:4:"type";s:10:"buttononly";s:5:"label";s:6:"Cancel";s:7:"onclick";s:64:"document.getElementById(\'delete_series\').style.display = \'none\';";}s:5:"align";s:6:"center";}}s:4:"name";s:13:"delete_series";}}','size' => '','style' => '/** + * delete series and exceptions popup used in eventWidget + */ +#delete_series { + position: fixed; + top: 200px; + left: 500px; + z-index: 20000; + display: none; + border-collapse:collapse; + border-spacing:0px +} +#delete_series input { + margin: 8px; +} + +#dialog-content {display:block; height:100px; padding:6px; color:#666666; font-size:13px; margin: -2px -1px 0px -2px; width:410px}','modified' => '1273136129',); + $templ_data[] = array('name' => 'calendar.edit','template' => '','lang' => '','group' => '0','version' => '1.7.002','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:6:{i:0;a:6:{s:2:"h1";s:6:",!@msg";s:2:"c2";s:2:"th";s:1:"A";s:3:"100";s:2:"h4";s:8:",!@owner";s:1:"B";s:3:"300";s:2:"h2";s:2:"28";}i:1;a:4:{s:1:"A";a:5:{s:4:"type";s:4:"html";s:4:"span";s:13:"all,redItalic";s:4:"name";s:3:"msg";s:7:"no_lang";s:1:"1";s:5:"align";s:6:"center";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}i:2;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Title";}s:1:"B";a:5:{s:4:"type";s:4:"text";s:4:"size";s:6:"80,255";s:4:"name";s:5:"title";s:4:"span";s:3:"all";s:6:"needed";s:1:"1";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}i:3;a:4:{s:1:"A";a:5:{s:4:"type";s:3:"tab";s:4:"span";s:3:"all";s:5:"label";s:71:"General|Description|Participants|Recurrence|Custom|Links|Alarms|History";s:4:"name";s:71:"general|description|participants|recurrence|custom|links|alarms|history";s:4:"help";s:173:"Location, Start- and Endtimes, ...|Full description|Participants, Resources, ...|Repeating Event Information|Custom fields|Links, Attachments|Alarm management|Change history";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}i:4;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Owner";}s:1:"B";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:5:"owner";s:8:"readonly";s:1:"1";}s:1:"C";a:7:{s:4:"type";s:9:"date-time";s:5:"label";s:7:"Updated";s:4:"name";s:8:"modified";s:8:"readonly";s:1:"1";s:7:"no_lang";s:1:"1";s:5:"align";s:5:"right";s:4:"span";s:8:",noBreak";}s:1:"D";a:6:{s:4:"type";s:14:"select-account";s:5:"label";s:2:"by";s:4:"name";s:8:"modifier";s:8:"readonly";s:1:"1";s:5:"align";s:5:"right";s:4:"span";s:8:",noBreak";}}i:5;a:4:{s:1:"A";a:7:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"4";s:4:"span";s:1:"3";i:1;a:4:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:12:"button[save]";s:4:"help";s:22:"saves the changes made";}i:2;a:4:{s:4:"type";s:6:"button";s:4:"name";s:13:"button[apply]";s:5:"label";s:5:"Apply";s:4:"help";s:17:"apply the changes";}i:3;a:5:{s:4:"type";s:6:"button";s:4:"name";s:14:"button[cancel]";s:5:"label";s:6:"Cancel";s:4:"help";s:16:"Close the window";s:7:"onclick";s:15:"window.close();";}i:4;a:5:{s:4:"type";s:6:"select";s:4:"name";s:6:"action";s:4:"help";s:39:"Execute a further action for this entry";s:4:"size";s:10:"Actions...";s:8:"onchange";s:34:"this.form.submit(); this.value=\'\';";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:6:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:4:"name";s:14:"button[delete]";s:4:"help";s:17:"Delete this event";s:7:"onclick";s:36:"return confirm(\'Delete this event\');";s:5:"align";s:5:"right";}}}s:4:"rows";i:5;s:4:"cols";i:4;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '.end_hide { display: block; white-space: nowrap; margin-left: 10px; } .noBreak { white-space: nowrap; }','modified' => '1265901781',);