Completed
Push — 14.2 ( 5702a1...375f73 )
by Nathan
38:22
created
calendar/inc/class.calendar_import_ical.inc.php 3 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -101,8 +101,7 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * imports entries according to given definition object.
103 103
 	 * @param resource $_stream
104
-	 * @param string $_charset
105
-	 * @param definition $_definition
104
+	 * @param importexport_definition $_definition
106 105
 	 */
107 106
 	public function import( $_stream, importexport_definition $_definition ) {
108 107
 
@@ -157,7 +156,6 @@  discard block
 block discarded – undo
157 156
 	/**
158 157
 	 * Add a warning message about conflicting events
159 158
 	 * 
160
-	 * @param int $record_num Current record index
161 159
 	 * @param Array $conflicts List of found conflicting events
162 160
 	 */
163 161
 	public function conflict_warning(&$event, &$conflicts)
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * import ical for calendar
17 17
  */
18
-class calendar_import_ical implements importexport_iface_import_plugin  {
18
+class calendar_import_ical implements importexport_iface_import_plugin {
19 19
 
20 20
 	private static $plugin_options = array(
21
-		'fieldsep', 		// char
22
-		'charset',		// string
23
-		'owner', 		// int
24
-		'update_cats', 			// string {override|add} overides record
21
+		'fieldsep', // char
22
+		'charset', // string
23
+		'owner', // int
24
+		'update_cats', // string {override|add} overides record
25 25
 								// with cat(s) from csv OR add the cat from
26 26
 								// csv file to exeisting cat(s) of record
27 27
 		'num_header_lines', // int number of header lines
28 28
 		'field_conversion', // array( $csv_col_num => conversion)
29
-		'field_mapping',	// array( $csv_col_num => adb_filed)
30
-		'conditions',		/* => array containing condition arrays:
29
+		'field_mapping', // array( $csv_col_num => adb_filed)
30
+		'conditions', /* => array containing condition arrays:
31 31
 				'type' => exists, // exists
32 32
 				'string' => '#kundennummer',
33 33
 				'true' => array(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @param string $_charset
105 105
 	 * @param definition $_definition
106 106
 	 */
107
-	public function import( $_stream, importexport_definition $_definition ) {
107
+	public function import($_stream, importexport_definition $_definition) {
108 108
 
109 109
 		$this->definition = $_definition;
110 110
 
@@ -112,20 +112,20 @@  discard block
 block discarded – undo
112 112
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
113 113
 
114 114
 		// dry run?
115
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
115
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
116 116
 
117 117
 		// fetch the addressbook bo
118
-		$this->bo= new calendar_boupdate();
118
+		$this->bo = new calendar_boupdate();
119 119
 
120 120
 
121 121
 		// Failures
122 122
 		$this->errors = array();
123 123
 
124
-		@set_time_limit(0);     // try switching execution time limit off
124
+		@set_time_limit(0); // try switching execution time limit off
125 125
 
126 126
 		$calendar_ical = new calendar_ical;
127 127
 		$calendar_ical->setSupportedFields('file', '');
128
-		if($this->dry_run)
128
+		if ($this->dry_run)
129 129
 		{
130 130
 			// No real dry run for iCal
131 131
 			echo lang("No preview for iCal");
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 			$_definition->plugin_options['no_notification'] = true;
138 138
 		}
139 139
 		// User wants conflicting events to not be imported
140
-		if($_definition->plugin_options['skip_conflicts'])
140
+		if ($_definition->plugin_options['skip_conflicts'])
141 141
 		{
142 142
 			$calendar_ical->conflict_callback = array($this, 'conflict_warning');
143 143
 		}
144
-		if (!$calendar_ical->importVCal($_stream, -1,null,false,0,'',null,null,null,$_definition->plugin_options['no_notification']))
144
+		if (!$calendar_ical->importVCal($_stream, -1, null, false, 0, '', null, null, null, $_definition->plugin_options['no_notification']))
145 145
 		{
146 146
 			$this->errors[] = lang('Error: importing the iCal');
147 147
 		}
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public function conflict_warning(&$event, &$conflicts)
164 164
 	{
165
-		$warning = EGroupware\Api\DateTime::to($event['start']) . ' ' . $event['title'] . ' ' . lang('Conflicts') . ':';
166
-		foreach($conflicts as $conflict)
165
+		$warning = EGroupware\Api\DateTime::to($event['start']).' '.$event['title'].' '.lang('Conflicts').':';
166
+		foreach ($conflicts as $conflict)
167 167
 		{
168
-			$warning .= "<br />\n" . EGroupware\Api\DateTime::to($conflict['start']) . "\t" . $conflict['title'];
168
+			$warning .= "<br />\n".EGroupware\Api\DateTime::to($conflict['start'])."\t".$conflict['title'];
169 169
 		}
170 170
 		$this->warnings[] = $warning;
171 171
 
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	private $bo;
65 65
 
66 66
 	/**
67
-	* For figuring out if an entry has changed
68
-	*/
67
+	 * For figuring out if an entry has changed
68
+	 */
69 69
 	protected $tracking;
70 70
 
71 71
 	/**
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 	protected $errors = array();
95 95
 
96 96
 	/**
97
-	* List of actions, and how many times that action was taken
98
-	*/
97
+	 * List of actions, and how many times that action was taken
98
+	 */
99 99
 	protected $results = array();
100 100
 
101 101
 	/**
@@ -228,39 +228,39 @@  discard block
 block discarded – undo
228 228
 	}
229 229
 
230 230
 	/**
231
-        * Returns warnings that were encountered during importing
232
-        * Maximum of one warning message per record, but you can append if you need to
233
-        *
234
-        * @return Array (
235
-        *       record_# => warning message
236
-        *       )
237
-        */
238
-        public function get_warnings() {
231
+	 * Returns warnings that were encountered during importing
232
+	 * Maximum of one warning message per record, but you can append if you need to
233
+	 *
234
+	 * @return Array (
235
+	 *       record_# => warning message
236
+	 *       )
237
+	 */
238
+		public function get_warnings() {
239 239
 		return $this->warnings;
240 240
 	}
241 241
 
242 242
 	/**
243
-        * Returns errors that were encountered during importing
244
-        * Maximum of one error message per record, but you can append if you need to
245
-        *
246
-        * @return Array (
247
-        *       record_# => error message
248
-        *       )
249
-        */
250
-        public function get_errors() {
243
+	 * Returns errors that were encountered during importing
244
+	 * Maximum of one error message per record, but you can append if you need to
245
+	 *
246
+	 * @return Array (
247
+	 *       record_# => error message
248
+	 *       )
249
+	 */
250
+		public function get_errors() {
251 251
 		return $this->errors;
252 252
 	}
253 253
 
254 254
 	/**
255
-        * Returns a list of actions taken, and the number of records for that action.
256
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
257
-        *
258
-        * @return Array (
259
-        *       action => record count
260
-        * )
261
-        */
262
-        public function get_results() {
263
-                return $this->results;
264
-        }
255
+	 * Returns a list of actions taken, and the number of records for that action.
256
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
257
+	 *
258
+	 * @return Array (
259
+	 *       action => record count
260
+	 * )
261
+	 */
262
+		public function get_results() {
263
+				return $this->results;
264
+		}
265 265
 } // end of iface_export_plugin
266 266
 ?>
Please login to merge, or discard this patch.
calendar/inc/class.calendar_import_csv.inc.php 2 patches
Braces   +75 added lines, -32 removed lines patch added patch discarded remove patch
@@ -17,7 +17,8 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * class import_csv for calendar
19 19
  */
20
-class calendar_import_csv extends importexport_basic_import_csv  {
20
+class calendar_import_csv extends importexport_basic_import_csv
21
+{
21 22
 
22 23
 	/**
23 24
 	 * actions wich could be done to data entries
@@ -83,8 +84,10 @@  discard block
 block discarded – undo
83 84
 		$options['owner'] = $options['owner'] ? $options['owner'] : $this->user;
84 85
 
85 86
 		// Set owner, unless it's supposed to come from CSV file
86
-		if($options['owner_from_csv']) {
87
-			if(!is_numeric($record['owner'])) {
87
+		if($options['owner_from_csv'])
88
+		{
89
+			if(!is_numeric($record['owner']))
90
+			{
88 91
 				$this->errors[$import_csv->get_current_position()] = lang(
89 92
 					'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
90 93
 					$record->owner,
@@ -106,14 +109,16 @@  discard block
 block discarded – undo
106 109
 		}
107 110
 
108 111
 		// Parse particpants
109
-		if ($record->participants && !is_array($record->participants)) {
112
+		if ($record->participants && !is_array($record->participants))
113
+		{
110 114
 			// Importing participants in human friendly format:
111 115
 			// Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+
112 116
 			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants);
113 117
 			$p_participants = array();
114 118
 			$missing = array();
115 119
 			list($lines, $p, $names, $quantity, $status, $role) = $participants;
116
-			foreach($names as $key => $name) {
120
+			foreach($names as $key => $name)
121
+			{
117 122
 				//error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}");
118 123
 
119 124
 				// Search for direct account name, then user in accounts first
@@ -121,9 +126,13 @@  discard block
 block discarded – undo
121 126
 				$id = importexport_helper_functions::account_name2id($name);
122 127
 
123 128
 				// If not found, or not an exact match to a user (account_name2id is pretty generous)
124
-				if(!$id || $names[$key] !== $this->bo->participant_name($id)) {
129
+				if(!$id || $names[$key] !== $this->bo->participant_name($id))
130
+				{
125 131
 					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1));
126
-					if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
132
+					if($contacts)
133
+					{
134
+						$id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
135
+					}
127 136
 				}
128 137
 				if(!$id)
129 138
 				{
@@ -131,7 +140,10 @@  discard block
 block discarded – undo
131 140
 					foreach($this->bo->resources as $resource)
132 141
 					{
133 142
 						// Can't search for email
134
-						if($resource['app'] == 'email') continue;
143
+						if($resource['app'] == 'email')
144
+						{
145
+							continue;
146
+						}
135 147
 						// Special resource search, since it does special stuff in link_query
136 148
 						if($resource['app'] == 'resources')
137 149
 						{
@@ -140,7 +152,8 @@  discard block
 block discarded – undo
140 152
 								$this->resource_so = new resources_so();
141 153
 							}
142 154
 							$result = $this->resource_so->search($search,'res_id');
143
-							if(count($result) >= 1) {
155
+							if(count($result) >= 1)
156
+							{
144 157
 								$id = $resource['type'].$result[0]['res_id'];
145 158
 								break;
146 159
 							}
@@ -159,7 +172,8 @@  discard block
 block discarded – undo
159 172
 						}
160 173
 					}
161 174
 				}
162
-				if($id) {
175
+				if($id)
176
+				{
163 177
 					$p_participants[$id] = calendar_so::combine_status(
164 178
 						$this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0],
165 179
 						$quantity[$key] ? $quantity[$key] : 1,
@@ -188,27 +202,38 @@  discard block
 block discarded – undo
188 202
 		}
189 203
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
190 204
 
191
-		if ( $options['conditions'] ) {
192
-			foreach ( $options['conditions'] as $condition ) {
205
+		if ( $options['conditions'] )
206
+		{
207
+			foreach ( $options['conditions'] as $condition )
208
+			{
193 209
 				$records = array();
194
-				switch ( $condition['type'] ) {
210
+				switch ( $condition['type'] )
211
+				{
195 212
 					// exists
196 213
 					case 'exists' :
197 214
 						// Check for that record
198 215
 						$result = $this->exists($record, $condition, $records);
199 216
 
200
-						if ( is_array( $records ) && count( $records ) >= 1) {
217
+						if ( is_array( $records ) && count( $records ) >= 1)
218
+						{
201 219
 							// apply action to all records matching this exists condition
202 220
 							$action = $condition['true'];
203
-							foreach ( (array)$records as $event ) {
221
+							foreach ( (array)$records as $event )
222
+							{
204 223
 								$record->id = $event['id'];
205
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
206
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
224
+								if ( $this->definition->plugin_options['update_cats'] == 'add' )
225
+								{
226
+									if ( !is_array( $record->category ) )
227
+									{
228
+										$record->category = explode( ',', $record->category );
229
+									}
207 230
 									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
208 231
 								}
209 232
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
210 233
 							}
211
-						} else {
234
+						}
235
+						else
236
+						{
212 237
 							$action = $condition['false'];
213 238
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
214 239
 						}
@@ -219,9 +244,14 @@  discard block
 block discarded – undo
219 244
 						die('condition / action not supported!!!');
220 245
 						break;
221 246
 				}
222
-				if ($action['last']) break;
247
+				if ($action['last'])
248
+				{
249
+					break;
250
+				}
223 251
 			}
224
-		} else {
252
+		}
253
+		else
254
+		{
225 255
 			// unconditional insert
226 256
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
227 257
 		}
@@ -240,12 +270,14 @@  discard block
 block discarded – undo
240 270
 	 */
241 271
 	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
242 272
 	{
243
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
273
+		if($record->__get($condition['string']) && $condition['string'] == 'id')
274
+		{
244 275
 			$event = $this->bo->read($record->__get($condition['string']));
245 276
 			$records = array($event);
246 277
 		}
247 278
 
248
-		if ( is_array( $records ) && count( $records ) >= 1) {
279
+		if ( is_array( $records ) && count( $records ) >= 1)
280
+		{
249 281
 			return true;
250 282
 		}
251 283
 		return false;
@@ -261,7 +293,8 @@  discard block
 block discarded – undo
261 293
 	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
262 294
 	{
263 295
 		$_data = $record->get_record_array();
264
-		switch ($_action) {
296
+		switch ($_action)
297
+		{
265 298
 			case 'none' :
266 299
 				return true;
267 300
 			case 'update' :
@@ -269,7 +302,8 @@  discard block
 block discarded – undo
269 302
 				$old = $this->bo->read($_data['id']);
270 303
 
271 304
 				// Don't change a user account into a record
272
-				if(!$this->definition->plugin_options['change_owner']) {
305
+				if(!$this->definition->plugin_options['change_owner'])
306
+				{
273 307
 					// Don't change owner of an existing record
274 308
 					unset($_data['owner']);
275 309
 				}
@@ -277,23 +311,27 @@  discard block
 block discarded – undo
277 311
 				// Merge to deal with fields not in import record
278 312
 				$_data = array_merge($old, $_data);
279 313
 				$changed = $this->tracking->changed_fields($_data, $old);
280
-				if(count($changed) == 0) {
314
+				if(count($changed) == 0)
315
+				{
281 316
 					return true;
282 317
 				}
283 318
 				// Fall through
284 319
 			case 'insert' :
285
-				if($_action == 'insert') {
320
+				if($_action == 'insert')
321
+				{
286 322
 					// Backend doesn't like inserting with ID specified, can overwrite existing
287 323
 					unset($_data['id']);
288 324
 				}
289 325
 				// Make sure participants are set
290
-				if(!$_data['participants']) {
326
+				if(!$_data['participants'])
327
+				{
291 328
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
292 329
 					$_data['participants'] = array(
293 330
 						$user => 'U'
294 331
 					);
295 332
 				}
296
-				if ( $this->dry_run ) {
333
+				if ( $this->dry_run )
334
+				{
297 335
 					//print_r($_data);
298 336
 					// User is interested in conflict checks, do so for dry run
299 337
 					// Otherwise, conflicts are just ignored and imported anyway
@@ -309,7 +347,9 @@  discard block
 block discarded – undo
309 347
 					}
310 348
 					$this->results[$_action]++;
311 349
 					return true;
312
-				} else {
350
+				}
351
+				else
352
+				{
313 353
 					$messages = null;
314 354
 					$result = $this->bo->update( $_data, 
315 355
 						!$this->definition->plugin_options['skip_conflicts'],
@@ -360,7 +400,8 @@  discard block
 block discarded – undo
360 400
 	 *
361 401
 	 * @return string name
362 402
 	 */
363
-	public static function get_name() {
403
+	public static function get_name()
404
+	{
364 405
 		return lang('Calendar CSV import');
365 406
 	}
366 407
 
@@ -369,7 +410,8 @@  discard block
 block discarded – undo
369 410
 	 *
370 411
 	 * @return string descriprion
371 412
 	 */
372
-	public static function get_description() {
413
+	public static function get_description()
414
+	{
373 415
 		return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
374 416
 	}
375 417
 
@@ -378,7 +420,8 @@  discard block
 block discarded – undo
378 420
 	 *
379 421
 	 * @return string suffix (comma seperated)
380 422
 	 */
381
-	public static function get_filesuffix() {
423
+	public static function get_filesuffix()
424
+	{
382 425
 		return 'csv';
383 426
 	}
384 427
 
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * class import_csv for calendar
19 19
  */
20
-class calendar_import_csv extends importexport_basic_import_csv  {
20
+class calendar_import_csv extends importexport_basic_import_csv {
21 21
 
22 22
 	/**
23 23
 	 * actions wich could be done to data entries
24 24
 	 */
25
-	protected static $actions = array( 'none', 'update', 'insert' );
25
+	protected static $actions = array('none', 'update', 'insert');
26 26
 
27 27
 	/**
28 28
 	 * conditions for actions
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * Set up tracker
46 46
 	 */
47
-	protected function init(importexport_definition &$definition)
47
+	protected function init(importexport_definition&$definition)
48 48
 	{
49 49
 		// fetch the addressbook bo
50
-		$this->bo= new calendar_boupdate();
50
+		$this->bo = new calendar_boupdate();
51 51
 
52 52
 		// Get the tracker for changes
53 53
 		$this->tracking = new calendar_tracking();
54 54
 
55 55
 		// Used for participants
56
-		$this->status_map = array_flip(array_map('lang',$this->bo->verbose_status));
56
+		$this->status_map = array_flip(array_map('lang', $this->bo->verbose_status));
57 57
 		$this->role_map = array_flip($this->bo->roles);
58 58
 
59 59
 		$this->lookups = array(
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return boolean success
78 78
 	 */
79
-	public function import_record(\importexport_iface_egw_record &$record, &$import_csv)
79
+	public function import_record(\importexport_iface_egw_record&$record, &$import_csv)
80 80
 	{
81 81
 		// set eventOwner
82
-		$options =& $this->definition->plugin_options;
82
+		$options = & $this->definition->plugin_options;
83 83
 		$options['owner'] = $options['owner'] ? $options['owner'] : $this->user;
84 84
 
85 85
 		// Set owner, unless it's supposed to come from CSV file
86
-		if($options['owner_from_csv']) {
87
-			if(!is_numeric($record['owner'])) {
86
+		if ($options['owner_from_csv']) {
87
+			if (!is_numeric($record['owner'])) {
88 88
 				$this->errors[$import_csv->get_current_position()] = lang(
89 89
 					'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
90 90
 					$record->owner,
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		}
100 100
 		
101 101
 		// Handle errors in length or start/end date
102
-		if($record->start > $record->end)
102
+		if ($record->start > $record->end)
103 103
 		{
104 104
 			$record->end = $record->start + $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60;
105 105
 			$this->warnings[$import_csv->get_current_position()] = lang('error: starttime has to be before the endtime !!!');
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 		if ($record->participants && !is_array($record->participants)) {
110 110
 			// Importing participants in human friendly format:
111 111
 			// Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+
112
-			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants);
112
+			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/', $record->participants, $participants);
113 113
 			$p_participants = array();
114 114
 			$missing = array();
115 115
 			list($lines, $p, $names, $quantity, $status, $role) = $participants;
116
-			foreach($names as $key => $name) {
116
+			foreach ($names as $key => $name) {
117 117
 				//error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}");
118 118
 
119 119
 				// Search for direct account name, then user in accounts first
@@ -121,26 +121,26 @@  discard block
 block discarded – undo
121 121
 				$id = importexport_helper_functions::account_name2id($name);
122 122
 
123 123
 				// If not found, or not an exact match to a user (account_name2id is pretty generous)
124
-				if(!$id || $names[$key] !== $this->bo->participant_name($id)) {
125
-					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1));
126
-					if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
124
+				if (!$id || $names[$key] !== $this->bo->participant_name($id)) {
125
+					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search, array('contact_id', 'account_id'), 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', array(0, 1));
126
+					if ($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
127 127
 				}
128
-				if(!$id)
128
+				if (!$id)
129 129
 				{
130 130
 					// Use calendar's registered resources to find participant
131
-					foreach($this->bo->resources as $resource)
131
+					foreach ($this->bo->resources as $resource)
132 132
 					{
133 133
 						// Can't search for email
134
-						if($resource['app'] == 'email') continue;
134
+						if ($resource['app'] == 'email') continue;
135 135
 						// Special resource search, since it does special stuff in link_query
136
-						if($resource['app'] == 'resources')
136
+						if ($resource['app'] == 'resources')
137 137
 						{
138
-							if(!$this->resource_so)
138
+							if (!$this->resource_so)
139 139
 							{
140 140
 								$this->resource_so = new resources_so();
141 141
 							}
142
-							$result = $this->resource_so->search($search,'res_id');
143
-							if(count($result) >= 1) {
142
+							$result = $this->resource_so->search($search, 'res_id');
143
+							if (count($result) >= 1) {
144 144
 								$id = $resource['type'].$result[0]['res_id'];
145 145
 								break;
146 146
 							}
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 							$link_options = array();
152 152
 							$result = Link::query($resource['app'], $search, $link_options);
153 153
 
154
-							if($result)
154
+							if ($result)
155 155
 							{
156
-								$id = $resource['type'] . key($result);
156
+								$id = $resource['type'].key($result);
157 157
 								break;
158 158
 							}
159 159
 						}
160 160
 					}
161 161
 				}
162
-				if($id) {
162
+				if ($id) {
163 163
 					$p_participants[$id] = calendar_so::combine_status(
164 164
 						$this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0],
165 165
 						$quantity[$key] ? $quantity[$key] : 1,
@@ -170,47 +170,47 @@  discard block
 block discarded – undo
170 170
 				{
171 171
 					$missing[] = $name;
172 172
 				}
173
-				if(count($missing) > 0)
173
+				if (count($missing) > 0)
174 174
 				{
175
-					$this->warnings[$import_csv->get_current_position()] = $record->title . ' ' . lang('participants') . ': ' .
176
-						lang('Contact not found!') . '<br />'.implode(", ",$missing);
175
+					$this->warnings[$import_csv->get_current_position()] = $record->title.' '.lang('participants').': '.
176
+						lang('Contact not found!').'<br />'.implode(", ", $missing);
177 177
 				}
178 178
 			}
179 179
 			$record->participants = $p_participants;
180 180
 		}
181 181
 
182
-		if($record->recurrence)
182
+		if ($record->recurrence)
183 183
 		{
184
-			list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2);
184
+			list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2);
185 185
 			$record->recur_interval = trim($record->recur_interval);
186
-			$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$this->lookups['recurrence']));
186
+			$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $this->lookups['recurrence']));
187 187
 			unset($record->recurrence);
188 188
 		}
189 189
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
190 190
 
191
-		if ( $options['conditions'] ) {
192
-			foreach ( $options['conditions'] as $condition ) {
191
+		if ($options['conditions']) {
192
+			foreach ($options['conditions'] as $condition) {
193 193
 				$records = array();
194
-				switch ( $condition['type'] ) {
194
+				switch ($condition['type']) {
195 195
 					// exists
196 196
 					case 'exists' :
197 197
 						// Check for that record
198 198
 						$result = $this->exists($record, $condition, $records);
199 199
 
200
-						if ( is_array( $records ) && count( $records ) >= 1) {
200
+						if (is_array($records) && count($records) >= 1) {
201 201
 							// apply action to all records matching this exists condition
202 202
 							$action = $condition['true'];
203
-							foreach ( (array)$records as $event ) {
203
+							foreach ((array)$records as $event) {
204 204
 								$record->id = $event['id'];
205
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
206
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
207
-									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
205
+								if ($this->definition->plugin_options['update_cats'] == 'add') {
206
+									if (!is_array($record->category)) $record->category = explode(',', $record->category);
207
+									$record->category = implode(',', array_unique(array_merge($record->category, $event['category'])));
208 208
 								}
209
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
209
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
210 210
 							}
211 211
 						} else {
212 212
 							$action = $condition['false'];
213
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
213
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
214 214
 						}
215 215
 						break;
216 216
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			}
224 224
 		} else {
225 225
 			// unconditional insert
226
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
226
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
227 227
 		}
228 228
 		
229 229
 		return $success;
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return boolean
240 240
 	 */
241
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
241
+	protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$records = array())
242 242
 	{
243
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
243
+		if ($record->__get($condition['string']) && $condition['string'] == 'id') {
244 244
 			$event = $this->bo->read($record->__get($condition['string']));
245 245
 			$records = array($event);
246 246
 		}
247 247
 
248
-		if ( is_array( $records ) && count( $records ) >= 1) {
248
+		if (is_array($records) && count($records) >= 1) {
249 249
 			return true;
250 250
 		}
251 251
 		return false;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @param array $_data record data for the action
259 259
 	 * @return bool success or not
260 260
 	 */
261
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
261
+	protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0)
262 262
 	{
263 263
 		$_data = $record->get_record_array();
264 264
 		switch ($_action) {
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 				$old = $this->bo->read($_data['id']);
270 270
 
271 271
 				// Don't change a user account into a record
272
-				if(!$this->definition->plugin_options['change_owner']) {
272
+				if (!$this->definition->plugin_options['change_owner']) {
273 273
 					// Don't change owner of an existing record
274 274
 					unset($_data['owner']);
275 275
 				}
@@ -277,30 +277,30 @@  discard block
 block discarded – undo
277 277
 				// Merge to deal with fields not in import record
278 278
 				$_data = array_merge($old, $_data);
279 279
 				$changed = $this->tracking->changed_fields($_data, $old);
280
-				if(count($changed) == 0) {
280
+				if (count($changed) == 0) {
281 281
 					return true;
282 282
 				}
283 283
 				// Fall through
284 284
 			case 'insert' :
285
-				if($_action == 'insert') {
285
+				if ($_action == 'insert') {
286 286
 					// Backend doesn't like inserting with ID specified, can overwrite existing
287 287
 					unset($_data['id']);
288 288
 				}
289 289
 				// Make sure participants are set
290
-				if(!$_data['participants']) {
290
+				if (!$_data['participants']) {
291 291
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
292 292
 					$_data['participants'] = array(
293 293
 						$user => 'U'
294 294
 					);
295 295
 				}
296
-				if ( $this->dry_run ) {
296
+				if ($this->dry_run) {
297 297
 					//print_r($_data);
298 298
 					// User is interested in conflict checks, do so for dry run
299 299
 					// Otherwise, conflicts are just ignored and imported anyway
300
-					if($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking'])
300
+					if ($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking'])
301 301
 					{
302 302
 						$conflicts = $this->bo->conflicts($_data);
303
-						if($conflicts)
303
+						if ($conflicts)
304 304
 						{
305 305
 							$this->conflict_warning($record_num, $conflicts);
306 306
 							$this->results['skipped']++;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 					return true;
312 312
 				} else {
313 313
 					$messages = null;
314
-					$result = $this->bo->update( $_data, 
314
+					$result = $this->bo->update($_data, 
315 315
 						!$this->definition->plugin_options['skip_conflicts'],
316 316
 						true, $this->is_admin, true, $messages,
317 317
 						$this->definition->plugin_options['no_notification']
318 318
 					);
319
-					if(!$result)
319
+					if (!$result)
320 320
 					{
321
-						$this->errors[$record_num] = lang('Unable to save') . "\n" .
322
-							implode("\n",$messages);
321
+						$this->errors[$record_num] = lang('Unable to save')."\n".
322
+							implode("\n", $messages);
323 323
 					}
324 324
 					else if (is_array($result))
325 325
 					{
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 	 */
350 350
 	protected function conflict_warning($record_num, &$conflicts)
351 351
 	{
352
-		$this->warnings[$record_num] = lang('Conflicts') . ':';
353
-		foreach($conflicts as $conflict)
352
+		$this->warnings[$record_num] = lang('Conflicts').':';
353
+		foreach ($conflicts as $conflict)
354 354
 		{
355
-			$this->warnings[$record_num] .= "<br />\n" . Api\DateTime::to($conflict['start']) . "\t" . $conflict['title'];
355
+			$this->warnings[$record_num] .= "<br />\n".Api\DateTime::to($conflict['start'])."\t".$conflict['title'];
356 356
 		}
357 357
 	}
358 358
 
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 	 *
389 389
 	 * @param egw_record $row_entry
390 390
 	 */
391
-	protected function row_preview(importexport_iface_egw_record &$row_entry)
391
+	protected function row_preview(importexport_iface_egw_record&$row_entry)
392 392
 	{
393
-		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true));
393
+		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true));
394 394
 	}
395 395
 
396 396
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
calendar/inc/class.calendar_wizard_import_ical.inc.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@
 block discarded – undo
15 15
 class calendar_wizard_import_ical
16 16
 {
17 17
 	/**
18
-	* List of steps.  Key is the function, value is the translated title.
19
-	*/
18
+	 * List of steps.  Key is the function, value is the translated title.
19
+	 */
20 20
 	public $steps;
21 21
 
22 22
 	/**
23
-	* List of eTemplates to use for each step.  You can override this with your own etemplates steps.
24
-	*/
23
+	 * List of eTemplates to use for each step.  You can override this with your own etemplates steps.
24
+	 */
25 25
 	protected $step_templates = array(
26 26
 		'wizard_step55' => 'calendar.import.conditions'
27 27
 	);
28
-    /**
28
+	/**
29 29
 	 * constructor
30 30
 	 */
31 31
 	function __construct()
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
39 39
 	{
40 40
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
41
-		$content['msg'] .= "\n*" ;
41
+		$content['msg'] .= "\n*";
42 42
 
43 43
 		return $result;
44 44
 	}
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
 			switch (array_search('pressed', $content['button']))
53 53
 			{
54 54
 				case 'next':
55
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
55
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
56 56
 				case 'previous' :
57
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
57
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
58 58
 				case 'finish':
59 59
 					return 'wizard_finish';
60 60
 				default :
61
-					return $this->wizard_step55($content,$sel_options,$readonlys,$preserv);
61
+					return $this->wizard_step55($content, $sel_options, $readonlys, $preserv);
62 62
 			}
63 63
 		}
64 64
 		// init step30
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		{
67 67
 			$content['text'] = $this->steps['wizard_step55'];
68 68
 			$content['step'] = 'wizard_step55';
69
-			if(!$content['skip_conflicts'] && array_key_exists('skip_conflicts', $content['plugin_options']))
69
+			if (!$content['skip_conflicts'] && array_key_exists('skip_conflicts', $content['plugin_options']))
70 70
 			{
71 71
 				$content['skip_conflicts'] = $content['plugin_options']['skip_conflicts'];
72 72
 			}
Please login to merge, or discard this patch.
calendar/inc/class.calendar_wizard_import_csv.inc.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 class calendar_wizard_import_csv extends importexport_wizard_basic_import_csv
16 16
 {
17 17
 
18
-    /**
18
+	/**
19 19
 	 * constructor
20 20
 	 */
21 21
 	function __construct()
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		// List each custom field
37 37
 		unset($this->mapping_fields['customfields']);
38 38
 		$custom = Api\Storage\Customfields::get('calendar');
39
-		foreach($custom as $name => $data) {
39
+		foreach ($custom as $name => $data) {
40 40
 			$this->mapping_fields['#'.$name] = $data['label'];
41 41
 		}
42 42
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
57 57
 	{
58 58
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
59
-		$content['msg'] .= "\n*" ;
59
+		$content['msg'] .= "\n*";
60 60
 
61 61
 		return $result;
62 62
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			'id'	=>	'Calendar ID'
72 72
 		);
73 73
 		
74
-		if(!$content['skip_conflicts'] && $content['plugin_options']['skip_conflicts'])
74
+		if (!$content['skip_conflicts'] && $content['plugin_options']['skip_conflicts'])
75 75
 		{
76 76
 			$content['skip_conflicts'] = $content['plugin_options']['skip_conflicts'];
77 77
 		}
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ical.inc.php 1 patch
Spacing   +269 added lines, -270 removed lines patch added patch discarded remove patch
@@ -61,39 +61,39 @@  discard block
 block discarded – undo
61 61
 	 * @var array $priority_egw2ical conversion of the priority egw => ical
62 62
 	 */
63 63
 	var $priority_egw2ical = array(
64
-		0 => 0,		// undefined
65
-		1 => 9,		// low
66
-		2 => 5,		// normal
67
-		3 => 1,		// high
64
+		0 => 0, // undefined
65
+		1 => 9, // low
66
+		2 => 5, // normal
67
+		3 => 1, // high
68 68
 	);
69 69
 
70 70
 	/**
71 71
 	 * @var array $priority_ical2egw conversion of the priority ical => egw
72 72
 	 */
73 73
 	var $priority_ical2egw = array(
74
-		0 => 0,		// undefined
75
-		9 => 1,	8 => 1, 7 => 1, 6 => 1,	// low
76
-		5 => 2,		// normal
77
-		4 => 3, 3 => 3, 2 => 3, 1 => 3,	// high
74
+		0 => 0, // undefined
75
+		9 => 1, 8 => 1, 7 => 1, 6 => 1, // low
76
+		5 => 2, // normal
77
+		4 => 3, 3 => 3, 2 => 3, 1 => 3, // high
78 78
 	);
79 79
 
80 80
 	/**
81 81
 	 * @var array $priority_egw2funambol conversion of the priority egw => funambol
82 82
 	 */
83 83
 	var $priority_egw2funambol = array(
84
-		0 => 1,		// undefined (mapped to normal since undefined does not exist)
85
-		1 => 0,		// low
86
-		2 => 1,		// normal
87
-		3 => 2,		// high
84
+		0 => 1, // undefined (mapped to normal since undefined does not exist)
85
+		1 => 0, // low
86
+		2 => 1, // normal
87
+		3 => 2, // high
88 88
 	);
89 89
 
90 90
 	/**
91 91
 	 * @var array $priority_funambol2egw conversion of the priority funambol => egw
92 92
 	 */
93 93
 	var $priority_funambol2egw = array(
94
-		0 => 1,		// low
95
-		1 => 2,		// normal
96
-		2 => 3,		// high
94
+		0 => 1, // low
95
+		1 => 2, // normal
96
+		2 => 3, // high
97 97
 	);
98 98
 
99 99
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @var boolean
164 164
 	 */
165 165
 	var $log = false;
166
-	var $logfile="/tmp/log-vcal";
166
+	var $logfile = "/tmp/log-vcal";
167 167
 
168 168
 	/**
169 169
 	 * Conflict callback
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY
201 201
 	 * @return string|boolean string with iCal or false on error (e.g. no permission to read the event)
202 202
 	 */
203
-	function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0)
203
+	function &exportVCal($events, $version = '1.0', $method = 'PUBLISH', $recur_date = 0, $principalURL = '', $charset = 'UTF-8', $current_user = 0)
204 204
 	{
205 205
 		if ($this->log)
206 206
 		{
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
 
232 232
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
233 233
 
234
-		if ($this->productManufacturer == '' )
234
+		if ($this->productManufacturer == '')
235 235
 		{	// syncevolution is broken
236 236
 			$version = '2.0';
237 237
 		}
238 238
 
239 239
 		$vcal = new Horde_Icalendar;
240
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
240
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
241 241
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
242 242
 		$vcal->setAttribute('VERSION', $version);
243 243
 		if ($method) $vcal->setAttribute('METHOD', $method);
@@ -267,15 +267,15 @@  discard block
 block discarded – undo
267 267
 						if ($this->log)
268 268
 						{
269 269
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
270
-								'() User does not have the permission to read event ' . $event['id']. "\n",
271
-								3,$this->logfile);
270
+								'() User does not have the permission to read event '.$event['id']."\n",
271
+								3, $this->logfile);
272 272
 						}
273 273
 						return -1; // Permission denied
274 274
 					}
275 275
 				}
276 276
 				else
277 277
 				{
278
-					$retval = false;  // Entry does not exist
278
+					$retval = false; // Entry does not exist
279 279
 					if ($this->log)
280 280
 					{
281 281
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 			if ($this->log)
290 290
 			{
291 291
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
292
-					'() export event UID: ' . $event['uid'] . ".\n",
292
+					'() export event UID: '.$event['uid'].".\n",
293 293
 					3, $this->logfile);
294 294
 			}
295 295
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 			if ($this->log)
315 315
 			{
316 316
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
317
-					'(' . $event['id']. ',' . $recurrence . ")\n" .
318
-					array2string($event)."\n",3,$this->logfile);
317
+					'('.$event['id'].','.$recurrence.")\n".
318
+					array2string($event)."\n", 3, $this->logfile);
319 319
 			}
320 320
 
321 321
 			if ($recurrence)
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 						{
337 337
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
338 338
 								"(, $recurrence) Gratuitous pseudo exception, skipped ...\n",
339
-								3,$this->logfile);
339
+								3, $this->logfile);
340 340
 						}
341 341
 						continue; // unsupported status only exception
342 342
 					}
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
 					$days = $this->so->get_recurrence_exceptions($master, $tzid, 0, 0, 'rrule');
347 347
 					if ($this->log)
348 348
 					{
349
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
350
-							array2string($days)."\n",3,$this->logfile);
349
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
350
+							array2string($days)."\n", 3, $this->logfile);
351 351
 					}
352 352
 					$recurrence = $days[$recurrence]; // use remote representation
353 353
 				}
354 354
 				// force single event
355
-				foreach (array('recur_enddate','recur_interval','recur_exception','recur_data','recur_date','id','etag') as $name)
355
+				foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data', 'recur_date', 'id', 'etag') as $name)
356 356
 				{
357 357
 					unset($event[$name]);
358 358
 				}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 			}
361 361
 
362 362
 			// check if tzid of event (not only recuring ones) is already added to export
363
-			if ($tzid && $tzid != 'UTC' && !in_array($tzid,$vtimezones_added))
363
+			if ($tzid && $tzid != 'UTC' && !in_array($tzid, $vtimezones_added))
364 364
 			{
365 365
 				// check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz)
366 366
 				if (calendar_timezones::add_vtimezone($vcal, $tzid) ||
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 			{
379 379
 				// Append UID to DESCRIPTION
380 380
 				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
381
-					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
381
+					$event['description'] .= "\n[UID:".$event['uid']."]";
382 382
 				}
383 383
 			}
384 384
 
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
 				$exceptions = array();
400 400
 
401 401
 				// dont use "virtual" exceptions created by participant status for GroupDAV or file export
402
-				if (!in_array($this->productManufacturer,array('file','groupdav')))
402
+				if (!in_array($this->productManufacturer, array('file', 'groupdav')))
403 403
 				{
404 404
 					$filter = isset($this->supportedFields['participants']) ? 'rrule' : 'tz_rrule';
405 405
 					$exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, $filter);
406 406
 					if ($this->log)
407 407
 					{
408
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" .
409
-							array2string($exceptions)."\n",3,$this->logfile);
408
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n".
409
+							array2string($exceptions)."\n", 3, $this->logfile);
410 410
 					}
411 411
 				}
412 412
 				elseif (is_array($event['recur_exception']))
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 					if ($this->log)
424 424
 					{
425 425
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
426
-							'(' . $event['id'] . ") [$icalFieldName] not supported\n",
427
-							3,$this->logfile);
426
+							'('.$event['id'].") [$icalFieldName] not supported\n",
427
+							3, $this->logfile);
428 428
 					}
429 429
 					continue;
430 430
 				}
@@ -441,23 +441,23 @@  discard block
 block discarded – undo
441 441
 
442 442
 							if (!($info = $this->resource_info($uid))) continue;
443 443
 
444
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
444
+							if (in_array($status, array('X', 'E'))) continue; // dont include deleted participants
445 445
 
446 446
 							if ($this->log)
447 447
 							{
448
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
449
-									'()attendee:' . array2string($info) ."\n",3,$this->logfile);
448
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
449
+									'()attendee:'.array2string($info)."\n", 3, $this->logfile);
450 450
 							}
451 451
 							$participantCN = str_replace(array('\\', ',', ';', ':'),
452 452
 												array('\\\\', '\\,', '\\;', '\\:'),
453 453
 												trim(empty($info['cn']) ? $info['name'] : $info['cn']));
454 454
 							if ($version == '1.0')
455 455
 							{
456
-								$participantURL = trim('"' . $participantCN . '"' . (empty($info['email']) ? '' : ' <' . $info['email'] .'>'));
456
+								$participantURL = trim('"'.$participantCN.'"'.(empty($info['email']) ? '' : ' <'.$info['email'].'>'));
457 457
 							}
458 458
 							else
459 459
 							{
460
-								$participantURL = empty($info['email']) ? '' : 'mailto:' . $info['email'];
460
+								$participantURL = empty($info['email']) ? '' : 'mailto:'.$info['email'];
461 461
 							}
462 462
 							// RSVP={TRUE|FALSE}	// resonse expected, not set in eGW => status=U
463 463
 							$rsvp = $status == 'U' ? 'TRUE' : 'FALSE';
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 										($members = $GLOBALS['egw']->accounts->members($uid, true)) && in_array($this->user, $members))
486 486
 									{
487 487
 										$user = $this->resource_info($this->user);
488
-										$attributes['ATTENDEE'][] = 'mailto:' . $user['email'];
488
+										$attributes['ATTENDEE'][] = 'mailto:'.$user['email'];
489 489
 			    						$parameters['ATTENDEE'][] = array(
490 490
 			    							'CN'		=>	$user['name'],
491 491
 			    							'ROLE'		=> 'REQ-PARTICIPANT',
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
528 528
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
529 529
 							{
530
-								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
530
+								$options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
531 531
 							}
532 532
 							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
533 533
 							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 						break;
538 538
 
539 539
 					case 'CLASS':
540
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
540
+						if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default
541 541
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
542 542
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
543 543
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -549,16 +549,16 @@  discard block
 block discarded – undo
549 549
     				case 'ORGANIZER':
550 550
 	    				if (!$organizerURL)
551 551
 	    				{
552
-	    					$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
553
-			    				. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
554
-			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
552
+	    					$organizerCN = '"'.trim($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_firstname')
553
+			    				. ' '.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_lastname')).'"';
554
+			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email');
555 555
 			    			if ($version == '1.0')
556 556
 			    			{
557
-		    					$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
557
+		    					$organizerURL = trim($organizerCN.(empty($organizerURL) ? '' : ' <'.$organizerURL.'>'));
558 558
 			    			}
559 559
 			    			else
560 560
 			    			{
561
-		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
561
+		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:'.$organizerEMail;
562 562
 			    			}
563 563
 			    			$organizerUID = $event['owner'];
564 564
 		    				if (!isset($event['participants'][$event['owner']]))
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 					case 'DTSTART':
592 592
 						if (empty($event['whole_day']))
593 593
 						{
594
-							$attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']);
594
+							$attributes['DTSTART'] = self::getDateTime($event['start'], $tzid, $parameters['DTSTART']);
595 595
 						}
596 596
 						break;
597 597
 
@@ -602,27 +602,27 @@  discard block
 block discarded – undo
602 602
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
603 603
 								$attributes['duration'] = $event['end'] - $event['start'];
604 604
 							else
605
-							$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
605
+							$attributes['DTEND'] = self::getDateTime($event['end'], $tzid, $parameters['DTEND']);
606 606
 						}
607 607
 						else
608 608
 						{
609 609
 							// write start + end of whole day events as dates
610
-							$event['end-nextday'] = $event['end'] + 12*3600;	// we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
611
-							foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t)
610
+							$event['end-nextday'] = $event['end'] + 12 * 3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
611
+							foreach (array('start' => 'DTSTART', 'end-nextday' => 'DTEND') as $f => $t)
612 612
 							{
613
-								$time = new egw_time($event[$f],egw_time::$server_timezone);
614
-								$arr = egw_time::to($time,'array');
615
-								$vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']),
613
+								$time = new egw_time($event[$f], egw_time::$server_timezone);
614
+								$arr = egw_time::to($time, 'array');
615
+								$vevent->setAttribute($t, array('year' => $arr['year'], 'month' => $arr['month'], 'mday' => $arr['day']),
616 616
 									array('VALUE' => 'DATE'));
617 617
 							}
618 618
 							unset($attributes['DTSTART']);
619 619
 							// Outlook does NOT care about type of DTSTART/END, only setting X-MICROSOFT-CDO-ALLDAYEVENT is used to determine an event is a whole-day event
620
-							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT','TRUE');
620
+							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
621 621
 						}
622 622
 						break;
623 623
 
624 624
 					case 'RRULE':
625
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
625
+						if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event
626 626
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
627 627
 						$rrule = $rriter->generate_rrule($version);
628 628
 						if ($event['recur_enddate'])
@@ -641,16 +641,16 @@  discard block
 block discarded – undo
641 641
 						{
642 642
 							if ($event['recur_enddate'] && $tzid)
643 643
 							{
644
-								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid);
644
+								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'], $tzid);
645 645
 							}
646 646
 							$attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL'];
647 647
 						}
648 648
 						else // $version == '2.0'
649 649
 						{
650 650
 							$attributes['RRULE'] = '';
651
-							foreach($rrule as $n => $v)
651
+							foreach ($rrule as $n => $v)
652 652
 							{
653
-								$attributes['RRULE'] .= ($attributes['RRULE']?';':'').$n.'='.$v;
653
+								$attributes['RRULE'] .= ($attributes['RRULE'] ? ';' : '').$n.'='.$v;
654 654
 							}
655 655
 						}
656 656
 						break;
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 								{
666 666
 									// current Horde_Icalendar 2.1.4 exports EXDATE always in UTC, so we should not set a timezone here
667 667
 									// Apple calendar on OS X 10.11.4 uses a timezone, so does Horde eg. for Recurrence-ID
668
-									$event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid);//,$parameters['EXDATE']);
668
+									$event['recur_exception'][$key] = self::getDateTime($timestamp, $tzid); //,$parameters['EXDATE']);
669 669
 								}
670 670
 							}
671 671
 							else
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 								// use 'DATE' instead of 'DATE-TIME' on whole day events
674 674
 								foreach ($event['recur_exception'] as $id => $timestamp)
675 675
 								{
676
-									$time = new egw_time($timestamp,egw_time::$server_timezone);
676
+									$time = new egw_time($timestamp, egw_time::$server_timezone);
677 677
 									$time->setTimezone(self::$tz_cache[$event['tzid']]);
678
-									$arr = egw_time::to($time,'array');
678
+									$arr = egw_time::to($time, 'array');
679 679
 									$days[$id] = array(
680 680
 										'year'  => $arr['year'],
681 681
 										'month' => $arr['month'],
@@ -690,21 +690,21 @@  discard block
 block discarded – undo
690 690
 						break;
691 691
 
692 692
 					case 'PRIORITY':
693
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
693
+						if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added
694 694
 						if ($this->productManufacturer == 'funambol' &&
695 695
 							(strpos($this->productName, 'outlook') !== false
696 696
 								|| strpos($this->productName, 'pocket pc') !== false))
697 697
 						{
698
-							$attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']];
698
+							$attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']];
699 699
 						}
700 700
 						else
701 701
 						{
702
-							$attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']];
702
+							$attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']];
703 703
 						}
704 704
 						break;
705 705
 
706 706
 					case 'TRANSP':
707
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
707
+						if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default
708 708
 						if ($version == '1.0')
709 709
 						{
710 710
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -743,13 +743,13 @@  discard block
 block discarded – undo
743 743
 							// We handle a pseudo exception
744 744
 							if (empty($event['whole_day']))
745 745
 							{
746
-								$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
746
+								$attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]);
747 747
 							}
748 748
 							else
749 749
 							{
750
-								$time = new egw_time($recur_date,egw_time::$server_timezone);
750
+								$time = new egw_time($recur_date, egw_time::$server_timezone);
751 751
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
752
-								$arr = egw_time::to($time,'array');
752
+								$arr = egw_time::to($time, 'array');
753 753
 								$vevent->setAttribute($icalFieldName, array(
754 754
 									'year' => $arr['year'],
755 755
 									'month' => $arr['month'],
@@ -761,17 +761,17 @@  discard block
 block discarded – undo
761 761
 						elseif ($event['recurrence'] && $event['reference'])
762 762
 						{
763 763
 							// $event['reference'] is a calendar_id, not a timestamp
764
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
764
+							if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
765 765
 
766 766
 							if (empty($revent['whole_day']))
767 767
 							{
768
-								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
768
+								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]);
769 769
 							}
770 770
 							else
771 771
 							{
772
-								$time = new egw_time($event['recurrence'],egw_time::$server_timezone);
772
+								$time = new egw_time($event['recurrence'], egw_time::$server_timezone);
773 773
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
774
-								$arr = egw_time::to($time,'array');
774
+								$arr = egw_time::to($time, 'array');
775 775
 								$vevent->setAttribute($icalFieldName, array(
776 776
 									'year' => $arr['year'],
777 777
 									'month' => $arr['month'],
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
 							$noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate'];
796 796
 							if ($this->log && $size > 0)
797 797
 							{
798
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
799
-									"() $icalFieldName Size: $size, NoTruncate: " .
800
-									($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
798
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
799
+									"() $icalFieldName Size: $size, NoTruncate: ".
800
+									($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
801 801
 							}
802 802
 							//Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
803 803
 							//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
 							{
816 816
 								if ($this->log)
817 817
 								{
818
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
819
-										"() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile);
818
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
819
+										"() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile);
820 820
 								}
821 821
 								//Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
822 822
 								//	__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -826,8 +826,8 @@  discard block
 block discarded – undo
826 826
 							$value = substr($value, 0, $size - 1);
827 827
 							if ($this->log)
828 828
 							{
829
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
830
-									"() $icalFieldName truncated to maximum size $size\n",3,$this->logfile);
829
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
830
+									"() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile);
831 831
 							}
832 832
 							//Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
833 833
 							//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 			// for CalDAV add all X-Properties previously parsed
843 843
 			if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file')
844 844
 			{
845
-				foreach($event as $name => $value)
845
+				foreach ($event as $name => $value)
846 846
 				{
847 847
 					if (substr($name, 0, 2) == '##')
848 848
 					{
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
 						$values['AALARM']['repeat count'] = '';
915 915
 						$values['AALARM']['display text'] = $description;
916 916
 					}
917
-					$attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']);
918
-					$attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']);
917
+					$attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']);
918
+					$attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']);
919 919
 					// lets take only the first alarm
920 920
 					break;
921 921
 				}
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 						$alarmData['offset'] = false;
953 953
 					}
954 954
 
955
-					$valarm = Horde_Icalendar::newComponent('VALARM',$vevent);
955
+					$valarm = Horde_Icalendar::newComponent('VALARM', $vevent);
956 956
 					if ($alarmData['offset'] !== false)
957 957
 					{
958 958
 						$valarm->setAttribute('TRIGGER', -$alarmData['offset'],
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 					else
962 962
 					{
963 963
 						$params = array('VALUE' => 'DATE-TIME');
964
-						$value = self::getDateTime($alarmData['time'],$tzid,$params);
964
+						$value = self::getDateTime($alarmData['time'], $tzid, $params);
965 965
 						$valarm->setAttribute('TRIGGER', $value, $params);
966 966
 					}
967 967
 					if (!empty($alarmData['uid']))
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 					// set evtl. existing attributes set by iCal clients not used by EGroupware
973 973
 					if (isset($alarmData['attrs']))
974 974
 					{
975
-						foreach($alarmData['attrs'] as $attr => $data)
975
+						foreach ($alarmData['attrs'] as $attr => $data)
976 976
 						{
977 977
 							$valarm->setAttribute($attr, $data['value'], $data['params']);
978 978
 						}
@@ -980,11 +980,11 @@  discard block
 block discarded – undo
980 980
 					// set default ACTION and DESCRIPTION, if not set by a client
981 981
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION']))
982 982
 					{
983
-						$valarm->setAttribute('ACTION','DISPLAY');
983
+						$valarm->setAttribute('ACTION', 'DISPLAY');
984 984
 					}
985 985
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION']))
986 986
 					{
987
-						$valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description);
987
+						$valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description);
988 988
 					}
989 989
 					$vevent->addComponent($valarm);
990 990
 				}
@@ -992,15 +992,15 @@  discard block
 block discarded – undo
992 992
 
993 993
 			foreach ($attributes as $key => $value)
994 994
 			{
995
-				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
995
+				foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData)
996 996
 				{
997
-					$valueData = translation::convert($valueData,translation::charset(),$charset);
998
-                    $paramData = (array) translation::convert(is_array($value) ?
997
+					$valueData = translation::convert($valueData, translation::charset(), $charset);
998
+                    $paramData = (array)translation::convert(is_array($value) ?
999 999
                     		$parameters[$key][$valueID] : $parameters[$key],
1000
-                            translation::charset(),$charset);
1001
-                    $valuesData = (array) translation::convert($values[$key],
1002
-                    		translation::charset(),$charset);
1003
-                    $content = $valueData . implode(';', $valuesData);
1000
+                            translation::charset(), $charset);
1001
+                    $valuesData = (array)translation::convert($values[$key],
1002
+                    		translation::charset(), $charset);
1003
+                    $content = $valueData.implode(';', $valuesData);
1004 1004
 
1005 1005
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1006 1006
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -1050,10 +1050,10 @@  discard block
 block discarded – undo
1050 1050
 		$retval = $events_exported ? $vcal->exportvCalendar() : false;
1051 1051
  		if ($this->log)
1052 1052
  		{
1053
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1054
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1055
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1056
-				"()\n".array2string($retval)."\n",3,$this->logfile);
1053
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1054
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1055
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1056
+				"()\n".array2string($retval)."\n", 3, $this->logfile);
1057 1057
  		}
1058 1058
 		return $retval;
1059 1059
 	}
@@ -1066,15 +1066,15 @@  discard block
 block discarded – undo
1066 1066
 	 * @param array &$params=null parameter array to set TZID
1067 1067
 	 * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid
1068 1068
 	 */
1069
-	static function getDateTime($time,$tzid,array &$params=null)
1069
+	static function getDateTime($time, $tzid, array &$params = null)
1070 1070
 	{
1071 1071
 		if (empty($tzid) || $tzid == 'UTC')
1072 1072
 		{
1073
-			return egw_time::to($time,'ts');
1073
+			return egw_time::to($time, 'ts');
1074 1074
 		}
1075
-		if (!is_a($time,'DateTime'))
1075
+		if (!is_a($time, 'DateTime'))
1076 1076
 		{
1077
-			$time = new egw_time($time,egw_time::$server_timezone);
1077
+			$time = new egw_time($time, egw_time::$server_timezone);
1078 1078
 		}
1079 1079
 		if (!isset(self::$tz_cache[$tzid]))
1080 1080
 		{
@@ -1109,11 +1109,11 @@  discard block
 block discarded – undo
1109 1109
 	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1110 1110
 	 * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden"
1111 1111
 	 */
1112
-	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
1112
+	function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false)
1113 1113
 	{
1114 1114
 		//error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)");
1115 1115
 		$this->events_imported = 0;
1116
-		$replace = $delete_exceptions= false;
1116
+		$replace = $delete_exceptions = false;
1117 1117
 
1118 1118
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1119 1119
 
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		{
1122 1122
 			return false;
1123 1123
 		}
1124
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1124
+		if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0])
1125 1125
 
1126 1126
 		if ($cal_id > 0)
1127 1127
 		{
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 			{
1130 1130
 				$replace = $recur_date == 0;
1131 1131
 				$events[0]['id'] = $cal_id;
1132
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1132
+				if (!is_null($etag)) $events[0]['etag'] = (int)$etag;
1133 1133
 				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1134 1134
 			}
1135 1135
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 			{
1182 1182
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1183 1183
 					."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n"
1184
-					. array2string($event)."\n",3,$this->logfile);
1184
+					. array2string($event)."\n", 3, $this->logfile);
1185 1185
 			}
1186 1186
 
1187 1187
 			$updated_id = false;
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
 					{
1205 1205
 						if ($delete_exceptions)
1206 1206
 						{
1207
-							$this->delete($id,0,false,$skip_notification);
1207
+							$this->delete($id, 0, false, $skip_notification);
1208 1208
 						}
1209 1209
 						else
1210 1210
 						{
1211 1211
 							if (!($exception = $this->read($id))) continue;
1212 1212
 							$exception['uid'] = common::generate_uid('calendar', $id);
1213 1213
 							$exception['reference'] = $exception['recurrence'] = 0;
1214
-							$this->update($exception, true,true,false,true,$msg,$skip_notification);
1214
+							$this->update($exception, true, true, false, true, $msg, $skip_notification);
1215 1215
 						}
1216 1216
 					}
1217 1217
 				}
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
 				{
1229 1229
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1230 1230
 						. "(UPDATE Event)\n"
1231
-						. array2string($event_info['stored_event'])."\n",3,$this->logfile);
1231
+						. array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1232 1232
 				}
1233 1233
 				if (empty($event['uid']))
1234 1234
 				{
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 								if ($this->log)
1251 1251
 								{
1252 1252
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1253
-										"() Restore status for $uid\n",3,$this->logfile);
1253
+										"() Restore status for $uid\n", 3, $this->logfile);
1254 1254
 								}
1255 1255
 								$event['participants'][$uid] = $event_info['stored_event']['participants'][$uid];
1256 1256
 							}
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
 					if ($this->log)
1275 1275
 					{
1276 1276
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1277
-							"()[MERGE]\n",3,$this->logfile);
1277
+							"()[MERGE]\n", 3, $this->logfile);
1278 1278
 					}
1279 1279
 					// overwrite with server data for merge
1280 1280
 					foreach ($event_info['stored_event'] as $key => $value)
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 				else
1305 1305
 				{
1306 1306
 					// no merge
1307
-					if(!isset($this->supportedFields['category']) || !isset($event['category']))
1307
+					if (!isset($this->supportedFields['category']) || !isset($event['category']))
1308 1308
 					{
1309 1309
 						$event['category'] = $event_info['stored_event']['category'];
1310 1310
 					}
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
 						if ($this->log)
1317 1317
 						{
1318 1318
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1319
-							"() No participants\n",3,$this->logfile);
1319
+							"() No participants\n", 3, $this->logfile);
1320 1320
 						}
1321 1321
 
1322 1322
 						// If this is an updated meeting, and the client doesn't support
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 								if ($this->log)
1336 1336
 								{
1337 1337
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1338
-										"() Restore resource $uid to status $status\n",3,$this->logfile);
1338
+										"() Restore resource $uid to status $status\n", 3, $this->logfile);
1339 1339
 								}
1340 1340
 								// Add it back in
1341 1341
 								$event['participants'][$uid] = $status;
@@ -1423,8 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 						}
1424 1424
 						// for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U')
1425 1425
 						$event['participants'][$user] = calendar_so::combine_status(
1426
-							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' :
1427
-							ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1426
+							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1428 1427
 					}
1429 1428
 				}
1430 1429
 				// check if an owner is set and the current user has add rights
@@ -1489,9 +1488,9 @@  discard block
 block discarded – undo
1489 1488
 
1490 1489
 			if ($this->log)
1491 1490
 			{
1492
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '('
1493
-					. $event_info['type'] . ")\n"
1494
-					. array2string($event)."\n",3,$this->logfile);
1491
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'('
1492
+					. $event_info['type'].")\n"
1493
+					. array2string($event)."\n", 3, $this->logfile);
1495 1494
 			}
1496 1495
 
1497 1496
 			// Android (any maybe others) delete recurrences by setting STATUS: CANCELLED
@@ -1499,10 +1498,10 @@  discard block
 block discarded – undo
1499 1498
 			if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) &&
1500 1499
 				$event['status'] == 'CANCELLED')
1501 1500
 			{
1502
-				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification))
1501
+				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification))
1503 1502
 				{
1504 1503
 					// delete fails (because no rights), reject recurrence
1505
-					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification);
1504
+					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification);
1506 1505
 				}
1507 1506
 				continue;
1508 1507
 			}
@@ -1514,7 +1513,7 @@  discard block
 block discarded – undo
1514 1513
 					if ($this->log)
1515 1514
 					{
1516 1515
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1517
-							"(): event SINGLE\n",3,$this->logfile);
1516
+							"(): event SINGLE\n", 3, $this->logfile);
1518 1517
 					}
1519 1518
 
1520 1519
 					// update the event
@@ -1524,7 +1523,7 @@  discard block
 block discarded – undo
1524 1523
 						$event['reference'] = 0;
1525 1524
 						$event_to_store = $event; // prevent $event from being changed by the update method
1526 1525
 						$this->server2usertime($event_to_store);
1527
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1526
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1528 1527
 						unset($event_to_store);
1529 1528
 					}
1530 1529
 					break;
@@ -1533,7 +1532,7 @@  discard block
 block discarded – undo
1533 1532
 					if ($this->log)
1534 1533
 					{
1535 1534
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1536
-							"(): event SERIES-MASTER\n",3,$this->logfile);
1535
+							"(): event SERIES-MASTER\n", 3, $this->logfile);
1537 1536
 					}
1538 1537
 
1539 1538
 					// remove all known pseudo exceptions and update the event
@@ -1543,8 +1542,8 @@  discard block
 block discarded – undo
1543 1542
 						$days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter);
1544 1543
 						if ($this->log)
1545 1544
 						{
1546
-							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" .
1547
-								array2string($days)."\n",3,$this->logfile);
1545
+							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n".
1546
+								array2string($days)."\n", 3, $this->logfile);
1548 1547
 						}
1549 1548
 						if (is_array($days))
1550 1549
 						{
@@ -1562,7 +1561,7 @@  discard block
 block discarded – undo
1562 1561
 
1563 1562
 						$event_to_store = $event; // prevent $event from being changed by the update method
1564 1563
 						$this->server2usertime($event_to_store);
1565
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1564
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1566 1565
 						unset($event_to_store);
1567 1566
 					}
1568 1567
 					break;
@@ -1572,7 +1571,7 @@  discard block
 block discarded – undo
1572 1571
 					if ($this->log)
1573 1572
 					{
1574 1573
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1575
-							"(): event SERIES-EXCEPTION\n",3,$this->logfile);
1574
+							"(): event SERIES-EXCEPTION\n", 3, $this->logfile);
1576 1575
 					}
1577 1576
 
1578 1577
 					// update event
@@ -1628,13 +1627,13 @@  discard block
 block discarded – undo
1628 1627
 							$event['owner'] = $event_info['master_event']['owner'];
1629 1628
 							$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1630 1629
 							$this->server2usertime($event_to_store);
1631
-							$this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1630
+							$this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1632 1631
 							unset($event_to_store);
1633 1632
 						}
1634 1633
 
1635 1634
 						$event_to_store = $event; // prevent $event from being changed by update method
1636 1635
 						$this->server2usertime($event_to_store);
1637
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1636
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1638 1637
 						unset($event_to_store);
1639 1638
 					}
1640 1639
 					break;
@@ -1643,7 +1642,7 @@  discard block
 block discarded – undo
1643 1642
 					if ($this->log)
1644 1643
 					{
1645 1644
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1646
-							"(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile);
1645
+							"(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile);
1647 1646
 					}
1648 1647
 					//Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION',
1649 1648
 					//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -1664,7 +1663,7 @@  discard block
 block discarded – undo
1664 1663
 						// save the series master with the adjusted exceptions
1665 1664
 						$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1666 1665
 						$this->server2usertime($event_to_store);
1667
-						$updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification);
1666
+						$updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification);
1668 1667
 						unset($event_to_store);
