Implement 'No notifications' flag when importing iCal

This commit is contained in:
Nathan Gray 2012-12-17 23:56:56 +00:00
parent a0738bd2f4
commit 2f2ad58e98
4 changed files with 17 additions and 16 deletions

View File

@ -1068,7 +1068,7 @@ class calendar_ical extends calendar_boupdate
* @param string $caldav_name=null name from CalDAV client or null (to use default)
* @return int|boolean cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied
*/
function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null)
function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
{
//error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)");
$this->events_imported = 0;
@ -1162,14 +1162,14 @@ class calendar_ical extends calendar_boupdate
{
if ($delete_exceptions)
{
$this->delete($id);
$this->delete($id,0,false,$skip_notification);
}
else
{
if (!($exception = $this->read($id))) continue;
$exception['uid'] = common::generate_uid('calendar', $id);
$exception['reference'] = $exception['recurrence'] = 0;
$this->update($exception, true);
$this->update($exception, true,true,false,true,$msg,$skip_notification);
}
}
}
@ -1499,10 +1499,10 @@ class calendar_ical extends calendar_boupdate
if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) &&
$event['status'] == 'CANCELLED')
{
if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence']))
if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification))
{
// delete fails (because no rights), reject recurrence
$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence']);
$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification);
}
continue;
}
@ -1524,7 +1524,7 @@ class calendar_ical extends calendar_boupdate
$event['reference'] = 0;
$event_to_store = $event; // prevent $event from being changed by the update method
$this->server2usertime($event_to_store);
$updated_id = $this->update($event_to_store, true);
$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
unset($event_to_store);
}
break;
@ -1562,7 +1562,7 @@ class calendar_ical extends calendar_boupdate
$event_to_store = $event; // prevent $event from being changed by the update method
$this->server2usertime($event_to_store);
$updated_id = $this->update($event_to_store, true);
$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
unset($event_to_store);
}
break;
@ -1628,13 +1628,13 @@ class calendar_ical extends calendar_boupdate
$event['owner'] = $event_info['master_event']['owner'];
$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
$this->server2usertime($event_to_store);
$this->update($event_to_store, true);
$this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
unset($event_to_store);
}
$event_to_store = $event; // prevent $event from being changed by update method
$this->server2usertime($event_to_store);
$updated_id = $this->update($event_to_store, true);
$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
unset($event_to_store);
}
break;
@ -1664,7 +1664,7 @@ class calendar_ical extends calendar_boupdate
// save the series master with the adjusted exceptions
$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
$this->server2usertime($event_to_store);
$updated_id = $this->update($event_to_store, true, true, false, false);
$updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification);
unset($event_to_store);
}
@ -1697,7 +1697,7 @@ class calendar_ical extends calendar_boupdate
{
// update the users status only
$this->set_status($event_info['stored_event']['id'], $this->user,
($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true);
($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification);
}
}
break;
@ -1715,7 +1715,7 @@ class calendar_ical extends calendar_boupdate
{
// update the users status only
$this->set_status($event_info['master_event']['id'], $this->user,
($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true);
($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification);
}
}
break;

View File

@ -125,7 +125,7 @@ class calendar_import_ical implements importexport_iface_import_plugin {
$calendar_ical = new calendar_ical;
$calendar_ical->setSupportedFields('file', '');
if (!$calendar_ical->importVCal(stream_get_contents($_stream)))
if (!$calendar_ical->importVCal(stream_get_contents($_stream), -1,null,false,0,'',null,null,null,$_definition->plugin_options['no_notification']))
{
$this->errors[] = lang('Error: importing the iCal');
}

View File

@ -56,6 +56,7 @@
$content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter'];
$definition_obj->plugin_options = $options;
}
$options['no_notification'] = $content['no_notifications'];
$plugin = new $definition_obj->plugin;

View File