1669 1668
 					}
1670 1669
 
@@ -1691,13 +1690,13 @@  discard block
 block discarded – undo
1691 1690
 							if ($event_info['acl_edit'])
1692 1691
 							{
1693 1692
 								// update all participants if we have the right to do that
1694
-								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1693
+								$this->update_status($event, $event_info['stored_event'], 0, $skip_notification);
1695 1694
 							}
1696 1695
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1697 1696
 							{
1698 1697
 								// update the users status only
1699 1698
 								$this->set_status($event_info['stored_event']['id'], $this->user,
1700
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification);
1699
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification);
1701 1700
 							}
1702 1701
 						}
1703 1702
 						break;
@@ -1709,13 +1708,13 @@  discard block
 block discarded – undo
1709 1708
 							if ($event_info['acl_edit'])
1710 1709
 							{
1711 1710
 								// update all participants if we have the right to do that
1712
-								$this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification);
1711
+								$this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification);
1713 1712
 							}
1714 1713
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
1715 1714
 							{
1716 1715
 								// update the users status only
1717 1716
 								$this->set_status($event_info['master_event']['id'], $this->user,
1718
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification);
1717
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification);
1719 1718
 							}
1720 1719
 						}
1721 1720
 						break;
@@ -1732,7 +1731,7 @@  discard block
 block discarded – undo
1732 1731
 					break;
1733 1732
 
1734 1733
 				case 'SERIES-PSEUDO-EXCEPTION':
1735
-					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false;
1734
+					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false;
1736 1735
 					break;
1737 1736
 
1738 1737
 				case 'SERIES-EXCEPTION-PROPAGATE':
@@ -1745,7 +1744,7 @@  discard block
 block discarded – undo
1745 1744
 					{
1746 1745
 						// we did not have sufficient rights to propagate the status only exception to a real one
1747 1746
 						// we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched
1748
-						$return_id = $event_info['master_event']['id'] . ':' . $event['recurrence'];
1747
+						$return_id = $event_info['master_event']['id'].':'.$event['recurrence'];
1749 1748
 					}
1750 1749
 					break;
1751 1750
 			}
@@ -1759,8 +1758,8 @@  discard block
 block discarded – undo
1759 1758
 			if ($this->log)
1760 1759
 			{
1761 1760
 				$event_info['stored_event'] = $this->read($event_info['stored_event']['id']);
1762
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" .
1763
-					array2string($event_info['stored_event'])."\n",3,$this->logfile);
1761
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n".
1762
+					array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1764 1763
 			}
1765 1764
 		}
1766 1765
 		date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -1782,19 +1781,19 @@  discard block
 block discarded – undo