@ -2,7 +2,7 @@
/**
* EGroupware - eTemplates for Application importexport
* http://www.egroupware.org
* generated by soetemplate::dump4setup() 2012-12-03 15:42
* generated by soetemplate::dump4setup() 2012-12-17 16:23
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package importexport
@ -93,7 +93,7 @@ $templ_data[] = array('name' => 'importexport.export_dialog.selection_tab','temp
$templ_data[] = array('name' => 'importexport.import_definition','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:92:"Import definitions (Attension: Existing definitions with equal names will be overwritten!!!)";}}i:2;a:1:{s:1:"A";a:2:{s:4:"type";s:4:"file";s:4:"name";s:11:"import_file";}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Import";s:4:"name";s:6:"import";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:6:"update";s:5:"label";s:26:"Update default-definitions";}}}}s:4:"rows";i:3;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1306253183',);
$templ_data[] = array('name' => 'importexport.import_dialog','template' => '','lang' => '','group' => '0','version' => '1.9.003','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:8:{i:0;a:1:{s:2:"h1";s:10:",!@message";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:4:"html";s:4:"span";s:11:"all,message";s:4:"name";s:7:"message";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:7:"appname";s:8:"onchange";s:87:"xajax_doXMLHTTP(\'importexport.importexport_import_ui.ajax_get_definitions\',this.value);";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:17:"Import definition";}s:1:"B";a:2:{s:4:"type";s:6:"select";s:4:"name";s:10:"definition";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:9:"Delimiter";}s:1:"B";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:6:"2,,0,0";s:7:"no_lang";s:1:"1";i:1;a:4:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:9:"delimiter";s:8:"onchange";s:163:"var _this = jQuery(this); var text = _this.parent().parent().find(\'input\'); if(_this.val() ==\'other\') {text.val(\'\');text.show(); text.focus();} else {text.hide();}";}i:2;a:4:{s:4:"type";s:4:"text";s:4:"name";s:15:"other_delimiter";s:4:"size";s:3:"2,1";s:4:"span";s:5:",hide";}}}i:5;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:28:"Please select file to import";}s:1:"B";a:2:{s:4:"type";s:4:"file";s:4:"name";s:4:"file";}}i:6;a:2:{s:1:"A";a:5:{s:4:"type";s:3:"box";s:4:"span";s:11:"all,preview";s:8:"readonly";s:1:"1";s:4:"size";s:1:"1";i:1;a:3:{s:4:"type";s:4:"html";s:4:"name";s:7:"preview";s:8:"readonly";s:1:"1";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:7;a:2:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:3:"all";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Import";s:4:"name";s:6:"import";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";}i:3;a:4:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"dry-run";s:5:"label";s:9:"Test only";s:5:"align";s:5:"right";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:7;s:4:"cols";i:2;}}','size' => '','style' => '.hide input {
$templ_data[] = array('name' => 'importexport.import_dialog','template' => '','lang' => '','group' => '0','version' => '1.9.004','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:8:{i:0;a:1:{s:2:"h1";s:10:",!@message";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:4:"html";s:4:"span";s:11:"all,message";s:4:"name";s:7:"message";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:7:"appname";s:8:"onchange";s:87:"xajax_doXMLHTTP(\'importexport.importexport_import_ui.ajax_get_definitions\',this.value);";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:17:"Import definition";}s:1:"B";a:2:{s:4:"type";s:6:"select";s:4:"name";s:10:"definition";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:9:"Delimiter";}s:1:"B";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:6:"2,,0,0";s:7:"no_lang";s:1:"1";i:1;a:4:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:9:"delimiter";s:8:"onchange";s:163:"var _this = jQuery(this); var text = _this.parent().parent().find(\'input\'); if(_this.val() ==\'other\') {text.val(\'\');text.show(); text.focus();} else {text.hide();}";}i:2;a:4:{s:4:"type";s:4:"text";s:4:"name";s:15:"other_delimiter";s:4:"size";s:3:"2,1";s:4:"span";s:5:",hide";}}}i:5;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:28:"Please select file to import";}s:1:"B";a:2:{s:4:"type";s:4:"file";s:4:"name";s:4:"file";}}i:6;a:2:{s:1:"A";a:5:{s:4:"type";s:3:"box";s:4:"span";s:11:"all,preview";s:8:"readonly";s:1:"1";s:4:"size";s:1:"1";i:1;a:3:{s:4:"type";s:4:"html";s:4:"name";s:7:"preview";s:8:"readonly";s:1:"1";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:7;a:2:{s:1:"A";a:7:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"4";s:4:"span";s:3:"all";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Import";s:4:"name";s:6:"import";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";}i:3;a:4:{s:4:"type";s:8:"checkbox";s:4:"name";s:16:"no_notifications";s:5:"label";s:16:"No notifications";s:5:"align";s:5:"right";}i:4;a:4:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"dry-run";s:5:"label";s:9:"Test only";s:5:"align";s:5:"right";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:7;s:4:"cols";i:2;}}','size' => '','style' => '.hide input {
display: none;
}
@ -103,7 +103,7 @@ display: none;
}
.preview tr{
vertical-align: top;
}','modified' => '1346865956',);
}','modified' => '1355786527',);
$templ_data[] = array('name' => 'importexport.schedule_edit','template' => '','lang' => '','group' => '0','version' => '1.9.003','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:12:{i:0;a:3:{s:2:"h1";s:10:",!@message";s:2:"c7";s:4:"help";s:2:"h8";s:17:",@no_delete_files";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:7:"message";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Type";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:4:"type";s:8:"onchange";i:1;}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:7:"appname";s:8:"onchange";s:137:"xajax_doXMLHTTP(\'importexport.importexport_schedule_ui.ajax_get_plugins\', document.getElementById(form::name(\'type\')).value, this.value);";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Plugin";}s:1:"B";a:4:{s:4:"type";s:6:"select";s:4:"name";s:6:"plugin";s:4:"size";s:9:"Select...";s:8:"onchange";s:144:"xajax_doXMLHTTP(\'importexport.importexport_schedule_ui.ajax_get_definitions\', document.getElementById(form::name(\'appname\')).value, this.value);";}}i:5;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:10:"Definition";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:10:"definition";s:4:"size";s:9:"Select...";}}i:6;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Target";}s:1:"B";a:3:{s:4:"type";s:4:"text";s:4:"size";s:2:"50";s:4:"name";s:6:"target";}}i:7;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:83:"Target examples: vfs://default/home/user/export.csv or http://server.net/prices.csv";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:8;a:2:{s:1:"A";a:4:{s:4:"type";s:8:"checkbox";s:5:"label";s:25:"Delete files after import";s:4:"name";s:12:"delete_files";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:9;a:2:{s:1:"A";a:7:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:1:{s:2:"c1";s:2:"th";}i:1;a:6:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Year";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Month";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"Day";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Day of week";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Hour";}s:1:"F";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Minute";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:4:"text";s:4:"name";s:4:"year";s:4:"size";s:1:"5";}s:1:"B";a:3:{s:4:"type";s:4:"text";s:4:"name";s:5:"month";s:4:"size";s:1:"5";}s:1:"C";a:3:{s:4:"type";s:4:"text";s:4:"name";s:3:"day";s:4:"size";s:1:"5";}s:1:"D";a:4:{s:4:"type";s:4:"text";s:4:"name";s:3:"dow";s:5:"align";s:6:"center";s:4:"size";s:1:"5";}s:1:"E";a:3:{s:4:"type";s:4:"text";s:4:"name";s:4:"hour";s:4:"size";s:1:"5";}s:1:"F";a:3:{s:4:"type";s:4:"text";s:4:"name";s:3:"min";s:4:"size";s:1:"5";}}i:3;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:1:"3";s:5:"label";s:11:"(* for all)";}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:2:{s:4:"type";s:5:"label";s:5:"label";s:12:"(0-6, 0=Sun)";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"(0-23)";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:3;s:4:"cols";i:6;s:4:"name";s:8:"schedule";s:4:"span";s:3:"all";s:7:"options";a:0:{}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:10;a:2:{s:1:"A";a:5:{s:4:"type";s:9:"date-time";s:4:"span";s:11:"all,message";s:5:"label";s:46:"Schedule times are server time! Currently %s.";s:4:"name";s:12:"current_time";s:8:"readonly";s:1:"1";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:11;a:2:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";s:4:"span";s:3:"all";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:4:"save";}i:2;a:4:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";s:7:"onclick";s:13:"self.close();";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:11;s:4:"cols";i:2;}}','size' => '','style' => '','modified' => '1323130226',);