1782 1781
 	 * @return mixed on success: int $cal_id > 0, on error or conflicts false.
1783 1782
 	 *	Conflicts are passed to $this->conflict_callback
1784 1783
 	 */
1785
-	public function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
1784
+	public function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
1786 1785
 	{
1787
-		if($this->conflict_callback !== null)
1786
+		if ($this->conflict_callback !== null)
1788 1787
 		{
1789 1788
 			// calendar_ical overrides search(), which breaks conflict checking
1790 1789
 			// so we make sure to use the original from parent
1791 1790
 			static $bo;
1792
-			if(!$bo)
1791
+			if (!$bo)
1793 1792
 			{
1794 1793
 				$bo = new calendar_boupdate();
1795 1794
 			}
1796 1795
 			$conflicts = $bo->conflicts($event);
1797
-			if(is_array($conflicts) && count($conflicts) > 0)
1796
+			if (is_array($conflicts) && count($conflicts) > 0)
1798 1797
 			{
1799 1798
 				call_user_func_array($this->conflict_callback, array(&$event, &$conflicts));
1800 1799
 				return false;
@@ -1815,10 +1814,10 @@  discard block
 block discarded – undo
1815 1814
 	{
1816 1815
 		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1817 1816
 		$modified = 0;
1818
-		foreach($event['alarm'] as &$alarm)
1817
+		foreach ($event['alarm'] as &$alarm)
1819 1818
 		{
1820 1819
 			// check if alarm is already stored or from other users
1821
-			foreach($old_alarms as $id => $old_alarm)
1820
+			foreach ($old_alarms as $id => $old_alarm)
1822 1821
 			{
1823 1822
 				// not current users alarm --> ignore
1824 1823
 				if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1855,7 +1854,7 @@  discard block
 block discarded – undo
1855 1854
 			}
1856 1855
 		}
1857 1856
 		// remove all old alarms left from current user
1858
-		foreach($old_alarms as $id => $old_alarm)
1857
+		foreach ($old_alarms as $id => $old_alarm)
1859 1858
 		{
1860 1859
 			// not current users alarm --> ignore
1861 1860
 			if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1878,7 +1877,7 @@  discard block
 block discarded – undo
1878 1877
 	 * @param string $what ='value'
1879 1878
 	 * @return mixed
1880 1879
 	 */
1881
-	static function _get_attribute($components,$name,$what='value')
1880
+	static function _get_attribute($components, $name, $what = 'value')
1882 1881
 	{
1883 1882
 		foreach ($components as $attribute)
1884 1883
 		{
@@ -1913,7 +1912,7 @@  discard block
 block discarded – undo
1913 1912
 						case 'DURATION':
1914 1913
 							if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END')
1915 1914
 							{
1916
-								$alarm['offset'] = $duration -$vattr['value'];
1915
+								$alarm['offset'] = $duration - $vattr['value'];
1917 1916
 							}
1918 1917
 							elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START')
1919 1918
 							{
@@ -1929,7 +1928,7 @@  discard block
 block discarded – undo
1929 1928
 							$alarm['time'] = $vattr['value'];
1930 1929
 							break;
1931 1930
 						default:
1932
-							error_log('VALARM/TRIGGER: unsupported value type:' . $vtype);
1931
+							error_log('VALARM/TRIGGER: unsupported value type:'.$vtype);
1933 1932
 					}
1934 1933
 					break;
1935 1934
 
@@ -1954,9 +1953,9 @@  discard block
 block discarded – undo
1954 1953
 		return 0;
1955 1954
 	}
1956 1955
 
1957
-	function setSupportedFields($_productManufacturer='', $_productName='')
1956
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
1958 1957
 	{
1959
-		$state =& $_SESSION['SyncML.state'];
1958
+		$state = & $_SESSION['SyncML.state'];
1960 1959
 		if (isset($state))
1961 1960
 		{
1962 1961
 			$deviceInfo = $state->getClientDeviceInfo();
@@ -2253,10 +2252,10 @@  discard block
 block discarded – undo
2253 2252
 		if ($this->log)
2254 2253
 		{
2255 2254
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2256
-				'(' . $this->productManufacturer .
2257
-				', '. $this->productName .', ' .
2258
-				($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .
2259
-				', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
2255
+				'('.$this->productManufacturer.
2256
+				', '.$this->productName.', '.
2257
+				($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()).
2258
+				', '.$this->calendarOwner.")\n", 3, $this->logfile);
2260 2259
 		}
2261 2260
 
2262 2261
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
@@ -2274,12 +2273,12 @@  discard block
 block discarded – undo
2274 2273
      *                         utf-8 for new format, iso-8859-1 for old format.
2275 2274
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2276 2275
 	 */
2277
-	function icaltoegw($_vcalData, $principalURL='', $charset=null)
2276
+	function icaltoegw($_vcalData, $principalURL = '', $charset = null)
2278 2277
 	{
2279 2278
 		if ($this->log)
2280 2279
 		{
2281
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" .
2282
-				array2string($_vcalData)."\n",3,$this->logfile);
2280
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n".
2281
+				array2string($_vcalData)."\n", 3, $this->logfile);
2283 2282
 		}
2284 2283
 
2285 2284
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
@@ -2287,7 +2286,7 @@  discard block
 block discarded – undo
2287 2286
 		// we use egw_ical_iterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2288 2287
 		if (is_resource($_vcalData))
2289 2288
 		{
2290
-			return new egw_ical_iterator($_vcalData,'VCALENDAR',$charset,array($this,'_ical2egw_callback'),array($this->tzid,$principalURL));
2289
+			return new egw_ical_iterator($_vcalData, 'VCALENDAR', $charset, array($this, '_ical2egw_callback'), array($this->tzid, $principalURL));
2291 2290
 		}
2292 2291
 
2293 2292
 		if ($this->tzid)
@@ -2312,14 +2311,14 @@  discard block
 block discarded – undo
2312 2311
 			if ($this->log)
2313 2312
 			{
2314 2313
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2315
-					"(): No vCalendar Container found!\n",3,$this->logfile);
2314
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
2316 2315
 			}
2317 2316
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
2318 2317
 			return false;
2319 2318
 		}
2320 2319
 		foreach ($vcal->getComponents() as $component)
2321 2320
 		{
2322
-			if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal)))
2321
+			if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal)))
2323 2322
 			{
2324 2323
 				$events[] = $event;
2325 2324
 			}
@@ -2338,13 +2337,13 @@  discard block
 block discarded – undo
2338 2337
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2339 2338
 	 * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent
2340 2339
 	 */
2341
-	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null)
2340
+	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null)
2342 2341
 	{
2343 2342
 		//unset($component->_container); _debug_array($component);
2344 2343
 
2345 2344
 		if ($this->log)
2346 2345
 		{
2347
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
2346
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile);
2348 2347
 		}
2349 2348
 
2350 2349
 		if (!is_a($component, 'Horde_Icalendar_Vevent') ||
@@ -2393,16 +2392,16 @@  discard block
 block discarded – undo
2393 2392
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2394 2393
 	 * @return array|boolean			event on success, false on failure
2395 2394
 	 */
2396
-	function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null)
2395
+	function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null)
2397 2396
 	{
2398
-		unset($principalURL);	// not longer used, but required in function signature
2397
+		unset($principalURL); // not longer used, but required in function signature
2399 2398
 
2400 2399
 		if ($check_component && !is_a($component, $check_component))
2401 2400
 		{
2402 2401
 			if ($this->log)
2403 2402
 			{
2404
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' .
2405
-					get_class($component)." found\n",3,$this->logfile);
2403
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'.
2404
+					get_class($component)." found\n", 3, $this->logfile);
2406 2405
 			}
2407 2406
 			return false;
2408 2407
 		}
@@ -2418,11 +2417,11 @@  discard block
 block discarded – undo
2418 2417
 
2419 2418
 		$isDate = false;
2420 2419
 		$event		= array();
2421
-		$alarms		= array();
2422
-		$vcardData	= array(
2420
+		$alarms = array();
2421
+		$vcardData = array(
2423 2422
 			'recur_type'		=> MCAL_RECUR_NONE,
2424 2423
 			'recur_exception'	=> array(),
2425
-			'priority'          => 0,	// iCalendar default is 0=undefined, not EGroupware 5=normal
2424
+			'priority'          => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal
2426 2425
 		);
2427 2426
 		// we need to parse DTSTART, DTEND or DURATION (in that order!) first
2428 2427
 		foreach (array_merge(
@@ -2439,7 +2438,7 @@  discard block
 block discarded – undo
2439 2438
 						$isDate = true;
2440 2439
 					}
2441 2440
 					$dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2442
-					$vcardData['start']	= $dtstart_ts;
2441
+					$vcardData['start'] = $dtstart_ts;
2443 2442
 
2444 2443
 					if ($this->tzid)
2445 2444
 					{
@@ -2462,18 +2461,18 @@  discard block
 block discarded – undo
2462 2461
 								}
2463 2462
 								else
2464 2463
 								{
2465
-									error_log(__METHOD__ . '() unknown TZID='
2466
-										. $attributes['params']['TZID'] . ', defaulting to timezone "'
2467
-										. date_default_timezone_get() . '".'.array2string($tz));
2468
-									$event['tzid'] = date_default_timezone_get();	// default to current timezone
2464
+									error_log(__METHOD__.'() unknown TZID='
2465
+										. $attributes['params']['TZID'].', defaulting to timezone "'
2466
+										. date_default_timezone_get().'".'.array2string($tz));
2467
+									$event['tzid'] = date_default_timezone_get(); // default to current timezone
2469 2468
 								}
2470 2469
 							}
2471
-							catch(Exception $e)
2470
+							catch (Exception $e)
2472 2471
 							{
2473
-								error_log(__METHOD__ . '() unknown TZID='
2474
-									. $attributes['params']['TZID'] . ', defaulting to timezone "'
2475
-									. date_default_timezone_get() . '".'.$e->getMessage());
2476
-								$event['tzid'] = date_default_timezone_get();	// default to current timezone
2472
+								error_log(__METHOD__.'() unknown TZID='
2473
+									. $attributes['params']['TZID'].', defaulting to timezone "'
2474
+									. date_default_timezone_get().'".'.$e->getMessage());
2475
+								$event['tzid'] = date_default_timezone_get(); // default to current timezone
2477 2476
 							}
2478 2477
 						}
2479 2478
 						else
@@ -2488,11 +2487,11 @@  discard block
 block discarded – undo
2488 2487
 
2489 2488
 				case 'DTEND':
2490 2489
 					$dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2491
-					if (date('H:i:s',$dtend_ts) == '00:00:00')
2490
+					if (date('H:i:s', $dtend_ts) == '00:00:00')
2492 2491
 					{
2493 2492
 						$dtend_ts -= 1;
2494 2493
 					}
2495
-					$vcardData['end']	= $dtend_ts;
2494
+					$vcardData['end'] = $dtend_ts;
2496 2495
 					break;
2497 2496
 
2498 2497
 				case 'DURATION':	// clients can use DTSTART+DURATION, instead of DTSTART+DTEND
@@ -2512,7 +2511,7 @@  discard block
 block discarded – undo
2512 2511
 			if ($this->log)
2513 2512
 			{
2514 2513
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2515
-					. "() DTSTART missing!\n",3,$this->logfile);
2514
+					. "() DTSTART missing!\n", 3, $this->logfile);
2516 2515
 			}
2517 2516
 			return false; // not a valid entry
2518 2517
 		}
@@ -2524,7 +2523,7 @@  discard block
 block discarded – undo
2524 2523
 				case 'X-MICROSOFT-CDO-ALLDAYEVENT':
2525 2524
 					if (isset($supportedFields['whole_day']))
2526 2525
 					{
2527
-						$event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true);
2526
+						$event['whole_day'] = (isset($attributes['value']) ? strtoupper($attributes['value']) == 'TRUE' : true);
2528 2527
 					}
2529 2528
 					break;
2530 2529
 				case 'AALARM':
@@ -2554,32 +2553,32 @@  discard block
 block discarded – undo
2554 2553
 					$vcardData['recurrence'] = $attributes['value'];
2555 2554
 					break;
2556 2555
 				case 'LOCATION':
2557
-					$vcardData['location']	= str_replace("\r\n", "\n", $attributes['value']);
2556
+					$vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']);
2558 2557
 					break;
2559 2558
 				case 'RRULE':
2560 2559
 					$recurence = $attributes['value'];
2561 2560
 					$vcardData['recur_interval'] = 1;
2562
-					$type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence[0];
2561
+					$type = preg_match('/FREQ=([^;: ]+)/i', $recurence, $matches) ? $matches[1] : $recurence[0];
2563 2562
 					// vCard 2.0 values for all types
2564
-					if (preg_match('/UNTIL=([0-9TZ]+)/',$recurence,$matches))
2563
+					if (preg_match('/UNTIL=([0-9TZ]+)/', $recurence, $matches))
2565 2564
 					{
2566 2565
 						$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($matches[1]);
2567 2566
 						// If it couldn't be parsed, treat it as not set
2568
-						if(is_string($vcardData['recur_enddate']))
2567
+						if (is_string($vcardData['recur_enddate']))
2569 2568
 						{
2570 2569
 							unset($vcardData['recur_enddate']);
2571 2570
 						}
2572 2571
 					}
2573
-					elseif (preg_match('/COUNT=([0-9]+)/',$recurence,$matches))
2572
+					elseif (preg_match('/COUNT=([0-9]+)/', $recurence, $matches))
2574 2573
 					{
2575 2574
 						$vcardData['recur_count'] = (int)$matches[1];
2576 2575
 					}
2577
-					if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches))
2576
+					if (preg_match('/INTERVAL=([0-9]+)/', $recurence, $matches))
2578 2577
 					{
2579
-						$vcardData['recur_interval'] = (int) $matches[1] ? (int) $matches[1] : 1;
2578
+						$vcardData['recur_interval'] = (int)$matches[1] ? (int)$matches[1] : 1;
2580 2579
 					}
2581 2580
 					$vcardData['recur_data'] = 0;
2582
-					switch($type)
2581
+					switch ($type)
2583 2582
 					{
2584 2583
 						case 'D':	// 1.0
2585 2584
 							$recurenceMatches = null;
@@ -2603,20 +2602,20 @@  discard block
 block discarded – undo
2603 2602
 						case 'W':
2604 2603
 						case 'WEEKLY':
2605 2604
 							$days = array();
2606
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2605
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/', $recurence, $recurenceMatches))		// 1.0
2607 2606
 							{
2608 2607
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2609 2608
 								if (empty($recurenceMatches[2]))
2610 2609
 								{
2611
-									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
2610
+									$days[0] = strtoupper(substr(date('D', $vcardData['start']), 0, 2));
2612 2611
 								}
2613 2612
 								else
2614 2613
 								{
2615
-									$days = explode(' ',trim($recurenceMatches[2]));
2614
+									$days = explode(' ', trim($recurenceMatches[2]));
2616 2615
 								}
2617 2616
 
2618 2617
 								$repeatMatches = null;
2619
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2618
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $repeatMatches))
2620 2619
 								{
2621 2620
 									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2622 2621
 								}
@@ -2627,21 +2626,21 @@  discard block
 block discarded – undo
2627 2626
 
2628 2627
 								$recur_days = $this->recur_days_1_0;
2629 2628
 							}
2630
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2629
+							elseif (preg_match('/BYDAY=([^;: ]+)/', $recurence, $recurenceMatches))	// 2.0
2631 2630
 							{
2632
-								$days = explode(',',$recurenceMatches[1]);
2631
+								$days = explode(',', $recurenceMatches[1]);
2633 2632
 								$recur_days = $this->recur_days;
2634 2633
 							}
2635 2634
 							else	// no day given, use the day of dtstart
2636 2635
 							{
2637
-								$vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']);
2636
+								$vcardData['recur_data'] |= 1 << (int)date('w', $vcardData['start']);
2638 2637
 								$vcardData['recur_type'] = MCAL_RECUR_WEEKLY;
2639 2638
 							}
2640 2639
 							if ($days)
2641 2640
 							{
2642 2641
 								foreach ($recur_days as $id => $day)
2643 2642
 								{
2644
-									if (in_array(strtoupper(substr($day,0,2)),$days))
2643
+									if (in_array(strtoupper(substr($day, 0, 2)), $days))
2645 2644
 									{
2646 2645
 										$vcardData['recur_data'] |= $id;
2647 2646
 									}
@@ -2657,17 +2656,17 @@  discard block
 block discarded – undo
2657 2656
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2658 2657
 								$vcardData['recur_count'] = $recurenceMatches[2];
2659 2658
 							}
2660
-							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2659
+							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2661 2660
 							{
2662 2661
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY;
2663 2662
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2664 2663
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2665 2664
 							}
2666
-							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches))
2665
+							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/', $recurence, $recurenceMatches))
2667 2666
 							{
2668 2667
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
2669 2668
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2670
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$recurenceMatches))
2669
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $recurenceMatches))
2671 2670
 								{
2672 2671
 									$vcardData['recur_count'] = $recurenceMatches[1];
2673 2672
 								}
@@ -2684,7 +2683,7 @@  discard block
 block discarded – undo
2684 2683
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2685 2684
 								$vcardData['recur_count'] = $recurenceMatches[2];
2686 2685
 							}
2687
-							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2686
+							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2688 2687
 							{
2689 2688
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2690 2689
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
@@ -2698,11 +2697,11 @@  discard block
 block discarded – undo
2698 2697
 							}
2699 2698
 							// handle FREQ=YEARLY;BYDAY= as FREQ=MONTHLY;BYDAY= with 12*INTERVAL
2700 2699
 							$vcardData['recur_interval'] = $vcardData['recur_interval'] ?
2701
-								12*$vcardData['recur_interval'] : 12;
2700
+								12 * $vcardData['recur_interval'] : 12;
2702 2701
 							// fall-through
2703 2702
 						case 'MONTHLY':
2704 2703
 							// does currently NOT parse BYDAY or BYMONTH, it has to be specified/identical to DTSTART
2705
-							$vcardData['recur_type'] = strpos($recurence,'BYDAY') !== false ?
2704
+							$vcardData['recur_type'] = strpos($recurence, 'BYDAY') !== false ?
2706 2705
 								MCAL_RECUR_MONTHLY_WDAY : MCAL_RECUR_MONTHLY_MDAY;
2707 2706
 							break;
2708 2707
 					}
@@ -2758,11 +2757,11 @@  discard block
 block discarded – undo
2758 2757
 						(strpos($this->productName, 'outlook') !== false
2759 2758
 							|| strpos($this->productName, 'pocket pc') !== false))
2760 2759
 					{
2761
-						$vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']];
2760
+						$vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']];
2762 2761
 					}
2763 2762
 					else
2764 2763
 					{
2765
-						$vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']];
2764
+						$vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']];
2766 2765
 					}
2767 2766
 					break;
2768 2767
 				case 'CATEGORIES':
@@ -2776,10 +2775,10 @@  discard block
 block discarded – undo
2776 2775
 					}
2777 2776
 					break;
2778 2777
 				case 'ORGANIZER':
2779
-					$event['organizer'] = $attributes['value'];	// no egw field, but needed in AS
2780
-					if (strtolower(substr($event['organizer'],0,7)) == 'mailto:')
2778
+					$event['organizer'] = $attributes['value']; // no egw field, but needed in AS
2779
+					if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:')
2781 2780
 					{
2782
-						$event['organizer'] = substr($event['organizer'],7);
2781
+						$event['organizer'] = substr($event['organizer'], 7);
2783 2782
 					}
2784 2783
 					if (!empty($attributes['params']['CN']))
2785 2784
 					{
@@ -2816,19 +2815,19 @@  discard block
 block discarded – undo
2816 2815
 					}
2817 2816
 					// try parsing email and cn from attendee
2818 2817
 					elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2819
-						$attributes['value'],$matches))
2818
+						$attributes['value'], $matches))
2820 2819
 					{
2821 2820
 						$email = $matches[1] ? $matches[1] : $matches[3];
2822
-						$cn = isset($matches[2]) ? $matches[2]: '';
2821
+						$cn = isset($matches[2]) ? $matches[2] : '';
2823 2822
 					}
2824 2823
 					elseif (!empty($attributes['value']) &&
2825 2824
 						preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2826
-						$attributes['value'],$matches))
2825
+						$attributes['value'], $matches))
2827 2826
 					{
2828 2827
 						$cn = $matches[1];
2829 2828
 						$email = $matches[2];
2830 2829
 					}
2831
-					elseif (strpos($attributes['value'],'@') !== false)
2830
+					elseif (strpos($attributes['value'], '@') !== false)
2832 2831
 					{
2833 2832
 						$email = $attributes['value'];
2834 2833
 					}
@@ -2845,7 +2844,7 @@  discard block
 block discarded – undo
2845 2844
 						if ($this->log)
2846 2845
 						{
2847 2846
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2848
-								. "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile);
2847
+								. "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile);
2849 2848
 						}
2850 2849
 					}
2851 2850
 					elseif ($attributes['value'] == 'Unknown')
@@ -2863,7 +2862,7 @@  discard block
 block discarded – undo
2863 2862
 						if ($this->log)
2864 2863
 						{
2865 2864
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2866
-								. "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile);
2865
+								. "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2867 2866
 						}
2868 2867
 					}
2869 2868
 					if (!$uid)
@@ -2880,9 +2879,9 @@  discard block
 block discarded – undo
2880 2879
 							$cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'),
2881 2880
 										array(',', ';', ':', '\\'),
2882 2881
 										$attributes['params']['CN']);
2883
-							if ($cn[0] == '"' && substr($cn,-1) == '"')
2882
+							if ($cn[0] == '"' && substr($cn, -1) == '"')
2884 2883
 							{
2885
-								$cn = substr($cn,1,-1);
2884
+								$cn = substr($cn, 1, -1);
2886 2885
 							}
2887 2886
 							// not searching for $cn, as match can be not unique or without an email address
2888 2887
 							// --> notification will fail, better store just as email
@@ -2891,19 +2890,19 @@  discard block
 block discarded – undo
2891 2890
 						if ($this->log)
2892 2891
 						{
2893 2892
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2894
-								. "() Search participant: '$cn', '$email'\n",3,$this->logfile);
2893
+								. "() Search participant: '$cn', '$email'\n", 3, $this->logfile);
2895 2894
 						}
2896 2895
 
2897 2896
 						//elseif (//$attributes['params']['CUTYPE'] == 'GROUP'
2898
-						if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches))
2897
+						if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches))
2899 2898
 						{
2900 2899
 							// we found a group
2901 2900
 							if ($this->log)
2902 2901
 							{
2903 2902
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2904
-									. "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile);
2903
+									. "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile);
2905 2904
 							}
2906
-							if (($uid =  $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2905
+							if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2907 2906
 							{
2908 2907
 								//Horde::logMessage("vevent2egw: group participant $uid",
2909 2908
 								//			__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -2917,7 +2916,7 @@  discard block
 block discarded – undo
2917 2916
 										//Horde::logMessage("vevent2egw: set status to " . $status,
2918 2917
 										//		__FILE__, __LINE__, PEAR_LOG_DEBUG);
2919 2918
 										$vcardData['participants'][$this->user] =
2920
-											calendar_so::combine_status($status,$quantity,$role);
2919
+											calendar_so::combine_status($status, $quantity, $role);
2921 2920
 									}
2922 2921
 								}
2923 2922
 								$status = 'U'; // keep the group
@@ -2926,36 +2925,36 @@  discard block
 block discarded – undo
2926 2925
 						}
2927 2926
 						elseif (empty($searcharray))
2928 2927
 						{
2929
-							continue;	// participants without email AND CN --> ignore it
2928
+							continue; // participants without email AND CN --> ignore it
2930 2929
 						}
2931 2930
 						elseif ((list($data) = $this->addressbook->search($searcharray,
2932
-							array('id','egw_addressbook.account_id as account_id','n_fn'),
2931
+							array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
2933 2932
 							'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
2934
-							'','',false,'OR')))
2933
+							'', '', false, 'OR')))
2935 2934
 						{
2936 2935
 							// found an addressbook entry
2937 2936
 							$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
2938 2937
 							if ($this->log)
2939 2938
 							{
2940 2939
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2941
-									. "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile);
2940
+									. "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2942 2941
 							}
2943 2942
 						}
2944 2943
 						else
2945 2944
 						{
2946 2945
 							if (!$email)
2947 2946
 							{
2948
-								$email = '[email protected]';	// set dummy email to store the CN
2947
+								$email = '[email protected]'; // set dummy email to store the CN
2949 2948
 							}
2950
-							$uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email);
2949
+							$uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email);
2951 2950
 							if ($this->log)
2952 2951
 							{
2953 2952
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2954
-									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile);
2953
+									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2955 2954
 							}
2956 2955
 						}
2957 2956
 					}
2958
-					switch($attributes['name'])
2957
+					switch ($attributes['name'])
2959 2958
 					{
2960 2959
 						case 'ATTENDEE':
2961 2960
 							if (!isset($attributes['params']['ROLE']) &&
@@ -2969,7 +2968,7 @@  discard block
 block discarded – undo
2969 2968
 								// keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role
2970 2969
 								// as this is currently the only way to store an external organizer and send him iMip responses
2971 2970
 								$q = $r = null;
2972
-								if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) &&
2971
+								if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) &&
2973 2972
 									calendar_so::split_status($s, $q, $r) && $r == 'CHAIR')
2974 2973
 								{
2975 2974
 									$role = 'CHAIR';
@@ -2983,7 +2982,7 @@  discard block
 block discarded – undo
2983 2982
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2984 2983
 										$component->getAttribute('ORGANIZER');
2985 2984
 								}
2986
-								catch(Horde_Icalendar_Exception $e)
2985
+								catch (Horde_Icalendar_Exception $e)
2987 2986
 								{
2988 2987
 									// we can store the ORGANIZER as event owner
2989 2988
 									$event['owner'] = $uid;
@@ -3039,7 +3038,7 @@  discard block
 block discarded – undo
3039 3038
 					break;
3040 3039
 
3041 3040
 				case 'ATTACH':
3042
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3041
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code
3043 3042
 					// fall throught to store external attachment url
3044 3043
 				default:	// X- attribute or other by EGroupware unsupported property
3045 3044
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3097,7 +3096,7 @@  discard block
 block discarded – undo
3097 3096
 					if ($event['recur_type'] != MCAL_RECUR_NONE)
3098 3097
 					{
3099 3098
 						$event['reference'] = 0;
3100
-						foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r)
3099
+						foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r)
3101 3100
 						{
3102 3101
 							if (isset($vcardData[$r]))
3103 3102
 							{
@@ -3120,12 +3119,12 @@  discard block
 block discarded – undo
3120 3119
 			// reset recure_enddate to 00:00:00 on the last day
3121 3120
 			$rriter = calendar_rrule::event2rrule($event, false);
3122 3121
 			$last = $rriter->normalize_enddate();
3123
-			if(!is_object($last))
3122
+			if (!is_object($last))
3124 3123
 			{
3125
-				if($this->log)
3124
+				if ($this->log)
3126 3125
 				{
3127
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
3128
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3126
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
3127
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3129 3128
 				}
3130 3129
 				return false;
3131 3130
 			}
@@ -3134,16 +3133,16 @@  discard block
 block discarded – undo
3134 3133
 			$event['recur_enddate'] = egw_time::to($last, 'server');
3135 3134
 		}
3136 3135
 		// translate COUNT into an enddate, as we only store enddates
3137
-		elseif($event['recur_count'])
3136
+		elseif ($event['recur_count'])
3138 3137
 		{
3139 3138
 			$rriter = calendar_rrule::event2rrule($event, false);
3140 3139
 			$last = $rriter->count2date($event['recur_count']);
3141
-			if(!is_object($last))
3140
+			if (!is_object($last))
3142 3141
 			{
3143
-				if($this->log)
3142
+				if ($this->log)
3144 3143
 				{
3145 3144
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__,
3146
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3145
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3147 3146
 				}
3148 3147
 				return false;
3149 3148
 			}
@@ -3157,7 +3156,7 @@  discard block
 block discarded – undo
3157 3156
 			if ($this->productManufacturer == 'groupdav' && $container &&
3158 3157
 				($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')))
3159 3158
 			{
3160
-				$event['public'] =  (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3159
+				$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3161 3160
 			}
3162 3161
 			//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
3163 3162
 		}
@@ -3178,15 +3177,15 @@  discard block
 block discarded – undo
3178 3177
 
3179 3178
 		if ($this->log)
3180 3179
 		{
3181
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
3182
-				array2string($event)."\n",3,$this->logfile);
3180
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
3181
+				array2string($event)."\n", 3, $this->logfile);
3183 3182
 		}
3184 3183
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3185 3184
         //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3186 3185
 		return $event;
3187 3186
 	}
3188 3187
 
3189
-	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3188
+	function search($_vcalData, $contentID = null, $relax = false, $charset = null)
3190 3189
 	{
3191 3190
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
3192 3191
 		{
@@ -3207,8 +3206,8 @@  discard block
 block discarded – undo
3207 3206
 			}
3208 3207
 			if ($this->log)
3209 3208
 			{
3210
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" .
3211
-					array2string($events)."\n",3,$this->logfile);
3209
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n".
3210
+					array2string($events)."\n", 3, $this->logfile);
3212 3211
 			}
3213 3212
 		}
3214 3213
 		return array();
@@ -3226,23 +3225,23 @@  discard block
 block discarded – undo
3226 3225
 	 * @param array $extra =null extra attributes to add
3227 3226
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3228 3227
 	 */
3229
-	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3228
+	function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null)
3230 3229
 	{
3231
-		if (!$start) $start = time();	// default now
3232
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3230
+		if (!$start) $start = time(); // default now
3231
+		if (!$end) $end = time() + 100 * DAY_s; // default next 100 days
3233 3232
 
3234 3233
 		$vcal = new Horde_Icalendar;
3235
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3234
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3236 3235
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
3237
-		$vcal->setAttribute('VERSION','2.0');
3238
-		$vcal->setAttribute('METHOD',$method);
3236
+		$vcal->setAttribute('VERSION', '2.0');
3237
+		$vcal->setAttribute('METHOD', $method);
3239 3238
 
3240
-		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal);
3239
+		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal);
3241 3240
 
3242 3241
 		$attributes = array(
3243 3242
 			'DTSTAMP' => time(),
3244
-			'DTSTART' => $this->date2ts($start,true),	// true = server-time
3245
-			'DTEND' => $this->date2ts($end,true),	// true = server-time
3243
+			'DTSTART' => $this->date2ts($start, true), // true = server-time
3244
+			'DTEND' => $this->date2ts($end, true), // true = server-time
3246 3245
 		);
3247 3246
 		if (!$utc)
3248 3247
 		{
@@ -3253,9 +3252,9 @@  discard block
 block discarded – undo
3253 3252
 		}
3254 3253
 		if (is_null($extra)) $extra = array(
3255 3254
 			'URL' => $this->freebusy_url($user),
3256
-			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3255
+			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'),
3257 3256
 		);
3258
-		foreach($attributes+$extra as $attr => $value)
3257
+		foreach ($attributes + $extra as $attr => $value)
3259 3258
 		{
3260 3259
 			$vfreebusy->setAttribute($attr, $value);
3261 3260
 		}
@@ -3278,16 +3277,16 @@  discard block
 block discarded – undo
3278 3277
 
3279 3278
 				if ($utc)
3280 3279
 				{
3281
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3280
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3282 3281
 						'start' => $event['start'],
3283 3282
 						'end' => $event['end'],
3284 3283
 					)), array('FBTYPE' => $fbtype));
3285 3284
 				}
3286 3285
 				else
3287 3286
 				{
3288
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3289
-						'start' => date('Ymd\THis',$event['start']),
3290
-						'end' => date('Ymd\THis',$event['end']),
3287
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3288
+						'start' => date('Ymd\THis', $event['start']),
3289
+						'end' => date('Ymd\THis', $event['end']),
3291 3290
 					)), array('FBTYPE' => $fbtype));
3292 3291
 				}
3293 3292
 			}
Please login to merge, or discard this patch.
calendar/inc/class.calendar_egw_record.inc.php 1 patch
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,12 +37,15 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $_identifier
39 39
 	 */
40
-	public function __construct( $_identifier='' ){
40
+	public function __construct( $_identifier='' )
41
+	{
41 42
 		$this->identifier = $_identifier;
42
-		if(!is_object($this->bo)) {
43
+		if(!is_object($this->bo))
44
+		{
43 45
 			$this->bo = new calendar_bo();
44 46
 		}
45
-		if($this->identifier) {
47
+		if($this->identifier)
48
+		{
46 49
 			$this->record = $this->bo->read($this->identifier);
47 50
 		}
48 51
 	}
@@ -52,7 +55,8 @@  discard block
 block discarded – undo
52 55
 	 *
53 56
 	 * @param string $_attribute_name
54 57
 	 */
55
-	public function __get($_attribute_name) {
58
+	public function __get($_attribute_name)
59
+	{
56 60
 		return $this->record[$_attribute_name];
57 61
 	}
58 62
 
@@ -62,11 +66,13 @@  discard block
 block discarded – undo
62 66
 	 * @param string $_attribute_name
63 67
 	 * @param data $data
64 68
 	 */
65
-	public function __set($_attribute_name, $data) {
69
+	public function __set($_attribute_name, $data)
70
+	{
66 71
 		$this->record[$_attribute_name] = $data;
67 72
 	}
68 73
 
69
-	public function __unset($_attribute_name) {
74
+	public function __unset($_attribute_name)
75
+	{
70 76
 		unset($this->record[$_attribute_name]);
71 77
 	}
72 78
 
@@ -78,7 +84,8 @@  discard block
 block discarded – undo
78 84
 	 *
79 85
 	 * @return array complete record as associative array
80 86
 	 */
81
-	public function get_record_array() {
87
+	public function get_record_array()
88
+	{
82 89
 		return $this->record;
83 90
 	}
84 91
 
@@ -87,8 +94,10 @@  discard block
 block discarded – undo
87 94
 	 *
88 95
 	 *@return string tiltle
89 96
 	 */
90
-	public function get_title() {
91
-		if (empty($this->record)) {
97
+	public function get_title()
98
+	{
99
+		if (empty($this->record))
100
+		{
92 101
 			$this->get_record();
93 102
 		}
94 103
 		return $this->record['title'];
@@ -100,7 +109,8 @@  discard block
 block discarded – undo
100 109
 	 * @todo add some checks
101 110
 	 * @return void
102 111
 	 */
103
-	public function set_record(array $_record){
112
+	public function set_record(array $_record)
113
+	{
104 114
 		$this->record = $_record;
105 115
 	}
106 116
 
@@ -109,7 +119,8 @@  discard block
 block discarded – undo
109 119
 	 *
110 120
 	 * @return string identifier of current record
111 121
 	 */
112
-	public function get_identifier() {
122
+	public function get_identifier()
123
+	{
113 124
 		return $this->identifier;
114 125
 	}
115 126
 
@@ -119,7 +130,8 @@  discard block
 block discarded – undo
119 130
 	 *
120 131
 	 * @return string Full URL of an icon, or appname/icon_name
121 132
 	 */
122
-	public function get_icon() {
133
+	public function get_icon()
134
+	{
123 135
 		return 'calendar/navbar';
124 136
 	}
125 137
 
@@ -128,7 +140,8 @@  discard block
 block discarded – undo
128 140
 	 *
129 141
 	 * @return string identifier
130 142
 	 */
131
-	public function save ( $_dst_identifier ) {
143
+	public function save ( $_dst_identifier )
144
+	{
132 145
 		// Not yet implemeted
133 146
 		$this->identifier = $_dst_identifier;
134 147
 	}
@@ -139,7 +152,8 @@  discard block
 block discarded – undo
139 152
 	 * @param string $_dst_identifier
140 153
 	 * @return string dst_identifier
141 154
 	 */
142
-	public function copy ( $_dst_identifier ) {
155
+	public function copy ( $_dst_identifier )
156
+	{
143 157
 
144 158
 	}
145 159
 
@@ -150,7 +164,8 @@  discard block
 block discarded – undo
150 164
 	 * @param string $_dst_identifier
151 165
 	 * @return string dst_identifier
152 166
 	 */
153
-	public function move ( $_dst_identifier ) {
167
+	public function move ( $_dst_identifier )
168
+	{
154 169
 
155 170
 	}
156 171
 
@@ -158,7 +173,8 @@  discard block
 block discarded – undo
158 173
 	 * delets current record from backend
159 174
 	 *
160 175
 	 */
161
-	public function delete () {
176
+	public function delete ()
177
+	{
162 178
 
163 179
 	}
164 180
 
@@ -166,7 +182,8 @@  discard block
 block discarded – undo
166 182
 	 * destructor
167 183
 	 *
168 184
 	 */
169
-	public function __destruct() {
185
+	public function __destruct()
186
+	{
170 187
 	}
171 188
 
172 189
 } // end of calendar_egw_record
Please login to merge, or discard this patch.