Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
calendar/importexport/class.import_events_csv.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,6 @@
 block discarded – undo
94 94
 	/**
95 95
 	 * imports entries according to given definition object.
96 96
 	 * @param resource $_stream
97
-	 * @param string $_charset
98 97
 	 * @param definition $_definition
99 98
 	 */
100 99
 	public function import( $_stream, definition $_definition ) {
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	private $user = null;
83 83
 
84 84
 	/**
85
-         * List of import errors
86
-         */
87
-        protected $errors = array();
85
+	 * List of import errors
86
+	 */
87
+		protected $errors = array();
88 88
 
89 89
 	/**
90 90
 	 * List of actions, and how many times that action was taken
@@ -305,26 +305,26 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 
307 307
 	/**
308
-        * Returns errors that were encountered during importing
309
-        * Maximum of one error message per record, but you can append if you need to
310
-        *
311
-        * @return Array (
312
-        *       record_# => error message
313
-        *       )
314
-        */
315
-        public function get_errors() {
308
+	 * Returns errors that were encountered during importing
309
+	 * Maximum of one error message per record, but you can append if you need to
310
+	 *
311
+	 * @return Array (
312
+	 *       record_# => error message
313
+	 *       )
314
+	 */
315
+		public function get_errors() {
316 316
 		return $this->errors;
317 317
 	}
318 318
 
319 319
 	/**
320
-        * Returns a list of actions taken, and the number of records for that action.
321
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
322
-        *
323
-        * @return Array (
324
-        *       action => record count
325
-        * )
326
-        */
327
-        public function get_results() {
320
+	 * Returns a list of actions taken, and the number of records for that action.
321
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
322
+	 *
323
+	 * @return Array (
324
+	 *       action => record count
325
+	 * )
326
+	 */
327
+		public function get_results() {
328 328
 		return $this->results;
329 329
 	}
330 330
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,28 +10,28 @@  discard block
 block discarded – undo
10 10
  * @version $Id: $
11 11
  */
12 12
 
13
-require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_import_plugin.inc.php');
13
+require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.iface_import_plugin.inc.php');
14 14
 require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.import_csv.inc.php');
15 15
 
16 16
 
17 17
 /**
18 18
  * class import_csv for addressbook
19 19
  */
20
-class import_events_csv implements iface_import_plugin  {
20
+class import_events_csv implements iface_import_plugin {
21 21
 
22 22
 	private static $plugin_options = array(
23
-		'fieldsep', 			// char
24
-		'charset', 				// string
25
-		'event_owner', 			// int account_id or -1 for leave untuched
26
-		'owner_joins_event',	// bool
27
-		'update_cats', 			// string {override|add} overides record
23
+		'fieldsep', // char
24
+		'charset', // string
25
+		'event_owner', // int account_id or -1 for leave untuched
26
+		'owner_joins_event', // bool
27
+		'update_cats', // string {override|add} overides record
28 28
 								// with cat(s) from csv OR add the cat from
29 29
 								// csv file to exeisting cat(s) of record
30
-		'num_header_lines',		// int number of header lines
31
-		'trash_users_records',	// trashes all events of events owner before import
32
-		'field_conversion', 	// array( $csv_col_num => conversion)
33
-		'field_mapping',		// array( $csv_col_num => adb_filed)
34
-		'conditions',			/* => array containing condition arrays:
30
+		'num_header_lines', // int number of header lines
31
+		'trash_users_records', // trashes all events of events owner before import
32
+		'field_conversion', // array( $csv_col_num => conversion)
33
+		'field_mapping', // array( $csv_col_num => adb_filed)
34
+		'conditions', /* => array containing condition arrays:
35 35
 				'type' => exists, // record['uid'] exists
36 36
 				'true' => array(
37 37
 					'action' => update,
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * actions wich could be done to data entries
49 49
 	 */
50
-	private static $actions = array( 'none', 'update', 'insert', 'delete', );
50
+	private static $actions = array('none', 'update', 'insert', 'delete',);
51 51
 
52 52
 	/**
53 53
 	 * conditions for actions
54 54
 	 *
55 55
 	 * @var array
56 56
 	 */
57
-	private static $conditions = array( 'exists', 'empty', );
57
+	private static $conditions = array('exists', 'empty',);
58 58
 
59 59
 	/**
60 60
 	 * @var definition
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @param string $_charset
98 98
 	 * @param definition $_definition
99 99
 	 */
100
-	public function import( $_stream, definition $_definition ) {
101
-		$import_csv = new import_csv( $_stream, array(
100
+	public function import($_stream, definition $_definition) {
101
+		$import_csv = new import_csv($_stream, array(
102 102
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
103 103
 			'charset' => $_definition->plugin_options['charset'],
104 104
 		));
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		$this->definition = $_definition;
107 107
 
108 108
 		// user, is admin ?
109
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
109
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
110 110
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
111 111
 
112 112
 		// dry run?
113
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
113
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
114 114
 
115 115
 		// fetch the calendar bo
116 116
 		$this->bocalupdate = new calendar_boupdate();
@@ -122,22 +122,22 @@  discard block
 block discarded – undo
122 122
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
123 123
 
124 124
 		//check if file has a header lines
125
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) ) {
126
-			$import_csv->skip_records( $_definition->plugin_options['num_header_lines'] );
125
+		if (isset($_definition->plugin_options['num_header_lines'])) {
126
+			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
127 127
 		}
128 128
 
129 129
 		// set eventOwner
130
-		$_definition->plugin_options['events_owner'] = isset( $_definition->plugin_options['events_owner'] ) ?
130
+		$_definition->plugin_options['events_owner'] = isset($_definition->plugin_options['events_owner']) ?
131 131
 			$_definition->plugin_options['events_owner'] : $this->user;
132 132
 
133 133
 		// trash_users_records ?
134
-		if ( $_definition->plugin_options['trash_users_records'] === true ) {
135
-			if ( !$_definition->plugin_options['dry_run'] ) {
134
+		if ($_definition->plugin_options['trash_users_records'] === true) {
135
+			if (!$_definition->plugin_options['dry_run']) {
136 136
 				$socal = new calendar_socal();
137
-				$this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']);
138
-				unset( $socal );
137
+				$this->bocalupdate->so->deleteaccount($_definition->plugin_options['events_owner']);
138
+				unset($socal);
139 139
 			} else {
140
-				$lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] );
140
+				$lid = $GLOBALS['egw']->accounts->id2name($_definition->plugin_options['events_owner']);
141 141
 				echo "Attension: All Events of '$lid' would be deleted!\n";
142 142
 			}
143 143
 		}
@@ -145,44 +145,44 @@  discard block
 block discarded – undo
145 145
 		$this->errors = array();
146 146
 		$this->results = array();
147 147
 
148
-		while ( $record = $import_csv->get_record() ) {
148
+		while ($record = $import_csv->get_record()) {
149 149
 
150 150
 			// don't import empty events
151
-			if( count( array_unique( $record ) ) < 2 ) continue;
151
+			if (count(array_unique($record)) < 2) continue;
152 152
 
153
-			if ( $_definition->plugin_options['events_owner'] != -1 ) {
153
+			if ($_definition->plugin_options['events_owner'] != -1) {
154 154
 				$record['owner'] = $_definition->plugin_options['events_owner'];
155
-			} else unset( $record['owner'] );
155
+			} else unset($record['owner']);
156 156
 
157
-			if ( $_definition->plugin_options['conditions'] ) {
158
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
159
-					switch ( $condition['type'] ) {
157
+			if ($_definition->plugin_options['conditions']) {
158
+				foreach ($_definition->plugin_options['conditions'] as $condition) {
159
+					switch ($condition['type']) {
160 160
 						// exists
161 161
 						case 'exists' :
162 162
 
163
-							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) {
163
+							if (is_array($event = $this->bocalupdate->read($record['uid'], null, $this->is_admin))) {
164 164
 								// apply action to event matching this exists condition
165 165
 								$record['id'] = $event['id'];
166 166
 
167
-								if ( $_definition->plugin_options['update_cats'] == 'add' ) {
168
-									if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] );
169
-									if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
170
-									$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) );
167
+								if ($_definition->plugin_options['update_cats'] == 'add') {
168
+									if (!is_array($event['cat_id'])) $event['cat_id'] = explode(',', $event['cat_id']);
169
+									if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
170
+									$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $event['cat_id'])));
171 171
 								}
172 172
 
173 173
 								// check if entry is modiefied
174
-								$event = array_intersect_key( $event, $record );
175
-								$diff = array_diff( $event, $record );
176
-								if( !empty( $diff ) ) $record['modified'] = time();
174
+								$event = array_intersect_key($event, $record);
175
+								$diff = array_diff($event, $record);
176
+								if (!empty($diff)) $record['modified'] = time();
177 177
 
178 178
 								$action = $condition['true'];
179 179
 							} else $action = $condition['false'];
180 180
 
181
-							$this->action( $action['action'], $record );
181
+							$this->action($action['action'], $record);
182 182
 							break;
183 183
 						case 'empty' :
184
-							$action = empty( $record[$condition['string']] ) ? $condition['true'] : $condition['false'];
185
-							$this->action( $action['action'], $record );
184
+							$action = empty($record[$condition['string']]) ? $condition['true'] : $condition['false'];
185
+							$this->action($action['action'], $record);
186 186
 							break;
187 187
 
188 188
 						// not supported action
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 				}
195 195
 			} else {
196 196
 				// unconditional insert
197
-				$this->action( 'insert', $record );
197
+				$this->action('insert', $record);
198 198
 			}
199 199
 		}
200 200
 	}
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 * @param array $_data event data for the action
207 207
 	 * @return bool success or not
208 208
 	 */
209
-	private function action ( $_action, $_data ) {
210
-		switch ( $_action ) {
209
+	private function action($_action, $_data) {
210
+		switch ($_action) {
211 211
 			case 'none' :
212 212
 				return true;
213 213
 
@@ -215,32 +215,32 @@  discard block
 block discarded – undo
215 215
 			case 'insert' :
216 216
 
217 217
 				// paticipants handling
218
-				$participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array();
218
+				$participants = $_data['participants'] ? split('[,;]', $_data['participants']) : array();
219 219
 				$_data['participants'] = array();
220
-				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) {
220
+				if ($this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0) {
221 221
 					$_data['participants'][$this->definition->plugin_options['events_owner']] = 'A';
222 222
 				}
223
-				foreach( $participants as $participant ) {
224
-					list( $participant, $status ) = explode( '=', $participant );
225
-					$valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T');
226
-					$status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U';
227
-					if ( $participant && is_numeric($participant ) ) {
223
+				foreach ($participants as $participant) {
224
+					list($participant, $status) = explode('=', $participant);
225
+					$valid_staties = array('U'=>'U', 'u'=>'U', 'A'=>'A', 'a'=>'A', 'R'=>'R', 'r'=>'R', 'T'=>'T', 't'=>'T');
226
+					$status = isset($valid_staties[$status]) ? $valid_staties[$status] : 'U';
227
+					if ($participant && is_numeric($participant)) {
228 228
 						$_data['participants'][$participant] = $status;
229 229
 					}
230 230
 				}
231 231
 				// no valid participants so far --> add the importing user/owner
232
-				if ( empty( $_data['participants'] ) ) {
232
+				if (empty($_data['participants'])) {
233 233
 					$_data['participants'][$this->user] = 'A';
234 234
 				}
235 235
 
236 236
 				// are we serious?
237
-				if ( $this->dry_run ) {
237
+				if ($this->dry_run) {
238 238
 					print_r($_data);
239 239
 					$this->results[$_action]++;
240 240
 				} else {
241 241
 					$messages = array();
242
-					$result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages);
243
-					if(!$result) {
242
+					$result = $this->bocalupdate->update($_data, true, !$_data['modified'], $this->is_admin, true, $messages);
243
+					if (!$result) {
244 244
 						$this->errors = implode(',', $messages);
245 245
 					} else {
246 246
 						$this->results[$_action]++;
Please login to merge, or discard this patch.
Braces   +94 added lines, -38 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 addressbook
19 19
  */
20
-class import_events_csv implements iface_import_plugin  {
20
+class import_events_csv implements iface_import_plugin
21
+{
21 22
 
22 23
 	private static $plugin_options = array(
23 24
 		'fieldsep', 			// char
@@ -97,7 +98,8 @@  discard block
 block discarded – undo
97 98
 	 * @param string $_charset
98 99
 	 * @param definition $_definition
99 100
 	 */
100
-	public function import( $_stream, definition $_definition ) {
101
+	public function import( $_stream, definition $_definition )
102
+	{
101 103
 		$import_csv = new import_csv( $_stream, array(
102 104
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
103 105
 			'charset' => $_definition->plugin_options['charset'],
@@ -122,7 +124,8 @@  discard block
 block discarded – undo
122 124
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
123 125
 
124 126
 		//check if file has a header lines
125
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) ) {
127
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) )
128
+		{
126 129
 			$import_csv->skip_records( $_definition->plugin_options['num_header_lines'] );
127 130
 		}
128 131
 
@@ -131,12 +134,16 @@  discard block
 block discarded – undo
131 134
 			$_definition->plugin_options['events_owner'] : $this->user;
132 135
 
133 136
 		// trash_users_records ?
134
-		if ( $_definition->plugin_options['trash_users_records'] === true ) {
135
-			if ( !$_definition->plugin_options['dry_run'] ) {
137
+		if ( $_definition->plugin_options['trash_users_records'] === true )
138
+		{
139
+			if ( !$_definition->plugin_options['dry_run'] )
140
+			{
136 141
 				$socal = new calendar_socal();
137 142
 				$this->bocalupdate->so->deleteaccount( $_definition->plugin_options['events_owner']);
138 143
 				unset( $socal );
139
-			} else {
144
+			}
145
+			else
146
+			{
140 147
 				$lid = $GLOBALS['egw']->accounts->id2name( $_definition->plugin_options['events_owner'] );
141 148
 				echo "Attension: All Events of '$lid' would be deleted!\n";
142 149
 			}
@@ -145,38 +152,63 @@  discard block
 block discarded – undo
145 152
 		$this->errors = array();
146 153
 		$this->results = array();
147 154
 
148
-		while ( $record = $import_csv->get_record() ) {
155
+		while ( $record = $import_csv->get_record() )
156
+		{
149 157
 
150 158
 			// don't import empty events
151
-			if( count( array_unique( $record ) ) < 2 ) continue;
159
+			if( count( array_unique( $record ) ) < 2 )
160
+			{
161
+				continue;
162
+			}
152 163
 
153
-			if ( $_definition->plugin_options['events_owner'] != -1 ) {
164
+			if ( $_definition->plugin_options['events_owner'] != -1 )
165
+			{
154 166
 				$record['owner'] = $_definition->plugin_options['events_owner'];
155
-			} else unset( $record['owner'] );
167
+			}
168
+			else {
169
+				unset( $record['owner'] );
170
+			}
156 171
 
157
-			if ( $_definition->plugin_options['conditions'] ) {
158
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
159
-					switch ( $condition['type'] ) {
172
+			if ( $_definition->plugin_options['conditions'] )
173
+			{
174
+				foreach ( $_definition->plugin_options['conditions'] as $condition )
175
+				{
176
+					switch ( $condition['type'] )
177
+					{
160 178
 						// exists
161 179
 						case 'exists' :
162 180
 
163
-							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) ) {
181
+							if ( is_array( $event = $this->bocalupdate->read( $record['uid'], null, $this->is_admin ) ) )
182
+							{
164 183
 								// apply action to event matching this exists condition
165 184
 								$record['id'] = $event['id'];
166 185
 
167
-								if ( $_definition->plugin_options['update_cats'] == 'add' ) {
168
-									if ( !is_array( $event['cat_id'] ) ) $event['cat_id'] = explode( ',', $event['cat_id'] );
169
-									if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
186
+								if ( $_definition->plugin_options['update_cats'] == 'add' )
187
+								{
188
+									if ( !is_array( $event['cat_id'] ) )
189
+									{
190
+										$event['cat_id'] = explode( ',', $event['cat_id'] );
191
+									}
192
+									if ( !is_array( $record['cat_id'] ) )
193
+									{
194
+										$record['cat_id'] = explode( ',', $record['cat_id'] );
195
+									}
170 196
 									$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $event['cat_id'] ) ) );
171 197
 								}
172 198
 
173 199
 								// check if entry is modiefied
174 200
 								$event = array_intersect_key( $event, $record );
175 201
 								$diff = array_diff( $event, $record );
176
-								if( !empty( $diff ) ) $record['modified'] = time();
202
+								if( !empty( $diff ) )
203
+								{
204
+									$record['modified'] = time();
205
+								}
177 206
 
178 207
 								$action = $condition['true'];
179
-							} else $action = $condition['false'];
208
+							}
209
+							else {
210
+								$action = $condition['false'];
211
+							}
180 212
 
181 213
 							$this->action( $action['action'], $record );
182 214
 							break;
@@ -190,9 +222,14 @@  discard block
 block discarded – undo
190 222
 							throw new Exception('condition not supported!!!');
191 223
 							break;
192 224
 					}
193
-					if ($action['last']) break;
225
+					if ($action['last'])
226
+					{
227
+						break;
228
+					}
194 229
 				}
195
-			} else {
230
+			}
231
+			else
232
+			{
196 233
 				// unconditional insert
197 234
 				$this->action( 'insert', $record );
198 235
 			}
@@ -206,8 +243,10 @@  discard block
 block discarded – undo
206 243
 	 * @param array $_data event data for the action
207 244
 	 * @return bool success or not
208 245
 	 */
209
-	private function action ( $_action, $_data ) {
210
-		switch ( $_action ) {
246
+	private function action ( $_action, $_data )
247
+	{
248
+		switch ( $_action )
249
+		{
211 250
 			case 'none' :
212 251
 				return true;
213 252
 
@@ -217,32 +256,42 @@  discard block
 block discarded – undo
217 256
 				// paticipants handling
218 257
 				$participants = $_data['participants'] ? split( '[,;]', $_data['participants'] ) : array();
219 258
 				$_data['participants'] = array();
220
-				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 ) {
259
+				if ( $this->definition->plugin_options['owner_joins_event'] && $this->definition->plugin_options['events_owner'] > 0 )
260
+				{
221 261
 					$_data['participants'][$this->definition->plugin_options['events_owner']] = 'A';
222 262
 				}
223
-				foreach( $participants as $participant ) {
263
+				foreach( $participants as $participant )
264
+				{
224 265
 					list( $participant, $status ) = explode( '=', $participant );
225 266
 					$valid_staties = array('U'=>'U','u'=>'U','A'=>'A','a'=>'A','R'=>'R','r'=>'R','T'=>'T','t'=>'T');
226 267
 					$status = isset( $valid_staties[$status] ) ? $valid_staties[$status] : 'U';
227
-					if ( $participant && is_numeric($participant ) ) {
268
+					if ( $participant && is_numeric($participant ) )
269
+					{
228 270
 						$_data['participants'][$participant] = $status;
229 271
 					}
230 272
 				}
231 273
 				// no valid participants so far --> add the importing user/owner
232
-				if ( empty( $_data['participants'] ) ) {
274
+				if ( empty( $_data['participants'] ) )
275
+				{
233 276
 					$_data['participants'][$this->user] = 'A';
234 277
 				}
235 278
 
236 279
 				// are we serious?
237
-				if ( $this->dry_run ) {
280
+				if ( $this->dry_run )
281
+				{
238 282
 					print_r($_data);
239 283
 					$this->results[$_action]++;
240
-				} else {
284
+				}
285
+				else
286
+				{
241 287
 					$messages = array();
242 288
 					$result = $this->bocalupdate->update( $_data, true, !$_data['modified'], $this->is_admin, true, $messages);
243
-					if(!$result) {
289
+					if(!$result)
290
+					{
244 291
 						$this->errors = implode(',', $messages);
245
-					} else {
292
+					}
293
+					else
294
+					{
246 295
 						$this->results[$_action]++;
247 296
 					}
248 297
 					return $result;
@@ -257,7 +306,8 @@  discard block
 block discarded – undo
257 306
 	 *
258 307
 	 * @return string name
259 308
 	 */
260
-	public static function get_name() {
309
+	public static function get_name()
310
+	{
261 311
 		return lang('Calendar CSV export');
262 312
 	}
263 313
 
@@ -266,7 +316,8 @@  discard block
 block discarded – undo
266 316
 	 *
267 317
 	 * @return string descriprion
268 318
 	 */
269
-	public static function get_description() {
319
+	public static function get_description()
320
+	{
270 321
 		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.");
271 322
 	}
272 323
 
@@ -275,7 +326,8 @@  discard block
 block discarded – undo
275 326
 	 *
276 327
 	 * @return string suffix (comma seperated)
277 328
 	 */
278
-	public static function get_filesuffix() {
329
+	public static function get_filesuffix()
330
+	{
279 331
 		return 'csv';
280 332
 	}
281 333
 
@@ -291,7 +343,8 @@  discard block
 block discarded – undo
291 343
 	 * 		preserv		=> array,
292 344
 	 * )
293 345
 	 */
294
-	public function get_options_etpl() {
346
+	public function get_options_etpl()
347
+	{
295 348
 		// lets do it!
296 349
 	}
297 350
 
@@ -300,7 +353,8 @@  discard block
 block discarded – undo
300 353
 	 *
301 354
 	 * @return string etemplate name
302 355
 	 */
303
-	public function get_selectors_etpl() {
356
+	public function get_selectors_etpl()
357
+	{
304 358
 		// lets do it!
305 359
 	}
306 360
 
@@ -312,7 +366,8 @@  discard block
 block discarded – undo
312 366
         *       record_# => error message
313 367
         *       )
314 368
         */
315
-        public function get_errors() {
369
+        public function get_errors()
370
+        {
316 371
 		return $this->errors;
317 372
 	}
318 373
 
@@ -324,7 +379,8 @@  discard block
 block discarded – undo
324 379
         *       action => record count
325 380
         * )
326 381
         */
327
-        public function get_results() {
382
+        public function get_results()
383
+        {
328 384
 		return $this->results;
329 385
 	}
330 386
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
calendar/inc/class.calendar_bo.inc.php 5 patches
Doc Comments   +8 added lines, -13 removed lines patch added patch discarded remove patch
@@ -626,8 +626,8 @@  discard block
 block discarded – undo
626 626
 	 * or an ExecMethod callback with parameters $id,$event
627 627
 	 *
628 628
 	 * @param string $app
629
-	 * @param int|string $id
630
-	 * @return string
629
+	 * @param string $id
630
+	 * @return boolean
631 631
 	 */
632 632
 	static function integration_get_private($app,$id,$event)
633 633
 	{
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 	 * This methods operates in usertime, while $this->config['horizont'] is in servertime!
757 757
 	 *
758 758
 	 * @param array $event
759
-	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
759
+	 * @param integer $start =0 minimum start-time for new recurrences or !$start = since the start of the event
760 760
 	 */
761 761
 	function set_recurrences($event,$start=0)
762 762
 	{
@@ -976,10 +976,9 @@  discard block
 block discarded – undo
976 976
 	 * Recurrences get calculated by rrule iterator implemented in calendar_rrule class.
977 977
 	 *
978 978
 	 * @param array $event repeating event whos repetions should be inserted
979
-	 * @param mixed $start start-date
979
+	 * @param mixed $_start start-date
980 980
 	 * @param mixed $end end-date
981 981
 	 * @param array $events where the repetions get inserted
982
-	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
983 982
 	 */
984 983
 	function insert_all_recurrences($event,$_start,$end,&$events)
985 984
 	{
@@ -1133,7 +1132,7 @@  discard block
 block discarded – undo
1133 1132
 	 *	even if you have no general read-grant from that user.
1134 1133
 	 *
1135 1134
 	 * @param int $needed necessary ACL right: Acl::{READ|EDIT|DELETE}
1136
-	 * @param mixed $event event as array or the event-id or 0 for a general check
1135
+	 * @param integer $event event as array or the event-id or 0 for a general check
1137 1136
 	 * @param int $other uid to check (if event==0) or 0 to check against $this->user
1138 1137
 	 * @param string $date_format ='ts' date-format used for reading: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc
1139 1138
 	 * @param mixed $date_to_read =null date used for reading, internal param for the caching
@@ -1306,8 +1305,6 @@  discard block
 block discarded – undo
1306 1305
 	 * @param string $msg message with parameters/variables like lang(), eg. '%1'
1307 1306
 	 * @param boolean $backtrace =True include a function-backtrace, default True=On
1308 1307
 	 *	should only be set to False=Off, if your code ensures a call with backtrace=On was made before !!!
1309
-	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1310
-	 *	arrays get serialized with print_r() !
1311 1308
 	 */
1312 1309
 	static function debug_message($msg,$backtrace=True)
1313 1310
 	{
@@ -1370,7 +1367,7 @@  discard block
 block discarded – undo
1370 1367
 	 * Formats one or two dates (range) as long date (full monthname), optionaly with a time
1371 1368
 	 *
1372 1369
 	 * @param mixed $_first first date
1373
-	 * @param mixed $last =0 last date if != 0 (default)
1370
+	 * @param integer $last =0 last date if != 0 (default)
1374 1371
 	 * @param boolean $display_time =false should a time be displayed too
1375 1372
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1376 1373
 	 * @return string with formated date
@@ -1839,7 +1836,6 @@  discard block
 block discarded – undo
1839 1836
 	 *
1840 1837
 	 * Is called as hook to participate in the linking
1841 1838
 	 *
1842
-	 * @param int|array $entry int cal_id or array with event
1843 1839
 	 * @param string|boolean string with title, null if not found or false if not read perms
1844 1840
 	 */
1845 1841
 	function link_title($event)
@@ -2028,7 +2024,8 @@  discard block
 block discarded – undo
2028 2024
 	 *
2029 2025
 	 * @param array|int|string $entry array with event or cal_id, or cal_id:recur_date for virtual exceptions
2030 2026
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2031
-	 * @return string|boolean string with etag or false
2027
+	 * @param string $schedule_tag
2028
+	 * @return string string with etag or false
2032 2029
 	 */
2033 2030
 	function get_etag($entry, &$schedule_tag=null)
2034 2031
 	{
@@ -2068,7 +2065,6 @@  discard block
 block discarded – undo
2068 2065
 	 * Hook for infolog  to set some extra data and links
2069 2066
 	 *
2070 2067
 	 * @param array $data event-array preset by infolog plus
2071
-	 * @param int $data[id] cal_id
2072 2068
 	 * @return array with key => value pairs to set in new event and link_app/link_id arrays
2073 2069
 	 */
2074 2070
 	function infolog_set($data)
@@ -2120,7 +2116,6 @@  discard block
 block discarded – undo
2120 2116
 	 * Hook for timesheet to set some extra data and links
2121 2117
 	 *
2122 2118
 	 * @param array $data
2123
-	 * @param int $data[id] cal_id:recurrence
2124 2119
 	 * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
2125 2120
 	 */
2126 2121
 	function timesheet_set($data)
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1490,13 +1490,13 @@  discard block
 block discarded – undo
1490 1490
 	}
1491 1491
 
1492 1492
 	/**
1493
-	* Converts a participant into a (readable) user- or resource-name
1494
-	*
1495
-	* @param string|int $id id of user or resource
1496
-	* @param string|boolean $use_type =false type-letter or false
1497
-	* @param boolean $append_email =false append email (Name <email>)
1498
-	* @return string with name
1499
-	*/
1493
+	 * Converts a participant into a (readable) user- or resource-name
1494
+	 *
1495
+	 * @param string|int $id id of user or resource
1496
+	 * @param string|boolean $use_type =false type-letter or false
1497
+	 * @param boolean $append_email =false append email (Name <email>)
1498
+	 * @return string with name
1499
+	 */
1500 1500
 	function participant_name($id,$use_type=false, $append_email=false)
1501 1501
 	{
1502 1502
 		static $id2lid = array();
@@ -1525,13 +1525,13 @@  discard block
 block discarded – undo
1525 1525
 	}
1526 1526
 
1527 1527
 	/**
1528
-	* Converts participants array of an event into array of (readable) participant-names with status
1529
-	*
1530
-	* @param array $event event-data
1531
-	* @param boolean $long_status =false should the long/verbose status or an icon be use
1532
-	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533
-	* @return array with id / names with status pairs
1534
-	*/
1528
+	 * Converts participants array of an event into array of (readable) participant-names with status
1529
+	 *
1530
+	 * @param array $event event-data
1531
+	 * @param boolean $long_status =false should the long/verbose status or an icon be use
1532
+	 * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533
+	 * @return array with id / names with status pairs
1534
+	 */
1535 1535
 	function participants($event,$long_status=false,$show_group_invitation=false)
1536 1536
 	{
1537 1537
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
 	}
1602 1602
 
1603 1603
 	/**
1604
-	* Converts category string of an event into array of (readable) category-names
1605
-	*
1606
-	* @param string $category cat-id (multiple id's commaseparated)
1607
-	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608
-	* @return array with id / names
1609
-	*/
1604
+	 * Converts category string of an event into array of (readable) category-names
1605
+	 *
1606
+	 * @param string $category cat-id (multiple id's commaseparated)
1607
+	 * @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608
+	 * @return array with id / names
1609
+	 */
1610 1610
 	function categories($category,&$color)
1611 1611
 	{
1612 1612
 		static $id2cat = array();
Please login to merge, or discard this patch.
Spacing   +287 added lines, -288 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 
18 18
 if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
19 19
 {
20
-	define('ACL_TYPE_IDENTIFER','***ACL***');
20
+	define('ACL_TYPE_IDENTIFER', '***ACL***');
21 21
 }
22 22
 
23
-define('HOUR_s',60*60);
24
-define('DAY_s',24*HOUR_s);
25
-define('WEEK_s',7*DAY_s);
23
+define('HOUR_s', 60 * 60);
24
+define('DAY_s', 24 * HOUR_s);
25
+define('WEEK_s', 7 * DAY_s);
26 26
 
27 27
 /**
28 28
  * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *	4 = function-calls to exported conversation-functions like date2ts, date2array, ...
72 72
 	 *	5 = function-calls to private functions
73 73
 	 */
74
-	var $debug=false;
74
+	var $debug = false;
75 75
 
76 76
 	/**
77 77
 	 * @var int $now timestamp in server-time
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @var int $user nummerical id of the current user-id
103 103
 	 */
104
-	var $user=0;
104
+	var $user = 0;
105 105
 
106 106
 	/**
107 107
 	 * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs
108 108
 	 */
109
-	var $grants=array();
109
+	var $grants = array();
110 110
 
111 111
 	/**
112 112
 	 * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor
@@ -216,15 +216,15 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	function __construct()
218 218
 	{
219
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
219
+		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True);
220 220
 
221 221
 		$this->so = new calendar_so();
222 222
 
223
-		$this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common'];
224
-		$this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar'];
223
+		$this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common'];
224
+		$this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar'];
225 225
 
226 226
 		$this->now = time();
227
-		$this->now_su = Api\DateTime::server2user($this->now,'ts');
227
+		$this->now_su = Api\DateTime::server2user($this->now, 'ts');
228 228
 
229 229
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
230 230
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		if (!is_array($this->resources = Api\Cache::getSession('calendar', 'resources')))
234 234
 		{
235 235
 			$this->resources = array();
236
-			foreach(Api\Hooks::process('calendar_resources') as $app => $data)
236
+			foreach (Api\Hooks::process('calendar_resources') as $app => $data)
237 237
 			{
238 238
 				if ($data && $data['type'])
239 239
 				{
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 		}
254 254
 		//error_log(__METHOD__ . " registered resources=". array2string($this->resources));
255 255
 
256
-		$this->config = Api\Config::read('calendar');	// only used for horizont, regular calendar Api\Config is under phpgwapi
256
+		$this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar Api\Config is under phpgwapi
257 257
 		$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
258 258
 
259
-		$this->categories = new Api\Categories($this->user,'calendar');
259
+		$this->categories = new Api\Categories($this->user, 'calendar');
260 260
 
261 261
 		$this->customfields = Api\Storage\Customfields::get('calendar');
262 262
 
263
-		foreach($this->alarms as $secs => &$label)
263
+		foreach ($this->alarms as $secs => &$label)
264 264
 		{
265 265
 			$label = self::secs2label($secs);
266 266
 		}
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 	{
277 277
 		if ($secs <= 3600)
278 278
 		{
279
-			$label = lang('%1 minutes', $secs/60);
279
+			$label = lang('%1 minutes', $secs / 60);
280 280
 		}
281
-		elseif($secs <= 86400)
281
+		elseif ($secs <= 86400)
282 282
 		{
283
-			$label = lang('%1 hours', $secs/3600);
283
+			$label = lang('%1 hours', $secs / 3600);
284 284
 		}
285 285
 		else
286 286
 		{
287
-			$label = lang('%1 days', $secs/86400);
287
+			$label = lang('%1 days', $secs / 86400);
288 288
 		}
289 289
 		return $label;
290 290
 	}
@@ -300,12 +300,12 @@  discard block
 block discarded – undo
300 300
 		if (!$ids) return null;
301 301
 
302 302
 		$data = array();
303
-		foreach((array)$ids as $id)
303
+		foreach ((array)$ids as $id)
304 304
 		{
305 305
 			$email = $id;
306 306
 			$name = '';
307 307
 			$matches = null;
308
-			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches))
308
+			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches))
309 309
 			{
310 310
 				$name = $matches[1];
311 311
 				$email = $matches[2];
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 	function enum_groups(&$event)
331 331
 	{
332 332
 		$added = 0;
333
-		foreach(array_keys($event['participants']) as $uid)
333
+		foreach (array_keys($event['participants']) as $uid)
334 334
 		{
335 335
 			if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' &&
336 336
 				($members = $GLOBALS['egw']->accounts->members($uid, true)))
337 337
 			{
338
-				foreach($members as $member)
338
+				foreach ($members as $member)
339 339
 				{
340 340
 					if (!isset($event['participants'][$member]))
341 341
 					{
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	 * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search
358 358
 	 * @return array of user-ids
359 359
 	 */
360
-	private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true)
360
+	private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true)
361 361
 	{
362 362
 		if (!is_array($_users))
363 363
 		{
@@ -365,19 +365,19 @@  discard block
 block discarded – undo
365 365
 		}
366 366
 		// only query calendars of users, we have READ-grants from
367 367
 		$users = array();
368
-		foreach($_users as $user)
368
+		foreach ($_users as $user)
369 369
 		{
370 370
 			$user = trim($user);
371
-			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
371
+			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $user))
372 372
 			{
373
-				if ($user && !in_array($user,$users))	// already added?
373
+				if ($user && !in_array($user, $users))	// already added?
374 374
 				{
375 375
 					$users[] = $user;
376 376
 				}
377 377
 			}
378 378
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
379 379
 			{
380
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
380
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
381 381
 			}
382 382
 			// the further code is only for real users
383 383
 			if (!is_numeric($user)) continue;
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
 				$members = $GLOBALS['egw']->accounts->members($user, true);
391 391
 				if (is_array($members))
392 392
 				{
393
-					foreach($members as $member)
393
+					foreach ($members as $member)
394 394
 					{
395 395
 						// use only members which gave the user a read-grant
396 396
 						if (!in_array($member, $users) &&
397
-							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy?self::ACL_FREEBUSY:0),0,$member)))
397
+							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $member)))
398 398
 						{
399 399
 							$users[] = $member;
400 400
 						}
@@ -406,9 +406,9 @@  discard block
 block discarded – undo
406 406
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
407 407
 				if (is_array($memberships))
408 408
 				{
409
-					foreach($memberships as $group)
409
+					foreach ($memberships as $group)
410 410
 					{
411
-						if (!in_array($group,$users))
411
+						if (!in_array($group, $users))
412 412
 						{
413 413
 							$users[] = $group;
414 414
 						}
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
 	 * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param)
450 450
 	 *	or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given
451 451
 	 */
452
-	function &search($params,$sql_filter=null)
452
+	function &search($params, $sql_filter = null)
453 453
 	{
454 454
 		$params_in = $params;
455 455
 
456
-		$params['sql_filter'] = $sql_filter;	// dont allow to set it via UI or xmlrpc
456
+		$params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc
457 457
 
458 458
 		// check if any resource wants to hook into
459
-		foreach($this->resources as $data)
459
+		foreach ($this->resources as $data)
460 460
 		{
461 461
 			if (isset($data['search_filter']))
462 462
 			{
463
-				$params = ExecMethod($data['search_filter'],$params);
463
+				$params = ExecMethod($data['search_filter'], $params);
464 464
 			}
465 465
 		}
466 466
 
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
 		if (!empty($params['query']))
479 479
 		{
480 480
 			$params['private_grants'] = array();
481
-			foreach($this->grants as $user => $rights)
481
+			foreach ($this->grants as $user => $rights)
482 482
 			{
483
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
483
+				if ($rights&Acl::PRIVAT) $params['private_grants'][] = $user;
484 484
 			}
485 485
 		}
486 486
 
@@ -506,49 +506,49 @@  discard block
 block discarded – undo
506 506
 		$params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring'];
507 507
 		$cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0;
508 508
 		$filter = isset($params['filter']) ? $params['filter'] : 'all';
509
-		$offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false;
509
+		$offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false;
510 510
 		// socal::search() returns rejected group-invitations, as only the user not also the group is rejected
511 511
 		// as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed
512 512
 		$users_in = (array)$params_in['users'];
513
-		$remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) &&
513
+		$remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) &&
514 514
 			count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null;
515 515
 		//error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user));
516 516
 
517 517
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'search'))
518 518
 		{
519 519
 			$this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)',
520
-				True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']);
520
+				True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']);
521 521
 		}
522 522
 		// date2ts(,true) converts to server time, db2data converts again to user-time
523
-		$events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null,
524
-			$users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user);
523
+		$events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null,
524
+			$users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user);
525 525
 
526 526
 		if (isset($params['cols']))
527 527
 		{
528 528
 			return $events;
529 529
 		}
530 530
 		$this->total = $this->so->total;
531
-		$this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts');
531
+		$this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts');
532 532
 
533 533
 		//echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n";
534
-		foreach($events as $id => $event)
534
+		foreach ($events as $id => $event)
535 535
 		{
536 536
 			if ($params['enum_groups'] && $this->enum_groups($event))
537 537
 			{
538 538
 				$events[$id] = $event;
539 539
 			}
540 540
 			$matches = null;
541
-			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches))
541
+			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches))
542 542
 			{
543
-				$is_private = self::integration_get_private($matches[1],$matches[2],$event);
543
+				$is_private = self::integration_get_private($matches[1], $matches[2], $event);
544 544
 			}
545 545
 			else
546 546
 			{
547
-				$is_private = !$this->check_perms(Acl::READ,$event);
547
+				$is_private = !$this->check_perms(Acl::READ, $event);
548 548
 			}
549 549
 			if ($is_private || (!$event['public'] && $filter == 'hideprivate'))
550 550
 			{
551
-				$this->clear_private_infos($events[$id],$users);
551
+				$this->clear_private_infos($events[$id], $users);
552 552
 			}
553 553
 		}
554 554
 
@@ -556,18 +556,18 @@  discard block
 block discarded – undo
556 556
 		{
557 557
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
558 558
 			{
559
-				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
559
+				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events);
560 560
 			}
561 561
 			// create empty entries for each day in the reported time
562
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
562
+			for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
563 563
 			{
564 564
 				$daysEvents[$this->date2string($ts)] = array();
565 565
 			}
566
-			foreach($events as $k => $event)
566
+			foreach ($events as $k => $event)
567 567
 			{
568
-				$e_start = max($this->date2ts($event['start']),$start);
568
+				$e_start = max($this->date2ts($event['start']), $start);
569 569
 				// $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59
570
-				$e_end   = min($this->date2ts($event['end'])-1,$end);
570
+				$e_end   = min($this->date2ts($event['end']) - 1, $end);
571 571
 
572 572
 				// add event to each day in the reported time
573 573
 				$ts = $e_start;
@@ -576,23 +576,23 @@  discard block
 block discarded – undo
576 576
 				$ymd = null;
577 577
 				while ($ts <= $e_end)
578 578
 				{
579
-					$daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k];
580
-					$ts = strtotime("+1 day",$ts);
579
+					$daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k];
580
+					$ts = strtotime("+1 day", $ts);
581 581
 				}
582 582
 				if ($ymd != ($last = $this->date2string($e_end)))
583 583
 				{
584
-					$daysEvents[$last][] =& $events[$k];
584
+					$daysEvents[$last][] = & $events[$k];
585 585
 				}
586 586
 			}
587
-			$events =& $daysEvents;
587
+			$events = & $daysEvents;
588 588
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
589 589
 			{
590
-				$this->debug_message('socalendar::search daywise events=%1',False,$events);
590
+				$this->debug_message('socalendar::search daywise events=%1', False, $events);
591 591
 			}
592 592
 		}
593 593
 		if ($this->debug && ($this->debug > 0 || $this->debug == 'search'))
594 594
 		{
595
-			$this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events);
595
+			$this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events);
596 596
 		}
597 597
 		//error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace());
598 598
 		return $events;
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 	 * @param string $part
606 606
 	 * @return array
607 607
 	 */
608
-	static function integration_get_data($app,$part=null)
608
+	static function integration_get_data($app, $part = null)
609 609
 	{
610
-		static $integration_data=null;
610
+		static $integration_data = null;
611 611
 
612 612
 		if (!isset($integration_data))
613 613
 		{
@@ -629,14 +629,14 @@  discard block
 block discarded – undo
629 629
 	 * @param int|string $id
630 630
 	 * @return string
631 631
 	 */
632
-	static function integration_get_private($app,$id,$event)
632
+	static function integration_get_private($app, $id, $event)
633 633
 	{
634
-		$app_data = self::integration_get_data($app,'is_private');
634
+		$app_data = self::integration_get_data($app, 'is_private');
635 635
 
636 636
 		// no method, fall back to link title
637 637
 		if (is_null($app_data))
638 638
 		{
639
-			$is_private = !Link::title($app,$id);
639
+			$is_private = !Link::title($app, $id);
640 640
 		}
641 641
 		// boolean value to make all events of $app public (false) or private (true)
642 642
 		elseif (is_bool($app_data))
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 		}
646 646
 		else
647 647
 		{
648
-			$is_private = (bool)ExecMethod2($app_data,$id,$event);
648
+			$is_private = (bool)ExecMethod2($app_data, $id, $event);
649 649
 		}
650 650
 		//echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n";
651 651
 		return $is_private;
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 	 * @param array &$event
660 660
 	 * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar
661 661
 	 */
662
-	function clear_private_infos(&$event,$allowed_participants = array())
662
+	function clear_private_infos(&$event, $allowed_participants = array())
663 663
 	{
664 664
 		if ($event == false) return;
665 665
 		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
@@ -675,19 +675,19 @@  discard block
 block discarded – undo
675 675
 			'owner'		=> $event['owner'],
676 676
 			'uid'	=> $event['uid'],
677 677
 			'etag'	=> $event['etag'],
678
-			'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)),
678
+			'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)),
679 679
 			'public'=> 0,
680
-			'category' => $event['category'],	// category is visible anyway, eg. by using planner by cat
680
+			'category' => $event['category'], // category is visible anyway, eg. by using planner by cat
681 681
 			'non_blocking' => $event['non_blocking'],
682 682
 			'caldav_name' => $event['caldav_name'],
683 683
 		// we need full recurrence information, as they are relevant free/busy information
684
-		)+($event['recur_type'] ? array(
684
+		) + ($event['recur_type'] ? array(
685 685
 			'recur_type'     => $event['recur_type'],
686 686
 			'recur_interval' => $event['recur_interval'],
687 687
 			'recur_data'     => $event['recur_data'],
688 688
 			'recur_enddate'  => $event['recur_enddate'],
689 689
 			'recur_exception'=> $event['recur_exception'],
690
-		):array(
690
+		) : array(
691 691
 			'reference'      => $event['reference'],
692 692
 			'recurrence'     => $event['recurrence'],
693 693
 		));
@@ -701,15 +701,15 @@  discard block
 block discarded – undo
701 701
 	 */
702 702
 	function check_move_horizont($_new_horizont)
703 703
 	{
704
-		if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont')
704
+		if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont')
705 705
 		{
706
-			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']);
706
+			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']);
707 707
 		}
708
-		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
708
+		$new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates
709 709
 
710 710
 		if ($new_horizont <= $this->config['horizont'])	// no move necessary
711 711
 		{
712
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
712
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do', true, $new_horizont, (int)$this->config['horizont']);
713 713
 			return;
714 714
 		}
715 715
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
@@ -717,15 +717,15 @@  discard block
 block discarded – undo
717 717
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
718 718
 		}
719 719
 		if (empty($maxdays)) $maxdays = 1000; // old default
720
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
720
+		if ($new_horizont > time() + $maxdays * DAY_s)		// some user tries to "look" more then the maximum number of days in the future
721 721
 		{
722
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
723
-			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
722
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it', true, $new_horizont, (int)$this->config['horizont'], $maxdays);
723
+			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont, true), $maxdays);
724 724
 			return;
725 725
 		}
726
-		if ($new_horizont < time()+31*DAY_s)
726
+		if ($new_horizont < time() + 31 * DAY_s)
727 727
 		{
728
-			$new_horizont = time()+31*DAY_s;
728
+			$new_horizont = time() + 31 * DAY_s;
729 729
 		}
730 730
 		$old_horizont = $this->config['horizont'];
731 731
 		$this->config['horizont'] = $new_horizont;
@@ -733,21 +733,21 @@  discard block
 block discarded – undo
733 733
 		// create further recurrences for all recurring and not yet (at the old horizont) ended events
734 734
 		if (($recuring = $this->so->unfinished_recuring($old_horizont)))
735 735
 		{
736
-			@set_time_limit(0);	// disable time-limit, in case it takes longer to calculate the recurrences
737
-			foreach($this->read(array_keys($recuring)) as $cal_id => $event)
736
+			@set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences
737
+			foreach ($this->read(array_keys($recuring)) as $cal_id => $event)
738 738
 			{
739 739
 				if ($this->debug == 'check_move_horizont')
740 740
 				{
741
-					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont);
741
+					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont);
742 742
 				}
743 743
 				// insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past
744
-				$this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1));	// set_recurences operates in user-time!
744
+				$this->set_recurrences($event, Api\DateTime::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time!
745 745
 			}
746 746
 		}
747 747
 		// update the horizont
748
-		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
748
+		Api\Config::save_value('horizont', $this->config['horizont'], 'calendar');
749 749
 
750
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
750
+		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting', true, $new_horizont, (int)$this->config['horizont']);
751 751
 	}
752 752
 
753 753
 	/**
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 	 * @param array $event
759 759
 	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
760 760
 	 */
761
-	function set_recurrences($event,$start=0)
761
+	function set_recurrences($event, $start = 0)
762 762
 	{
763
-		if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
763
+		if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
764 764
 		{
765
-			$this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start);
765
+			$this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start);
766 766
 		}
767 767
 		// check if the caller gave us enough information and if not read it from the DB
768 768
 		if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end']))
@@ -781,26 +781,26 @@  discard block
 block discarded – undo
781 781
 		if (!$start) $start = $event['start'];
782 782
 
783 783
 		$events = array();
784
-		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
784
+		$this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events);
785 785
 
786 786
 		$exceptions = array();
787
-		foreach((array)$event['recur_exception'] as $exception)
787
+		foreach ((array)$event['recur_exception'] as $exception)
788 788
 		{
789
-			$exceptions[] = Api\DateTime::to($exception, true);	// true = date
789
+			$exceptions[] = Api\DateTime::to($exception, true); // true = date
790 790
 		}
791
-		foreach($events as $event)
791
+		foreach ($events as $event)
792 792
 		{
793 793
 			$is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions);
794
-			$start = $this->date2ts($event['start'],true);
794
+			$start = $this->date2ts($event['start'], true);
795 795
 			if ($event['whole_day'])
796 796
 			{
797 797
 				$time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone));
798 798
 				$time->setTime(23, 59, 59);
799
-				$end = $this->date2ts($time,true);
799
+				$end = $this->date2ts($time, true);
800 800
 			}
801 801
 			else
802 802
 			{
803
-				$end = $this->date2ts($event['end'],true);
803
+				$end = $this->date2ts($event['end'], true);
804 804
 			}
805 805
 			//error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception));
806 806
 			$this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception);
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 	 * @param array &$events array of event-arrays (reference)
817 817
 	 * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
818 818
 	 */
819
-	function db2data(&$events,$date_format='ts')
819
+	function db2data(&$events, $date_format = 'ts')
820 820
 	{
821 821
 		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
822 822
 		foreach ($events as &$event)
@@ -829,65 +829,65 @@  discard block
 block discarded – undo
829 829
 			// database returns timestamps as string, convert them to integer
830 830
 			// to avoid misinterpretation by Api\DateTime as Ymd string
831 831
 			// (this will fail on 32bit systems for times > 2038!)
832
-			$event['start'] = (int)$event['start'];	// this is for isWholeDay(), which also calls Api\DateTime
832
+			$event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime
833 833
 			$event['end'] = (int)$event['end'];
834 834
 			$event['whole_day'] = self::isWholeDay($event);
835 835
 			if ($event['whole_day'] && $date_format != 'server')
836 836
 			{
837 837
 				// Adjust dates to user TZ
838
-				$stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
838
+				$stime = & $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
839 839
 				$event['start'] = Api\DateTime::to($stime, $date_format);
840
-				$time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
840
+				$time = & $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
841 841
 				$time->setTime(23, 59, 59);
842 842
 				$event['end'] = Api\DateTime::to($time, $date_format);
843 843
 				if (!empty($event['recurrence']))
844 844
 				{
845
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
845
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
846 846
 					$event['recurrence'] = Api\DateTime::to($time, $date_format);
847 847
 				}
848 848
 				if (!empty($event['recur_enddate']))
849 849
 				{
850
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
850
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
851 851
 					$time->setTime(23, 59, 59);
852 852
 					$event['recur_enddate'] = Api\DateTime::to($time, $date_format);
853 853
 				}
854
-				$timestamps = array('modified','created');
854
+				$timestamps = array('modified', 'created');
855 855
 			}
856 856
 			else
857 857
 			{
858
-				$timestamps = array('start','end','modified','created','recur_enddate','recurrence','recur_date');
858
+				$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence', 'recur_date');
859 859
 			}
860 860
 			// we convert here from the server-time timestamps to user-time and (optional) to a different date-format!
861 861
 			foreach ($timestamps as $ts)
862 862
 			{
863 863
 				if (!empty($event[$ts]))
864 864
 				{
865
-					$event[$ts] = $this->date2usertime((int)$event[$ts],$date_format);
865
+					$event[$ts] = $this->date2usertime((int)$event[$ts], $date_format);
866 866
 				}
867 867
 			}
868 868
 			// same with the recur exceptions
869 869
 			if (isset($event['recur_exception']) && is_array($event['recur_exception']))
870 870
 			{
871
-				foreach($event['recur_exception'] as &$date)
871
+				foreach ($event['recur_exception'] as &$date)
872 872
 				{
873 873
 					if ($event['whole_day'] && $date_format != 'server')
874 874
 					{
875 875
 						// Adjust dates to user TZ
876
-						$time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
876
+						$time = & $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
877 877
 						$date = Api\DateTime::to($time, $date_format);
878 878
 					}
879 879
 					else
880 880
 					{
881
-						$date = $this->date2usertime((int)$date,$date_format);
881
+						$date = $this->date2usertime((int)$date, $date_format);
882 882
 					}
883 883
 				}
884 884
 			}
885 885
 			// same with the alarms
886 886
 			if (isset($event['alarm']) && is_array($event['alarm']))
887 887
 			{
888
-				foreach($event['alarm'] as &$alarm)
888
+				foreach ($event['alarm'] as &$alarm)
889 889
 				{
890
-					$alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format);
890
+					$alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format);
891 891
 				}
892 892
 			}
893 893
 		}
@@ -900,11 +900,11 @@  discard block
 block discarded – undo
900 900
 	 * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
901 901
 	 * @return mixed depending of $date_format
902 902
 	 */
903
-	function date2usertime($ts,$date_format='ts')
903
+	function date2usertime($ts, $date_format = 'ts')
904 904
 	{
905 905
 		if (empty($ts) || $date_format == 'server') return $ts;
906 906
 
907
-		return Api\DateTime::server2user($ts,$date_format);
907
+		return Api\DateTime::server2user($ts, $date_format);
908 908
 	}
909 909
 
910 910
 	/**
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 	 * 	but call clear_private_infos() with the given users
919 919
 	 * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found
920 920
 	 */
921
-	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
921
+	function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null)
922 922
 	{
923 923
 		if (!$ids) return false;
924 924
 
@@ -927,21 +927,21 @@  discard block
 block discarded – undo
927 927
 		$return = null;
928 928
 
929 929
 		$check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ;
930
-		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date)))
930
+		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date)))
931 931
 		{
932 932
 			if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids ||
933 933
 				self::$cached_event_date_format != $date_format ||
934 934
 				self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date)
935 935
 			{
936
-				$events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0);
936
+				$events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0);
937 937
 
938 938
 				if ($events)
939 939
 				{
940
-					$this->db2data($events,$date_format);
940
+					$this->db2data($events, $date_format);
941 941
 
942 942
 					if (is_array($ids))
943 943
 					{
944
-						$return =& $events;
944
+						$return = & $events;
945 945
 					}
946 946
 					else
947 947
 					{
@@ -957,13 +957,13 @@  discard block
 block discarded – undo
957 957
 				$return = self::$cached_event;
958 958
 			}
959 959
 		}
960
-		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return))
960
+		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ, $return))
961 961
 		{
962 962
 			$this->clear_private_infos($return, (array)$clear_private_infos_users);
963 963
 		}
964 964
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'read'))
965 965
 		{
966
-			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return);
966
+			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return);
967 967
 		}
968 968
 		return $return;
969 969
 	}
@@ -981,17 +981,17 @@  discard block
 block discarded – undo
981 981
 	 * @param array $events where the repetions get inserted
982 982
 	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
983 983
 	 */
984
-	function insert_all_recurrences($event,$_start,$end,&$events)
984
+	function insert_all_recurrences($event, $_start, $end, &$events)
985 985
 	{
986
-		if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
986
+		if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
987 987
 		{
988
-			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end);
988
+			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end);
989 989
 		}
990 990
 		$end_in = $end;
991 991
 
992 992
 		$start = $this->date2ts($_start);
993 993
 		$event_start_ts = $this->date2ts($event['start']);
994
-		$event_length = $this->date2ts($event['end']) - $event_start_ts;	// we use a constant event-length, NOT a constant end-time!
994
+		$event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time!
995 995
 
996 996
 		// if $end is before recur_enddate, use it instead
997 997
 		if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end))
@@ -1003,27 +1003,27 @@  discard block
 block discarded – undo
1003 1003
 		// unset exceptions, as we need to add them as recurrence too, but marked as exception
1004 1004
 		unset($event['recur_exception']);
1005 1005
 		// loop over all recurrences and insert them, if they are after $start
1006
-		$rrule = calendar_rrule::event2rrule($event, true);	// true = we operate in usertime, like the rest of calendar_bo
1007
-		foreach($rrule as $time)
1006
+		$rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo
1007
+		foreach ($rrule as $time)
1008 1008
 		{
1009
-			$time->setUser();	// $time is in timezone of event, convert it to usertime used here
1010
-			if (($ts = $this->date2ts($time)) < $start-$event_length)
1009
+			$time->setUser(); // $time is in timezone of event, convert it to usertime used here
1010
+			if (($ts = $this->date2ts($time)) < $start - $event_length)
1011 1011
 			{
1012 1012
 				//echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n";
1013
-				continue;	// to early or original event (returned by interator too)
1013
+				continue; // to early or original event (returned by interator too)
1014 1014
 			}
1015 1015
 
1016 1016
 			$ts_end = $ts + $event_length;
1017 1017
 			// adjust ts_end for whole day events in case it does not fit due to
1018 1018
 			// spans over summer/wintertime adjusted days
1019
-			if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1019
+			if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1020 1020
 				!($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59))
1021 1021
 			{
1022 1022
 				$arr_end['hour'] = 23;
1023 1023
 				$arr_end['minute'] = 59;
1024 1024
 				$arr_end['second'] = 59;
1025 1025
 				$ts_end_guess = $this->date2ts($arr_end);
1026
-				if($ts_end_guess - $ts_end > DAY_s/2)
1026
+				if ($ts_end_guess - $ts_end > DAY_s / 2)
1027 1027
 				{
1028 1028
 					$ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future
1029 1029
 				}
@@ -1037,11 +1037,11 @@  discard block
 block discarded – undo
1037 1037
 			$event['end'] = $ts_end;
1038 1038
 			$events[] = $event;
1039 1039
 		}
1040
-		if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1040
+		if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1041 1041
 		{
1042 1042
 			$event['start'] = $event_start_ts;
1043 1043
 			$event['end'] = $event_start_ts + $event_length;
1044
-			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events);
1044
+			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events);
1045 1045
 		}
1046 1046
 	}
1047 1047
 
@@ -1052,18 +1052,18 @@  discard block
 block discarded – undo
1052 1052
 	 * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd
1053 1053
 	 * @param int|string $date_ymd of the date of the event
1054 1054
 	 */
1055
-	function add_adjusted_event(&$events,$event,$date_ymd)
1055
+	function add_adjusted_event(&$events, $event, $date_ymd)
1056 1056
 	{
1057 1057
 		$event_in = $event;
1058 1058
 		// calculate the new start- and end-time
1059 1059
 		$length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']);
1060 1060
 		$event_start_arr = $this->date2array($event['start']);
1061 1061
 
1062
-		$date_arr = $this->date2array((string) $date_ymd);
1062
+		$date_arr = $this->date2array((string)$date_ymd);
1063 1063
 		$date_arr['hour'] = $event_start_arr['hour'];
1064 1064
 		$date_arr['minute'] = $event_start_arr['minute'];
1065 1065
 		$date_arr['second'] = $event_start_arr['second'];
1066
-		unset($date_arr['raw']);	// else date2ts would use it
1066
+		unset($date_arr['raw']); // else date2ts would use it
1067 1067
 		$event['start'] = $this->date2ts($date_arr);
1068 1068
 		$event['end'] = $event['start'] + $length_s;
1069 1069
 
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 
1072 1072
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event'))
1073 1073
 		{
1074
-			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event);
1074
+			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event);
1075 1075
 		}
1076 1076
 	}
1077 1077
 
@@ -1095,22 +1095,22 @@  discard block
 block discarded – undo
1095 1095
 			{
1096 1096
 				$info = array(
1097 1097
 					'res_id'    => $uid,
1098
-					'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'),
1099
-					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' .
1100
-					$GLOBALS['egw']->accounts->id2name($uid,'account_lastname')),
1098
+					'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'),
1099
+					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1100
+					$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')),
1101 1101
 					'type'  => $GLOBALS['egw']->accounts->get_type($uid),
1102 1102
 					'app'   => 'accounts',
1103 1103
 				);
1104 1104
 			}
1105 1105
 			else
1106 1106
 			{
1107
-				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false;
1107
+				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false;
1108 1108
 				if ($info)
1109 1109
 				{
1110 1110
 					$info['type'] = $uid[0];
1111 1111
 					if (!$info['email'] && $info['responsible'])
1112 1112
 					{
1113
-						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email');
1113
+						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email');
1114 1114
 					}
1115 1115
 					$info['app'] = $this->resources[$uid[0]]['app'];
1116 1116
 				}
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 		}
1120 1120
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info'))
1121 1121
 		{
1122
-			$this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]);
1122
+			$this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]);
1123 1123
 		}
1124 1124
 		return $res_info_cache[$uid];
1125 1125
 	}
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 	 * @param int $user =null for which user to check, default current user
1141 1141
 	 * @return boolean true permission granted, false for permission denied or null if event not found
1142 1142
 	 */
1143
-	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1143
+	function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null)
1144 1144
 	{
1145 1145
 		if (!$user) $user = $this->user;
1146 1146
 		if ($user == $this->user)
@@ -1149,13 +1149,13 @@  discard block
 block discarded – undo
1149 1149
 		}
1150 1150
 		else
1151 1151
 		{
1152
-			$grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user);
1152
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1153 1153
 		}
1154 1154
 
1155 1155
 		if ($other && !is_numeric($other))
1156 1156
 		{
1157 1157
 			$resource = $this->resource_info($other);
1158
-			return $needed & $resource['rights'];
1158
+			return $needed&$resource['rights'];
1159 1159
 		}
1160 1160
 		if (is_int($event) && $event == 0)
1161 1161
 		{
@@ -1165,15 +1165,15 @@  discard block
 block discarded – undo
1165 1165
 		{
1166 1166
 			if (!is_array($event))
1167 1167
 			{
1168
-				$event = $this->read($event,$date_to_read,true,$date_format);	// = no ACL check !!!
1168
+				$event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!!
1169 1169
 			}
1170 1170
 			if (!is_array($event))
1171 1171
 			{
1172 1172
 				if ($this->xmlrpc)
1173 1173
 				{
1174
-					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
1174
+					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']);
1175 1175
 				}
1176
-				return null;	// event not found
1176
+				return null; // event not found
1177 1177
 			}
1178 1178
 			$owner = $event['owner'];
1179 1179
 			$private = !$event['public'];
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 		$grant = $grants[$owner];
1182 1182
 
1183 1183
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1184
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1184
+		if ($grant&~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1185 1185
 
1186 1186
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1187 1187
 		{
@@ -1190,15 +1190,15 @@  discard block
 block discarded – undo
1190 1190
 			//
1191 1191
 			if ($event['participants'] && is_array($event['participants']))
1192 1192
 			{
1193
-				foreach(array_keys($event['participants']) as $uid)
1193
+				foreach (array_keys($event['participants']) as $uid)
1194 1194
 				{
1195
-					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true)))
1195
+					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true)))
1196 1196
 					{
1197 1197
 						// if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant
1198
-						$grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT;
1198
+						$grant |= self::ACL_FREEBUSY|Acl::READ|Acl::PRIVAT;
1199 1199
 						break;
1200 1200
 					}
1201
-					elseif ($grants[$uid] & Acl::READ)
1201
+					elseif ($grants[$uid]&Acl::READ)
1202 1202
 					{
1203 1203
 						// if we have a READ grant from a participant, we dont give an implicit privat grant too
1204 1204
 						$grant |= Acl::READ;
@@ -1217,12 +1217,12 @@  discard block
 block discarded – undo
1217 1217
 		}
1218 1218
 		if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD)
1219 1219
 		{
1220
-			$access = False;	// a group can't be the owner of an event
1220
+			$access = False; // a group can't be the owner of an event
1221 1221
 		}
1222 1222
 		else
1223 1223
 		{
1224
-			$access = $user == $owner || $grant & $needed
1225
-				&& ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT);
1224
+			$access = $user == $owner || $grant&$needed
1225
+				&& ($needed == self::ACL_FREEBUSY || !$private || $grant&Acl::PRIVAT);
1226 1226
 		}
1227 1227
 		// do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled
1228 1228
 		if ($access && $needed == Acl::DELETE && $event['deleted'] &&
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 		}
1234 1234
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms'))
1235 1235
 		{
1236
-			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access);
1236
+			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access);
1237 1237
 		}
1238 1238
 		//error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access));
1239 1239
 		return $access;
@@ -1248,9 +1248,9 @@  discard block
 block discarded – undo
1248 1248
 	 *	array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year'
1249 1249
 	 * @param boolean $user2server =False conversion between user- and server-time; default False == Off
1250 1250
 	 */
1251
-	static function date2ts($date,$user2server=False)
1251
+	static function date2ts($date, $user2server = False)
1252 1252
 	{
1253
-		return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts');
1253
+		return $user2server ? Api\DateTime::user2server($date, 'ts') : Api\DateTime::to($date, 'ts');
1254 1254
 	}
1255 1255
 
1256 1256
 	/**
@@ -1260,9 +1260,9 @@  discard block
 block discarded – undo
1260 1260
 	 * @param boolean $server2user conversation between user- and server-time default False == Off
1261 1261
 	 * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string)
1262 1262
 	 */
1263
-	static function date2array($date,$server2user=False)
1263
+	static function date2array($date, $server2user = False)
1264 1264
 	{
1265
-		return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array');
1265
+		return $server2user ? Api\DateTime::server2user($date, 'array') : Api\DateTime::to($date, 'array');
1266 1266
 	}
1267 1267
 
1268 1268
 	/**
@@ -1273,9 +1273,9 @@  discard block
 block discarded – undo
1273 1273
 	 * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100)
1274 1274
 	 * @return string date formatted according to $format
1275 1275
 	 */
1276
-	static function date2string($date,$server2user=False,$format='Ymd')
1276
+	static function date2string($date, $server2user = False, $format = 'Ymd')
1277 1277
 	{
1278
-		return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format);
1278
+		return $server2user ? Api\DateTime::server2user($date, $format) : Api\DateTime::to($date, $format);
1279 1279
 	}
1280 1280
 
1281 1281
 	/**
@@ -1285,9 +1285,9 @@  discard block
 block discarded – undo
1285 1285
 	 * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only
1286 1286
 	 * @return string the formated date (incl. time)
1287 1287
 	 */
1288
-	static function format_date($date,$format='')
1288
+	static function format_date($date, $format = '')
1289 1289
 	{
1290
-		return Api\DateTime::to($date,$format);
1290
+		return Api\DateTime::to($date, $format);
1291 1291
 	}
1292 1292
 
1293 1293
 	/**
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1310 1310
 	 *	arrays get serialized with print_r() !
1311 1311
 	 */
1312
-	static function debug_message($msg,$backtrace=True)
1312
+	static function debug_message($msg, $backtrace = True)
1313 1313
 	{
1314 1314
 		static $acl2string = array(
1315 1315
 			0               => 'ACL-UNKNOWN',
@@ -1320,22 +1320,22 @@  discard block
 block discarded – undo
1320 1320
 			Acl::PRIVAT => 'ACL_PRIVATE',
1321 1321
 			self::ACL_FREEBUSY => 'ACL_FREEBUSY',
1322 1322
 		);
1323
-		for($i = 2; $i < func_num_args(); ++$i)
1323
+		for ($i = 2; $i < func_num_args(); ++$i)
1324 1324
 		{
1325 1325
 			$param = func_get_arg($i);
1326 1326
 
1327 1327
 			if (is_null($param))
1328 1328
 			{
1329
-				$param='NULL';
1329
+				$param = 'NULL';
1330 1330
 			}
1331 1331
 			else
1332 1332
 			{
1333
-				switch(gettype($param))
1333
+				switch (gettype($param))
1334 1334
 				{
1335 1335
 					case 'string':
1336
-						if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER)
1336
+						if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER)
1337 1337
 						{
1338
-							$param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER));
1338
+							$param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER));
1339 1339
 							$param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)";
1340 1340
 						}
1341 1341
 						else
@@ -1357,11 +1357,11 @@  discard block
 block discarded – undo
1357 1357
 						$param = $param ? 'True' : 'False';
1358 1358
 						break;
1359 1359
 					case 'integer':
1360
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1360
+						if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)";
1361 1361
 						break;
1362 1362
 				}
1363 1363
 			}
1364
-			$msg = str_replace('%'.($i-1),$param,$msg);
1364
+			$msg = str_replace('%'.($i - 1), $param, $msg);
1365 1365
 		}
1366 1366
 		if ($backtrace) error_log(function_backtrace(1));
1367 1367
 	}
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1376 1376
 	 * @return string with formated date
1377 1377
 	 */
1378
-	function long_date($_first,$last=0,$display_time=false,$display_day=false)
1378
+	function long_date($_first, $last = 0, $display_time = false, $display_day = false)
1379 1379
 	{
1380 1380
 		$first = $this->date2array($_first);
1381 1381
 		if ($last)
@@ -1390,27 +1390,27 @@  discard block
 block discarded – undo
1390 1390
 
1391 1391
 		if ($display_day)
1392 1392
 		{
1393
-			$range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1393
+			$range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1394 1394
 		}
1395 1395
 		for ($i = 0; $i < 5; $i += 2)
1396 1396
 		{
1397
-			switch($datefmt[$i])
1397
+			switch ($datefmt[$i])
1398 1398
 			{
1399 1399
 				case 'd':
1400
-					$range .= $first['day'] . ($datefmt[1] == '.' ? '.' : '');
1400
+					$range .= $first['day'].($datefmt[1] == '.' ? '.' : '');
1401 1401
 					if ($first['month'] != $last['month'] || $first['year'] != $last['year'])
1402 1402
 					{
1403 1403
 						if (!$month_before_day)
1404 1404
 						{
1405
-							$range .= ' '.lang(strftime('%B',$first['raw']));
1405
+							$range .= ' '.lang(strftime('%B', $first['raw']));
1406 1406
 						}
1407 1407
 						if ($first['year'] != $last['year'] && $datefmt[0] != 'Y')
1408 1408
 						{
1409
-							$range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year'];
1409
+							$range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year'];
1410 1410
 						}
1411 1411
 						if ($display_time)
1412 1412
 						{
1413
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1413
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1414 1414
 						}
1415 1415
 						if (!$last)
1416 1416
 						{
@@ -1420,43 +1420,43 @@  discard block
 block discarded – undo
1420 1420
 
1421 1421
 						if ($first['year'] != $last['year'] && $datefmt[0] == 'Y')
1422 1422
 						{
1423
-							$range .= $last['year'] . ', ';
1423
+							$range .= $last['year'].', ';
1424 1424
 						}
1425 1425
 
1426 1426
 						if ($month_before_day)
1427 1427
 						{
1428
-							$range .= lang(strftime('%B',$last['raw']));
1428
+							$range .= lang(strftime('%B', $last['raw']));
1429 1429
 						}
1430 1430
 					}
1431 1431
 					else
1432 1432
 					{
1433 1433
 						if ($display_time)
1434 1434
 						{
1435
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1435
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1436 1436
 						}
1437 1437
 						$range .= ' - ';
1438 1438
 					}
1439
-					$range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : '');
1439
+					$range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : '');
1440 1440
 					break;
1441 1441
 				case 'm':
1442 1442
 				case 'M':
1443
-					$range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' ';
1443
+					$range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' ';
1444 1444
 					break;
1445 1445
 				case 'Y':
1446 1446
 					if ($datefmt[0] != 'm')
1447 1447
 					{
1448
-						$range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1448
+						$range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1449 1449
 					}
1450 1450
 					break;
1451 1451
 			}
1452 1452
 		}
1453 1453
 		if ($display_time && $last)
1454 1454
 		{
1455
-			$range .= ' '.adodb_date($timefmt,$last['raw']);
1455
+			$range .= ' '.adodb_date($timefmt, $last['raw']);
1456 1456
 		}
1457 1457
 		if ($datefmt[4] == 'Y' && $datefmt[0] == 'm')
1458 1458
 		{
1459
-			$range .= ', ' . $last['year'];
1459
+			$range .= ', '.$last['year'];
1460 1460
 		}
1461 1461
 		return $range;
1462 1462
 	}
@@ -1468,25 +1468,25 @@  discard block
 block discarded – undo
1468 1468
 	 * @param int $end_m end time in minutes since 0h
1469 1469
 	 * @param boolean $both =false display the end-time too, duration is always displayed
1470 1470
 	 */
1471
-	function timespan($start_m,$end_m,$both=false)
1471
+	function timespan($start_m, $end_m, $both = false)
1472 1472
 	{
1473 1473
 		$duration = $end_m - $start_m;
1474
-		if ($end_m == 24*60-1) ++$duration;
1475
-		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1474
+		if ($end_m == 24 * 60 - 1) ++$duration;
1475
+		$duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
1476 1476
 
1477
-		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1477
+		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d', $start_m / 60).sprintf('%02d', $start_m % 60).'00', false);
1478 1478
 
1479 1479
 		if ($both)	// end-time too
1480 1480
 		{
1481
-			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1481
+			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d', $end_m / 60).sprintf('%02d', $end_m % 60).'00', false);
1482 1482
 			// dont double am/pm if they are the same in both times
1483
-			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1483
+			if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2))
1484 1484
 			{
1485
-				$timespan = str_replace($t,substr($t,0,-3),$timespan);
1485
+				$timespan = str_replace($t, substr($t, 0, -3), $timespan);
1486 1486
 			}
1487 1487
 			$timespan .= ':';
1488 1488
 		}
1489
-		return $timespan . ' ' . $duration;
1489
+		return $timespan.' '.$duration;
1490 1490
 	}
1491 1491
 
1492 1492
 	/**
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
 	* @param boolean $append_email =false append email (Name <email>)
1498 1498
 	* @return string with name
1499 1499
 	*/
1500
-	function participant_name($id,$use_type=false, $append_email=false)
1500
+	function participant_name($id, $use_type = false, $append_email = false)
1501 1501
 	{
1502 1502
 		static $id2lid = array();
1503 1503
 		static $id2email = array();
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 			else
1519 1519
 			{
1520 1520
 				$id2lid[$id] = Api\Accounts::username($id);
1521
-				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
1521
+				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email');
1522 1522
 			}
1523 1523
 		}
1524 1524
 		return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
@@ -1532,37 +1532,37 @@  discard block
 block discarded – undo
1532 1532
 	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533 1533
 	* @return array with id / names with status pairs
1534 1534
 	*/
1535
-	function participants($event,$long_status=false,$show_group_invitation=false)
1535
+	function participants($event, $long_status = false, $show_group_invitation = false)
1536 1536
 	{
1537 1537
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
1538 1538
 		$names = array();
1539
-		foreach((array)$event['participants'] as $id => $status)
1539
+		foreach ((array)$event['participants'] as $id => $status)
1540 1540
 		{
1541 1541
 			if (!is_string($status)) continue;
1542 1542
 			$quantity = $role = null;
1543
-			calendar_so::split_status($status,$quantity,$role);
1543
+			calendar_so::split_status($status, $quantity, $role);
1544 1544
 
1545
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1545
+			if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation
1546 1546
 
1547 1547
 			$lang_status = lang($this->verbose_status[$status]);
1548 1548
 			if (!$long_status)
1549 1549
 			{
1550
-				switch($status[0])
1550
+				switch ($status[0])
1551 1551
 				{
1552 1552
 					case 'A':	// accepted
1553
-						$status = Api\Html::image('calendar','accepted',$lang_status);
1553
+						$status = Api\Html::image('calendar', 'accepted', $lang_status);
1554 1554
 						break;
1555 1555
 					case 'R':	// rejected
1556
-						$status = Api\Html::image('calendar','rejected',$lang_status);
1556
+						$status = Api\Html::image('calendar', 'rejected', $lang_status);
1557 1557
 						break;
1558 1558
 					case 'T':	// tentative
1559
-						$status = Api\Html::image('calendar','tentative',$lang_status);
1559
+						$status = Api\Html::image('calendar', 'tentative', $lang_status);
1560 1560
 						break;
1561 1561
 					case 'U':	// no response = unknown
1562
-						$status = Api\Html::image('calendar','needs-action',$lang_status);
1562
+						$status = Api\Html::image('calendar', 'needs-action', $lang_status);
1563 1563
 						break;
1564 1564
 					case 'D':	// delegated
1565
-						$status = Api\Html::image('calendar','forward',$lang_status);
1565
+						$status = Api\Html::image('calendar', 'forward', $lang_status);
1566 1566
 						break;
1567 1567
 					case 'G':	// group invitation
1568 1568
 						// Todo: Image, seems not to be used
@@ -1584,13 +1584,13 @@  discard block
 block discarded – undo
1584 1584
 					$role = lang($this->roles[$role]);
1585 1585
 				}
1586 1586
 				// allow to use cats as roles (beside regular iCal ones)
1587
-				elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0)
1587
+				elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0)
1588 1588
 				{
1589 1589
 					$role = $GLOBALS['egw']->categories->id2name($cat_id);
1590 1590
 				}
1591 1591
 				else
1592 1592
 				{
1593
-					$role = lang(str_replace('X-','',$role));
1593
+					$role = lang(str_replace('X-', '', $role));
1594 1594
 				}
1595 1595
 				$names[$id] .= ' '.$role;
1596 1596
 			}
@@ -1607,13 +1607,13 @@  discard block
 block discarded – undo
1607 1607
 	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608 1608
 	* @return array with id / names
1609 1609
 	*/
1610
-	function categories($category,&$color)
1610
+	function categories($category, &$color)
1611 1611
 	{
1612 1612
 		static $id2cat = array();
1613 1613
 		$cats = array();
1614 1614
 		$color = 0;
1615 1615
 
1616
-		foreach(explode(',',$category) as $cat_id)
1616
+		foreach (explode(',', $category) as $cat_id)
1617 1617
 		{
1618 1618
 			if (!$cat_id) continue;
1619 1619
 
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 			{
1629 1629
 				$color = $cat['data']['color'];
1630 1630
 			}
1631
-			elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1631
+			elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1632 1632
 			{
1633 1633
 				$color = $parts[1];
1634 1634
 			}
@@ -1640,12 +1640,12 @@  discard block
 block discarded – undo
1640 1640
 	/**
1641 1641
 	 *  This is called only by list_cals().  It was moved here to remove fatal error in php5 beta4
1642 1642
 	 */
1643
-	private static function _list_cals_add($id,&$users,&$groups)
1643
+	private static function _list_cals_add($id, &$users, &$groups)
1644 1644
 	{
1645 1645
 		$name = Api\Accounts::username($id);
1646 1646
 		if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id)))
1647 1647
 		{
1648
-			return;	// do not return no longer existing accounts which eg. still mentioned in acl
1648
+			return; // do not return no longer existing accounts which eg. still mentioned in acl
1649 1649
 		}
1650 1650
 		if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g')
1651 1651
 		{
@@ -1657,7 +1657,7 @@  discard block
 block discarded – undo
1657 1657
 		}
1658 1658
 		$arr[$id] = array(
1659 1659
 			'grantor' => $id,
1660
-			'value'   => ($type == 'g' ? 'g_' : '') . $id,
1660
+			'value'   => ($type == 'g' ? 'g_' : '').$id,
1661 1661
 			'name'    => $name,
1662 1662
 			'sname'	  => $egw_name
1663 1663
 		);
@@ -1679,26 +1679,26 @@  discard block
 block discarded – undo
1679 1679
 	 * @param int $user account_id of user to generate list for
1680 1680
 	 * @param array $grants =null calendar grants from user, or null to query them from acl class
1681 1681
 	 */
1682
-	public static function list_calendars($user, array $grants=null)
1682
+	public static function list_calendars($user, array $grants = null)
1683 1683
 	{
1684 1684
 		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1685 1685
 
1686 1686
 		$users = $groups = array();
1687
-		foreach(array_keys($grants) as $id)
1687
+		foreach (array_keys($grants) as $id)
1688 1688
 		{
1689
-			self::_list_cals_add($id,$users,$groups);
1689
+			self::_list_cals_add($id, $users, $groups);
1690 1690
 		}
1691 1691
 		if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true)))
1692 1692
 		{
1693
-			foreach($memberships as $group)
1693
+			foreach ($memberships as $group)
1694 1694
 			{
1695
-				self::_list_cals_add($group,$users,$groups);
1695
+				self::_list_cals_add($group, $users, $groups);
1696 1696
 
1697
-				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar')))
1697
+				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group, Acl::READ, 'calendar')))
1698 1698
 				{
1699
-					foreach($account_perms as $id)
1699
+					foreach ($account_perms as $id)
1700 1700
 					{
1701
-						self::_list_cals_add($id,$users,$groups);
1701
+						self::_list_cals_add($id, $users, $groups);
1702 1702
 					}
1703 1703
 				}
1704 1704
 			}
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
 		usort($users, array(__CLASS__, 'name_cmp'));
1707 1707
 		usort($groups, array(__CLASS__, 'name_cmp'));
1708 1708
 
1709
-		return array_merge($users, $groups);	// users first and then groups, both alphabeticaly
1709
+		return array_merge($users, $groups); // users first and then groups, both alphabeticaly
1710 1710
 	}
1711 1711
 
1712 1712
 	/**
@@ -1746,9 +1746,9 @@  discard block
 block discarded – undo
1746 1746
 	 *	month: numerical month
1747 1747
 	 *	occurence: numerical year or 0 for every year
1748 1748
 	 */
1749
-	function read_holidays($year=0)
1749
+	function read_holidays($year = 0)
1750 1750
 	{
1751
-		if (!$year) $year = (int) date('Y',$this->now_su);
1751
+		if (!$year) $year = (int)date('Y', $this->now_su);
1752 1752
 
1753 1753
 		if (!$this->cached_holidays)	// try reading the holidays from the session
1754 1754
 		{
@@ -1758,8 +1758,7 @@  discard block
 block discarded – undo
1758 1758
 		{
1759 1759
 			$this->cached_holidays[$year] = calendar_holidays::read(
1760 1760
 				!empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ?
1761
-				$GLOBALS['egw_info']['server']['ical_holiday_url'] :
1762
-				$GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1761
+				$GLOBALS['egw_info']['server']['ical_holiday_url'] : $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1763 1762
 
1764 1763
 			// search for birthdays
1765 1764
 			if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
@@ -1769,36 +1768,36 @@  discard block
 block discarded – undo
1769 1768
 					'n_family' => "!''",
1770 1769
 					'bday' => "!''",
1771 1770
 				);
1772
-				$bdays =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),
1773
-					'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter);
1771
+				$bdays = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'),
1772
+					'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter);
1774 1773
 				// search accounts too, if not stored in contacts repository
1775 1774
 				$extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) &&
1776 1775
 					!$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'];
1777
-				if ($extra_accounts_search && ($bdays2 =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),
1778
-					'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter+array('owner' => 0))))
1776
+				if ($extra_accounts_search && ($bdays2 = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'),
1777
+					'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter + array('owner' => 0))))
1779 1778
 				{
1780
-					$bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2);
1779
+					$bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2);
1781 1780
 				}
1782 1781
 				if ($bdays)
1783 1782
 				{
1784 1783
 					// sort by month and day only
1785
-					usort($bdays,create_function('$a,$b','return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];'));
1786
-					foreach($bdays as $pers)
1784
+					usort($bdays, create_function('$a,$b', 'return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];'));
1785
+					foreach ($bdays as $pers)
1787 1786
 					{
1788
-						if (empty($pers['bday']) || $pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00')
1787
+						if (empty($pers['bday']) || $pers['bday'] == '0000-00-00 0' || $pers['bday'] == '0000-00-00' || $pers['bday'] == '0.0.00')
1789 1788
 						{
1790 1789
 							//error_log(__METHOD__.__LINE__.' Skipping entry for invalid birthday:'.array2string($pers));
1791 1790
 							continue;
1792 1791
 						}
1793
-						list($y,$m,$d) = explode('-',$pers['bday']);
1794
-						if ($y > $year) continue; 	// not yet born
1795
-						$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
1792
+						list($y, $m, $d) = explode('-', $pers['bday']);
1793
+						if ($y > $year) continue; // not yet born
1794
+						$this->cached_holidays[$year][sprintf('%04d%02d%02d', $year, $m, $d)][] = array(
1796 1795
 							'day'       => $d,
1797 1796
 							'month'     => $m,
1798 1797
 							'occurence' => 0,
1799 1798
 							'name'      => lang('Birthday').' '.($pers['n_given'] ? $pers['n_given'] : $pers['n_prefix']).' '.$pers['n_middle'].' '.
1800 1799
 								$pers['n_family'].($y && !$GLOBALS['egw_info']['server']['hide_birthdays'] ? ' ('.$y.')' : ''),
1801
-							'birthyear' => $y,	// this can be used to identify birthdays from holidays
1800
+							'birthyear' => $y, // this can be used to identify birthdays from holidays
1802 1801
 						);
1803 1802
 					}
1804 1803
 				}
@@ -1806,9 +1805,9 @@  discard block
 block discarded – undo
1806 1805
 			// store holidays and birthdays in the session
1807 1806
 			Api\Cache::setSession('calendar', 'holidays', $this->cached_holidays);
1808 1807
 		}
1809
-		if ((int) $this->debug >= 2 || $this->debug == 'read_holidays')
1808
+		if ((int)$this->debug >= 2 || $this->debug == 'read_holidays')
1810 1809
 		{
1811
-			$this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$this->cached_holidays[$year]);
1810
+			$this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $this->cached_holidays[$year]);
1812 1811
 		}
1813 1812
 		return $this->cached_holidays[$year];
1814 1813
 	}
@@ -1819,10 +1818,10 @@  discard block
 block discarded – undo
1819 1818
 	 * @param type $event
1820 1819
 	 * @return array array of selected calendar fields
1821 1820
 	 */
1822
-	public static function get_link_options ($event = array())
1821
+	public static function get_link_options($event = array())
1823 1822
 	{
1824
-		unset($event);	// not used, but required by function signature
1825
-		$options = array (
1823
+		unset($event); // not used, but required by function signature
1824
+		$options = array(
1826 1825
 			'end' => lang('End date'),
1827 1826
 			'id' => lang('ID'),
1828 1827
 			'owner' => lang('Event owner'),
@@ -1849,7 +1848,7 @@  discard block
 block discarded – undo
1849 1848
 			list($id, $recur) = explode('-', $event, 2);
1850 1849
 			$event = $this->read($id, $recur);
1851 1850
 		}
1852
-		else if (!is_array($event) && (int) $event > 0)
1851
+		else if (!is_array($event) && (int)$event > 0)
1853 1852
 		{
1854 1853
 			$event = $this->read($event);
1855 1854
 		}
@@ -1857,7 +1856,7 @@  discard block
 block discarded – undo
1857 1856
 		{
1858 1857
 			return $event;
1859 1858
 		}
1860
-		$type = explode(',',$this->cal_prefs['link_title']);
1859
+		$type = explode(',', $this->cal_prefs['link_title']);
1861 1860
 		if (is_array($type))
1862 1861
 		{
1863 1862
 			foreach ($type as &$val)
@@ -1883,10 +1882,10 @@  discard block
 block discarded – undo
1883 1882
 						$extra_fields [] = $event[$val];
1884 1883
 				}
1885 1884
 			}
1886
-			$str_fields = implode(', ',$extra_fields);
1887
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
1885
+			$str_fields = implode(', ', $extra_fields);
1886
+			if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : '');
1888 1887
 		}
1889
-		return $this->format_date($event['start']) . ': ' . $event['title'];
1888
+		return $this->format_date($event['start']).': '.$event['title'];
1890 1889
 	}
1891 1890
 
1892 1891
 	/**
@@ -1905,10 +1904,10 @@  discard block
 block discarded – undo
1905 1904
 			'offset' =>	$options['start'],
1906 1905
 			'order' => 'cal_start DESC',
1907 1906
 		);
1908
-		if($options['num_rows']) {
1907
+		if ($options['num_rows']) {
1909 1908
 			$query['num_rows'] = $options['num_rows'];
1910 1909
 		}
1911
-		foreach((array) $this->search($query) as $event)
1910
+		foreach ((array)$this->search($query) as $event)
1912 1911
 		{
1913 1912
 			$result[$event['id']] = $this->link_title($event);
1914 1913
 		}
@@ -1925,11 +1924,11 @@  discard block
 block discarded – undo
1925 1924
 	 * @param int $user =null for which user to check, default current user
1926 1925
 	 * @return boolean true if access is granted or false otherwise
1927 1926
 	 */
1928
-	function file_access($id,$check,$rel_path,$user=null)
1927
+	function file_access($id, $check, $rel_path, $user = null)
1929 1928
 	{
1930
-		unset($rel_path);	// not used, but required by function signature
1929
+		unset($rel_path); // not used, but required by function signature
1931 1930
 
1932
-		return $this->check_perms($check,$id,0,'ts',null,$user);
1931
+		return $this->check_perms($check, $id, 0, 'ts', null, $user);
1933 1932
 	}
1934 1933
 
1935 1934
 	/**
@@ -1945,36 +1944,36 @@  discard block
 block discarded – undo
1945 1944
 		}
1946 1945
 		Api\Cache::setSession('calendar', 'default_prefs_set', 'set');
1947 1946
 
1948
-		$default_prefs =& $GLOBALS['egw']->preferences->default['calendar'];
1949
-		$forced_prefs  =& $GLOBALS['egw']->preferences->forced['calendar'];
1947
+		$default_prefs = & $GLOBALS['egw']->preferences->default['calendar'];
1948
+		$forced_prefs  = & $GLOBALS['egw']->preferences->forced['calendar'];
1950 1949
 
1951
-		$subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n";
1950
+		$subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n";
1952 1951
 		$values = array(
1953
-			'notifyAdded'     => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'),
1954
-			'notifyCanceled'  => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'),
1955
-			'notifyModified'  => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'),
1956
-			'notifyDisinvited'=> $subject . lang ('You have been disinvited from the meeting at %1','$$startdate$$'),
1957
-			'notifyResponse'  => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
1958
-			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'),
1952
+			'notifyAdded'     => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'),
1953
+			'notifyCanceled'  => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'),
1954
+			'notifyModified'  => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'),
1955
+			'notifyDisinvited'=> $subject.lang('You have been disinvited from the meeting at %1', '$$startdate$$'),
1956
+			'notifyResponse'  => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'),
1957
+			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'),
1959 1958
 			'interval'        => 30,
1960 1959
 		);
1961
-		foreach($values as $var => $default)
1960
+		foreach ($values as $var => $default)
1962 1961
 		{
1963
-			$type = substr($var,0,6) == 'notify' ? 'forced' : 'default';
1962
+			$type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default';
1964 1963
 
1965 1964
 			// only set, if neither default nor forced pref exists
1966 1965
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
1967 1966
 			{
1968
-				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
1969
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
1967
+				$GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too
1968
+				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced');
1970 1969
 				$this->cal_prefs[$var] = $default;
1971 1970
 				$need_save = True;
1972 1971
 			}
1973 1972
 		}
1974 1973
 		if ($need_save)
1975 1974
 		{
1976
-			$GLOBALS['egw']->preferences->save_repository(False,'default');
1977
-			$GLOBALS['egw']->preferences->save_repository(False,'forced');
1975
+			$GLOBALS['egw']->preferences->save_repository(False, 'default');
1976
+			$GLOBALS['egw']->preferences->save_repository(False, 'forced');
1978 1977
 		}
1979 1978
 	}
1980 1979
 
@@ -1984,7 +1983,7 @@  discard block
 block discarded – undo
1984 1983
 	 * @param int|string $user account_id or account_lid
1985 1984
 	 * @param string $pw =null password
1986 1985
 	 */
1987
-	static function freebusy_url($user='',$pw=null)
1986
+	static function freebusy_url($user = '', $pw = null)
1988 1987
 	{
1989 1988
 		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
1990 1989
 
@@ -1997,8 +1996,8 @@  discard block
 block discarded – undo
1997 1996
 		elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2)
1998 1997
 		{
1999 1998
 			$credentials = $GLOBALS['egw_info']['user']['account_lid']
2000
-				. ':' . $GLOBALS['egw_info']['user']['passwd'];
2001
-			$credentials = '&cred=' . base64_encode($credentials);
1999
+				. ':'.$GLOBALS['egw_info']['user']['passwd'];
2000
+			$credentials = '&cred='.base64_encode($credentials);
2002 2001
 		}
2003 2002
 		return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ?
2004 2003
 			($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : '').
@@ -2030,11 +2029,11 @@  discard block
 block discarded – undo
2030 2029
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2031 2030
 	 * @return string|boolean string with etag or false
2032 2031
 	 */
2033
-	function get_etag($entry, &$schedule_tag=null)
2032
+	function get_etag($entry, &$schedule_tag = null)
2034 2033
 	{
2035 2034
 		if (!is_array($entry))
2036 2035
 		{
2037
-			list($id,$recur_date) = explode(':',$entry);
2036
+			list($id, $recur_date) = explode(':', $entry);
2038 2037
 			$entry = $this->read($id, $recur_date, true, 'server');
2039 2038
 		}
2040 2039
 		$etag = $schedule_tag = $entry['id'].':'.$entry['etag'];
@@ -2052,15 +2051,15 @@  discard block
 block discarded – undo
2052 2051
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
2053 2052
 	 * @return integer
2054 2053
 	 */
2055
-	public function get_ctag($user, $filter='owner', $master_only=false)
2054
+	public function get_ctag($user, $filter = 'owner', $master_only = false)
2056 2055
 	{
2057 2056
 		if ($this->debug > 1) $startime = microtime(true);
2058 2057
 
2059 2058
 		// resolve users to add memberships for users and members for groups
2060 2059
 		$users = $this->resolve_users($user);
2061
-		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2060
+		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!)
2062 2061
 
2063
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2062
+		if ($this->debug > 1) error_log(__METHOD__."($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s', $ctag)." took ".(microtime(true) - $startime)." secs");
2064 2063
 		return $ctag;
2065 2064
 	}
2066 2065
 
@@ -2080,7 +2079,7 @@  discard block
 block discarded – undo
2080 2079
 
2081 2080
 		$content = array(
2082 2081
 			'info_cat'       => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']),
2083
-			'info_priority'  => $calendar['priority'] ,
2082
+			'info_priority'  => $calendar['priority'],
2084 2083
 			'info_public'    => $calendar['public'] != 'private',
2085 2084
 			'info_subject'   => $calendar['title'],
2086 2085
 			'info_des'       => $calendar['description'],
@@ -2095,7 +2094,7 @@  discard block
 block discarded – undo
2095 2094
 		$content['link_app'][] = $calendar['info_link']['app'];
2096 2095
 		$content['link_id'][]  = $calendar['info_link']['id'];
2097 2096
 		// Copy claendar's links
2098
-		foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
2097
+		foreach (Link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link)
2099 2098
 		{
2100 2099
 			if ($link['app'] != Link::VFS_APPNAME)
2101 2100
 			{
@@ -2108,7 +2107,7 @@  discard block
 block discarded – undo
2108 2107
 			}
2109 2108
 		}
2110 2109
 		// Copy same custom fields
2111
-		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2110
+		foreach (array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2112 2111
 		{
2113 2112
 			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2114 2113
 		}
@@ -2126,20 +2125,20 @@  discard block
 block discarded – undo
2126 2125
 	function timesheet_set($data)
2127 2126
 	{
2128 2127
 		$set = array();
2129
-		list($id,$recurrence) = explode(':',$data['id']);
2130
-		if ((int)$id && ($event = $this->read($id,$recurrence)))
2128
+		list($id, $recurrence) = explode(':', $data['id']);
2129
+		if ((int)$id && ($event = $this->read($id, $recurrence)))
2131 2130
 		{
2132 2131
 			$set['ts_start'] = $event['start'];
2133 2132
 			$set['ts_title'] = $this->link_title($event);
2134
-			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2133
+			$set['start_time'] = Api\DateTime::to($event['start'], 'H:i');
2135 2134
 			$set['ts_description'] = $event['description'];
2136
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2135
+			if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short
2137 2136
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2138 2137
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2139
-			$set['end_time'] = null;	// unset end-time
2138
+			$set['end_time'] = null; // unset end-time
2140 2139
 			$set['cat_id'] = (int)$event['category'];
2141 2140
 
2142
-			foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link)
2141
+			foreach (Link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link)
2143 2142
 			{
2144 2143
 				if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
2145 2144
 				{
Please login to merge, or discard this patch.
Braces   +198 added lines, -49 removed lines patch added patch discarded remove patch
@@ -15,10 +15,13 @@  discard block
 block discarded – undo
15 15
 use EGroupware\Api\Link;
16 16
 use EGroupware\Api\Acl;
17 17
 
18
-if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
18
+if (!defined('ACL_TYPE_IDENTIFER'))
19
+{
20
+	// used to mark ACL-values for the debug_message methode
19 21
 {
20 22
 	define('ACL_TYPE_IDENTIFER','***ACL***');
21 23
 }
24
+}
22 25
 
23 26
 define('HOUR_s',60*60);
24 27
 define('DAY_s',24*HOUR_s);
@@ -216,7 +219,10 @@  discard block
 block discarded – undo
216 219
 	 */
217 220
 	function __construct()
218 221
 	{
219
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
222
+		if ($this->debug > 0)
223
+		{
224
+			$this->debug_message('calendar_bo::bocal() started',True);
225
+		}
220 226
 
221 227
 		$this->so = new calendar_so();
222 228
 
@@ -297,7 +303,10 @@  discard block
 block discarded – undo
297 303
 	 */
298 304
 	static function email_info($ids)
299 305
 	{
300
-		if (!$ids) return null;
306
+		if (!$ids)
307
+		{
308
+			return null;
309
+		}
301 310
 
302 311
 		$data = array();
303 312
 		foreach((array)$ids as $id)
@@ -370,22 +379,31 @@  discard block
 block discarded – undo
370 379
 			$user = trim($user);
371 380
 			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
372 381
 			{
373
-				if ($user && !in_array($user,$users))	// already added?
382
+				if ($user && !in_array($user,$users))
383
+				{
384
+					// already added?
374 385
 				{
375 386
 					$users[] = $user;
376 387
 				}
388
+				}
377 389
 			}
378 390
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
379 391
 			{
380 392
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
381 393
 			}
382 394
 			// the further code is only for real users
383
-			if (!is_numeric($user)) continue;
395
+			if (!is_numeric($user))
396
+			{
397
+				continue;
398
+			}
384 399
 
385 400
 			// for groups we have to include the members
386 401
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
387 402
 			{
388
-				if ($no_enum_groups) continue;
403
+				if ($no_enum_groups)
404
+				{
405
+					continue;
406
+				}
389 407
 
390 408
 				$members = $GLOBALS['egw']->accounts->members($user, true);
391 409
 				if (is_array($members))
@@ -465,11 +483,14 @@  discard block
 block discarded – undo
465 483
 		}
466 484
 
467 485
 		if (!isset($params['users']) || !$params['users'] ||
468
-			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])	// null or '' casted to an array
486
+			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])
487
+		{
488
+			// null or '' casted to an array
469 489
 		{
470 490
 			// for a search use all account you have read grants from
471 491
 			$params['users'] = $params['query'] ? array_keys($this->grants) : $this->user;
472 492
 		}
493
+		}
473 494
 		// resolve users to add memberships for users and members for groups
474 495
 		// for search, do NOT use freebusy rights, as it would allow to probe the content of event entries
475 496
 		$users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query']));
@@ -480,7 +501,10 @@  discard block
 block discarded – undo
480 501
 			$params['private_grants'] = array();
481 502
 			foreach($this->grants as $user => $rights)
482 503
 			{
483
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
504
+				if ($rights & Acl::PRIVAT)
505
+				{
506
+					$params['private_grants'][] = $user;
507
+				}
484 508
 			}
485 509
 		}
486 510
 
@@ -495,7 +519,10 @@  discard block
 block discarded – undo
495 519
 		{
496 520
 			return false;
497 521
 		}
498
-		if (isset($params['start'])) $start = $this->date2ts($params['start']);
522
+		if (isset($params['start']))
523
+		{
524
+			$start = $this->date2ts($params['start']);
525
+		}
499 526
 
500 527
 		if (isset($params['end']))
501 528
 		{
@@ -559,10 +586,13 @@  discard block
 block discarded – undo
559 586
 				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
560 587
 			}
561 588
 			// create empty entries for each day in the reported time
562
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
589
+			for($ts = $start; $ts <= $end; $ts += DAY_s)
590
+			{
591
+				// good enough for array creation, but see while loop below.
563 592
 			{
564 593
 				$daysEvents[$this->date2string($ts)] = array();
565 594
 			}
595
+			}
566 596
 			foreach($events as $k => $event)
567 597
 			{
568 598
 				$e_start = max($this->date2ts($event['start']),$start);
@@ -614,7 +644,10 @@  discard block
 block discarded – undo
614 644
 			$integration_data = calendar_so::get_integration_data();
615 645
 		}
616 646
 
617
-		if (!isset($integration_data[$app])) return null;
647
+		if (!isset($integration_data[$app]))
648
+		{
649
+			return null;
650
+		}
618 651
 
619 652
 		return $part ? $integration_data[$app][$part] : $integration_data[$app];
620 653
 	}
@@ -661,8 +694,14 @@  discard block
 block discarded – undo
661 694
 	 */
662 695
 	function clear_private_infos(&$event,$allowed_participants = array())
663 696
 	{
664
-		if ($event == false) return;
665
-		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
697
+		if ($event == false)
698
+		{
699
+			return;
700
+		}
701
+		if (!is_array($event['participants']))
702
+		{
703
+			error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
704
+		}
666 705
 
667 706
 		$event = array(
668 707
 			'id'    => $event['id'],
@@ -707,19 +746,29 @@  discard block
 block discarded – undo
707 746
 		}
708 747
 		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
709 748
 
710
-		if ($new_horizont <= $this->config['horizont'])	// no move necessary
749
+		if ($new_horizont <= $this->config['horizont'])
750
+		{
751
+			// no move necessary
711 752
 		{
712 753
 			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
754
+		}
713 755
 			return;
714 756
 		}
715 757
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
716 758
 		{
717 759
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
718 760
 		}
719
-		if (empty($maxdays)) $maxdays = 1000; // old default
720
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
761
+		if (empty($maxdays))
762
+		{
763
+			$maxdays = 1000;
764
+		}
765
+		// old default
766
+		if ($new_horizont > time()+$maxdays*DAY_s)
767
+		{
768
+			// some user tries to "look" more then the maximum number of days in the future
721 769
 		{
722 770
 			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
771
+		}
723 772
 			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
724 773
 			return;
725 774
 		}
@@ -747,7 +796,10 @@  discard block
 block discarded – undo
747 796
 		// update the horizont
748 797
 		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
749 798
 
750
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
799
+		if ($this->debug == 'check_move_horizont')
800
+		{
801
+			$this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
802
+		}
751 803
 	}
752 804
 
753 805
 	/**
@@ -778,7 +830,10 @@  discard block
 block discarded – undo
778 830
 				$event['end'] = $event_read['end'];
779 831
 			}
780 832
 		}
781
-		if (!$start) $start = $event['start'];
833
+		if (!$start)
834
+		{
835
+			$start = $event['start'];
836
+		}
782 837
 
783 838
 		$events = array();
784 839
 		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
@@ -818,7 +873,10 @@  discard block
 block discarded – undo
818 873
 	 */
819 874
 	function db2data(&$events,$date_format='ts')
820 875
 	{
821
-		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
876
+		if (!is_array($events))
877
+		{
878
+			echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
879
+		}
822 880
 		foreach ($events as &$event)
823 881
 		{
824 882
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
@@ -902,7 +960,10 @@  discard block
 block discarded – undo
902 960
 	 */
903 961
 	function date2usertime($ts,$date_format='ts')
904 962
 	{
905
-		if (empty($ts) || $date_format == 'server') return $ts;
963
+		if (empty($ts) || $date_format == 'server')
964
+		{
965
+			return $ts;
966
+		}
906 967
 
907 968
 		return Api\DateTime::server2user($ts,$date_format);
908 969
 	}
@@ -920,9 +981,15 @@  discard block
 block discarded – undo
920 981
 	 */
921 982
 	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
922 983
 	{
923
-		if (!$ids) return false;
984
+		if (!$ids)
985
+		{
986
+			return false;
987
+		}
924 988
 
925
-		if ($date) $date = $this->date2ts($date);
989
+		if ($date)
990
+		{
991
+			$date = $this->date2ts($date);
992
+		}
926 993
 
927 994
 		$return = null;
928 995
 
@@ -1087,7 +1154,10 @@  discard block
 block discarded – undo
1087 1154
 	{
1088 1155
 		static $res_info_cache = array();
1089 1156
 
1090
-		if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1157
+		if (!is_scalar($uid))
1158
+		{
1159
+			throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1160
+		}
1091 1161
 
1092 1162
 		if (!isset($res_info_cache[$uid]))
1093 1163
 		{
@@ -1142,7 +1212,10 @@  discard block
 block discarded – undo
1142 1212
 	 */
1143 1213
 	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1144 1214
 	{
1145
-		if (!$user) $user = $this->user;
1215
+		if (!$user)
1216
+		{
1217
+			$user = $this->user;
1218
+		}
1146 1219
 		if ($user == $this->user)
1147 1220
 		{
1148 1221
 			$grants = $this->grants;
@@ -1181,7 +1254,10 @@  discard block
 block discarded – undo
1181 1254
 		$grant = $grants[$owner];
1182 1255
 
1183 1256
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1184
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1257
+		if ($grant & ~self::ACL_INVITE)
1258
+		{
1259
+			$grant |= self::ACL_FREEBUSY;
1260
+		}
1185 1261
 
1186 1262
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1187 1263
 		{
@@ -1207,7 +1283,10 @@  discard block
 block discarded – undo
1207 1283
 					elseif (!is_numeric($uid))
1208 1284
 					{
1209 1285
 						// if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights
1210
-						if ($grant == self::ACL_FREEBUSY) continue;
1286
+						if ($grant == self::ACL_FREEBUSY)
1287
+						{
1288
+							continue;
1289
+						}
1211 1290
 						// if we have a resource as participant
1212 1291
 						$resource = $this->resource_info($uid);
1213 1292
 						$grant |= $resource['rights'];
@@ -1357,13 +1436,19 @@  discard block
 block discarded – undo
1357 1436
 						$param = $param ? 'True' : 'False';
1358 1437
 						break;
1359 1438
 					case 'integer':
1360
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1439
+						if ($param >= mktime(0,0,0,1,1,2000))
1440
+						{
1441
+							$param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1442
+						}
1361 1443
 						break;
1362 1444
 				}
1363 1445
 			}
1364 1446
 			$msg = str_replace('%'.($i-1),$param,$msg);
1365 1447
 		}
1366
-		if ($backtrace) error_log(function_backtrace(1));
1448
+		if ($backtrace)
1449
+		{
1450
+			error_log(function_backtrace(1));
1451
+		}
1367 1452
 	}
1368 1453
 
1369 1454
 	/**
@@ -1471,14 +1556,20 @@  discard block
 block discarded – undo
1471 1556
 	function timespan($start_m,$end_m,$both=false)
1472 1557
 	{
1473 1558
 		$duration = $end_m - $start_m;
1474
-		if ($end_m == 24*60-1) ++$duration;
1559
+		if ($end_m == 24*60-1)
1560
+		{
1561
+			++$duration;
1562
+		}
1475 1563
 		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1476 1564
 
1477 1565
 		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1478 1566
 
1479
-		if ($both)	// end-time too
1567
+		if ($both)
1568
+		{
1569
+			// end-time too
1480 1570
 		{
1481 1571
 			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1572
+		}
1482 1573
 			// dont double am/pm if they are the same in both times
1483 1574
 			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1484 1575
 			{
@@ -1502,7 +1593,10 @@  discard block
 block discarded – undo
1502 1593
 		static $id2lid = array();
1503 1594
 		static $id2email = array();
1504 1595
 
1505
-		if ($use_type && $use_type != 'u') $id = $use_type.$id;
1596
+		if ($use_type && $use_type != 'u')
1597
+		{
1598
+			$id = $use_type.$id;
1599
+		}
1506 1600
 
1507 1601
 		if (!isset($id2lid[$id]))
1508 1602
 		{
@@ -1512,7 +1606,10 @@  discard block
 block discarded – undo
1512 1606
 				if (($info = $this->resource_info($id)))
1513 1607
 				{
1514 1608
 					$id2lid[$id] = $info['name'] ? $info['name'] : $info['email'];
1515
-					if ($info['name']) $id2email[$id] = $info['email'];
1609
+					if ($info['name'])
1610
+					{
1611
+						$id2email[$id] = $info['email'];
1612
+					}
1516 1613
 				}
1517 1614
 			}
1518 1615
 			else
@@ -1538,11 +1635,18 @@  discard block
 block discarded – undo
1538 1635
 		$names = array();
1539 1636
 		foreach((array)$event['participants'] as $id => $status)
1540 1637
 		{
1541
-			if (!is_string($status)) continue;
1638
+			if (!is_string($status))
1639
+			{
1640
+				continue;
1641
+			}
1542 1642
 			$quantity = $role = null;
1543 1643
 			calendar_so::split_status($status,$quantity,$role);
1544 1644
 
1545
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1645
+			if ($status == 'G' && !$show_group_invitation)
1646
+			{
1647
+				continue;
1648
+			}
1649
+			// dont show group-invitation
1546 1650
 
1547 1651
 			$lang_status = lang($this->verbose_status[$status]);
1548 1652
 			if (!$long_status)
@@ -1615,7 +1719,10 @@  discard block
 block discarded – undo
1615 1719
 
1616 1720
 		foreach(explode(',',$category) as $cat_id)
1617 1721
 		{
1618
-			if (!$cat_id) continue;
1722
+			if (!$cat_id)
1723
+			{
1724
+				continue;
1725
+			}
1619 1726
 
1620 1727
 			if (!isset($id2cat[$cat_id]))
1621 1728
 			{
@@ -1681,7 +1788,10 @@  discard block
 block discarded – undo
1681 1788
 	 */
1682 1789
 	public static function list_calendars($user, array $grants=null)
1683 1790
 	{
1684
-		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1791
+		if (is_null($grants))
1792
+		{
1793
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1794
+		}
1685 1795
 
1686 1796
 		$users = $groups = array();
1687 1797
 		foreach(array_keys($grants) as $id)
@@ -1729,7 +1839,10 @@  discard block
 block discarded – undo
1729 1839
 	 */
1730 1840
 	function recure2string($event)
1731 1841
 	{
1732
-		if (!is_array($event)) return false;
1842
+		if (!is_array($event))
1843
+		{
1844
+			return false;
1845
+		}
1733 1846
 		return (string)calendar_rrule::event2rrule($event);
1734 1847
 	}
1735 1848
 
@@ -1748,12 +1861,18 @@  discard block
 block discarded – undo
1748 1861
 	 */
1749 1862
 	function read_holidays($year=0)
1750 1863
 	{
1751
-		if (!$year) $year = (int) date('Y',$this->now_su);
1864
+		if (!$year)
1865
+		{
1866
+			$year = (int) date('Y',$this->now_su);
1867
+		}
1752 1868
 
1753
-		if (!$this->cached_holidays)	// try reading the holidays from the session
1869
+		if (!$this->cached_holidays)
1870
+		{
1871
+			// try reading the holidays from the session
1754 1872
 		{
1755 1873
 			$this->cached_holidays = Api\Cache::getSession('calendar', 'holidays');
1756 1874
 		}
1875
+		}
1757 1876
 		if (!isset($this->cached_holidays[$year]))
1758 1877
 		{
1759 1878
 			$this->cached_holidays[$year] = calendar_holidays::read(
@@ -1791,7 +1910,11 @@  discard block
 block discarded – undo
1791 1910
 							continue;
1792 1911
 						}
1793 1912
 						list($y,$m,$d) = explode('-',$pers['bday']);
1794
-						if ($y > $year) continue; 	// not yet born
1913
+						if ($y > $year)
1914
+						{
1915
+							continue;
1916
+						}
1917
+						// not yet born
1795 1918
 						$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
1796 1919
 							'day'       => $d,
1797 1920
 							'month'     => $m,
@@ -1884,7 +2007,10 @@  discard block
 block discarded – undo
1884 2007
 				}
1885 2008
 			}
1886 2009
 			$str_fields = implode(', ',$extra_fields);
1887
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2010
+			if (is_array($extra_fields))
2011
+			{
2012
+				return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2013
+			}
1888 2014
 		}
1889 2015
 		return $this->format_date($event['start']) . ': ' . $event['title'];
1890 2016
 	}
@@ -1905,7 +2031,8 @@  discard block
 block discarded – undo
1905 2031
 			'offset' =>	$options['start'],
1906 2032
 			'order' => 'cal_start DESC',
1907 2033
 		);
1908
-		if($options['num_rows']) {
2034
+		if($options['num_rows'])
2035
+		{
1909 2036
 			$query['num_rows'] = $options['num_rows'];
1910 2037
 		}
1911 2038
 		foreach((array) $this->search($query) as $event)
@@ -1966,7 +2093,10 @@  discard block
 block discarded – undo
1966 2093
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
1967 2094
 			{
1968 2095
 				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
1969
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2096
+				if ($type == 'forced')
2097
+				{
2098
+					$GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2099
+				}
1970 2100
 				$this->cal_prefs[$var] = $default;
1971 2101
 				$need_save = True;
1972 2102
 			}
@@ -1986,7 +2116,10 @@  discard block
 block discarded – undo
1986 2116
 	 */
1987 2117
 	static function freebusy_url($user='',$pw=null)
1988 2118
 	{
1989
-		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2119
+		if (is_numeric($user))
2120
+		{
2121
+			$user = $GLOBALS['egw']->accounts->id2name($user);
2122
+		}
1990 2123
 
1991 2124
 		$credentials = '';
1992 2125
 
@@ -2054,13 +2187,19 @@  discard block
 block discarded – undo
2054 2187
 	 */
2055 2188
 	public function get_ctag($user, $filter='owner', $master_only=false)
2056 2189
 	{
2057
-		if ($this->debug > 1) $startime = microtime(true);
2190
+		if ($this->debug > 1)
2191
+		{
2192
+			$startime = microtime(true);
2193
+		}
2058 2194
 
2059 2195
 		// resolve users to add memberships for users and members for groups
2060 2196
 		$users = $this->resolve_users($user);
2061 2197
 		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2062 2198
 
2063
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2199
+		if ($this->debug > 1)
2200
+		{
2201
+			error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2202
+		}
2064 2203
 		return $ctag;
2065 2204
 	}
2066 2205
 
@@ -2102,15 +2241,21 @@  discard block
 block discarded – undo
2102 2241
 				$content['link_app'][] = $link['app'];
2103 2242
 				$content['link_id'][]  = $link['id'];
2104 2243
 			}
2105
-			if ($link['app'] == 'addressbook')	// prefering contact as primary contact over calendar entry set above
2244
+			if ($link['app'] == 'addressbook')
2245
+			{
2246
+				// prefering contact as primary contact over calendar entry set above
2106 2247
 			{
2107 2248
 				$content['info_contact'] = 'addressbook:'.$link['id'];
2108 2249
 			}
2250
+			}
2109 2251
 		}
2110 2252
 		// Copy same custom fields
2111 2253
 		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2112 2254
 		{
2113
-			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2255
+			if ($this->customfields[$name])
2256
+			{
2257
+				$content['#'.$name] = $calendar['#'.$name];
2258
+			}
2114 2259
 		}
2115 2260
 		//error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content));
2116 2261
 		return $content;
@@ -2133,7 +2278,11 @@  discard block
 block discarded – undo
2133 2278
 			$set['ts_title'] = $this->link_title($event);
2134 2279
 			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2135 2280
 			$set['ts_description'] = $event['description'];
2136
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2281
+			if ($this->isWholeDay($event))
2282
+			{
2283
+				$event['end']++;
2284
+			}
2285
+			// whole day events are 1sec short
2137 2286
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2138 2287
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2139 2288
 			$set['end_time'] = null;	// unset end-time
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	/**
123 123
 	 * @var array recur_types translates MCAL recur-types to verbose labels
124 124
 	 */
125
-	var $recur_types = Array(
125
+	var $recur_types = array(
126 126
 		MCAL_RECUR_NONE         => 'No recurrence',
127 127
 		MCAL_RECUR_DAILY        => 'Daily',
128 128
 		MCAL_RECUR_WEEKLY       => 'Weekly',
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 	 * @param string $pattern pattern to search
1898 1898
 	 * @return array with cal_id - title pairs of the matching entries
1899 1899
 	 */
1900
-	function link_query($pattern, Array &$options = array())
1900
+	function link_query($pattern, array &$options = array())
1901 1901
 	{
1902 1902
 		$result = array();
1903 1903
 		$query = array(
Please login to merge, or discard this patch.
calendar/inc/class.calendar_boupdate.inc.php 5 patches
Doc Comments   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -519,6 +519,7 @@  discard block
 block discarded – undo
519 519
 	 * @param array $new_event Event after the change
520 520
 	 * @param string $role we treat CHAIR like event owners
521 521
 	 * @param string $status of current user
522
+	 * @param integer $msg_type
522 523
 	 * @return boolean true = update requested, false otherwise
523 524
 	 */
524 525
 	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null)
@@ -594,7 +595,7 @@  discard block
 block discarded – undo
594 595
 	/**
595 596
 	 * Check calendar prefs, if a given user (integer account_id) or email (user or externals) should get notified
596 597
 	 *
597
-	 * @param int|string $user_or_email
598
+	 * @param string $user_or_email
598 599
 	 * @param string $ical_method ='REQUEST'
599 600
 	 * @param string $role ='REQ-PARTICIPANT'
600 601
 	 * @return boolean true if user requested to be notified, false if not
@@ -645,8 +646,7 @@  discard block
 block discarded – undo
645 646
 	 * Get iCal/iMip method from internal nummeric msg-type plus optional notification message and verbose name
646 647
 	 *
647 648
 	 * @param int $msg_type see MSG_* defines
648
-	 * @param string& $action=null on return verbose name
649
-	 * @param string& $msg=null on return notification message
649
+	 * @param string& $action on return verbose name
650 650
 	 */
651 651
 	function msg_type2ical_method($msg_type, &$action=null, &$msg=null)
652 652
 	{
@@ -1011,6 +1011,9 @@  discard block
 block discarded – undo
1011 1011
 		return true;
1012 1012
 	}
1013 1013
 
1014
+	/**
1015
+	 * @param integer $added
1016
+	 */
1014 1017
 	function get_update_message($event,$added)
1015 1018
 	{
1016 1019
 		$nul = null;
@@ -1300,8 +1303,8 @@  discard block
 block discarded – undo
1300 1303
 	 *
1301 1304
 	 * @param int $right self::CAT_ACL_{ADD|STATUS}
1302 1305
 	 * @param int|array $event
1303
-	 * @return boolean true if use has the right, false if not
1304
-	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1306
+	 * @return null|boolean true if use has the right, false if not
1307
+	 * @return null|boolean false=access denied because of cat acl, true access granted because of cat acl,
1305 1308
 	 * 	null = cat has no acl
1306 1309
 	 */
1307 1310
 	function check_cat_acl($right,$event)
@@ -1386,6 +1389,8 @@  discard block
 block discarded – undo
1386 1389
 	 * Check if current user has a given right on a category (if it's restricted!)
1387 1390
 	 *
1388 1391
 	 * @param int $cat_id
1392
+	 * @param integer $right
1393
+	 * @param integer $user
1389 1394
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1390 1395
 	 * 	null = cat has no acl
1391 1396
 	 */
@@ -1647,7 +1652,7 @@  discard block
 block discarded – undo
1647 1652
 	 * @param string $action
1648 1653
 	 * @param array $event_arr
1649 1654
 	 * @param array $disinvited
1650
-	 * @return array
1655
+	 * @return string
1651 1656
 	 */
1652 1657
 	function _get_event_details($event,$action,&$event_arr,$disinvited=array())
1653 1658
 	{
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1504,22 +1504,22 @@  discard block
 block discarded – undo
1504 1504
 		// check the old list against the new list
1505 1505
 		foreach ($old_event['participants'] as $userid => $status)
1506 1506
   		{
1507
-            if (!isset($new_event['participants'][$userid])){
1508
-            	// Attendee will be deleted this way
1509
-            	$new_event['participants'][$userid] = 'G';
1510
-            }
1511
-            elseif ($new_event['participants'][$userid] == $status)
1512
-            {
1513
-            	// Same status -- nothing to do.
1514
-            	unset($new_event['participants'][$userid]);
1515
-            }
1507
+			if (!isset($new_event['participants'][$userid])){
1508
+				// Attendee will be deleted this way
1509
+				$new_event['participants'][$userid] = 'G';
1510
+			}
1511
+			elseif ($new_event['participants'][$userid] == $status)
1512
+			{
1513
+				// Same status -- nothing to do.
1514
+				unset($new_event['participants'][$userid]);
1515
+			}
1516 1516
 		}
1517 1517
 		// write the changes
1518 1518
 		foreach ($new_event['participants'] as $userid => $status)
1519 1519
 		{
1520 1520
 			$this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification);
1521 1521
 		}
1522
-    }
1522
+	}
1523 1523
 
1524 1524
 	/**
1525 1525
 	 * deletes an event
@@ -2493,24 +2493,24 @@  discard block
 block discarded – undo
2493 2493
 	/**
2494 2494
 	 * classifies an incoming event from the eGW point-of-view
2495 2495
 	 *
2496
-     * exceptions: unlike other calendar apps eGW does not create an event exception
2497
-     * if just the participant state changes - therefore we have to distinguish between
2498
-     * real exceptions and status only exceptions
2499
-     *
2500
-     * @param array $event the event to check
2501
-     *
2502
-     * @return array
2503
-     * 	type =>
2504
-     * 		SINGLE a single event
2505
-     * 		SERIES-MASTER the series master
2506
-     * 		SERIES-EXCEPTION event is a real exception
2507
-	  * 		SERIES-PSEUDO-EXCEPTION event is a status only exception
2508
-	  * 		SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception
2509
-	  * 	stored_event => if event already exists in the database array with event data or false
2510
-	  * 	master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE
2511
-	  * 		the corresponding series master event array
2512
-	  * 		NOTE: this param is false if event is of type SERIES-MASTER
2513
-     */
2496
+	 * exceptions: unlike other calendar apps eGW does not create an event exception
2497
+	 * if just the participant state changes - therefore we have to distinguish between
2498
+	 * real exceptions and status only exceptions
2499
+	 *
2500
+	 * @param array $event the event to check
2501
+	 *
2502
+	 * @return array
2503
+	 * 	type =>
2504
+	 * 		SINGLE a single event
2505
+	 * 		SERIES-MASTER the series master
2506
+	 * 		SERIES-EXCEPTION event is a real exception
2507
+	 * 		SERIES-PSEUDO-EXCEPTION event is a status only exception
2508
+	 * 		SERIES-EXCEPTION-PROPAGATE event was a status only exception in the past and is now a real exception
2509
+	 * 	stored_event => if event already exists in the database array with event data or false
2510
+	 * 	master_event => for event type SERIES-EXCEPTION, SERIES-PSEUDO-EXCEPTION or SERIES-EXCEPTION-PROPAGATE
2511
+	 * 		the corresponding series master event array
2512
+	 * 		NOTE: this param is false if event is of type SERIES-MASTER
2513
+	 */
2514 2514
 	function get_event_info($event)
2515 2515
 	{
2516 2516
 		$type = 'SINGLE'; // default
@@ -2681,16 +2681,16 @@  discard block
 block discarded – undo
2681 2681
 			'stored_event' => $stored_event,
2682 2682
 			'master_event' => $master_event,
2683 2683
 		);
2684
-    }
2685
-
2686
-    /**
2687
-     * Translates all timestamps for a given event from server-time to user-time.
2688
-     * The update() and save() methods expect timestamps in user-time.
2689
-     * @param &$event	the event we are working on
2690
-     *
2691
-     */
2692
-    function server2usertime (&$event)
2693
-    {
2684
+	}
2685
+
2686
+	/**
2687
+	 * Translates all timestamps for a given event from server-time to user-time.
2688
+	 * The update() and save() methods expect timestamps in user-time.
2689
+	 * @param &$event	the event we are working on
2690
+	 *
2691
+	 */
2692
+	function server2usertime (&$event)
2693
+	{
2694 2694
 		// we run all dates through date2usertime, to adjust to user-time
2695 2695
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2696 2696
 		{
@@ -2713,7 +2713,7 @@  discard block
 block discarded – undo
2713 2713
 				$event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']);
2714 2714
 			}
2715 2715
 		}
2716
-    }
2716
+	}
2717 2717
 	/**
2718 2718
 	 * Delete events that are more than $age years old
2719 2719
 	 *
Please login to merge, or discard this patch.
Spacing   +295 added lines, -297 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
16 16
 use EGroupware\Api\Acl;
17 17
 
18 18
 // types of messsages send by calendar_boupdate::send_update
19
-define('MSG_DELETED',0);
20
-define('MSG_MODIFIED',1);
21
-define('MSG_ADDED',2);
22
-define('MSG_REJECTED',3);
23
-define('MSG_TENTATIVE',4);
24
-define('MSG_ACCEPTED',5);
25
-define('MSG_ALARM',6);
26
-define('MSG_DISINVITE',7);
27
-define('MSG_DELEGATED',8);
19
+define('MSG_DELETED', 0);
20
+define('MSG_MODIFIED', 1);
21
+define('MSG_ADDED', 2);
22
+define('MSG_REJECTED', 3);
23
+define('MSG_TENTATIVE', 4);
24
+define('MSG_ACCEPTED', 5);
25
+define('MSG_ALARM', 6);
26
+define('MSG_DISINVITE', 7);
27
+define('MSG_DELEGATED', 8);
28 28
 
29 29
 /**
30 30
  * Class to access AND manipulate all calendar data (business object)
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	function __construct()
87 87
 	{
88
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
88
+		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True);
89 89
 
90
-		parent::__construct();	// calling the parent constructor
90
+		parent::__construct(); // calling the parent constructor
91 91
 
92
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
92
+		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True);
93 93
 	}
94 94
 
95 95
 	/**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * +      + +  C   +	which is clearly wrong for everything with a maximum quantity > 1
117 117
 	 * ++++++++ ++++++++
118 118
 	 */
119
-	function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
119
+	function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
120 120
 	{
121 121
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
122 122
 		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		if ($this->debug > 1 || $this->debug == 'update')
125 125
 		{
126 126
 			$this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)',
127
-				false,$event,$ignore_conflicts,$touch_modified,$ignore_acl);
127
+				false, $event, $ignore_conflicts, $touch_modified, $ignore_acl);
128 128
 		}
129 129
 		// check some minimum requirements:
130 130
 		// - new events need start, end and title
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 		}
153 153
 
154 154
 		// check if user has the permission to update / create the event
155
-		if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) ||
156
-			$new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) &&
157
-			!$this->check_perms(Acl::ADD,0,$event['owner']))
155
+		if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) ||
156
+			$new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) &&
157
+			!$this->check_perms(Acl::ADD, 0, $event['owner']))
158 158
 		{
159
-			$messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner']));
159
+			$messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner']));
160 160
 			return false;
161 161
 		}
162 162
 		if ($new_event)
@@ -165,24 +165,24 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 		else
167 167
 		{
168
-			$old_event = $this->read((int)$event['id'],null,$ignore_acl);
168
+			$old_event = $this->read((int)$event['id'], null, $ignore_acl);
169 169
 		}
170 170
 
171 171
 		// do we need to check, if user is allowed to invite the invited participants
172
-		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event)))
172
+		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event)))
173 173
 		{
174 174
 			// report removed participants back to user
175
-			foreach($removed as $key => $account_id)
175
+			foreach ($removed as $key => $account_id)
176 176
 			{
177 177
 				$removed[$key] = $this->participant_name($account_id);
178 178
 			}
179
-			$messages[] = lang('%1 participants removed because of missing invite grants',count($removed)).
180
-				': '.implode(', ',$removed);
179
+			$messages[] = lang('%1 participants removed because of missing invite grants', count($removed)).
180
+				': '.implode(', ', $removed);
181 181
 		}
182 182
 		// check category based ACL
183 183
 		if ($event['category'])
184 184
 		{
185
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
185
+			if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']);
186 186
 			if (!$old_event || !isset($old_event['category']))
187 187
 			{
188 188
 				$old_event['category'] = array();
@@ -191,38 +191,38 @@  discard block
 block discarded – undo
191 191
 			{
192 192
 				$old_event['category'] = explode(',', $old_event['category']);
193 193
 			}
194
-			foreach($event['category'] as $key => $cat_id)
194
+			foreach ($event['category'] as $key => $cat_id)
195 195
 			{
196 196
 				// check if user is allowed to update event categories
197
-				if ((!$old_event || !in_array($cat_id,$old_event['category'])) &&
198
-					self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false)
197
+				if ((!$old_event || !in_array($cat_id, $old_event['category'])) &&
198
+					self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false)
199 199
 				{
200 200
 					unset($event['category'][$key]);
201 201
 					// report removed category to user
202 202
 					$removed_cats[$cat_id] = $this->categories->id2name($cat_id);
203
-					continue;	// no further check, as cat was removed
203
+					continue; // no further check, as cat was removed
204 204
 				}
205 205
 				// for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown
206 206
 				if (!$status_reset_to_unknown &&
207
-					self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false &&
207
+					self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false &&
208 208
 					(!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end']))
209 209
 				{
210
-					foreach((array)$event['participants'] as $uid => $status)
210
+					foreach ((array)$event['participants'] as $uid => $status)
211 211
 					{
212 212
 						$q = $r = null;
213
-						calendar_so::split_status($status,$q,$r);
213
+						calendar_so::split_status($status, $q, $r);
214 214
 						if ($status != 'U')
215 215
 						{
216
-							$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
216
+							$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
217 217
 							// todo: report reset status to user
218 218
 						}
219 219
 					}
220
-					$status_reset_to_unknown = true;	// once is enough
220
+					$status_reset_to_unknown = true; // once is enough
221 221
 				}
222 222
 			}
223 223
 			if ($removed_cats)
224 224
 			{
225
-				$messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats));
225
+				$messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats));
226 226
 			}
227 227
 			if ($status_reset_to_unknown)
228 228
 			{
@@ -233,61 +233,61 @@  discard block
 block discarded – undo
233 233
 		if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']))
234 234
 		{
235 235
 			$types_with_quantity = array();
236
-			foreach($this->resources as $type => $data)
236
+			foreach ($this->resources as $type => $data)
237 237
 			{
238 238
 				if ($data['max_quantity']) $types_with_quantity[] = $type;
239 239
 			}
240 240
 			// get all NOT rejected participants and evtl. their quantity
241 241
 			$quantity = $users = array();
242
-			foreach($event['participants'] as $uid => $status)
242
+			foreach ($event['participants'] as $uid => $status)
243 243
 			{
244
-				calendar_so::split_status($status,$q,$r);
245
-				if ($status[0] == 'R') continue;	// ignore rejected participants
244
+				calendar_so::split_status($status, $q, $r);
245
+				if ($status[0] == 'R') continue; // ignore rejected participants
246 246
 
247 247
 				if ($uid < 0)	// group, check it's members too
248 248
 				{
249
-					$users += (array)$GLOBALS['egw']->accounts->members($uid,true);
249
+					$users += (array)$GLOBALS['egw']->accounts->members($uid, true);
250 250
 					$users = array_unique($users);
251 251
 				}
252 252
 				$users[] = $uid;
253
-				if (in_array($uid[0],$types_with_quantity))
253
+				if (in_array($uid[0], $types_with_quantity))
254 254
 				{
255 255
 					$quantity[$uid] = $q;
256 256
 				}
257 257
 			}
258 258
 			//$start = microtime(true);
259
-			$overlapping_events =& $this->search(array(
259
+			$overlapping_events = & $this->search(array(
260 260
 				'start' => $event['start'],
261 261
 				'end'   => $event['end'],
262 262
 				'users' => $users,
263
-				'ignore_acl' => true,	// otherwise we get only events readable by the user
264
-				'enum_groups' => true,	// otherwise group-events would not block time
263
+				'ignore_acl' => true, // otherwise we get only events readable by the user
264
+				'enum_groups' => true, // otherwise group-events would not block time
265 265
 				'query' => array(
266 266
 					'cal_non_blocking' => 0,
267 267
 				),
268
-				'no_integration' => true,	// do NOT use integration of other apps
268
+				'no_integration' => true, // do NOT use integration of other apps
269 269
 			));
270 270
 			//error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s');
271 271
 			if ($this->debug > 2 || $this->debug == 'update')
272 272
 			{
273
-				$this->debug_message('calendar_boupdate::update() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$event['start'],$event['end']);
273
+				$this->debug_message('calendar_boupdate::update() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $event['start'], $event['end']);
274 274
 			}
275 275
 			$max_quantity = $possible_quantity_conflicts = $conflicts = array();
276
-			foreach((array) $overlapping_events as $k => $overlap)
276
+			foreach ((array)$overlapping_events as $k => $overlap)
277 277
 			{
278
-				if ($overlap['id'] == $event['id'] ||	// that's the event itself
279
-					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
278
+				if ($overlap['id'] == $event['id'] || // that's the event itself
279
+					$overlap['id'] == $event['reference'] || // event is an exception of overlap
280 280
 					$overlap['non_blocking'])			// that's a non_blocking event
281 281
 				{
282 282
 					continue;
283 283
 				}
284 284
 				if ($this->debug > 3 || $this->debug == 'update')
285 285
 				{
286
-					$this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap);
286
+					$this->debug_message('calendar_boupdate::update() checking overlapping event %1', false, $overlap);
287 287
 				}
288 288
 				// check if the overlap is with a rejected participant or within the allowed quantity
289
-				$common_parts = array_intersect($users,array_keys($overlap['participants']));
290
-				foreach($common_parts as $n => $uid)
289
+				$common_parts = array_intersect($users, array_keys($overlap['participants']));
290
+				foreach ($common_parts as $n => $uid)
291 291
 				{
292 292
 					$status = $overlap['participants'][$uid];
293 293
 					calendar_so::split_status($status, $q, $r);
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 						unset($common_parts[$n]);
297 297
 						continue;
298 298
 					}
299
-					if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity))
299
+					if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity))
300 300
 					{
301
-						continue;	// no quantity check: quantity allways 1 ==> conflict
301
+						continue; // no quantity check: quantity allways 1 ==> conflict
302 302
 					}
303 303
 					if (!isset($max_quantity[$uid]))
304 304
 					{
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 					$quantity[$uid] += $q;
309 309
 					if ($quantity[$uid] <= $max_quantity[$uid])
310 310
 					{
311
-						$possible_quantity_conflicts[$uid][] =& $overlapping_events[$k];	// an other event can give the conflict
311
+						$possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict
312 312
 						unset($common_parts[$n]);
313 313
 						continue;
314 314
 					}
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 				{
319 319
 					if ($this->debug > 3 || $this->debug == 'update')
320 320
 					{
321
-						$this->debug_message('calendar_boupdate::update() conflicts with the following participants found %1',false,$common_parts);
321
+						$this->debug_message('calendar_boupdate::update() conflicts with the following participants found %1', false, $common_parts);
322 322
 					}
323
-					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k];
323
+					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k];
324 324
 				}
325 325
 			}
326 326
 			// check if we are withing the allowed quantity and if not add all events using that resource
327 327
 			// seems this function is doing very strange things, it gives empty conflicts
328
-			foreach($max_quantity as $uid => $max)
328
+			foreach ($max_quantity as $uid => $max)
329 329
 			{
330 330
 				if ($quantity[$uid] > $max)
331 331
 				{
332
-					foreach((array)$possible_quantity_conflicts[$uid] as $conflict)
332
+					foreach ((array)$possible_quantity_conflicts[$uid] as $conflict)
333 333
 					{
334
-						$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k];
334
+						$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k];
335 335
 					}
336 336
 				}
337 337
 			}
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
 
340 340
 			if (count($conflicts))
341 341
 			{
342
-				foreach($conflicts as $key => $conflict)
342
+				foreach ($conflicts as $key => $conflict)
343 343
 				{
344
-						$conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']);
345
-					if (!$this->check_perms(Acl::READ,$conflict))
344
+						$conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']);
345
+					if (!$this->check_perms(Acl::READ, $conflict))
346 346
 					{
347 347
 						$conflicts[$key] = array(
348 348
 							'id'    => $conflict['id'],
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 				}
356 356
 				if ($this->debug > 2 || $this->debug == 'update')
357 357
 				{
358
-					$this->debug_message('calendar_boupdate::update() %1 conflicts found %2',false,count($conflicts),$conflicts);
358
+					$this->debug_message('calendar_boupdate::update() %1 conflicts found %2', false, count($conflicts), $conflicts);
359 359
 				}
360 360
 				return $conflicts;
361 361
 			}
@@ -369,33 +369,33 @@  discard block
 block discarded – undo
369 369
 			return $cal_id;
370 370
 		}
371 371
 
372
-		$event = $this->read($cal_id);	// we re-read the event, in case only partial information was update and we need the full info for the notifies
372
+		$event = $this->read($cal_id); // we re-read the event, in case only partial information was update and we need the full info for the notifies
373 373
 		//echo "new $cal_id="; _debug_array($event);
374 374
 
375
-		if($old_event['deleted'] && $event['deleted'] == null)
375
+		if ($old_event['deleted'] && $event['deleted'] == null)
376 376
 		{
377 377
 			// Restored, bring back links
378 378
 			Link::restore('calendar', $cal_id);
379 379
 		}
380 380
 		if ($this->log_file)
381 381
 		{
382
-			$this->log2file($event2save,$event,$old_event);
382
+			$this->log2file($event2save, $event, $old_event);
383 383
 		}
384 384
 		// send notifications
385
-		if(!$skip_notification)
385
+		if (!$skip_notification)
386 386
 		{
387 387
 			if ($new_event)
388 388
 			{
389
-				$this->send_update(MSG_ADDED,$event['participants'],'',$event);
389
+				$this->send_update(MSG_ADDED, $event['participants'], '', $event);
390 390
 			}
391 391
 			else // update existing event
392 392
 			{
393
-				$this->check4update($event,$old_event);
393
+				$this->check4update($event, $old_event);
394 394
 			}
395 395
 		}
396 396
 
397 397
 		// notify the link-class about the update, as other apps may be subscribt to it
398
-		Link::notify_update('calendar',$cal_id,$event);
398
+		Link::notify_update('calendar', $cal_id, $event);
399 399
 
400 400
 		return $cal_id;
401 401
 	}
@@ -407,22 +407,22 @@  discard block
 block discarded – undo
407 407
 	 * @param array $old_event =null old event with already invited participants
408 408
 	 * @return array removed participants because of missing invite grants
409 409
 	 */
410
-	public function remove_no_acl_invite(array &$event,array $old_event=null)
410
+	public function remove_no_acl_invite(array &$event, array $old_event = null)
411 411
 	{
412 412
 		if (!$this->require_acl_invite)
413 413
 		{
414
-			return array();	// nothing to check, everyone can invite everyone else
414
+			return array(); // nothing to check, everyone can invite everyone else
415 415
 		}
416 416
 		if ($event['id'] && is_null($old_event))
417 417
 		{
418 418
 			$old_event = $this->read($event['id']);
419 419
 		}
420 420
 		$removed = array();
421
-		foreach(array_keys((array)$event['participants']) as $uid)
421
+		foreach (array_keys((array)$event['participants']) as $uid)
422 422
 		{
423 423
 			if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid))
424 424
 			{
425
-				unset($event['participants'][$uid]);	// remove participant
425
+				unset($event['participants'][$uid]); // remove participant
426 426
 				$removed[] = $uid;
427 427
 			}
428 428
 		}
@@ -438,19 +438,19 @@  discard block
 block discarded – undo
438 438
 	 */
439 439
 	public function check_acl_invite($uid)
440 440
 	{
441
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
441
+		if (!is_numeric($uid)) return true; // nothing implemented for resources so far
442 442
 
443 443
 		if (!$this->require_acl_invite)
444 444
 		{
445
-			$ret = true;	// no grant required
445
+			$ret = true; // no grant required
446 446
 		}
447 447
 		elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g')
448 448
 		{
449
-			$ret = true;	// grant only required for groups
449
+			$ret = true; // grant only required for groups
450 450
 		}
451 451
 		else
452 452
 		{
453
-			$ret = $this->check_perms(self::ACL_INVITE,0,$uid);
453
+			$ret = $this->check_perms(self::ACL_INVITE, 0, $uid);
454 454
 		}
455 455
 		//error_log(__METHOD__."($uid) = ".array2string($ret));
456 456
 		//echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n";
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 * @param array $old_event the event before the update
465 465
 	 * @todo check if there is a real change, not assume every save is a change
466 466
 	 */
467
-	function check4update($new_event,$old_event)
467
+	function check4update($new_event, $old_event)
468 468
 	{
469 469
 		//error_log(__METHOD__."($new_event[title])");
470 470
 		$modified = $added = $deleted = array();
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 		//echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n";
473 473
 
474 474
 		// Find modified and deleted participants ...
475
-		foreach($old_event['participants'] as $old_userid => $old_status)
475
+		foreach ($old_event['participants'] as $old_userid => $old_status)
476 476
 		{
477
-			if(isset($new_event['participants'][$old_userid]))
477
+			if (isset($new_event['participants'][$old_userid]))
478 478
 			{
479 479
 				$modified[$old_userid] = $new_event['participants'][$old_userid];
480 480
 			}
@@ -484,27 +484,27 @@  discard block
 block discarded – undo
484 484
 			}
485 485
 		}
486 486
 		// Find new participants ...
487
-		foreach(array_keys((array)$new_event['participants']) as $new_userid)
487
+		foreach (array_keys((array)$new_event['participants']) as $new_userid)
488 488
 		{
489
-			if(!isset($old_event['participants'][$new_userid]))
489
+			if (!isset($old_event['participants'][$new_userid]))
490 490
 			{
491 491
 				$added[$new_userid] = 'U';
492 492
 			}
493 493
 		}
494 494
 		//echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n";
495
-		if(count($added) || count($modified) || count($deleted))
495
+		if (count($added) || count($modified) || count($deleted))
496 496
 		{
497
-			if(count($added))
497
+			if (count($added))
498 498
 			{
499
-				$this->send_update(MSG_ADDED,$added,$old_event,$new_event);
499
+				$this->send_update(MSG_ADDED, $added, $old_event, $new_event);
500 500
 			}
501
-			if(count($modified))
501
+			if (count($modified))
502 502
 			{
503
-				$this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event);
503
+				$this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event);
504 504
 			}
505
-			if(count($deleted))
505
+			if (count($deleted))
506 506
 			{
507
-				$this->send_update(MSG_DISINVITE,$deleted,$new_event);
507
+				$this->send_update(MSG_DISINVITE, $deleted, $new_event);
508 508
 			}
509 509
 		}
510 510
 	}
@@ -521,11 +521,11 @@  discard block
 block discarded – undo
521 521
 	 * @param string $status of current user
522 522
 	 * @return boolean true = update requested, false otherwise
523 523
 	 */
524
-	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null)
524
+	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null)
525 525
 	{
526 526
 		if ($msg_type == MSG_ALARM)
527 527
 		{
528
-			return True;	// always True for now
528
+			return True; // always True for now
529 529
 		}
530 530
 		$want_update = 0;
531 531
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 		//
534 534
 		$msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED;
535 535
 
536
-		switch($ru = $part_prefs['calendar']['receive_updates'])
536
+		switch ($ru = $part_prefs['calendar']['receive_updates'])
537 537
 		{
538 538
 			case 'responses':
539 539
 				++$want_update;
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
 			default:
548 548
 				if (is_array($new_event) && is_array($old_event))
549 549
 				{
550
-					$diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])),
551
-						abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end'])));
550
+					$diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])),
551
+						abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end'])));
552 552
 					$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
553 553
 					if ($msg_type == MSG_MODIFIED && $diff > $check)
554 554
 					{
@@ -568,13 +568,13 @@  discard block
 block discarded – undo
568 568
 				if (!is_numeric($userid) && $role == 'CHAIR' &&
569 569
 					($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED))))
570 570
 				{
571
-					switch($msg_type)
571
+					switch ($msg_type)
572 572
 					{
573 573
 						case MSG_DELETED:	// treat deleting event as rejection to organizer
574 574
 							$msg_type = MSG_REJECTED;
575 575
 							break;
576 576
 						case MSG_ADDED:		// new events use added, but organizer needs status
577
-							switch($status[0])
577
+							switch ($status[0])
578 578
 							{
579 579
 								case 'A': $msg_type = MSG_ACCEPTED; break;
580 580
 								case 'R': $msg_type = MSG_REJECTED; break;
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 	 * @param string $role ='REQ-PARTICIPANT'
600 600
 	 * @return boolean true if user requested to be notified, false if not
601 601
 	 */
602
-	static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT')
602
+	static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT')
603 603
 	{
604 604
 		// check if email is from a user
605 605
 		if (is_numeric($user_or_email))
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 				)
624 624
 			);
625 625
 		}
626
-		switch($ical_method)
626
+		switch ($ical_method)
627 627
 		{
628 628
 			default:
629 629
 			case 'REQUEST':
@@ -648,9 +648,9 @@  discard block
 block discarded – undo
648 648
 	 * @param string& $action=null on return verbose name
649 649
 	 * @param string& $msg=null on return notification message
650 650
 	 */
651
-	function msg_type2ical_method($msg_type, &$action=null, &$msg=null)
651
+	function msg_type2ical_method($msg_type, &$action = null, &$msg = null)
652 652
 	{
653
-		switch($msg_type)
653
+		switch ($msg_type)
654 654
 		{
655 655
 			case MSG_DELETED:
656 656
 				$action = 'Canceled';
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 		$msg = $this->cal_prefs['notify'.$pref];
703 703
 		if (empty($msg))
704 704
 		{
705
-			$msg = $this->cal_prefs['notifyAdded'];	// use a default
705
+			$msg = $this->cal_prefs['notifyAdded']; // use a default
706 706
 		}
707 707
 		//error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'");
708 708
 		return $method;
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 	 * @param int $user =0 User who started the notify, default current user
719 719
 	 * @return bool true/false
720 720
 	 */
721
-	function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0)
721
+	function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0)
722 722
 	{
723 723
 		//error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event));
724 724
 		if (!is_array($to_notify))
@@ -730,11 +730,11 @@  discard block
 block discarded – undo
730 730
 		$owner = $old_event ? $old_event['owner'] : $new_event['owner'];
731 731
 		if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM)
732 732
 		{
733
-			$to_notify[$owner] = 'OCHAIR';	// always include the event-owner
733
+			$to_notify[$owner] = 'OCHAIR'; // always include the event-owner
734 734
 		}
735 735
 
736 736
 		// ignore events in the past (give a tolerance of 10 seconds for the script)
737
-		if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
737
+		if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
738 738
 		{
739 739
 			return False;
740 740
 		}
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 			$restore_tz = $tz;
745 745
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
746 746
 		}
747
-		$temp_user = $GLOBALS['egw_info']['user'];	// save user-date of the enviroment to restore it after
747
+		$temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after
748 748
 
749 749
 		if (!$user)
750 750
 		{
@@ -760,16 +760,16 @@  discard block
 block discarded – undo
760 760
 		$event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event;
761 761
 
762 762
 		// add all group-members to the notification, unless they are already participants
763
-		foreach($to_notify as $userid => $statusid)
763
+		foreach ($to_notify as $userid => $statusid)
764 764
 		{
765 765
 			if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' &&
766 766
 				($members = $GLOBALS['egw']->accounts->members($userid, true)))
767 767
 			{
768
-				foreach($members as $member)
768
+				foreach ($members as $member)
769 769
 				{
770 770
 					if (!isset($to_notify[$member]))
771 771
 					{
772
-						$to_notify[$member] = 'G';	// Group-invitation
772
+						$to_notify[$member] = 'G'; // Group-invitation
773 773
 					}
774 774
 				}
775 775
 			}
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
782 782
 		//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
783 783
 		$owner_prefs = $ics = null;
784
-		foreach($to_notify as $userid => $statusid)
784
+		foreach ($to_notify as $userid => $statusid)
785 785
 		{
786 786
 			$res_info = $quantity = $role = null;
787 787
 			calendar_so::split_status($statusid, $quantity, $role);
@@ -804,14 +804,14 @@  discard block
 block discarded – undo
804 804
 
805 805
 				if (!isset($userid))
806 806
 				{
807
-					if (empty($res_info['email'])) continue;	// no way to notify
807
+					if (empty($res_info['email'])) continue; // no way to notify
808 808
 					// check if event-owner wants non-EGroupware users notified
809 809
 					if (is_null($owner_prefs))
810 810
 					{
811 811
 						$preferences = new Api\Preferences($owner);
812 812
 						$owner_prefs = $preferences->read_repository();
813 813
 					}
814
-					if ($role != 'CHAIR' &&		// always notify externals CHAIRs
814
+					if ($role != 'CHAIR' && // always notify externals CHAIRs
815 815
 						(empty($owner_prefs['calendar']['notify_externals']) ||
816 816
 						$owner_prefs['calendar']['notify_externals'] == 'no'))
817 817
 					{
@@ -823,12 +823,12 @@  discard block
 block discarded – undo
823 823
 
824 824
 			if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g')
825 825
 			{
826
-				continue;	// dont notify rejected participants or groups
826
+				continue; // dont notify rejected participants or groups
827 827
 			}
828 828
 
829
-			if($userid != $GLOBALS['egw_info']['user']['account_id'] ||
829
+			if ($userid != $GLOBALS['egw_info']['user']['account_id'] ||
830 830
 				($userid == $GLOBALS['egw_info']['user']['account_id'] &&
831
-					$user_prefs['calendar']['receive_own_updates']==1) ||
831
+					$user_prefs['calendar']['receive_own_updates'] == 1) ||
832 832
 				$msg_type == MSG_ALARM)
833 833
 			{
834 834
 				$tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop)
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 					}
848 848
 					$part_prefs = $owner_prefs;
849 849
 					$part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals'];
850
-					$part_prefs['calendar']['update_format'] = 'ical';	// use ical format
850
+					$part_prefs['calendar']['update_format'] = 'ical'; // use ical format
851 851
 					$fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid;
852 852
 				}
853 853
 				$m_type = $msg_type;
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
876 876
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
877 877
 				$timeformat = $part_prefs['common']['timeformat'];
878
-				switch($timeformat)
878
+				switch ($timeformat)
879 879
 				{
880 880
 			  		case '24':
881 881
 						$timeformat = 'H:i';
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 						$timeformat = 'h:i a';
885 885
 						break;
886 886
 				}
887
-				$timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat;
887
+				$timeformat = $part_prefs['common']['dateformat'].', '.$timeformat;
888 888
 
889 889
 				$startdate->setTimezone($timezone);
890 890
 				$details['startdate'] = $startdate->format($timeformat);
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 				$details['enddate'] = $enddate->format($timeformat);
894 894
 
895 895
 				$modified->setTimezone($timezone);
896
-				$details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']);
896
+				$details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']);
897 897
 
898 898
 				if ($old_event != False)
899 899
 				{
@@ -902,15 +902,14 @@  discard block
 block discarded – undo
902 902
 				}
903 903
 				//error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]");
904 904
 
905
-				list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
905
+				list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
906 906
 				// alarm is NOT an iCal method, therefore we have to use extened (no iCal)
907
-				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
907
+				switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
908 908
 				{
909
-					case 'ical':
910
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
909
+					case 'ical' : if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
911 910
 						{
912 911
 							$calendar_ical = new calendar_ical();
913
-							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
912
+							$calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ
914 913
 							// we need to pass $event[id] so iCal class reads event again,
915 914
 							// as event is in user TZ, but iCal class expects server TZ!
916 915
 							$ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']),
@@ -929,11 +928,11 @@  discard block
 block discarded – undo
929 928
 					case 'extended':
930 929
 
931 930
 						$details_body = lang('Event Details follow').":\n";
932
-						foreach($event_arr as $key => $val)
931
+						foreach ($event_arr as $key => $val)
933 932
 						{
934
-							if(!empty($details[$key]))
933
+							if (!empty($details[$key]))
935 934
 							{
936
-								switch($key)
935
+								switch ($key)
937 936
 								{
938 937
 							 		case 'access':
939 938
 									case 'priority':
@@ -942,7 +941,7 @@  discard block
 block discarded – undo
942 941
 									case 'title':
943 942
 										break;
944 943
 									default:
945
-										$details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
944
+										$details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]);
946 945
 										break;
947 946
 							 	}
948 947
 							}
@@ -950,7 +949,7 @@  discard block
 block discarded – undo
950 949
 						break;
951 950
 				}
952 951
 				// send via notification_app
953
-				if($GLOBALS['egw_info']['apps']['notifications']['enabled'])
952
+				if ($GLOBALS['egw_info']['apps']['notifications']['enabled'])
954 953
 				{
955 954
 					try {
956 955
 						//error_log(__METHOD__."() notifying $userid from $senderid: $subject");
@@ -974,7 +973,7 @@  discard block
 block discarded – undo
974 973
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
975 974
 						$notification->set_popuplinks(array($details['link_arr']));
976 975
 
977
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
976
+						if (is_array($attachment)) { $notification->set_attachments(array($attachment)); }
978 977
 						$notification->send();
979 978
 					}
980 979
 					catch (Exception $exception) {
@@ -1011,14 +1010,14 @@  discard block
 block discarded – undo
1011 1010
 		return true;
1012 1011
 	}
1013 1012
 
1014
-	function get_update_message($event,$added)
1013
+	function get_update_message($event, $added)
1015 1014
 	{
1016 1015
 		$nul = null;
1017
-		$details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul);
1016
+		$details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul);
1018 1017
 
1019 1018
 		$notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified'];
1020 1019
 
1021
-		return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
1020
+		return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
1022 1021
 	}
1023 1022
 
1024 1023
 	/**
@@ -1032,37 +1031,37 @@  discard block
 block discarded – undo
1032 1031
 		//echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n";
1033 1032
 		$GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner'];
1034 1033
 
1035
-		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']);	// alarm[time] is in server-time, read requires user-time
1036
-		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user)))
1034
+		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time
1035
+		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user)))
1037 1036
 		{
1038
-			return False;	// event not found
1037
+			return False; // event not found
1039 1038
 		}
1040 1039
 		if ($alarm['all'])
1041 1040
 		{
1042 1041
 			$to_notify = $event['participants'];
1043 1042
 		}
1044
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1043
+		elseif ($this->check_perms(Acl::READ, $event))	// checks agains $this->owner set to $alarm[owner]
1045 1044
 		{
1046 1045
 			$to_notify[$alarm['owner']] = 'A';
1047 1046
 		}
1048 1047
 		else
1049 1048
 		{
1050
-			return False;	// no rights
1049
+			return False; // no rights
1051 1050
 		}
1052 1051
 		// need to load calendar translations and set currentapp, so calendar can reload a different lang
1053 1052
 		Api\Translation::add_app('calendar');
1054 1053
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
1055 1054
 
1056
-		$ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
1055
+		$ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']);
1057 1056
 
1058 1057
 		// create a new alarm for recuring events for the next event, if one exists
1059
-		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1)))
1058
+		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1)))
1060 1059
 		{
1061 1060
 			$alarm['time'] = $this->date2ts($event['start']) - $alarm['offset'];
1062 1061
 			unset($alarm['times']);
1063 1062
 			unset($alarm['next']);
1064 1063
 			//error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm));
1065
-			$this->save_alarm($alarm['cal_id'], $alarm, false);	// false = do NOT update timestamp, as nothing changed for iCal clients
1064
+			$this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients
1066 1065
 		}
1067 1066
 		return $ret;
1068 1067
 	}
@@ -1078,15 +1077,15 @@  discard block
 block discarded – undo
1078 1077
 	 * DEPRECATED: we allways (have to) update timestamp, as they are required for sync!
1079 1078
 	 * @return int|boolean $cal_id > 0 or false on error (eg. permission denied)
1080 1079
 	 */
1081
-	function save($event,$ignore_acl=false,$updateTS=true)
1080
+	function save($event, $ignore_acl = false, $updateTS = true)
1082 1081
 	{
1083 1082
 		unset($updateTS);
1084 1083
 		//error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)");
1085 1084
 
1086 1085
 		// check if user has the permission to update / create the event
1087
-		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) ||
1088
-			!$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) &&
1089
-			!$this->check_perms(Acl::ADD,0,$event['owner'])))
1086
+		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) ||
1087
+			!$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) &&
1088
+			!$this->check_perms(Acl::ADD, 0, $event['owner'])))
1090 1089
 		{
1091 1090
 			return false;
1092 1091
 		}
@@ -1131,19 +1130,19 @@  discard block
 block discarded – undo
1131 1130
 				$time->setUser();
1132 1131
 				$save_event['recur_enddate'] = Api\DateTime::to($time, 'ts');
1133 1132
 			}
1134
-			$timestamps = array('modified','created');
1133
+			$timestamps = array('modified', 'created');
1135 1134
 			// all-day events are handled in server time
1136 1135
 			$event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName();
1137 1136
 		}
1138 1137
 		else
1139 1138
 		{
1140
-			$timestamps = array('start','end','modified','created','recur_enddate','recurrence');
1139
+			$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence');
1141 1140
 		}
1142 1141
 		// we run all dates through date2ts, to adjust to server-time and the possible date-formats
1143
-		foreach($timestamps as $ts)
1142
+		foreach ($timestamps as $ts)
1144 1143
 		{
1145 1144
 			// we convert here from user-time to timestamps in server-time!
1146
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1145
+			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0;
1147 1146
 		}
1148 1147
 		// convert tzid name to integer tz_id, of set user default
1149 1148
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1153,7 +1152,7 @@  discard block
 block discarded – undo
1153 1152
 		// same with the recur exceptions
1154 1153
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
1155 1154
 		{
1156
-			foreach($event['recur_exception'] as &$date)
1155
+			foreach ($event['recur_exception'] as &$date)
1157 1156
 			{
1158 1157
 				if ($event['whole_day'])
1159 1158
 				{
@@ -1162,7 +1161,7 @@  discard block
 block discarded – undo
1162 1161
 				}
1163 1162
 				else
1164 1163
 				{
1165
-					$date = $this->date2ts($date,true);
1164
+					$date = $this->date2ts($date, true);
1166 1165
 				}
1167 1166
 			}
1168 1167
 			unset($date);
@@ -1170,7 +1169,7 @@  discard block
 block discarded – undo
1170 1169
 		// same with the alarms
1171 1170
 		if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start']))
1172 1171
 		{
1173
-			foreach($event['alarm'] as $id => &$alarm)
1172
+			foreach ($event['alarm'] as $id => &$alarm)
1174 1173
 			{
1175 1174
 				// remove alarms belonging to not longer existing or rejected participants
1176 1175
 				if ($alarm['owner'] && isset($event['participants']))
@@ -1188,15 +1187,14 @@  discard block
 block discarded – undo
1188 1187
 		// update all existing alarm times, in case alarm got moved and alarms are not include in $event
1189 1188
 		if ($old_event && is_array($old_event['alarm']) && isset($event['start']))
1190 1189
 		{
1191
-			foreach($old_event['alarm'] as $id => &$alarm)
1190
+			foreach ($old_event['alarm'] as $id => &$alarm)
1192 1191
 			{
1193 1192
 				if (!isset($event['alarm'][$id]))
1194 1193
 				{
1195 1194
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1196 1195
 					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1197 1196
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1198
-					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1199
-						$old_event['participants'][$alarm['owner']];
1197
+					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']];
1200 1198
 					if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R')
1201 1199
 					{
1202 1200
 						$this->so->save_alarm($event['id'], $alarm);
@@ -1222,7 +1220,7 @@  discard block
 block discarded – undo
1222 1220
 		}
1223 1221
 		$set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate'] : false;
1224 1222
 		$set_recurrences_start = 0;
1225
-		if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1223
+		if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1226 1224
 		{
1227 1225
 			$save_event['id'] = $cal_id;
1228 1226
 			// unset participants to enforce the default stati for all added recurrences
@@ -1233,7 +1231,7 @@  discard block
 block discarded – undo
1233 1231
 		// create links for new participants from addressbook, if configured
1234 1232
 		if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants'])
1235 1233
 		{
1236
-			foreach($event['participants'] as $uid => $status)
1234
+			foreach ($event['participants'] as $uid => $status)
1237 1235
 			{
1238 1236
 				$user_type = $user_id = null;
1239 1237
 				calendar_so::split_user($uid, $user_type, $user_id);
@@ -1246,7 +1244,7 @@  discard block
 block discarded – undo
1246 1244
 
1247 1245
 		// Update history
1248 1246
 		$tracking = new calendar_tracking($this);
1249
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1247
+		if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id;
1250 1248
 		$tracking->track($event, $old_event);
1251 1249
 
1252 1250
 		return $cal_id;
@@ -1261,16 +1259,16 @@  discard block
 block discarded – undo
1261 1259
 	 * @param array|int $event event array or id of the event
1262 1260
 	 * @return boolean
1263 1261
 	 */
1264
-	function check_status_perms($uid,$event)
1262
+	function check_status_perms($uid, $event)
1265 1263
 	{
1266 1264
 		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1267 1265
 		{
1268 1266
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1269 1267
 
1270
-			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1268
+			return $this->check_perms(Acl::EDIT, 0, $event['owner']);
1271 1269
 		}
1272 1270
 		// check if we have a category Acl for the event or not (null)
1273
-		$access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event);
1271
+		$access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event);
1274 1272
 		if (!is_null($access))
1275 1273
 		{
1276 1274
 			return $access;
@@ -1280,17 +1278,17 @@  discard block
 block discarded – undo
1280 1278
 		{
1281 1279
 			$resource = $this->resource_info($uid);
1282 1280
 
1283
-			return Acl::EDIT & $resource['rights'];
1281
+			return Acl::EDIT&$resource['rights'];
1284 1282
 		}
1285 1283
 		if (!is_array($event) && !($event = $this->read($event))) return false;
1286 1284
 
1287 1285
 		// regular user and groups (need to check memberships too)
1288 1286
 		if (!isset($event['participants'][$uid]))
1289 1287
 		{
1290
-			$memberships = $GLOBALS['egw']->accounts->memberships($uid,true);
1288
+			$memberships = $GLOBALS['egw']->accounts->memberships($uid, true);
1291 1289
 		}
1292 1290
 		$memberships[] = $uid;
1293
-		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid);
1291
+		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid);
1294 1292
 	}
1295 1293
 
1296 1294
 	/**
@@ -1304,16 +1302,16 @@  discard block
 block discarded – undo
1304 1302
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1305 1303
 	 * 	null = cat has no acl
1306 1304
 	 */
1307
-	function check_cat_acl($right,$event)
1305
+	function check_cat_acl($right, $event)
1308 1306
 	{
1309 1307
 		if (!is_array($event)) $event = $this->read($event);
1310 1308
 
1311 1309
 		$ret = null;
1312 1310
 		if ($event['category'])
1313 1311
 		{
1314
-			foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id)
1312
+			foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id)
1315 1313
 			{
1316
-				$access = self::has_cat_right($right,$cat_id,$this->user);
1314
+				$access = self::has_cat_right($right, $cat_id, $this->user);
1317 1315
 				if ($access === true)
1318 1316
 				{
1319 1317
 					$ret = true;
@@ -1321,7 +1319,7 @@  discard block
 block discarded – undo
1321 1319
 				}
1322 1320
 				if ($access === false)
1323 1321
 				{
1324
-					$ret = false;	// cat denies access --> check further cats
1322
+					$ret = false; // cat denies access --> check further cats
1325 1323
 				}
1326 1324
 			}
1327 1325
 		}
@@ -1342,12 +1340,12 @@  discard block
 block discarded – undo
1342 1340
 	 * @param int $cat_id =null null to return array with all cats
1343 1341
 	 * @return array with account_id => right pairs
1344 1342
 	 */
1345
-	public static function get_cat_rights($cat_id=null)
1343
+	public static function get_cat_rights($cat_id = null)
1346 1344
 	{
1347 1345
 		if (!isset(self::$cat_rights_cache))
1348 1346
 		{
1349
-			self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights',
1350
-				array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar'));
1347
+			self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights',
1348
+				array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar'));
1351 1349
 		}
1352 1350
 		//echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n";
1353 1351
 		return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache;
@@ -1360,7 +1358,7 @@  discard block
 block discarded – undo
1360 1358
 	 * @param int $user
1361 1359
 	 * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together
1362 1360
 	 */
1363
-	public static function set_cat_rights($cat_id,$user,$rights)
1361
+	public static function set_cat_rights($cat_id, $user, $rights)
1364 1362
 	{
1365 1363
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1366 1364
 		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
@@ -1370,15 +1368,15 @@  discard block
 block discarded – undo
1370 1368
 			if ($rights)
1371 1369
 			{
1372 1370
 				self::$cat_rights_cache['L'.$cat_id][$user] = $rights;
1373
-				$GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights);
1371
+				$GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights);
1374 1372
 			}
1375 1373
 			else
1376 1374
 			{
1377 1375
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1378 1376
 				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1379
-				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1377
+				$GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user);
1380 1378
 			}
1381
-			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
1379
+			Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache);
1382 1380
 		}
1383 1381
 	}
1384 1382
 
@@ -1389,9 +1387,9 @@  discard block
 block discarded – undo
1389 1387
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1390 1388
 	 * 	null = cat has no acl
1391 1389
 	 */
1392
-	public static function has_cat_right($right,$cat_id,$user)
1390
+	public static function has_cat_right($right, $cat_id, $user)
1393 1391
 	{
1394
-		static $cache=null;
1392
+		static $cache = null;
1395 1393
 
1396 1394
 		if (!isset($cache[$cat_id]))
1397 1395
 		{
@@ -1399,21 +1397,21 @@  discard block
 block discarded – undo
1399 1397
 			$cat_rights = self::get_cat_rights($cat_id);
1400 1398
 			if (!is_null($cat_rights))
1401 1399
 			{
1402
-				static $memberships=null;
1400
+				static $memberships = null;
1403 1401
 				if (is_null($memberships))
1404 1402
 				{
1405
-					$memberships = $GLOBALS['egw']->accounts->memberships($user,true);
1403
+					$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1406 1404
 					$memberships[] = $user;
1407 1405
 				}
1408
-				foreach($cat_rights as $uid => $value)
1406
+				foreach ($cat_rights as $uid => $value)
1409 1407
 				{
1410 1408
 					$all |= $value;
1411
-					if (in_array($uid,$memberships)) $own |= $value;
1409
+					if (in_array($uid, $memberships)) $own |= $value;
1412 1410
 				}
1413 1411
 			}
1414
-			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
1412
+			foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask)
1415 1413
 			{
1416
-				$cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask);
1414
+				$cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask);
1417 1415
 			}
1418 1416
 		}
1419 1417
 		//echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n";
@@ -1433,13 +1431,13 @@  discard block
 block discarded – undo
1433 1431
 	 * @param boolean $skip_notification =false true: do not send notification messages
1434 1432
 	 * @return int number of changed recurrences
1435 1433
 	 */
1436
-	function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false)
1434
+	function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false)
1437 1435
 	{
1438 1436
 		unset($updateTS);
1439 1437
 
1440 1438
 		$cal_id = is_array($event) ? $event['id'] : $event;
1441 1439
 		//echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n";
1442
-		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event)))
1440
+		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event)))
1443 1441
 		{
1444 1442
 			return false;
1445 1443
 		}
@@ -1448,16 +1446,16 @@  discard block
 block discarded – undo
1448 1446
 		if ($this->log)
1449 1447
 		{
1450 1448
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1451
-				"($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile);
1449
+				"($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile);
1452 1450
 		}
1453 1451
 		$old_event = $this->read($cal_id, $recur_date, false, 'server');
1454
-		if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0],
1455
-				is_numeric($uid)?$uid:substr($uid,1),$status,
1456
-				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1452
+		if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0],
1453
+				is_numeric($uid) ? $uid : substr($uid, 1), $status,
1454
+				$recur_date ? $this->date2ts($recur_date, true) : 0, $role)))
1457 1455
 		{
1458 1456
 			if ($status == 'R')	// remove alarms belonging to rejected participants
1459 1457
 			{
1460
-				foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1458
+				foreach (isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1461 1459
 				{
1462 1460
 					if ((string)$alarm['owner'] === (string)$uid)
1463 1461
 					{
@@ -1476,8 +1474,8 @@  discard block
 block discarded – undo
1476 1474
 			if (isset($status2msg[$status]) && !$skip_notification)
1477 1475
 			{
1478 1476
 				if (!is_array($event)) $event = $this->read($cal_id);
1479
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1480
-				$this->send_update($status2msg[$status],$event['participants'],$event);
1477
+				if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event
1478
+				$this->send_update($status2msg[$status], $event['participants'], $event);
1481 1479
 			}
1482 1480
 
1483 1481
 			// Update history
@@ -1497,14 +1495,14 @@  discard block
 block discarded – undo
1497 1495
 	 * @param int $recur_date =0 date to change, or 0 = all since now
1498 1496
 	 * @param boolean $skip_notification Do not send notifications.  Parameter passed on to set_status().
1499 1497
 	 */
1500
-	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1498
+	function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false)
1501 1499
 	{
1502 1500
 		if (!isset($new_event['participants'])) return;
1503 1501
 
1504 1502
 		// check the old list against the new list
1505 1503
 		foreach ($old_event['participants'] as $userid => $status)
1506 1504
   		{
1507
-            if (!isset($new_event['participants'][$userid])){
1505
+            if (!isset($new_event['participants'][$userid])) {
1508 1506
             	// Attendee will be deleted this way
1509 1507
             	$new_event['participants'][$userid] = 'G';
1510 1508
             }
@@ -1517,7 +1515,7 @@  discard block
 block discarded – undo
1517 1515
 		// write the changes
1518 1516
 		foreach ($new_event['participants'] as $userid => $status)
1519 1517
 		{
1520
-			$this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification);
1518
+			$this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification);
1521 1519
 		}
1522 1520
     }
1523 1521
 
@@ -1532,43 +1530,43 @@  discard block
 block discarded – undo
1532 1530
 	 * @param int &$exceptions_kept=null on return number of kept exceptions
1533 1531
 	 * @return boolean true on success, false on error (usually permission denied)
1534 1532
 	 */
1535
-	function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false,
1536
-		$delete_exceptions=true, &$exceptions_kept=null)
1533
+	function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false,
1534
+		$delete_exceptions = true, &$exceptions_kept = null)
1537 1535
 	{
1538 1536
 		//error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)");
1539
-		if (!($event = $this->read($cal_id,$recur_date)) ||
1540
-			!$ignore_acl && !$this->check_perms(Acl::DELETE,$event))
1537
+		if (!($event = $this->read($cal_id, $recur_date)) ||
1538
+			!$ignore_acl && !$this->check_perms(Acl::DELETE, $event))
1541 1539
 		{
1542 1540
 			return false;
1543 1541
 		}
1544 1542
 
1545 1543
 		// Don't send notification if the event has already been deleted
1546
-		if(!$event['deleted'] && !$skip_notification)
1544
+		if (!$event['deleted'] && !$skip_notification)
1547 1545
 		{
1548
-			$this->send_update(MSG_DELETED,$event['participants'],$event);
1546
+			$this->send_update(MSG_DELETED, $event['participants'], $event);
1549 1547
 		}
1550 1548
 
1551 1549
 		if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE)
1552 1550
 		{
1553 1551
 			$config = Api\Config::read('phpgwapi');
1554
-			if(!$config['calendar_delete_history'] || $event['deleted'])
1552
+			if (!$config['calendar_delete_history'] || $event['deleted'])
1555 1553
 			{
1556 1554
 				$this->so->delete($cal_id);
1557 1555
 
1558 1556
 				// delete all links to the event
1559
-				Link::unlink(0,'calendar',$cal_id);
1557
+				Link::unlink(0, 'calendar', $cal_id);
1560 1558
 			}
1561 1559
 			elseif ($config['calendar_delete_history'])
1562 1560
 			{
1563 1561
 				// mark all links to the event as deleted, but keep them
1564
-				Link::unlink(0,'calendar',$cal_id,'','','',true);
1562
+				Link::unlink(0, 'calendar', $cal_id, '', '', '', true);
1565 1563
 
1566 1564
 				$event['deleted'] = $this->now;
1567 1565
 				$this->save($event, $ignore_acl);
1568 1566
 				// Actually delete alarms
1569 1567
 				if (isset($event['alarm']) && is_array($event['alarm']))
1570 1568
 				{
1571
-					foreach($event['alarm'] as $id => $alarm)
1569
+					foreach ($event['alarm'] as $id => $alarm)
1572 1570
 					{
1573 1571
 						$this->delete_alarm($id);
1574 1572
 					}
@@ -1590,7 +1588,7 @@  discard block
 block discarded – undo
1590 1588
 						if (!($exception = $this->read($id))) continue;
1591 1589
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1592 1590
 						$exception['reference'] = $exception['recurrence'] = 0;
1593
-						$this->update($exception, true, true, false, true, $msg=null, true);
1591
+						$this->update($exception, true, true, false, true, $msg = null, true);
1594 1592
 						++$exceptions_kept;
1595 1593
 					}
1596 1594
 				}
@@ -1602,9 +1600,9 @@  discard block
 block discarded – undo
1602 1600
 			if ($event['alarm'])
1603 1601
 			{
1604 1602
 				$next_recurrance = null;
1605
-				foreach($event['alarm'] as &$alarm)
1603
+				foreach ($event['alarm'] as &$alarm)
1606 1604
 				{
1607
-					if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date))
1605
+					if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date))
1608 1606
 					{
1609 1607
 						//error_log(__METHOD__.__LINE__.'->'.array2string($recur_date));
1610 1608
 						//error_log(__METHOD__.__LINE__.array2string($event));
@@ -1612,12 +1610,12 @@  discard block
 block discarded – undo
1612 1610
 						{
1613 1611
 							$checkdate = $recur_date;
1614 1612
 							//if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset'];
1615
-							if (($e = $this->read($cal_id,$checkdate+1)))
1613
+							if (($e = $this->read($cal_id, $checkdate + 1)))
1616 1614
 							{
1617 1615
 								$next_recurrance = $this->date2ts($e['start']);
1618 1616
 							}
1619 1617
 						}
1620
-						$alarm['time'] = $this->date2ts($next_recurrance, true);	// user to server-time
1618
+						$alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time
1621 1619
 						$alarm['cal_id'] = $cal_id;
1622 1620
 						unset($alarm['times']);
1623 1621
 						unset($alarm['next']);
@@ -1631,7 +1629,7 @@  discard block
 block discarded – undo
1631 1629
 			$event = $this->read($cal_id);
1632 1630
 			//if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer;
1633 1631
 			$event['recur_exception'][] = $recur_date;
1634
-			$this->save($event);// updates the content-history
1632
+			$this->save($event); // updates the content-history
1635 1633
 		}
1636 1634
 		if ($event['reference'])
1637 1635
 		{
@@ -1649,19 +1647,19 @@  discard block
 block discarded – undo
1649 1647
 	 * @param array $disinvited
1650 1648
 	 * @return array
1651 1649
 	 */
1652
-	function _get_event_details($event,$action,&$event_arr,$disinvited=array())
1650
+	function _get_event_details($event, $action, &$event_arr, $disinvited = array())
1653 1651
 	{
1654 1652
 		$details = array(			// event-details for the notify-msg
1655 1653
 			'id'          => $event['id'],
1656 1654
 			'action'      => lang($action),
1657 1655
 		);
1658 1656
 		$event_arr = $this->event2array($event);
1659
-		foreach($event_arr as $key => $val)
1657
+		foreach ($event_arr as $key => $val)
1660 1658
 		{
1661 1659
 			if ($key == 'recur_type') $key = 'repetition';
1662 1660
 			$details[$key] = $val['data'];
1663 1661
 		}
1664
-		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
1662
+		$details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : '';
1665 1663
 
1666 1664
 		$event_arr['link']['field'] = lang('URL');
1667 1665
 		$eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state
@@ -1682,7 +1680,7 @@  discard block
 block discarded – undo
1682 1680
 		 */
1683 1681
 		$link_arr = array();
1684 1682
 		$link_arr['text'] = $event['title'];
1685
-		$link_arr['view'] = array(	'menuaction' => 'calendar.calendar_uiforms.edit',
1683
+		$link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit',
1686 1684
 									'cal_id' => $event['id'],
1687 1685
 									'date' => $eventStart_arr['full'],
1688 1686
 									);
@@ -1690,11 +1688,11 @@  discard block
 block discarded – undo
1690 1688
 		$details['link_arr'] = $link_arr;
1691 1689
 
1692 1690
 		$dis = array();
1693
-		foreach($disinvited as $uid)
1691
+		foreach ($disinvited as $uid)
1694 1692
 		{
1695 1693
 			$dis[] = $this->participant_name($uid);
1696 1694
 		}
1697
-		$details['disinvited'] = implode(', ',$dis);
1695
+		$details['disinvited'] = implode(', ', $dis);
1698 1696
 		return $details;
1699 1697
 	}
1700 1698
 
@@ -1718,13 +1716,13 @@  discard block
 block discarded – undo
1718 1716
 			'data'	=> $event['description']
1719 1717
 		);
1720 1718
 
1721
-		foreach(explode(',',$event['category']) as $cat_id)
1719
+		foreach (explode(',', $event['category']) as $cat_id)
1722 1720
 		{
1723 1721
 			$cat_string[] = stripslashes(Api\Categories::id2name($cat_id));
1724 1722
 		}
1725 1723
 		$var['category'] = Array(
1726 1724
 			'field'	=> lang('Category'),
1727
-			'data'	=> implode(', ',$cat_string)
1725
+			'data'	=> implode(', ', $cat_string)
1728 1726
 		);
1729 1727
 
1730 1728
 		$var['location'] = Array(
@@ -1770,7 +1768,7 @@  discard block
 block discarded – undo
1770 1768
 
1771 1769
 		if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants']))
1772 1770
 		{
1773
-			$participants = $this->participants($event,true);
1771
+			$participants = $this->participants($event, true);
1774 1772
 		}
1775 1773
 		$var['participants'] = Array(
1776 1774
 			'field'	=> lang('Participants'),
@@ -1793,26 +1791,26 @@  discard block
 block discarded – undo
1793 1791
 	 * @param array $old_event =null event-data in the DB before calling save
1794 1792
 	 * @param string $type ='update'
1795 1793
 	 */
1796
-	function log2file($event2save,$event_saved,$old_event=null,$type='update')
1794
+	function log2file($event2save, $event_saved, $old_event = null, $type = 'update')
1797 1795
 	{
1798
-		if (!($f = fopen($this->log_file,'a')))
1796
+		if (!($f = fopen($this->log_file, 'a')))
1799 1797
 		{
1800 1798
 			echo "<p>error opening '$this->log_file' !!!</p>\n";
1801 1799
 			return false;
1802 1800
 		}
1803
-		fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1804
-		fwrite($f,"Time: time to save / saved time read back / old time before save\n");
1805
-		foreach(array('start','end') as $name)
1801
+		fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1802
+		fwrite($f, "Time: time to save / saved time read back / old time before save\n");
1803
+		foreach (array('start', 'end') as $name)
1806 1804
 		{
1807
-			fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1808
-				$this->format_date($event_saved[$name]) .' / '.
1805
+			fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1806
+				$this->format_date($event_saved[$name]).' / '.
1809 1807
 				(is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n");
1810 1808
 		}
1811
-		foreach(array('event2save','event_saved','old_event') as $name)
1809
+		foreach (array('event2save', 'event_saved', 'old_event') as $name)
1812 1810
 		{
1813
-			fwrite($f,$name.' = '.print_r($$name,true));
1811
+			fwrite($f, $name.' = '.print_r($$name, true));
1814 1812
 		}
1815
-		fwrite($f,"\n");
1813
+		fwrite($f, "\n");
1816 1814
 		fclose($f);
1817 1815
 
1818 1816
 		return true;
@@ -1833,14 +1831,14 @@  discard block
 block discarded – undo
1833 1831
 		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1834 1832
 
1835 1833
 		$time = new Api\DateTime($event['start']);
1836
-		if(!is_array($event['alarm']))
1834
+		if (!is_array($event['alarm']))
1837 1835
 		{
1838 1836
 			$event['alarm'] = $this->so->read_alarms($event['id']);
1839 1837
 		}
1840 1838
 
1841
-		foreach($event['alarm'] as &$alarm)
1839
+		foreach ($event['alarm'] as &$alarm)
1842 1840
 		{
1843
-			if($event['recur_type'] != MCAL_RECUR_NONE)
1841
+			if ($event['recur_type'] != MCAL_RECUR_NONE)
1844 1842
 			{
1845 1843
 				calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts'));
1846 1844
 			}
@@ -1860,14 +1858,14 @@  discard block
 block discarded – undo
1860 1858
 	 * @param boolean $update_modified =true call update modified, default true
1861 1859
 	 * @return string id of the alarm, or false on error (eg. no perms)
1862 1860
 	 */
1863
-	function save_alarm($cal_id, $alarm, $update_modified=true)
1861
+	function save_alarm($cal_id, $alarm, $update_modified = true)
1864 1862
 	{
1865
-		if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1863
+		if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1866 1864
 		{
1867 1865
 			//echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>";
1868
-			return false;	// no rights to add the alarm
1866
+			return false; // no rights to add the alarm
1869 1867
 		}
1870
-		$alarm['time'] = $this->date2ts($alarm['time'],true);	// user to server-time
1868
+		$alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time
1871 1869
 
1872 1870
 		return $this->so->save_alarm($cal_id, $alarm, $update_modified);
1873 1871
 	}
@@ -1880,11 +1878,11 @@  discard block
 block discarded – undo
1880 1878
 	 */
1881 1879
 	function delete_alarm($id)
1882 1880
 	{
1883
-		list(,$cal_id) = explode(':',$id);
1881
+		list(,$cal_id) = explode(':', $id);
1884 1882
 
1885
-		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1883
+		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1886 1884
 		{
1887
-			return false;	// no rights to delete the alarm
1885
+			return false; // no rights to delete the alarm
1888 1886
 		}
1889 1887
 
1890 1888
 		return $this->so->delete_alarm($id);
@@ -1899,13 +1897,13 @@  discard block
 block discarded – undo
1899 1897
 	 *  by the ones the user normally does not see due to category permissions - used to preserve categories
1900 1898
 	 * @return array category ids (found, added and preserved categories)
1901 1899
 	 */
1902
-	function find_or_add_categories($catname_list, $old_event=null)
1900
+	function find_or_add_categories($catname_list, $old_event = null)
1903 1901
 	{
1904 1902
 		if (is_array($old_event) || $old_event > 0)
1905 1903
 		{
1906 1904
 			// preserve categories without users read access
1907 1905
 			if (!is_array($old_event)) $old_event = $this->read($old_event);
1908
-			$old_categories = explode(',',$old_event['category']);
1906
+			$old_categories = explode(',', $old_event['category']);
1909 1907
 			$old_cats_preserve = array();
1910 1908
 			if (is_array($old_categories) && count($old_categories) > 0)
1911 1909
 			{
@@ -1959,7 +1957,7 @@  discard block
 block discarded – undo
1959 1957
 	{
1960 1958
 		if (!is_array($cat_id_list))
1961 1959
 		{
1962
-			$cat_id_list = explode(',',$cat_id_list);
1960
+			$cat_id_list = explode(',', $cat_id_list);
1963 1961
 		}
1964 1962
 		$cat_list = array();
1965 1963
 		foreach ($cat_id_list as $cat_id)
@@ -1984,7 +1982,7 @@  discard block
 block discarded – undo
1984 1982
 	 *                              master	-> try to find a releated series master
1985 1983
 	 * @return array calendar_ids of matching entries
1986 1984
 	 */
1987
-	function find_event($event, $filter='exact')
1985
+	function find_event($event, $filter = 'exact')
1988 1986
 	{
1989 1987
 		$matchingEvents = array();
1990 1988
 		$query = array();
@@ -1992,14 +1990,14 @@  discard block
 block discarded – undo
1992 1990
 		if ($this->log)
1993 1991
 		{
1994 1992
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1995
-				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
1993
+				"($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile);
1996 1994
 		}
1997 1995
 
1998 1996
 		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
1999 1997
 
2000 1998
 		if ($filter == 'master')
2001 1999
 		{
2002
-			$query[] = 'recur_type!='. MCAL_RECUR_NONE;
2000
+			$query[] = 'recur_type!='.MCAL_RECUR_NONE;
2003 2001
 			$query['cal_recurrence'] = 0;
2004 2002
 		}
2005 2003
 		elseif ($filter == 'exact')
@@ -2020,14 +2018,14 @@  discard block
 block discarded – undo
2020 2018
 			if ($this->log)
2021 2019
 			{
2022 2020
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2023
-					'(' . $event['id'] . ")[EventID]\n",3,$this->logfile);
2021
+					'('.$event['id'].")[EventID]\n", 3, $this->logfile);
2024 2022
 			}
2025 2023
 			if (($egwEvent = $this->read($event['id'], 0, false, 'server')))
2026 2024
 			{
2027 2025
 				if ($this->log)
2028 2026
 				{
2029 2027
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2030
-						'()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile);
2028
+						'()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile);
2031 2029
 				}
2032 2030
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE &&
2033 2031
 					(empty($event['uid']) || $event['uid'] == $egwEvent['uid']))
@@ -2046,7 +2044,7 @@  discard block
 block discarded – undo
2046 2044
 						$exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']);
2047 2045
 						if (in_array($event['recurrence'], $exceptions))
2048 2046
 						{
2049
-							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2047
+							$matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence'];
2050 2048
 						}
2051 2049
 					}
2052 2050
 				} elseif ($filter != 'master' && ($filter == 'exact' ||
@@ -2065,19 +2063,19 @@  discard block
 block discarded – undo
2065 2063
 
2066 2064
 		// only query calendars of users, we have READ-grants from
2067 2065
 		$users = array();
2068
-		foreach(array_keys($this->grants) as $user)
2066
+		foreach (array_keys($this->grants) as $user)
2069 2067
 		{
2070 2068
 			$user = trim($user);
2071
-			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2069
+			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user))
2072 2070
 			{
2073
-				if ($user && !in_array($user,$users))	// already added?
2071
+				if ($user && !in_array($user, $users))	// already added?
2074 2072
 				{
2075 2073
 					$users[] = $user;
2076 2074
 				}
2077 2075
 			}
2078 2076
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2079 2077
 			{
2080
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2078
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
2081 2079
 			}
2082 2080
 			// the further code is only for real users
2083 2081
 			if (!is_numeric($user)) continue;
@@ -2088,7 +2086,7 @@  discard block
 block discarded – undo
2088 2086
 				$members = $GLOBALS['egw']->accounts->members($user, true);
2089 2087
 				if (is_array($members))
2090 2088
 				{
2091
-					foreach($members as $member)
2089
+					foreach ($members as $member)
2092 2090
 					{
2093 2091
 						// use only members which gave the user a read-grant
2094 2092
 						if (!in_array($member, $users) &&
@@ -2104,7 +2102,7 @@  discard block
 block discarded – undo
2104 2102
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
2105 2103
 				if (is_array($memberships))
2106 2104
 				{
2107
-					foreach($memberships as $group)
2105
+					foreach ($memberships as $group)
2108 2106
 					{
2109 2107
 						if (!in_array($group, $users))
2110 2108
 						{
@@ -2130,24 +2128,24 @@  discard block
 block discarded – undo
2130 2128
 
2131 2129
 				// check length with some tolerance
2132 2130
 				$length = $event['end'] - $event['start'] - $delta;
2133
-				$query[] = ('(cal_end-cal_start)>' . $length);
2131
+				$query[] = ('(cal_end-cal_start)>'.$length);
2134 2132
 				$length += 2 * $delta;
2135
-				$query[] = ('(cal_end-cal_start)<' . $length);
2136
-				$query[] = ('cal_start>' . ($event['start'] - 86400));
2137
-				$query[] = ('cal_start<' . ($event['start'] + 86400));
2133
+				$query[] = ('(cal_end-cal_start)<'.$length);
2134
+				$query[] = ('cal_start>'.($event['start'] - 86400));
2135
+				$query[] = ('cal_start<'.($event['start'] + 86400));
2138 2136
 			}
2139 2137
 			elseif (isset($event['start']))
2140 2138
 			{
2141 2139
 				if ($filter == 'relax')
2142 2140
 				{
2143
-					$query[] = ('cal_start>' . ($event['start'] - 3600));
2144
-					$query[] = ('cal_start<' . ($event['start'] + 3600));
2141
+					$query[] = ('cal_start>'.($event['start'] - 3600));
2142
+					$query[] = ('cal_start<'.($event['start'] + 3600));
2145 2143
 				}
2146 2144
 				else
2147 2145
 				{
2148 2146
 					// we accept a tiny tolerance
2149
-					$query[] = ('cal_start>' . ($event['start'] - 2));
2150
-					$query[] = ('cal_start<' . ($event['start'] + 2));
2147
+					$query[] = ('cal_start>'.($event['start'] - 2));
2148
+					$query[] = ('cal_start<'.($event['start'] + 2));
2151 2149
 				}
2152 2150
 			}
2153 2151
 			if ($filter == 'relax')
@@ -2170,14 +2168,14 @@  discard block
 block discarded – undo
2170 2168
 			if ($this->log)
2171 2169
 			{
2172 2170
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2173
-					'(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile);
2171
+					'('.$event['uid'].")[EventUID]\n", 3, $this->logfile);
2174 2172
 			}
2175 2173
 		}
2176 2174
 
2177 2175
 		if ($this->log)
2178 2176
 		{
2179 2177
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2180
-				'[QUERY]: ' . array2string($query)."\n",3,$this->logfile);
2178
+				'[QUERY]: '.array2string($query)."\n", 3, $this->logfile);
2181 2179
 		}
2182 2180
 		if (!count($users) || !($foundEvents =
2183 2181
 			$this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query))))
@@ -2185,19 +2183,19 @@  discard block
 block discarded – undo
2185 2183
 			if ($this->log)
2186 2184
 			{
2187 2185
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2188
-				"[NO MATCH]\n",3,$this->logfile);
2186
+				"[NO MATCH]\n", 3, $this->logfile);
2189 2187
 			}
2190 2188
 			return $matchingEvents;
2191 2189
 		}
2192 2190
 
2193 2191
 		$pseudos = array();
2194 2192
 
2195
-		foreach($foundEvents as $egwEvent)
2193
+		foreach ($foundEvents as $egwEvent)
2196 2194
 		{
2197 2195
 			if ($this->log)
2198 2196
 			{
2199 2197
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2200
-					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2198
+					'[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile);
2201 2199
 			}
2202 2200
 
2203 2201
 			if (in_array($egwEvent['id'], $matchingEvents)) continue;
@@ -2271,7 +2269,7 @@  discard block
 block discarded – undo
2271 2269
 						if (in_array($event['recurrence'], $exceptions))
2272 2270
 						{
2273 2271
 							// We found a pseudo exception
2274
-							$matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']);
2272
+							$matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']);
2275 2273
 							break;
2276 2274
 						}
2277 2275
 					}
@@ -2289,7 +2287,7 @@  discard block
 block discarded – undo
2289 2287
 						if ($this->log)
2290 2288
 						{
2291 2289
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2292
-							"() egwEvent length does not match!\n",3,$this->logfile);
2290
+							"() egwEvent length does not match!\n", 3, $this->logfile);
2293 2291
 						}
2294 2292
 						continue;
2295 2293
 					}
@@ -2301,7 +2299,7 @@  discard block
 block discarded – undo
2301 2299
 						if ($this->log)
2302 2300
 						{
2303 2301
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2304
-							"() egwEvent is not a whole-day event!\n",3,$this->logfile);
2302
+							"() egwEvent is not a whole-day event!\n", 3, $this->logfile);
2305 2303
 						}
2306 2304
 						continue;
2307 2305
 					}
@@ -2322,8 +2320,8 @@  discard block
 block discarded – undo
2322 2320
 					if ($this->log)
2323 2321
 					{
2324 2322
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2325
-							"() event[$key] differ: '" . $event[$key] .
2326
-							"' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile);
2323
+							"() event[$key] differ: '".$event[$key].
2324
+							"' <> '".$egwEvent[$key]."'\n", 3, $this->logfile);
2327 2325
 					}
2328 2326
 					continue 2; // next foundEvent
2329 2327
 				}
@@ -2341,7 +2339,7 @@  discard block
 block discarded – undo
2341 2339
 						if ($this->log)
2342 2340
 						{
2343 2341
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2344
-							"() egwEvent category $cat_id is missing!\n",3,$this->logfile);
2342
+							"() egwEvent category $cat_id is missing!\n", 3, $this->logfile);
2345 2343
 						}
2346 2344
 						continue 2;
2347 2345
 					}
@@ -2353,7 +2351,7 @@  discard block
 block discarded – undo
2353 2351
 					{
2354 2352
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2355 2353
 							'() event has additional categories:'
2356
-							. array2string($newCategories)."\n",3,$this->logfile);
2354
+							. array2string($newCategories)."\n", 3, $this->logfile);
2357 2355
 					}
2358 2356
 					continue;
2359 2357
 				}
@@ -2373,7 +2371,7 @@  discard block
 block discarded – undo
2373 2371
 							if ($this->log)
2374 2372
 							{
2375 2373
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2376
-								"() additional event['participants']: $attendee\n",3,$this->logfile);
2374
+								"() additional event['participants']: $attendee\n", 3, $this->logfile);
2377 2375
 							}
2378 2376
 							continue 2;
2379 2377
 						}
@@ -2396,8 +2394,8 @@  discard block
 block discarded – undo
2396 2394
 						if ($this->log)
2397 2395
 						{
2398 2396
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2399
-								'() missing event[participants]: ' .
2400
-								array2string($egwEvent['participants'])."\n",3,$this->logfile);
2397
+								'() missing event[participants]: '.
2398
+								array2string($egwEvent['participants'])."\n", 3, $this->logfile);
2401 2399
 						}
2402 2400
 						continue;
2403 2401
 					}
@@ -2409,7 +2407,7 @@  discard block
 block discarded – undo
2409 2407
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE)
2410 2408
 				{
2411 2409
 					// We found a pseudo Exception
2412
-					$pseudos[] = $egwEvent['id'] . ':' . $event['start'];
2410
+					$pseudos[] = $egwEvent['id'].':'.$event['start'];
2413 2411
 					continue;
2414 2412
 				}
2415 2413
 			}
@@ -2431,7 +2429,7 @@  discard block
 block discarded – undo
2431 2429
 							if ($this->log)
2432 2430
 							{
2433 2431
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2434
-								"() additional event['recur_exception']: $day\n",3,$this->logfile);
2432
+								"() additional event['recur_exception']: $day\n", 3, $this->logfile);
2435 2433
 							}
2436 2434
 							continue 2;
2437 2435
 						}
@@ -2441,8 +2439,8 @@  discard block
 block discarded – undo
2441 2439
 						if ($this->log)
2442 2440
 						{
2443 2441
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2444
-								'() missing event[recur_exception]: ' .
2445
-								array2string($event['recur_exception'])."\n",3,$this->logfile);
2442
+								'() missing event[recur_exception]: '.
2443
+								array2string($event['recur_exception'])."\n", 3, $this->logfile);
2446 2444
 						}
2447 2445
 						continue;
2448 2446
 					}
@@ -2457,8 +2455,8 @@  discard block
 block discarded – undo
2457 2455
 						if ($this->log)
2458 2456
 						{
2459 2457
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2460
-								"() events[$key] differ: " . $event[$key] .
2461
-								' <> ' . $egwEvent[$key]."\n",3,$this->logfile);
2458
+								"() events[$key] differ: ".$event[$key].
2459
+								' <> '.$egwEvent[$key]."\n", 3, $this->logfile);
2462 2460
 						}
2463 2461
 						continue 2;
2464 2462
 					}
@@ -2474,7 +2472,7 @@  discard block
 block discarded – undo
2474 2472
 			if ($this->log)
2475 2473
 			{
2476 2474
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2477
-					"() new exception for series found.\n",3,$this->logfile);
2475
+					"() new exception for series found.\n", 3, $this->logfile);
2478 2476
 			}
2479 2477
 			$matchingEvents = array();
2480 2478
 		}
@@ -2485,7 +2483,7 @@  discard block
 block discarded – undo
2485 2483
 		if ($this->log)
2486 2484
 		{
2487 2485
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2488
-				'[MATCHES]:' . array2string($matches)."\n",3,$this->logfile);
2486
+				'[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile);
2489 2487
 		}
2490 2488
 		return $matches;
2491 2489
 	}
@@ -2558,7 +2556,7 @@  discard block
 block discarded – undo
2558 2556
 				if ($this->log)
2559 2557
 				{
2560 2558
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2561
-					"()[MASTER]: $eventID\n",3,$this->logfile);
2559
+					"()[MASTER]: $eventID\n", 3, $this->logfile);
2562 2560
 				}
2563 2561
 				$type = 'SERIES-EXCEPTION';
2564 2562
 				if (($master_event = $this->read($eventID, 0, false, 'server')))
@@ -2579,7 +2577,7 @@  discard block
 block discarded – undo
2579 2577
 					}
2580 2578
 					elseif (in_array($event['start'], $master_event['recur_exception']))
2581 2579
 					{
2582
-						$type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2580
+						$type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2583 2581
 						$recurrence_event = $master_event;
2584 2582
 						$recurrence_event['start'] = $event['start'];
2585 2583
 						$recurrence_event['end'] -= $master_event['start'] - $event['start'];
@@ -2596,8 +2594,8 @@  discard block
 block discarded – undo
2596 2594
 							if ($this->log)
2597 2595
 							{
2598 2596
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2599
-									'() try occurrence ' . $egw_rrule->current()
2600
-									. " ($occurrence)\n",3,$this->logfile);
2597
+									'() try occurrence '.$egw_rrule->current()
2598
+									. " ($occurrence)\n", 3, $this->logfile);
2601 2599
 							}
2602 2600
 							if ($event['start'] == $occurrence)
2603 2601
 							{
@@ -2630,8 +2628,8 @@  discard block
 block discarded – undo
2630 2628
 			// default if we cannot find a proof for a fundamental change
2631 2629
 			// the recurrence_event is the master event with start and end adjusted to the recurrence
2632 2630
 			// check for changed data
2633
-			foreach (array('start','end','uid','title','location','description',
2634
-				'priority','public','special','non_blocking') as $key)
2631
+			foreach (array('start', 'end', 'uid', 'title', 'location', 'description',
2632
+				'priority', 'public', 'special', 'non_blocking') as $key)
2635 2633
 			{
2636 2634
 				if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key])
2637 2635
 				{
@@ -2689,10 +2687,10 @@  discard block
 block discarded – undo
2689 2687
      * @param &$event	the event we are working on
2690 2688
      *
2691 2689
      */
2692
-    function server2usertime (&$event)
2690
+    function server2usertime(&$event)
2693 2691
     {
2694 2692
 		// we run all dates through date2usertime, to adjust to user-time
2695
-		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2693
+		foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts)
2696 2694
 		{
2697 2695
 			// we convert here from server-time to timestamps in user-time!
2698 2696
 			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
@@ -2700,7 +2698,7 @@  discard block
 block discarded – undo
2700 2698
 		// same with the recur exceptions
2701 2699
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
2702 2700
 		{
2703
-			foreach($event['recur_exception'] as $n => $date)
2701
+			foreach ($event['recur_exception'] as $n => $date)
2704 2702
 			{
2705 2703
 				$event['recur_exception'][$n] = $this->date2usertime($date);
2706 2704
 			}
@@ -2708,7 +2706,7 @@  discard block
 block discarded – undo
2708 2706
 		// same with the alarms
2709 2707
 		if (isset($event['alarm']) && is_array($event['alarm']))
2710 2708
 		{
2711
-			foreach($event['alarm'] as $id => $alarm)
2709
+			foreach ($event['alarm'] as $id => $alarm)
2712 2710
 			{
2713 2711
 				$event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']);
2714 2712
 			}
@@ -2725,7 +2723,7 @@  discard block
 block discarded – undo
2725 2723
 	{
2726 2724
 		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2727 2725
 		{
2728
-			$this->so->purge(time() - 365*24*3600*(float)$age);
2726
+			$this->so->purge(time() - 365 * 24 * 3600 * (float)$age);
2729 2727
 		}
2730 2728
 	}
2731 2729
 }
Please login to merge, or discard this patch.
Braces   +212 added lines, -54 removed lines patch added patch discarded remove patch
@@ -85,11 +85,17 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	function __construct()
87 87
 	{
88
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
88
+		if ($this->debug > 0)
89
+		{
90
+			$this->debug_message('calendar_boupdate::__construct() started',True);
91
+		}
89 92
 
90 93
 		parent::__construct();	// calling the parent constructor
91 94
 
92
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
95
+		if ($this->debug > 0)
96
+		{
97
+			$this->debug_message('calendar_boupdate::__construct() finished',True);
98
+		}
93 99
 	}
94 100
 
95 101
 	/**
@@ -119,7 +125,10 @@  discard block
 block discarded – undo
119 125
 	function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
120 126
 	{
121 127
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
122
-		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
128
+		if (!is_array($messages))
129
+		{
130
+			$messages = $messages ? (array)$messages : array();
131
+		}
123 132
 
124 133
 		if ($this->debug > 1 || $this->debug == 'update')
125 134
 		{
@@ -139,10 +148,13 @@  discard block
 block discarded – undo
139 148
 
140 149
 		$status_reset_to_unknown = false;
141 150
 
142
-		if (($new_event = !$event['id']))	// some defaults for new entries
151
+		if (($new_event = !$event['id']))
152
+		{
153
+			// some defaults for new entries
143 154
 		{
144 155
 			// if no owner given, set user to owner
145 156
 			if (!$event['owner']) $event['owner'] = $this->user;
157
+		}
146 158
 			// set owner as participant if none is given
147 159
 			if (!is_array($event['participants']) || !count($event['participants']))
148 160
 			{
@@ -182,7 +194,10 @@  discard block
 block discarded – undo
182 194
 		// check category based ACL
183 195
 		if ($event['category'])
184 196
 		{
185
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
197
+			if (!is_array($event['category']))
198
+			{
199
+				$event['category'] = explode(',',$event['category']);
200
+			}
186 201
 			if (!$old_event || !isset($old_event['category']))
187 202
 			{
188 203
 				$old_event['category'] = array();
@@ -235,18 +250,28 @@  discard block
 block discarded – undo
235 250
 			$types_with_quantity = array();
236 251
 			foreach($this->resources as $type => $data)
237 252
 			{
238
-				if ($data['max_quantity']) $types_with_quantity[] = $type;
253
+				if ($data['max_quantity'])
254
+				{
255
+					$types_with_quantity[] = $type;
256
+				}
239 257
 			}
240 258
 			// get all NOT rejected participants and evtl. their quantity
241 259
 			$quantity = $users = array();
242 260
 			foreach($event['participants'] as $uid => $status)
243 261
 			{
244 262
 				calendar_so::split_status($status,$q,$r);
245
-				if ($status[0] == 'R') continue;	// ignore rejected participants
263
+				if ($status[0] == 'R')
264
+				{
265
+					continue;
266
+				}
267
+				// ignore rejected participants
246 268
 
247
-				if ($uid < 0)	// group, check it's members too
269
+				if ($uid < 0)
270
+				{
271
+					// group, check it's members too
248 272
 				{
249 273
 					$users += (array)$GLOBALS['egw']->accounts->members($uid,true);
274
+				}
250 275
 					$users = array_unique($users);
251 276
 				}
252 277
 				$users[] = $uid;
@@ -277,10 +302,13 @@  discard block
 block discarded – undo
277 302
 			{
278 303
 				if ($overlap['id'] == $event['id'] ||	// that's the event itself
279 304
 					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
280
-					$overlap['non_blocking'])			// that's a non_blocking event
305
+					$overlap['non_blocking'])
306
+				{
307
+					// that's a non_blocking event
281 308
 				{
282 309
 					continue;
283 310
 				}
311
+				}
284 312
 				if ($this->debug > 3 || $this->debug == 'update')
285 313
 				{
286 314
 					$this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap);
@@ -438,7 +466,11 @@  discard block
 block discarded – undo
438 466
 	 */
439 467
 	public function check_acl_invite($uid)
440 468
 	{
441
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
469
+		if (!is_numeric($uid))
470
+		{
471
+			return true;
472
+		}
473
+		// nothing implemented for resources so far
442 474
 
443 475
 		if (!$this->require_acl_invite)
444 476
 		{
@@ -778,14 +810,20 @@  discard block
 block discarded – undo
778 810
 		$startdate = new Api\DateTime($event['start']);
779 811
 		$enddate = new Api\DateTime($event['end']);
780 812
 		$modified = new Api\DateTime($event['modified']);
781
-		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
813
+		if ($old_event)
814
+		{
815
+			$olddate = new Api\DateTime($old_event['start']);
816
+		}
782 817
 		//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
783 818
 		$owner_prefs = $ics = null;
784 819
 		foreach($to_notify as $userid => $statusid)
785 820
 		{
786 821
 			$res_info = $quantity = $role = null;
787 822
 			calendar_so::split_status($statusid, $quantity, $role);
788
-			if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
823
+			if ($this->debug > 0)
824
+			{
825
+				error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
826
+			}
789 827
 
790 828
 			if (!is_numeric($userid))
791 829
 			{
@@ -804,7 +842,11 @@  discard block
 block discarded – undo
804 842
 
805 843
 				if (!isset($userid))
806 844
 				{
807
-					if (empty($res_info['email'])) continue;	// no way to notify
845
+					if (empty($res_info['email']))
846
+					{
847
+						continue;
848
+					}
849
+					// no way to notify
808 850
 					// check if event-owner wants non-EGroupware users notified
809 851
 					if (is_null($owner_prefs))
810 852
 					{
@@ -868,11 +910,20 @@  discard block
 block discarded – undo
868 910
 				$details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event,
869 911
 					$action, $event_arr, $disinvited);
870 912
 				$details['to-fullname'] = $fullname;
871
-				if (isset($tfn)) $details['to-firstname'] = $tfn;
872
-				if (isset($tln)) $details['to-lastname'] = $tln;
913
+				if (isset($tfn))
914
+				{
915
+					$details['to-firstname'] = $tfn;
916
+				}
917
+				if (isset($tln))
918
+				{
919
+					$details['to-lastname'] = $tln;
920
+				}
873 921
 
874 922
 				// event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account
875
-				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
923
+				if (!isset($part_prefs['common']['tz']))
924
+				{
925
+					$part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
926
+				}
876 927
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
877 928
 				$timeformat = $part_prefs['common']['timeformat'];
878 929
 				switch($timeformat)
@@ -907,9 +958,12 @@  discard block
 block discarded – undo
907 958
 				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
908 959
 				{
909 960
 					case 'ical':
910
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
961
+						if (is_null($ics) || $m_type != $msg_type)
962
+						{
963
+							// need different ical for organizer notification
911 964
 						{
912 965
 							$calendar_ical = new calendar_ical();
966
+						}
913 967
 							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
914 968
 							// we need to pass $event[id] so iCal class reads event again,
915 969
 							// as event is in user TZ, but iCal class expects server TZ!
@@ -923,7 +977,10 @@  discard block
 block discarded – undo
923 977
 							'encoding' => '8bit',
924 978
 							'type' => 'text/calendar; method='.$method,
925 979
 						);
926
-						if ($m_type != $msg_type) unset($ics);
980
+						if ($m_type != $msg_type)
981
+						{
982
+							unset($ics);
983
+						}
927 984
 						$subject = isset($cleared_event) ? $cleared_event['title'] : $event['title'];
928 985
 						// fall through
929 986
 					case 'extended':
@@ -974,7 +1031,9 @@  discard block
 block discarded – undo
974 1031
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
975 1032
 						$notification->set_popuplinks(array($details['link_arr']));
976 1033
 
977
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1034
+						if(is_array($attachment))
1035
+						{
1036
+$notification->set_attachments(array($attachment)); }
978 1037
 						$notification->send();
979 1038
 					}
980 1039
 					catch (Exception $exception) {
@@ -1006,7 +1065,10 @@  discard block
 block discarded – undo
1006 1065
 			Api\Translation::init();
1007 1066
 		}
1008 1067
 		// restore timezone, in case we had to reset it to server-timezone
1009
-		if ($restore_tz) date_default_timezone_set($restore_tz);
1068
+		if ($restore_tz)
1069
+		{
1070
+			date_default_timezone_set($restore_tz);
1071
+		}
1010 1072
 
1011 1073
 		return true;
1012 1074
 	}
@@ -1041,10 +1103,13 @@  discard block
 block discarded – undo
1041 1103
 		{
1042 1104
 			$to_notify = $event['participants'];
1043 1105
 		}
1044
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1106
+		elseif ($this->check_perms(Acl::READ,$event))
1107
+		{
1108
+			// checks agains $this->owner set to $alarm[owner]
1045 1109
 		{
1046 1110
 			$to_notify[$alarm['owner']] = 'A';
1047 1111
 		}
1112
+		}
1048 1113
 		else
1049 1114
 		{
1050 1115
 			return False;	// no rights
@@ -1094,7 +1159,10 @@  discard block
 block discarded – undo
1094 1159
 		if ($event['id'])
1095 1160
 		{
1096 1161
 			// invalidate the read-cache if it contains the event we store now
1097
-			if ($event['id'] == self::$cached_event['id']) self::$cached_event = array();
1162
+			if ($event['id'] == self::$cached_event['id'])
1163
+			{
1164
+				self::$cached_event = array();
1165
+			}
1098 1166
 			$old_event = $this->read($event['id'], $event['recurrence'], false, 'server');
1099 1167
 		}
1100 1168
 		else
@@ -1102,7 +1170,10 @@  discard block
 block discarded – undo
1102 1170
 			$old_event = null;
1103 1171
 		}
1104 1172
 
1105
-		if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
1173
+		if (!isset($event['whole_day']))
1174
+		{
1175
+			$event['whole_day'] = $this->isWholeDay($event);
1176
+		}
1106 1177
 		$save_event = $event;
1107 1178
 		if ($event['whole_day'])
1108 1179
 		{
@@ -1143,7 +1214,10 @@  discard block
 block discarded – undo
1143 1214
 		foreach($timestamps as $ts)
1144 1215
 		{
1145 1216
 			// we convert here from user-time to timestamps in server-time!
1146
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1217
+			if (isset($event[$ts]))
1218
+			{
1219
+				$event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1220
+			}
1147 1221
 		}
1148 1222
 		// convert tzid name to integer tz_id, of set user default
1149 1223
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1193,7 +1267,10 @@  discard block
 block discarded – undo
1193 1267
 				if (!isset($event['alarm'][$id]))
1194 1268
 				{
1195 1269
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1196
-					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1270
+					if ($alarm['time'] < time())
1271
+					{
1272
+						calendar_so::shift_alarm($event, $alarm);
1273
+					}
1197 1274
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1198 1275
 					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1199 1276
 						$old_event['participants'][$alarm['owner']];
@@ -1246,7 +1323,10 @@  discard block
 block discarded – undo
1246 1323
 
1247 1324
 		// Update history
1248 1325
 		$tracking = new calendar_tracking($this);
1249
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1326
+		if (empty($event['id']) && !empty($cal_id))
1327
+		{
1328
+			$event['id']=$cal_id;
1329
+		}
1250 1330
 		$tracking->track($event, $old_event);
1251 1331
 
1252 1332
 		return $cal_id;
@@ -1263,9 +1343,12 @@  discard block
 block discarded – undo
1263 1343
 	 */
1264 1344
 	function check_status_perms($uid,$event)
1265 1345
 	{
1266
-		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1346
+		if ($uid[0] == 'c' || $uid[0] == 'e')
1347
+		{
1348
+			// for contact we use the owner of the event
1267 1349
 		{
1268 1350
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1351
+		}
1269 1352
 
1270 1353
 			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1271 1354
 		}
@@ -1276,13 +1359,19 @@  discard block
 block discarded – undo
1276 1359
 			return $access;
1277 1360
 		}
1278 1361
 		// no access or denied access because of category acl --> regular check
1279
-		if (!is_numeric($uid))	// this is eg. for resources (r123)
1362
+		if (!is_numeric($uid))
1363
+		{
1364
+			// this is eg. for resources (r123)
1280 1365
 		{
1281 1366
 			$resource = $this->resource_info($uid);
1367
+		}
1282 1368
 
1283 1369
 			return Acl::EDIT & $resource['rights'];
1284 1370
 		}
1285
-		if (!is_array($event) && !($event = $this->read($event))) return false;
1371
+		if (!is_array($event) && !($event = $this->read($event)))
1372
+		{
1373
+			return false;
1374
+		}
1286 1375
 
1287 1376
 		// regular user and groups (need to check memberships too)
1288 1377
 		if (!isset($event['participants'][$uid]))
@@ -1306,7 +1395,10 @@  discard block
 block discarded – undo
1306 1395
 	 */
1307 1396
 	function check_cat_acl($right,$event)
1308 1397
 	{
1309
-		if (!is_array($event)) $event = $this->read($event);
1398
+		if (!is_array($event))
1399
+		{
1400
+			$event = $this->read($event);
1401
+		}
1310 1402
 
1311 1403
 		$ret = null;
1312 1404
 		if ($event['category'])
@@ -1363,7 +1455,10 @@  discard block
 block discarded – undo
1363 1455
 	public static function set_cat_rights($cat_id,$user,$rights)
1364 1456
 	{
1365 1457
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1366
-		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
1458
+		if (!isset(self::$cat_rights_cache))
1459
+		{
1460
+			self::get_cat_rights($cat_id);
1461
+		}
1367 1462
 
1368 1463
 		if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user])
1369 1464
 		{
@@ -1375,7 +1470,10 @@  discard block
 block discarded – undo
1375 1470
 			else
1376 1471
 			{
1377 1472
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1378
-				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1473
+				if (!self::$cat_rights_cache['L'.$cat_id])
1474
+				{
1475
+					unset(self::$cat_rights_cache['L'.$cat_id]);
1476
+				}
1379 1477
 				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1380 1478
 			}
1381 1479
 			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
@@ -1408,7 +1506,10 @@  discard block
 block discarded – undo
1408 1506
 				foreach($cat_rights as $uid => $value)
1409 1507
 				{
1410 1508
 					$all |= $value;
1411
-					if (in_array($uid,$memberships)) $own |= $value;
1509
+					if (in_array($uid,$memberships))
1510
+					{
1511
+						$own |= $value;
1512
+					}
1412 1513
 				}
1413 1514
 			}
1414 1515
 			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
@@ -1455,13 +1556,16 @@  discard block
 block discarded – undo
1455 1556
 				is_numeric($uid)?$uid:substr($uid,1),$status,
1456 1557
 				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1457 1558
 		{
1458
-			if ($status == 'R')	// remove alarms belonging to rejected participants
1559
+			if ($status == 'R')
1560
+			{
1561
+				// remove alarms belonging to rejected participants
1459 1562
 			{
1460 1563
 				foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1461 1564
 				{
1462 1565
 					if ((string)$alarm['owner'] === (string)$uid)
1463 1566
 					{
1464 1567
 						$this->so->delete_alarm($id);
1568
+			}
1465 1569
 						//error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
1466 1570
 					}
1467 1571
 				}
@@ -1475,8 +1579,15 @@  discard block
 block discarded – undo
1475 1579
 			);
1476 1580
 			if (isset($status2msg[$status]) && !$skip_notification)
1477 1581
 			{
1478
-				if (!is_array($event)) $event = $this->read($cal_id);
1479
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1582
+				if (!is_array($event))
1583
+				{
1584
+					$event = $this->read($cal_id);
1585
+				}
1586
+				if (isset($recur_date))
1587
+				{
1588
+					$event = $this->read($event['id'],$recur_date);
1589
+				}
1590
+				//re-read the actually edited recurring event
1480 1591
 				$this->send_update($status2msg[$status],$event['participants'],$event);
1481 1592
 			}
1482 1593
 
@@ -1499,12 +1610,16 @@  discard block
 block discarded – undo
1499 1610
 	 */
1500 1611
 	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1501 1612
 	{
1502
-		if (!isset($new_event['participants'])) return;
1613
+		if (!isset($new_event['participants']))
1614
+		{
1615
+			return;
1616
+		}
1503 1617
 
1504 1618
 		// check the old list against the new list
1505 1619
 		foreach ($old_event['participants'] as $userid => $status)
1506
-  		{
1507
-            if (!isset($new_event['participants'][$userid])){
1620
+		{
1621
+            if (!isset($new_event['participants'][$userid]))
1622
+            {
1508 1623
             	// Attendee will be deleted this way
1509 1624
             	$new_event['participants'][$userid] = 'G';
1510 1625
             }
@@ -1587,7 +1702,10 @@  discard block
 block discarded – undo
1587 1702
 					}
1588 1703
 					else
1589 1704
 					{
1590
-						if (!($exception = $this->read($id))) continue;
1705
+						if (!($exception = $this->read($id)))
1706
+						{
1707
+							continue;
1708
+						}
1591 1709
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1592 1710
 						$exception['reference'] = $exception['recurrence'] = 0;
1593 1711
 						$this->update($exception, true, true, false, true, $msg=null, true);
@@ -1658,7 +1776,10 @@  discard block
 block discarded – undo
1658 1776
 		$event_arr = $this->event2array($event);
1659 1777
 		foreach($event_arr as $key => $val)
1660 1778
 		{
1661
-			if ($key == 'recur_type') $key = 'repetition';
1779
+			if ($key == 'recur_type')
1780
+			{
1781
+				$key = 'repetition';
1782
+			}
1662 1783
 			$details[$key] = $val['data'];
1663 1784
 		}
1664 1785
 		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
@@ -1830,7 +1951,10 @@  discard block
 block discarded – undo
1830 1951
 	 */
1831 1952
 	function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
1832 1953
 	{
1833
-		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1954
+		if ($old_event !== null && $event['start'] == $old_event['start'])
1955
+		{
1956
+			return;
1957
+		}
1834 1958
 
1835 1959
 		$time = new Api\DateTime($event['start']);
1836 1960
 		if(!is_array($event['alarm']))
@@ -1904,7 +2028,10 @@  discard block
 block discarded – undo
1904 2028
 		if (is_array($old_event) || $old_event > 0)
1905 2029
 		{
1906 2030
 			// preserve categories without users read access
1907
-			if (!is_array($old_event)) $old_event = $this->read($old_event);
2031
+			if (!is_array($old_event))
2032
+			{
2033
+				$old_event = $this->read($old_event);
2034
+			}
1908 2035
 			$old_categories = explode(',',$old_event['category']);
1909 2036
 			$old_cats_preserve = array();
1910 2037
 			if (is_array($old_categories) && count($old_categories) > 0)
@@ -1995,7 +2122,10 @@  discard block
 block discarded – undo
1995 2122
 				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
1996 2123
 		}
1997 2124
 
1998
-		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2125
+		if (!isset($event['recurrence']))
2126
+		{
2127
+			$event['recurrence'] = 0;
2128
+		}
1999 2129
 
2000 2130
 		if ($filter == 'master')
2001 2131
 		{
@@ -2049,19 +2179,26 @@  discard block
 block discarded – undo
2049 2179
 							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2050 2180
 						}
2051 2181
 					}
2052
-				} elseif ($filter != 'master' && ($filter == 'exact' ||
2182
+				}
2183
+				elseif ($filter != 'master' && ($filter == 'exact' ||
2053 2184
 							$event['recur_type'] == $egwEvent['recur_type'] &&
2054 2185
 							strpos($egwEvent['title'], $event['title']) === 0))
2055 2186
 				{
2056 2187
 					$matchingEvents[] = $egwEvent['id']; // we found the event
2057 2188
 				}
2058 2189
 			}
2059
-			if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents;
2190
+			if (!empty($matchingEvents) || $filter == 'exact')
2191
+			{
2192
+				return $matchingEvents;
2193
+			}
2060 2194
 		}
2061 2195
 		unset($event['id']);
2062 2196
 
2063 2197
 		// No chance to find a master without [U]ID
2064
-		if ($filter == 'master' && empty($event['uid'])) return $matchingEvents;
2198
+		if ($filter == 'master' && empty($event['uid']))
2199
+		{
2200
+			return $matchingEvents;
2201
+		}
2065 2202
 
2066 2203
 		// only query calendars of users, we have READ-grants from
2067 2204
 		$users = array();
@@ -2070,17 +2207,23 @@  discard block
 block discarded – undo
2070 2207
 			$user = trim($user);
2071 2208
 			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2072 2209
 			{
2073
-				if ($user && !in_array($user,$users))	// already added?
2210
+				if ($user && !in_array($user,$users))
2211
+				{
2212
+					// already added?
2074 2213
 				{
2075 2214
 					$users[] = $user;
2076 2215
 				}
2216
+				}
2077 2217
 			}
2078 2218
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2079 2219
 			{
2080 2220
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2081 2221
 			}
2082 2222
 			// the further code is only for real users
2083
-			if (!is_numeric($user)) continue;
2223
+			if (!is_numeric($user))
2224
+			{
2225
+				continue;
2226
+			}
2084 2227
 
2085 2228
 			// for groups we have to include the members
2086 2229
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
@@ -2160,7 +2303,10 @@  discard block
 block discarded – undo
2160 2303
 			}
2161 2304
 			foreach ($matchFields as $key)
2162 2305
 			{
2163
-				if (isset($event[$key])) $query['cal_'.$key] = $event[$key];
2306
+				if (isset($event[$key]))
2307
+				{
2308
+					$query['cal_'.$key] = $event[$key];
2309
+				}
2164 2310
 			}
2165 2311
 		}
2166 2312
 
@@ -2200,7 +2346,10 @@  discard block
 block discarded – undo
2200 2346
 					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2201 2347
 			}
2202 2348
 
2203
-			if (in_array($egwEvent['id'], $matchingEvents)) continue;
2349
+			if (in_array($egwEvent['id'], $matchingEvents))
2350
+			{
2351
+				continue;
2352
+			}
2204 2353
 
2205 2354
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
2206 2355
 			if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id'])))
@@ -2367,13 +2516,16 @@  discard block
 block discarded – undo
2367 2516
 					foreach ($event['participants'] as $attendee => $status)
2368 2517
 					{
2369 2518
 						if (!isset($egwEvent['participants'][$attendee]) &&
2370
-								$attendee != $egwEvent['owner']) // ||
2519
+								$attendee != $egwEvent['owner'])
2520
+						{
2521
+							// ||
2371 2522
 							//(!$relax && $egw_event['participants'][$attendee] != $status))
2372 2523
 						{
2373 2524
 							if ($this->log)
2374 2525
 							{
2375 2526
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2376 2527
 								"() additional event['participants']: $attendee\n",3,$this->logfile);
2528
+						}
2377 2529
 							}
2378 2530
 							continue 2;
2379 2531
 						}
@@ -2695,7 +2847,10 @@  discard block
 block discarded – undo
2695 2847
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2696 2848
 		{
2697 2849
 			// we convert here from server-time to timestamps in user-time!
2698
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2850
+			if (isset($event[$ts]))
2851
+			{
2852
+				$event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2853
+			}
2699 2854
 		}
2700 2855
 		// same with the recur exceptions
2701 2856
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
@@ -2723,9 +2878,12 @@  discard block
 block discarded – undo
2723 2878
 	 */
2724 2879
 	function purge($age)
2725 2880
 	{
2726
-		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2881
+		if (is_numeric($age) && $age > 0)
2882
+		{
2883
+			// just make sure bogus values dont delete everything
2727 2884
 		{
2728 2885
 			$this->so->purge(time() - 365*24*3600*(float)$age);
2729 2886
 		}
2887
+		}
2730 2888
 	}
2731 2889
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1708,12 +1708,12 @@  discard block
 block discarded – undo
1708 1708
 	 */
1709 1709
 	function event2array($event)
1710 1710
 	{
1711
-		$var['title'] = Array(
1711
+		$var['title'] = array(
1712 1712
 			'field'		=> lang('Title'),
1713 1713
 			'data'		=> $event['title']
1714 1714
 		);
1715 1715
 
1716
-		$var['description'] = Array(
1716
+		$var['description'] = array(
1717 1717
 			'field'	=> lang('Description'),
1718 1718
 			'data'	=> $event['description']
1719 1719
 		);
@@ -1722,48 +1722,48 @@  discard block
 block discarded – undo
1722 1722
 		{
1723 1723
 			$cat_string[] = stripslashes(Api\Categories::id2name($cat_id));
1724 1724
 		}
1725
-		$var['category'] = Array(
1725
+		$var['category'] = array(
1726 1726
 			'field'	=> lang('Category'),
1727 1727
 			'data'	=> implode(', ',$cat_string)
1728 1728
 		);
1729 1729
 
1730
-		$var['location'] = Array(
1730
+		$var['location'] = array(
1731 1731
 			'field'	=> lang('Location'),
1732 1732
 			'data'	=> $event['location']
1733 1733
 		);
1734 1734
 
1735
-		$var['startdate'] = Array(
1735
+		$var['startdate'] = array(
1736 1736
 			'field'	=> lang('Start Date/Time'),
1737 1737
 			'data'	=> $this->format_date($event['start']),
1738 1738
 		);
1739 1739
 
1740
-		$var['enddate'] = Array(
1740
+		$var['enddate'] = array(
1741 1741
 			'field'	=> lang('End Date/Time'),
1742 1742
 			'data'	=> $this->format_date($event['end']),
1743 1743
 		);
1744 1744
 
1745
-		$pri = Array(
1745
+		$pri = array(
1746 1746
 			0   => lang('None'),
1747 1747
 			1	=> lang('Low'),
1748 1748
 			2	=> lang('Normal'),
1749 1749
 			3	=> lang('High')
1750 1750
 		);
1751
-		$var['priority'] = Array(
1751
+		$var['priority'] = array(
1752 1752
 			'field'	=> lang('Priority'),
1753 1753
 			'data'	=> $pri[$event['priority']]
1754 1754
 		);
1755 1755
 
1756
-		$var['owner'] = Array(
1756
+		$var['owner'] = array(
1757 1757
 			'field'	=> lang('Owner'),
1758 1758
 			'data'	=> Api\Accounts::username($event['owner'])
1759 1759
 		);
1760 1760
 
1761
-		$var['updated'] = Array(
1761
+		$var['updated'] = array(
1762 1762
 			'field'	=> lang('Updated'),
1763 1763
 			'data'	=> $this->format_date($event['modtime']).', '.Api\Accounts::username($event['modifier'])
1764 1764
 		);
1765 1765
 
1766
-		$var['access'] = Array(
1766
+		$var['access'] = array(
1767 1767
 			'field'	=> lang('Access'),
1768 1768
 			'data'	=> $event['public'] ? lang('Public') : lang('Private')
1769 1769
 		);
@@ -1772,13 +1772,13 @@  discard block
 block discarded – undo
1772 1772
 		{
1773 1773
 			$participants = $this->participants($event,true);
1774 1774
 		}
1775
-		$var['participants'] = Array(
1775
+		$var['participants'] = array(
1776 1776
 			'field'	=> lang('Participants'),
1777 1777
 			'data'	=> $participants
1778 1778
 		);
1779 1779
 
1780 1780
 		// Repeated Events
1781
-		$var['recur_type'] = Array(
1781
+		$var['recur_type'] = array(
1782 1782
 			'field'	=> lang('Repetition'),
1783 1783
 			'data'	=> ($event['recur_type'] != MCAL_RECUR_NONE) ? $this->recure2string($event) : '',
1784 1784
 		);
@@ -1828,7 +1828,7 @@  discard block
 block discarded – undo
1828 1828
 	 * @param Api\DateTime $instance_date For recurring events, this is the date we
1829 1829
 	 *	are dealing with
1830 1830
 	 */
1831
-	function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
1831
+	function check_move_alarms(array &$event, array $old_event = null, Api\DateTime $instance_date = null)
1832 1832
 	{
1833 1833
 		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1834 1834
 
Please login to merge, or discard this patch.
calendar/inc/class.calendar_groupdav.inc.php 3 patches
Doc Comments   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @param string $path
317 317
 	 * @param array $filter
318
-	 * @param array|boolean $start =false false=return all or array(start,num)
318
+	 * @param integer[] $start =false false=return all or array(start,num)
319 319
 	 * @return array with "files" array with values for keys path and props
320 320
 	 */
321 321
 	function propfind_callback($path,array $filter,$start=false)
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @param array &$options
621 621
 	 * @param int $id
622 622
 	 * @param int $user =null account_id
623
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
623
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
624 624
 	 */
625 625
 	function get(&$options,$id,$user=null)
626 626
 	{
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 	 * Check if $user is a participant of given $event incl. group-invitations
794 794
 	 *
795 795
 	 * @param array $event
796
-	 * @param int|string $user
796
+	 * @param integer $user
797 797
 	 * @return boolean
798 798
 	 */
799 799
 	public static function isParticipant(array $event, $user)
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 	 * @param int $id
811 811
 	 * @param int $user =null account_id of owner, default null
812 812
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
813
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
813
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
814 814
 	 */
815 815
 	function put(&$options,$id,$user=null,$prefix=null)
816 816
 	{
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 	 * @param array &$options
1039 1039
 	 * @param int $id
1040 1040
 	 * @param int $user =null account_id of owner, default null
1041
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1041
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1042 1042
 	 */
1043 1043
 	function post(&$options,$id,$user=null)
1044 1044
 	{
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 	 * @param string $charset of ical
1113 1113
 	 * @param int $user account_id of owner
1114 1114
 	 * @param array &$options
1115
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1115
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1116 1116
 	 */
1117 1117
 	protected function outbox_freebusy_request($ical, $charset, $user, array &$options)
1118 1118
 	{
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 	 * @param string $path
1188 1188
 	 * @param array $options
1189 1189
 	 * @param int $user account_id
1190
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1190
+	 * @return string|null boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1191 1191
 	 */
1192 1192
 	function free_busy_report($path,$options,$user)
1193 1193
 	{
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
 	/**
1417 1417
 	 * Query ctag for calendar
1418 1418
 	 *
1419
-	 * @return string
1419
+	 * @return integer
1420 1420
 	 */
1421 1421
 	public function getctag($path,$user)
1422 1422
 	{
@@ -1432,7 +1432,7 @@  discard block
 block discarded – undo
1432 1432
 	 *
1433 1433
 	 * @param array|int $entry array with event or cal_id
1434 1434
 	 * @param string $schedule_tag =null on return schedule-tag
1435
-	 * @return string|boolean string with etag or false
1435
+	 * @return string string with etag or false
1436 1436
 	 */
1437 1437
 	function get_etag($entry, &$schedule_tag=null)
1438 1438
 	{
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 	 *
1450 1450
 	 * @param int|array $entry id or array of new created entry
1451 1451
 	 * @param string $path
1452
-	 * @param int|string $retval
1452
+	 * @param string|boolean $retval
1453 1453
 	 * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
1454 1454
 	 */
1455 1455
 	function put_response_headers($entry, $path, $retval, $path_attr_is_name=true)
Please login to merge, or discard this patch.
Spacing   +148 added lines, -149 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param string $id =''
142 142
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
143 143
 	 */
144
-	function propfind($path,&$options,&$files,$user,$id='')
144
+	function propfind($path, &$options, &$files, $user, $id = '')
145 145
 	{
146 146
 		if ($this->debug)
147 147
 		{
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 			'enum_recuring' => false,
168 168
 			'daywise' => false,
169 169
 			'date_format' => 'server',
170
-			'no_total' => true,	// we need no total number of rows (saves extra query)
171
-			'cfs' => array(),	// return custom-fields, as we use them to store X- attributes
170
+			'no_total' => true, // we need no total number of rows (saves extra query)
171
+			'cfs' => array(), // return custom-fields, as we use them to store X- attributes
172 172
 		);
173
-		foreach(array(
173
+		foreach (array(
174 174
 			'start' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-past-limit'],
175 175
 			'end' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-future-limit'],
176 176
 		) as $name => $value)
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			{
180 180
 				$value = $name == 'start' ? self::PAST_LIMIT : self::FUTURE_LIMIT;
181 181
 			}
182
-			$filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value);
182
+			$filter[$name] = $this->bo->now + 24 * 3600 * ($name == 'start' ? -1 : 1) * abs($value);
183 183
 		}
184 184
 		if ($this->client_shared_uid_exceptions)	// do NOT return (non-virtual) exceptions
185 185
 		{
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 			$filter['filter'] = 'owner';
192 192
 		}
193 193
 		// scheduling inbox, shows only not yet accepted or rejected events
194
-		elseif (substr($path,-7) == '/inbox/')
194
+		elseif (substr($path, -7) == '/inbox/')
195 195
 		{
196 196
 			$filter['filter'] = 'unknown';
197
-			$filter['start'] = $this->bo->now;	// only return future invitations
197
+			$filter['start'] = $this->bo->now; // only return future invitations
198 198
 		}
199 199
 		// ToDo: not sure what scheduling outbox is supposed to show, leave it empty for now
200
-		elseif (substr($path,-8) == '/outbox/')
200
+		elseif (substr($path, -8) == '/outbox/')
201 201
 		{
202 202
 			return true;
203 203
 		}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			// when trying to request not supported components, eg. VTODO on a calendar collection
215 215
 			return true;
216 216
 		}
217
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
217
+		if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback
218 218
 
219 219
 		if ($this->debug > 1)
220 220
 		{
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 			$this->sync_collection_token = null;
233 233
 
234
-			$filter['order'] = 'cal_modified ASC';	// return oldest modifications first
234
+			$filter['order'] = 'cal_modified ASC'; // return oldest modifications first
235 235
 			$filter['sync-collection'] = true;
236 236
 			// no end-date / limit into the future, as unchanged entries would never be transferted later on
237 237
 			unset($filter['end']);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 		if (isset($nresults))
241 241
 		{
242
-			unset($filter['no_total']);	// we need the total!
242
+			unset($filter['no_total']); // we need the total!
243 243
 			$files['files'] = $this->propfind_callback($path, $filter, array(0, (int)$nresults));
244 244
 
245 245
 			// hack to support limit with sync-collection report: events are returned in modified ASC order (oldest first)
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
 			if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults)
249 249
 			{
250 250
 				--$this->sync_collection_token;
251
-				$files['sync-token-params'][] = true;	// tel get_sync_collection_token that we have more entries
251
+				$files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries
252 252
 			}
253 253
 		}
254 254
 		else
255 255
 		{
256 256
 			// return iterator, calling ourself to return result in chunks
257
-			$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
257
+			$files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']);
258 258
 		}
259 259
 		if (isset($_GET['download']))
260 260
 		{
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 		Api\Header\Content::type('calendar.ics', 'text/calendar');
275 275
 
276 276
 		$n = 0;
277
-		foreach($files as $file)
277
+		foreach ($files as $file)
278 278
 		{
279
-			if (!$n++) continue;	// first entry is collection itself
279
+			if (!$n++) continue; // first entry is collection itself
280 280
 
281 281
 			$icalendar = $file['props']['calendar-data']['val'];
282 282
 			if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false &&
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 						echo substr($icalendar, 0, $start);
301 301
 					}
302 302
 				}
303
-				echo substr($icalendar, $start, $end-$start);
303
+				echo substr($icalendar, $start, $end - $start);
304 304
 			}
305 305
 		}
306 306
 		if ($icalendar && $end)
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
 	 * @param array|boolean $start =false false=return all or array(start,num)
319 319
 	 * @return array with "files" array with values for keys path and props
320 320
 	 */
321
-	function propfind_callback($path,array $filter,$start=false)
321
+	function propfind_callback($path, array $filter, $start = false)
322 322
 	{
323 323
 		if ($this->debug) $starttime = microtime(true);
324 324
 
325 325
 		$calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true);
326
-		if (!is_array($calendar_data)) $calendar_data = false;	// not in allprop or autoindex
326
+		if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex
327 327
 
328 328
 		$files = array();
329 329
 
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 		$requested_multiget_ids = (array)$filter['query'][self::$path_attr];
336 336
 		$sync_collection = $filter['sync-collection'];
337 337
 
338
-		$events =& $this->bo->search($filter);
338
+		$events = & $this->bo->search($filter);
339 339
 
340 340
 		if ($events)
341 341
 		{
342
-			foreach($events as $event)
342
+			foreach ($events as $event)
343 343
 			{
344 344
 				// remove event from requested multiget ids, to be able to report not found urls
345 345
 				if ($requested_multiget_ids && ($k = array_search($event[self::$path_attr], $requested_multiget_ids)) !== false)
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 					unset($requested_multiget_ids[$k]);
348 348
 				}
349 349
 				// sync-collection report: deleted entries need to be reported without properties, same for rejected or deleted invitations
350
-				if ($sync_collection && ($event['deleted'] || in_array($event['participants'][$filter['users']][0], array('R','X'))))
350
+				if ($sync_collection && ($event['deleted'] || in_array($event['participants'][$filter['users']][0], array('R', 'X'))))
351 351
 				{
352 352
 					$files[] = array('path' => $path.urldecode($this->get_path($event)));
353 353
 					continue;
@@ -375,10 +375,9 @@  discard block
 block discarded – undo
375 375
 				{
376 376
 					$content = $this->iCal($event, $filter['users'],
377 377
 						strpos($path, '/inbox/') !== false ? 'REQUEST' : null,
378
-						!isset($calendar_data['children']['expand']) ? false :
379
-							($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true));
378
+						!isset($calendar_data['children']['expand']) ? false : ($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true));
380 379
 					$props['getcontentlength'] = bytes($content);
381
-					$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content);
380
+					$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content);
382 381
 				}
383 382
 				/* Calendarserver reports new events with schedule-changes: action: create, which iCal request
384 383
 				 * adding it, unfortunately does not lead to showing the new event in the users inbox
@@ -397,7 +396,7 @@  discard block
 block discarded – undo
397 396
 		// report not found multiget urls
398 397
 		if ($requested_multiget_ids)
399 398
 		{
400
-			foreach($requested_multiget_ids as $id)
399
+			foreach ($requested_multiget_ids as $id)
401 400
 			{
402 401
 				$files[] = array('path' => $path.$id.self::$path_extension);
403 402
 			}
@@ -433,7 +432,7 @@  discard block
 block discarded – undo
433 432
 	private function _created_updated_by_prop($user, $time)
434 433
 	{
435 434
 		$props = array();
436
-		foreach(array(
435
+		foreach (array(
437 436
 			'first-name' => 'account_firstname',
438 437
 			'last-name' => 'account_lastname',
439 438
 			'href' => 'account_email',
@@ -476,23 +475,23 @@  discard block
 block discarded – undo
476 475
 			$cal_end = $cal_filters['end']; unset($cal_filters['end']);
477 476
 			$num_filters = count($cal_filters);
478 477
 
479
-			foreach($options['filters'] as $filter)
478
+			foreach ($options['filters'] as $filter)
480 479
 			{
481
-				switch($filter['name'])
480
+				switch ($filter['name'])
482 481
 				{
483 482
 					case 'comp-filter':
484 483
 						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
485 484
 
486
-						switch($filter['attrs']['name'])
485
+						switch ($filter['attrs']['name'])
487 486
 						{
488 487
 							case 'VTODO':
489
-								return false;	// return nothing for now, todo: check if we can pass it on to the infolog handler
488
+								return false; // return nothing for now, todo: check if we can pass it on to the infolog handler
490 489
 								// todos are handled by the infolog handler
491 490
 								//$infolog_handler = new groupdav_infolog();
492 491
 								//return $infolog_handler->propfind($options['path'],$options,$options['files'],$user,$method);
493 492
 							case 'VCALENDAR':
494 493
 							case 'VEVENT':
495
-								break;			// that's our default anyway
494
+								break; // that's our default anyway
496 495
 						}
497 496
 						break;
498 497
 					case 'prop-filter':
@@ -515,14 +514,14 @@  discard block
 block discarded – undo
515 514
 						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
516 515
 						break;
517 516
 					case 'time-range':
518
-				 		if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
517
+				 		if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
519 518
 				 		if (!empty($filter['attrs']['start']))
520 519
 				 		{
521 520
 					 		$cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']);
522 521
 				 		}
523 522
 				 		if (!empty($filter['attrs']['end']))
524 523
 				 		{
525
-					 		$cal_filters['end']   = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
524
+					 		$cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
526 525
 				 		}
527 526
 						break;
528 527
 					default:
@@ -543,9 +542,9 @@  discard block
 block discarded – undo
543 542
 		    <B:nresults>10</B:nresults>
544 543
 		  </B:limit>
545 544
 		*/
546
-		foreach((array)$options['other'] as $option)
545
+		foreach ((array)$options['other'] as $option)
547 546
 		{
548
-			switch($option['name'])
547
+			switch ($option['name'])
549 548
 			{
550 549
 				case 'nresults':
551 550
 					$nresults = (int)$option['data'];
@@ -554,7 +553,7 @@  discard block
 block discarded – undo
554 553
 				case 'limit':
555 554
 					break;
556 555
 				case 'href':
557
-					break;	// from addressbook-multiget, handled below
556
+					break; // from addressbook-multiget, handled below
558 557
 				// rfc 6578 sync-report
559 558
 				case 'sync-token':
560 559
 					if (!empty($option['data']))
@@ -562,7 +561,7 @@  discard block
 block discarded – undo
562 561
 						$parts = explode('/', $option['data']);
563 562
 						$sync_token = array_pop($parts);
564 563
 						$cal_filters['query'][] = 'cal_modified>'.(int)$sync_token;
565
-						$cal_filters['filter'] = 'everything';	// to return deleted entries too
564
+						$cal_filters['filter'] = 'everything'; // to return deleted entries too
566 565
 						// no standard time-range!
567 566
 						unset($cal_filters['start']);
568 567
 					}
@@ -591,25 +590,25 @@  discard block
 block discarded – undo
591 590
 			if ($id)
592 591
 			{
593 592
 				$cal_filters['query'][self::$path_attr] = self::$path_extension ?
594
-					basename($id,self::$path_extension) : $id;
593
+					basename($id, self::$path_extension) : $id;
595 594
 			}
596 595
 			else	// fetch all given url's
597 596
 			{
598
-				foreach($options['other'] as $option)
597
+				foreach ($options['other'] as $option)
599 598
 				{
600 599
 					if ($option['name'] == 'href')
601 600
 					{
602
-						$parts = explode('/',$option['data']);
601
+						$parts = explode('/', $option['data']);
603 602
 						if (($id = urldecode(array_pop($parts))))
604 603
 						{
605 604
 							$cal_filters['query'][self::$path_attr][] = self::$path_extension ?
606
-								basename($id,self::$path_extension) : $id;
605
+								basename($id, self::$path_extension) : $id;
607 606
 						}
608 607
 					}
609 608
 				}
610 609
 			}
611 610
 
612
-			if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
611
+			if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids).', cal_filters='.array2string($cal_filters));
613 612
 		}
614 613
 		return true;
615 614
 	}
@@ -622,9 +621,9 @@  discard block
 block discarded – undo
622 621
 	 * @param int $user =null account_id
623 622
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
624 623
 	 */
625
-	function get(&$options,$id,$user=null)
624
+	function get(&$options, $id, $user = null)
626 625
 	{
627
-		if (!is_array($event = $this->_common_get_put_delete('GET',$options,$id)))
626
+		if (!is_array($event = $this->_common_get_put_delete('GET', $options, $id)))
628 627
 		{
629 628
 			return $event;
630 629
 		}
@@ -652,7 +651,7 @@  discard block
 block discarded – undo
652 651
 	 * @param boolean|array $expand =false true or array with values for 'start', 'end' to expand recurrences
653 652
 	 * @return string
654 653
 	 */
655
-	private function iCal(array $event,$user=null, $method=null, $expand=false)
654
+	private function iCal(array $event, $user = null, $method = null, $expand = false)
656 655
 	{
657 656
 		static $handler = null;
658 657
 		if (is_null($handler)) $handler = $this->_get_handler();
@@ -676,11 +675,11 @@  discard block
 block discarded – undo
676 675
 				if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
677 676
 				if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
678 677
 			}
679
-			$events =& self::get_series($event['uid'], $this->bo, $expand, $user);
678
+			$events = & self::get_series($event['uid'], $this->bo, $expand, $user);
680 679
 		}
681
-		elseif(!$this->client_shared_uid_exceptions && $event['reference'])
680
+		elseif (!$this->client_shared_uid_exceptions && $event['reference'])
682 681
 		{
683
-			$events[0]['uid'] .= '-'.$event['id'];	// force a different uid
682
+			$events[0]['uid'] .= '-'.$event['id']; // force a different uid
684 683
 		}
685 684
 		return $handler->exportVCal($events, '2.0', $method);
686 685
 	}
@@ -696,20 +695,20 @@  discard block
 block discarded – undo
696 695
 	 * @param int $user =null account_id of calendar to display, to remove master, if current user does not participate in
697 696
 	 * @return array
698 697
 	 */
699
-	private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null)
698
+	private static function &get_series($uid, calendar_bo $bo = null, $expand = false, $user = null)
700 699
 	{
701 700
 		if (is_null($bo)) $bo = new calendar_bopdate();
702 701
 
703 702
 		$params = array(
704 703
 			'query' => array('cal_uid' => $uid),
705
-			'filter' => 'owner',  // return all possible entries
704
+			'filter' => 'owner', // return all possible entries
706 705
 			'daywise' => false,
707 706
 			'date_format' => 'server',
708
-			'cfs' => array(),	// read cfs as we use them to store X- attributes
707
+			'cfs' => array(), // read cfs as we use them to store X- attributes
709 708
 		);
710 709
 		if (is_array($expand)) $params += $expand;
711 710
 
712
-		if (!($events =& $bo->search($params)))
711
+		if (!($events = & $bo->search($params)))
713 712
 		{
714 713
 			return array();
715 714
 		}
@@ -717,12 +716,12 @@  discard block
 block discarded – undo
717 716
 		// find master, which is not always first event, eg. when first event is an exception
718 717
 		$master = null;
719 718
 		$exceptions = array();
720
-		foreach($events as $k => &$recurrence)
719
+		foreach ($events as $k => &$recurrence)
721 720
 		{
722 721
 			if ($recurrence['recur_type'])
723 722
 			{
724 723
 				$master = $recurrence;
725
-				$exceptions =& $master['recur_exception'];
724
+				$exceptions = & $master['recur_exception'];
726 725
 				unset($events[$k]);
727 726
 				break;
728 727
 			}
@@ -730,7 +729,7 @@  discard block
 block discarded – undo
730 729
 		// if recurring event starts in future behind horizont, nothing will be returned by bo::search()
731 730
 		if (!isset($master)) $master = $bo->read($uid);
732 731
 
733
-		foreach($events as $k => &$recurrence)
732
+		foreach ($events as $k => &$recurrence)
734 733
 		{
735 734
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence));
736 735
 			if (!$master || $recurrence['id'] != $master['id'])	// real exception
@@ -752,16 +751,16 @@  discard block
 block discarded – undo
752 751
 				// at least Lightning "understands" EXDATE as exception from what's included
753 752
 				// in the whole resource / VCALENDAR component
754 753
 				// not removing it causes Lightning to remove the exception itself
755
-				if (($e = array_search($recurrence['recurrence'],$exceptions)) !== false)
754
+				if (($e = array_search($recurrence['recurrence'], $exceptions)) !== false)
756 755
 				{
757 756
 					unset($exceptions[$e]);
758 757
 				}
759
-				continue;	// nothing to change
758
+				continue; // nothing to change
760 759
 			}
761 760
 			// alarms are reported on recurrences --> move them to master
762 761
 			if ($master)
763 762
 			{
764
-				foreach($recurrence['alarm'] as $alarm)
763
+				foreach ($recurrence['alarm'] as $alarm)
765 764
 				{
766 765
 					$master['alarm'][] = $alarm;
767 766
 				}
@@ -771,14 +770,14 @@  discard block
 block discarded – undo
771 770
 			if (!$expand && $master && $master['participants'] == $recurrence['participants'])
772 771
 			{
773 772
 				//error_log('NO exception: '.array2string($recurrence));
774
-				unset($events[$k]);	// no exception --> remove it
773
+				unset($events[$k]); // no exception --> remove it
775 774
 				continue;
776 775
 			}
777 776
 			// this is a virtual exception now (no extra event/cal_id in DB)
778 777
 			//error_log('virtual exception: '.array2string($recurrence));
779 778
 			$recurrence['recurrence'] = $recurrence['start'];
780 779
 			if ($master) $recurrence['reference'] = $master['id'];
781
-			$recurrence['recur_type'] = MCAL_RECUR_NONE;	// is set, as this is a copy of the master
780
+			$recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master
782 781
 			// not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start'];
783 782
 		}
784 783
 		// only add master if we are not expanding and current user participates in master (and not just some exceptions)
@@ -812,23 +811,23 @@  discard block
 block discarded – undo
812 811
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
813 812
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
814 813
 	 */
815
-	function put(&$options,$id,$user=null,$prefix=null)
814
+	function put(&$options, $id, $user = null, $prefix = null)
816 815
 	{
817
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
816
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
818 817
 
819
-		if (!$prefix) $user = null;	// /infolog/ does not imply setting the current user (for new entries it's done anyway)
818
+		if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway)
820 819
 
821 820
 		// fix for iCal4OL using WinHTTP only supporting a certain header length
822 821
 		if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']))
823 822
 		{
824 823
 			$_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'] = $_SERVER['HTTP_IF_SCHEDULE'];
825 824
 		}
826
-		$return_no_access = true;	// as handled by importVCal anyway and allows it to set the status for participants
827
-		$oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access,
828
-			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']));	// dont fail with 412 Precondition Failed in that case
825
+		$return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants
826
+		$oldEvent = $this->_common_get_put_delete('PUT', $options, $id, $return_no_access,
827
+			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case
829 828
 		if (!is_null($oldEvent) && !is_array($oldEvent))
830 829
 		{
831
-			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
830
+			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent, true).function_backtrace());
832 831
 			return $oldEvent;
833 832
 		}
834 833
 
@@ -859,7 +858,7 @@  discard block
 block discarded – undo
859 858
 					switch (strtolower($key))
860 859
 					{
861 860
 						case 'charset':
862
-							$charset = strtoupper(substr($value,1,-1));
861
+							$charset = strtoupper(substr($value, 1, -1));
863 862
 					}
864 863
 				}
865 864
 			}
@@ -915,7 +914,7 @@  discard block
 block discarded – undo
915 914
 				if (($events = $handler->icaltoegw($vCalendar)))
916 915
 				{
917 916
 					$modified = 0;
918
-					foreach($events as $n => $event)
917
+					foreach ($events as $n => $event)
919 918
 					{
920 919
 						// for recurrances of event series, we need to read correct recurrence (or if series master is no first event)
921 920
 						if ($event['recurrence'] || $n && !$event['recurrence'] || isset($series))
@@ -926,7 +925,7 @@  discard block
 block discarded – undo
926 925
 								$series = self::get_series($event['uid'], $this->bo);
927 926
 								//foreach($series as $s => $sEvent) error_log("series[$s]: ".array2string($sEvent));
928 927
 							}
929
-							foreach($series as $oldEvent)
928
+							foreach ($series as $oldEvent)
930 929
 							{
931 930
 								if ($oldEvent['recurrence'] == $event['recurrence']) break;
932 931
 							}
@@ -991,9 +990,9 @@  discard block
 block discarded – undo
991 990
 					isset($oldEvent['participants'][$GLOBALS['egw_info']['user']['account_id']]))
992 991
 				{
993 992
 					// just update etag in database
994
-					$GLOBALS['egw']->db->update($this->bo->so->cal_table,'cal_etag=cal_etag+1',array(
993
+					$GLOBALS['egw']->db->update($this->bo->so->cal_table, 'cal_etag=cal_etag+1', array(
995 994
 						'cal_id' => $eventId,
996
-					),__LINE__,__FILE__,'calendar');
995
+					), __LINE__, __FILE__, 'calendar');
997 996
 				}
998 997
 			}
999 998
 		}
@@ -1040,9 +1039,9 @@  discard block
 block discarded – undo
1040 1039
 	 * @param int $user =null account_id of owner, default null
1041 1040
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1042 1041
 	 */
1043
-	function post(&$options,$id,$user=null)
1042
+	function post(&$options, $id, $user = null)
1044 1043
 	{
1045
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
1044
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
1046 1045
 
1047 1046
 		$vCalendar = htmlspecialchars_decode($options['content']);
1048 1047
 		$charset = null;
@@ -1059,13 +1058,13 @@  discard block
 block discarded – undo
1059 1058
 					switch (strtolower($key))
1060 1059
 					{
1061 1060
 						case 'charset':
1062
-							$charset = strtoupper(substr($value,1,-1));
1061
+							$charset = strtoupper(substr($value, 1, -1));
1063 1062
 					}
1064 1063
 				}
1065 1064
 			}
1066 1065
 		}
1067 1066
 
1068
-		if (substr($options['path'],-8) == '/outbox/')
1067
+		if (substr($options['path'], -8) == '/outbox/')
1069 1068
 		{
1070 1069
 			if (preg_match('/^METHOD:REQUEST(\r\n|\r|\n)(.*)^BEGIN:VFREEBUSY/ism', $vCalendar))
1071 1070
 			{
@@ -1116,7 +1115,7 @@  discard block
 block discarded – undo
1116 1115
 	 */
1117 1116
 	protected function outbox_freebusy_request($ical, $charset, $user, array &$options)
1118 1117
 	{
1119
-		unset($options);	// not used, but required by function signature
1118
+		unset($options); // not used, but required by function signature
1120 1119
 
1121 1120
 		$vcal = new Horde_Icalendar();
1122 1121
 		if (!$vcal->parsevCalendar($ical, 'VCALENDAR', $charset))
@@ -1129,7 +1128,7 @@  discard block
 block discarded – undo
1129 1128
 
1130 1129
 		$handler = $this->_get_handler();
1131 1130
 		$handler->setSupportedFields('groupdav');
1132
-		$handler->calendarOwner = $handler->user = 0;	// to NOT default owner/organizer to something
1131
+		$handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something
1133 1132
 		if (!($component = $vcal->getComponent(0)) ||
1134 1133
 			!($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->caldav->current_user_principal, 'Horde_Icalendar_Vfreebusy')))
1135 1134
 		{
@@ -1154,13 +1153,13 @@  discard block
 block discarded – undo
1154 1153
 		$xml->startDocument('1.0', 'UTF-8');
1155 1154
 		$xml->startElementNs('C', 'schedule-response', Api\CalDAV::CALDAV);
1156 1155
 
1157
-		foreach(array_keys($event['participants']) as $uid)
1156
+		foreach (array_keys($event['participants']) as $uid)
1158 1157
 		{
1159 1158
 			$xml->startElementNs('C', 'response', null);
1160 1159
 
1161 1160
 			$xml->startElementNs('C', 'recipient', null);
1162
-			$xml->writeElementNs('D', 'href', 'DAV:', $attendee=array_shift($attendees));
1163
-			$xml->endElement();	// recipient
1161
+			$xml->writeElementNs('D', 'href', 'DAV:', $attendee = array_shift($attendees));
1162
+			$xml->endElement(); // recipient
1164 1163
 
1165 1164
 			$xml->writeElementNs('C', 'request-status', null, '2.0;Success');
1166 1165
 			$xml->writeElementNs('C', 'calendar-data', null,
@@ -1168,13 +1167,13 @@  discard block
 block discarded – undo
1168 1167
 					'UID' => $event['uid'],
1169 1168
 					'ORGANIZER' => $organizer,
1170 1169
 					'ATTENDEE' => $attendee,
1171
-				)+(empty($mask_uid) || !is_string($mask_uid) ? array() : array(
1170
+				) + (empty($mask_uid) || !is_string($mask_uid) ? array() : array(
1172 1171
 					'X-CALENDARSERVER-MASK-UID' => $mask_uid,
1173 1172
 				))));
1174 1173
 
1175
-			$xml->endElement();	// response
1174
+			$xml->endElement(); // response
1176 1175
 		}
1177
-		$xml->endElement();	// schedule-response
1176
+		$xml->endElement(); // schedule-response
1178 1177
 		$xml->endDocument();
1179 1178
 		echo $xml->outputMemory();
1180 1179
 
@@ -1189,14 +1188,14 @@  discard block
 block discarded – undo
1189 1188
 	 * @param int $user account_id
1190 1189
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1191 1190
 	 */
1192
-	function free_busy_report($path,$options,$user)
1191
+	function free_busy_report($path, $options, $user)
1193 1192
 	{
1194
-		unset($path);	// unused, but required by function signature
1193
+		unset($path); // unused, but required by function signature
1195 1194
 		if (!$this->bo->check_perms(calendar_bo::ACL_FREEBUSY, 0, $user))
1196 1195
 		{
1197 1196
 			return '403 Forbidden';
1198 1197
 		}
1199
-		foreach($options['other'] as $filter)
1198
+		foreach ($options['other'] as $filter)
1200 1199
 		{
1201 1200
 			if ($filter['name'] == 'time-range')
1202 1201
 			{
@@ -1208,7 +1207,7 @@  discard block
 block discarded – undo
1208 1207
 		header('Content-Type: text/calendar');
1209 1208
 		echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array());
1210 1209
 
1211
-		exit();	// otherwise we get a 207 multistatus, not 200 Ok
1210
+		exit(); // otherwise we get a 207 multistatus, not 200 Ok
1212 1211
 	}
1213 1212
 
1214 1213
 	/**
@@ -1220,7 +1219,7 @@  discard block
 block discarded – undo
1220 1219
 	 * @param int $user =null owner of the collection, default current user
1221 1220
 	 * @return array with privileges
1222 1221
 	 */
1223
-	public function current_user_privileges($path, $user=null)
1222
+	public function current_user_privileges($path, $user = null)
1224 1223
 	{
1225 1224
 		$privileges = parent::current_user_privileges($path, $user);
1226 1225
 		//error_log(__METHOD__."('$path', $user) parent gave ".array2string($privileges));
@@ -1263,7 +1262,7 @@  discard block
 block discarded – undo
1263 1262
 
1264 1263
 		// get array with orginal recurrences indexed by recurrence-id
1265 1264
 		$org_recurrences = $exceptions = array();
1266
-		foreach(self::get_series($events[0]['uid'],$bo) as $k => $event)
1265
+		foreach (self::get_series($events[0]['uid'], $bo) as $k => $event)
1267 1266
 		{
1268 1267
 			if (!$k) $master = $event;
1269 1268
 			if ($event['recurrence'])
@@ -1273,13 +1272,13 @@  discard block
 block discarded – undo
1273 1272
 		}
1274 1273
 
1275 1274
 		// assign cal_id's to already existing recurrences and evtl. re-add recur_exception to master
1276
-		foreach($events as $k => &$recurrence)
1275
+		foreach ($events as $k => &$recurrence)
1277 1276
 		{
1278 1277
 			if (!$recurrence['recurrence'])
1279 1278
 			{
1280 1279
 				// master
1281 1280
 				$recurrence['id'] = $master['id'];
1282
-				$master =& $events[$k];
1281
+				$master = & $events[$k];
1283 1282
 				continue;
1284 1283
 			}
1285 1284
 
@@ -1303,12 +1302,12 @@  discard block
 block discarded – undo
1303 1302
 		$master['recur_exception'] = array_merge($exceptions, $master['recur_exception']);
1304 1303
 
1305 1304
 		// delete not longer existing recurrences
1306
-		foreach($org_recurrences as $org_recurrence)
1305
+		foreach ($org_recurrences as $org_recurrence)
1307 1306
 		{
1308 1307
 			if ($org_recurrence['id'] != $master['id'])	// non-virtual recurrence
1309 1308
 			{
1310 1309
 				//error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
1311
-				$bo->delete($org_recurrence['id']);	// might fail because of permissions
1310
+				$bo->delete($org_recurrence['id']); // might fail because of permissions
1312 1311
 			}
1313 1312
 			else	// virtual recurrence
1314 1313
 			{
@@ -1329,25 +1328,25 @@  discard block
 block discarded – undo
1329 1328
 	 * @param int $id
1330 1329
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1331 1330
 	 */
1332
-	function delete(&$options,$id)
1331
+	function delete(&$options, $id)
1333 1332
 	{
1334 1333
 		if (strpos($options['path'], '/inbox/') !== false)
1335 1334
 		{
1336
-			return true;	// simply ignore DELETE in inbox for now
1335
+			return true; // simply ignore DELETE in inbox for now
1337 1336
 		}
1338
-		$return_no_access = true;	// to allow to check if current use is a participant and reject the event for him
1339
-		if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access)
1337
+		$return_no_access = true; // to allow to check if current use is a participant and reject the event for him
1338
+		if (!is_array($event = $this->_common_get_put_delete('DELETE', $options, $id, $return_no_access)) || !$return_no_access)
1340 1339
 		{
1341 1340
  			if (!$return_no_access)
1342 1341
 			{
1343 1342
 				// check if user is a participant or one of the groups he is a member of --> reject the meeting request
1344 1343
 				$ret = '403 Forbidden';
1345 1344
 				$memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true);
1346
-				foreach(array_keys($event['participants']) as $uid)
1345
+				foreach (array_keys($event['participants']) as $uid)
1347 1346
 				{
1348 1347
 					if ($this->bo->user == $uid || in_array($uid, $memberships))
1349 1348
 					{
1350
-						$this->bo->set_status($event,$this->bo->user, 'R');
1349
+						$this->bo->set_status($event, $this->bo->user, 'R');
1351 1350
 						$ret = true;
1352 1351
 						break;
1353 1352
 					}
@@ -1362,7 +1361,7 @@  discard block
 block discarded – undo
1362 1361
 		{
1363 1362
 			$ret = $this->bo->delete($event['id']);
1364 1363
 		}
1365
-		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1364
+		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event) ? $event['participants'] : null).", user={$this->bo->user} --> return ".array2string($ret));
1366 1365
 		return $ret;
1367 1366
 	}
1368 1367
 
@@ -1377,12 +1376,12 @@  discard block
 block discarded – undo
1377 1376
 	 */
1378 1377
 	function read($id)
1379 1378
 	{
1380
-		if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column;
1379
+		if (strpos($column = self::$path_attr, '_') === false) $column = 'cal_'.$column;
1381 1380
 
1382 1381
 		$event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server');
1383
-		if ($event) $event = array_shift($event);	// read with array as 1. param, returns an array of events!
1382
+		if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events!
1384 1383
 
1385
-		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) &&
1384
+		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY, $event, 0, 'server')) &&
1386 1385
 			// above can be true, if current user is not in master but just a recurrence
1387 1386
 			(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
1388 1387
 		{
@@ -1418,11 +1417,11 @@  discard block
 block discarded – undo
1418 1417
 	 *
1419 1418
 	 * @return string
1420 1419
 	 */
1421
-	public function getctag($path,$user)
1420
+	public function getctag($path, $user)
1422 1421
 	{
1423
-		$ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1422
+		$ctag = $this->bo->get_ctag($user, $path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1424 1423
 
1425
-		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1424
+		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($path)[$user] = $ctag");
1426 1425
 
1427 1426
 		return $ctag;
1428 1427
 	}
@@ -1434,7 +1433,7 @@  discard block
 block discarded – undo
1434 1433
 	 * @param string $schedule_tag =null on return schedule-tag
1435 1434
 	 * @return string|boolean string with etag or false
1436 1435
 	 */
1437
-	function get_etag($entry, &$schedule_tag=null)
1436
+	function get_etag($entry, &$schedule_tag = null)
1438 1437
 	{
1439 1438
 		$etag = $this->bo->get_etag($entry, $schedule_tag, $this->client_shared_uid_exceptions);
1440 1439
 
@@ -1452,7 +1451,7 @@  discard block
 block discarded – undo
1452 1451
 	 * @param int|string $retval
1453 1452
 	 * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
1454 1453
 	 */
1455
-	function put_response_headers($entry, $path, $retval, $path_attr_is_name=true)
1454
+	function put_response_headers($entry, $path, $retval, $path_attr_is_name = true)
1456 1455
 	{
1457 1456
 		$schedule_tag = null;
1458 1457
 		$etag = $this->get_etag($entry, $schedule_tag);
@@ -1471,14 +1470,14 @@  discard block
 block discarded – undo
1471 1470
 	 * @param array|int $event event-array or id
1472 1471
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1473 1472
 	 */
1474
-	function check_access($acl,$event)
1473
+	function check_access($acl, $event)
1475 1474
 	{
1476 1475
 		if ($acl == Acl::READ)
1477 1476
 		{
1478 1477
 			// we need at least calendar_bo::ACL_FREEBUSY to get some information
1479 1478
 			$acl = calendar_bo::ACL_FREEBUSY;
1480 1479
 		}
1481
-		return $this->bo->check_perms($acl,$event,0,'server');
1480
+		return $this->bo->check_perms($acl, $event, 0, 'server');
1482 1481
 	}
1483 1482
 
1484 1483
 	/**
@@ -1491,53 +1490,53 @@  discard block
 block discarded – undo
1491 1490
 	 * @param string $path =null path of the collection
1492 1491
 	 * @return array
1493 1492
 	 */
1494
-	public function extra_properties(array $props, $displayname, $base_uri=null, $user=null, $path=null)
1493
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null, $path = null)
1495 1494
 	{
1496
-		unset($base_uri);	// unused, but required by function signature
1495
+		unset($base_uri); // unused, but required by function signature
1497 1496
 		if (!isset($props['calendar-description']))
1498 1497
 		{
1499 1498
 			// default calendar description: can be overwritten via PROPPATCH, in which case it's already set
1500
-			$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname);
1499
+			$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname);
1501 1500
 		}
1502 1501
 		$supported_components = array(
1503
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VCALENDAR')),
1504
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VEVENT')),
1502
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VCALENDAR')),
1503
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VEVENT')),
1505 1504
 		);
1506 1505
 		// outbox supports VFREEBUSY too, it is required from OS X iCal to autocomplete locations
1507
-		if (substr($path,-8) == '/outbox/')
1506
+		if (substr($path, -8) == '/outbox/')
1508 1507
 		{
1509
-			$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VFREEBUSY'));
1508
+			$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VFREEBUSY'));
1510 1509
 		}
1511 1510
 		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,
1512
-			'supported-calendar-component-set',$supported_components);
1511
+			'supported-calendar-component-set', $supported_components);
1513 1512
 		// supported reports
1514 1513
 		$props['supported-report-set'] = array(
1515
-			'calendar-query' => Api\CalDAV::mkprop('supported-report',array(
1516
-				Api\CalDAV::mkprop('report',array(
1517
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))),
1518
-			'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array(
1519
-				Api\CalDAV::mkprop('report',array(
1520
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
1521
-			'free-busy-query' => Api\CalDAV::mkprop('supported-report',array(
1522
-				Api\CalDAV::mkprop('report',array(
1523
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'free-busy-query',''))))),
1514
+			'calendar-query' => Api\CalDAV::mkprop('supported-report', array(
1515
+				Api\CalDAV::mkprop('report', array(
1516
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))),
1517
+			'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array(
1518
+				Api\CalDAV::mkprop('report', array(
1519
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))),
1520
+			'free-busy-query' => Api\CalDAV::mkprop('supported-report', array(
1521
+				Api\CalDAV::mkprop('report', array(
1522
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'free-busy-query', ''))))),
1524 1523
 		);
1525 1524
 		// rfc 6578 sync-collection report for everything but outbox
1526 1525
 		// only if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
1527 1526
 		if (strpos($path, '/outbox/') === false && $GLOBALS['egw_info']['server']['calendar_delete_history'])
1528 1527
 		{
1529
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
1530
-				Api\CalDAV::mkprop('report',array(
1531
-					Api\CalDAV::mkprop('sync-collection','')))));
1528
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
1529
+				Api\CalDAV::mkprop('report', array(
1530
+					Api\CalDAV::mkprop('sync-collection', '')))));
1532 1531
 		}
1533
-		$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-data',array(
1534
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
1535
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
1532
+		$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-data', array(
1533
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
1534
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
1536 1535
 
1537 1536
 		// get timezone of calendar
1538 1537
 		if ($this->caldav->prop_requested('calendar-timezone'))
1539 1538
 		{
1540
-			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone',
1539
+			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone',
1541 1540
 				calendar_timezones::user_timezone($user));
1542 1541
 		}
1543 1542
 		return $props;
@@ -1551,9 +1550,9 @@  discard block
 block discarded – undo
1551 1550
 	private function _get_handler()
1552 1551
 	{
1553 1552
 		$handler = new calendar_ical();
1554
-		$handler->setSupportedFields('GroupDAV',$this->agent);
1555
-		$handler->supportedFields['attachments'] = true;	// enabling attachments
1556
-		if ($this->debug > 1) error_log("ical Handler called: " . $this->agent);
1553
+		$handler->setSupportedFields('GroupDAV', $this->agent);
1554
+		$handler->supportedFields['attachments'] = true; // enabling attachments
1555
+		if ($this->debug > 1) error_log("ical Handler called: ".$this->agent);
1557 1556
 		return $handler;
1558 1557
 	}
1559 1558
 
@@ -1568,7 +1567,7 @@  discard block
 block discarded – undo
1568 1567
 		$pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set'];
1569 1568
 		$calendar_home_set = $pref ? explode(',', $pref) : array();
1570 1569
 		// replace symbolic id's with real nummeric id's
1571
-		foreach(array(
1570
+		foreach (array(
1572 1571
 			'G' => $GLOBALS['egw_info']['user']['account_primary_group'],
1573 1572
 		) as $sym => $id)
1574 1573
 		{
@@ -1577,11 +1576,11 @@  discard block
 block discarded – undo
1577 1576
 				$calendar_home_set[$key] = $id;
1578 1577
 			}
1579 1578
 		}
1580
-		foreach(ExecMethod('calendar.calendar_bo.list_cals') as $entry)
1579
+		foreach (ExecMethod('calendar.calendar_bo.list_cals') as $entry)
1581 1580
 		{
1582 1581
 			$id = $entry['grantor'];
1583
-			if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id &&	// no current user
1584
-				(in_array('A',$calendar_home_set) || in_array((string)$id,$calendar_home_set)) &&
1582
+			if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user
1583
+				(in_array('A', $calendar_home_set) || in_array((string)$id, $calendar_home_set)) &&
1585 1584
 				is_numeric($id) && ($owner = $this->accounts->id2name($id)))
1586 1585
 			{
1587 1586
 				$shared[$id] = 'calendar-'.$owner;
@@ -1590,11 +1589,11 @@  discard block
 block discarded – undo
1590 1589
 		// shared locations and resources
1591 1590
 		if ($GLOBALS['egw_info']['user']['apps']['resources'])
1592 1591
 		{
1593
-			foreach(array('locations','resources') as $res)
1592
+			foreach (array('locations', 'resources') as $res)
1594 1593
 			{
1595 1594
 				if (($pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set-'.$res]))
1596 1595
 				{
1597
-					foreach(explode(',', $pref) as $res_id)
1596
+					foreach (explode(',', $pref) as $res_id)
1598 1597
 					{
1599 1598
 						$is_location = $res == 'locations';
1600 1599
 						$shared['r'.$res_id] = str_replace('s/', '-', Api\CalDAV\Principals::resource2name($res_id, $is_location));
@@ -1624,7 +1623,7 @@  discard block
 block discarded – undo
1624 1623
 			{
1625 1624
 				$calendars[$entry['grantor']] = $entry['name'];
1626 1625
 			}
1627
-			if ($user > 0) unset($calendars[$user]);	// skip current user
1626
+			if ($user > 0) unset($calendars[$user]); // skip current user
1628 1627
 		}
1629 1628
 
1630 1629
 		$settings = array();
@@ -1632,7 +1631,7 @@  discard block
 block discarded – undo
1632 1631
 			'type'   => 'multiselect',
1633 1632
 			'label'  => 'Calendars to sync in addition to personal calendar',
1634 1633
 			'name'   => 'calendar-home-set',
1635
-			'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'),
1634
+			'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'),
1636 1635
 			'values' => $calendars,
1637 1636
 			'xmlrpc' => True,
1638 1637
 			'admin'  => False,
@@ -1658,7 +1657,7 @@  discard block
 block discarded – undo
1658 1657
 		if ($GLOBALS['egw_info']['user']['apps']['resources'] && ($all_resources = Api\CalDAV\Principals::get_resources()))
1659 1658
 		{
1660 1659
 			$resources = $locations = array();
1661
-			foreach($all_resources as $resource)
1660
+			foreach ($all_resources as $resource)
1662 1661
 			{
1663 1662
 				if (Api\CalDAV\Principals::resource_is_location($resource))
1664 1663
 				{
@@ -1669,7 +1668,7 @@  discard block
 block discarded – undo
1669 1668
 					$resources[$resource['res_id']] = $resource['name'];
1670 1669
 				}
1671 1670
 			}
1672
-			foreach(array(
1671
+			foreach (array(
1673 1672
 				'locations' => $locations,
1674 1673
 				'resources' => $resources,
1675 1674
 			) as $name => $options)
@@ -1682,7 +1681,7 @@  discard block
 block discarded – undo
1682 1681
 						'label'  => lang('%1 to sync', lang($name == 'locations' ? 'Location calendars' : 'Resource calendars')),
1683 1682
 						'no_lang'=> true,
1684 1683
 						'name'   => 'calendar-home-set-'.$name,
1685
-						'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'),
1684
+						'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'),
1686 1685
 						'values' => $options,
1687 1686
 						'xmlrpc' => True,
1688 1687
 						'admin'  => False,
Please login to merge, or discard this patch.
Braces   +225 added lines, -56 removed lines patch added patch discarded remove patch
@@ -120,7 +120,10 @@  discard block
 block discarded – undo
120 120
 		}
121 121
 		else
122 122
 		{
123
-			if (!is_array($event)) $event = $this->bo->read($event);
123
+			if (!is_array($event))
124
+			{
125
+				$event = $this->bo->read($event);
126
+			}
124 127
 			$name = $event[self::$path_attr];
125 128
 		}
126 129
 		$name .= self::$path_extension;
@@ -181,10 +184,13 @@  discard block
 block discarded – undo
181 184
 			}
182 185
 			$filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value);
183 186
 		}
184
-		if ($this->client_shared_uid_exceptions)	// do NOT return (non-virtual) exceptions
187
+		if ($this->client_shared_uid_exceptions)
188
+		{
189
+			// do NOT return (non-virtual) exceptions
185 190
 		{
186 191
 			$filter['query'] = array('cal_reference' => 0);
187 192
 		}
193
+		}
188 194
 
189 195
 		if ($path == '/calendar/')
190 196
 		{
@@ -214,7 +220,11 @@  discard block
 block discarded – undo
214 220
 			// when trying to request not supported components, eg. VTODO on a calendar collection
215 221
 			return true;
216 222
 		}
217
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
223
+		if ($id)
224
+		{
225
+			$path = dirname($path).'/';
226
+		}
227
+		// caldav_name get's added anyway in the callback
218 228
 
219 229
 		if ($this->debug > 1)
220 230
 		{
@@ -276,7 +286,11 @@  discard block
 block discarded – undo
276 286
 		$n = 0;
277 287
 		foreach($files as $file)
278 288
 		{
279
-			if (!$n++) continue;	// first entry is collection itself
289
+			if (!$n++)
290
+			{
291
+				continue;
292
+			}
293
+			// first entry is collection itself
280 294
 
281 295
 			$icalendar = $file['props']['calendar-data']['val'];
282 296
 			if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false &&
@@ -320,10 +334,17 @@  discard block
 block discarded – undo
320 334
 	 */
321 335
 	function propfind_callback($path,array $filter,$start=false)
322 336
 	{
323
-		if ($this->debug) $starttime = microtime(true);
337
+		if ($this->debug)
338
+		{
339
+			$starttime = microtime(true);
340
+		}
324 341
 
325 342
 		$calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true);
326
-		if (!is_array($calendar_data)) $calendar_data = false;	// not in allprop or autoindex
343
+		if (!is_array($calendar_data))
344
+		{
345
+			$calendar_data = false;
346
+		}
347
+		// not in allprop or autoindex
327 348
 
328 349
 		$files = array();
329 350
 
@@ -481,7 +502,10 @@  discard block
 block discarded – undo
481 502
 				switch($filter['name'])
482 503
 				{
483 504
 					case 'comp-filter':
484
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
505
+						if ($this->debug > 1)
506
+						{
507
+							error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
508
+						}
485 509
 
486 510
 						switch($filter['attrs']['name'])
487 511
 						{
@@ -496,14 +520,23 @@  discard block
 block discarded – undo
496 520
 						}
497 521
 						break;
498 522
 					case 'prop-filter':
499
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
523
+						if ($this->debug > 1)
524
+						{
525
+							error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
526
+						}
500 527
 						$prop_filter = $filter['attrs']['name'];
501 528
 						break;
502 529
 					case 'text-match':
503
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
530
+						if ($this->debug > 1)
531
+						{
532
+							error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
533
+						}
504 534
 						if (!isset($this->filter_prop2cal[strtoupper($prop_filter)]))
505 535
 						{
506
-							if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
536
+							if ($this->debug)
537
+							{
538
+								error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
539
+							}
507 540
 						}
508 541
 						else
509 542
 						{
@@ -512,10 +545,16 @@  discard block
 block discarded – undo
512 545
 						unset($prop_filter);
513 546
 						break;
514 547
 					case 'param-filter':
515
-						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
548
+						if ($this->debug)
549
+						{
550
+							error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
551
+						}
516 552
 						break;
517 553
 					case 'time-range':
518
-				 		if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
554
+				 		if ($this->debug > 1)
555
+				 		{
556
+				 			error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
557
+				 		}
519 558
 				 		if (!empty($filter['attrs']['start']))
520 559
 				 		{
521 560
 					 		$cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']);
@@ -526,13 +565,19 @@  discard block
 block discarded – undo
526 565
 				 		}
527 566
 						break;
528 567
 					default:
529
-						if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
568
+						if ($this->debug)
569
+						{
570
+							error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
571
+						}
530 572
 						break;
531 573
 				}
532 574
 			}
533
-			if (count($cal_filters) == $num_filters)	// no filters set --> restore default start and end time
575
+			if (count($cal_filters) == $num_filters)
576
+			{
577
+				// no filters set --> restore default start and end time
534 578
 			{
535 579
 				$cal_filters['start'] = $cal_start;
580
+			}
536 581
 				$cal_filters['end']   = $cal_end;
537 582
 			}
538 583
 		}
@@ -609,7 +654,10 @@  discard block
 block discarded – undo
609 654
 				}
610 655
 			}
611 656
 
612
-			if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
657
+			if ($this->debug > 1)
658
+			{
659
+				error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
660
+			}
613 661
 		}
614 662
 		return true;
615 663
 	}
@@ -655,9 +703,15 @@  discard block
 block discarded – undo
655 703
 	private function iCal(array $event,$user=null, $method=null, $expand=false)
656 704
 	{
657 705
 		static $handler = null;
658
-		if (is_null($handler)) $handler = $this->_get_handler();
706
+		if (is_null($handler))
707
+		{
708
+			$handler = $this->_get_handler();
709
+		}
659 710
 
660
-		if (!$user) $user = $GLOBALS['egw_info']['user']['account_id'];
711
+		if (!$user)
712
+		{
713
+			$user = $GLOBALS['egw_info']['user']['account_id'];
714
+		}
661 715
 
662 716
 		// only return alarms in own calendar, not other users calendars
663 717
 		if ($user != $GLOBALS['egw_info']['user']['account_id'])
@@ -673,8 +727,14 @@  discard block
 block discarded – undo
673 727
 		{
674 728
 			if (is_array($expand))
675 729
 			{
676
-				if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
677
-				if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
730
+				if (isset($expand['start']))
731
+				{
732
+					$expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
733
+				}
734
+				if (isset($expand['end']))
735
+				{
736
+					$expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
737
+				}
678 738
 			}
679 739
 			$events =& self::get_series($event['uid'], $this->bo, $expand, $user);
680 740
 		}
@@ -698,7 +758,10 @@  discard block
 block discarded – undo
698 758
 	 */
699 759
 	private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null)
700 760
 	{
701
-		if (is_null($bo)) $bo = new calendar_bopdate();
761
+		if (is_null($bo))
762
+		{
763
+			$bo = new calendar_bopdate();
764
+		}
702 765
 
703 766
 		$params = array(
704 767
 			'query' => array('cal_uid' => $uid),
@@ -707,7 +770,10 @@  discard block
 block discarded – undo
707 770
 			'date_format' => 'server',
708 771
 			'cfs' => array(),	// read cfs as we use them to store X- attributes
709 772
 		);
710
-		if (is_array($expand)) $params += $expand;
773
+		if (is_array($expand))
774
+		{
775
+			$params += $expand;
776
+		}
711 777
 
712 778
 		if (!($events =& $bo->search($params)))
713 779
 		{
@@ -728,12 +794,17 @@  discard block
 block discarded – undo
728 794
 			}
729 795
 		}
730 796
 		// if recurring event starts in future behind horizont, nothing will be returned by bo::search()
731
-		if (!isset($master)) $master = $bo->read($uid);
797
+		if (!isset($master))
798
+		{
799
+			$master = $bo->read($uid);
800
+		}
732 801
 
733 802
 		foreach($events as $k => &$recurrence)
734 803
 		{
735 804
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence));
736
-			if (!$master || $recurrence['id'] != $master['id'])	// real exception
805
+			if (!$master || $recurrence['id'] != $master['id'])
806
+			{
807
+				// real exception
737 808
 			{
738 809
 				// user is NOT participating in this exception
739 810
 				if ($user && !self::isParticipant($recurrence, $user))
@@ -742,6 +813,7 @@  discard block
 block discarded – undo
742 813
 					if (!$master || !self::isParticipant($master, $user))
743 814
 					{
744 815
 						unset($events[$k]);
816
+			}
745 817
 						continue;
746 818
 					}
747 819
 					// otherwise mark him in this exception as rejected
@@ -777,7 +849,10 @@  discard block
 block discarded – undo
777 849
 			// this is a virtual exception now (no extra event/cal_id in DB)
778 850
 			//error_log('virtual exception: '.array2string($recurrence));
779 851
 			$recurrence['recurrence'] = $recurrence['start'];
780
-			if ($master) $recurrence['reference'] = $master['id'];
852
+			if ($master)
853
+			{
854
+				$recurrence['reference'] = $master['id'];
855
+			}
781 856
 			$recurrence['recur_type'] = MCAL_RECUR_NONE;	// is set, as this is a copy of the master
782 857
 			// not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start'];
783 858
 		}
@@ -814,9 +889,16 @@  discard block
 block discarded – undo
814 889
 	 */
815 890
 	function put(&$options,$id,$user=null,$prefix=null)
816 891
 	{
817
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
892
+		if ($this->debug)
893
+		{
894
+			error_log(__METHOD__."($id, $user)".print_r($options,true));
895
+		}
818 896
 
819
-		if (!$prefix) $user = null;	// /infolog/ does not imply setting the current user (for new entries it's done anyway)
897
+		if (!$prefix)
898
+		{
899
+			$user = null;
900
+		}
901
+		// /infolog/ does not imply setting the current user (for new entries it's done anyway)
820 902
 
821 903
 		// fix for iCal4OL using WinHTTP only supporting a certain header length
822 904
 		if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']))
@@ -828,7 +910,10 @@  discard block
 block discarded – undo
828 910
 			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']));	// dont fail with 412 Precondition Failed in that case
829 911
 		if (!is_null($oldEvent) && !is_array($oldEvent))
830 912
 		{
831
-			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
913
+			if ($this->debug)
914
+			{
915
+				error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
916
+			}
832 917
 			return $oldEvent;
833 918
 		}
834 919
 
@@ -839,7 +924,10 @@  discard block
 block discarded – undo
839 924
 		{
840 925
 			// we have no add permission on this user's calendar
841 926
 			// ToDo: create event in current users calendar and invite only $user
842
-			if ($this->debug) error_log(__METHOD__."(,,$user) we have not enough rights on this calendar");
927
+			if ($this->debug)
928
+			{
929
+				error_log(__METHOD__."(,,$user) we have not enough rights on this calendar");
930
+			}
843 931
 			return '403 Forbidden';
844 932
 		}
845 933
 
@@ -887,13 +975,19 @@  discard block
 block discarded – undo
887 975
 			if ($this->use_schedule_tag && isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']))
888 976
 			{
889 977
 				$schedule_tag_match = $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'];
890
-				if ($schedule_tag_match[0] == '"') $schedule_tag_match = substr($schedule_tag_match, 1, -1);
978
+				if ($schedule_tag_match[0] == '"')
979
+				{
980
+					$schedule_tag_match = substr($schedule_tag_match, 1, -1);
981
+				}
891 982
 				$schedule_tag = null;
892 983
 				$this->get_etag($oldEvent, $schedule_tag);
893 984
 
894 985
 				if ($schedule_tag_match !== $schedule_tag)
895 986
 				{
896
-					if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
987
+					if ($this->debug)
988
+					{
989
+						error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
990
+					}
897 991
 					// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
898 992
 					$this->check_return_representation($options, $id, $user);
899 993
 					return '412 Precondition Failed';
@@ -908,7 +1002,10 @@  discard block
 block discarded – undo
908 1002
 					// above can be true, if current user is not in master but just a recurrence
909 1003
 					(!$oldEvent['recur_type'] || !($series = self::get_series($oldEvent['uid'], $this->bo))))
910 1004
 				{
911
-					if ($this->debug) error_log(__METHOD__."(,,$user) user $user is NOT an attendee!");
1005
+					if ($this->debug)
1006
+					{
1007
+						error_log(__METHOD__."(,,$user) user $user is NOT an attendee!");
1008
+					}
912 1009
 					return '403 Forbidden';
913 1010
 				}
914 1011
 				// update only participant status and alarms of current user
@@ -928,7 +1025,10 @@  discard block
 block discarded – undo
928 1025
 							}
929 1026
 							foreach($series as $oldEvent)
930 1027
 							{
931
-								if ($oldEvent['recurrence'] == $event['recurrence']) break;
1028
+								if ($oldEvent['recurrence'] == $event['recurrence'])
1029
+								{
1030
+									break;
1031
+								}
932 1032
 							}
933 1033
 							// if no exception found, check if it might be just a recurrence (no exception)
934 1034
 							if ($event['recurrence'] && $oldEvent['recurrence'] != $event['recurrence'])
@@ -943,7 +1043,10 @@  discard block
 block discarded – undo
943 1043
 								}
944 1044
 							}
945 1045
 						}
946
-						if ($this->debug) error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event));
1046
+						if ($this->debug)
1047
+						{
1048
+							error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event));
1049
+						}
947 1050
 						if (isset($event['participants']) && isset($event['participants'][$user]) &&
948 1051
 							$event['participants'][$user] !== $oldEvent['participants'][$user])
949 1052
 						{
@@ -951,13 +1054,19 @@  discard block
 block discarded – undo
951 1054
 								// real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence!
952 1055
 								$recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0))
953 1056
 							{
954
-								if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')');
1057
+								if ($this->debug)
1058
+								{
1059
+									error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')');
1060
+								}
955 1061
 								return '403 Forbidden';
956 1062
 							}
957 1063
 							else
958 1064
 							{
959 1065
 								++$modified;
960
-								if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')');
1066
+								if ($this->debug)
1067
+								{
1068
+									error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')');
1069
+								}
961 1070
 							}
962 1071
 						}
963 1072
 						// import alarms, if given and changed
@@ -967,15 +1076,21 @@  discard block
 block discarded – undo
967 1076
 							$modified += $handler->sync_alarms($event, (array)$oldEvent['alarm'], $user);
968 1077
 						}
969 1078
 					}
970
-					if (!$modified)	// NO modififictions, or none we understood --> log it and return Ok: "204 No Content"
1079
+					if (!$modified)
1080
+					{
1081
+						// NO modififictions, or none we understood --> log it and return Ok: "204 No Content"
971 1082
 					{
972 1083
 						$this->caldav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent));
973 1084
 					}
1085
+					}
974 1086
 					$this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name');
975 1087
 
976 1088
 					return '204 No Content';
977 1089
 				}
978
-				if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT");
1090
+				if ($this->debug && !isset($events))
1091
+				{
1092
+					error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT");
1093
+				}
979 1094
 			}
980 1095
 			if ($return_no_access)
981 1096
 			{
@@ -1007,17 +1122,23 @@  discard block
 block discarded – undo
1007 1122
 		if (!($cal_id = $handler->importVCal($vCalendar, $eventId,
1008 1123
 			self::etag2value($this->http_if_match), false, 0, $this->caldav->current_user_principal, $user, $charset, $id)))
1009 1124
 		{
1010
-			if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id));
1125
+			if ($this->debug)
1126
+			{
1127
+				error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id));
1128
+			}
1011 1129
 			if ($eventId && $cal_id === false)
1012 1130
 			{
1013 1131
 				// ignore import failures
1014 1132
 				$cal_id = $eventId;
1015 1133
 				$retval = true;
1016 1134
 			}
1017
-			elseif ($cal_id === 0)	// etag failure
1135
+			elseif ($cal_id === 0)
1136
+			{
1137
+				// etag failure
1018 1138
 			{
1019 1139
 				// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
1020 1140
 				$this->check_return_representation($options, $id, $user);
1141
+			}
1021 1142
 				return '412 Precondition Failed';
1022 1143
 			}
1023 1144
 			else
@@ -1042,7 +1163,10 @@  discard block
 block discarded – undo
1042 1163
 	 */
1043 1164
 	function post(&$options,$id,$user=null)
1044 1165
 	{
1045
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
1166
+		if ($this->debug)
1167
+		{
1168
+			error_log(__METHOD__."($id, $user)".print_r($options,true));
1169
+		}
1046 1170
 
1047 1171
 		$vCalendar = htmlspecialchars_decode($options['content']);
1048 1172
 		$charset = null;
@@ -1097,7 +1221,10 @@  discard block
 block discarded – undo
1097 1221
 				if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null,
1098 1222
 					false, 0, $this->caldav->current_user_principal, $user, $charset)))
1099 1223
 				{
1100
-					if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false");
1224
+					if ($this->debug)
1225
+					{
1226
+						error_log(__METHOD__."() importVCal($eventId) returned false");
1227
+					}
1101 1228
 				}
1102 1229
 				header('ETag: "'.$this->get_etag($eventId).'"');
1103 1230
 			}
@@ -1265,7 +1392,10 @@  discard block
 block discarded – undo
1265 1392
 		$org_recurrences = $exceptions = array();
1266 1393
 		foreach(self::get_series($events[0]['uid'],$bo) as $k => $event)
1267 1394
 		{
1268
-			if (!$k) $master = $event;
1395
+			if (!$k)
1396
+			{
1397
+				$master = $event;
1398
+			}
1269 1399
 			if ($event['recurrence'])
1270 1400
 			{
1271 1401
 				$org_recurrences[$event['recurrence']] = $event;
@@ -1285,10 +1415,13 @@  discard block
 block discarded – undo
1285 1415
 
1286 1416
 			// from now on we deal with exceptions
1287 1417
 			$org_recurrence = $org_recurrences[$recurrence['recurrence']];
1288
-			if (isset($org_recurrence))	// already existing recurrence
1418
+			if (isset($org_recurrence))
1419
+			{
1420
+				// already existing recurrence
1289 1421
 			{
1290 1422
 				//error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']);
1291 1423
 				$recurrence['id'] = $org_recurrence['id'];
1424
+			}
1292 1425
 
1293 1426
 				// re-add (non-virtual) exceptions to master's recur_exception
1294 1427
 				if ($recurrence['id'] != $master['id'])
@@ -1305,10 +1438,14 @@  discard block
 block discarded – undo
1305 1438
 		// delete not longer existing recurrences
1306 1439
 		foreach($org_recurrences as $org_recurrence)
1307 1440
 		{
1308
-			if ($org_recurrence['id'] != $master['id'])	// non-virtual recurrence
1441
+			if ($org_recurrence['id'] != $master['id'])
1442
+			{
1443
+				// non-virtual recurrence
1309 1444
 			{
1310 1445
 				//error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
1311
-				$bo->delete($org_recurrence['id']);	// might fail because of permissions
1446
+				$bo->delete($org_recurrence['id']);
1447
+			}
1448
+			// might fail because of permissions
1312 1449
 			}
1313 1450
 			else	// virtual recurrence
1314 1451
 			{
@@ -1339,7 +1476,7 @@  discard block
 block discarded – undo
1339 1476
 		if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access)
1340 1477
 		{
1341 1478
  			if (!$return_no_access)
1342
-			{
1479
+ 			{
1343 1480
 				// check if user is a participant or one of the groups he is a member of --> reject the meeting request
1344 1481
 				$ret = '403 Forbidden';
1345 1482
 				$memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true);
@@ -1362,7 +1499,10 @@  discard block
 block discarded – undo
1362 1499
 		{
1363 1500
 			$ret = $this->bo->delete($event['id']);
1364 1501
 		}
1365
-		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1502
+		if ($this->debug)
1503
+		{
1504
+			error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1505
+		}
1366 1506
 		return $ret;
1367 1507
 	}
1368 1508
 
@@ -1377,16 +1517,26 @@  discard block
 block discarded – undo
1377 1517
 	 */
1378 1518
 	function read($id)
1379 1519
 	{
1380
-		if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column;
1520
+		if (strpos($column=self::$path_attr,'_') === false)
1521
+		{
1522
+			$column = 'cal_'.$column;
1523
+		}
1381 1524
 
1382 1525
 		$event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server');
1383
-		if ($event) $event = array_shift($event);	// read with array as 1. param, returns an array of events!
1526
+		if ($event)
1527
+		{
1528
+			$event = array_shift($event);
1529
+		}
1530
+		// read with array as 1. param, returns an array of events!
1384 1531
 
1385 1532
 		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) &&
1386 1533
 			// above can be true, if current user is not in master but just a recurrence
1387 1534
 			(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
1388 1535
 		{
1389
-			if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval));
1536
+			if ($this->debug > 0)
1537
+			{
1538
+				error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval));
1539
+			}
1390 1540
 			return $retval;
1391 1541
 		}
1392 1542
 		if (!$this->bo->check_perms(Acl::READ, $event, 0, 'server'))
@@ -1394,9 +1544,15 @@  discard block
 block discarded – undo
1394 1544
 			$this->bo->clear_private_infos($event, array($this->bo->user, $event['owner']));
1395 1545
 		}
1396 1546
 		// handle deleted events, as not existing
1397
-		if ($event['deleted']) $event = null;
1547
+		if ($event['deleted'])
1548
+		{
1549
+			$event = null;
1550
+		}
1398 1551
 
1399
-		if ($this->debug > 1) error_log(__METHOD__."($id) returning ".array2string($event));
1552
+		if ($this->debug > 1)
1553
+		{
1554
+			error_log(__METHOD__."($id) returning ".array2string($event));
1555
+		}
1400 1556
 
1401 1557
 		return $event;
1402 1558
 	}
@@ -1408,7 +1564,10 @@  discard block
 block discarded – undo
1408 1564
 	 */
1409 1565
 	public function update_tags($entry)
1410 1566
 	{
1411
-		if (!is_array($entry)) $entry = $this->read($entry);
1567
+		if (!is_array($entry))
1568
+		{
1569
+			$entry = $this->read($entry);
1570
+		}
1412 1571
 
1413 1572
 		$this->bo->update($entry, true);
1414 1573
 	}
@@ -1422,7 +1581,10 @@  discard block
 block discarded – undo
1422 1581
 	{
1423 1582
 		$ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1424 1583
 
1425
-		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1584
+		if ($this->debug > 1)
1585
+		{
1586
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1587
+		}
1426 1588
 
1427 1589
 		return $ctag;
1428 1590
 	}
@@ -1553,7 +1715,10 @@  discard block
 block discarded – undo
1553 1715
 		$handler = new calendar_ical();
1554 1716
 		$handler->setSupportedFields('GroupDAV',$this->agent);
1555 1717
 		$handler->supportedFields['attachments'] = true;	// enabling attachments
1556
-		if ($this->debug > 1) error_log("ical Handler called: " . $this->agent);
1718
+		if ($this->debug > 1)
1719
+		{
1720
+			error_log("ical Handler called: " . $this->agent);
1721
+		}
1557 1722
 		return $handler;
1558 1723
 	}
1559 1724
 
@@ -1624,7 +1789,11 @@  discard block
 block discarded – undo
1624 1789
 			{
1625 1790
 				$calendars[$entry['grantor']] = $entry['name'];
1626 1791
 			}
1627
-			if ($user > 0) unset($calendars[$user]);	// skip current user
1792
+			if ($user > 0)
1793
+			{
1794
+				unset($calendars[$user]);
1795
+			}
1796
+			// skip current user
1628 1797
 		}
1629 1798
 
1630 1799
 		$settings = array();
Please login to merge, or discard this patch.
calendar/inc/class.calendar_holidays.inc.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -135,6 +135,9 @@
 block discarded – undo
135 135
 		return $until_year ? $years : $years[$year];
136 136
 	}
137 137
 
138
+	/**
139
+	 * @param string $url
140
+	 */
138 141
 	protected static function is_url($url)
139 142
 	{
140 143
 		return $url[0] == '/' || strpos($url, '://') !== false;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param int $year =null default current year
40 40
 	 * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title'
41 41
 	 */
42
-	public static function read($country, $year=null)
42
+	public static function read($country, $year = null)
43 43
 	{
44 44
 		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
45 45
 		$level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE;
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 		$holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year);
48 48
 
49 49
 		// if we dont find holidays in cache, we render from previous year until next 5 years
50
-		if (!isset($holidays) && ($years = self::render($country, $year-1, $year+5)))
50
+		if (!isset($holidays) && ($years = self::render($country, $year - 1, $year + 5)))
51 51
 		{
52
-			foreach($years as $y => $data)
52
+			foreach ($years as $y => $data)
53 53
 			{
54 54
 				Api\Cache::setCache($level, __CLASS__, $country.':'.$y, $data, self::HOLIDAY_CACHE_TIME);
55 55
 			}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @param int $until_year =null default, fetch only one year, if given result is indexed additional by year
67 67
 	 * @return array of Ymd => array of array with values for keys 'occurence','month','day','name', (commented out) 'title'
68 68
 	 */
69
-	public static function render($country, $year=null, $until_year=null)
69
+	public static function render($country, $year = null, $until_year = null)
70 70
 	{
71 71
 		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
72 72
 		$end_year = $until_year && $year < $until_year ? $until_year : $year;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			return array();
78 78
 		}
79 79
 		$years = array();
80
-		foreach($holidays as $event)
80
+		foreach ($holidays as $event)
81 81
 		{
82 82
 			$start = new Api\DateTime($event['start']);
83 83
 			$end = new Api\DateTime($event['end']);
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 			if ($event['recur_type'])
89 89
 			{
90 90
 				// calendar_rrule limits no enddate, to 5 years
91
-				if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101';
91
+				if (!$event['recur_enddate']) $event['recur_enddate'] = (1 + $end_year).'0101';
92 92
 
93 93
 				$rrule = calendar_rrule::event2rrule($event);
94 94
 				if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue;
95 95
 
96
-				foreach($rrule as $rtime)
96
+				foreach ($rrule as $rtime)
97 97
 				{
98 98
 					if (($y = (int)$rtime->format('Y')) < $year) continue;
99 99
 					if ($y > $end_year) break;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			else
112 112
 			{
113 113
 				$end_ymd = (int)$end->format('Ymd');
114
-				while(($ymd = (int)$start->format('Ymd')) <= $end_ymd)
114
+				while (($ymd = (int)$start->format('Ymd')) <= $end_ymd)
115 115
 				{
116 116
 					$y = (int)$start->format('Y');
117 117
 					$years[$y][(string)$ymd][] = array(
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 				}
126 126
 			}
127 127
 		}
128
-		foreach($years as $y => &$data)
128
+		foreach ($years as $y => &$data)
129 129
 		{
130 130
 			ksort($data);
131 131
 		}
132
-		error_log(__METHOD__."('$country', $year, $end_year) took ".  number_format(microtime(true)-$starttime, 3).'s to fetch '.count(call_user_func_array('array_merge', $years)).' events');
132
+		error_log(__METHOD__."('$country', $year, $end_year) took ".number_format(microtime(true) - $starttime, 3).'s to fetch '.count(call_user_func_array('array_merge', $years)).' events');
133 133
 		unset($starttime);
134 134
 
135 135
 		return $until_year ? $years : $years[$year];
Please login to merge, or discard this patch.
Braces   +32 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,10 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function read($country, $year=null)
43 43
 	{
44
-		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
44
+		if (!$year)
45
+		{
46
+			$year = (int)Api\DateTime::to('now', 'Y');
47
+		}
45 48
 		$level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE;
46 49
 
47 50
 		$holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year);
@@ -68,7 +71,10 @@  discard block
 block discarded – undo
68 71
 	 */
69 72
 	public static function render($country, $year=null, $until_year=null)
70 73
 	{
71
-		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
74
+		if (!$year)
75
+		{
76
+			$year = (int)Api\DateTime::to('now', 'Y');
77
+		}
72 78
 		$end_year = $until_year && $year < $until_year ? $until_year : $year;
73 79
 
74 80
 		$starttime = microtime(true);
@@ -81,22 +87,40 @@  discard block
 block discarded – undo
81 87
 		{
82 88
 			$start = new Api\DateTime($event['start']);
83 89
 			$end = new Api\DateTime($event['end']);
84
-			if ($start->format('Y') > $end_year) continue;
85
-			if ($end->format('Y') < $year && !$event['recur_type']) continue;
90
+			if ($start->format('Y') > $end_year)
91
+			{
92
+				continue;
93
+			}
94
+			if ($end->format('Y') < $year && !$event['recur_type'])
95
+			{
96
+				continue;
97
+			}
86 98
 
87 99
 			// recuring events
88 100
 			if ($event['recur_type'])
89 101
 			{
90 102
 				// calendar_rrule limits no enddate, to 5 years
91
-				if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101';
103
+				if (!$event['recur_enddate'])
104
+				{
105
+					$event['recur_enddate'] = (1+$end_year).'0101';
106
+				}
92 107
 
93 108
 				$rrule = calendar_rrule::event2rrule($event);
94
-				if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue;
109
+				if ($rrule->enddate && $rrule->enddate->format('Y') < $year)
110
+				{
111
+					continue;
112
+				}
95 113
 
96 114
 				foreach($rrule as $rtime)
97 115
 				{
98
-					if (($y = (int)$rtime->format('Y')) < $year) continue;
99
-					if ($y > $end_year) break;
116
+					if (($y = (int)$rtime->format('Y')) < $year)
117
+					{
118
+						continue;
119
+					}
120
+					if ($y > $end_year)
121
+					{
122
+						break;
123
+					}
100 124
 
101 125
 					$ymd = (int)$rtime->format('Ymd');
102 126
 					$years[$y][(string)$ymd][] = array(
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ical.inc.php 4 patches
Doc Comments   +11 added lines, -7 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 *                          default 0 => export whole series (or events, if not recurring)
195 195
 	 * @param string $principalURL ='' Used for CalDAV exports
196 196
 	 * @param string $charset ='UTF-8' encoding of the vcalendar, default UTF-8
197
-	 * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY
197
+	 * @param integer $current_user =0 uid of current user to only export that one as participant for method=REPLY
198 198
 	 * @return string|boolean string with iCal or false on error (e.g. no permission to read the event)
199 199
 	 */
200 200
 	function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0)
@@ -1094,16 +1094,15 @@  discard block
 block discarded – undo
1094 1094
 	 * Import an iCal
1095 1095
 	 *
1096 1096
 	 * @param string|resource $_vcalData
1097
-	 * @param int $cal_id=-1 must be -1 for new entries!
1098
-	 * @param string $etag=null if an etag is given, it has to match the current etag or the import will fail
1099
-	 * @param boolean $merge=false	merge data with existing entry
1100
-	 * @param int $recur_date=0 if set, import the recurrence at this timestamp,
1097
+	 * @param int $cal_id must be -1 for new entries!
1098
+	 * @param int $recur_date if set, import the recurrence at this timestamp,
1101 1099
 	 *                          default 0 => import whole series (or events, if not recurring)
1102 1100
 	 * @param string $principalURL='' Used for CalDAV imports
1103
-	 * @param int $user=null account_id of owner, default null
1104 1101
 	 * @param string $charset  The encoding charset for $text. Defaults to
1105 1102
 	 *                         utf-8 for new format, iso-8859-1 for old format.
1106
-	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1103
+	 * @param string $caldav_name name from CalDAV client or null (to use default)
1104
+	 * @param integer $etag
1105
+	 * @param integer $user
1107 1106
 	 * @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"
1108 1107
 	 */
1109 1108
 	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
@@ -3182,6 +3181,10 @@  discard block
 block discarded – undo
3182 3181
 		return $event;
3183 3182
 	}
3184 3183
 
3184
+	/**
3185
+	 * @param integer $contentID
3186
+	 * @param string $charset
3187
+	 */
3185 3188
 	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3186 3189
 	{
3187 3190
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
@@ -3221,6 +3224,7 @@  discard block
 block discarded – undo
3221 3224
 	 * @param string $method ='PUBLISH' or eg. 'REPLY'
3222 3225
 	 * @param array $extra =null extra attributes to add
3223 3226
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3227
+	 * @return string|null
3224 3228
 	 */
3225 3229
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3226 3230
 	{
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -483,15 +483,15 @@  discard block
 block discarded – undo
483 483
 									{
484 484
 										$user = $this->resource_info($this->user);
485 485
 										$attributes['ATTENDEE'][] = 'mailto:' . $user['email'];
486
-			    						$parameters['ATTENDEE'][] = array(
487
-			    							'CN'		=>	$user['name'],
488
-			    							'ROLE'		=> 'REQ-PARTICIPANT',
486
+										$parameters['ATTENDEE'][] = array(
487
+											'CN'		=>	$user['name'],
488
+											'ROLE'		=> 'REQ-PARTICIPANT',
489 489
 											'PARTSTAT'	=> 'NEEDS-ACTION',
490 490
 											'CUTYPE'	=> 'INDIVIDUAL',
491 491
 											'RSVP'		=> 'TRUE',
492 492
 											'X-EGROUPWARE-UID'	=> (string)$this->user,
493
-			    						);
494
-			    						$event['participants'][$this->user] = true;
493
+										);
494
+										$event['participants'][$this->user] = true;
495 495
 									}
496 496
 									break;
497 497
 								case 'r':
@@ -543,24 +543,24 @@  discard block
 block discarded – undo
543 543
 						}
544 544
 						break;
545 545
 
546
-    				case 'ORGANIZER':
547
-	    				if (!$organizerURL)
548
-	    				{
549
-	    					$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
550
-			    				. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
551
-			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
552
-			    			if ($version == '1.0')
553
-			    			{
554
-		    					$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
555
-			    			}
556
-			    			else
557
-			    			{
558
-		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
559
-			    			}
560
-			    			$organizerUID = $event['owner'];
561
-		    				if (!isset($event['participants'][$event['owner']]))
562
-		    				{
563
-			    				$options = array(
546
+					case 'ORGANIZER':
547
+						if (!$organizerURL)
548
+						{
549
+							$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
550
+								. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
551
+							$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
552
+							if ($version == '1.0')
553
+							{
554
+								$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
555
+							}
556
+							else
557
+							{
558
+								$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
559
+							}
560
+							$organizerUID = $event['owner'];
561
+							if (!isset($event['participants'][$event['owner']]))
562
+							{
563
+								$options = array(
564 564
 									'ROLE'     => 'CHAIR',
565 565
 									'PARTSTAT' => 'DELEGATED',
566 566
 									'CUTYPE'   => 'INDIVIDUAL',
@@ -570,20 +570,20 @@  discard block
 block discarded – undo
570 570
 								if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail;
571 571
 								if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner'];
572 572
 								$attributes['ATTENDEE'][] = $organizerURL;
573
-			    				$parameters['ATTENDEE'][] = $options;
574
-		    				}
575
-	    				}
576
-    					// do NOT use ORGANIZER for events without further participants or a different organizer
577
-	    				if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']]))
578
-	    				{
579
-		    				$attributes['ORGANIZER'] = $organizerURL;
580
-		    				$parameters['ORGANIZER']['CN'] = $organizerCN;
581
-		    				if (!empty($organizerUID))
582
-		    				{
583
-			    				$parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID;
584
-		    				}
585
-	    				}
586
-	    				break;
573
+								$parameters['ATTENDEE'][] = $options;
574
+							}
575
+						}
576
+						// do NOT use ORGANIZER for events without further participants or a different organizer
577
+						if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']]))
578
+						{
579
+							$attributes['ORGANIZER'] = $organizerURL;
580
+							$parameters['ORGANIZER']['CN'] = $organizerCN;
581
+							if (!empty($organizerUID))
582
+							{
583
+								$parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID;
584
+							}
585
+						}
586
+						break;
587 587
 
588 588
 					case 'DTSTART':
589 589
 						if (empty($event['whole_day']))
@@ -992,12 +992,12 @@  discard block
 block discarded – undo
992 992
 				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
993 993
 				{
994 994
 					$valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset);
995
-                    $paramData = (array) Api\Translation::convert(is_array($value) ?
996
-                    		$parameters[$key][$valueID] : $parameters[$key],
997
-                            Api\Translation::charset(),$charset);
998
-                    $valuesData = (array) Api\Translation::convert($values[$key],
999
-                    		Api\Translation::charset(),$charset);
1000
-                    $content = $valueData . implode(';', $valuesData);
995
+					$paramData = (array) Api\Translation::convert(is_array($value) ?
996
+							$parameters[$key][$valueID] : $parameters[$key],
997
+							Api\Translation::charset(),$charset);
998
+					$valuesData = (array) Api\Translation::convert($values[$key],
999
+							Api\Translation::charset(),$charset);
1000
+					$content = $valueData . implode(';', $valuesData);
1001 1001
 
1002 1002
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1003 1003
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
 	 * @param string|resource $_vcalData
2234 2234
 	 * @param string $principalURL ='' Used for CalDAV imports
2235 2235
 	 * @param string $charset  The encoding charset for $text. Defaults to
2236
-     *                         utf-8 for new format, iso-8859-1 for old format.
2236
+	 *                         utf-8 for new format, iso-8859-1 for old format.
2237 2237
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2238 2238
 	 */
2239 2239
 	function icaltoegw($_vcalData, $principalURL='', $charset=null)
@@ -2784,10 +2784,10 @@  discard block
 block discarded – undo
2784 2784
 					// fall throught
2785 2785
 				case 'ATTENDEE':
2786 2786
 					if (isset($attributes['params']['PARTSTAT']))
2787
-				    {
2788
-				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2789
-				    }
2790
-				    if (isset($attributes['params']['STATUS']))
2787
+					{
2788
+						$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2789
+					}
2790
+					if (isset($attributes['params']['STATUS']))
2791 2791
 					{
2792 2792
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2793 2793
 						if (empty($status)) $status = 'X';
@@ -3178,7 +3178,7 @@  discard block
 block discarded – undo
3178 3178
 				array2string($event)."\n",3,$this->logfile);
3179 3179
 		}
3180 3180
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3181
-        //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3181
+		//    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3182 3182
 		return $event;
3183 3183
 	}
3184 3184
 
Please login to merge, or discard this patch.
Spacing   +264 added lines, -265 removed lines patch added patch discarded remove patch
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
 	 * @var array $priority_egw2ical conversion of the priority egw => ical
65 65
 	 */
66 66
 	var $priority_egw2ical = array(
67
-		0 => 0,		// undefined
68
-		1 => 9,		// low
69
-		2 => 5,		// normal
70
-		3 => 1,		// high
67
+		0 => 0, // undefined
68
+		1 => 9, // low
69
+		2 => 5, // normal
70
+		3 => 1, // high
71 71
 	);
72 72
 
73 73
 	/**
74 74
 	 * @var array $priority_ical2egw conversion of the priority ical => egw
75 75
 	 */
76 76
 	var $priority_ical2egw = array(
77
-		0 => 0,		// undefined
78
-		9 => 1,	8 => 1, 7 => 1, 6 => 1,	// low
79
-		5 => 2,		// normal
80
-		4 => 3, 3 => 3, 2 => 3, 1 => 3,	// high
77
+		0 => 0, // undefined
78
+		9 => 1, 8 => 1, 7 => 1, 6 => 1, // low
79
+		5 => 2, // normal
80
+		4 => 3, 3 => 3, 2 => 3, 1 => 3, // high
81 81
 	);
82 82
 
83 83
 	/**
84 84
 	 * @var array $priority_egw2funambol conversion of the priority egw => funambol
85 85
 	 */
86 86
 	var $priority_egw2funambol = array(
87
-		0 => 1,		// undefined (mapped to normal since undefined does not exist)
88
-		1 => 0,		// low
89
-		2 => 1,		// normal
90
-		3 => 2,		// high
87
+		0 => 1, // undefined (mapped to normal since undefined does not exist)
88
+		1 => 0, // low
89
+		2 => 1, // normal
90
+		3 => 2, // high
91 91
 	);
92 92
 
93 93
 	/**
94 94
 	 * @var array $priority_funambol2egw conversion of the priority funambol => egw
95 95
 	 */
96 96
 	var $priority_funambol2egw = array(
97
-		0 => 1,		// low
98
-		1 => 2,		// normal
99
-		2 => 3,		// high
97
+		0 => 1, // low
98
+		1 => 2, // normal
99
+		2 => 3, // high
100 100
 	);
101 101
 
102 102
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @var boolean
167 167
 	 */
168 168
 	var $log = false;
169
-	var $logfile="/tmp/log-vcal";
169
+	var $logfile = "/tmp/log-vcal";
170 170
 
171 171
 
172 172
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY
198 198
 	 * @return string|boolean string with iCal or false on error (e.g. no permission to read the event)
199 199
 	 */
200
-	function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0)
200
+	function &exportVCal($events, $version = '1.0', $method = 'PUBLISH', $recur_date = 0, $principalURL = '', $charset = 'UTF-8', $current_user = 0)
201 201
 	{
202 202
 		if ($this->log)
203 203
 		{
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
 
229 229
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
230 230
 
231
-		if ($this->productManufacturer == '' )
231
+		if ($this->productManufacturer == '')
232 232
 		{	// syncevolution is broken
233 233
 			$version = '2.0';
234 234
 		}
235 235
 
236 236
 		$vcal = new Horde_Icalendar;
237
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
237
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
238 238
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
239 239
 		$vcal->setAttribute('VERSION', $version);
240 240
 		if ($method) $vcal->setAttribute('METHOD', $method);
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
 						if ($this->log)
265 265
 						{
266 266
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
267
-								'() User does not have the permission to read event ' . $event['id']. "\n",
268
-								3,$this->logfile);
267
+								'() User does not have the permission to read event '.$event['id']."\n",
268
+								3, $this->logfile);
269 269
 						}
270 270
 						return -1; // Permission denied
271 271
 					}
272 272
 				}
273 273
 				else
274 274
 				{
275
-					$retval = false;  // Entry does not exist
275
+					$retval = false; // Entry does not exist
276 276
 					if ($this->log)
277 277
 					{
278 278
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			if ($this->log)
287 287
 			{
288 288
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
289
-					'() export event UID: ' . $event['uid'] . ".\n",
289
+					'() export event UID: '.$event['uid'].".\n",
290 290
 					3, $this->logfile);
291 291
 			}
292 292
 
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 			if ($this->log)
312 312
 			{
313 313
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
314
-					'(' . $event['id']. ',' . $recurrence . ")\n" .
315
-					array2string($event)."\n",3,$this->logfile);
314
+					'('.$event['id'].','.$recurrence.")\n".
315
+					array2string($event)."\n", 3, $this->logfile);
316 316
 			}
317 317
 
318 318
 			if ($recurrence)
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 						{
334 334
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
335 335
 								"(, $recurrence) Gratuitous pseudo exception, skipped ...\n",
336
-								3,$this->logfile);
336
+								3, $this->logfile);
337 337
 						}
338 338
 						continue; // unsupported status only exception
339 339
 					}
@@ -343,13 +343,13 @@  discard block
 block discarded – undo
343 343
 					$days = $this->so->get_recurrence_exceptions($master, $tzid, 0, 0, 'rrule');
344 344
 					if ($this->log)
345 345
 					{
346
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
347
-							array2string($days)."\n",3,$this->logfile);
346
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
347
+							array2string($days)."\n", 3, $this->logfile);
348 348
 					}
349 349
 					$recurrence = $days[$recurrence]; // use remote representation
350 350
 				}
351 351
 				// force single event
352
-				foreach (array('recur_enddate','recur_interval','recur_exception','recur_data','recur_date','id','etag') as $name)
352
+				foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data', 'recur_date', 'id', 'etag') as $name)
353 353
 				{
354 354
 					unset($event[$name]);
355 355
 				}
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 			}
358 358
 
359 359
 			// check if tzid of event (not only recuring ones) is already added to export
360
-			if ($tzid && $tzid != 'UTC' && !in_array($tzid,$vtimezones_added))
360
+			if ($tzid && $tzid != 'UTC' && !in_array($tzid, $vtimezones_added))
361 361
 			{
362 362
 				// check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz)
363 363
 				if (calendar_timezones::add_vtimezone($vcal, $tzid) ||
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 			{
376 376
 				// Append UID to DESCRIPTION
377 377
 				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
378
-					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
378
+					$event['description'] .= "\n[UID:".$event['uid']."]";
379 379
 				}
380 380
 			}
381 381
 
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 				$exceptions = array();
397 397
 
398 398
 				// dont use "virtual" exceptions created by participant status for GroupDAV or file export
399
-				if (!in_array($this->productManufacturer,array('file','groupdav')))
399
+				if (!in_array($this->productManufacturer, array('file', 'groupdav')))
400 400
 				{
401 401
 					$filter = isset($this->supportedFields['participants']) ? 'rrule' : 'tz_rrule';
402 402
 					$exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, $filter);
403 403
 					if ($this->log)
404 404
 					{
405
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" .
406
-							array2string($exceptions)."\n",3,$this->logfile);
405
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n".
406
+							array2string($exceptions)."\n", 3, $this->logfile);
407 407
 					}
408 408
 				}
409 409
 				elseif (is_array($event['recur_exception']))
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 					if ($this->log)
421 421
 					{
422 422
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
423
-							'(' . $event['id'] . ") [$icalFieldName] not supported\n",
424
-							3,$this->logfile);
423
+							'('.$event['id'].") [$icalFieldName] not supported\n",
424
+							3, $this->logfile);
425 425
 					}
426 426
 					continue;
427 427
 				}
@@ -438,23 +438,23 @@  discard block
 block discarded – undo
438 438
 
439 439
 							if (!($info = $this->resource_info($uid))) continue;
440 440
 
441
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
441
+							if (in_array($status, array('X', 'E'))) continue; // dont include deleted participants
442 442
 
443 443
 							if ($this->log)
444 444
 							{
445
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
446
-									'()attendee:' . array2string($info) ."\n",3,$this->logfile);
445
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
446
+									'()attendee:'.array2string($info)."\n", 3, $this->logfile);
447 447
 							}
448 448
 							$participantCN = str_replace(array('\\', ',', ';', ':'),
449 449
 												array('\\\\', '\\,', '\\;', '\\:'),
450 450
 												trim(empty($info['cn']) ? $info['name'] : $info['cn']));
451 451
 							if ($version == '1.0')
452 452
 							{
453
-								$participantURL = trim('"' . $participantCN . '"' . (empty($info['email']) ? '' : ' <' . $info['email'] .'>'));
453
+								$participantURL = trim('"'.$participantCN.'"'.(empty($info['email']) ? '' : ' <'.$info['email'].'>'));
454 454
 							}
455 455
 							else
456 456
 							{
457
-								$participantURL = empty($info['email']) ? '' : 'mailto:' . $info['email'];
457
+								$participantURL = empty($info['email']) ? '' : 'mailto:'.$info['email'];
458 458
 							}
459 459
 							// RSVP={TRUE|FALSE}	// resonse expected, not set in eGW => status=U
460 460
 							$rsvp = $status == 'U' ? 'TRUE' : 'FALSE';
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 										($members = $GLOBALS['egw']->accounts->members($uid, true)) && in_array($this->user, $members))
483 483
 									{
484 484
 										$user = $this->resource_info($this->user);
485
-										$attributes['ATTENDEE'][] = 'mailto:' . $user['email'];
485
+										$attributes['ATTENDEE'][] = 'mailto:'.$user['email'];
486 486
 			    						$parameters['ATTENDEE'][] = array(
487 487
 			    							'CN'		=>	$user['name'],
488 488
 			    							'ROLE'		=> 'REQ-PARTICIPANT',
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
525 525
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
526 526
 							{
527
-								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
527
+								$options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
528 528
 							}
529 529
 							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
530 530
 							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 						break;
535 535
 
536 536
 					case 'CLASS':
537
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
537
+						if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default
538 538
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
539 539
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
540 540
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -546,16 +546,16 @@  discard block
 block discarded – undo
546 546
     				case 'ORGANIZER':
547 547
 	    				if (!$organizerURL)
548 548
 	    				{
549
-	    					$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
550
-			    				. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
551
-			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
549
+	    					$organizerCN = '"'.trim($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_firstname')
550
+			    				. ' '.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_lastname')).'"';
551
+			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email');
552 552
 			    			if ($version == '1.0')
553 553
 			    			{
554
-		    					$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
554
+		    					$organizerURL = trim($organizerCN.(empty($organizerURL) ? '' : ' <'.$organizerURL.'>'));
555 555
 			    			}
556 556
 			    			else
557 557
 			    			{
558
-		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
558
+		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:'.$organizerEMail;
559 559
 			    			}
560 560
 			    			$organizerUID = $event['owner'];
561 561
 		    				if (!isset($event['participants'][$event['owner']]))
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 					case 'DTSTART':
589 589
 						if (empty($event['whole_day']))
590 590
 						{
591
-							$attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']);
591
+							$attributes['DTSTART'] = self::getDateTime($event['start'], $tzid, $parameters['DTSTART']);
592 592
 						}
593 593
 						break;
594 594
 
@@ -599,27 +599,27 @@  discard block
 block discarded – undo
599 599
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
600 600
 								$attributes['duration'] = $event['end'] - $event['start'];
601 601
 							else
602
-							$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
602
+							$attributes['DTEND'] = self::getDateTime($event['end'], $tzid, $parameters['DTEND']);
603 603
 						}
604 604
 						else
605 605
 						{
606 606
 							// write start + end of whole day events as dates
607
-							$event['end-nextday'] = $event['end'] + 12*3600;	// we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
608
-							foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t)
607
+							$event['end-nextday'] = $event['end'] + 12 * 3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
608
+							foreach (array('start' => 'DTSTART', 'end-nextday' => 'DTEND') as $f => $t)
609 609
 							{
610
-								$time = new Api\DateTime($event[$f],Api\DateTime::$server_timezone);
611
-								$arr = Api\DateTime::to($time,'array');
612
-								$vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']),
610
+								$time = new Api\DateTime($event[$f], Api\DateTime::$server_timezone);
611
+								$arr = Api\DateTime::to($time, 'array');
612
+								$vevent->setAttribute($t, array('year' => $arr['year'], 'month' => $arr['month'], 'mday' => $arr['day']),
613 613
 									array('VALUE' => 'DATE'));
614 614
 							}
615 615
 							unset($attributes['DTSTART']);
616 616
 							// 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
617
-							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT','TRUE');
617
+							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
618 618
 						}
619 619
 						break;
620 620
 
621 621
 					case 'RRULE':
622
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
622
+						if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event
623 623
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
624 624
 						$rrule = $rriter->generate_rrule($version);
625 625
 						if ($event['recur_enddate'])
@@ -638,16 +638,16 @@  discard block
 block discarded – undo
638 638
 						{
639 639
 							if ($event['recur_enddate'] && $tzid)
640 640
 							{
641
-								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid);
641
+								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'], $tzid);
642 642
 							}
643 643
 							$attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL'];
644 644
 						}
645 645
 						else // $version == '2.0'
646 646
 						{
647 647
 							$attributes['RRULE'] = '';
648
-							foreach($rrule as $n => $v)
648
+							foreach ($rrule as $n => $v)
649 649
 							{
650
-								$attributes['RRULE'] .= ($attributes['RRULE']?';':'').$n.'='.$v;
650
+								$attributes['RRULE'] .= ($attributes['RRULE'] ? ';' : '').$n.'='.$v;
651 651
 							}
652 652
 						}
653 653
 						break;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 								{
663 663
 									// current Horde_Icalendar 2.1.4 exports EXDATE always in UTC, so we should not set a timezone here
664 664
 									// Apple calendar on OS X 10.11.4 uses a timezone, so does Horde eg. for Recurrence-ID
665
-									$event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid);//,$parameters['EXDATE']);
665
+									$event['recur_exception'][$key] = self::getDateTime($timestamp, $tzid); //,$parameters['EXDATE']);
666 666
 								}
667 667
 							}
668 668
 							else
@@ -670,9 +670,9 @@  discard block
 block discarded – undo
670 670
 								// use 'DATE' instead of 'DATE-TIME' on whole day events
671 671
 								foreach ($event['recur_exception'] as $id => $timestamp)
672 672
 								{
673
-									$time = new Api\DateTime($timestamp,Api\DateTime::$server_timezone);
673
+									$time = new Api\DateTime($timestamp, Api\DateTime::$server_timezone);
674 674
 									$time->setTimezone(self::$tz_cache[$event['tzid']]);
675
-									$arr = Api\DateTime::to($time,'array');
675
+									$arr = Api\DateTime::to($time, 'array');
676 676
 									$days[$id] = array(
677 677
 										'year'  => $arr['year'],
678 678
 										'month' => $arr['month'],
@@ -687,21 +687,21 @@  discard block
 block discarded – undo
687 687
 						break;
688 688
 
689 689
 					case 'PRIORITY':
690
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
690
+						if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added
691 691
 						if ($this->productManufacturer == 'funambol' &&
692 692
 							(strpos($this->productName, 'outlook') !== false
693 693
 								|| strpos($this->productName, 'pocket pc') !== false))
694 694
 						{
695
-							$attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']];
695
+							$attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']];
696 696
 						}
697 697
 						else
698 698
 						{
699
-							$attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']];
699
+							$attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']];
700 700
 						}
701 701
 						break;
702 702
 
703 703
 					case 'TRANSP':
704
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
704
+						if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default
705 705
 						if ($version == '1.0')
706 706
 						{
707 707
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
 							// We handle a pseudo exception
741 741
 							if (empty($event['whole_day']))
742 742
 							{
743
-								$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
743
+								$attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]);
744 744
 							}
745 745
 							else
746 746
 							{
747
-								$time = new Api\DateTime($recur_date,Api\DateTime::$server_timezone);
747
+								$time = new Api\DateTime($recur_date, Api\DateTime::$server_timezone);
748 748
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
749
-								$arr = Api\DateTime::to($time,'array');
749
+								$arr = Api\DateTime::to($time, 'array');
750 750
 								$vevent->setAttribute($icalFieldName, array(
751 751
 									'year' => $arr['year'],
752 752
 									'month' => $arr['month'],
@@ -758,17 +758,17 @@  discard block
 block discarded – undo
758 758
 						elseif ($event['recurrence'] && $event['reference'])
759 759
 						{
760 760
 							// $event['reference'] is a calendar_id, not a timestamp
761
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
761
+							if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
762 762
 
763 763
 							if (empty($revent['whole_day']))
764 764
 							{
765
-								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
765
+								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]);
766 766
 							}
767 767
 							else
768 768
 							{
769
-								$time = new Api\DateTime($event['recurrence'],Api\DateTime::$server_timezone);
769
+								$time = new Api\DateTime($event['recurrence'], Api\DateTime::$server_timezone);
770 770
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
771
-								$arr = Api\DateTime::to($time,'array');
771
+								$arr = Api\DateTime::to($time, 'array');
772 772
 								$vevent->setAttribute($icalFieldName, array(
773 773
 									'year' => $arr['year'],
774 774
 									'month' => $arr['month'],
@@ -792,9 +792,9 @@  discard block
 block discarded – undo
792 792
 							$noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate'];
793 793
 							if ($this->log && $size > 0)
794 794
 							{
795
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
796
-									"() $icalFieldName Size: $size, NoTruncate: " .
797
-									($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
795
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
796
+									"() $icalFieldName Size: $size, NoTruncate: ".
797
+									($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
798 798
 							}
799 799
 							//Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
800 800
 							//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 							{
813 813
 								if ($this->log)
814 814
 								{
815
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
816
-										"() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile);
815
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
816
+										"() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile);
817 817
 								}
818 818
 								//Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
819 819
 								//	__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -823,8 +823,8 @@  discard block
 block discarded – undo
823 823
 							$value = substr($value, 0, $size - 1);
824 824
 							if ($this->log)
825 825
 							{
826
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
827
-									"() $icalFieldName truncated to maximum size $size\n",3,$this->logfile);
826
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
827
+									"() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile);
828 828
 							}
829 829
 							//Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
830 830
 							//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 			// for CalDAV add all X-Properties previously parsed
840 840
 			if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file')
841 841
 			{
842
-				foreach($event as $name => $value)
842
+				foreach ($event as $name => $value)
843 843
 				{
844 844
 					if (substr($name, 0, 2) == '##')
845 845
 					{
@@ -911,8 +911,8 @@  discard block
 block discarded – undo
911 911
 						$values['AALARM']['repeat count'] = '';
912 912
 						$values['AALARM']['display text'] = $description;
913 913
 					}
914
-					$attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']);
915
-					$attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']);
914
+					$attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']);
915
+					$attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']);
916 916
 					// lets take only the first alarm
917 917
 					break;
918 918
 				}
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 						$alarmData['offset'] = false;
950 950
 					}
951 951
 
952
-					$valarm = Horde_Icalendar::newComponent('VALARM',$vevent);
952
+					$valarm = Horde_Icalendar::newComponent('VALARM', $vevent);
953 953
 					if ($alarmData['offset'] !== false)
954 954
 					{
955 955
 						$valarm->setAttribute('TRIGGER', -$alarmData['offset'],
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 					else
959 959
 					{
960 960
 						$params = array('VALUE' => 'DATE-TIME');
961
-						$value = self::getDateTime($alarmData['time'],$tzid,$params);
961
+						$value = self::getDateTime($alarmData['time'], $tzid, $params);
962 962
 						$valarm->setAttribute('TRIGGER', $value, $params);
963 963
 					}
964 964
 					if (!empty($alarmData['uid']))
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 					// set evtl. existing attributes set by iCal clients not used by EGroupware
970 970
 					if (isset($alarmData['attrs']))
971 971
 					{
972
-						foreach($alarmData['attrs'] as $attr => $data)
972
+						foreach ($alarmData['attrs'] as $attr => $data)
973 973
 						{
974 974
 							$valarm->setAttribute($attr, $data['value'], $data['params']);
975 975
 						}
@@ -977,11 +977,11 @@  discard block
 block discarded – undo
977 977
 					// set default ACTION and DESCRIPTION, if not set by a client
978 978
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION']))
979 979
 					{
980
-						$valarm->setAttribute('ACTION','DISPLAY');
980
+						$valarm->setAttribute('ACTION', 'DISPLAY');
981 981
 					}
982 982
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION']))
983 983
 					{
984
-						$valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description);
984
+						$valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description);
985 985
 					}
986 986
 					$vevent->addComponent($valarm);
987 987
 				}
@@ -989,15 +989,15 @@  discard block
 block discarded – undo
989 989
 
990 990
 			foreach ($attributes as $key => $value)
991 991
 			{
992
-				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
992
+				foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData)
993 993
 				{
994
-					$valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset);
995
-                    $paramData = (array) Api\Translation::convert(is_array($value) ?
994
+					$valueData = Api\Translation::convert($valueData, Api\Translation::charset(), $charset);
995
+                    $paramData = (array)Api\Translation::convert(is_array($value) ?
996 996
                     		$parameters[$key][$valueID] : $parameters[$key],
997
-                            Api\Translation::charset(),$charset);
998
-                    $valuesData = (array) Api\Translation::convert($values[$key],
999
-                    		Api\Translation::charset(),$charset);
1000
-                    $content = $valueData . implode(';', $valuesData);
997
+                            Api\Translation::charset(), $charset);
998
+                    $valuesData = (array)Api\Translation::convert($values[$key],
999
+                    		Api\Translation::charset(), $charset);
1000
+                    $content = $valueData.implode(';', $valuesData);
1001 1001
 
1002 1002
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1003 1003
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -1047,10 +1047,10 @@  discard block
 block discarded – undo
1047 1047
 		$retval = $events_exported ? $vcal->exportvCalendar() : false;
1048 1048
  		if ($this->log)
1049 1049
  		{
1050
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1051
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1052
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1053
-				"()\n".array2string($retval)."\n",3,$this->logfile);
1050
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1051
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1052
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1053
+				"()\n".array2string($retval)."\n", 3, $this->logfile);
1054 1054
  		}
1055 1055
 		return $retval;
1056 1056
 	}
@@ -1063,15 +1063,15 @@  discard block
 block discarded – undo
1063 1063
 	 * @param array &$params=null parameter array to set TZID
1064 1064
 	 * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid
1065 1065
 	 */
1066
-	static function getDateTime($time,$tzid,array &$params=null)
1066
+	static function getDateTime($time, $tzid, array &$params = null)
1067 1067
 	{
1068 1068
 		if (empty($tzid) || $tzid == 'UTC')
1069 1069
 		{
1070
-			return Api\DateTime::to($time,'ts');
1070
+			return Api\DateTime::to($time, 'ts');
1071 1071
 		}
1072
-		if (!is_a($time,'DateTime'))
1072
+		if (!is_a($time, 'DateTime'))
1073 1073
 		{
1074
-			$time = new Api\DateTime($time,Api\DateTime::$server_timezone);
1074
+			$time = new Api\DateTime($time, Api\DateTime::$server_timezone);
1075 1075
 		}
1076 1076
 		if (!isset(self::$tz_cache[$tzid]))
1077 1077
 		{
@@ -1106,11 +1106,11 @@  discard block
 block discarded – undo
1106 1106
 	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1107 1107
 	 * @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"
1108 1108
 	 */
1109
-	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
1109
+	function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false)
1110 1110
 	{
1111 1111
 		//error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)");
1112 1112
 		$this->events_imported = 0;
1113
-		$replace = $delete_exceptions= false;
1113
+		$replace = $delete_exceptions = false;
1114 1114
 
1115 1115
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1116 1116
 
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 		{
1119 1119
 			return false;
1120 1120
 		}
1121
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1121
+		if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0])
1122 1122
 
1123 1123
 		if ($cal_id > 0)
1124 1124
 		{
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 			{
1127 1127
 				$replace = $recur_date == 0;
1128 1128
 				$events[0]['id'] = $cal_id;
1129
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1129
+				if (!is_null($etag)) $events[0]['etag'] = (int)$etag;
1130 1130
 				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1131 1131
 			}
1132 1132
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 			{
1179 1179
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1180 1180
 					."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n"
1181
-					. array2string($event)."\n",3,$this->logfile);
1181
+					. array2string($event)."\n", 3, $this->logfile);
1182 1182
 			}
1183 1183
 
1184 1184
 			$updated_id = false;
@@ -1201,14 +1201,14 @@  discard block
 block discarded – undo
1201 1201
 					{
1202 1202
 						if ($delete_exceptions)
1203 1203
 						{
1204
-							$this->delete($id,0,false,$skip_notification);
1204
+							$this->delete($id, 0, false, $skip_notification);
1205 1205
 						}
1206 1206
 						else
1207 1207
 						{
1208 1208
 							if (!($exception = $this->read($id))) continue;
1209 1209
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1210 1210
 							$exception['reference'] = $exception['recurrence'] = 0;
1211
-							$this->update($exception, true,true,false,true,$msg,$skip_notification);
1211
+							$this->update($exception, true, true, false, true, $msg, $skip_notification);
1212 1212
 						}
1213 1213
 					}
1214 1214
 				}
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 				{
1226 1226
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1227 1227
 						. "(UPDATE Event)\n"
1228
-						. array2string($event_info['stored_event'])."\n",3,$this->logfile);
1228
+						. array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1229 1229
 				}
1230 1230
 				if (empty($event['uid']))
1231 1231
 				{
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 								if ($this->log)
1248 1248
 								{
1249 1249
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1250
-										"() Restore status for $uid\n",3,$this->logfile);
1250
+										"() Restore status for $uid\n", 3, $this->logfile);
1251 1251
 								}
1252 1252
 								$event['participants'][$uid] = $event_info['stored_event']['participants'][$uid];
1253 1253
 							}
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 					if ($this->log)
1272 1272
 					{
1273 1273
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1274
-							"()[MERGE]\n",3,$this->logfile);
1274
+							"()[MERGE]\n", 3, $this->logfile);
1275 1275
 					}
1276 1276
 					// overwrite with server data for merge
1277 1277
 					foreach ($event_info['stored_event'] as $key => $value)
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 				else
1302 1302
 				{
1303 1303
 					// no merge
1304
-					if(!isset($this->supportedFields['category']) || !isset($event['category']))
1304
+					if (!isset($this->supportedFields['category']) || !isset($event['category']))
1305 1305
 					{
1306 1306
 						$event['category'] = $event_info['stored_event']['category'];
1307 1307
 					}
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 						if ($this->log)
1314 1314
 						{
1315 1315
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1316
-							"() No participants\n",3,$this->logfile);
1316
+							"() No participants\n", 3, $this->logfile);
1317 1317
 						}
1318 1318
 
1319 1319
 						// If this is an updated meeting, and the client doesn't support
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 								if ($this->log)
1333 1333
 								{
1334 1334
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1335
-										"() Restore resource $uid to status $status\n",3,$this->logfile);
1335
+										"() Restore resource $uid to status $status\n", 3, $this->logfile);
1336 1336
 								}
1337 1337
 								// Add it back in
1338 1338
 								$event['participants'][$uid] = $status;
@@ -1420,8 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 						}
1421 1421
 						// for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U')
1422 1422
 						$event['participants'][$user] = calendar_so::combine_status(
1423
-							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' :
1424
-							ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1423
+							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1425 1424
 					}
1426 1425
 				}
1427 1426
 				// check if an owner is set and the current user has add rights
@@ -1486,9 +1485,9 @@  discard block
 block discarded – undo
1486 1485
 
1487 1486
 			if ($this->log)
1488 1487
 			{
1489
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '('
1490
-					. $event_info['type'] . ")\n"
1491
-					. array2string($event)."\n",3,$this->logfile);
1488
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'('
1489
+					. $event_info['type'].")\n"
1490
+					. array2string($event)."\n", 3, $this->logfile);
1492 1491
 			}
1493 1492
 
1494 1493
 			// Android (any maybe others) delete recurrences by setting STATUS: CANCELLED
@@ -1496,10 +1495,10 @@  discard block
 block discarded – undo
1496 1495
 			if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) &&
1497 1496
 				$event['status'] == 'CANCELLED')
1498 1497
 			{
1499
-				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification))
1498
+				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification))
1500 1499
 				{
1501 1500
 					// delete fails (because no rights), reject recurrence
1502
-					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification);
1501
+					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification);
1503 1502
 				}
1504 1503
 				continue;
1505 1504
 			}
@@ -1511,7 +1510,7 @@  discard block
 block discarded – undo
1511 1510
 					if ($this->log)
1512 1511
 					{
1513 1512
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1514
-							"(): event SINGLE\n",3,$this->logfile);
1513
+							"(): event SINGLE\n", 3, $this->logfile);
1515 1514
 					}
1516 1515
 
1517 1516
 					// update the event
@@ -1521,7 +1520,7 @@  discard block
 block discarded – undo
1521 1520
 						$event['reference'] = 0;
1522 1521
 						$event_to_store = $event; // prevent $event from being changed by the update method
1523 1522
 						$this->server2usertime($event_to_store);
1524
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1523
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1525 1524
 						unset($event_to_store);
1526 1525
 					}
1527 1526
 					break;
@@ -1530,7 +1529,7 @@  discard block
 block discarded – undo
1530 1529
 					if ($this->log)
1531 1530
 					{
1532 1531
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1533
-							"(): event SERIES-MASTER\n",3,$this->logfile);
1532
+							"(): event SERIES-MASTER\n", 3, $this->logfile);
1534 1533
 					}
1535 1534
 
1536 1535
 					// remove all known pseudo exceptions and update the event
@@ -1540,8 +1539,8 @@  discard block
 block discarded – undo
1540 1539
 						$days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter);
1541 1540
 						if ($this->log)
1542 1541
 						{
1543
-							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" .
1544
-								array2string($days)."\n",3,$this->logfile);
1542
+							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n".
1543
+								array2string($days)."\n", 3, $this->logfile);
1545 1544
 						}
1546 1545
 						if (is_array($days))
1547 1546
 						{
@@ -1559,7 +1558,7 @@  discard block
 block discarded – undo
1559 1558
 
1560 1559
 						$event_to_store = $event; // prevent $event from being changed by the update method
1561 1560
 						$this->server2usertime($event_to_store);
1562
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1561
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1563 1562
 						unset($event_to_store);
1564 1563
 					}
1565 1564
 					break;
@@ -1569,7 +1568,7 @@  discard block
 block discarded – undo
1569 1568
 					if ($this->log)
1570 1569
 					{
1571 1570
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1572
-							"(): event SERIES-EXCEPTION\n",3,$this->logfile);
1571
+							"(): event SERIES-EXCEPTION\n", 3, $this->logfile);
1573 1572
 					}
1574 1573
 
1575 1574
 					// update event
@@ -1625,13 +1624,13 @@  discard block
 block discarded – undo
1625 1624
 							$event['owner'] = $event_info['master_event']['owner'];
1626 1625
 							$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1627 1626
 							$this->server2usertime($event_to_store);
1628
-							$this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1627
+							$this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1629 1628
 							unset($event_to_store);
1630 1629
 						}
1631 1630
 
1632 1631
 						$event_to_store = $event; // prevent $event from being changed by update method
1633 1632
 						$this->server2usertime($event_to_store);
1634
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1633
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1635 1634
 						unset($event_to_store);
1636 1635
 					}
1637 1636
 					break;
@@ -1640,7 +1639,7 @@  discard block
 block discarded – undo
1640 1639
 					if ($this->log)
1641 1640
 					{
1642 1641
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1643
-							"(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile);
1642
+							"(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile);
1644 1643
 					}
1645 1644
 					//Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION',
1646 1645
 					//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -1661,7 +1660,7 @@  discard block
 block discarded – undo
1661 1660
 						// save the series master with the adjusted exceptions
1662 1661
 						$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1663 1662
 						$this->server2usertime($event_to_store);
1664
-						$updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification);
1663
+						$updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification);
1665 1664
 						unset($event_to_store);
1666 1665
 					}
1667 1666
 
@@ -1688,13 +1687,13 @@  discard block
 block discarded – undo
1688 1687
 							if ($event_info['acl_edit'])
1689 1688
 							{
1690 1689
 								// update all participants if we have the right to do that
1691
-								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1690
+								$this->update_status($event, $event_info['stored_event'], 0, $skip_notification);
1692 1691
 							}
1693 1692
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1694 1693
 							{
1695 1694
 								// update the users status only
1696 1695
 								$this->set_status($event_info['stored_event']['id'], $this->user,
1697
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification);
1696
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification);
1698 1697
 							}
1699 1698
 						}
1700 1699
 						break;
@@ -1706,13 +1705,13 @@  discard block
 block discarded – undo
1706 1705
 							if ($event_info['acl_edit'])
1707 1706
 							{
1708 1707
 								// update all participants if we have the right to do that
1709
-								$this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification);
1708
+								$this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification);
1710 1709
 							}
1711 1710
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
1712 1711
 							{
1713 1712
 								// update the users status only
1714 1713
 								$this->set_status($event_info['master_event']['id'], $this->user,
1715
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification);
1714
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification);
1716 1715
 							}
1717 1716
 						}
1718 1717
 						break;
@@ -1729,7 +1728,7 @@  discard block
 block discarded – undo
1729 1728
 					break;
1730 1729
 
1731 1730
 				case 'SERIES-PSEUDO-EXCEPTION':
1732
-					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false;
1731
+					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false;
1733 1732
 					break;
1734 1733
 
1735 1734
 				case 'SERIES-EXCEPTION-PROPAGATE':
@@ -1742,7 +1741,7 @@  discard block
 block discarded – undo
1742 1741
 					{
1743 1742
 						// we did not have sufficient rights to propagate the status only exception to a real one
1744 1743
 						// we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched
1745
-						$return_id = $event_info['master_event']['id'] . ':' . $event['recurrence'];
1744
+						$return_id = $event_info['master_event']['id'].':'.$event['recurrence'];
1746 1745
 					}
1747 1746
 					break;
1748 1747
 			}
@@ -1756,8 +1755,8 @@  discard block
 block discarded – undo
1756 1755
 			if ($this->log)
1757 1756
 			{
1758 1757
 				$event_info['stored_event'] = $this->read($event_info['stored_event']['id']);
1759
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" .
1760
-					array2string($event_info['stored_event'])."\n",3,$this->logfile);
1758
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n".
1759
+					array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1761 1760
 			}
1762 1761
 		}
1763 1762
 		date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -1777,10 +1776,10 @@  discard block
 block discarded – undo
1777 1776
 	{
1778 1777
 		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1779 1778
 		$modified = 0;
1780
-		foreach($event['alarm'] as &$alarm)
1779
+		foreach ($event['alarm'] as &$alarm)
1781 1780
 		{
1782 1781
 			// check if alarm is already stored or from other users
1783
-			foreach($old_alarms as $id => $old_alarm)
1782
+			foreach ($old_alarms as $id => $old_alarm)
1784 1783
 			{
1785 1784
 				// not current users alarm --> ignore
1786 1785
 				if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1817,7 +1816,7 @@  discard block
 block discarded – undo
1817 1816
 			}
1818 1817
 		}
1819 1818
 		// remove all old alarms left from current user
1820
-		foreach($old_alarms as $id => $old_alarm)
1819
+		foreach ($old_alarms as $id => $old_alarm)
1821 1820
 		{
1822 1821
 			// not current users alarm --> ignore
1823 1822
 			if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1840,7 +1839,7 @@  discard block
 block discarded – undo
1840 1839
 	 * @param string $what ='value'
1841 1840
 	 * @return mixed
1842 1841
 	 */
1843
-	static function _get_attribute($components,$name,$what='value')
1842
+	static function _get_attribute($components, $name, $what = 'value')
1844 1843
 	{
1845 1844
 		foreach ($components as $attribute)
1846 1845
 		{
@@ -1875,7 +1874,7 @@  discard block
 block discarded – undo
1875 1874
 						case 'DURATION':
1876 1875
 							if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END')
1877 1876
 							{
1878
-								$alarm['offset'] = $duration -$vattr['value'];
1877
+								$alarm['offset'] = $duration - $vattr['value'];
1879 1878
 							}
1880 1879
 							elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START')
1881 1880
 							{
@@ -1891,7 +1890,7 @@  discard block
 block discarded – undo
1891 1890
 							$alarm['time'] = $vattr['value'];
1892 1891
 							break;
1893 1892
 						default:
1894
-							error_log('VALARM/TRIGGER: unsupported value type:' . $vtype);
1893
+							error_log('VALARM/TRIGGER: unsupported value type:'.$vtype);
1895 1894
 					}
1896 1895
 					break;
1897 1896
 
@@ -1916,9 +1915,9 @@  discard block
 block discarded – undo
1916 1915
 		return 0;
1917 1916
 	}
1918 1917
 
1919
-	function setSupportedFields($_productManufacturer='', $_productName='')
1918
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
1920 1919
 	{
1921
-		$state =& $_SESSION['SyncML.state'];
1920
+		$state = & $_SESSION['SyncML.state'];
1922 1921
 		if (isset($state))
1923 1922
 		{
1924 1923
 			$deviceInfo = $state->getClientDeviceInfo();
@@ -2215,10 +2214,10 @@  discard block
 block discarded – undo
2215 2214
 		if ($this->log)
2216 2215
 		{
2217 2216
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2218
-				'(' . $this->productManufacturer .
2219
-				', '. $this->productName .', ' .
2220
-				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
2221
-				', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
2217
+				'('.$this->productManufacturer.
2218
+				', '.$this->productName.', '.
2219
+				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()).
2220
+				', '.$this->calendarOwner.")\n", 3, $this->logfile);
2222 2221
 		}
2223 2222
 
2224 2223
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
@@ -2236,12 +2235,12 @@  discard block
 block discarded – undo
2236 2235
      *                         utf-8 for new format, iso-8859-1 for old format.
2237 2236
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2238 2237
 	 */
2239
-	function icaltoegw($_vcalData, $principalURL='', $charset=null)
2238
+	function icaltoegw($_vcalData, $principalURL = '', $charset = null)
2240 2239
 	{
2241 2240
 		if ($this->log)
2242 2241
 		{
2243
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" .
2244
-				array2string($_vcalData)."\n",3,$this->logfile);
2242
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n".
2243
+				array2string($_vcalData)."\n", 3, $this->logfile);
2245 2244
 		}
2246 2245
 
2247 2246
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
@@ -2276,14 +2275,14 @@  discard block
 block discarded – undo
2276 2275
 			if ($this->log)
2277 2276
 			{
2278 2277
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2279
-					"(): No vCalendar Container found!\n",3,$this->logfile);
2278
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
2280 2279
 			}
2281 2280
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
2282 2281
 			return false;
2283 2282
 		}
2284 2283
 		foreach ($vcal->getComponents() as $component)
2285 2284
 		{
2286
-			if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal)))
2285
+			if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal)))
2287 2286
 			{
2288 2287
 				$events[] = $event;
2289 2288
 			}
@@ -2328,13 +2327,13 @@  discard block
 block discarded – undo
2328 2327
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2329 2328
 	 * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent
2330 2329
 	 */
2331
-	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null)
2330
+	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null)
2332 2331
 	{
2333 2332
 		//unset($component->_container); _debug_array($component);
2334 2333
 
2335 2334
 		if ($this->log)
2336 2335
 		{
2337
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
2336
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile);
2338 2337
 		}
2339 2338
 
2340 2339
 		// eg. Mozilla holiday calendars contain only a X-WR-TIMEZONE on vCalendar component
@@ -2389,16 +2388,16 @@  discard block
 block discarded – undo
2389 2388
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2390 2389
 	 * @return array|boolean			event on success, false on failure
2391 2390
 	 */
2392
-	function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null)
2391
+	function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null)
2393 2392
 	{
2394
-		unset($principalURL);	// not longer used, but required in function signature
2393
+		unset($principalURL); // not longer used, but required in function signature
2395 2394
 
2396 2395
 		if ($check_component && !is_a($component, $check_component))
2397 2396
 		{
2398 2397
 			if ($this->log)
2399 2398
 			{
2400
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' .
2401
-					get_class($component)." found\n",3,$this->logfile);
2399
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'.
2400
+					get_class($component)." found\n", 3, $this->logfile);
2402 2401
 			}
2403 2402
 			return false;
2404 2403
 		}
@@ -2414,11 +2413,11 @@  discard block
 block discarded – undo
2414 2413
 
2415 2414
 		$isDate = false;
2416 2415
 		$event		= array();
2417
-		$alarms		= array();
2418
-		$vcardData	= array(
2416
+		$alarms = array();
2417
+		$vcardData = array(
2419 2418
 			'recur_type'		=> MCAL_RECUR_NONE,
2420 2419
 			'recur_exception'	=> array(),
2421
-			'priority'          => 0,	// iCalendar default is 0=undefined, not EGroupware 5=normal
2420
+			'priority'          => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal
2422 2421
 		);
2423 2422
 		// we need to parse DTSTART, DTEND or DURATION (in that order!) first
2424 2423
 		foreach (array_merge(
@@ -2435,7 +2434,7 @@  discard block
 block discarded – undo
2435 2434
 						$isDate = true;
2436 2435
 					}
2437 2436
 					$dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2438
-					$vcardData['start']	= $dtstart_ts;
2437
+					$vcardData['start'] = $dtstart_ts;
2439 2438
 
2440 2439
 					if ($this->tzid)
2441 2440
 					{
@@ -2458,18 +2457,18 @@  discard block
 block discarded – undo
2458 2457
 								}
2459 2458
 								else
2460 2459
 								{
2461
-									error_log(__METHOD__ . '() unknown TZID='
2462
-										. $attributes['params']['TZID'] . ', defaulting to timezone "'
2463
-										. date_default_timezone_get() . '".'.array2string($tz));
2464
-									$event['tzid'] = date_default_timezone_get();	// default to current timezone
2460
+									error_log(__METHOD__.'() unknown TZID='
2461
+										. $attributes['params']['TZID'].', defaulting to timezone "'
2462
+										. date_default_timezone_get().'".'.array2string($tz));
2463
+									$event['tzid'] = date_default_timezone_get(); // default to current timezone
2465 2464
 								}
2466 2465
 							}
2467
-							catch(Exception $e)
2466
+							catch (Exception $e)
2468 2467
 							{
2469
-								error_log(__METHOD__ . '() unknown TZID='
2470
-									. $attributes['params']['TZID'] . ', defaulting to timezone "'
2471
-									. date_default_timezone_get() . '".'.$e->getMessage());
2472
-								$event['tzid'] = date_default_timezone_get();	// default to current timezone
2468
+								error_log(__METHOD__.'() unknown TZID='
2469
+									. $attributes['params']['TZID'].', defaulting to timezone "'
2470
+									. date_default_timezone_get().'".'.$e->getMessage());
2471
+								$event['tzid'] = date_default_timezone_get(); // default to current timezone
2473 2472
 							}
2474 2473
 						}
2475 2474
 						else
@@ -2484,11 +2483,11 @@  discard block
 block discarded – undo
2484 2483
 
2485 2484
 				case 'DTEND':
2486 2485
 					$dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2487
-					if (date('H:i:s',$dtend_ts) == '00:00:00')
2486
+					if (date('H:i:s', $dtend_ts) == '00:00:00')
2488 2487
 					{
2489 2488
 						$dtend_ts -= 1;
2490 2489
 					}
2491
-					$vcardData['end']	= $dtend_ts;
2490
+					$vcardData['end'] = $dtend_ts;
2492 2491
 					break;
2493 2492
 
2494 2493
 				case 'DURATION':	// clients can use DTSTART+DURATION, instead of DTSTART+DTEND
@@ -2508,7 +2507,7 @@  discard block
 block discarded – undo
2508 2507
 			if ($this->log)
2509 2508
 			{
2510 2509
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2511
-					. "() DTSTART missing!\n",3,$this->logfile);
2510
+					. "() DTSTART missing!\n", 3, $this->logfile);
2512 2511
 			}
2513 2512
 			return false; // not a valid entry
2514 2513
 		}
@@ -2520,7 +2519,7 @@  discard block
 block discarded – undo
2520 2519
 				case 'X-MICROSOFT-CDO-ALLDAYEVENT':
2521 2520
 					if (isset($supportedFields['whole_day']))
2522 2521
 					{
2523
-						$event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true);
2522
+						$event['whole_day'] = (isset($attributes['value']) ? strtoupper($attributes['value']) == 'TRUE' : true);
2524 2523
 					}
2525 2524
 					break;
2526 2525
 				case 'AALARM':
@@ -2550,32 +2549,32 @@  discard block
 block discarded – undo
2550 2549
 					$vcardData['recurrence'] = $attributes['value'];
2551 2550
 					break;
2552 2551
 				case 'LOCATION':
2553
-					$vcardData['location']	= str_replace("\r\n", "\n", $attributes['value']);
2552
+					$vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']);
2554 2553
 					break;
2555 2554
 				case 'RRULE':
2556 2555
 					$recurence = $attributes['value'];
2557 2556
 					$vcardData['recur_interval'] = 1;
2558
-					$type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence[0];
2557
+					$type = preg_match('/FREQ=([^;: ]+)/i', $recurence, $matches) ? $matches[1] : $recurence[0];
2559 2558
 					// vCard 2.0 values for all types
2560
-					if (preg_match('/UNTIL=([0-9TZ]+)/',$recurence,$matches))
2559
+					if (preg_match('/UNTIL=([0-9TZ]+)/', $recurence, $matches))
2561 2560
 					{
2562 2561
 						$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($matches[1]);
2563 2562
 						// If it couldn't be parsed, treat it as not set
2564
-						if(is_string($vcardData['recur_enddate']))
2563
+						if (is_string($vcardData['recur_enddate']))
2565 2564
 						{
2566 2565
 							unset($vcardData['recur_enddate']);
2567 2566
 						}
2568 2567
 					}
2569
-					elseif (preg_match('/COUNT=([0-9]+)/',$recurence,$matches))
2568
+					elseif (preg_match('/COUNT=([0-9]+)/', $recurence, $matches))
2570 2569
 					{
2571 2570
 						$vcardData['recur_count'] = (int)$matches[1];
2572 2571
 					}
2573
-					if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches))
2572
+					if (preg_match('/INTERVAL=([0-9]+)/', $recurence, $matches))
2574 2573
 					{
2575
-						$vcardData['recur_interval'] = (int) $matches[1] ? (int) $matches[1] : 1;
2574
+						$vcardData['recur_interval'] = (int)$matches[1] ? (int)$matches[1] : 1;
2576 2575
 					}
2577 2576
 					$vcardData['recur_data'] = 0;
2578
-					switch($type)
2577
+					switch ($type)
2579 2578
 					{
2580 2579
 						case 'D':	// 1.0
2581 2580
 							$recurenceMatches = null;
@@ -2599,20 +2598,20 @@  discard block
 block discarded – undo
2599 2598
 						case 'W':
2600 2599
 						case 'WEEKLY':
2601 2600
 							$days = array();
2602
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2601
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/', $recurence, $recurenceMatches))		// 1.0
2603 2602
 							{
2604 2603
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2605 2604
 								if (empty($recurenceMatches[2]))
2606 2605
 								{
2607
-									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
2606
+									$days[0] = strtoupper(substr(date('D', $vcardData['start']), 0, 2));
2608 2607
 								}
2609 2608
 								else
2610 2609
 								{
2611
-									$days = explode(' ',trim($recurenceMatches[2]));
2610
+									$days = explode(' ', trim($recurenceMatches[2]));
2612 2611
 								}
2613 2612
 
2614 2613
 								$repeatMatches = null;
2615
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2614
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $repeatMatches))
2616 2615
 								{
2617 2616
 									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2618 2617
 								}
@@ -2623,21 +2622,21 @@  discard block
 block discarded – undo
2623 2622
 
2624 2623
 								$recur_days = $this->recur_days_1_0;
2625 2624
 							}
2626
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2625
+							elseif (preg_match('/BYDAY=([^;: ]+)/', $recurence, $recurenceMatches))	// 2.0
2627 2626
 							{
2628
-								$days = explode(',',$recurenceMatches[1]);
2627
+								$days = explode(',', $recurenceMatches[1]);
2629 2628
 								$recur_days = $this->recur_days;
2630 2629
 							}
2631 2630
 							else	// no day given, use the day of dtstart
2632 2631
 							{
2633
-								$vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']);
2632
+								$vcardData['recur_data'] |= 1 << (int)date('w', $vcardData['start']);
2634 2633
 								$vcardData['recur_type'] = MCAL_RECUR_WEEKLY;
2635 2634
 							}
2636 2635
 							if ($days)
2637 2636
 							{
2638 2637
 								foreach ($recur_days as $id => $day)
2639 2638
 								{
2640
-									if (in_array(strtoupper(substr($day,0,2)),$days))
2639
+									if (in_array(strtoupper(substr($day, 0, 2)), $days))
2641 2640
 									{
2642 2641
 										$vcardData['recur_data'] |= $id;
2643 2642
 									}
@@ -2653,17 +2652,17 @@  discard block
 block discarded – undo
2653 2652
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2654 2653
 								$vcardData['recur_count'] = $recurenceMatches[2];
2655 2654
 							}
2656
-							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2655
+							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2657 2656
 							{
2658 2657
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY;
2659 2658
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2660 2659
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2661 2660
 							}
2662
-							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches))
2661
+							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/', $recurence, $recurenceMatches))
2663 2662
 							{
2664 2663
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
2665 2664
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2666
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$recurenceMatches))
2665
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $recurenceMatches))
2667 2666
 								{
2668 2667
 									$vcardData['recur_count'] = $recurenceMatches[1];
2669 2668
 								}
@@ -2680,7 +2679,7 @@  discard block
 block discarded – undo
2680 2679
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2681 2680
 								$vcardData['recur_count'] = $recurenceMatches[2];
2682 2681
 							}
2683
-							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2682
+							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2684 2683
 							{
2685 2684
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2686 2685
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
@@ -2694,11 +2693,11 @@  discard block
 block discarded – undo
2694 2693
 							}
2695 2694
 							// handle FREQ=YEARLY;BYDAY= as FREQ=MONTHLY;BYDAY= with 12*INTERVAL
2696 2695
 							$vcardData['recur_interval'] = $vcardData['recur_interval'] ?
2697
-								12*$vcardData['recur_interval'] : 12;
2696
+								12 * $vcardData['recur_interval'] : 12;
2698 2697
 							// fall-through
2699 2698
 						case 'MONTHLY':
2700 2699
 							// does currently NOT parse BYDAY or BYMONTH, it has to be specified/identical to DTSTART
2701
-							$vcardData['recur_type'] = strpos($recurence,'BYDAY') !== false ?
2700
+							$vcardData['recur_type'] = strpos($recurence, 'BYDAY') !== false ?
2702 2701
 								MCAL_RECUR_MONTHLY_WDAY : MCAL_RECUR_MONTHLY_MDAY;
2703 2702
 							break;
2704 2703
 					}
@@ -2754,11 +2753,11 @@  discard block
 block discarded – undo
2754 2753
 						(strpos($this->productName, 'outlook') !== false
2755 2754
 							|| strpos($this->productName, 'pocket pc') !== false))
2756 2755
 					{
2757
-						$vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']];
2756
+						$vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']];
2758 2757
 					}
2759 2758
 					else
2760 2759
 					{
2761
-						$vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']];
2760
+						$vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']];
2762 2761
 					}
2763 2762
 					break;
2764 2763
 				case 'CATEGORIES':
@@ -2772,10 +2771,10 @@  discard block
 block discarded – undo
2772 2771
 					}
2773 2772
 					break;
2774 2773
 				case 'ORGANIZER':
2775
-					$event['organizer'] = $attributes['value'];	// no egw field, but needed in AS
2776
-					if (strtolower(substr($event['organizer'],0,7)) == 'mailto:')
2774
+					$event['organizer'] = $attributes['value']; // no egw field, but needed in AS
2775
+					if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:')
2777 2776
 					{
2778
-						$event['organizer'] = substr($event['organizer'],7);
2777
+						$event['organizer'] = substr($event['organizer'], 7);
2779 2778
 					}
2780 2779
 					if (!empty($attributes['params']['CN']))
2781 2780
 					{
@@ -2812,19 +2811,19 @@  discard block
 block discarded – undo
2812 2811
 					}
2813 2812
 					// try parsing email and cn from attendee
2814 2813
 					elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2815
-						$attributes['value'],$matches))
2814
+						$attributes['value'], $matches))
2816 2815
 					{
2817 2816
 						$email = $matches[1] ? $matches[1] : $matches[3];
2818
-						$cn = isset($matches[2]) ? $matches[2]: '';
2817
+						$cn = isset($matches[2]) ? $matches[2] : '';
2819 2818
 					}
2820 2819
 					elseif (!empty($attributes['value']) &&
2821 2820
 						preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2822
-						$attributes['value'],$matches))
2821
+						$attributes['value'], $matches))
2823 2822
 					{
2824 2823
 						$cn = $matches[1];
2825 2824
 						$email = $matches[2];
2826 2825
 					}
2827
-					elseif (strpos($attributes['value'],'@') !== false)
2826
+					elseif (strpos($attributes['value'], '@') !== false)
2828 2827
 					{
2829 2828
 						$email = $attributes['value'];
2830 2829
 					}
@@ -2841,7 +2840,7 @@  discard block
 block discarded – undo
2841 2840
 						if ($this->log)
2842 2841
 						{
2843 2842
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2844
-								. "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile);
2843
+								. "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile);
2845 2844
 						}
2846 2845
 					}
2847 2846
 					elseif ($attributes['value'] == 'Unknown')
@@ -2859,7 +2858,7 @@  discard block
 block discarded – undo
2859 2858
 						if ($this->log)
2860 2859
 						{
2861 2860
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2862
-								. "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile);
2861
+								. "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2863 2862
 						}
2864 2863
 					}
2865 2864
 					if (!$uid)
@@ -2876,9 +2875,9 @@  discard block
 block discarded – undo
2876 2875
 							$cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'),
2877 2876
 										array(',', ';', ':', '\\'),
2878 2877
 										$attributes['params']['CN']);
2879
-							if ($cn[0] == '"' && substr($cn,-1) == '"')
2878
+							if ($cn[0] == '"' && substr($cn, -1) == '"')
2880 2879
 							{
2881
-								$cn = substr($cn,1,-1);
2880
+								$cn = substr($cn, 1, -1);
2882 2881
 							}
2883 2882
 							// not searching for $cn, as match can be not unique or without an email address
2884 2883
 							// --> notification will fail, better store just as email
@@ -2887,19 +2886,19 @@  discard block
 block discarded – undo
2887 2886
 						if ($this->log)
2888 2887
 						{
2889 2888
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2890
-								. "() Search participant: '$cn', '$email'\n",3,$this->logfile);
2889
+								. "() Search participant: '$cn', '$email'\n", 3, $this->logfile);
2891 2890
 						}
2892 2891
 
2893 2892
 						//elseif (//$attributes['params']['CUTYPE'] == 'GROUP'
2894
-						if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches))
2893
+						if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches))
2895 2894
 						{
2896 2895
 							// we found a group
2897 2896
 							if ($this->log)
2898 2897
 							{
2899 2898
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2900
-									. "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile);
2899
+									. "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile);
2901 2900
 							}
2902
-							if (($uid =  $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2901
+							if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2903 2902
 							{
2904 2903
 								//Horde::logMessage("vevent2egw: group participant $uid",
2905 2904
 								//			__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -2913,7 +2912,7 @@  discard block
 block discarded – undo
2913 2912
 										//Horde::logMessage("vevent2egw: set status to " . $status,
2914 2913
 										//		__FILE__, __LINE__, PEAR_LOG_DEBUG);
2915 2914
 										$vcardData['participants'][$this->user] =
2916
-											calendar_so::combine_status($status,$quantity,$role);
2915
+											calendar_so::combine_status($status, $quantity, $role);
2917 2916
 									}
2918 2917
 								}
2919 2918
 								$status = 'U'; // keep the group
@@ -2922,36 +2921,36 @@  discard block
 block discarded – undo
2922 2921
 						}
2923 2922
 						elseif (empty($searcharray))
2924 2923
 						{
2925
-							continue;	// participants without email AND CN --> ignore it
2924
+							continue; // participants without email AND CN --> ignore it
2926 2925
 						}
2927 2926
 						elseif ((list($data) = $this->addressbook->search($searcharray,
2928
-							array('id','egw_addressbook.account_id as account_id','n_fn'),
2927
+							array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
2929 2928
 							'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
2930
-							'','',false,'OR')))
2929
+							'', '', false, 'OR')))
2931 2930
 						{
2932 2931
 							// found an addressbook entry
2933 2932
 							$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
2934 2933
 							if ($this->log)
2935 2934
 							{
2936 2935
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2937
-									. "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile);
2936
+									. "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2938 2937
 							}
2939 2938
 						}
2940 2939
 						else
2941 2940
 						{
2942 2941
 							if (!$email)
2943 2942
 							{
2944
-								$email = '[email protected]';	// set dummy email to store the CN
2943
+								$email = '[email protected]'; // set dummy email to store the CN
2945 2944
 							}
2946
-							$uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email);
2945
+							$uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email);
2947 2946
 							if ($this->log)
2948 2947
 							{
2949 2948
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2950
-									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile);
2949
+									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2951 2950
 							}
2952 2951
 						}
2953 2952
 					}
2954
-					switch($attributes['name'])
2953
+					switch ($attributes['name'])
2955 2954
 					{
2956 2955
 						case 'ATTENDEE':
2957 2956
 							if (!isset($attributes['params']['ROLE']) &&
@@ -2965,7 +2964,7 @@  discard block
 block discarded – undo
2965 2964
 								// keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role
2966 2965
 								// as this is currently the only way to store an external organizer and send him iMip responses
2967 2966
 								$q = $r = null;
2968
-								if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) &&
2967
+								if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) &&
2969 2968
 									calendar_so::split_status($s, $q, $r) && $r == 'CHAIR')
2970 2969
 								{
2971 2970
 									$role = 'CHAIR';
@@ -2979,7 +2978,7 @@  discard block
 block discarded – undo
2979 2978
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2980 2979
 										$component->getAttribute('ORGANIZER');
2981 2980
 								}
2982
-								catch(Horde_Icalendar_Exception $e)
2981
+								catch (Horde_Icalendar_Exception $e)
2983 2982
 								{
2984 2983
 									// we can store the ORGANIZER as event owner
2985 2984
 									$event['owner'] = $uid;
@@ -3035,7 +3034,7 @@  discard block
 block discarded – undo
3035 3034
 					break;
3036 3035
 
3037 3036
 				case 'ATTACH':
3038
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3037
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code
3039 3038
 					// fall throught to store external attachment url
3040 3039
 				default:	// X- attribute or other by EGroupware unsupported property
3041 3040
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3093,7 +3092,7 @@  discard block
 block discarded – undo
3093 3092
 					if ($event['recur_type'] != MCAL_RECUR_NONE)
3094 3093
 					{
3095 3094
 						$event['reference'] = 0;
3096
-						foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r)
3095
+						foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r)
3097 3096
 						{
3098 3097
 							if (isset($vcardData[$r]))
3099 3098
 							{
@@ -3116,12 +3115,12 @@  discard block
 block discarded – undo
3116 3115
 			// reset recure_enddate to 00:00:00 on the last day
3117 3116
 			$rriter = calendar_rrule::event2rrule($event, false);
3118 3117
 			$last = $rriter->normalize_enddate();
3119
-			if(!is_object($last))
3118
+			if (!is_object($last))
3120 3119
 			{
3121
-				if($this->log)
3120
+				if ($this->log)
3122 3121
 				{
3123
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
3124
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3122
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
3123
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3125 3124
 				}
3126 3125
 				return false;
3127 3126
 			}
@@ -3130,16 +3129,16 @@  discard block
 block discarded – undo
3130 3129
 			$event['recur_enddate'] = Api\DateTime::to($last, 'server');
3131 3130
 		}
3132 3131
 		// translate COUNT into an enddate, as we only store enddates
3133
-		elseif($event['recur_count'])
3132
+		elseif ($event['recur_count'])
3134 3133
 		{
3135 3134
 			$rriter = calendar_rrule::event2rrule($event, false);
3136 3135
 			$last = $rriter->count2date($event['recur_count']);
3137
-			if(!is_object($last))
3136
+			if (!is_object($last))
3138 3137
 			{
3139
-				if($this->log)
3138
+				if ($this->log)
3140 3139
 				{
3141 3140
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__,
3142
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3141
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3143 3142
 				}
3144 3143
 				return false;
3145 3144
 			}
@@ -3153,7 +3152,7 @@  discard block
 block discarded – undo
3153 3152
 			if ($this->productManufacturer == 'groupdav' && $container &&
3154 3153
 				($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')))
3155 3154
 			{
3156
-				$event['public'] =  (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3155
+				$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3157 3156
 			}
3158 3157
 			//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
3159 3158
 		}
@@ -3174,15 +3173,15 @@  discard block
 block discarded – undo
3174 3173
 
3175 3174
 		if ($this->log)
3176 3175
 		{
3177
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
3178
-				array2string($event)."\n",3,$this->logfile);
3176
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
3177
+				array2string($event)."\n", 3, $this->logfile);
3179 3178
 		}
3180 3179
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3181 3180
         //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3182 3181
 		return $event;
3183 3182
 	}
3184 3183
 
3185
-	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3184
+	function search($_vcalData, $contentID = null, $relax = false, $charset = null)
3186 3185
 	{
3187 3186
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
3188 3187
 		{
@@ -3203,8 +3202,8 @@  discard block
 block discarded – undo
3203 3202
 			}
3204 3203
 			if ($this->log)
3205 3204
 			{
3206
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" .
3207
-					array2string($events)."\n",3,$this->logfile);
3205
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n".
3206
+					array2string($events)."\n", 3, $this->logfile);
3208 3207
 			}
3209 3208
 		}
3210 3209
 		return array();
@@ -3222,23 +3221,23 @@  discard block
 block discarded – undo
3222 3221
 	 * @param array $extra =null extra attributes to add
3223 3222
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3224 3223
 	 */
3225
-	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3224
+	function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null)
3226 3225
 	{
3227
-		if (!$start) $start = time();	// default now
3228
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3226
+		if (!$start) $start = time(); // default now
3227
+		if (!$end) $end = time() + 100 * DAY_s; // default next 100 days
3229 3228
 
3230 3229
 		$vcal = new Horde_Icalendar;
3231
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3230
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3232 3231
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
3233
-		$vcal->setAttribute('VERSION','2.0');
3234
-		$vcal->setAttribute('METHOD',$method);
3232
+		$vcal->setAttribute('VERSION', '2.0');
3233
+		$vcal->setAttribute('METHOD', $method);
3235 3234
 
3236
-		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal);
3235
+		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal);
3237 3236
 
3238 3237
 		$attributes = array(
3239 3238
 			'DTSTAMP' => time(),
3240
-			'DTSTART' => $this->date2ts($start,true),	// true = server-time
3241
-			'DTEND' => $this->date2ts($end,true),	// true = server-time
3239
+			'DTSTART' => $this->date2ts($start, true), // true = server-time
3240
+			'DTEND' => $this->date2ts($end, true), // true = server-time
3242 3241
 		);
3243 3242
 		if (!$utc)
3244 3243
 		{
@@ -3249,9 +3248,9 @@  discard block
 block discarded – undo
3249 3248
 		}
3250 3249
 		if (is_null($extra)) $extra = array(
3251 3250
 			'URL' => $this->freebusy_url($user),
3252
-			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3251
+			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'),
3253 3252
 		);
3254
-		foreach($attributes+$extra as $attr => $value)
3253
+		foreach ($attributes + $extra as $attr => $value)
3255 3254
 		{
3256 3255
 			$vfreebusy->setAttribute($attr, $value);
3257 3256
 		}
@@ -3274,16 +3273,16 @@  discard block
 block discarded – undo
3274 3273
 
3275 3274
 				if ($utc)
3276 3275
 				{
3277
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3276
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3278 3277
 						'start' => $event['start'],
3279 3278
 						'end' => $event['end'],
3280 3279
 					)), array('FBTYPE' => $fbtype));
3281 3280
 				}
3282 3281
 				else
3283 3282
 				{
3284
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3285
-						'start' => date('Ymd\THis',$event['start']),
3286
-						'end' => date('Ymd\THis',$event['end']),
3283
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3284
+						'start' => date('Ymd\THis', $event['start']),
3285
+						'end' => date('Ymd\THis', $event['end']),
3287 3286
 					)), array('FBTYPE' => $fbtype));
3288 3287
 				}
3289 3288
 			}
Please login to merge, or discard this patch.
Braces   +317 added lines, -81 removed lines patch added patch discarded remove patch
@@ -177,7 +177,10 @@  discard block
 block discarded – undo
177 177
 	function __construct(&$_clientProperties = array())
178 178
 	{
179 179
 		parent::__construct();
180
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
180
+		if ($this->log)
181
+		{
182
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
183
+		}
181 184
 		$this->clientProperties = $_clientProperties;
182 185
 		$this->vCalendar = new Horde_Icalendar;
183 186
 		$this->addressbook = new Api\Contacts;
@@ -226,10 +229,14 @@  discard block
 block discarded – undo
226 229
 			'ATTACH'        => 'attachments',
227 230
 		);
228 231
 
229
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
232
+		if (!is_array($this->supportedFields))
233
+		{
234
+			$this->setSupportedFields();
235
+		}
230 236
 
231 237
 		if ($this->productManufacturer == '' )
232
-		{	// syncevolution is broken
238
+		{
239
+// syncevolution is broken
233 240
 			$version = '2.0';
234 241
 		}
235 242
 
@@ -237,10 +244,16 @@  discard block
 block discarded – undo
237 244
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
238 245
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
239 246
 		$vcal->setAttribute('VERSION', $version);
240
-		if ($method) $vcal->setAttribute('METHOD', $method);
247
+		if ($method)
248
+		{
249
+			$vcal->setAttribute('METHOD', $method);
250
+		}
241 251
 		$events_exported = false;
242 252
 
243
-		if (!is_array($events)) $events = array($events);
253
+		if (!is_array($events))
254
+		{
255
+			$events = array($events);
256
+		}
244 257
 
245 258
 		$vtimezones_added = array();
246 259
 		foreach ($events as $event)
@@ -306,7 +319,10 @@  discard block
 block discarded – undo
306 319
 				self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']);
307 320
 			}
308 321
 
309
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
322
+			if ($this->so->isWholeDay($event))
323
+			{
324
+				$event['whole_day'] = true;
325
+			}
310 326
 
311 327
 			if ($this->log)
312 328
 			{
@@ -317,7 +333,10 @@  discard block
 block discarded – undo
317 333
 
318 334
 			if ($recurrence)
319 335
 			{
320
-				if (!($master = $this->read($event['id'], 0, true, 'server'))) continue;
336
+				if (!($master = $this->read($event['id'], 0, true, 'server')))
337
+				{
338
+					continue;
339
+				}
321 340
 
322 341
 				if (!isset($this->supportedFields['participants']))
323 342
 				{
@@ -374,7 +393,8 @@  discard block
 block discarded – undo
374 393
 			if ($this->productManufacturer != 'file' && $this->uidExtension)
375 394
 			{
376 395
 				// Append UID to DESCRIPTION
377
-				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
396
+				if (!preg_match('/\[UID:.+\]/m', $event['description']))
397
+				{
378 398
 					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
379 399
 				}
380 400
 			}
@@ -434,11 +454,21 @@  discard block
 block discarded – undo
434 454
 							$quantity = $role = null;
435 455
 							calendar_so::split_status($status, $quantity, $role);
436 456
 							// do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant
437
-							if (count($event['participants']) == 1 && $event['owner'] == $uid) continue;
457
+							if (count($event['participants']) == 1 && $event['owner'] == $uid)
458
+							{
459
+								continue;
460
+							}
438 461
 
439
-							if (!($info = $this->resource_info($uid))) continue;
462
+							if (!($info = $this->resource_info($uid)))
463
+							{
464
+								continue;
465
+							}
440 466
 
441
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
467
+							if (in_array($status, array('X','E')))
468
+							{
469
+								continue;
470
+							}
471
+							// dont include deleted participants
442 472
 
443 473
 							if ($this->log)
444 474
 							{
@@ -517,24 +547,49 @@  discard block
 block discarded – undo
517 547
 							}
518 548
 							// ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*}
519 549
 							$options = array();
520
-							if (!empty($participantCN)) $options['CN'] = $participantCN;
521
-							if (!empty($role)) $options['ROLE'] = $role;
522
-							if (!empty($status)) $options['PARTSTAT'] = $status;
523
-							if (!empty($cutype)) $options['CUTYPE'] = $cutype;
524
-							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
550
+							if (!empty($participantCN))
551
+							{
552
+								$options['CN'] = $participantCN;
553
+							}
554
+							if (!empty($role))
555
+							{
556
+								$options['ROLE'] = $role;
557
+							}
558
+							if (!empty($status))
559
+							{
560
+								$options['PARTSTAT'] = $status;
561
+							}
562
+							if (!empty($cutype))
563
+							{
564
+								$options['CUTYPE'] = $cutype;
565
+							}
566
+							if (!empty($rsvp))
567
+							{
568
+								$options['RSVP'] = $rsvp;
569
+							}
525 570
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
526 571
 							{
527 572
 								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
528 573
 							}
529
-							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
530
-							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
574
+							if ($info['type'] != 'e')
575
+							{
576
+								$options['X-EGROUPWARE-UID'] = (string)$uid;
577
+							}
578
+							if ($quantity > 1)
579
+							{
580
+								$options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
581
+							}
531 582
 							$attributes['ATTENDEE'][] = $participantURL;
532 583
 							$parameters['ATTENDEE'][] = $options;
533 584
 						}
534 585
 						break;
535 586
 
536 587
 					case 'CLASS':
537
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
588
+						if ($event['public'])
589
+						{
590
+							continue;
591
+						}
592
+						// public is default, no need to export, fails CalDAVTester if added as default
538 593
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
539 594
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
540 595
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -566,9 +621,18 @@  discard block
 block discarded – undo
566 621
 									'CUTYPE'   => 'INDIVIDUAL',
567 622
 									//'RSVP'     => 'FALSE',
568 623
 									);
569
-								if (!empty($organizerCN)) $options['CN'] = $organizerCN;
570
-								if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail;
571
-								if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner'];
624
+								if (!empty($organizerCN))
625
+								{
626
+									$options['CN'] = $organizerCN;
627
+								}
628
+								if (!empty($organizerEMail))
629
+								{
630
+									$options['EMAIL'] = $organizerEMail;
631
+								}
632
+								if (!empty($event['owner']))
633
+								{
634
+									$options['X-EGROUPWARE-UID'] = $event['owner'];
635
+								}
572 636
 								$attributes['ATTENDEE'][] = $organizerURL;
573 637
 			    				$parameters['ATTENDEE'][] = $options;
574 638
 		    				}
@@ -597,9 +661,12 @@  discard block
 block discarded – undo
597 661
 						{
598 662
 							// Hack for CalDAVTester to export duration instead of endtime
599 663
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
600
-								$attributes['duration'] = $event['end'] - $event['start'];
601
-							else
602
-							$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
664
+							{
665
+															$attributes['duration'] = $event['end'] - $event['start'];
666
+							}
667
+							else {
668
+														$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
669
+							}
603 670
 						}
604 671
 						else
605 672
 						{
@@ -619,7 +686,11 @@  discard block
 block discarded – undo
619 686
 						break;
620 687
 
621 688
 					case 'RRULE':
622
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
689
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
690
+						{
691
+							break;
692
+						}
693
+						// no recuring event
623 694
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
624 695
 						$rrule = $rriter->generate_rrule($version);
625 696
 						if ($event['recur_enddate'])
@@ -653,7 +724,10 @@  discard block
 block discarded – undo
653 724
 						break;
654 725
 
655 726
 					case 'EXDATE':
656
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;
727
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
728
+						{
729
+							break;
730
+						}
657 731
 						if (!empty($event['recur_exception']))
658 732
 						{
659 733
 							if (empty($event['whole_day']))
@@ -680,14 +754,21 @@  discard block
 block discarded – undo
680 754
 									);
681 755
 								}
682 756
 								$event['recur_exception'] = $days;
683
-								if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE';
757
+								if ($version != '1.0')
758
+								{
759
+									$parameters['EXDATE']['VALUE'] = 'DATE';
760
+								}
684 761
 							}
685 762
 							$vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']);
686 763
 						}
687 764
 						break;
688 765
 
689 766
 					case 'PRIORITY':
690
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
767
+						if (!$event['priority'])
768
+						{
769
+							continue;
770
+						}
771
+						// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
691 772
 						if ($this->productManufacturer == 'funambol' &&
692 773
 							(strpos($this->productName, 'outlook') !== false
693 774
 								|| strpos($this->productName, 'pocket pc') !== false))
@@ -701,7 +782,11 @@  discard block
 block discarded – undo
701 782
 						break;
702 783
 
703 784
 					case 'TRANSP':
704
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
785
+						if (!$event['non_blocking'])
786
+						{
787
+							continue;
788
+						}
789
+						// OPAQUE is default, no need to export, fails CalDAVTester if added as default
705 790
 						if ($version == '1.0')
706 791
 						{
707 792
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -758,7 +843,11 @@  discard block
 block discarded – undo
758 843
 						elseif ($event['recurrence'] && $event['reference'])
759 844
 						{
760 845
 							// $event['reference'] is a calendar_id, not a timestamp
761
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
846
+							if (!($revent = $this->read($event['reference'])))
847
+							{
848
+								break;
849
+							}
850
+							// referenced event does not exist
762 851
 
763 852
 							if (empty($revent['whole_day']))
764 853
 							{
@@ -884,7 +973,10 @@  discard block
 block discarded – undo
884 973
 			foreach ((array)$event['alarm'] as $alarmData)
885 974
 			{
886 975
 				// skip over alarms that don't have the minimum required info
887
-				if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue;
976
+				if (!isset($alarmData['offset']) && !isset($alarmData['time']))
977
+				{
978
+					continue;
979
+				}
888 980
 
889 981
 				// skip alarms not being set for all users and alarms owned by other users
890 982
 				if ($alarmData['all'] != true && $alarmData['owner'] != $this->user)
@@ -901,7 +993,10 @@  discard block
 block discarded – undo
901 993
 
902 994
 				if ($version == '1.0')
903 995
 				{
904
-					if ($event['title']) $description = $event['title'];
996
+					if ($event['title'])
997
+					{
998
+						$description = $event['title'];
999
+					}
905 1000
 					if ($description)
906 1001
 					{
907 1002
 						$values['DALARM']['snooze_time'] = '';
@@ -921,7 +1016,10 @@  discard block
 block discarded – undo
921 1016
 					// VCalendar 2.0 / RFC 2445
922 1017
 
923 1018
 					// RFC requires DESCRIPTION for DISPLAY
924
-					if (!$event['title'] && !$description) $description = 'Alarm';
1019
+					if (!$event['title'] && !$description)
1020
+					{
1021
+						$description = 'Alarm';
1022
+					}
925 1023
 
926 1024
 					/* Disabling for now
927 1025
 					// Lightning infinitly pops up alarms for recuring events, if the only use an offset
@@ -1112,13 +1210,20 @@  discard block
 block discarded – undo
1112 1210
 		$this->events_imported = 0;
1113 1211
 		$replace = $delete_exceptions= false;
1114 1212
 
1115
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1213
+		if (!is_array($this->supportedFields))
1214
+		{
1215
+			$this->setSupportedFields();
1216
+		}
1116 1217
 
1117 1218
 		if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset)))
1118 1219
 		{
1119 1220
 			return false;
1120 1221
 		}
1121
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1222
+		if (!is_array($events))
1223
+		{
1224
+			$cal_id = -1;
1225
+		}
1226
+		// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1122 1227
 
1123 1228
 		if ($cal_id > 0)
1124 1229
 		{
@@ -1126,8 +1231,14 @@  discard block
 block discarded – undo
1126 1231
 			{
1127 1232
 				$replace = $recur_date == 0;
1128 1233
 				$events[0]['id'] = $cal_id;
1129
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1130
-				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1234
+				if (!is_null($etag))
1235
+				{
1236
+					$events[0]['etag'] = (int) $etag;
1237
+				}
1238
+				if ($recur_date)
1239
+				{
1240
+					$events[0]['recurrence'] = $recur_date;
1241
+				}
1131 1242
 			}
1132 1243
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
1133 1244
 					($eventId = array_shift($foundEvent)) &&
@@ -1135,7 +1246,10 @@  discard block
 block discarded – undo
1135 1246
 			{
1136 1247
 				foreach ($events as $k => $event)
1137 1248
 				{
1138
-					if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid'];
1249
+					if (!isset($event['uid']))
1250
+					{
1251
+						$events[$k]['uid'] = $egwEvent['uid'];
1252
+					}
1139 1253
 				}
1140 1254
 			}
1141 1255
 		}
@@ -1165,10 +1279,17 @@  discard block
 block discarded – undo
1165 1279
 		$msg = null;
1166 1280
 		foreach ($events as $event)
1167 1281
 		{
1168
-			if (!is_array($event)) continue; // the iterator may return false
1282
+			if (!is_array($event))
1283
+			{
1284
+				continue;
1285
+			}
1286
+			// the iterator may return false
1169 1287
 			++$this->events_imported;
1170 1288
 
1171
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
1289
+			if ($this->so->isWholeDay($event))
1290
+			{
1291
+				$event['whole_day'] = true;
1292
+			}
1172 1293
 			if (is_array($event['category']))
1173 1294
 			{
1174 1295
 				$event['category'] = $this->find_or_add_categories($event['category'],
@@ -1205,7 +1326,10 @@  discard block
 block discarded – undo
1205 1326
 						}
1206 1327
 						else
1207 1328
 						{
1208
-							if (!($exception = $this->read($id))) continue;
1329
+							if (!($exception = $this->read($id)))
1330
+							{
1331
+								continue;
1332
+							}
1209 1333
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1210 1334
 							$exception['reference'] = $exception['recurrence'] = 0;
1211 1335
 							$this->update($exception, true,true,false,true,$msg,$skip_notification);
@@ -1294,7 +1418,10 @@  discard block
 block discarded – undo
1294 1418
 								break;
1295 1419
 
1296 1420
 							default:
1297
-								if (!empty($value)) $event[$key] = $value;
1421
+								if (!empty($value))
1422
+								{
1423
+									$event[$key] = $value;
1424
+								}
1298 1425
 						}
1299 1426
 					}
1300 1427
 				}
@@ -1392,7 +1519,10 @@  discard block
 block discarded – undo
1392 1519
 			else // common adjustments for new events
1393 1520
 			{
1394 1521
 				unset($event['id']);
1395
-				if ($caldav_name) $event['caldav_name'] = $caldav_name;
1522
+				if ($caldav_name)
1523
+				{
1524
+					$event['caldav_name'] = $caldav_name;
1525
+				}
1396 1526
 				// set non blocking all day depending on the user setting
1397 1527
 				if (!empty($event['whole_day']) && $this->nonBlockingAllday)
1398 1528
 				{
@@ -1440,7 +1570,10 @@  discard block
 block discarded – undo
1440 1570
 					|| !isset($event['participants'][$event['owner']]))
1441 1571
 				{
1442 1572
 					$status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR');
1443
-					if (!is_array($event['participants'])) $event['participants'] = array();
1573
+					if (!is_array($event['participants']))
1574
+					{
1575
+						$event['participants'] = array();
1576
+					}
1444 1577
 					$event['participants'][$event['owner']] = $status;
1445 1578
 				}
1446 1579
 				else
@@ -1593,7 +1726,10 @@  discard block
 block discarded – undo
1593 1726
 								$occurence = $exception = false;
1594 1727
 								foreach ($event_info['master_event']['recur_exception'] as $exception)
1595 1728
 								{
1596
-									if ($exception > $event['start']) break;
1729
+									if ($exception > $event['start'])
1730
+									{
1731
+										break;
1732
+									}
1597 1733
 									$occurence = $exception;
1598 1734
 								}
1599 1735
 								if (!$occurence)
@@ -1683,12 +1819,15 @@  discard block
 block discarded – undo
1683 1819
 					case 'SERIES-MASTER':
1684 1820
 					case 'SERIES-EXCEPTION':
1685 1821
 					case 'SERIES-EXCEPTION-PROPAGATE':
1686
-						if (is_array($event_info['stored_event'])) // status update requires a stored event
1822
+						if (is_array($event_info['stored_event']))
1823
+						{
1824
+							// status update requires a stored event
1687 1825
 						{
1688 1826
 							if ($event_info['acl_edit'])
1689 1827
 							{
1690 1828
 								// update all participants if we have the right to do that
1691 1829
 								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1830
+						}
1692 1831
 							}
1693 1832
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1694 1833
 							{
@@ -1700,9 +1839,12 @@  discard block
 block discarded – undo
1700 1839
 						break;
1701 1840
 
1702 1841
 					case 'SERIES-PSEUDO-EXCEPTION':
1703
-						if (is_array($event_info['master_event'])) // status update requires a stored master event
1842
+						if (is_array($event_info['master_event']))
1843
+						{
1844
+							// status update requires a stored master event
1704 1845
 						{
1705 1846
 							$recurrence = $this->date2usertime($event['recurrence']);
1847
+						}
1706 1848
 							if ($event_info['acl_edit'])
1707 1849
 							{
1708 1850
 								// update all participants if we have the right to do that
@@ -1775,7 +1917,10 @@  discard block
 block discarded – undo
1775 1917
 	 */
1776 1918
 	public function sync_alarms(array &$event, array $old_alarms, $user)
1777 1919
 	{
1778
-		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1920
+		if ($this->debug)
1921
+		{
1922
+			error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1923
+		}
1779 1924
 		$modified = 0;
1780 1925
 		foreach($event['alarm'] as &$alarm)
1781 1926
 		{
@@ -1799,19 +1944,40 @@  discard block
 block discarded – undo
1799 1944
 			if ($alarm['offset'] != $old_alarm['offset'] || $old_alarm['owner'] != $user && !$alarm['all'])
1800 1945
 			{
1801 1946
 				$alarm['owner'] = $user;
1802
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1803
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1804
-				if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1805
-				if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm);
1947
+				if (!isset($alarm['time']))
1948
+				{
1949
+					$alarm['time'] = $event['start'] - $alarm['offset'];
1950
+				}
1951
+				if ($alarm['time'] < time())
1952
+				{
1953
+					calendar_so::shift_alarm($event, $alarm);
1954
+				}
1955
+				if ($this->debug)
1956
+				{
1957
+					error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1958
+				}
1959
+				if ($event['id'])
1960
+				{
1961
+					$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1962
+				}
1806 1963
 				++$modified;
1807 1964
 			}
1808 1965
 			// existing alarm --> update it
1809 1966
 			elseif ($alarm['offset'] == $old_alarm['offset'] && ($old_alarm['owner'] == $user || $old_alarm['all']))
1810 1967
 			{
1811
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1812
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1968
+				if (!isset($alarm['time']))
1969
+				{
1970
+					$alarm['time'] = $event['start'] - $alarm['offset'];
1971
+				}
1972
+				if ($alarm['time'] < time())
1973
+				{
1974
+					calendar_so::shift_alarm($event, $alarm);
1975
+				}
1813 1976
 				$alarm = array_merge($old_alarm, $alarm);
1814
-				if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
1977
+				if ($this->debug)
1978
+				{
1979
+					error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
1980
+				}
1815 1981
 				$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1816 1982
 				++$modified;
1817 1983
 			}
@@ -1825,7 +1991,10 @@  discard block
 block discarded – undo
1825 1991
 				unset($old_alarm[$id]);
1826 1992
 				continue;
1827 1993
 			}
1828
-			if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
1994
+			if ($this->debug)
1995
+			{
1996
+				error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
1997
+			}
1829 1998
 			$this->delete_alarm($id);
1830 1999
 			++$modified;
1831 2000
 		}
@@ -2244,7 +2413,10 @@  discard block
 block discarded – undo
2244 2413
 				array2string($_vcalData)."\n",3,$this->logfile);
2245 2414
 		}
2246 2415
 
2247
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
2416
+		if (!is_array($this->supportedFields))
2417
+		{
2418
+			$this->setSupportedFields();
2419
+		}
2248 2420
 
2249 2421
 		// we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2250 2422
 		if (is_resource($_vcalData))
@@ -2589,19 +2761,27 @@  discard block
 block discarded – undo
2589 2761
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2590 2762
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2]));
2591 2763
 							}
2592
-							else break;
2764
+							else {
2765
+								break;
2766
+							}
2593 2767
 							// fall-through
2594 2768
 						case 'DAILY':	// 2.0
2595 2769
 							$vcardData['recur_type'] = MCAL_RECUR_DAILY;
2596
-							if (stripos($recurence, 'BYDAY') === false) break;
2770
+							if (stripos($recurence, 'BYDAY') === false)
2771
+							{
2772
+								break;
2773
+							}
2597 2774
 							// hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval
2598 2775
 							// fall-through
2599 2776
 						case 'W':
2600 2777
 						case 'WEEKLY':
2601 2778
 							$days = array();
2602
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2779
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))
2780
+							{
2781
+								// 1.0
2603 2782
 							{
2604 2783
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2784
+							}
2605 2785
 								if (empty($recurenceMatches[2]))
2606 2786
 								{
2607 2787
 									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
@@ -2614,7 +2794,10 @@  discard block
 block discarded – undo
2614 2794
 								$repeatMatches = null;
2615 2795
 								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2616 2796
 								{
2617
-									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2797
+									if ($repeatMatches[1])
2798
+									{
2799
+										$vcardData['recur_count'] = $repeatMatches[1];
2800
+									}
2618 2801
 								}
2619 2802
 								else
2620 2803
 								{
@@ -2623,9 +2806,12 @@  discard block
 block discarded – undo
2623 2806
 
2624 2807
 								$recur_days = $this->recur_days_1_0;
2625 2808
 							}
2626
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2809
+							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))
2810
+							{
2811
+								// 2.0
2627 2812
 							{
2628 2813
 								$days = explode(',',$recurenceMatches[1]);
2814
+							}
2629 2815
 								$recur_days = $this->recur_days;
2630 2816
 							}
2631 2817
 							else	// no day given, use the day of dtstart
@@ -2684,7 +2870,10 @@  discard block
 block discarded – undo
2684 2870
 							{
2685 2871
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2686 2872
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2687
-							} else break;
2873
+							}
2874
+							else {
2875
+								break;
2876
+							}
2688 2877
 							// fall-through
2689 2878
 						case 'YEARLY':	// 2.0
2690 2879
 							if (strpos($recurence, 'BYDAY') === false)
@@ -2704,7 +2893,10 @@  discard block
 block discarded – undo
2704 2893
 					}
2705 2894
 					break;
2706 2895
 				case 'EXDATE':
2707
-					if (!$attributes['value']) break;
2896
+					if (!$attributes['value'])
2897
+					{
2898
+						break;
2899
+					}
2708 2900
 					if ((isset($attributes['params']['VALUE'])
2709 2901
 							&& $attributes['params']['VALUE'] == 'DATE') ||
2710 2902
 						(!isset($attributes['params']['VALUE']) && $isDate))
@@ -2784,13 +2976,16 @@  discard block
 block discarded – undo
2784 2976
 					// fall throught
2785 2977
 				case 'ATTENDEE':
2786 2978
 					if (isset($attributes['params']['PARTSTAT']))
2787
-				    {
2979
+					{
2788 2980
 				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2789 2981
 				    }
2790 2982
 				    if (isset($attributes['params']['STATUS']))
2791
-					{
2983
+				    {
2792 2984
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2793
-						if (empty($status)) $status = 'X';
2985
+						if (empty($status))
2986
+						{
2987
+							$status = 'X';
2988
+						}
2794 2989
 					}
2795 2990
 					else
2796 2991
 					{
@@ -2850,7 +3045,10 @@  discard block
 block discarded – undo
2850 3045
 							$uid = $this->user;
2851 3046
 					}
2852 3047
 					// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
2853
-					if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3048
+					if (!$uid)
3049
+					{
3050
+						$uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3051
+					}
2854 3052
 
2855 3053
 					// try to find an email address
2856 3054
 					if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))
@@ -2918,7 +3116,10 @@  discard block
 block discarded – undo
2918 3116
 								}
2919 3117
 								$status = 'U'; // keep the group
2920 3118
 							}
2921
-							else continue; // can't find this group
3119
+							else {
3120
+								continue;
3121
+							}
3122
+							// can't find this group
2922 3123
 						}
2923 3124
 						elseif (empty($searcharray))
2924 3125
 						{
@@ -2977,7 +3178,9 @@  discard block
 block discarded – undo
2977 3178
 
2978 3179
 								try {
2979 3180
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2980
-										$component->getAttribute('ORGANIZER');
3181
+									{
3182
+																			$component->getAttribute('ORGANIZER');
3183
+									}
2981 3184
 								}
2982 3185
 								catch(Horde_Icalendar_Exception $e)
2983 3186
 								{
@@ -3014,7 +3217,10 @@  discard block
 block discarded – undo
3014 3217
 					}
3015 3218
 					break;
3016 3219
 				case 'CREATED':		// will be written direct to the event
3017
-					if ($event['modified']) break;
3220
+					if ($event['modified'])
3221
+					{
3222
+						break;
3223
+					}
3018 3224
 					// fall through
3019 3225
 				case 'LAST-MODIFIED':	// will be written direct to the event
3020 3226
 					$event['modified'] = $attributes['value'];
@@ -3035,7 +3241,11 @@  discard block
 block discarded – undo
3035 3241
 					break;
3036 3242
 
3037 3243
 				case 'ATTACH':
3038
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3244
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE']))
3245
+					{
3246
+						break;
3247
+					}
3248
+					// handeled by managed attachment code
3039 3249
 					// fall throught to store external attachment url
3040 3250
 				default:	// X- attribute or other by EGroupware unsupported property
3041 3251
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3166,7 +3376,10 @@  discard block
 block discarded – undo
3166 3376
 			$event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength'];
3167 3377
 		}
3168 3378
 
3169
-		if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
3379
+		if ($this->calendarOwner)
3380
+		{
3381
+			$event['owner'] = $this->calendarOwner;
3382
+		}
3170 3383
 
3171 3384
 		// parsing ATTACH attributes for managed attachments
3172 3385
 		$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
@@ -3192,7 +3405,10 @@  discard block
 block discarded – undo
3192 3405
 				$filter = $relax ? 'relax' : 'check';
3193 3406
 				$event = array_shift($events);
3194 3407
 				$eventId = -1;
3195
-				if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
3408
+				if ($this->so->isWholeDay($event))
3409
+				{
3410
+					$event['whole_day'] = true;
3411
+				}
3196 3412
 				if ($contentID)
3197 3413
 				{
3198 3414
 					$parts = preg_split('/:/', $contentID);
@@ -3224,8 +3440,16 @@  discard block
 block discarded – undo
3224 3440
 	 */
3225 3441
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3226 3442
 	{
3227
-		if (!$start) $start = time();	// default now
3228
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3443
+		if (!$start)
3444
+		{
3445
+			$start = time();
3446
+		}
3447
+		// default now
3448
+		if (!$end)
3449
+		{
3450
+			$end = time() + 100*DAY_s;
3451
+		}
3452
+		// default next 100 days
3229 3453
 
3230 3454
 		$vcal = new Horde_Icalendar;
3231 3455
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -3247,10 +3471,13 @@  discard block
 block discarded – undo
3247 3471
 				$attributes[$attr] = date('Ymd\THis', $value);
3248 3472
 			}
3249 3473
 		}
3250
-		if (is_null($extra)) $extra = array(
3474
+		if (is_null($extra))
3475
+		{
3476
+			$extra = array(
3251 3477
 			'URL' => $this->freebusy_url($user),
3252 3478
 			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3253 3479
 		);
3480
+		}
3254 3481
 		foreach($attributes+$extra as $attr => $value)
3255 3482
 		{
3256 3483
 			$vfreebusy->setAttribute($attr, $value);
@@ -3266,9 +3493,18 @@  discard block
 block discarded – undo
3266 3493
 		{
3267 3494
 			foreach ($fbdata as $event)
3268 3495
 			{
3269
-				if ($event['non_blocking']) continue;
3270
-				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
3271
-				if ($event['participants'][$user] == 'R') continue;
3496
+				if ($event['non_blocking'])
3497
+				{
3498
+					continue;
3499
+				}
3500
+				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID'])
3501
+				{
3502
+					continue;
3503
+				}
3504
+				if ($event['participants'][$user] == 'R')
3505
+				{
3506
+					continue;
3507
+				}
3272 3508
 
3273 3509
 				$fbtype = $event['participants'][$user] == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
3274 3510
 
Please login to merge, or discard this patch.
calendar/inc/class.calendar_import_csv.inc.php 5 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param importepport_iface_egw_record record The egw_record object being imported
75 75
 	 * @param importexport_iface_import_record import_csv Import object contains current state
76 76
 	 *
77
-	 * @return boolean success
77
+	 * @return null|boolean success
78 78
 	 */
79 79
 	public function import_record(\importexport_iface_egw_record &$record, &$import_csv)
80 80
 	{
@@ -254,7 +254,6 @@  discard block
 block discarded – undo
254 254
 	 * perform the required action
255 255
 	 *
256 256
 	 * @param int $_action one of $this->actions
257
-	 * @param array $_data record data for the action
258 257
 	 * @return bool success or not
259 258
 	 */
260 259
 	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
@@ -343,7 +342,7 @@  discard block
 block discarded – undo
343 342
 	/**
344 343
 	 * Alter a row for preview to show multiple participants instead of Array
345 344
 	 *
346
-	 * @param egw_record $row_entry
345
+	 * @param importexport_iface_egw_record $row_entry
347 346
 	 */
348 347
 	protected function row_preview(importexport_iface_egw_record &$row_entry)
349 348
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@
 block discarded – undo
32 32
 	protected static $conditions = array('exists');
33 33
 
34 34
 	/**
35
-	* For figuring out if an entry has changed
36
-	*/
35
+	 * For figuring out if an entry has changed
36
+	 */
37 37
 	protected $tracking;
38 38
 
39 39
 	/**
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 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
 							}
@@ -150,15 +150,15 @@  discard block
 block discarded – undo
150 150
 							// Search app via link query
151 151
 							$result = Link::query($resource['app'], $search, $options);
152 152
 
153
-							if($result)
153
+							if ($result)
154 154
 							{
155
-								$id = $resource['type'] . key($result);
155
+								$id = $resource['type'].key($result);
156 156
 								break;
157 157
 							}
158 158
 						}
159 159
 					}
160 160
 				}
161
-				if($id) {
161
+				if ($id) {
162 162
 					$p_participants[$id] = calendar_so::combine_status(
163 163
 						$this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0],
164 164
 						$quantity[$key] ? $quantity[$key] : 1,
@@ -169,47 +169,47 @@  discard block
 block discarded – undo
169 169
 				{
170 170
 					$missing[] = $name;
171 171
 				}
172
-				if(count($missing) > 0)
172
+				if (count($missing) > 0)
173 173
 				{
174
-					$this->warnings[$import_csv->get_current_position()] = $record->title . ' ' . lang('participants') . ': ' .
175
-						lang('Contact not found!') . '<br />'.implode(", ",$missing);
174
+					$this->warnings[$import_csv->get_current_position()] = $record->title.' '.lang('participants').': '.
175
+						lang('Contact not found!').'<br />'.implode(", ", $missing);
176 176
 				}
177 177
 			}
178 178
 			$record->participants = $p_participants;
179 179
 		}
180 180
 
181
-		if($record->recurrence)
181
+		if ($record->recurrence)
182 182
 		{
183
-			list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2);
183
+			list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2);
184 184
 			$record->recur_interval = trim($record->recur_interval);
185
-			$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$lookups['recurrence']));
185
+			$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $lookups['recurrence']));
186 186
 			unset($record->recurrence);
187 187
 		}
188 188
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
189 189
 
190
-		if ( $options['conditions'] ) {
191
-			foreach ( $options['conditions'] as $condition ) {
190
+		if ($options['conditions']) {
191
+			foreach ($options['conditions'] as $condition) {
192 192
 				$records = array();
193
-				switch ( $condition['type'] ) {
193
+				switch ($condition['type']) {
194 194
 					// exists
195 195
 					case 'exists' :
196 196
 						// Check for that record
197 197
 						$result = $this->exists($record, $condition, $records);
198 198
 
199
-						if ( is_array( $records ) && count( $records ) >= 1) {
199
+						if (is_array($records) && count($records) >= 1) {
200 200
 							// apply action to all records matching this exists condition
201 201
 							$action = $condition['true'];
202
-							foreach ( (array)$records as $event ) {
202
+							foreach ((array)$records as $event) {
203 203
 								$record->id = $event['id'];
204
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
205
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
206
-									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
204
+								if ($this->definition->plugin_options['update_cats'] == 'add') {
205
+									if (!is_array($record->category)) $record->category = explode(',', $record->category);
206
+									$record->category = implode(',', array_unique(array_merge($record->category, $event['category'])));
207 207
 								}
208
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
208
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
209 209
 							}
210 210
 						} else {
211 211
 							$action = $condition['false'];
212
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
212
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
213 213
 						}
214 214
 						break;
215 215
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 			}
223 223
 		} else {
224 224
 			// unconditional insert
225
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
225
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
226 226
 		}
227 227
 
228 228
 		return $success;
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return boolean
239 239
 	 */
240
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
240
+	protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$records = array())
241 241
 	{
242
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
242
+		if ($record->__get($condition['string']) && $condition['string'] == 'id') {
243 243
 			$event = $this->bo->read($record->__get($condition['string']));
244 244
 			$records = array($event);
245 245
 		}
246 246
 
247
-		if ( is_array( $records ) && count( $records ) >= 1) {
247
+		if (is_array($records) && count($records) >= 1) {
248 248
 			return true;
249 249
 		}
250 250
 		return false;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @param array $_data record data for the action
258 258
 	 * @return bool success or not
259 259
 	 */
260
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
260
+	protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0)
261 261
 	{
262 262
 		$_data = $record->get_record_array();
263 263
 		switch ($_action) {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 				$old = $this->bo->read($_data['id']);
269 269
 
270 270
 				// Don't change a user account into a record
271
-				if(!$this->definition->plugin_options['change_owner']) {
271
+				if (!$this->definition->plugin_options['change_owner']) {
272 272
 					// Don't change owner of an existing record
273 273
 					unset($_data['owner']);
274 274
 				}
@@ -276,29 +276,29 @@  discard block
 block discarded – undo
276 276
 				// Merge to deal with fields not in import record
277 277
 				$_data = array_merge($old, $_data);
278 278
 				$changed = $this->tracking->changed_fields($_data, $old);
279
-				if(count($changed) == 0) {
279
+				if (count($changed) == 0) {
280 280
 					return true;
281 281
 				}
282 282
 				// Fall through
283 283
 			case 'insert' :
284
-				if($_action == 'insert') {
284
+				if ($_action == 'insert') {
285 285
 					// Backend doesn't like inserting with ID specified, can overwrite existing
286 286
 					unset($_data['id']);
287 287
 				}
288 288
 				// Make sure participants are set
289
-				if(!$_data['participants']) {
289
+				if (!$_data['participants']) {
290 290
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
291 291
 					$_data['participants'] = array(
292 292
 						$user => 'U'
293 293
 					);
294 294
 				}
295
-				if ( $this->dry_run ) {
295
+				if ($this->dry_run) {
296 296
 					//print_r($_data);
297 297
 					$this->results[$_action]++;
298 298
 					return true;
299 299
 				} else {
300
-					$result = $this->bo->save( $_data, $this->is_admin);
301
-					if(!$result) {
300
+					$result = $this->bo->save($_data, $this->is_admin);
301
+					if (!$result) {
302 302
 						$this->errors[$record_num] = lang('Unable to save');
303 303
 					} else {
304 304
 						$this->results[$_action]++;
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @param egw_record $row_entry
347 347
 	 */
348
-	protected function row_preview(importexport_iface_egw_record &$row_entry)
348
+	protected function row_preview(importexport_iface_egw_record&$row_entry)
349 349
 	{
350
-		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true));
350
+		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true));
351 351
 	}
352 352
 
353 353
 }
354 354
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +80 added lines, -34 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
 							}
@@ -158,7 +171,8 @@  discard block
 block discarded – undo
158 171
 						}
159 172
 					}
160 173
 				}
161
-				if($id) {
174
+				if($id)
175
+				{
162 176
 					$p_participants[$id] = calendar_so::combine_status(
163 177
 						$this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0],
164 178
 						$quantity[$key] ? $quantity[$key] : 1,
@@ -187,27 +201,38 @@  discard block
 block discarded – undo
187 201
 		}
188 202
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
189 203
 
190
-		if ( $options['conditions'] ) {
191
-			foreach ( $options['conditions'] as $condition ) {
204
+		if ( $options['conditions'] )
205
+		{
206
+			foreach ( $options['conditions'] as $condition )
207
+			{
192 208
 				$records = array();
193
-				switch ( $condition['type'] ) {
209
+				switch ( $condition['type'] )
210
+				{
194 211
 					// exists
195 212
 					case 'exists' :
196 213
 						// Check for that record
197 214
 						$result = $this->exists($record, $condition, $records);
198 215
 
199
-						if ( is_array( $records ) && count( $records ) >= 1) {
216
+						if ( is_array( $records ) && count( $records ) >= 1)
217
+						{
200 218
 							// apply action to all records matching this exists condition
201 219
 							$action = $condition['true'];
202
-							foreach ( (array)$records as $event ) {
220
+							foreach ( (array)$records as $event )
221
+							{
203 222
 								$record->id = $event['id'];
204
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
205
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
223
+								if ( $this->definition->plugin_options['update_cats'] == 'add' )
224
+								{
225
+									if ( !is_array( $record->category ) )
226
+									{
227
+										$record->category = explode( ',', $record->category );
228
+									}
206 229
 									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
207 230
 								}
208 231
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
209 232
 							}
210
-						} else {
233
+						}
234
+						else
235
+						{
211 236
 							$action = $condition['false'];
212 237
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
213 238
 						}
@@ -218,9 +243,14 @@  discard block
 block discarded – undo
218 243
 						die('condition / action not supported!!!');
219 244
 						break;
220 245
 				}
221
-				if ($action['last']) break;
246
+				if ($action['last'])
247
+				{
248
+					break;
249
+				}
222 250
 			}
223
-		} else {
251
+		}
252
+		else
253
+		{
224 254
 			// unconditional insert
225 255
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
226 256
 		}
@@ -239,12 +269,14 @@  discard block
 block discarded – undo
239 269
 	 */
240 270
 	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
241 271
 	{
242
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
272
+		if($record->__get($condition['string']) && $condition['string'] == 'id')
273
+		{
243 274
 			$event = $this->bo->read($record->__get($condition['string']));
244 275
 			$records = array($event);
245 276
 		}
246 277
 
247
-		if ( is_array( $records ) && count( $records ) >= 1) {
278
+		if ( is_array( $records ) && count( $records ) >= 1)
279
+		{
248 280
 			return true;
249 281
 		}
250 282
 		return false;
@@ -260,7 +292,8 @@  discard block
 block discarded – undo
260 292
 	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
261 293
 	{
262 294
 		$_data = $record->get_record_array();
263
-		switch ($_action) {
295
+		switch ($_action)
296
+		{
264 297
 			case 'none' :
265 298
 				return true;
266 299
 			case 'update' :
@@ -268,7 +301,8 @@  discard block
 block discarded – undo
268 301
 				$old = $this->bo->read($_data['id']);
269 302
 
270 303
 				// Don't change a user account into a record
271
-				if(!$this->definition->plugin_options['change_owner']) {
304
+				if(!$this->definition->plugin_options['change_owner'])
305
+				{
272 306
 					// Don't change owner of an existing record
273 307
 					unset($_data['owner']);
274 308
 				}
@@ -276,31 +310,40 @@  discard block
 block discarded – undo
276 310
 				// Merge to deal with fields not in import record
277 311
 				$_data = array_merge($old, $_data);
278 312
 				$changed = $this->tracking->changed_fields($_data, $old);
279
-				if(count($changed) == 0) {
313
+				if(count($changed) == 0)
314
+				{
280 315
 					return true;
281 316
 				}
282 317
 				// Fall through
283 318
 			case 'insert' :
284
-				if($_action == 'insert') {
319
+				if($_action == 'insert')
320
+				{
285 321
 					// Backend doesn't like inserting with ID specified, can overwrite existing
286 322
 					unset($_data['id']);
287 323
 				}
288 324
 				// Make sure participants are set
289
-				if(!$_data['participants']) {
325
+				if(!$_data['participants'])
326
+				{
290 327
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
291 328
 					$_data['participants'] = array(
292 329
 						$user => 'U'
293 330
 					);
294 331
 				}
295
-				if ( $this->dry_run ) {
332
+				if ( $this->dry_run )
333
+				{
296 334
 					//print_r($_data);
297 335
 					$this->results[$_action]++;
298 336
 					return true;
299
-				} else {
337
+				}
338
+				else
339
+				{
300 340
 					$result = $this->bo->save( $_data, $this->is_admin);
301
-					if(!$result) {
341
+					if(!$result)
342
+					{
302 343
 						$this->errors[$record_num] = lang('Unable to save');
303
-					} else {
344
+					}
345
+					else
346
+					{
304 347
 						$this->results[$_action]++;
305 348
 						// This does nothing (yet?) but update the identifier
306 349
 						$record->save($result);
@@ -318,7 +361,8 @@  discard block
 block discarded – undo
318 361
 	 *
319 362
 	 * @return string name
320 363
 	 */
321
-	public static function get_name() {
364
+	public static function get_name()
365
+	{
322 366
 		return lang('Calendar CSV import');
323 367
 	}
324 368
 
@@ -327,7 +371,8 @@  discard block
 block discarded – undo
327 371
 	 *
328 372
 	 * @return string descriprion
329 373
 	 */
330
-	public static function get_description() {
374
+	public static function get_description()
375
+	{
331 376
 		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.");
332 377
 	}
333 378
 
@@ -336,7 +381,8 @@  discard block
 block discarded – undo
336 381
 	 *
337 382
 	 * @return string suffix (comma seperated)
338 383
 	 */
339
-	public static function get_filesuffix() {
384
+	public static function get_filesuffix()
385
+	{
340 386
 		return 'csv';
341 387
 	}
342 388
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		$this->role_map = array_flip($this->bo->roles);
58 58
 
59 59
 		$this->lookups = array(
60
-			'priority'	=> Array(
60
+			'priority'	=> array(
61 61
 				0 => lang('None'),
62 62
 				1 => lang('Low'),
63 63
 				2 => lang('Normal'),
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return boolean
239 239
 	 */
240
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
240
+	protected function exists(importexport_iface_egw_record &$record, array &$condition, &$records = array())
241 241
 	{
242 242
 		if($record->__get($condition['string']) && $condition['string'] == 'id') {
243 243
 			$event = $this->bo->read($record->__get($condition['string']));
Please login to merge, or discard this patch.
calendar/inc/class.calendar_merge.inc.php 4 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -113,8 +113,6 @@  discard block
 block discarded – undo
113 113
 	 * @param array $ids array with contact id(s)
114 114
 	 * @param string &$err error-message on error
115 115
 	 * @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf
116
-	 * @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders
117
-	 * @param string $charset=null charset to override default set by mimetype or export charset
118 116
 	 * @return string|boolean merged document or false on error
119 117
 	 */
120 118
 	function merge_string($content,$ids,$err,$mimetype,$fix)
@@ -234,7 +232,6 @@  discard block
 block discarded – undo
234 232
 	 * Return replacements for the calendar
235 233
 	 *
236 234
 	 * @param int|array $id event-id or array with id/recur_date, or array with event info
237
-	 * @param boolean $last_event_too=false also include information about the last event
238 235
 	 * @return array
239 236
 	 */
240 237
 	public function calendar_replacements($id,$prefix = '', &$content = '')
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -326,20 +326,20 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 
328 328
 	/**
329
-	* Table plugin for event
330
-	* Lists events for a certain day of the week.  Only works for one week at a time, so for multiple weeks,
331
-	* use multiple date ranges.
332
-	*
333
-	* Use:
334
-	* $$table/Monday$$ $$starttime$$ $$title$$ $$endtable$$
335
-	* The day of the week may be language specific (date('l')).
336
-	*
337
-	* @param string $plugin (Monday-Sunday)
338
-	* @param int/array date or date range
339
-	* @param int $n Row number
340
-	* @param string $repeat Text being repeated for each entry
341
-	* @return array
342
-	*/
329
+	 * Table plugin for event
330
+	 * Lists events for a certain day of the week.  Only works for one week at a time, so for multiple weeks,
331
+	 * use multiple date ranges.
332
+	 *
333
+	 * Use:
334
+	 * $$table/Monday$$ $$starttime$$ $$title$$ $$endtable$$
335
+	 * The day of the week may be language specific (date('l')).
336
+	 *
337
+	 * @param string $plugin (Monday-Sunday)
338
+	 * @param int/array date or date range
339
+	 * @param int $n Row number
340
+	 * @param string $repeat Text being repeated for each entry
341
+	 * @return array
342
+	 */
343 343
 	public function day_plugin($plugin,$date,$n,$repeat)
344 344
 	{
345 345
 		static $days = null;
@@ -414,16 +414,16 @@  discard block
 block discarded – undo
414 414
 	}
415 415
 
416 416
 	/**
417
-	* Table plugin for a certain date
418
-	*
419
-	* Can be either a particular date (2011-02-15) or a day of the month (15)
420
-	*
421
-	* @param string $plugin
422
-	* @param int $id ID for this record
423
-	* @param int $n Repeated row number
424
-	* @param string $repeat Text being repeated for each entry
425
-	* @return array
426
-	*/
417
+	 * Table plugin for a certain date
418
+	 *
419
+	 * Can be either a particular date (2011-02-15) or a day of the month (15)
420
+	 *
421
+	 * @param string $plugin
422
+	 * @param int $id ID for this record
423
+	 * @param int $n Repeated row number
424
+	 * @param string $repeat Text being repeated for each entry
425
+	 * @return array
426
+	 */
427 427
 	public function day($plugin,$id,$n,$repeat)
428 428
 	{
429 429
 		static $days = null;
@@ -515,15 +515,15 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	/**
518
-	* Table plugin for participants
519
-	*
520
-	* Copied from eventmgr resources
521
-	*
522
-	* @param string $plugin
523
-	* @param int $id
524
-	* @param int $n
525
-	* @return array
526
-	*/
518
+	 * Table plugin for participants
519
+	 *
520
+	 * Copied from eventmgr resources
521
+	 *
522
+	 * @param string $plugin
523
+	 * @param int $id
524
+	 * @param int $n
525
+	 * @return array
526
+	 */
527 527
 	public function participant($plugin,$id,$n)
528 528
 	{
529 529
 		unset($plugin);	// not used, but required by function signature
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 				{
583 583
 					foreach($resource as $name => $value)
584 584
 					{
585
-					    $replacements['$$'.$name.'$$'] = $value;
585
+						$replacements['$$'.$name.'$$'] = $value;
586 586
 					}
587 587
 				}
588 588
 				break;
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 
85 85
 		// Register table plugins
86 86
 		$this->table_plugins['participant'] = 'participant';
87
-		for($i = 0; $i < 7; $i++)
87
+		for ($i = 0; $i < 7; $i++)
88 88
 		{
89 89
 			$this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin';
90 90
 		}
91
-		for($i = 1; $i <= 31; $i++) {
91
+		for ($i = 1; $i <= 31; $i++) {
92 92
 			$this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31)
93 93
 		}
94
-		foreach(self::$relative as $day) {
94
+		foreach (self::$relative as $day) {
95 95
 			$this->table_plugins[$day] = 'day'; // Current day
96 96
 		}
97 97
 		$this->query = is_array($this->bo->cal_prefs['saved_states']) ?
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 * @param string $charset=null charset to override default set by mimetype or export charset
118 118
 	 * @return string|boolean merged document or false on error
119 119
 	 */
120
-	function merge_string($content,$ids,$err,$mimetype,$fix)
120
+	function merge_string($content, $ids, $err, $mimetype, $fix)
121 121
 	{
122 122
 		//error_log(__METHOD__ . ' IDs: ' . array2string($ids));
123 123
 		// Handle merging a list of events into a document with range instead of pagerepeat
124
-		if((strpos($content, '$$range') !== false || strpos($content, '{{range') !== false) && is_array($ids))
124
+		if ((strpos($content, '$$range') !== false || strpos($content, '{{range') !== false) && is_array($ids))
125 125
 		{
126 126
 			//error_log(__METHOD__ . ' Got list of events(?), no pagerepeat tag');
127 127
 			// Merging more than one something will fail without pagerepeat
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 				$events = $ids;
132 132
 				$ids = array('start' => PHP_INT_MAX, 'end' => 0);
133 133
 				$this->ids = array();
134
-				foreach($events as $event) {
135
-					if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'],'ts');
136
-					if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'],'ts');
134
+				foreach ($events as $event) {
135
+					if ($event['start'] && Api\DateTime::to($event['start'], 'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'], 'ts');
136
+					if ($event['end'] && Api\DateTime::to($event['end'], 'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'], 'ts');
137 137
 					// Keep ids for future use
138 138
 					$this->ids[] = $event['id'];
139 139
 				}
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 				'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
155 155
 			));
156 156
 			$ids = array();
157
-			foreach($events as $event) {
157
+			foreach ($events as $event) {
158 158
 				$ids[] = $event;
159 159
 			}
160 160
 		}
161 161
 
162
-		return parent::merge_string($content, $ids, $err, $mimetype,$fix);
162
+		return parent::merge_string($content, $ids, $err, $mimetype, $fix);
163 163
 	}
164 164
 
165 165
 	/**
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
 	 * @param string &$content=null content to create some replacements only if they are used
170 170
 	 * @return array|boolean
171 171
 	 */
172
-	protected function get_replacements($id,&$content=null)
172
+	protected function get_replacements($id, &$content = null)
173 173
 	{
174 174
 		$prefix = '';
175 175
 		// List events ?
176
-		if(is_array($id) && !$id['id'] && !$id[0]['id'])
176
+		if (is_array($id) && !$id['id'] && !$id[0]['id'])
177 177
 		{
178 178
 			$events = $this->bo->search($this->query + $id + array(
179 179
 				'offset' => 0,
180 180
 				'order' => 'cal_start',
181 181
 				'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
182 182
 			));
183
-			if(strpos($content,'$$calendar/') !== false || strpos($content, '$$table/day') !== false)
183
+			if (strpos($content, '$$calendar/') !== false || strpos($content, '$$table/day') !== false)
184 184
 			{
185
-				array_unshift($events,false); unset($events[0]);	// renumber the array to start with key 1, instead of 0
185
+				array_unshift($events, false); unset($events[0]); // renumber the array to start with key 1, instead of 0
186 186
 				$prefix = 'calendar/%d';
187 187
 			}
188 188
 		}
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 			$events = $id;
193 193
 			$id = array('start' => PHP_INT_MAX, 'end' => 0);
194 194
 			$this->ids = array();
195
-			foreach($events as $event) {
196
-				if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
197
-				if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
195
+			foreach ($events as $event) {
196
+				if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
197
+				if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
198 198
 				// Keep ids for future use
199
-				$this->ids[]  = $event['id'];
199
+				$this->ids[] = $event['id'];
200 200
 			}
201 201
 			$id = array($id);
202 202
 		}
@@ -208,20 +208,20 @@  discard block
 block discarded – undo
208 208
 		// as this function allows to pass query- parameters, we need to check the result of the query against export_limit restrictions
209 209
 		if (Api\Storage\Merge::hasExportLimit($this->export_limit) && !Api\Storage\Merge::is_export_limit_excepted() && count($events) > (int)$this->export_limit)
210 210
 		{
211
-			$err = lang('No rights to export more than %1 entries!',(int)$this->export_limit);
211
+			$err = lang('No rights to export more than %1 entries!', (int)$this->export_limit);
212 212
 			throw new Api\Exception\WrongUserinput($err);
213 213
 		}
214 214
 		$replacements = array();
215 215
 		$n = 0;
216
-		foreach($events as $event)
216
+		foreach ($events as $event)
217 217
 		{
218
-			$values = $this->calendar_replacements($event,sprintf($prefix,++$n), $content);
219
-			if(is_array($id) && $id['start'])
218
+			$values = $this->calendar_replacements($event, sprintf($prefix, ++$n), $content);
219
+			if (is_array($id) && $id['start'])
220 220
 			{
221
-				foreach(self::$range_tags as $key => $format)
221
+				foreach (self::$range_tags as $key => $format)
222 222
 				{
223 223
 					$value = date($format, $key == 'end' ? $id['end'] : $id['start']);
224
-					if($key == 'month') $value = lang($value);
224
+					if ($key == 'month') $value = lang($value);
225 225
 					$values["$\$range/$key$$"] = $value;
226 226
 				}
227 227
 			}
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 	 * @param boolean $last_event_too=false also include information about the last event
238 238
 	 * @return array
239 239
 	 */
240
-	public function calendar_replacements($id,$prefix = '', &$content = '')
240
+	public function calendar_replacements($id, $prefix = '', &$content = '')
241 241
 	{
242 242
 		$replacements = array();
243
-		if(!is_array($id) || !$id['start']) {
243
+		if (!is_array($id) || !$id['start']) {
244 244
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
245 245
 		} else {
246 246
 			$event = $id;
@@ -253,68 +253,68 @@  discard block
 block discarded – undo
253 253
 		importexport_export_csv::convert($record, $types, 'calendar');
254 254
 
255 255
 		$array = $record->get_record_array();
256
-		foreach($array as $key => $value)
256
+		foreach ($array as $key => $value)
257 257
 		{
258
-			$replacements['$$'.($prefix?$prefix.'/':'').$key.'$$'] = $value;
258
+			$replacements['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value;
259 259
 		}
260 260
 
261
-		$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id'];
262
-		foreach($this->bo->event2array($event) as $name => $data)
261
+		$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_id'.'$$'] = $event['id'];
262
+		foreach ($this->bo->event2array($event) as $name => $data)
263 263
 		{
264
-			if (substr($name,-4) == 'date') $name = substr($name,0,-4);
265
-			$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data'];
264
+			if (substr($name, -4) == 'date') $name = substr($name, 0, -4);
265
+			$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data'];
266 266
 		}
267 267
 		// Add seperate lists of participants by type
268
-		if(strpos($content, 'calendar_participants/')!== false)
268
+		if (strpos($content, 'calendar_participants/') !== false)
269 269
 		{
270 270
 			$types = array();
271
-			foreach($this->bo->resources as $resource)
271
+			foreach ($this->bo->resources as $resource)
272 272
 			{
273 273
 				$types[$resource['app']] = array();
274 274
 			}
275
-			foreach($event['participants'] as $uid => $status)
275
+			foreach ($event['participants'] as $uid => $status)
276 276
 			{
277 277
 				$type = $this->bo->resources[$uid[0]]['app'];
278
-				if($type == 'api-accounts')
278
+				if ($type == 'api-accounts')
279 279
 				{
280 280
 					$type = ($GLOBALS['egw']->accounts->get_type($uid) == 'g' ? 'group' : 'account');
281 281
 				}
282 282
 				$types[$type][] = $this->bo->participant_name($uid);
283 283
 			}
284
-			foreach($types as $t_id => $type)
284
+			foreach ($types as $t_id => $type)
285 285
 			{
286
-				$replacements['$$'.($prefix ? $prefix . '/' : '') . "calendar_participants/{$t_id}$$"] = implode(', ',$type);
286
+				$replacements['$$'.($prefix ? $prefix.'/' : '')."calendar_participants/{$t_id}$$"] = implode(', ', $type);
287 287
 			}
288 288
 		}
289
-		if(!$replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$'])
289
+		if (!$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$'])
290 290
 		{
291 291
 			// Need to set it to '' if not set or previous record may be used
292
-			$replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$'] = '';
292
+			$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$'] = '';
293 293
 		}
294
-		foreach(array('start','end') as $what)
294
+		foreach (array('start', 'end') as $what)
295 295
 		{
296
-			foreach(array(
296
+			foreach (array(
297 297
 				'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],
298 298
 				'day'  => 'l',
299
-				'time' => (date('Ymd',$event['start']) != date('Ymd',$event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '') . ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'),
299
+				'time' => (date('Ymd', $event['start']) != date('Ymd', $event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '').($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'),
300 300
 			) as $name => $format)
301 301
 			{
302
-				$value = Api\DateTime::to($event[$what],$format);
302
+				$value = Api\DateTime::to($event[$what], $format);
303 303
 				if ($format == 'l') $value = lang($value);
304
-				$replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value;
304
+				$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$what.$name.'$$'] = $value;
305 305
 			}
306 306
 		}
307
-		$duration = ($event['end'] - $event['start'])/60;
308
-		$replacements['$$'.($prefix?$prefix.'/':'').'calendar_duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
307
+		$duration = ($event['end'] - $event['start']) / 60;
308
+		$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
309 309
 
310 310
 		// Add in contact stuff for owner
311
-		if (strpos($content,'$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'],'person_id')))
311
+		if (strpos($content, '$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'], 'person_id')))
312 312
 		{
313
-			$replacements += $this->contact_replacements($user,($prefix ? $prefix.'/':'').'calendar_owner');
314
-			$replacements['$$'.($prefix?$prefix.'/':'').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'],'account_primary_group'));
313
+			$replacements += $this->contact_replacements($user, ($prefix ? $prefix.'/' : '').'calendar_owner');
314
+			$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_primary_group'));
315 315
 		}
316 316
 
317
-		if($content && strpos($content, '$$#') !== FALSE)
317
+		if ($content && strpos($content, '$$#') !== FALSE)
318 318
 		{
319 319
 			$this->cf_link_to_expand($event, $content, $replacements);
320 320
 		}
@@ -340,77 +340,77 @@  discard block
 block discarded – undo
340 340
 	* @param string $repeat Text being repeated for each entry
341 341
 	* @return array
342 342
 	*/
343
-	public function day_plugin($plugin,$date,$n,$repeat)
343
+	public function day_plugin($plugin, $date, $n, $repeat)
344 344
 	{
345 345
 		static $days = null;
346
-		if(is_array($date) && !$date['start']) {
346
+		if (is_array($date) && !$date['start']) {
347 347
 			// List of IDs
348
-			if($date[0]['start']) {
348
+			if ($date[0]['start']) {
349 349
 				$id = array('start' => PHP_INT_MAX, 'end' => 0);
350
-				foreach($date as $event) {
351
-					if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
352
-					if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
350
+				foreach ($date as $event) {
351
+					if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
352
+					if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
353 353
 				}
354 354
 				$date = $id;
355 355
 			} else {
356 356
 				$event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null);
357
-				if(date('l',$event['start']) != $plugin) return array();
357
+				if (date('l', $event['start']) != $plugin) return array();
358 358
 				$date = $event['start'];
359 359
 			}
360 360
 		}
361 361
 
362 362
 		$_date = $date['start'] ? $date['start'] : $date;
363
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
363
+		if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n];
364 364
 
365 365
 		$events = $this->bo->search($this->query + array(
366
-			'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)),
367
-			'end' => $date['end'] ? $date['end'] : mktime(23,59,59,date('m',$_date),date('d',$_date),date('Y',$_date)),
366
+			'start' => $date['end'] ? $date['start'] : mktime(0, 0, 0, date('m', $_date), date('d', $_date), date('Y', $_date)),
367
+			'end' => $date['end'] ? $date['end'] : mktime(23, 59, 59, date('m', $_date), date('d', $_date), date('Y', $_date)),
368 368
 			'offset' => 0,
369 369
 			'num_rows' => 20,
370 370
 			'order' => 'cal_start',
371 371
 			'daywise' => true,
372
-			'cfs' => array(),	// read all custom-fields
372
+			'cfs' => array(), // read all custom-fields
373 373
 		));
374 374
 
375 375
 		if (true) $days = array();
376 376
 		$replacements = array();
377 377
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
378
-		foreach($events as $day => $list)
378
+		foreach ($events as $day => $list)
379 379
 		{
380
-			foreach($list as $event)
380
+			foreach ($list as $event)
381 381
 			{
382
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
382
+				if ($this->ids && !in_array($event['id'], $this->ids)) continue;
383 383
 				$start = Api\DateTime::to($event['start'], 'array');
384 384
 				$end = Api\DateTime::to($event['end'], 'array');
385 385
 				$replacements = $this->calendar_replacements($event);
386
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
387
-					$dow = date('l',$event['start']);
386
+				if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
387
+					$dow = date('l', $event['start']);
388 388
 				} else {
389 389
 					$dow = date('l', strtotime($day));
390 390
 					// Fancy date+time formatting for multi-day events
391
-					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
392
-					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0));
391
+					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1));
392
+					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0));
393 393
 				}
394 394
 
395
-				$days[date('Ymd',$_date)][$dow][] = $replacements;
395
+				$days[date('Ymd', $_date)][$dow][] = $replacements;
396 396
 			}
397
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
397
+			if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
398 398
 				$date_marker = array(
399 399
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
400 400
 					'$$day/name$$' => lang(date('l', strtotime($day)))
401 401
 				);
402
-				if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) {
402
+				if (!is_array($days[date('Ymd', $_date)][date('l', strtotime($day))])) {
403 403
 					$blank = $this->calendar_replacements(array());
404
-					foreach($blank as &$value)
404
+					foreach ($blank as &$value)
405 405
 					{
406 406
 						$value = '';
407 407
 					}
408
-					$days[date('Ymd',$_date)][date('l',strtotime($day))][] = $blank;
408
+					$days[date('Ymd', $_date)][date('l', strtotime($day))][] = $blank;
409 409
 				}
410
-				$days[date('Ymd',$_date)][date('l',strtotime($day))][0] += $date_marker;
410
+				$days[date('Ymd', $_date)][date('l', strtotime($day))][0] += $date_marker;
411 411
 			}
412 412
 		}
413
-		return $days[date('Ymd',$_date)][$plugin][0];
413
+		return $days[date('Ymd', $_date)][$plugin][0];
414 414
 	}
415 415
 
416 416
 	/**
@@ -424,27 +424,27 @@  discard block
 block discarded – undo
424 424
 	* @param string $repeat Text being repeated for each entry
425 425
 	* @return array
426 426
 	*/
427
-	public function day($plugin,$id,$n,$repeat)
427
+	public function day($plugin, $id, $n, $repeat)
428 428
 	{
429 429
 		static $days = null;
430 430
 
431 431
 		// Figure out which day
432
-		list($type, $which) = explode('_',$plugin);
433
-		if($type == 'day' && $which)
432
+		list($type, $which) = explode('_', $plugin);
433
+		if ($type == 'day' && $which)
434 434
 		{
435
-			if($id[0]['start'])
435
+			if ($id[0]['start'])
436 436
 			{
437 437
 				$dates = array('start' => PHP_INT_MAX, 'end' => 0);
438
-				foreach($id as $event) {
439
-					if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start'];
440
-					if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end'];
438
+				foreach ($id as $event) {
439
+					if ($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start'];
440
+					if ($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end'];
441 441
 				}
442 442
 				$id = $dates;
443 443
 			}
444 444
 			$arr = $this->bo->date2array($id['start']);
445 445
 			$arr['day'] = $which;
446 446
 			$date = $this->bo->date2ts($arr);
447
-			if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array();
447
+			if (is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array();
448 448
 		}
449 449
 		elseif ($plugin == 'selected')
450 450
 		{
@@ -454,64 +454,64 @@  discard block
 block discarded – undo
454 454
 		{
455 455
 			$date = strtotime($plugin);
456 456
 		}
457
-		if($type == 'day' && is_array($id) && !$id['start']) {
457
+		if ($type == 'day' && is_array($id) && !$id['start']) {
458 458
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
459
-			if($which && date('d',$event['start']) != $which) return array();
460
-			if(date('Ymd',$date) != date('Ymd', $event['start'])) return array();
459
+			if ($which && date('d', $event['start']) != $which) return array();
460
+			if (date('Ymd', $date) != date('Ymd', $event['start'])) return array();
461 461
 			return $n == 0 ? $this->calendar_replacements($event) : array();
462 462
 		}
463 463
 
464 464
 		// Use start for cache, in case of multiple months
465 465
 		$_date = $id['start'] ? $id['start'] : $date;
466
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
466
+		if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n];
467 467
 
468 468
 		$events = $this->bo->search($this->query + array(
469 469
 			'start' => $date,
470
-			'end' => mktime(23,59,59,date('m',$date),date('d',$date),date('Y',$date)),
470
+			'end' => mktime(23, 59, 59, date('m', $date), date('d', $date), date('Y', $date)),
471 471
 			'offset' => 0,
472 472
 			'num_rows' => 20,
473 473
 			'order' => 'cal_start',
474 474
 			'daywise' => true,
475
-			'cfs' => array(),	// read all custom-fields
475
+			'cfs' => array(), // read all custom-fields
476 476
 		));
477 477
 
478 478
 		$replacements = array();
479 479
 		if (true) $days = array();
480 480
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
481
-		foreach($events as $day => $list)
481
+		foreach ($events as $day => $list)
482 482
 		{
483
-			foreach($list as $event)
483
+			foreach ($list as $event)
484 484
 			{
485
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
485
+				if ($this->ids && !in_array($event['id'], $this->ids)) continue;
486 486
 				$start = Api\DateTime::to($event['start'], 'array');
487 487
 				$end = Api\DateTime::to($event['end'], 'array');
488 488
 				$replacements = $this->calendar_replacements($event);
489
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
489
+				if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
490 490
 					//$dow = date('l',$event['start']);
491 491
 				} else {
492 492
 					// Fancy date+time formatting for multi-day events
493
-					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
494
-					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0));
493
+					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1));
494
+					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0));
495 495
 				}
496
-				$days[date('Ymd',$_date)][$plugin][] = $replacements;
496
+				$days[date('Ymd', $_date)][$plugin][] = $replacements;
497 497
 			}
498
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
498
+			if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
499 499
 				$date_marker = array(
500 500
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
501 501
 					'$$day/name$$' => lang(date('l', strtotime($day)))
502 502
 				);
503
-				if(!is_array($days[date('Ymd',$_date)][$plugin])) {
503
+				if (!is_array($days[date('Ymd', $_date)][$plugin])) {
504 504
 					$blank = $this->calendar_replacements(array());
505
-					foreach($blank as &$value)
505
+					foreach ($blank as &$value)
506 506
 					{
507 507
 						$value = '';
508 508
 					}
509
-					$days[date('Ymd',$_date)][$plugin][] = $blank;
509
+					$days[date('Ymd', $_date)][$plugin][] = $blank;
510 510
 				}
511
-				$days[date('Ymd',$_date)][$plugin][0] += $date_marker;
511
+				$days[date('Ymd', $_date)][$plugin][0] += $date_marker;
512 512
 			}
513 513
 		}
514
-		return $days[date('Ymd',$_date)][$plugin][0];
514
+		return $days[date('Ymd', $_date)][$plugin][0];
515 515
 	}
516 516
 
517 517
 	/**
@@ -524,30 +524,30 @@  discard block
 block discarded – undo
524 524
 	* @param int $n
525 525
 	* @return array
526 526
 	*/
527
-	public function participant($plugin,$id,$n)
527
+	public function participant($plugin, $id, $n)
528 528
 	{
529
-		unset($plugin);	// not used, but required by function signature
529
+		unset($plugin); // not used, but required by function signature
530 530
 
531
-		if(!is_array($id) || !$id['start']) {
531
+		if (!is_array($id) || !$id['start']) {
532 532
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
533 533
 		} else {
534 534
 			$event = $id;
535 535
 		}
536 536
 
537
-		if(!is_array($event['participants']) || $n >= count($event['participants'])) return array();
537
+		if (!is_array($event['participants']) || $n >= count($event['participants'])) return array();
538 538
 
539 539
 		$participant = null;
540 540
 		$status = null;
541 541
 		$i = -1;
542
-		foreach($event['participants'] as $participant => $status) {
543
-			if(++$i == $n) break;
542
+		foreach ($event['participants'] as $participant => $status) {
543
+			if (++$i == $n) break;
544 544
 		}
545 545
 
546
-		if(!$participant) return array();
546
+		if (!$participant) return array();
547 547
 
548 548
 		// Add some common information
549 549
 		$quantity = $role = null;
550
-		calendar_so::split_status($status,$quantity,$role);
550
+		calendar_so::split_status($status, $quantity, $role);
551 551
 		if ($role != 'REQ-PARTICIPANT')
552 552
 		{
553 553
 			if (isset($this->bo->roles[$role]))
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
 				$role = lang($this->bo->roles[$role]);
556 556
 			}
557 557
 			// allow to use cats as roles (beside regular iCal ones)
558
-			elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0)
558
+			elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0)
559 559
 			{
560 560
 				$role = $GLOBALS['egw']->categories->id2name($cat_id);
561 561
 			}
562 562
 			else
563 563
 			{
564
-				$role = lang(str_replace('X-','',$role));
564
+				$role = lang(str_replace('X-', '', $role));
565 565
 			}
566 566
 		}
567 567
 		$info = array(
@@ -574,26 +574,26 @@  discard block
 block discarded – undo
574 574
 		switch ($participant[0])
575 575
 		{
576 576
 			case 'c':
577
-				$replacements = $this->contact_replacements(substr($participant,1),'');
577
+				$replacements = $this->contact_replacements(substr($participant, 1), '');
578 578
 				break;
579 579
 			case 'r':
580 580
 				if (is_null(self::$resources)) self::$resources = CreateObject('resources.resources_bo');
581
-				if (($resource = self::$resources->read(substr($participant,1))))
581
+				if (($resource = self::$resources->read(substr($participant, 1))))
582 582
 				{
583
-					foreach($resource as $name => $value)
583
+					foreach ($resource as $name => $value)
584 584
 					{
585 585
 					    $replacements['$$'.$name.'$$'] = $value;
586 586
 					}
587 587
 				}
588 588
 				break;
589 589
 			default:
590
-				if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant,'person_id')))
590
+				if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant, 'person_id')))
591 591
 				{
592
-					$replacements = $this->contact_replacements($contact,'');
592
+					$replacements = $this->contact_replacements($contact, '');
593 593
 				}
594 594
 				break;
595 595
 		}
596
-		foreach($info as $name => $value)
596
+		foreach ($info as $name => $value)
597 597
 		{
598 598
 			$replacements['$$'.$name.'$$'] = $value;
599 599
 		}
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 		echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')."</h3></td></tr>";
616 616
 
617 617
 		$n = 0;
618
-		foreach(array(
618
+		foreach (array(
619 619
 			'calendar_id' => lang('Calendar ID'),
620 620
 			'calendar_title' => lang('Title'),
621 621
 			'calendar_description' => lang('Description'),
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 			'calendar_owner'    => lang('Owner'),
639 639
 		) as $name => $label)
640 640
 		{
641
-			if (in_array($name,array('start','end')) && $n&1)		// main values, which should be in the first column
641
+			if (in_array($name, array('start', 'end')) && $n&1)		// main values, which should be in the first column
642 642
 			{
643 643
 				echo "</tr>\n";
644 644
 				$n++;
@@ -651,13 +651,13 @@  discard block
 block discarded – undo
651 651
 
652 652
 		echo '<tr><td colspan="4"><h3>'.lang('Range fields').":</h3></td></tr>";
653 653
 		echo '<tr><td colspan="4">'.lang('If you select a range (month, week, etc) instead of a list of entries, these extra fields are available').'</td></tr>';
654
-		foreach(array_keys(self::$range_tags) as $name)
654
+		foreach (array_keys(self::$range_tags) as $name)
655 655
 		{
656 656
 			echo '<tr><td>{{range/'.$name.'}}</td><td>'.lang($name)."</td></tr>\n";
657 657
 		}
658 658
 		echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>";
659 659
 		$custom = Api\Storage\Customfields::get('calendar');
660
-		foreach($custom as $name => $field)
660
+		foreach ($custom as $name => $field)
661 661
 		{
662 662
 			echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n";
663 663
 		}
@@ -666,9 +666,9 @@  discard block
 block discarded – undo
666 666
 		echo '<tr><td colspan="4"><h3>'.lang('Participants').":</h3></td></tr>";
667 667
 		echo '<tr><td>{{calendar_participants/account}}</td><td colspan="3">'.lang('Accounts')."</td></tr>\n";
668 668
 		echo '<tr><td>{{calendar_participants/group}}</td><td colspan="3">'.lang('Groups')."</td></tr>\n";
669
-		foreach($this->bo->resources as $resource)
669
+		foreach ($this->bo->resources as $resource)
670 670
 		{
671
-			if($resource['type'])
671
+			if ($resource['type'])
672 672
 			{
673 673
 				echo '<tr><td>{{calendar_participants/'.$resource['app'].'}}</td><td colspan="3">'.lang($resource['app'])."</td></tr>\n";
674 674
 			}
@@ -685,19 +685,19 @@  discard block
 block discarded – undo
685 685
 		echo '<tr style="vertical-align:top"><td colspan="2"><table >';
686 686
 		echo '<tr><td><h3>'.lang('Day of week tables').":</h3></td></tr>";
687 687
 		$days = array();
688
-		for($i = 0; $i < 7; $i++)
688
+		for ($i = 0; $i < 7; $i++)
689 689
 		{
690
-			$days[date('N',strtotime("+$i days"))] = date('l',strtotime("+$i days"));
690
+			$days[date('N', strtotime("+$i days"))] = date('l', strtotime("+$i days"));
691 691
 		}
692 692
 		ksort($days);
693
-		foreach($days as $day)
693
+		foreach ($days as $day)
694 694
 		{
695
-			echo '<tr><td>{{table/'.$day. '}} ... {{endtable}}</td></tr>';
695
+			echo '<tr><td>{{table/'.$day.'}} ... {{endtable}}</td></tr>';
696 696
 		}
697 697
 		echo '</table></td><td colspan="2"><table >';
698 698
 		echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>";
699
-		foreach(self::$relative as $value) {
700
-			echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>';
699
+		foreach (self::$relative as $value) {
700
+			echo '<tr><td>{{table/'.$value.'}} ... {{endtable}}</td></tr>';
701 701
 		}
702 702
 		echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>';
703 703
 		echo '</table></td></tr>';
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 		echo '<tr><td>{{day/name}}</td><td colspan="3">'.lang('Name of the week (ex: Monday), available for the first entry inside each day of week or daily table inside the selected range.').'</td></tr>';
706 706
 
707 707
 		echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
708
-		foreach(array(
708
+		foreach (array(
709 709
 			'link' => lang('HTML link to the current record'),
710 710
 			'links' => lang('Titles of any entries linked to the current record, excluding attached files'),
711 711
 			'attachments' => lang('List of files linked to the current record'),
Please login to merge, or discard this patch.
Braces   +167 added lines, -53 removed lines patch added patch discarded remove patch
@@ -88,10 +88,12 @@  discard block
 block discarded – undo
88 88
 		{
89 89
 			$this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin';
90 90
 		}
91
-		for($i = 1; $i <= 31; $i++) {
91
+		for($i = 1; $i <= 31; $i++)
92
+		{
92 93
 			$this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31)
93 94
 		}
94
-		foreach(self::$relative as $day) {
95
+		foreach(self::$relative as $day)
96
+		{
95 97
 			$this->table_plugins[$day] = 'day'; // Current day
96 98
 		}
97 99
 		$this->query = is_array($this->bo->cal_prefs['saved_states']) ?
@@ -131,9 +133,16 @@  discard block
 block discarded – undo
131 133
 				$events = $ids;
132 134
 				$ids = array('start' => PHP_INT_MAX, 'end' => 0);
133 135
 				$this->ids = array();
134
-				foreach($events as $event) {
135
-					if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'],'ts');
136
-					if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'],'ts');
136
+				foreach($events as $event)
137
+				{
138
+					if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start'])
139
+					{
140
+						$ids['start'] = Api\DateTime::to($event['start'],'ts');
141
+					}
142
+					if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end'])
143
+					{
144
+						$ids['end'] = Api\DateTime::to($event['end'],'ts');
145
+					}
137 146
 					// Keep ids for future use
138 147
 					$this->ids[] = $event['id'];
139 148
 				}
@@ -154,7 +163,8 @@  discard block
 block discarded – undo
154 163
 				'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
155 164
 			));
156 165
 			$ids = array();
157
-			foreach($events as $event) {
166
+			foreach($events as $event)
167
+			{
158 168
 				$ids[] = $event;
159 169
 			}
160 170
 		}
@@ -192,9 +202,16 @@  discard block
 block discarded – undo
192 202
 			$events = $id;
193 203
 			$id = array('start' => PHP_INT_MAX, 'end' => 0);
194 204
 			$this->ids = array();
195
-			foreach($events as $event) {
196
-				if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
197
-				if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
205
+			foreach($events as $event)
206
+			{
207
+				if($event['start'] && $event['start'] < $id['start'])
208
+				{
209
+					$id['start'] = $event['start'];
210
+				}
211
+				if($event['end'] && $event['end'] > $id['end'])
212
+				{
213
+					$id['end'] = $event['end'];
214
+				}
198 215
 				// Keep ids for future use
199 216
 				$this->ids[]  = $event['id'];
200 217
 			}
@@ -221,7 +238,10 @@  discard block
 block discarded – undo
221 238
 				foreach(self::$range_tags as $key => $format)
222 239
 				{
223 240
 					$value = date($format, $key == 'end' ? $id['end'] : $id['start']);
224
-					if($key == 'month') $value = lang($value);
241
+					if($key == 'month')
242
+					{
243
+						$value = lang($value);
244
+					}
225 245
 					$values["$\$range/$key$$"] = $value;
226 246
 				}
227 247
 			}
@@ -240,9 +260,12 @@  discard block
 block discarded – undo
240 260
 	public function calendar_replacements($id,$prefix = '', &$content = '')
241 261
 	{
242 262
 		$replacements = array();
243
-		if(!is_array($id) || !$id['start']) {
263
+		if(!is_array($id) || !$id['start'])
264
+		{
244 265
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
245
-		} else {
266
+		}
267
+		else
268
+		{
246 269
 			$event = $id;
247 270
 		}
248 271
 
@@ -261,7 +284,10 @@  discard block
 block discarded – undo
261 284
 		$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id'];
262 285
 		foreach($this->bo->event2array($event) as $name => $data)
263 286
 		{
264
-			if (substr($name,-4) == 'date') $name = substr($name,0,-4);
287
+			if (substr($name,-4) == 'date')
288
+			{
289
+				$name = substr($name,0,-4);
290
+			}
265 291
 			$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data'];
266 292
 		}
267 293
 		// Add seperate lists of participants by type
@@ -300,7 +326,10 @@  discard block
 block discarded – undo
300 326
 			) as $name => $format)
301 327
 			{
302 328
 				$value = Api\DateTime::to($event[$what],$format);
303
-				if ($format == 'l') $value = lang($value);
329
+				if ($format == 'l')
330
+				{
331
+					$value = lang($value);
332
+				}
304 333
 				$replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value;
305 334
 			}
306 335
 		}
@@ -343,24 +372,41 @@  discard block
 block discarded – undo
343 372
 	public function day_plugin($plugin,$date,$n,$repeat)
344 373
 	{
345 374
 		static $days = null;
346
-		if(is_array($date) && !$date['start']) {
375
+		if(is_array($date) && !$date['start'])
376
+		{
347 377
 			// List of IDs
348
-			if($date[0]['start']) {
378
+			if($date[0]['start'])
379
+			{
349 380
 				$id = array('start' => PHP_INT_MAX, 'end' => 0);
350
-				foreach($date as $event) {
351
-					if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
352
-					if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
381
+				foreach($date as $event)
382
+				{
383
+					if($event['start'] && $event['start'] < $id['start'])
384
+					{
385
+						$id['start'] = $event['start'];
386
+					}
387
+					if($event['end'] && $event['end'] > $id['end'])
388
+					{
389
+						$id['end'] = $event['end'];
390
+					}
353 391
 				}
354 392
 				$date = $id;
355
-			} else {
393
+			}
394
+			else
395
+			{
356 396
 				$event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null);
357
-				if(date('l',$event['start']) != $plugin) return array();
397
+				if(date('l',$event['start']) != $plugin)
398
+				{
399
+					return array();
400
+				}
358 401
 				$date = $event['start'];
359 402
 			}
360 403
 		}
361 404
 
362 405
 		$_date = $date['start'] ? $date['start'] : $date;
363
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
406
+		if($days[date('Ymd',$_date)][$plugin])
407
+		{
408
+			return $days[date('Ymd',$_date)][$plugin][$n];
409
+		}
364 410
 
365 411
 		$events = $this->bo->search($this->query + array(
366 412
 			'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)),
@@ -372,20 +418,29 @@  discard block
 block discarded – undo
372 418
 			'cfs' => array(),	// read all custom-fields
373 419
 		));
374 420
 
375
-		if (true) $days = array();
421
+		if (true)
422
+		{
423
+			$days = array();
424
+		}
376 425
 		$replacements = array();
377 426
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
378 427
 		foreach($events as $day => $list)
379 428
 		{
380 429
 			foreach($list as $event)
381 430
 			{
382
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
431
+				if($this->ids && !in_array($event['id'], $this->ids))
432
+				{
433
+					continue;
434
+				}
383 435
 				$start = Api\DateTime::to($event['start'], 'array');
384 436
 				$end = Api\DateTime::to($event['end'], 'array');
385 437
 				$replacements = $this->calendar_replacements($event);
386
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
438
+				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day'])
439
+				{
387 440
 					$dow = date('l',$event['start']);
388
-				} else {
441
+				}
442
+				else
443
+				{
389 444
 					$dow = date('l', strtotime($day));
390 445
 					// Fancy date+time formatting for multi-day events
391 446
 					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
@@ -394,12 +449,14 @@  discard block
 block discarded – undo
394 449
 
395 450
 				$days[date('Ymd',$_date)][$dow][] = $replacements;
396 451
 			}
397
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
452
+			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false)
453
+			{
398 454
 				$date_marker = array(
399 455
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
400 456
 					'$$day/name$$' => lang(date('l', strtotime($day)))
401 457
 				);
402
-				if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) {
458
+				if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))]))
459
+				{
403 460
 					$blank = $this->calendar_replacements(array());
404 461
 					foreach($blank as &$value)
405 462
 					{
@@ -435,16 +492,26 @@  discard block
 block discarded – undo
435 492
 			if($id[0]['start'])
436 493
 			{
437 494
 				$dates = array('start' => PHP_INT_MAX, 'end' => 0);
438
-				foreach($id as $event) {
439
-					if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start'];
440
-					if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end'];
495
+				foreach($id as $event)
496
+				{
497
+					if($event['start'] && $event['start'] < $dates['start'])
498
+					{
499
+						$dates['start'] = $event['start'];
500
+					}
501
+					if($event['end'] && $event['end'] > $dates['end'])
502
+					{
503
+						$dates['end'] = $event['end'];
504
+					}
441 505
 				}
442 506
 				$id = $dates;
443 507
 			}
444 508
 			$arr = $this->bo->date2array($id['start']);
445 509
 			$arr['day'] = $which;
446 510
 			$date = $this->bo->date2ts($arr);
447
-			if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array();
511
+			if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end']))
512
+			{
513
+				return array();
514
+			}
448 515
 		}
449 516
 		elseif ($plugin == 'selected')
450 517
 		{
@@ -454,16 +521,26 @@  discard block
 block discarded – undo
454 521
 		{
455 522
 			$date = strtotime($plugin);
456 523
 		}
457
-		if($type == 'day' && is_array($id) && !$id['start']) {
524
+		if($type == 'day' && is_array($id) && !$id['start'])
525
+		{
458 526
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
459
-			if($which && date('d',$event['start']) != $which) return array();
460
-			if(date('Ymd',$date) != date('Ymd', $event['start'])) return array();
527
+			if($which && date('d',$event['start']) != $which)
528
+			{
529
+				return array();
530
+			}
531
+			if(date('Ymd',$date) != date('Ymd', $event['start']))
532
+			{
533
+				return array();
534
+			}
461 535
 			return $n == 0 ? $this->calendar_replacements($event) : array();
462 536
 		}
463 537
 
464 538
 		// Use start for cache, in case of multiple months
465 539
 		$_date = $id['start'] ? $id['start'] : $date;
466
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
540
+		if($days[date('Ymd',$_date)][$plugin])
541
+		{
542
+			return $days[date('Ymd',$_date)][$plugin][$n];
543
+		}
467 544
 
468 545
 		$events = $this->bo->search($this->query + array(
469 546
 			'start' => $date,
@@ -476,31 +553,42 @@  discard block
 block discarded – undo
476 553
 		));
477 554
 
478 555
 		$replacements = array();
479
-		if (true) $days = array();
556
+		if (true)
557
+		{
558
+			$days = array();
559
+		}
480 560
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
481 561
 		foreach($events as $day => $list)
482 562
 		{
483 563
 			foreach($list as $event)
484 564
 			{
485
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
565
+				if($this->ids && !in_array($event['id'], $this->ids))
566
+				{
567
+					continue;
568
+				}
486 569
 				$start = Api\DateTime::to($event['start'], 'array');
487 570
 				$end = Api\DateTime::to($event['end'], 'array');
488 571
 				$replacements = $this->calendar_replacements($event);
489
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
572
+				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day'])
573
+				{
490 574
 					//$dow = date('l',$event['start']);
491
-				} else {
575
+				}
576
+				else
577
+				{
492 578
 					// Fancy date+time formatting for multi-day events
493 579
 					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
494 580
 					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0));
495 581
 				}
496 582
 				$days[date('Ymd',$_date)][$plugin][] = $replacements;
497 583
 			}
498
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
584
+			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false)
585
+			{
499 586
 				$date_marker = array(
500 587
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
501 588
 					'$$day/name$$' => lang(date('l', strtotime($day)))
502 589
 				);
503
-				if(!is_array($days[date('Ymd',$_date)][$plugin])) {
590
+				if(!is_array($days[date('Ymd',$_date)][$plugin]))
591
+				{
504 592
 					$blank = $this->calendar_replacements(array());
505 593
 					foreach($blank as &$value)
506 594
 					{
@@ -528,22 +616,35 @@  discard block
 block discarded – undo
528 616
 	{
529 617
 		unset($plugin);	// not used, but required by function signature
530 618
 
531
-		if(!is_array($id) || !$id['start']) {
619
+		if(!is_array($id) || !$id['start'])
620
+		{
532 621
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
533
-		} else {
622
+		}
623
+		else
624
+		{
534 625
 			$event = $id;
535 626
 		}
536 627
 
537
-		if(!is_array($event['participants']) || $n >= count($event['participants'])) return array();
628
+		if(!is_array($event['participants']) || $n >= count($event['participants']))
629
+		{
630
+			return array();
631
+		}
538 632
 
539 633
 		$participant = null;
540 634
 		$status = null;
541 635
 		$i = -1;
542
-		foreach($event['participants'] as $participant => $status) {
543
-			if(++$i == $n) break;
636
+		foreach($event['participants'] as $participant => $status)
637
+		{
638
+			if(++$i == $n)
639
+			{
640
+				break;
641
+			}
544 642
 		}
545 643
 
546
-		if(!$participant) return array();
644
+		if(!$participant)
645
+		{
646
+			return array();
647
+		}
547 648
 
548 649
 		// Add some common information
549 650
 		$quantity = $role = null;
@@ -577,7 +678,10 @@  discard block
 block discarded – undo
577 678
 				$replacements = $this->contact_replacements(substr($participant,1),'');
578 679
 				break;
579 680
 			case 'r':
580
-				if (is_null(self::$resources)) self::$resources = CreateObject('resources.resources_bo');
681
+				if (is_null(self::$resources))
682
+				{
683
+					self::$resources = CreateObject('resources.resources_bo');
684
+				}
581 685
 				if (($resource = self::$resources->read(substr($participant,1))))
582 686
 				{
583 687
 					foreach($resource as $name => $value)
@@ -638,14 +742,23 @@  discard block
 block discarded – undo
638 742
 			'calendar_owner'    => lang('Owner'),
639 743
 		) as $name => $label)
640 744
 		{
641
-			if (in_array($name,array('start','end')) && $n&1)		// main values, which should be in the first column
745
+			if (in_array($name,array('start','end')) && $n&1)
746
+			{
747
+				// main values, which should be in the first column
642 748
 			{
643 749
 				echo "</tr>\n";
750
+			}
644 751
 				$n++;
645 752
 			}
646
-			if (!($n&1)) echo '<tr>';
753
+			if (!($n&1))
754
+			{
755
+				echo '<tr>';
756
+			}
647 757
 			echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>';
648
-			if ($n&1) echo "</tr>\n";
758
+			if ($n&1)
759
+			{
760
+				echo "</tr>\n";
761
+			}
649 762
 			$n++;
650 763
 		}
651 764
 
@@ -696,7 +809,8 @@  discard block
 block discarded – undo
696 809
 		}
697 810
 		echo '</table></td><td colspan="2"><table >';
698 811
 		echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>";
699
-		foreach(self::$relative as $value) {
812
+		foreach(self::$relative as $value)
813
+		{
700 814
 			echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>';
701 815
 		}
702 816
 		echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>';
Please login to merge, or discard this patch.
calendar/inc/class.calendar_so.inc.php 5 patches
Doc Comments   +13 added lines, -37 removed lines patch added patch discarded remove patch
@@ -211,23 +211,11 @@  discard block
 block discarded – undo
211 211
 	 * @param int $start startdate of the search/list (servertime)
212 212
 	 * @param int $end enddate of the search/list (servertime)
213 213
 	 * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users
214
-	 * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
214
+	 * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
215 215
 	 * @param string $filter ='default' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted)
216 216
 	 * @param int|boolean $offset =False offset for a limited query or False (default)
217 217
 	 * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs
218 218
 	 * @param array $params =array()
219
-	 * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search)
220
-	 *		Please Note: a search never returns repeating events more then once AND does not honor start+end date !!!
221
-	 *      array: everything is directly used as $where
222
-	 * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma
223
-	 * @param string $params['sql_filter'] sql to be and'ed into query (fully quoted)
224
-	 * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
225
-	 * 						if specified and not false an iterator for the rows is returned
226
-	 * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause
227
-	 * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names
228
-	 * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved!
229
-	 * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS)
230
-	 * @param boolean $params['enum_recuring'] =true enumerate recuring events
231 219
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
232 220
 	 * @return array of events
233 221
 	 */
@@ -594,7 +582,7 @@  discard block
 block discarded – undo
594 582
 	/**
595 583
 	 * generate SQL to filter after a given category (incl. subcategories)
596 584
 	 *
597
-	 * @param array|int $cat_id cat-id or array of cat-ids, or !$cat_id for none
585
+	 * @param integer $cat_id cat-id or array of cat-ids, or !$cat_id for none
598 586
 	 * @return string SQL to include in the query
599 587
 	 */
600 588
 	function cat_filter($cat_id)
@@ -682,24 +670,11 @@  discard block
 block discarded – undo
682 670
 	 * @param int $start startdate of the search/list (servertime)
683 671
 	 * @param int $end enddate of the search/list (servertime)
684 672
 	 * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users
685
-	 * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
673
+	 * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
686 674
 	 * @param string $filter ='all' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted)
687 675
 	 * @param int|boolean $offset =False offset for a limited query or False (default)
688 676
 	 * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs
689 677
 	 * @param array $params =array()
690
-	 * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search)
691
-	 *		Please Note: a search never returns repeating events more then once AND does not honor start+end date !!!
692
-	 *      array: everything is directly used as $where
693
-	 * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma
694
-	 * @param string|array $params['sql_filter'] sql to be and'ed into query (fully quoted), or usual filter array
695
-	 * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
696
-	 * 						if specified and not false an iterator for the rows is returned
697
-	 * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause
698
-	 * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names
699
-	 * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved!
700
-	 * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS)
701
-	 * @param boolean $params['enum_recuring'] =true enumerate recuring events
702
-	 * @param boolean $params['use_so_events'] =false, true return result of new $this->events()
703 678
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
704 679
 	 * @return Iterator|array of events
705 680
 	 */
@@ -1140,11 +1115,11 @@  discard block
 block discarded – undo
1140 1115
 	 * Ask other apps if they want to participate in calendar search / display
1141 1116
 	 *
1142 1117
 	 * @param &$selects parts of union query
1143
-	 * @param $start see search()
1144
-	 * @param $end
1118
+	 * @param integer $start see search()
1119
+	 * @param integer $end
1145 1120
 	 * @param $users as used in calendar_so ($users_raw plus all members and memberships added by calendar_bo)
1146
-	 * @param $cat_id
1147
-	 * @param $filter
1121
+	 * @param integer $cat_id
1122
+	 * @param string $filter
1148 1123
 	 * @param $query
1149 1124
 	 * @param $users_raw as passed to calendar_bo::search (no members and memberships added)
1150 1125
 	 */
@@ -1312,6 +1287,7 @@  discard block
 block discarded – undo
1312 1287
 	 * @param int &$set_recurrences_start=0 on return: time from which on the recurrences should be rebuilt, default 0=all
1313 1288
 	 * @param int $change_since =0 time from which on the repetitions should be changed, default 0=all
1314 1289
 	 * @param int &$etag etag=null etag to check or null, on return new etag
1290
+	 * @param boolean $set_recurrences
1315 1291
 	 * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise
1316 1292
 	 */
1317 1293
 	function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null)
@@ -1722,7 +1698,7 @@  discard block
 block discarded – undo
1722 1698
 	 * @param int $cal_id
1723 1699
 	 * @param int $start new starttime
1724 1700
 	 * @param int $end new endtime
1725
-	 * @param int|boolean $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all
1701
+	 * @param integer $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all
1726 1702
 	 * @param int $old_start =0 old starttime or (default) 0, to query it from the db
1727 1703
 	 * @param int $old_end =0 old starttime or (default) 0
1728 1704
 	 * @todo Recalculate recurrences, if timezone changes
@@ -1899,12 +1875,12 @@  discard block
 block discarded – undo
1899 1875
 	 *
1900 1876
 	 * @param int $cal_id
1901 1877
 	 * @param array $participants uid => status pairs
1902
-	 * @param int|boolean $change_since =0, false=new event,
1878
+	 * @param integer $change_since =0, false=new event,
1903 1879
 	 * 		0=all, > 0 time from which on the repetitions should be changed
1904 1880
 	 * @param boolean $add_only =false
1905 1881
 	 *		false = add AND delete participants if needed (full list of participants required in $participants)
1906 1882
 	 *		true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants)
1907
-	 * @return int|boolean number of updated recurrences or false on error
1883
+	 * @return boolean number of updated recurrences or false on error
1908 1884
 	 */
1909 1885
 	function participants($cal_id,$participants,$change_since=0,$add_only=false)
1910 1886
 	{
@@ -2045,7 +2021,7 @@  discard block
 block discarded – undo
2045 2021
 	 * set the status of one participant for a given recurrence or for all recurrences since now (includes recur_date=0)
2046 2022
 	 *
2047 2023
 	 * @param int $cal_id
2048
-	 * @param char $user_type 'u' regular user, 'r' resource, 'c' contact
2024
+	 * @param string $user_type 'u' regular user, 'r' resource, 'c' contact
2049 2025
 	 * @param int|string $user_id
2050 2026
 	 * @param int|char $status numeric status (defines) or 1-char code: 'R', 'U', 'T' or 'A'
2051 2027
 	 * @param int $recur_date =0 date to change, or 0 = all since now
@@ -2962,7 +2938,7 @@  discard block
 block discarded – undo
2962 2938
 	 * Updates the modification timestamp to force an etag, ctag and sync-token change
2963 2939
 	 *
2964 2940
 	 * @param int $id event id
2965
-	 * @param int|boolean $update_master =false id of series master or true, to update series master too
2941
+	 * @param boolean $update_master =false id of series master or true, to update series master too
2966 2942
 	 * @param int $time =null new timestamp, default current (server-)time
2967 2943
 	 * @param int $modifier =null uid of the modifier, default current user
2968 2944
 	 */
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1528,7 +1528,7 @@
 block discarded – undo
1528 1528
 			if (!$set_recurrences)
1529 1529
 			{
1530 1530
 				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) ||
1531
-				    $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1531
+					$event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1532 1532
 					(int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id;
1533 1533
 			}
1534 1534
 
Please login to merge, or discard this patch.
Spacing   +387 added lines, -390 removed lines patch added patch discarded remove patch
@@ -19,40 +19,40 @@  discard block
 block discarded – undo
19 19
 /**
20 20
  * some necessary defines used by the calendar
21 21
  */
22
-if(!extension_loaded('mcal'))
22
+if (!extension_loaded('mcal'))
23 23
 {
24
-	define('MCAL_RECUR_NONE',0);
25
-	define('MCAL_RECUR_DAILY',1);
26
-	define('MCAL_RECUR_WEEKLY',2);
27
-	define('MCAL_RECUR_MONTHLY_MDAY',3);
28
-	define('MCAL_RECUR_MONTHLY_WDAY',4);
29
-	define('MCAL_RECUR_YEARLY',5);
30
-	define('MCAL_RECUR_SECONDLY',6);
31
-	define('MCAL_RECUR_MINUTELY',7);
32
-	define('MCAL_RECUR_HOURLY',8);
33
-
34
-	define('MCAL_M_SUNDAY',1);
35
-	define('MCAL_M_MONDAY',2);
36
-	define('MCAL_M_TUESDAY',4);
37
-	define('MCAL_M_WEDNESDAY',8);
38
-	define('MCAL_M_THURSDAY',16);
39
-	define('MCAL_M_FRIDAY',32);
40
-	define('MCAL_M_SATURDAY',64);
41
-
42
-	define('MCAL_M_WEEKDAYS',62);
43
-	define('MCAL_M_WEEKEND',65);
44
-	define('MCAL_M_ALLDAYS',127);
24
+	define('MCAL_RECUR_NONE', 0);
25
+	define('MCAL_RECUR_DAILY', 1);
26
+	define('MCAL_RECUR_WEEKLY', 2);
27
+	define('MCAL_RECUR_MONTHLY_MDAY', 3);
28
+	define('MCAL_RECUR_MONTHLY_WDAY', 4);
29
+	define('MCAL_RECUR_YEARLY', 5);
30
+	define('MCAL_RECUR_SECONDLY', 6);
31
+	define('MCAL_RECUR_MINUTELY', 7);
32
+	define('MCAL_RECUR_HOURLY', 8);
33
+
34
+	define('MCAL_M_SUNDAY', 1);
35
+	define('MCAL_M_MONDAY', 2);
36
+	define('MCAL_M_TUESDAY', 4);
37
+	define('MCAL_M_WEDNESDAY', 8);
38
+	define('MCAL_M_THURSDAY', 16);
39
+	define('MCAL_M_FRIDAY', 32);
40
+	define('MCAL_M_SATURDAY', 64);
41
+
42
+	define('MCAL_M_WEEKDAYS', 62);
43
+	define('MCAL_M_WEEKEND', 65);
44
+	define('MCAL_M_ALLDAYS', 127);
45 45
 }
46 46
 
47
-define('REJECTED',0);
48
-define('NO_RESPONSE',1);
49
-define('TENTATIVE',2);
50
-define('ACCEPTED',3);
51
-define('DELEGATED',4);
47
+define('REJECTED', 0);
48
+define('NO_RESPONSE', 1);
49
+define('TENTATIVE', 2);
50
+define('ACCEPTED', 3);
51
+define('DELEGATED', 4);
52 52
 
53
-define('HOUR_s',60*60);
54
-define('DAY_s',24*HOUR_s);
55
-define('WEEK_s',7*DAY_s);
53
+define('HOUR_s', 60 * 60);
54
+define('DAY_s', 24 * HOUR_s);
55
+define('WEEK_s', 7 * DAY_s);
56 56
 
57 57
 /**
58 58
  * Class to store all calendar data (storage object)
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * name of the main calendar table and prefix for all other calendar tables
101 101
 	 */
102 102
 	var $cal_table = 'egw_cal';
103
-	var $extra_table,$repeats_table,$user_table,$dates_table,$all_tables;
103
+	var $extra_table, $repeats_table, $user_table, $dates_table, $all_tables;
104 104
 
105 105
 	/**
106 106
 	 * reference to global db-object
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		$this->db = $GLOBALS['egw']->db;
137 137
 
138 138
 		$this->all_tables = array($this->cal_table);
139
-		foreach(array('extra','repeats','user','dates') as $name)
139
+		foreach (array('extra', 'repeats', 'user', 'dates') as $name)
140 140
 		{
141 141
 			$vname = $name.'_table';
142 142
 			$this->all_tables[] = $this->$vname = $this->cal_table.'_'.$name;
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 * @param boolean $deleted =false
153 153
 	 * @return string
154 154
 	 */
155
-	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
155
+	protected function cal_range_view($start, $end, array $_where = null, $deleted = false)
156 156
 	{
157 157
 		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
158 158
 		{
159
-			return $this->cal_table;	// no need / use for a view
159
+			return $this->cal_table; // no need / use for a view
160 160
 		}
161 161
 
162 162
 		$where = array();
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	 * @param boolean $deleted =false
183 183
 	 * @return string
184 184
 	 */
185
-	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
185
+	protected function dates_range_view($start, $end, array $_where = null, $deleted = false)
186 186
 	{
187 187
 		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
188 188
 		{
189
-			return $this->dates_table;	// no need / use for a view
189
+			return $this->dates_table; // no need / use for a view
190 190
 		}
191 191
 
192 192
 		$where = array();
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
232 232
 	 * @return array of events
233 233
 	 */
234
-	function &events($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null)
234
+	function &events($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null)
235 235
 	{
236
-		error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
236
+		error_log(__METHOD__.'('.($start ? date('Y-m-d H:i', $start) : '').','.($end ? date('Y-m-d H:i', $end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
237 237
 		$start_time = microtime(true);
238 238
 		// not everything is supported by now
239 239
 		if (!$start || !$end || is_string($params['query']) ||
240 240
 			//in_array($filter,array('owner','deleted')) ||
241
-			$params['enum_recuring']===false)
241
+			$params['enum_recuring'] === false)
242 242
 		{
243 243
 			throw new Api\Exception\AssertionFailed("Unsupported value for parameters!");
244 244
 		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		{
266 266
 			// fix $users to also prefix system users and groups (with 'u')
267 267
 			if (!is_array($users)) $users = $users ? (array)$users : array();
268
-			foreach($users as &$uid)
268
+			foreach ($users as &$uid)
269 269
 			{
270 270
 				$user_type = $user_id = null;
271 271
 				self::split_user($uid, $user_type, $user_id, true);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 		if ($params['order'])	// only order if requested
288 288
 		{
289
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
289
+			if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection
290 290
 			$sql .= "\nORDER BY ".$params['order'];
291 291
 		}
292 292
 
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 			$offset = 0;
296 296
 			$num_rows = -1;
297 297
 		}
298
-		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
299
-		error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true)-$start_time, 3));
298
+		$events = & $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
299
+		error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true) - $start_time, 3));
300 300
 		return $events;
301 301
 	}
302 302
 
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
 	 * @param int $recur_date =0 if set read the next recurrence at or after the timestamp, default 0 = read the initital one
310 310
 	 * @return array|boolean array with cal_id => event array pairs or false if entry not found
311 311
 	 */
312
-	function read($ids,$recur_date=0)
312
+	function read($ids, $recur_date = 0)
313 313
 	{
314 314
 		//error_log(__METHOD__.'('.array2string($ids).",$recur_date) ".function_backtrace());
315 315
 		$cols = self::get_columns('calendar', $this->cal_table);
316 316
 		$cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id');
317
-		$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',',$cols);
317
+		$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',', $cols);
318 318
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
319 319
 
320 320
 		$where = array();
@@ -324,23 +324,23 @@  discard block
 block discarded – undo
324 324
 			$where['cal_uid'] = $ids;
325 325
 			$where['cal_reference'] = 0;
326 326
 		}
327
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
327
+		elseif (is_array($ids) && isset($ids[count($ids) - 1]) || is_scalar($ids))	// one or more cal_id's
328 328
 		{
329 329
 			$where['cal_id'] = $ids;
330 330
 		}
331 331
 		else	// array with column => value pairs
332 332
 		{
333 333
 			$where = $ids;
334
-			unset($ids);	// otherwise users get not read!
334
+			unset($ids); // otherwise users get not read!
335 335
 		}
336 336
 		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
337 337
 		{
338
-			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
338
+			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.', array(
339 339
 				'cal_id' => $where['cal_id'],
340 340
 			));
341 341
 			unset($where['cal_id']);
342 342
 		}
343
-		if ((int) $recur_date)
343
+		if ((int)$recur_date)
344 344
 		{
345 345
 			$where[] = 'cal_start >= '.(int)$recur_date;
346 346
 			$group_by = 'GROUP BY '.$cols;
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		}
354 354
 		$cols .= ',range_end AS recur_enddate';
355 355
 
356
-		$events =& $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date);
356
+		$events = & $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date);
357 357
 
358 358
 		return $events ? $events : false;
359 359
 	}
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 * @param int $recur_date =0
366 366
 	 * @return array
367 367
 	 */
368
-	protected function &get_events($rs, $recur_date=0)
368
+	protected function &get_events($rs, $recur_date = 0)
369 369
 	{
370 370
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
371 371
 		{
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 
379 379
 		$events = array();
380
-		foreach($rs as $row)
380
+		foreach ($rs as $row)
381 381
 		{
382 382
 			if (!$row['recur_type'])
383 383
 			{
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 				unset($row['recur_enddate']);
386 386
 			}
387 387
 			$row['recur_exception'] = $row['alarm'] = array();
388
-			$events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_');
388
+			$events[$row['cal_id']] = Api\Db::strip_array_keys($row, 'cal_');
389 389
 		}
390 390
 		if (!$events) return $events;
391 391
 
@@ -397,26 +397,26 @@  discard block
 block discarded – undo
397 397
 			if (!isset($event['uid']) || strlen($event['uid']) < $minimum_uid_length)
398 398
 			{
399 399
 				// event (without uid), not strong enough uid => create new uid
400
-				$event['uid'] = Api\CalDAV::generate_uid('calendar',$event['id']);
400
+				$event['uid'] = Api\CalDAV::generate_uid('calendar', $event['id']);
401 401
 				$this->db->update($this->cal_table, array('cal_uid' => $event['uid']),
402
-					array('cal_id' => $event['id']),__LINE__,__FILE__,'calendar');
402
+					array('cal_id' => $event['id']), __LINE__, __FILE__, 'calendar');
403 403
 			}
404 404
 			if (!(int)$recur_date && $event['recur_type'] != MCAL_RECUR_NONE)
405 405
 			{
406
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
406
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
407 407
 					'cal_id' => $ids,
408 408
 					'recur_exception' => true,
409 409
 				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row)
410 410
 				{
411 411
 					$events[$row['cal_id']]['recur_exception'][] = $row['cal_start'];
412 412
 				}
413
-				break;	// as above select read all exceptions (and I dont think too short uid problem still exists)
413
+				break; // as above select read all exceptions (and I dont think too short uid problem still exists)
414 414
 			}
415 415
 			// make sure we fetch only real exceptions (deleted occurrences of a series should not show up)
416
-			if (($recur_date &&	$event['recur_type'] != MCAL_RECUR_NONE))
416
+			if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE))
417 417
 			{
418 418
 				//_debug_array(__METHOD__.__LINE__.' recur_date:'.$recur_date.' check cal_start:'.$event['start']);
419
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
419
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
420 420
 					'cal_id' => $event['id'],
421 421
 					'cal_start' => $event['start'],
422 422
 					'recur_exception' => true,
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 						'cal_deleted' => NULL
433 433
 					), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn())
434 434
 					{
435
-						$e = $this->read($event['id'],$event['start']+1);
435
+						$e = $this->read($event['id'], $event['start'] + 1);
436 436
 						$event = $e[$event['id']];
437 437
 						break;
438 438
 					}
@@ -454,21 +454,21 @@  discard block
 block discarded – undo
454 454
 			if ($recur_date)
455 455
 			{
456 456
 				// also remember recur_date, maybe we need it later, duno now
457
-				$recur_date = array(0,$events[$ids]['recur_date'] = $events[$ids]['start']);
457
+				$recur_date = array(0, $events[$ids]['recur_date'] = $events[$ids]['start']);
458 458
 			}
459 459
 		}
460 460
 
461 461
 		// participants, if a recur_date give, we read that recurance, plus the one users from the default entry with recur_date=0
462 462
 		// sorting by cal_recur_date ASC makes sure recurence status always overwrites series status
463
-		foreach($this->db->select($this->user_table,'*',array(
463
+		foreach ($this->db->select($this->user_table, '*', array(
464 464
 			'cal_id'      => $ids,
465 465
 			'cal_recur_date' => $recur_date,
466 466
 			"cal_status NOT IN ('X','E')",
467
-		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)	// DESC puts users before resources and contacts
467
+		), __LINE__, __FILE__, false, 'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT, 'calendar') as $row)	// DESC puts users before resources and contacts
468 468
 		{
469 469
 			// combine all participant data in uid and status values
470 470
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
471
-			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
471
+			$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
472 472
 
473 473
 			$events[$row['cal_id']]['participants'][$uid] = $status;
474 474
 			$events[$row['cal_id']]['participant_types'][$row['cal_user_type']][is_numeric($uid) ? $uid : substr($uid, 1)] = $status;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		}
478 478
 
479 479
 		// custom fields
480
-		foreach($this->db->select($this->extra_table,'*',array('cal_id'=>$ids),__LINE__,__FILE__,false,'','calendar') as $row)
480
+		foreach ($this->db->select($this->extra_table, '*', array('cal_id'=>$ids), __LINE__, __FILE__, false, '', 'calendar') as $row)
481 481
 		{
482 482
 			$events[$row['cal_id']]['#'.$row['cal_extra_name']] = $row['cal_extra_value'];
483 483
 		}
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		// alarms
486 486
 		if (is_array($ids))
487 487
 		{
488
-			foreach($this->read_alarms((array)$ids) as $cal_id => $alarms)
488
+			foreach ($this->read_alarms((array)$ids) as $cal_id => $alarms)
489 489
 			{
490 490
 				$events[$cal_id]['alarm'] = $alarms;
491 491
 			}
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
515 515
 	 * @return int maximum modification timestamp
516 516
 	 */
517
-	function get_ctag($users, $owner_too=false,$master_only=false)
517
+	function get_ctag($users, $owner_too = false, $master_only = false)
518 518
 	{
519
-		static $ctags = array();	// some per-request caching
519
+		static $ctags = array(); // some per-request caching
520 520
 		static $last_request = null;
521
-		if (!isset($last_request) || time()-$last_request > self::MAX_CTAG_CACHE_TIME)
521
+		if (!isset($last_request) || time() - $last_request > self::MAX_CTAG_CACHE_TIME)
522 522
 		{
523 523
 			$ctags = array();
524 524
 			$last_request = time();
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
 		if (isset($ctags[$signature])) return $ctags[$signature];
528 528
 
529 529
 		$types = array();
530
-		foreach((array)$users as $uid)
530
+		foreach ((array)$users as $uid)
531 531
 		{
532 532
 			$type = $id = null;
533 533
 			self::split_user($uid, $type, $id, true);
534 534
 			$types[$type][] = $id;
535 535
 		}
536
-		foreach($types as $type => $ids)
536
+		foreach ($types as $type => $ids)
537 537
 		{
538 538
 			$where = array(
539 539
 				'cal_user_type' => $type,
@@ -555,17 +555,17 @@  discard block
 block discarded – undo
555 555
 		if ($owner_too)
556 556
 		{
557 557
 			// owner can only by users, no groups or resources
558
-			foreach($users as $key => $user)
558
+			foreach ($users as $key => $user)
559 559
 			{
560 560
 				if (!($user > 0)) unset($users[$key]);
561 561
 			}
562 562
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
563 563
 				$this->db->expression($this->cal_table, array(
564 564
 					'cal_owner' => $users,
565
-				),')');
565
+				), ')');
566 566
 		}
567
-		return $ctags[$signature] = $this->db->select($this->user_table,'MAX(cal_modified)',
568
-			$where,__LINE__,__FILE__,false,'','calendar',0,'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn();
567
+		return $ctags[$signature] = $this->db->select($this->user_table, 'MAX(cal_modified)',
568
+			$where, __LINE__, __FILE__, false, '', 'calendar', 0, 'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn();
569 569
 	}
570 570
 
571 571
 	/**
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	 * @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query
578 578
 	 * @return Iterator as Api\Db::select
579 579
 	 */
580
-	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
580
+	function get_cal_data(array $query, $cols = 'cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
581 581
 	{
582 582
 		if (!is_array($cols)) $cols = explode(',', $cols);
583 583
 
@@ -603,12 +603,12 @@  discard block
 block discarded – undo
603 603
 		if ($cat_id)
604 604
 		{
605 605
 			$cats = $GLOBALS['egw']->categories->return_all_children($cat_id);
606
-			array_walk($cats,create_function('&$val,$key','$val = (int) $val;'));
607
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
608
-			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
609
-			foreach($cats as $cat)
606
+			array_walk($cats, create_function('&$val,$key', '$val = (int) $val;'));
607
+			if (is_array($cat_id) && count($cat_id) == 1) $cat_id = $cat_id[0];
608
+			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','", $cats)."')" : '='.$this->db->quote((int)$cat_id));
609
+			foreach ($cats as $cat)
610 610
 			{
611
-				$sql .= ' OR '.$this->db->concat("','",'cal_category',"','").' LIKE '.$this->db->quote('%,'.$cat.',%');
611
+				$sql .= ' OR '.$this->db->concat("','", 'cal_category', "','").' LIKE '.$this->db->quote('%,'.$cat.',%');
612 612
 			}
613 613
 			$sql .= ') ';
614 614
 		}
@@ -623,13 +623,13 @@  discard block
 block discarded – undo
623 623
 	 * @param array $where =array() array to add filters too
624 624
 	 * @return array
625 625
 	 */
626
-	protected function status_filter($filter, $enum_recuring=true, array $where=array())
626
+	protected function status_filter($filter, $enum_recuring = true, array $where = array())
627 627
 	{
628
-		if($filter != 'deleted' && $filter != 'everything')
628
+		if ($filter != 'deleted' && $filter != 'everything')
629 629
 		{
630 630
 			$where[] = 'cal_deleted IS NULL';
631 631
 		}
632
-		switch($filter)
632
+		switch ($filter)
633 633
 		{
634 634
 			case 'everything':	// no filter at all
635 635
 				break;
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
704 704
 	 * @return Iterator|array of events
705 705
 	 */
706
-	function &search($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null)
706
+	function &search($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null)
707 707
 	{
708 708
 		//error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
709 709
 
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 		{
727 727
 			$all_cols = self::get_columns('calendar', $this->cal_table);
728 728
 			$all_cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id');
729
-			$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',',$all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date";
729
+			$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',', $all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date";
730 730
 		}
731 731
 		$where = array();
732 732
 		if (is_array($params['query']))
@@ -735,19 +735,19 @@  discard block
 block discarded – undo
735 735
 		}
736 736
 		elseif ($params['query'])
737 737
 		{
738
-			foreach(array('cal_title','cal_description','cal_location') as $col)
738
+			foreach (array('cal_title', 'cal_description', 'cal_location') as $col)
739 739
 			{
740 740
 				$to_or[] = $col.' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%'.$params['query'].'%');
741 741
 			}
742
-			$where[] = '('.implode(' OR ',$to_or).')';
742
+			$where[] = '('.implode(' OR ', $to_or).')';
743 743
 
744 744
 			// Searching - restrict private to own or private grant
745 745
 			if (!isset($params['private_grants']))
746 746
 			{
747 747
 				$params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], Acl::PRIVAT, 'calendar');
748
-				$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id'];	// db query does NOT return current user
748
+				$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user
749 749
 			}
750
-			$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')';
750
+			$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])).')';
751 751
 			$where[] = $private_filter;
752 752
 		}
753 753
 		if (!empty($params['sql_filter']))
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			{
757 757
 				$where[] = $params['sql_filter'];
758 758
 			}
759
-			elseif(is_array($params['sql_filter']))
759
+			elseif (is_array($params['sql_filter']))
760 760
 			{
761 761
 				$where = array_merge($where, $params['sql_filter']);
762 762
 			}
@@ -764,11 +764,11 @@  discard block
 block discarded – undo
764 764
 		if ($users)
765 765
 		{
766 766
 			$users_by_type = array();
767
-			foreach((array)$users as $user)
767
+			foreach ((array)$users as $user)
768 768
 			{
769 769
 				if (is_numeric($user))
770 770
 				{
771
-					$users_by_type['u'][] = (int) $user;
771
+					$users_by_type['u'][] = (int)$user;
772 772
 				}
773 773
 				else
774 774
 				{
@@ -780,45 +780,45 @@  discard block
 block discarded – undo
780 780
 			$to_or = $user_or = array();
781 781
 			$owner_or = null;
782 782
 			$useUnionQuery = $this->db->capabilities['distinct_on_text'] && $this->db->capabilities['union'];
783
-			$table_def = $this->db->get_table_definitions('calendar',$this->user_table);
784
-			foreach($users_by_type as $type => $ids)
783
+			$table_def = $this->db->get_table_definitions('calendar', $this->user_table);
784
+			foreach ($users_by_type as $type => $ids)
785 785
 			{
786 786
 				// when we are able to use Union Querys, we do not OR our query, we save the needed parts for later construction of the union
787 787
 				if ($useUnionQuery)
788 788
 				{
789
-					$user_or[] = $this->db->expression($table_def,$this->user_table.'.',array(
789
+					$user_or[] = $this->db->expression($table_def, $this->user_table.'.', array(
790 790
 						'cal_user_type' => $type,
791
-					),' AND '.$this->user_table.'.',array(
791
+					), ' AND '.$this->user_table.'.', array(
792 792
 						'cal_user_id'   => $ids,
793 793
 					));
794 794
 					if ($type == 'u' && $filter == 'owner')
795 795
 					{
796
-						$cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table);
796
+						$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
797 797
 						// only users can be owners, no need to add groups
798 798
 						$user_ids = array();
799
-						foreach($ids as $user_id)
799
+						foreach ($ids as $user_id)
800 800
 						{
801 801
 							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
802 802
 						}
803
-						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
803
+						$owner_or = $this->db->expression($cal_table_def, array('cal_owner' => $user_ids));
804 804
 					}
805 805
 				}
806 806
 				else
807 807
 				{
808
-					$to_or[] = $this->db->expression($table_def,$this->user_table.'.',array(
808
+					$to_or[] = $this->db->expression($table_def, $this->user_table.'.', array(
809 809
 						'cal_user_type' => $type,
810
-					),' AND '.$this->user_table.'.',array(
810
+					), ' AND '.$this->user_table.'.', array(
811 811
 						'cal_user_id'   => $ids,
812 812
 					));
813 813
 					if ($type == 'u' && $filter == 'owner')
814 814
 					{
815
-						$cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table);
816
-						$to_or[] = $this->db->expression($cal_table_def,array('cal_owner' => $ids));
815
+						$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
816
+						$to_or[] = $this->db->expression($cal_table_def, array('cal_owner' => $ids));
817 817
 					}
818 818
 				}
819 819
 			}
820 820
 			// this is only used, when we cannot use UNIONS
821
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
821
+			if (!$useUnionQuery) $where[] = '('.implode(' OR ', $to_or).')';
822 822
 
823 823
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
824 824
 		}
@@ -837,15 +837,15 @@  discard block
 block discarded – undo
837 837
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
838 838
 			}
839 839
 		}
840
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
840
+		if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection
841 841
 
842 842
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
843 843
 		if (!$params['enum_recuring'])
844 844
 		{
845 845
 			$where[] = "$this->user_table.cal_recur_date=0";
846
-			$cols = str_replace(array('cal_start','cal_end'),array('range_start AS cal_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'),$cols);
846
+			$cols = str_replace(array('cal_start', 'cal_end'), array('range_start AS cal_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'), $cols);
847 847
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
848
-			$where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
848
+			$where = str_replace(array('cal_start', 'cal_end'), array('range_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
849 849
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
850 850
 			if ($end) $where[] = (int)$end.' > range_start';
851 851
   		}
@@ -857,14 +857,13 @@  discard block
 block discarded – undo
857 857
 				" ON $this->cal_table.cal_id=rejected_by_user.cal_id".
858 858
 				" AND rejected_by_user.cal_user_type='u'".
859 859
 				" AND rejected_by_user.cal_user_id=".$this->db->quote($remove_rejected_by_user).
860
-				" AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' :
861
-					'(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)');
860
+				" AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)');
862 861
 			$or_required = array(
863 862
 				'rejected_by_user.cal_status IS NULL',
864 863
 				"rejected_by_user.cal_status NOT IN ('R','X')",
865 864
 			);
866 865
 			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
867
-			$where[] = '('.implode(' OR ',$or_required).')';
866
+			$where[] = '('.implode(' OR ', $or_required).')';
868 867
 		}
869 868
 		// using a time-range and deleted attribute limited view instead of full table
870 869
 		$cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted');
@@ -876,7 +875,7 @@  discard block
 block discarded – undo
876 875
 		// dates table join only needed to enum recuring events, we use a time-range limited view here too
877 876
 		if ($params['enum_recuring'])
878 877
 		{
879
-			$join = "JOIN ".$this->dates_table.	// using dates_table direct seems quicker then an other view
878
+			$join = "JOIN ".$this->dates_table.// using dates_table direct seems quicker then an other view
880 879
 				//$this->dates_range_view($start, $end, null, $filter == 'everything' ? null : $filter == 'deleted').
881 880
 				" ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$join;
882 881
 		}
@@ -903,29 +902,29 @@  discard block
 block discarded – undo
903 902
 			// as replace the OR by construction of a suitable UNION for performance reasons
904 903
 			if ($owner_or || $user_or)
905 904
 			{
906
-				foreach($user_or as $user_sql)
905
+				foreach ($user_or as $user_sql)
907 906
 				{
908 907
 					$selects[] = $select;
909
-					$selects[count($selects)-1]['where'][] = $user_sql;
908
+					$selects[count($selects) - 1]['where'][] = $user_sql;
910 909
 					if ($params['enum_recuring'])
911 910
 					{
912
-						$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
911
+						$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
913 912
 						$selects[] = $select;
914
-						$selects[count($selects)-1]['where'][] = $user_sql;
915
-						$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
913
+						$selects[count($selects) - 1]['where'][] = $user_sql;
914
+						$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
916 915
 					}
917 916
 				}
918 917
 				// if the query is to be filtered by owner we need to add more selects for the union
919 918
 				if ($owner_or)
920 919
 				{
921 920
 					$selects[] = $select;
922
-					$selects[count($selects)-1]['where'][] = $owner_or;
921
+					$selects[count($selects) - 1]['where'][] = $owner_or;
923 922
 					if ($params['enum_recuring'])
924 923
 					{
925
-						$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
924
+						$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
926 925
 						$selects[] = $select;
927
-						$selects[count($selects)-1]['where'][] = $owner_or;
928
-						$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
926
+						$selects[count($selects) - 1]['where'][] = $owner_or;
927
+						$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
929 928
 					}
930 929
 				}
931 930
 			}
@@ -935,34 +934,34 @@  discard block
 block discarded – undo
935 934
 				$selects[] = $select;
936 935
 				if ($params['enum_recuring'])
937 936
 				{
938
-					$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
937
+					$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
939 938
 					$selects[] = $select;
940
-					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
939
+					$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
941 940
 				}
942 941
 			}
943 942
 			if (is_numeric($offset) && !$params['no_total'])	// get the total too
944 943
 			{
945 944
 				$save_selects = $selects;
946 945
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
947
-				foreach(array_keys($selects) as $key)
946
+				foreach (array_keys($selects) as $key)
948 947
 				{
949 948
 					$selects[$key]['cols'] = "DISTINCT $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date";
950 949
 					if (!$params['enum_recuring'])
951 950
 					{
952
-						$selects[$key]['cols'] = str_replace(array('cal_start','cal_end'),
953
-							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
951
+						$selects[$key]['cols'] = str_replace(array('cal_start', 'cal_end'),
952
+							array('range_start AS cal_start', 'range_end AS cal_end'), $selects[$key]['cols']);
954 953
 					}
955 954
 				}
956
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
955
+				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
957 956
 
958
-				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
957
+				$this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows();
959 958
 
960 959
 				// restore original cols / selects
961 960
 				$selects = $save_selects; unset($save_selects);
962 961
 			}
963
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
962
+			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
964 963
 
965
-			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
964
+			$rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows);
966 965
 		}
967 966
 		else	// MsSQL oder MySQL 3.23
968 967
 		{
@@ -985,27 +984,27 @@  discard block
 block discarded – undo
985 984
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
986 985
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
987 986
 				{
988
-					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
987
+					self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
989 988
 				}
990 989
 				$this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows();
991 990
 				$selects = $save_selects;
992 991
 			}
993 992
 			if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
994 993
 			{
995
-				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
994
+				self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
996 995
 			}
997
-			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
996
+			$rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows);
998 997
 		}
999 998
 		//error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime).'s '.$rs->sql);
1000 999
 
1001 1000
 		if (isset($params['cols']))
1002 1001
 		{
1003
-			return $rs;	// if colums are specified we return the recordset / iterator
1002
+			return $rs; // if colums are specified we return the recordset / iterator
1004 1003
 		}
1005 1004
 		// Todo: return $this->get_events($rs);
1006 1005
 
1007 1006
 		$events = $ids = $recur_dates = $recur_ids = array();
1008
-		foreach($rs as $row)
1007
+		foreach ($rs as $row)
1009 1008
 		{
1010 1009
 			$id = $row['cal_id'];
1011 1010
 			if (is_numeric($id)) $ids[] = $id;
@@ -1017,9 +1016,9 @@  discard block
 block discarded – undo
1017 1016
 			}
1018 1017
 			if ($row['participants'])
1019 1018
 			{
1020
-				$row['participants'] = explode(',',$row['participants']);
1019
+				$row['participants'] = explode(',', $row['participants']);
1021 1020
 				$row['participants'] = array_combine($row['participants'],
1022
-					array_fill(0,count($row['participants']),''));
1021
+					array_fill(0, count($row['participants']), ''));
1023 1022
 			}
1024 1023
 			else
1025 1024
 			{
@@ -1028,9 +1027,9 @@  discard block
 block discarded – undo
1028 1027
 			$row['recur_exception'] = $row['alarm'] = array();
1029 1028
 
1030 1029
 			// compile a list of recurrences per cal_id
1031
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1030
+			if (!in_array($id, (array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1032 1031
 
1033
-			$events[$id] = Api\Db::strip_array_keys($row,'cal_');
1032
+			$events[$id] = Api\Db::strip_array_keys($row, 'cal_');
1034 1033
 		}
1035 1034
 		//_debug_array($events);
1036 1035
 		if (count($ids))
@@ -1040,26 +1039,26 @@  discard block
 block discarded – undo
1040 1039
 			// now ready all users with the given cal_id AND (cal_recur_date=0 or the fitting recur-date)
1041 1040
 			// This will always read the first entry of each recuring event too, we eliminate it later
1042 1041
 			$recur_dates[] = 0;
1043
-			$utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',',$ids).")".
1042
+			$utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',', $ids).")".
1044 1043
 				($filter != 'everything' ? " AND cal_status NOT IN ('X','E')" : '').") utcalid ";
1045 1044
 			//$utrecurdate_view = " (select * from ".$this->user_table." where cal_recur_date in (".implode(',',array_unique($recur_dates)).")) utrecurdates ";
1046
-			foreach($this->db->select($utcal_id_view,'*',array(
1045
+			foreach ($this->db->select($utcal_id_view, '*', array(
1047 1046
 					//'cal_id' => array_unique($ids),
1048 1047
 					'cal_recur_date' => $recur_dates,
1049
-				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',$num_rows,$join='',
1050
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1048
+				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT, 'calendar', $num_rows, $join = '',
1049
+				$this->db->get_table_definitions('calendar', $this->user_table)) as $row)	// DESC puts users before resources and contacts
1051 1050
 			{
1052 1051
 				$id = $row['cal_id'];
1053 1052
 				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1054 1053
 
1055 1054
 				// combine all participant data in uid and status values
1056 1055
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1057
-				$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
1056
+				$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
1058 1057
 
1059 1058
 				// set accept/reject/tentative of series for all recurrences
1060 1059
 				if (!$row['cal_recur_date'])
1061 1060
 				{
1062
-					foreach((array)$recur_ids[$row['cal_id']] as $i)
1061
+					foreach ((array)$recur_ids[$row['cal_id']] as $i)
1063 1062
 					{
1064 1063
 						if (isset($events[$i]) && !isset($events[$i]['participants'][$uid]))
1065 1064
 						{
@@ -1074,16 +1073,16 @@  discard block
 block discarded – undo
1074 1073
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1075 1074
 			if (!$params['enum_recuring'] || !$params['daywise'])
1076 1075
 			{
1077
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
1076
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
1078 1077
 					'cal_id' => $ids,
1079 1078
 					'recur_exception' => true,
1080 1079
 				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row)
1081 1080
 				{
1082 1081
 					// for enum_recurring events are not indexed by cal_id, but $cal_id.'-'.$cal_start
1083 1082
 					// find master, which is first recurrence
1084
-					if (!isset($events[$id=$row['cal_id']]))
1083
+					if (!isset($events[$id = $row['cal_id']]))
1085 1084
 					{
1086
-						foreach($events as $id => $event)
1085
+						foreach ($events as $id => $event)
1087 1086
 						{
1088 1087
 							if ($event['id'] == $row['cal_id']) break;
1089 1088
 						}
@@ -1096,10 +1095,10 @@  discard block
 block discarded – undo
1096 1095
 			{
1097 1096
 				$where = array('cal_id' => $ids);
1098 1097
 				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1099
-				foreach($this->db->select($this->extra_table,'*',$where,
1100
-					__LINE__,__FILE__,false,'','calendar') as $row)
1098
+				foreach ($this->db->select($this->extra_table, '*', $where,
1099
+					__LINE__, __FILE__, false, '', 'calendar') as $row)
1101 1100
 				{
1102
-					foreach((array)$recur_ids[$row['cal_id']] as $id)
1101
+					foreach ((array)$recur_ids[$row['cal_id']] as $id)
1103 1102
 					{
1104 1103
 						if (isset($events[$id]))
1105 1104
 						{
@@ -1109,9 +1108,9 @@  discard block
 block discarded – undo
1109 1108
 				}
1110 1109
 			}
1111 1110
 			// alarms
1112
-			foreach($this->read_alarms($ids) as $cal_id => $alarms)
1111
+			foreach ($this->read_alarms($ids) as $cal_id => $alarms)
1113 1112
 			{
1114
-				foreach($alarms as $id => $alarm)
1113
+				foreach ($alarms as $id => $alarm)
1115 1114
 				{
1116 1115
 					$event_start = $alarm['time'] + $alarm['offset'];
1117 1116
 
@@ -1148,16 +1147,16 @@  discard block
 block discarded – undo
1148 1147
 	 * @param $query
1149 1148
 	 * @param $users_raw as passed to calendar_bo::search (no members and memberships added)
1150 1149
 	 */
1151
-	private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query,$users_raw)
1150
+	private static function get_union_selects(array &$selects, $start, $end, $users, $cat_id, $filter, $query, $users_raw)
1152 1151
 	{
1153
-		if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','rpc.php','xmlrpc.php','/activesync/index.php')) ||
1154
-			!in_array($GLOBALS['egw_info']['flags']['currentapp'],array('calendar','home')))
1152
+		if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('groupdav.php', 'rpc.php', 'xmlrpc.php', '/activesync/index.php')) ||
1153
+			!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('calendar', 'home')))
1155 1154
 		{
1156
-			return;    // disable integration for GroupDAV, SyncML, ...
1155
+			return; // disable integration for GroupDAV, SyncML, ...
1157 1156
 		}
1158 1157
 		self::$integration_data = Api\Hooks::process(array(
1159 1158
 			'location' => 'calendar_search_union',
1160
-			'cols'  => $selects[0]['cols'],    // cols to return
1159
+			'cols'  => $selects[0]['cols'], // cols to return
1161 1160
 			'start' => $start,
1162 1161
 			'end'   => $end,
1163 1162
 			'users' => $users,
@@ -1166,12 +1165,12 @@  discard block
 block discarded – undo
1166 1165
 			'filter'=> $filter,
1167 1166
 			'query' => $query,
1168 1167
 		));
1169
-		foreach(self::$integration_data as $data)
1168
+		foreach (self::$integration_data as $data)
1170 1169
 		{
1171 1170
 			if (is_array($data['selects']))
1172 1171
 			{
1173 1172
 				//echo $app; _debug_array($data);
1174
-				$selects = array_merge($selects,$data['selects']);
1173
+				$selects = array_merge($selects, $data['selects']);
1175 1174
 			}
1176 1175
 		}
1177 1176
 	}
@@ -1196,35 +1195,35 @@  discard block
 block discarded – undo
1196 1195
 	 * @param string $required_app ='calendar'
1197 1196
 	 * @return string cols for union query to match ones supplied in $required
1198 1197
 	 */
1199
-	public static function union_cols(array $app_cols,$required,$required_app='calendar')
1198
+	public static function union_cols(array $app_cols, $required, $required_app = 'calendar')
1200 1199
 	{
1201 1200
 		// remove evtl. used DISTINCT, we currently dont need it
1202
-		if (($distinct = substr($required,0,9) == 'DISTINCT '))
1201
+		if (($distinct = substr($required, 0, 9) == 'DISTINCT '))
1203 1202
 		{
1204
-			$required = substr($required,9);
1203
+			$required = substr($required, 9);
1205 1204
 		}
1206 1205
 		$return_cols = array();
1207
-		foreach(is_array($required) ? $required : explode(',',$required) as $cols)
1206
+		foreach (is_array($required) ? $required : explode(',', $required) as $cols)
1208 1207
 		{
1209 1208
 			$matches = null;
1210
-			if (substr($cols,-2) == '.*')
1209
+			if (substr($cols, -2) == '.*')
1211 1210
 			{
1212
-				$cols = self::get_columns($required_app,substr($cols,0,-2));
1211
+				$cols = self::get_columns($required_app, substr($cols, 0, -2));
1213 1212
 			}
1214 1213
 			// remove CAST added for PostgreSQL from eg. "CAST(egw_cal.cal_id AS varchar)"
1215 1214
 			elseif (preg_match('/CAST\(([a-z0-9_.]+) AS [a-z0-9_]+\)/i', $cols, $matches))
1216 1215
 			{
1217 1216
 				$cols = $matches[1];
1218 1217
 			}
1219
-			elseif (strpos($cols,' AS ') !== false)
1218
+			elseif (strpos($cols, ' AS ') !== false)
1220 1219
 			{
1221
-				list(,$cols) = explode(' AS ',$cols);
1220
+				list(,$cols) = explode(' AS ', $cols);
1222 1221
 			}
1223
-			foreach((array)$cols as $col)
1222
+			foreach ((array)$cols as $col)
1224 1223
 			{
1225
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1224
+				if (substr($col, 0, 7) == 'egw_cal')	// remove table name
1226 1225
 				{
1227
-					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1226
+					$col = preg_replace('/^egw_cal[a-z_]*\./', '', $col);
1228 1227
 				}
1229 1228
 				if (isset($app_cols[$col]))
1230 1229
 				{
@@ -1237,7 +1236,7 @@  discard block
 block discarded – undo
1237 1236
 			}
1238 1237
 		}
1239 1238
 		//error_log(__METHOD__."(".array2string($app_cols).", ".array2string($required).", '$required_app') returning ".array2string(implode(',',$return_cols)));
1240
-		return implode(',',$return_cols);
1239
+		return implode(',', $return_cols);
1241 1240
 	}
1242 1241
 
1243 1242
 	/**
@@ -1247,21 +1246,21 @@  discard block
 block discarded – undo
1247 1246
 	 * @param string $table
1248 1247
 	 * @return array of column names
1249 1248
 	 */
1250
-	static private function get_columns($app,$table)
1249
+	static private function get_columns($app, $table)
1251 1250
 	{
1252 1251
 		if ($table != 'egw_cal')
1253 1252
 		{
1254
-			$table_def = $GLOBALS['egw']->db->get_table_definitions($app,$table);
1253
+			$table_def = $GLOBALS['egw']->db->get_table_definitions($app, $table);
1255 1254
 			$cols = array_keys($table_def['fd']);
1256 1255
 		}
1257 1256
 		else
1258 1257
 		{
1259 1258
 			// special handling for egw_cal, as old databases have a different column order!!!
1260
-			$cols =& Api\Cache::getSession(__CLASS__,$table);
1259
+			$cols = & Api\Cache::getSession(__CLASS__, $table);
1261 1260
 
1262 1261
 			if (is_null($cols))
1263 1262
 			{
1264
-				$meta = $GLOBALS['egw']->db->metadata($table,true);
1263
+				$meta = $GLOBALS['egw']->db->metadata($table, true);
1265 1264
 				$cols = array_keys($meta['meta']);
1266 1265
 			}
1267 1266
 		}
@@ -1314,12 +1313,12 @@  discard block
 block discarded – undo
1314 1313
 	 * @param int &$etag etag=null etag to check or null, on return new etag
1315 1314
 	 * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise
1316 1315
 	 */
1317
-	function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null)
1316
+	function save($event, &$set_recurrences, &$set_recurrences_start = 0, $change_since = 0, &$etag = null)
1318 1317
 	{
1319 1318
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1320 1319
 		{
1321 1320
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1322
-			if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1321
+			if (empty($minimum_uid_length) || $minimum_uid_length <= 1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1323 1322
 		}
1324 1323
 		else
1325 1324
 		{
@@ -1330,7 +1329,7 @@  discard block
 block discarded – undo
1330 1329
 
1331 1330
 		//error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace());
1332 1331
 
1333
-		$cal_id = (int) $event['id'];
1332
+		$cal_id = (int)$event['id'];
1334 1333
 		unset($event['id']);
1335 1334
 		$set_recurrences = $set_recurrences || !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE;
1336 1335
 
@@ -1358,9 +1357,9 @@  discard block
 block discarded – undo
1358 1357
 		}
1359 1358
 
1360 1359
 		// add colum prefix 'cal_' if there's not already a 'recur_' prefix
1361
-		foreach($event as $col => $val)
1360
+		foreach ($event as $col => $val)
1362 1361
 		{
1363
-			if ($col[0] != '#' && substr($col,0,6) != 'recur_' && substr($col,0,6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name')
1362
+			if ($col[0] != '#' && substr($col, 0, 6) != 'recur_' && substr($col, 0, 6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name')
1364 1363
 			{
1365 1364
 				$event['cal_'.$col] = $val;
1366 1365
 				unset($event[$col]);
@@ -1370,13 +1369,12 @@  discard block
 block discarded – undo
1370 1369
 		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1371 1370
 		if (isset($event['cal_end']))
1372 1371
 		{
1373
-			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
1374
-				($event['recur_enddate'] ? $event['recur_enddate'] : null);
1372
+			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : ($event['recur_enddate'] ? $event['recur_enddate'] : null);
1375 1373
 		}
1376 1374
 		// ensure that we find mathing entries later on
1377 1375
 		if (!is_array($event['cal_category']))
1378 1376
 		{
1379
-			$categories = array_unique(explode(',',$event['cal_category']));
1377
+			$categories = array_unique(explode(',', $event['cal_category']));
1380 1378
 			sort($categories);
1381 1379
 		}
1382 1380
 		else
@@ -1385,7 +1383,7 @@  discard block
 block discarded – undo
1385 1383
 		}
1386 1384
 		sort($categories, SORT_NUMERIC);
1387 1385
 
1388
-		$event['cal_category'] = implode(',',$categories);
1386
+		$event['cal_category'] = implode(',', $categories);
1389 1387
 
1390 1388
 		// make sure recurring events never reference to an other recurrent event
1391 1389
 		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
@@ -1403,18 +1401,18 @@  discard block
 block discarded – undo
1403 1401
 			// read only timezone id, to check if it is changed
1404 1402
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1405 1403
 			{
1406
-				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1404
+				$old_tz_id = $this->db->select($this->cal_table, 'tz_id', $where, __LINE__, __FILE__, 'calendar')->fetchColumn();
1407 1405
 			}
1408 1406
 			if (!is_null($etag)) $where['cal_etag'] = $etag;
1409 1407
 
1410 1408
 			unset($event['cal_etag']);
1411
-			$event[] = 'cal_etag=cal_etag+1';	// always update the etag, even if none given to check
1409
+			$event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check
1412 1410
 
1413
-			$this->db->update($this->cal_table,$event,$where,__LINE__,__FILE__,'calendar');
1411
+			$this->db->update($this->cal_table, $event, $where, __LINE__, __FILE__, 'calendar');
1414 1412
 
1415 1413
 			if (!is_null($etag) && $this->db->affected_rows() < 1)
1416 1414
 			{
1417
-				return 0;	// wrong etag, someone else updated the entry
1415
+				return 0; // wrong etag, someone else updated the entry
1418 1416
 			}
1419 1417
 			if (!is_null($etag)) ++$etag;
1420 1418
 		}
@@ -1423,10 +1421,10 @@  discard block
 block discarded – undo
1423 1421
 			// new event
1424 1422
 			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1425 1423
 
1426
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1424
+			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL!
1427 1425
 
1428
-			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
1429
-			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id')))
1426
+			$this->db->insert($this->cal_table, $event, false, __LINE__, __FILE__, 'calendar');
1427
+			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table, 'cal_id')))
1430 1428
 			{
1431 1429
 				return false;
1432 1430
 			}
@@ -1436,7 +1434,7 @@  discard block
 block discarded – undo
1436 1434
 		// event without uid or not strong enough uid
1437 1435
 		if (!isset($event['cal_uid']) || strlen($event['cal_uid']) < $minimum_uid_length)
1438 1436
 		{
1439
-			$update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar',$cal_id);
1437
+			$update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar', $cal_id);
1440 1438
 		}
1441 1439
 		// set caldav_name, if not given by caller
1442 1440
 		if (empty($event['caldav_name']) && version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.003', '>='))
@@ -1445,37 +1443,37 @@  discard block
 block discarded – undo
1445 1443
 		}
1446 1444
 		if ($update)
1447 1445
 		{
1448
-			$this->db->update($this->cal_table, $update, array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar');
1446
+			$this->db->update($this->cal_table, $update, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
1449 1447
 		}
1450 1448
 
1451 1449
 		if ($event['recur_type'] == MCAL_RECUR_NONE)
1452 1450
 		{
1453
-			$this->db->delete($this->dates_table,array(
1451
+			$this->db->delete($this->dates_table, array(
1454 1452
 				'cal_id' => $cal_id),
1455
-				__LINE__,__FILE__,'calendar');
1453
+				__LINE__, __FILE__, 'calendar');
1456 1454
 
1457 1455
 			// delete all user-records, with recur-date != 0
1458
-			$this->db->delete($this->user_table,array(
1456
+			$this->db->delete($this->user_table, array(
1459 1457
 				'cal_id' => $cal_id, 'cal_recur_date != 0'),
1460
-				__LINE__,__FILE__,'calendar');
1458
+				__LINE__, __FILE__, 'calendar');
1461 1459
 
1462
-			$this->db->delete($this->repeats_table,array(
1460
+			$this->db->delete($this->repeats_table, array(
1463 1461
 				'cal_id' => $cal_id),
1464
-				__LINE__,__FILE__,'calendar');
1462
+				__LINE__, __FILE__, 'calendar');
1465 1463
 
1466 1464
 			// add exception marker to master, so participants added to exceptions *only* get found
1467 1465
 			if ($event['cal_reference'])
1468 1466
 			{
1469 1467
 				$master_participants = array();
1470
-				foreach($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array(
1468
+				foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array(
1471 1469
 					'cal_id' => $event['cal_reference'],
1472 1470
 					'cal_recur_date' => 0,
1473
-					"cal_status != 'X'",	// deleted need to be replaced with exception marker too
1471
+					"cal_status != 'X'", // deleted need to be replaced with exception marker too
1474 1472
 				), __LINE__, __FILE__, 'calendar') as $row)
1475 1473
 				{
1476 1474
 					$master_participants[] = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1477 1475
 				}
1478
-				foreach(array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid)
1476
+				foreach (array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid)
1479 1477
 				{
1480 1478
 					$user_type = $user_id = null;
1481 1479
 					self::split_user($uid, $user_type, $user_id, true);
@@ -1494,10 +1492,10 @@  discard block
 block discarded – undo
1494 1492
 		else // write information about recuring event, if recur_type is present in the array
1495 1493
 		{
1496 1494
 			// fetch information about the currently saved (old) event
1497
-			$old_min = (int) $this->db->select($this->dates_table,'MIN(cal_start)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
1498
-			$old_duration = (int) $this->db->select($this->dates_table,'MIN(cal_end)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn() - $old_min;
1495
+			$old_min = (int)$this->db->select($this->dates_table, 'MIN(cal_start)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
1496
+			$old_duration = (int)$this->db->select($this->dates_table, 'MIN(cal_end)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn() - $old_min;
1499 1497
 			$old_exceptions = array();
1500
-			foreach($this->db->select($this->dates_table, 'cal_start', array(
1498
+			foreach ($this->db->select($this->dates_table, 'cal_start', array(
1501 1499
 				'cal_id' => $cal_id,
1502 1500
 				'recur_exception' => true
1503 1501
 			), __LINE__, __FILE__, false, 'ORDER BY cal_start', 'calendar') as $row)
@@ -1516,8 +1514,8 @@  discard block
 block discarded – undo
1516 1514
 				'cal_recur_date' => 0,
1517 1515
 			);
1518 1516
 			$old_participants = array();
1519
-			foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where,
1520
-				__LINE__,__FILE__,false,'','calendar') as $row)
1517
+			foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where,
1518
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
1521 1519
 			{
1522 1520
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1523 1521
 				$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
@@ -1527,7 +1525,7 @@  discard block
 block discarded – undo
1527 1525
 			// re-check: did so much recurrence data change that we have to rebuild it from scratch?
1528 1526
 			if (!$set_recurrences)
1529 1527
 			{
1530
-				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) ||
1528
+				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int)$event['cal_start']) ||
1531 1529
 				    $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1532 1530
 					(int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id;
1533 1531
 			}
@@ -1536,22 +1534,22 @@  discard block
 block discarded – undo
1536 1534
 			{
1537 1535
 				// too much recurrence data has changed, we have to do a rebuild from scratch
1538 1536
 				// delete all, but the lowest dates record
1539
-				$this->db->delete($this->dates_table,array(
1537
+				$this->db->delete($this->dates_table, array(
1540 1538
 					'cal_id' => $cal_id,
1541 1539
 					'cal_start > '.(int)$old_min,
1542
-				),__LINE__,__FILE__,'calendar');
1540
+				), __LINE__, __FILE__, 'calendar');
1543 1541
 
1544 1542
 				// delete all user-records, with recur-date != 0
1545
-				$this->db->delete($this->user_table,array(
1543
+				$this->db->delete($this->user_table, array(
1546 1544
 					'cal_id' => $cal_id,
1547 1545
 					'cal_recur_date != 0',
1548
-				),__LINE__,__FILE__,'calendar');
1546
+				), __LINE__, __FILE__, 'calendar');
1549 1547
 			}
1550 1548
 			else
1551 1549
 			{
1552 1550
 				// we adjust some possibly changed recurrences manually
1553 1551
 				// deleted exceptions: re-insert recurrences into the user and dates table
1554
-				if (count($deleted_exceptions = array_diff($old_exceptions,$event['recur_exception'])))
1552
+				if (count($deleted_exceptions = array_diff($old_exceptions, $event['recur_exception'])))
1555 1553
 				{
1556 1554
 					if (isset($event['cal_participants']))
1557 1555
 					{
@@ -1562,7 +1560,7 @@  discard block
 block discarded – undo
1562 1560
 						// use old default
1563 1561
 						$participants = $old_participants;
1564 1562
 					}
1565
-					foreach($deleted_exceptions as $id => $deleted_exception)
1563
+					foreach ($deleted_exceptions as $id => $deleted_exception)
1566 1564
 					{
1567 1565
 						// rebuild participants for the re-inserted recurrence
1568 1566
 						$this->recurrence($cal_id, $deleted_exception, $deleted_exception + $old_duration, $participants);
@@ -1570,24 +1568,24 @@  discard block
 block discarded – undo
1570 1568
 				}
1571 1569
 
1572 1570
 				// check if recurrence enddate was adjusted
1573
-				if(isset($event['recur_enddate']))
1571
+				if (isset($event['recur_enddate']))
1574 1572
 				{
1575 1573
 					// recurrences need to be truncated
1576
-					if((int)$event['recur_enddate'] > 0 &&
1574
+					if ((int)$event['recur_enddate'] > 0 &&
1577 1575
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1578 1576
 					)
1579 1577
 					{
1580
-						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1581
-						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1578
+						$this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar');
1579
+						$this->db->delete($this->dates_table, array('cal_id' => $cal_id, 'cal_start >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar');
1582 1580
 					}
1583 1581
 
1584 1582
 					// recurrences need to be expanded
1585
-					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1583
+					if (((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1586 1584
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1587 1585
 					)
1588 1586
 					{
1589 1587
 						$set_recurrences = true;
1590
-						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1588
+						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1 * DAY_s);
1591 1589
 					}
1592 1590
 					//error_log(__METHOD__."() event[recur_enddate]=$event[recur_enddate], old_repeats[recur_enddate]=$old_repeats[recur_enddate] --> set_recurrences=".array2string($set_recurrences).", set_recurrences_start=$set_recurrences_start");
1593 1591
 				}
@@ -1596,9 +1594,9 @@  discard block
 block discarded – undo
1596 1594
 				if (count($event['recur_exception']))
1597 1595
 				{
1598 1596
 					// added and existing exceptions: delete the execeptions from the user table, it could be the first time
1599
-					$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date' => $event['recur_exception']),__LINE__,__FILE__,'calendar');
1597
+					$this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date' => $event['recur_exception']), __LINE__, __FILE__, 'calendar');
1600 1598
 					// update recur_exception flag based on current exceptions
1601
-					$this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table,array(
1599
+					$this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table, array(
1602 1600
 						'cal_start' => $event['recur_exception'],
1603 1601
 					)), array(
1604 1602
 						'cal_id' => $cal_id,
@@ -1607,25 +1605,25 @@  discard block
 block discarded – undo
1607 1605
 			}
1608 1606
 
1609 1607
 			// write the repeats table
1610
-			unset($event[0]);	// unset the 'etag=etag+1', as it's not in the repeats table
1611
-			$this->db->insert($this->repeats_table,$event,array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar');
1608
+			unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table
1609
+			$this->db->insert($this->repeats_table, $event, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
1612 1610
 		}
1613 1611
 		// update start- and endtime if present in the event-array, evtl. we need to move all recurrences
1614 1612
 		if (isset($event['cal_start']) && isset($event['cal_end']))
1615 1613
 		{
1616
-			$this->move($cal_id,$event['cal_start'],$event['cal_end'],!$cal_id ? false : $change_since, $old_min, $old_min +  $old_duration);
1614
+			$this->move($cal_id, $event['cal_start'], $event['cal_end'], !$cal_id ? false : $change_since, $old_min, $old_min + $old_duration);
1617 1615
 		}
1618 1616
 		// update participants if present in the event-array
1619 1617
 		if (isset($event['cal_participants']))
1620 1618
 		{
1621
-			$this->participants($cal_id,$event['cal_participants'],!$cal_id ? false : $change_since);
1619
+			$this->participants($cal_id, $event['cal_participants'], !$cal_id ? false : $change_since);
1622 1620
 		}
1623 1621
 		// Custom fields
1624
-		foreach($event as $name => $value)
1622
+		foreach ($event as $name => $value)
1625 1623
 		{
1626 1624
 			if ($name[0] == '#')
1627 1625
 			{
1628
-				if (is_array($value) && array_key_exists('id',$value))
1626
+				if (is_array($value) && array_key_exists('id', $value))
1629 1627
 				{
1630 1628
 					//error_log(__METHOD__.__LINE__."$name => ".array2string($value).function_backtrace());
1631 1629
 					$value = $value['id'];
@@ -1633,19 +1631,19 @@  discard block
 block discarded – undo
1633 1631
 				}
1634 1632
 				if ($value)
1635 1633
 				{
1636
-					$this->db->insert($this->extra_table,array(
1637
-						'cal_extra_value'	=> is_array($value) ? implode(',',$value) : $value,
1638
-					),array(
1634
+					$this->db->insert($this->extra_table, array(
1635
+						'cal_extra_value'	=> is_array($value) ? implode(',', $value) : $value,
1636
+					), array(
1639 1637
 						'cal_id'			=> $cal_id,
1640
-						'cal_extra_name'	=> substr($name,1),
1641
-					),__LINE__,__FILE__,'calendar');
1638
+						'cal_extra_name'	=> substr($name, 1),
1639
+					), __LINE__, __FILE__, 'calendar');
1642 1640
 				}
1643 1641
 				else
1644 1642
 				{
1645
-					$this->db->delete($this->extra_table,array(
1643
+					$this->db->delete($this->extra_table, array(
1646 1644
 						'cal_id'			=> $cal_id,
1647
-						'cal_extra_name'	=> substr($name,1),
1648
-					),__LINE__,__FILE__,'calendar');
1645
+						'cal_extra_name'	=> substr($name, 1),
1646
+					), __LINE__, __FILE__, 'calendar');
1649 1647
 				}
1650 1648
 			}
1651 1649
 		}
@@ -1656,9 +1654,9 @@  discard block
 block discarded – undo
1656 1654
 			{
1657 1655
 				if ($alarm['id'] && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0)
1658 1656
 				{
1659
-					unset($alarm['id']);	// unset the temporary id to add the alarm
1657
+					unset($alarm['id']); // unset the temporary id to add the alarm
1660 1658
 				}
1661
-				if(!isset($alarm['offset']))
1659
+				if (!isset($alarm['offset']))
1662 1660
 				{
1663 1661
 					$alarm['offset'] = $event['cal_start'] - $alarm['time'];
1664 1662
 				}
@@ -1669,14 +1667,14 @@  discard block
 block discarded – undo
1669 1667
 
1670 1668
 				if ($alarm['time'] < time() && !self::shift_alarm($event, $alarm))
1671 1669
 				{
1672
-					continue;	// pgoerzen: don't add alarm in the past
1670
+					continue; // pgoerzen: don't add alarm in the past
1673 1671
 				}
1674
-				$this->save_alarm($cal_id, $alarm, false);	// false: not update modified, we do it anyway
1672
+				$this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway
1675 1673
 			}
1676 1674
 		}
1677 1675
 		if (is_null($etag))
1678 1676
 		{
1679
-			$etag = $this->db->select($this->cal_table,'cal_etag',array('cal_id' => $cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
1677
+			$etag = $this->db->select($this->cal_table, 'cal_etag', array('cal_id' => $cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
1680 1678
 		}
1681 1679
 
1682 1680
 		// if event is an exception: update modified of master, to force etag, ctag and sync-token change
@@ -1696,7 +1694,7 @@  discard block
 block discarded – undo
1696 1694
 	 *	are dealing with, default is now.
1697 1695
 	 * @return boolean true if alarm could be shifted, false if not
1698 1696
 	 */
1699
-	public static function shift_alarm(array $_event, array &$alarm, $timestamp=null)
1697
+	public static function shift_alarm(array $_event, array &$alarm, $timestamp = null)
1700 1698
 	{
1701 1699
 		if ($_event['recur_type'] == MCAL_RECUR_NONE)
1702 1700
 		{
@@ -1707,7 +1705,7 @@  discard block
 block discarded – undo
1707 1705
 		$rrule = calendar_rrule::event2rrule($event, false);
1708 1706
 		foreach ($rrule as $time)
1709 1707
 		{
1710
-			if ($start < ($ts = Api\DateTime::to($time,'server')))
1708
+			if ($start < ($ts = Api\DateTime::to($time, 'server')))
1711 1709
 			{
1712 1710
 				$alarm['time'] = $ts - $alarm['offset'];
1713 1711
 				return true;
@@ -1728,34 +1726,34 @@  discard block
 block discarded – undo
1728 1726
 	 * @todo Recalculate recurrences, if timezone changes
1729 1727
 	 * @return int|boolean number of moved recurrences or false on error
1730 1728
 	 */
1731
-	function move($cal_id,$start,$end,$change_since=0,$old_start=0,$old_end=0)
1729
+	function move($cal_id, $start, $end, $change_since = 0, $old_start = 0, $old_end = 0)
1732 1730
 	{
1733 1731
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1734 1732
 
1735
-		if (!(int) $cal_id) return false;
1733
+		if (!(int)$cal_id) return false;
1736 1734
 
1737 1735
 		if (!$old_start)
1738 1736
 		{
1739
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1740
-				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1737
+			if ($change_since !== false) $row = $this->db->select($this->dates_table, 'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1738
+				array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetch();
1741 1739
 			// if no recurrence found, create one with the new dates
1742 1740
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1743 1741
 			{
1744
-				$this->db->insert($this->dates_table,array(
1742
+				$this->db->insert($this->dates_table, array(
1745 1743
 					'cal_id'    => $cal_id,
1746 1744
 					'cal_start' => $start,
1747 1745
 					'cal_end'   => $end,
1748
-				),false,__LINE__,__FILE__,'calendar');
1746
+				), false, __LINE__, __FILE__, 'calendar');
1749 1747
 
1750 1748
 				return 1;
1751 1749
 			}
1752
-			$move_start = (int) ($start-$row['cal_start']);
1753
-			$move_end   = (int) ($end-$row['cal_end']);
1750
+			$move_start = (int)($start - $row['cal_start']);
1751
+			$move_end   = (int)($end - $row['cal_end']);
1754 1752
 		}
1755 1753
 		else
1756 1754
 		{
1757
-			$move_start = (int) ($start-$old_start);
1758
-			$move_end   = (int) ($end-$old_end);
1755
+			$move_start = (int)($start - $old_start);
1756
+			$move_end   = (int)($end - $old_end);
1759 1757
 		}
1760 1758
 		$where = 'cal_id='.(int)$cal_id;
1761 1759
 
@@ -1763,13 +1761,13 @@  discard block
 block discarded – undo
1763 1761
 		{
1764 1762
 			// move the recur-date of the participants
1765 1763
 			$this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1766
-				((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__);
1764
+				((int)$change_since ? '>= '.(int)$change_since : '!= 0'), __LINE__, __FILE__);
1767 1765
 		}
1768 1766
 		if ($move_start || $move_end)
1769 1767
 		{
1770 1768
 			// move the event and it's recurrences
1771 1769
 			$this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1772
-				((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__);
1770
+				((int)$change_since ? ' AND cal_start >= '.(int)$change_since : ''), __LINE__, __FILE__);
1773 1771
 		}
1774 1772
 		return $this->db->affected_rows();
1775 1773
 	}
@@ -1788,8 +1786,7 @@  discard block
 block discarded – undo
1788 1786
 		}
1789 1787
 		if (is_array($attendee))
1790 1788
 		{
1791
-			$email = !empty($attendee['email']) ? $user_attendee['email'] :
1792
-				(strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']);
1789
+			$email = !empty($attendee['email']) ? $user_attendee['email'] : (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']);
1793 1790
 			$attendee = !empty($attendee['cn']) ? $attendee['cn'].' <'.$email.'>' : $email;
1794 1791
 		}
1795 1792
 		return $attendee;
@@ -1802,11 +1799,11 @@  discard block
 block discarded – undo
1802 1799
 	 * @param string|array $attendee attendee information: email, json or array with attr cn and url
1803 1800
 	 * @return string|int combined id
1804 1801
 	 */
1805
-	static function combine_user($user_type, $user_id, $attendee=null)
1802
+	static function combine_user($user_type, $user_id, $attendee = null)
1806 1803
 	{
1807 1804
 		if (!$user_type || $user_type == 'u')
1808 1805
 		{
1809
-			return (int) $user_id;
1806
+			return (int)$user_id;
1810 1807
 		}
1811 1808
 		if ($user_type == 'e' && $attendee)
1812 1809
 		{
@@ -1826,12 +1823,12 @@  discard block
 block discarded – undo
1826 1823
 	 * @param string|int &$user_id id
1827 1824
 	 * @param boolean $md5_email =false md5 hash user_id for email / user_type=="e"
1828 1825
 	 */
1829
-	static function split_user($uid, &$user_type, &$user_id, $md5_email=false)
1826
+	static function split_user($uid, &$user_type, &$user_id, $md5_email = false)
1830 1827
 	{
1831 1828
 		if (is_numeric($uid))
1832 1829
 		{
1833 1830
 			$user_type = 'u';
1834
-			$user_id = (int) $uid;
1831
+			$user_id = (int)$uid;
1835 1832
 		}
1836 1833
 		// create md5 hash from lowercased and trimed raw email ("[email protected]", not "Ralf Becker <[email protected]>")
1837 1834
 		elseif ($md5_email && $uid[0] == 'e')
@@ -1845,7 +1842,7 @@  discard block
 block discarded – undo
1845 1842
 		else
1846 1843
 		{
1847 1844
 			$user_type = $uid[0];
1848
-			$user_id = substr($uid,1);
1845
+			$user_id = substr($uid, 1);
1849 1846
 		}
1850 1847
 	}
1851 1848
 
@@ -1857,7 +1854,7 @@  discard block
 block discarded – undo
1857 1854
 	 * @param string $role ='REQ-PARTICIPANT'
1858 1855
 	 * @return string
1859 1856
 	 */
1860
-	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1857
+	static function combine_status($status, $quantity = 1, $role = 'REQ-PARTICIPANT')
1861 1858
 	{
1862 1859
 		if ((int)$quantity > 1) $status .= (int)$quantity;
1863 1860
 		if ($role != 'REQ-PARTICIPANT') $status .= $role;
@@ -1873,13 +1870,13 @@  discard block
 block discarded – undo
1873 1870
 	 * @param string &$role=null only O: role
1874 1871
 	 * @return string status U, T, A or R, same as $status parameter on return
1875 1872
 	 */
1876
-	static function split_status(&$status,&$quantity=null,&$role=null)
1873
+	static function split_status(&$status, &$quantity = null, &$role = null)
1877 1874
 	{
1878 1875
 		$quantity = 1;
1879 1876
 		$role = 'REQ-PARTICIPANT';
1880 1877
 		//error_log(__METHOD__.__LINE__.array2string($status));
1881 1878
 		$matches = null;
1882
-		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1879
+		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/', $status, $matches))
1883 1880
 		{
1884 1881
 			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1885 1882
 			if ($matches[2]) $role = $matches[2];
@@ -1906,14 +1903,14 @@  discard block
 block discarded – undo
1906 1903
 	 *		true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants)
1907 1904
 	 * @return int|boolean number of updated recurrences or false on error
1908 1905
 	 */
1909
-	function participants($cal_id,$participants,$change_since=0,$add_only=false)
1906
+	function participants($cal_id, $participants, $change_since = 0, $add_only = false)
1910 1907
 	{
1911 1908
 		//error_log(__METHOD__."($cal_id,".array2string($participants).",$change_since,$add_only");
1912 1909
 
1913 1910
 		$recurrences = array();
1914 1911
 
1915 1912
 		// remove group-invitations, they are NOT stored in the db
1916
-		foreach($participants as $uid => $status)
1913
+		foreach ($participants as $uid => $status)
1917 1914
 		{
1918 1915
 			if ($status[0] == 'G')
1919 1916
 			{
@@ -1922,7 +1919,7 @@  discard block
 block discarded – undo
1922 1919
 		}
1923 1920
 		$where = array('cal_id' => $cal_id);
1924 1921
 
1925
-		if ((int) $change_since)
1922
+		if ((int)$change_since)
1926 1923
 		{
1927 1924
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')';
1928 1925
 		}
@@ -1930,31 +1927,31 @@  discard block
 block discarded – undo
1930 1927
 		if ($change_since !== false)
1931 1928
 		{
1932 1929
 			// find all existing recurrences
1933
-			foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row)
1930
+			foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row)
1934 1931
 			{
1935 1932
 				$recurrences[] = $row['cal_recur_date'];
1936 1933
 			}
1937 1934
 
1938 1935
 			// update existing entries
1939
-			$existing_entries = $this->db->select($this->user_table,'*',$where,__LINE__,__FILE__,false,'ORDER BY cal_recur_date DESC','calendar');
1936
+			$existing_entries = $this->db->select($this->user_table, '*', $where, __LINE__, __FILE__, false, 'ORDER BY cal_recur_date DESC', 'calendar');
1940 1937
 
1941 1938
 			// create a full list of participants which already exist in the db
1942 1939
 			// with status, quantity and role of the earliest recurence
1943 1940
 			$old_participants = array();
1944
-			foreach($existing_entries as $row)
1941
+			foreach ($existing_entries as $row)
1945 1942
 			{
1946 1943
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1947 1944
 				if ($row['cal_recur_date'] || !isset($old_participants[$uid]))
1948 1945
 				{
1949
-					$old_participants[$uid] = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
1946
+					$old_participants[$uid] = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
1950 1947
 				}
1951 1948
 			}
1952 1949
 
1953 1950
 			// tag participants which should be deleted
1954
-			if($add_only === false)
1951
+			if ($add_only === false)
1955 1952
 			{
1956 1953
 				$deleted = array();
1957
-				foreach($existing_entries as $row)
1954
+				foreach ($existing_entries as $row)
1958 1955
 				{
1959 1956
 					$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1960 1957
 					// delete not longer set participants
@@ -1967,7 +1964,7 @@  discard block
 block discarded – undo
1967 1964
 
1968 1965
 			// only keep added OR status (incl. quantity!) changed participants for further steps
1969 1966
 			// we do not touch unchanged (!) existing ones
1970
-			foreach($participants as $uid => $status)
1967
+			foreach ($participants as $uid => $status)
1971 1968
 			{
1972 1969
 				if ($old_participants[$uid] === $status)
1973 1970
 				{
@@ -1979,46 +1976,46 @@  discard block
 block discarded – undo
1979 1976
 			if ($add_only === false && count($deleted))
1980 1977
 			{
1981 1978
 				$to_or = array();
1982
-				$table_def = $this->db->get_table_definitions('calendar',$this->user_table);
1983
-				foreach($deleted as $type => $ids)
1979
+				$table_def = $this->db->get_table_definitions('calendar', $this->user_table);
1980
+				foreach ($deleted as $type => $ids)
1984 1981
 				{
1985
-					$to_or[] = $this->db->expression($table_def,array(
1982
+					$to_or[] = $this->db->expression($table_def, array(
1986 1983
 						'cal_user_type' => $type,
1987 1984
 						'cal_user_id'   => $ids,
1988 1985
 					));
1989 1986
 				}
1990
-				$where[] = '('.implode(' OR ',$to_or).')';
1991
-				$where[] = "cal_status!='E'";	// do NOT delete exception marker
1992
-				$this->db->update($this->user_table,array('cal_status'=>'X'),$where,__LINE__,__FILE__,'calendar');
1987
+				$where[] = '('.implode(' OR ', $to_or).')';
1988
+				$where[] = "cal_status!='E'"; // do NOT delete exception marker
1989
+				$this->db->update($this->user_table, array('cal_status'=>'X'), $where, __LINE__, __FILE__, 'calendar');
1993 1990
 			}
1994 1991
 		}
1995 1992
 
1996 1993
 		if (count($participants))	// participants which need to be added
1997 1994
 		{
1998
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
1995
+			if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence
1999 1996
 
2000 1997
 			$delete_deleted = array();
2001 1998
 
2002 1999
 			// update participants
2003
-			foreach($participants as $uid => $status)
2000
+			foreach ($participants as $uid => $status)
2004 2001
 			{
2005 2002
 				$type = $id = $quantity = $role = null;
2006 2003
 				self::split_user($uid, $type, $id, true);
2007
-				self::split_status($status,$quantity,$role);
2004
+				self::split_status($status, $quantity, $role);
2008 2005
 				$set = array(
2009 2006
 					'cal_status'	  => $status,
2010 2007
 					'cal_quantity'	  => $quantity,
2011 2008
 					'cal_role'        => $role,
2012 2009
 					'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null,
2013 2010
 				);
2014
-				foreach($recurrences as $recur_date)
2011
+				foreach ($recurrences as $recur_date)
2015 2012
 				{
2016
-					$this->db->insert($this->user_table,$set,array(
2013
+					$this->db->insert($this->user_table, $set, array(
2017 2014
 						'cal_id'	      => $cal_id,
2018 2015
 						'cal_recur_date'  => $recur_date,
2019 2016
 						'cal_user_type'   => $type,
2020 2017
 						'cal_user_id' 	  => $id,
2021
-					),__LINE__,__FILE__,'calendar');
2018
+					), __LINE__, __FILE__, 'calendar');
2022 2019
 				}
2023 2020
 				// for new or changed group-invitations, remove previously deleted members, so they show up again
2024 2021
 				if ($uid < 0)
@@ -2028,13 +2025,13 @@  discard block
 block discarded – undo
2028 2025
 			}
2029 2026
 			if ($delete_deleted)
2030 2027
 			{
2031
-				$this->db->delete($this->user_table, $where=array(
2028
+				$this->db->delete($this->user_table, $where = array(
2032 2029
 					'cal_id' => $cal_id,
2033 2030
 					'cal_recur_date' => $recurrences,
2034 2031
 					'cal_user_type' => 'u',
2035 2032
 					'cal_user_id' => array_unique($delete_deleted),
2036 2033
 					'cal_status' => 'X',
2037
-				),__LINE__,__FILE__,'calendar');
2034
+				), __LINE__, __FILE__, 'calendar');
2038 2035
 				//error_log(__METHOD__."($cal_id, ".array2string($participants).", since=$change_since, add_only=$add_only) db->delete('$this->user_table', ".array2string($where).") affected ".$this->db->affected_rows().' rows');
2039 2036
 			}
2040 2037
 		}
@@ -2053,7 +2050,7 @@  discard block
 block discarded – undo
2053 2050
 	 * @param string $attendee =null extra attendee information to set for all types (incl. accounts!)
2054 2051
 	 * @return int number of changed recurrences
2055 2052
 	 */
2056
-	function set_status($cal_id,$user_type,$user_id,$status,$recur_date=0,$role=null,$attendee=null)
2053
+	function set_status($cal_id, $user_type, $user_id, $status, $recur_date = 0, $role = null, $attendee = null)
2057 2054
 	{
2058 2055
 		static $status_code_short = array(
2059 2056
 			REJECTED 	=> 'R',
@@ -2078,7 +2075,7 @@  discard block
 block discarded – undo
2078 2075
 			'cal_user_type'	=> $user_type,
2079 2076
 			'cal_user_id'   => $user_id_md5,
2080 2077
 		);
2081
-		if ((int) $recur_date)
2078
+		if ((int)$recur_date)
2082 2079
 		{
2083 2080
 			$where['cal_recur_date'] = $recur_date;
2084 2081
 		}
@@ -2089,7 +2086,7 @@  discard block
 block discarded – undo
2089 2086
 
2090 2087
 		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2091 2088
 		{
2092
-			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2089
+			$this->db->delete($this->user_table, $where, __LINE__, __FILE__, 'calendar');
2093 2090
 			$ret = $this->db->affected_rows();
2094 2091
 		}
2095 2092
 		else
@@ -2097,7 +2094,7 @@  discard block
 block discarded – undo
2097 2094
 			$set = array('cal_status' => $status);
2098 2095
 			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2099 2096
 			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2100
-			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2097
+			$this->db->insert($this->user_table, $set, $where, __LINE__, __FILE__, 'calendar');
2101 2098
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2102 2099
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
2103 2100
 			{
@@ -2110,7 +2107,7 @@  discard block
 block discarded – undo
2110 2107
 		// update modified and modifier in main table
2111 2108
 		if ($ret)
2112 2109
 		{
2113
-			$this->updateModified($cal_id, true);	// true = update series master too
2110
+			$this->updateModified($cal_id, true); // true = update series master too
2114 2111
 		}
2115 2112
 		//error_log(__METHOD__."($cal_id,$user_type,$user_id,$status,$recur_date) = $ret");
2116 2113
 		return $ret;
@@ -2125,7 +2122,7 @@  discard block
 block discarded – undo
2125 2122
 	 * @param array $participants uid => status pairs
2126 2123
 	 * @param boolean $exception =null true or false to set recure_exception flag, null leave it unchanged (new are by default no exception)
2127 2124
 	 */
2128
-	function recurrence($cal_id,$start,$end,$participants,$exception=null)
2125
+	function recurrence($cal_id, $start, $end, $participants, $exception = null)
2129 2126
 	{
2130 2127
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2131 2128
 		$update = array('cal_end' => $end);
@@ -2134,7 +2131,7 @@  discard block
 block discarded – undo
2134 2131
 		$this->db->insert($this->dates_table, $update, array(
2135 2132
 			'cal_id' => $cal_id,
2136 2133
 			'cal_start'  => $start,
2137
-		),__LINE__,__FILE__,'calendar');
2134
+		), __LINE__, __FILE__, 'calendar');
2138 2135
 
2139 2136
 		if (!is_array($participants))
2140 2137
 		{
@@ -2142,26 +2139,26 @@  discard block
 block discarded – undo
2142 2139
 		}
2143 2140
 		if ($exception !== true)
2144 2141
 		{
2145
-			foreach($participants as $uid => $status)
2142
+			foreach ($participants as $uid => $status)
2146 2143
 			{
2147
-				if ($status == 'G') continue;	// dont save group-invitations
2144
+				if ($status == 'G') continue; // dont save group-invitations
2148 2145
 
2149 2146
 				$type = '';
2150 2147
 				$id = null;
2151 2148
 				self::split_user($uid, $type, $id, true);
2152 2149
 				$quantity = $role = null;
2153
-				self::split_status($status,$quantity,$role);
2154
-				$this->db->insert($this->user_table,array(
2150
+				self::split_status($status, $quantity, $role);
2151
+				$this->db->insert($this->user_table, array(
2155 2152
 					'cal_status'	=> $status,
2156 2153
 					'cal_quantity'	=> $quantity,
2157 2154
 					'cal_role'		=> $role,
2158 2155
 					'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null,
2159
-				),array(
2156
+				), array(
2160 2157
 					'cal_id'		 => $cal_id,
2161 2158
 					'cal_recur_date' => $start,
2162 2159
 					'cal_user_type'  => $type,
2163 2160
 					'cal_user_id' 	 => $id,
2164
-				),__LINE__,__FILE__,'calendar');
2161
+				), __LINE__, __FILE__, 'calendar');
2165 2162
 			}
2166 2163
 		}
2167 2164
 	}
@@ -2175,7 +2172,7 @@  discard block
 block discarded – undo
2175 2172
 	function unfinished_recuring($time)
2176 2173
 	{
2177 2174
 		$ids = array();
2178
-		foreach($rs=$this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start",
2175
+		foreach ($rs = $this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start",
2179 2176
 			'(range_end IS NULL OR range_end > '.(int)$time.')',
2180 2177
 			__LINE__, __FILE__, false, "GROUP BY $this->repeats_table.cal_id,range_end", 'calendar', 0,
2181 2178
 			" JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id".
@@ -2201,9 +2198,9 @@  discard block
 block discarded – undo
2201 2198
 		// update timestamp of series master, updates own timestamp too, which does not hurt ;-)
2202 2199
 		$this->updateModified($cal_id, true);
2203 2200
 
2204
-		foreach($this->all_tables as $table)
2201
+		foreach ($this->all_tables as $table)
2205 2202
 		{
2206
-			$this->db->delete($table,array('cal_id'=>$cal_id),__LINE__,__FILE__,'calendar');
2203
+			$this->db->delete($table, array('cal_id'=>$cal_id), __LINE__, __FILE__, 'calendar');
2207 2204
 		}
2208 2205
 	}
2209 2206
 
@@ -2219,19 +2216,19 @@  discard block
 block discarded – undo
2219 2216
 	function purge($date)
2220 2217
 	{
2221 2218
 		// with new range_end we simple delete all with range_end < $date (range_end NULL is never returned)
2222
-		foreach($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row)
2219
+		foreach ($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row)
2223 2220
 		{
2224 2221
 			//echo __METHOD__." About to delete".$row['cal_id']."\r\n";
2225
-			foreach($this->all_tables as $table)
2222
+			foreach ($this->all_tables as $table)
2226 2223
 			{
2227 2224
 				$this->db->delete($table, array('cal_id'=>$row['cal_id']), __LINE__, __FILE__, 'calendar');
2228 2225
 			}
2229 2226
 			// handle sync
2230
-			$this->db->update('egw_api_content_history',array(
2227
+			$this->db->update('egw_api_content_history', array(
2231 2228
 				'sync_deleted' => time(),
2232
-			),array(
2229
+			), array(
2233 2230
 				'sync_appname' => 'calendar',
2234
-				'sync_contentid' => $row['cal_id'],	// sync_contentid is varchar(60)!
2231
+				'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)!
2235 2232
 			), __LINE__, __FILE__);
2236 2233
 			// handle links
2237 2234
 			Link::unlink('', 'calendar', $row['cal_id']);
@@ -2254,23 +2251,23 @@  discard block
 block discarded – undo
2254 2251
 	 * @param boolean $update_cache =null true: re-read given $cal_id, false: delete given $cal_id
2255 2252
 	 * @return array of (cal_id => array of) alarms with alarm-id as key
2256 2253
 	 */
2257
-	function read_alarms($cal_id, $update_cache=null)
2254
+	function read_alarms($cal_id, $update_cache = null)
2258 2255
 	{
2259 2256
 		if (!isset(self::$alarm_cache) && is_array($cal_id))
2260 2257
 		{
2261 2258
 			self::$alarm_cache = array();
2262 2259
 			if (($jobs = $this->async->read('cal:%')))
2263 2260
 			{
2264
-				foreach($jobs as $id => $job)
2261
+				foreach ($jobs as $id => $job)
2265 2262
 				{
2266
-					$alarm         = $job['data'];	// text, enabled
2263
+					$alarm         = $job['data']; // text, enabled
2267 2264
 					$alarm['id']   = $id;
2268 2265
 					$alarm['time'] = $job['next'];
2269 2266
 
2270 2267
 					self::$alarm_cache[$alarm['cal_id']][$id] = $alarm;
2271 2268
 				}
2272 2269
 			}
2273
-			unset($update_cache);	// just done
2270
+			unset($update_cache); // just done
2274 2271
 		}
2275 2272
 		$alarms = array();
2276 2273
 
@@ -2278,13 +2275,13 @@  discard block
 block discarded – undo
2278 2275
 		{
2279 2276
 			if (isset($update_cache))
2280 2277
 			{
2281
-				foreach((array)$cal_id as $id)
2278
+				foreach ((array)$cal_id as $id)
2282 2279
 				{
2283 2280
 					if ($update_cache === false)
2284 2281
 					{
2285 2282
 						unset(self::$alarm_cache[$cal_id]);
2286 2283
 					}
2287
-					elseif($update_cache === true)
2284
+					elseif ($update_cache === true)
2288 2285
 					{
2289 2286
 						self::$alarm_cache[$cal_id] = $this->read_alarms_nocache($cal_id);
2290 2287
 					}
@@ -2296,7 +2293,7 @@  discard block
 block discarded – undo
2296 2293
 			}
2297 2294
 			else
2298 2295
 			{
2299
-				foreach($cal_id as $id)
2296
+				foreach ($cal_id as $id)
2300 2297
 				{
2301 2298
 					$alarms[$id] = (array)self::$alarm_cache[$id];
2302 2299
 				}
@@ -2311,9 +2308,9 @@  discard block
 block discarded – undo
2311 2308
 	{
2312 2309
 		if (($jobs = $this->async->read('cal:'.(int)$cal_id.':%')))
2313 2310
 		{
2314
-			foreach($jobs as $id => $job)
2311
+			foreach ($jobs as $id => $job)
2315 2312
 			{
2316
-				$alarm         = $job['data'];	// text, enabled
2313
+				$alarm         = $job['data']; // text, enabled
2317 2314
 				$alarm['id']   = $id;
2318 2315
 				$alarm['time'] = $job['next'];
2319 2316
 
@@ -2336,8 +2333,8 @@  discard block
 block discarded – undo
2336 2333
 		{
2337 2334
 			return False;
2338 2335
 		}
2339
-		list($alarm_id,$job) = each($jobs);
2340
-		$alarm         = $job['data'];	// text, enabled
2336
+		list($alarm_id, $job) = each($jobs);
2337
+		$alarm         = $job['data']; // text, enabled
2341 2338
 		$alarm['id']   = $alarm_id;
2342 2339
 		$alarm['time'] = $job['next'];
2343 2340
 
@@ -2353,12 +2350,12 @@  discard block
 block discarded – undo
2353 2350
 	 * @param boolean $update_modified =true call update modified, default true
2354 2351
 	 * @return string id of the alarm
2355 2352
 	 */
2356
-	function save_alarm($cal_id, $alarm, $update_modified=true)
2353
+	function save_alarm($cal_id, $alarm, $update_modified = true)
2357 2354
 	{
2358 2355
 		//error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace());
2359 2356
 		if (!($id = $alarm['id']))
2360 2357
 		{
2361
-			$alarms = $this->read_alarms($cal_id);	// find a free alarm#
2358
+			$alarms = $this->read_alarms($cal_id); // find a free alarm#
2362 2359
 			$n = count($alarms);
2363 2360
 			do
2364 2361
 			{
@@ -2371,12 +2368,12 @@  discard block
 block discarded – undo
2371 2368
 		{
2372 2369
 			$this->async->cancel_timer($id);
2373 2370
 		}
2374
-		$alarm['cal_id'] = $cal_id;		// we need the back-reference
2371
+		$alarm['cal_id'] = $cal_id; // we need the back-reference
2375 2372
 		// add an alarm uid, if none is given
2376 2373
 		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
2377 2374
 		//error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace());
2378 2375
 		// allways store job with the alarm owner as job-owner to get eg. the correct from address
2379
-		if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner']))
2376
+		if (!$this->async->set_timer($alarm['time'], $id, 'calendar.calendar_boupdate.send_alarm', $alarm, $alarm['owner']))
2380 2377
 		{
2381 2378
 			return False;
2382 2379
 		}
@@ -2403,7 +2400,7 @@  discard block
 block discarded – undo
2403 2400
 		//error_log(__METHOD__."($cal_id) ".function_backtrace());
2404 2401
 		if (($alarms = $this->read_alarms($cal_id)))
2405 2402
 		{
2406
-			foreach(array_keys($alarms) as $id)
2403
+			foreach (array_keys($alarms) as $id)
2407 2404
 			{
2408 2405
 				$this->async->cancel_timer($id);
2409 2406
 			}
@@ -2423,7 +2420,7 @@  discard block
 block discarded – undo
2423 2420
 	{
2424 2421
 		//error_log(__METHOD__."('$id') ".function_backtrace());
2425 2422
 		// update the modification information of the related event
2426
-		list(,$cal_id) = explode(':',$id);
2423
+		list(,$cal_id) = explode(':', $id);
2427 2424
 		if ($cal_id)
2428 2425
 		{
2429 2426
 			$this->updateModified($cal_id, true);
@@ -2442,7 +2439,7 @@  discard block
 block discarded – undo
2442 2439
 	 * @param array|int $old_user integer old user or array with keys 'account_id' and 'new_owner' as the deleteaccount hook uses it
2443 2440
 	 * @param int $new_user =null
2444 2441
 	 */
2445
-	function deleteaccount($old_user, $new_user=null)
2442
+	function deleteaccount($old_user, $new_user = null)
2446 2443
 	{
2447 2444
 		if (is_array($old_user))
2448 2445
 		{
@@ -2453,52 +2450,52 @@  discard block
 block discarded – undo
2453 2450
 		{
2454 2451
 			$user_type = '';
2455 2452
 			$user_id = null;
2456
-			self::split_user($old_user,$user_type,$user_id);
2453
+			self::split_user($old_user, $user_type, $user_id);
2457 2454
 
2458 2455
 			if ($user_type == 'u')	// only accounts can be owners of events
2459 2456
 			{
2460
-				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2457
+				foreach ($this->db->select($this->cal_table, 'cal_id', array('cal_owner' => $old_user), __LINE__, __FILE__, false, '', 'calendar') as $row)
2461 2458
 				{
2462 2459
 					$this->delete($row['cal_id']);
2463 2460
 				}
2464 2461
 			}
2465
-			$this->db->delete($this->user_table,array(
2462
+			$this->db->delete($this->user_table, array(
2466 2463
 				'cal_user_type' => $user_type,
2467 2464
 				'cal_user_id'   => $user_id,
2468
-			),__LINE__,__FILE__,'calendar');
2465
+			), __LINE__, __FILE__, 'calendar');
2469 2466
 
2470 2467
 			// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
2471
-			foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2472
-				False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2468
+			foreach ($this->db->select($this->cal_table, "DISTINCT $this->cal_table.cal_id", 'cal_user_id IS NULL', __LINE__, __FILE__,
2469
+				False, '', 'calendar', 0, "LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2473 2470
 			{
2474 2471
 				$this->delete($row['cal_id']);
2475 2472
 			}
2476 2473
 		}
2477 2474
 		else
2478 2475
 		{
2479
-			$this->db->update($this->cal_table,array('cal_owner' => $new_user),array('cal_owner' => $old_user),__LINE__,__FILE__,'calendar');
2476
+			$this->db->update($this->cal_table, array('cal_owner' => $new_user), array('cal_owner' => $old_user), __LINE__, __FILE__, 'calendar');
2480 2477
 			// delete participation of old user, if new user is already a participant
2481 2478
 			$ids = array();
2482
-			foreach($this->db->select($this->user_table,'cal_id',array(		// MySQL does NOT allow to run this as delete!
2479
+			foreach ($this->db->select($this->user_table, 'cal_id', array(		// MySQL does NOT allow to run this as delete!
2483 2480
 				'cal_user_type' => 'u',
2484 2481
 				'cal_user_id' => $old_user,
2485 2482
 				"cal_id IN (SELECT cal_id FROM $this->user_table other WHERE other.cal_id=cal_id AND other.cal_user_id=".$this->db->quote($new_user)." AND cal_user_type='u')",
2486
-			),__LINE__,__FILE__,false,'','calendar') as $row)
2483
+			), __LINE__, __FILE__, false, '', 'calendar') as $row)
2487 2484
 			{
2488 2485
 				$ids[] = $row['cal_id'];
2489 2486
 			}
2490
-			if ($ids) $this->db->delete($this->user_table,array(
2487
+			if ($ids) $this->db->delete($this->user_table, array(
2491 2488
 				'cal_user_type' => 'u',
2492 2489
 				'cal_user_id' => $old_user,
2493 2490
 				'cal_id' => $ids,
2494
-			),__LINE__,__FILE__,'calendar');
2491
+			), __LINE__, __FILE__, 'calendar');
2495 2492
 			// now change participant in the rest to contain new user instead of old user
2496
-			$this->db->update($this->user_table,array(
2493
+			$this->db->update($this->user_table, array(
2497 2494
 				'cal_user_id' => $new_user,
2498
-			),array(
2495
+			), array(
2499 2496
 				'cal_user_type' => 'u',
2500 2497
 				'cal_user_id' => $old_user,
2501
-			),__LINE__,__FILE__,'calendar');
2498
+			), __LINE__, __FILE__, 'calendar');
2502 2499
 		}
2503 2500
 	}
2504 2501
 
@@ -2512,18 +2509,18 @@  discard block
 block discarded – undo
2512 2509
 	 *
2513 2510
 	 * @return array recur_date => status pairs (index 0 => main status)
2514 2511
 	 */
2515
-	function get_recurrences($cal_id, $uid=null, $start=0, $end=0)
2512
+	function get_recurrences($cal_id, $uid = null, $start = 0, $end = 0)
2516 2513
 	{
2517 2514
 		$participant_status = array();
2518 2515
 		$where = array('cal_id' => $cal_id);
2519
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2520
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2516
+		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')';
2517
+		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')';
2521 2518
 		if ($start != 0 && $end != 0)
2522 2519
 		{
2523
-			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
2524
-						' AND cal_recur_date <= ' . (int)$end . '))';
2520
+			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start.
2521
+						' AND cal_recur_date <= '.(int)$end.'))';
2525 2522
 		}
2526
-		foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row)
2523
+		foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row)
2527 2524
 		{
2528 2525
 			// inititalize the array
2529 2526
 			$participant_status[$row['cal_recur_date']] = null;
@@ -2537,17 +2534,17 @@  discard block
 block discarded – undo
2537 2534
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2538 2535
 			'cal_user_id'   => $user_id,
2539 2536
 		);
2540
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2541
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2537
+		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')';
2538
+		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')';
2542 2539
 		if ($start != 0 && $end != 0)
2543 2540
 		{
2544
-			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
2545
-						' AND cal_recur_date <= ' . (int)$end . '))';
2541
+			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start.
2542
+						' AND cal_recur_date <= '.(int)$end.'))';
2546 2543
 		}
2547
-		foreach ($this->db->select($this->user_table,'cal_recur_date,cal_status,cal_quantity,cal_role',$where2,
2548
-				__LINE__,__FILE__,false,'','calendar') as $row)
2544
+		foreach ($this->db->select($this->user_table, 'cal_recur_date,cal_status,cal_quantity,cal_role', $where2,
2545
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2549 2546
 		{
2550
-			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
2547
+			$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
2551 2548
 			$participant_status[$row['cal_recur_date']] = $status;
2552 2549
 		}
2553 2550
 		return $participant_status;
@@ -2596,8 +2593,8 @@  discard block
 block discarded – undo
2596 2593
 			'cal_uid'		=> $uid,
2597 2594
 		);
2598 2595
 		$related = array();
2599
-		foreach ($this->db->select($this->cal_table,'cal_id,cal_reference',$where,
2600
-				__LINE__,__FILE__,false,'','calendar') as $row)
2596
+		foreach ($this->db->select($this->cal_table, 'cal_id,cal_reference', $where,
2597
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2601 2598
 		{
2602 2599
 			if ($row['cal_reference'] != 0)
2603 2600
 			{
@@ -2626,10 +2623,10 @@  discard block
 block discarded – undo
2626 2623
 	 *
2627 2624
 	 * @return array		Array of exception days (false for non-recurring events).
2628 2625
 	 */
2629
-	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2626
+	function get_recurrence_exceptions($event, $tz_id = null, $start = 0, $end = 0, $filter = 'all')
2630 2627
 	{
2631 2628
 		if (!is_array($event)) return false;
2632
-		$cal_id = (int) $event['id'];
2629
+		$cal_id = (int)$event['id'];
2633 2630
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2634 2631
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2635 2632
 		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
@@ -2653,27 +2650,27 @@  discard block
 block discarded – undo
2653 2650
 		while ($egw_rrule->valid())
2654 2651
 		{
2655 2652
 			while ($egw_rrule->exceptions &&
2656
-				in_array($egw_rrule->current->format('Ymd'),$egw_rrule->exceptions))
2653
+				in_array($egw_rrule->current->format('Ymd'), $egw_rrule->exceptions))
2657 2654
 			{
2658
-				if (in_array($filter, array('map','tz_map','rrule','tz_rrule')))
2655
+				if (in_array($filter, array('map', 'tz_map', 'rrule', 'tz_rrule')))
2659 2656
 				{
2660 2657
 					 // real exception
2661
-					$locts = (int)Api\DateTime::to($egw_rrule->current(),'server');
2658
+					$locts = (int)Api\DateTime::to($egw_rrule->current(), 'server');
2662 2659
 					if ($expand_all)
2663 2660
 					{
2664
-						$remts = (int)Api\DateTime::to($remote_rrule->current(),'server');
2661
+						$remts = (int)Api\DateTime::to($remote_rrule->current(), 'server');
2665 2662
 						if ($remote)
2666 2663
 						{
2667
-							$days[$locts]= $remts;
2664
+							$days[$locts] = $remts;
2668 2665
 						}
2669 2666
 						else
2670 2667
 						{
2671
-							$days[$remts]= $locts;
2668
+							$days[$remts] = $locts;
2672 2669
 						}
2673 2670
 					}
2674 2671
 					else
2675 2672
 					{
2676
-						$days[$locts]= $locts;
2673
+						$days[$locts] = $locts;
2677 2674
 					}
2678 2675
 				}
2679 2676
 				if ($expand_all)
@@ -2684,14 +2681,14 @@  discard block
 block discarded – undo
2684 2681
 				if (!$egw_rrule->valid()) return $days;
2685 2682
 			}
2686 2683
 			$day = $egw_rrule->current();
2687
-			$locts = (int)Api\DateTime::to($day,'server');
2684
+			$locts = (int)Api\DateTime::to($day, 'server');
2688 2685
 			$tz_exception = ($filter == 'tz_rrule');
2689 2686
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2690 2687
 			//	'()[EVENT Server]: ' . $day->format('Ymd\THis') . " ($locts)");
2691 2688
 			if ($expand_all)
2692 2689
 			{
2693 2690
 				$remote_day = $remote_rrule->current();
2694
-				$remts = (int)Api\DateTime::to($remote_day,'server');
2691
+				$remts = (int)Api\DateTime::to($remote_day, 'server');
2695 2692
 			//	error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2696 2693
 			//	'()[EVENT Device]: ' . $remote_day->format('Ymd\THis') . " ($remts)");
2697 2694
 			}
@@ -2710,11 +2707,11 @@  discard block
 block discarded – undo
2710 2707
 						//	'() tz exception: ' . $day->format('Ymd\THis'));
2711 2708
 						if ($remote)
2712 2709
 						{
2713
-							$days[$locts]= $remts;
2710
+							$days[$locts] = $remts;
2714 2711
 						}
2715 2712
 						else
2716 2713
 						{
2717
-							$days[$remts]= $locts;
2714
+							$days[$remts] = $locts;
2718 2715
 						}
2719 2716
 					}
2720 2717
 				}
@@ -2736,18 +2733,18 @@  discard block
 block discarded – undo
2736 2733
 							{
2737 2734
 								if ($remote)
2738 2735
 								{
2739
-									$days[$locts]= $remts;
2736
+									$days[$locts] = $remts;
2740 2737
 								}
2741 2738
 								else
2742 2739
 								{
2743
-									$days[$remts]= $locts;
2740
+									$days[$remts] = $locts;
2744 2741
 								}
2745 2742
 							}
2746 2743
 						}
2747 2744
 					}
2748 2745
 					elseif ($filter != 'map')
2749 2746
 					{
2750
-						$days[$locts]= $locts;
2747
+						$days[$locts] = $locts;
2751 2748
 					}
2752 2749
 				}
2753 2750
 				elseif (($filter == 'map' || filter == 'tz_map') &&
@@ -2757,11 +2754,11 @@  discard block
 block discarded – undo
2757 2754
 					if ($expand_all)
2758 2755
 					{
2759 2756
 
2760
-						$days[$remts]= $locts;
2757
+						$days[$remts] = $locts;
2761 2758
 					}
2762 2759
 					else
2763 2760
 					{
2764
-						$days[$locts]= $locts;
2761
+						$days[$locts] = $locts;
2765 2762
 					}
2766 2763
 				}
2767 2764
 			}
@@ -2785,9 +2782,9 @@  discard block
 block discarded – undo
2785 2782
 	 */
2786 2783
 	function status_pseudo_exception($cal_id, $recur_date, $filter)
2787 2784
 	{
2788
-		static $recurrence_zero=null;
2789
-		static $cached_id=null;
2790
-		static $user=null;
2785
+		static $recurrence_zero = null;
2786
+		static $cached_id = null;
2787
+		static $user = null;
2791 2788
 
2792 2789
 		if (!isset($cached_id) || $cached_id != $cal_id)
2793 2790
 		{
@@ -2798,8 +2795,8 @@  discard block
 block discarded – undo
2798 2795
 				'cal_id' => $cal_id,
2799 2796
 				'cal_recur_date' => 0,
2800 2797
 			);
2801
-			foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where,
2802
-				__LINE__,__FILE__,false,'','calendar') as $row)
2798
+			foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where,
2799
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2803 2800
 			{
2804 2801
 				switch ($row['cal_user_type'])
2805 2802
 				{
@@ -2822,8 +2819,8 @@  discard block
 block discarded – undo
2822 2819
 			'cal_id' => $cal_id,
2823 2820
 			'cal_recur_date' => $recur_date,
2824 2821
 		);
2825
-		foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where,
2826
-			__LINE__,__FILE__,false,'','calendar') as $row)
2822
+		foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where,
2823
+			__LINE__, __FILE__, false, '', 'calendar') as $row)
2827 2824
 		{
2828 2825
 			switch ($row['cal_user_type'])
2829 2826
 			{
@@ -2920,14 +2917,14 @@  discard block
 block discarded – undo
2920 2917
 			}
2921 2918
 			$timezone = self::$tz_cache[$event['tzid']];
2922 2919
 		}
2923
-		$start_time = new Api\DateTime($event['start'],Api\DateTime::$server_timezone);
2920
+		$start_time = new Api\DateTime($event['start'], Api\DateTime::$server_timezone);
2924 2921
 		$start_time->setTimezone($timezone);
2925
-		$end_time = new Api\DateTime($event['end'],Api\DateTime::$server_timezone);
2922
+		$end_time = new Api\DateTime($event['end'], Api\DateTime::$server_timezone);
2926 2923
 		$end_time->setTimezone($timezone);
2927 2924
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2928 2925
 		//	'(): ' . $start . '-' . $end);
2929
-		$start = Api\DateTime::to($start_time,'array');
2930
-		$end = Api\DateTime::to($end_time,'array');
2926
+		$start = Api\DateTime::to($start_time, 'array');
2927
+		$end = Api\DateTime::to($end_time, 'array');
2931 2928
 
2932 2929
 
2933 2930
 		return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59;
@@ -2941,7 +2938,7 @@  discard block
 block discarded – undo
2941 2938
 	 *
2942 2939
 	 * @return DateTime
2943 2940
 	 */
2944
-	function &startOfDay(Api\DateTime $time, $tz_id=null)
2941
+	function &startOfDay(Api\DateTime $time, $tz_id = null)
2945 2942
 	{
2946 2943
 		if (empty($tz_id))
2947 2944
 		{
@@ -2966,14 +2963,14 @@  discard block
 block discarded – undo
2966 2963
 	 * @param int $time =null new timestamp, default current (server-)time
2967 2964
 	 * @param int $modifier =null uid of the modifier, default current user
2968 2965
 	 */
2969
-	function updateModified($id, $update_master=false, $time=null, $modifier=null)
2966
+	function updateModified($id, $update_master = false, $time = null, $modifier = null)
2970 2967
 	{
2971 2968
 		if (is_null($time) || !$time) $time = time();
2972 2969
 		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
2973 2970
 
2974 2971
 		$this->db->update($this->cal_table,
2975 2972
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
2976
-			array('cal_id' => $id), __LINE__,__FILE__, 'calendar');
2973
+			array('cal_id' => $id), __LINE__, __FILE__, 'calendar');
2977 2974
 
2978 2975
 		// if event is an exception: update modified of master, to force etag, ctag and sync-token change
2979 2976
 		if ($update_master)
Please login to merge, or discard this patch.
Braces   +366 added lines, -96 removed lines patch added patch discarded remove patch
@@ -154,16 +154,32 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
156 156
 	{
157
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
157
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)
158 158
 		{
159
-			return $this->cal_table;	// no need / use for a view
159
+			// using view without start-date is slower!
160
+		{
161
+			return $this->cal_table;
162
+		}
163
+		// no need / use for a view
160 164
 		}
161 165
 
162 166
 		$where = array();
163
-		if (isset($deleted)) $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
164
-		if ($end) $where[] = "range_start<".(int)$end;
165
-		if ($start) $where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
166
-		if ($_where) $where = array_merge($where, $_where);
167
+		if (isset($deleted))
168
+		{
169
+			$where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
170
+		}
171
+		if ($end)
172
+		{
173
+			$where[] = "range_start<".(int)$end;
174
+		}
175
+		if ($start)
176
+		{
177
+			$where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
178
+		}
179
+		if ($_where)
180
+		{
181
+			$where = array_merge($where, $_where);
182
+		}
167 183
 
168 184
 		$sql = "(SELECT * FROM $this->cal_table WHERE ".$this->db->expression($this->cal_table, $where).") $this->cal_table";
169 185
 
@@ -184,16 +200,32 @@  discard block
 block discarded – undo
184 200
 	 */
185 201
 	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
186 202
 	{
187
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
203
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)
204
+		{
205
+			// using view without start- AND end-date is slower!
188 206
 		{
189
-			return $this->dates_table;	// no need / use for a view
207
+			return $this->dates_table;
208
+		}
209
+		// no need / use for a view
190 210
 		}
191 211
 
192 212
 		$where = array();
193
-		if (isset($deleted)) $where['recur_exception'] = $deleted;
194
-		if ($end) $where[] = "cal_start<".(int)$end;
195
-		if ($start) $where[] = "cal_end>".(int)$start;
196
-		if ($_where) $where = array_merge($where, $_where);
213
+		if (isset($deleted))
214
+		{
215
+			$where['recur_exception'] = $deleted;
216
+		}
217
+		if ($end)
218
+		{
219
+			$where[] = "cal_start<".(int)$end;
220
+		}
221
+		if ($start)
222
+		{
223
+			$where[] = "cal_end>".(int)$start;
224
+		}
225
+		if ($_where)
226
+		{
227
+			$where = array_merge($where, $_where);
228
+		}
197 229
 
198 230
 		// Api\Db::union uses Api\Db::select which check if join contains "WHERE"
199 231
 		// to support old join syntax like ", other_table WHERE ...",
@@ -243,7 +275,10 @@  discard block
 block discarded – undo
243 275
 			throw new Api\Exception\AssertionFailed("Unsupported value for parameters!");
244 276
 		}
245 277
 		$where = is_array($params['query']) ? $params['query'] : array();
246
-		if ($cat_id) $where[] = $this->cat_filter($cat_id);
278
+		if ($cat_id)
279
+		{
280
+			$where[] = $this->cat_filter($cat_id);
281
+		}
247 282
 		$egw_cal = $this->cal_range_view($start, $end, $where, $filter == 'everything' ? null : $filter != 'deleted');
248 283
 
249 284
 		$status_filter = $this->status_filter($filter, $params['enum_recuring']);
@@ -264,7 +299,10 @@  discard block
 block discarded – undo
264 299
 		if ($users)
265 300
 		{
266 301
 			// fix $users to also prefix system users and groups (with 'u')
267
-			if (!is_array($users)) $users = $users ? (array)$users : array();
302
+			if (!is_array($users))
303
+			{
304
+				$users = $users ? (array)$users : array();
305
+			}
268 306
 			foreach($users as &$uid)
269 307
 			{
270 308
 				$user_type = $user_id = null;
@@ -284,15 +322,22 @@  discard block
 block discarded – undo
284 322
 			$sql .= " AND\n	".$params['sql_filter'];
285 323
 		}
286 324
 
287
-		if ($params['order'])	// only order if requested
325
+		if ($params['order'])
288 326
 		{
289
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
327
+			// only order if requested
328
+		{
329
+			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';
330
+		}
331
+		// gard against SQL injection
290 332
 			$sql .= "\nORDER BY ".$params['order'];
291 333
 		}
292 334
 
293
-		if ($offset === false)	// return all rows --> Api\Db::query wants offset=0, num_rows=-1
335
+		if ($offset === false)
336
+		{
337
+			// return all rows --> Api\Db::query wants offset=0, num_rows=-1
294 338
 		{
295 339
 			$offset = 0;
340
+		}
296 341
 			$num_rows = -1;
297 342
 		}
298 343
 		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
@@ -318,26 +363,35 @@  discard block
 block discarded – undo
318 363
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
319 364
 
320 365
 		$where = array();
321
-		if (is_scalar($ids) && !is_numeric($ids))	// a single uid
366
+		if (is_scalar($ids) && !is_numeric($ids))
367
+		{
368
+			// a single uid
322 369
 		{
323 370
 			// We want only the parents to match
324 371
 			$where['cal_uid'] = $ids;
372
+		}
325 373
 			$where['cal_reference'] = 0;
326 374
 		}
327
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
375
+		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))
376
+		{
377
+			// one or more cal_id's
328 378
 		{
329 379
 			$where['cal_id'] = $ids;
330 380
 		}
381
+		}
331 382
 		else	// array with column => value pairs
332 383
 		{
333 384
 			$where = $ids;
334 385
 			unset($ids);	// otherwise users get not read!
335 386
 		}
336
-		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
387
+		if (isset($where['cal_id']))
388
+		{
389
+			// prevent non-unique column-name cal_id
337 390
 		{
338 391
 			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
339 392
 				'cal_id' => $where['cal_id'],
340 393
 			));
394
+		}
341 395
 			unset($where['cal_id']);
342 396
 		}
343 397
 		if ((int) $recur_date)
@@ -387,10 +441,16 @@  discard block
 block discarded – undo
387 441
 			$row['recur_exception'] = $row['alarm'] = array();
388 442
 			$events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_');
389 443
 		}
390
-		if (!$events) return $events;
444
+		if (!$events)
445
+		{
446
+			return $events;
447
+		}
391 448
 
392 449
 		$ids = array_keys($events);
393
-		if (count($ids) == 1) $ids = $ids[0];
450
+		if (count($ids) == 1)
451
+		{
452
+			$ids = $ids[0];
453
+		}
394 454
 
395 455
 		foreach ($events as &$event)
396 456
 		{
@@ -464,10 +524,13 @@  discard block
 block discarded – undo
464 524
 			'cal_id'      => $ids,
465 525
 			'cal_recur_date' => $recur_date,
466 526
 			"cal_status NOT IN ('X','E')",
467
-		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)	// DESC puts users before resources and contacts
527
+		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)
528
+		{
529
+			// DESC puts users before resources and contacts
468 530
 		{
469 531
 			// combine all participant data in uid and status values
470 532
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
533
+		}
471 534
 			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
472 535
 
473 536
 			$events[$row['cal_id']]['participants'][$uid] = $status;
@@ -524,7 +587,10 @@  discard block
 block discarded – undo
524 587
 			$last_request = time();
525 588
 		}
526 589
 		$signature = serialize(func_get_args());
527
-		if (isset($ctags[$signature])) return $ctags[$signature];
590
+		if (isset($ctags[$signature]))
591
+		{
592
+			return $ctags[$signature];
593
+		}
528 594
 
529 595
 		$types = array();
530 596
 		foreach((array)$users as $uid)
@@ -557,7 +623,10 @@  discard block
 block discarded – undo
557 623
 			// owner can only by users, no groups or resources
558 624
 			foreach($users as $key => $user)
559 625
 			{
560
-				if (!($user > 0)) unset($users[$key]);
626
+				if (!($user > 0))
627
+				{
628
+					unset($users[$key]);
629
+				}
561 630
 			}
562 631
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
563 632
 				$this->db->expression($this->cal_table, array(
@@ -579,7 +648,10 @@  discard block
 block discarded – undo
579 648
 	 */
580 649
 	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
581 650
 	{
582
-		if (!is_array($cols)) $cols = explode(',', $cols);
651
+		if (!is_array($cols))
652
+		{
653
+			$cols = explode(',', $cols);
654
+		}
583 655
 
584 656
 		// special handling of cal_user_modified "pseudo" column
585 657
 		if (($key = array_search('cal_user_modified', $cols)) !== false)
@@ -604,7 +676,10 @@  discard block
 block discarded – undo
604 676
 		{
605 677
 			$cats = $GLOBALS['egw']->categories->return_all_children($cat_id);
606 678
 			array_walk($cats,create_function('&$val,$key','$val = (int) $val;'));
607
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
679
+			if (is_array($cat_id) && count($cat_id)==1)
680
+			{
681
+				$cat_id = $cat_id[0];
682
+			}
608 683
 			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
609 684
 			foreach($cats as $cat)
610 685
 			{
@@ -663,10 +738,13 @@  discard block
 block discarded – undo
663 738
 				$where[] = "$this->user_table.cal_status NOT IN ('X','E')";
664 739
 				break;
665 740
 			default:
666
-				if ($enum_recuring)	// regular UI
741
+				if ($enum_recuring)
742
+				{
743
+					// regular UI
667 744
 				{
668 745
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X','E')";
669 746
 				}
747
+				}
670 748
 				else	// CalDAV / eSync / iCal need to include 'E' = exceptions
671 749
 				{
672 750
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X')";
@@ -798,7 +876,10 @@  discard block
 block discarded – undo
798 876
 						$user_ids = array();
799 877
 						foreach($ids as $user_id)
800 878
 						{
801
-							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
879
+							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u')
880
+							{
881
+								$user_ids[] = $user_id;
882
+							}
802 883
 						}
803 884
 						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
804 885
 					}
@@ -818,7 +899,10 @@  discard block
 block discarded – undo
818 899
 				}
819 900
 			}
820 901
 			// this is only used, when we cannot use UNIONS
821
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
902
+			if (!$useUnionQuery)
903
+			{
904
+				$where[] = '('.implode(' OR ',$to_or).')';
905
+			}
822 906
 
823 907
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
824 908
 		}
@@ -837,7 +921,11 @@  discard block
 block discarded – undo
837 921
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
838 922
 			}
839 923
 		}
840
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
924
+		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order']))
925
+		{
926
+			$params['order'] = 'cal_start';
927
+		}
928
+		// gard against SQL injection
841 929
 
842 930
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
843 931
 		if (!$params['enum_recuring'])
@@ -847,9 +935,15 @@  discard block
 block discarded – undo
847 935
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
848 936
 			$where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
849 937
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
850
-			if ($end) $where[] = (int)$end.' > range_start';
938
+			if ($end)
939
+			{
940
+				$where[] = (int)$end.' > range_start';
941
+			}
851 942
   		}
852
-		elseif ($end) $where[] = (int)$end.' > cal_start';
943
+  		elseif ($end)
944
+		{
945
+			$where[] = (int)$end.' > cal_start';
946
+		}
853 947
 
854 948
 		if ($remove_rejected_by_user && $filter != 'everything')
855 949
 		{
@@ -863,7 +957,10 @@  discard block
 block discarded – undo
863 957
 				'rejected_by_user.cal_status IS NULL',
864 958
 				"rejected_by_user.cal_status NOT IN ('R','X')",
865 959
 			);
866
-			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
960
+			if ($filter == 'owner')
961
+			{
962
+				$or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
963
+			}
867 964
 			$where[] = '('.implode(' OR ',$or_required).')';
868 965
 		}
869 966
 		// using a time-range and deleted attribute limited view instead of full table
@@ -885,7 +982,10 @@  discard block
 block discarded – undo
885 982
 		if ($useUnionQuery)
886 983
 		{
887 984
 			// allow apps to supply participants and/or icons
888
-			if (!isset($params['cols'])) $cols .= ',NULL AS participants,NULL AS icons';
985
+			if (!isset($params['cols']))
986
+			{
987
+				$cols .= ',NULL AS participants,NULL AS icons';
988
+			}
889 989
 
890 990
 			// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
891 991
 			// with time-range views benefit is now at best slim for huge tables or none at all!
@@ -940,9 +1040,12 @@  discard block
 block discarded – undo
940 1040
 					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
941 1041
 				}
942 1042
 			}
943
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1043
+			if (is_numeric($offset) && !$params['no_total'])
1044
+			{
1045
+				// get the total too
944 1046
 			{
945 1047
 				$save_selects = $selects;
1048
+			}
946 1049
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
947 1050
 				foreach(array_keys($selects) as $key)
948 1051
 				{
@@ -953,14 +1056,20 @@  discard block
 block discarded – undo
953 1056
 							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
954 1057
 					}
955 1058
 				}
956
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1059
+				if (!isset($params['cols']) && !$params['no_integration'])
1060
+				{
1061
+					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1062
+				}
957 1063
 
958 1064
 				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
959 1065
 
960 1066
 				// restore original cols / selects
961 1067
 				$selects = $save_selects; unset($save_selects);
962 1068
 			}
963
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1069
+			if (!isset($params['cols']) && !$params['no_integration'])
1070
+			{
1071
+				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1072
+			}
964 1073
 
965 1074
 			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
966 1075
 		}
@@ -978,9 +1087,12 @@  discard block
 block discarded – undo
978 1087
 				'table_def' => $cal_table_def,
979 1088
 			));
980 1089
 
981
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1090
+			if (is_numeric($offset) && !$params['no_total'])
1091
+			{
1092
+				// get the total too
982 1093
 			{
983 1094
 				$save_selects = $selects;
1095
+			}
984 1096
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
985 1097
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
986 1098
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
@@ -1008,7 +1120,10 @@  discard block
 block discarded – undo
1008 1120
 		foreach($rs as $row)
1009 1121
 		{
1010 1122
 			$id = $row['cal_id'];
1011
-			if (is_numeric($id)) $ids[] = $id;
1123
+			if (is_numeric($id))
1124
+			{
1125
+				$ids[] = $id;
1126
+			}
1012 1127
 
1013 1128
 			if ($row['cal_recur_date'])
1014 1129
 			{
@@ -1028,7 +1143,10 @@  discard block
 block discarded – undo
1028 1143
 			$row['recur_exception'] = $row['alarm'] = array();
1029 1144
 
1030 1145
 			// compile a list of recurrences per cal_id
1031
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1146
+			if (!in_array($id,(array)$recur_ids[$row['cal_id']]))
1147
+			{
1148
+				$recur_ids[$row['cal_id']][] = $id;
1149
+			}
1032 1150
 
1033 1151
 			$events[$id] = Api\Db::strip_array_keys($row,'cal_');
1034 1152
 		}
@@ -1047,10 +1165,16 @@  discard block
 block discarded – undo
1047 1165
 					//'cal_id' => array_unique($ids),
1048 1166
 					'cal_recur_date' => $recur_dates,
1049 1167
 				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',$num_rows,$join='',
1050
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1168
+				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)
1169
+			{
1170
+				// DESC puts users before resources and contacts
1051 1171
 			{
1052 1172
 				$id = $row['cal_id'];
1053
-				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1173
+			}
1174
+				if ($row['cal_recur_date'])
1175
+				{
1176
+					$id .= '-'.$row['cal_recur_date'];
1177
+				}
1054 1178
 
1055 1179
 				// combine all participant data in uid and status values
1056 1180
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
@@ -1069,7 +1193,10 @@  discard block
 block discarded – undo
1069 1193
 				}
1070 1194
 
1071 1195
 				// set data, if recurrence is requested
1072
-				if (isset($events[$id])) $events[$id]['participants'][$uid] = $status;
1196
+				if (isset($events[$id]))
1197
+				{
1198
+					$events[$id]['participants'][$uid] = $status;
1199
+				}
1073 1200
 			}
1074 1201
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1075 1202
 			if (!$params['enum_recuring'] || !$params['daywise'])
@@ -1085,7 +1212,10 @@  discard block
 block discarded – undo
1085 1212
 					{
1086 1213
 						foreach($events as $id => $event)
1087 1214
 						{
1088
-							if ($event['id'] == $row['cal_id']) break;
1215
+							if ($event['id'] == $row['cal_id'])
1216
+							{
1217
+								break;
1218
+							}
1089 1219
 						}
1090 1220
 					}
1091 1221
 					$events[$id]['recur_exception'][] = $row['cal_start'];
@@ -1095,7 +1225,10 @@  discard block
 block discarded – undo
1095 1225
 			if (!is_null($params['cfs']))
1096 1226
 			{
1097 1227
 				$where = array('cal_id' => $ids);
1098
-				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1228
+				if ($params['cfs'])
1229
+				{
1230
+					$where['cal_extra_name'] = $params['cfs'];
1231
+				}
1099 1232
 				foreach($this->db->select($this->extra_table,'*',$where,
1100 1233
 					__LINE__,__FILE__,false,'','calendar') as $row)
1101 1234
 				{
@@ -1115,14 +1248,20 @@  discard block
 block discarded – undo
1115 1248
 				{
1116 1249
 					$event_start = $alarm['time'] + $alarm['offset'];
1117 1250
 
1118
-					if (isset($events[$cal_id]))	// none recuring event
1251
+					if (isset($events[$cal_id]))
1252
+					{
1253
+						// none recuring event
1119 1254
 					{
1120 1255
 						$events[$cal_id]['alarm'][$id] = $alarm;
1121 1256
 					}
1122
-					elseif (isset($events[$cal_id.'-'.$event_start]))	// recuring event
1257
+					}
1258
+					elseif (isset($events[$cal_id.'-'.$event_start]))
1259
+					{
1260
+						// recuring event
1123 1261
 					{
1124 1262
 						$events[$cal_id.'-'.$event_start]['alarm'][$id] = $alarm;
1125 1263
 					}
1264
+					}
1126 1265
 				}
1127 1266
 			}
1128 1267
 		}
@@ -1222,10 +1361,13 @@  discard block
 block discarded – undo
1222 1361
 			}
1223 1362
 			foreach((array)$cols as $col)
1224 1363
 			{
1225
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1364
+				if (substr($col,0,7) == 'egw_cal')
1365
+				{
1366
+					// remove table name
1226 1367
 				{
1227 1368
 					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1228 1369
 				}
1370
+				}
1229 1371
 				if (isset($app_cols[$col]))
1230 1372
 				{
1231 1373
 					$return_cols[] = $app_cols[$col];
@@ -1319,7 +1461,11 @@  discard block
 block discarded – undo
1319 1461
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1320 1462
 		{
1321 1463
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1322
-			if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1464
+			if (empty($minimum_uid_length) || $minimum_uid_length<=1)
1465
+			{
1466
+				$minimum_uid_length = 8;
1467
+			}
1468
+			// we just do not accept no uid, or uid way to short!
1323 1469
 		}
1324 1470
 		else
1325 1471
 		{
@@ -1367,7 +1513,10 @@  discard block
 block discarded – undo
1367 1513
 			}
1368 1514
 		}
1369 1515
 		// set range_start/_end, but only if we have cal_start/_end, as otherwise we destroy present values!
1370
-		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1516
+		if (isset($event['cal_start']))
1517
+		{
1518
+			$event['range_start'] = $event['cal_start'];
1519
+		}
1371 1520
 		if (isset($event['cal_end']))
1372 1521
 		{
1373 1522
 			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
@@ -1388,7 +1537,10 @@  discard block
 block discarded – undo
1388 1537
 		$event['cal_category'] = implode(',',$categories);
1389 1538
 
1390 1539
 		// make sure recurring events never reference to an other recurrent event
1391
-		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
1540
+		if ($event['recur_type'] != MCAL_RECUR_NONE)
1541
+		{
1542
+			$event['cal_reference'] = 0;
1543
+		}
1392 1544
 
1393 1545
 		if ($cal_id)
1394 1546
 		{
@@ -1405,7 +1557,10 @@  discard block
 block discarded – undo
1405 1557
 			{
1406 1558
 				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1407 1559
 			}
1408
-			if (!is_null($etag)) $where['cal_etag'] = $etag;
1560
+			if (!is_null($etag))
1561
+			{
1562
+				$where['cal_etag'] = $etag;
1563
+			}
1409 1564
 
1410 1565
 			unset($event['cal_etag']);
1411 1566
 			$event[] = 'cal_etag=cal_etag+1';	// always update the etag, even if none given to check
@@ -1416,14 +1571,24 @@  discard block
 block discarded – undo
1416 1571
 			{
1417 1572
 				return 0;	// wrong etag, someone else updated the entry
1418 1573
 			}
1419
-			if (!is_null($etag)) ++$etag;
1574
+			if (!is_null($etag))
1575
+			{
1576
+				++$etag;
1577
+			}
1420 1578
 		}
1421 1579
 		else
1422 1580
 		{
1423 1581
 			// new event
1424
-			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1582
+			if (!$event['cal_owner'])
1583
+			{
1584
+				$event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1585
+			}
1425 1586
 
1426
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1587
+			if (!$event['cal_id'] && !isset($event['cal_uid']))
1588
+			{
1589
+				$event['cal_uid'] = '';
1590
+			}
1591
+			// uid is NOT NULL!
1427 1592
 
1428 1593
 			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
1429 1594
 			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id')))
@@ -1575,8 +1740,7 @@  discard block
 block discarded – undo
1575 1740
 					// recurrences need to be truncated
1576 1741
 					if((int)$event['recur_enddate'] > 0 &&
1577 1742
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1578
-					)
1579
-					{
1743
+					) {
1580 1744
 						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1581 1745
 						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1582 1746
 					}
@@ -1584,8 +1748,7 @@  discard block
 block discarded – undo
1584 1748
 					// recurrences need to be expanded
1585 1749
 					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1586 1750
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1587
-					)
1588
-					{
1751
+					) {
1589 1752
 						$set_recurrences = true;
1590 1753
 						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1591 1754
 					}
@@ -1732,12 +1895,18 @@  discard block
 block discarded – undo
1732 1895
 	{
1733 1896
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1734 1897
 
1735
-		if (!(int) $cal_id) return false;
1898
+		if (!(int) $cal_id)
1899
+		{
1900
+			return false;
1901
+		}
1736 1902
 
1737 1903
 		if (!$old_start)
1738 1904
 		{
1739
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1905
+			if ($change_since !== false)
1906
+			{
1907
+				$row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1740 1908
 				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1909
+			}
1741 1910
 			// if no recurrence found, create one with the new dates
1742 1911
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1743 1912
 			{
@@ -1839,7 +2008,10 @@  discard block
 block discarded – undo
1839 2008
 			$user_type = $uid[0];
1840 2009
 			$email = substr($uid, 1);
1841 2010
 			$matches = null;
1842
-			if (preg_match('/<([^<>]+)>$/', $email, $matches)) $email = $matches[1];
2011
+			if (preg_match('/<([^<>]+)>$/', $email, $matches))
2012
+			{
2013
+				$email = $matches[1];
2014
+			}
1843 2015
 			$user_id = md5(trim(strtolower($email)));
1844 2016
 		}
1845 2017
 		else
@@ -1859,8 +2031,14 @@  discard block
 block discarded – undo
1859 2031
 	 */
1860 2032
 	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1861 2033
 	{
1862
-		if ((int)$quantity > 1) $status .= (int)$quantity;
1863
-		if ($role != 'REQ-PARTICIPANT') $status .= $role;
2034
+		if ((int)$quantity > 1)
2035
+		{
2036
+			$status .= (int)$quantity;
2037
+		}
2038
+		if ($role != 'REQ-PARTICIPANT')
2039
+		{
2040
+			$status .= $role;
2041
+		}
1864 2042
 
1865 2043
 		return $status;
1866 2044
 	}
@@ -1881,8 +2059,14 @@  discard block
 block discarded – undo
1881 2059
 		$matches = null;
1882 2060
 		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1883 2061
 		{
1884
-			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1885
-			if ($matches[2]) $role = $matches[2];
2062
+			if ((int)$matches[1] > 0)
2063
+			{
2064
+				$quantity = (int)$matches[1];
2065
+			}
2066
+			if ($matches[2])
2067
+			{
2068
+				$role = $matches[2];
2069
+			}
1886 2070
 			$status = $status[0];
1887 2071
 		}
1888 2072
 		elseif ($status === true)
@@ -1993,9 +2177,13 @@  discard block
 block discarded – undo
1993 2177
 			}
1994 2178
 		}
1995 2179
 
1996
-		if (count($participants))	// participants which need to be added
2180
+		if (count($participants))
2181
+		{
2182
+			// participants which need to be added
1997 2183
 		{
1998
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
2184
+			if (!count($recurrences)) $recurrences[] = 0;
2185
+		}
2186
+		// insert the default recurrence
1999 2187
 
2000 2188
 			$delete_deleted = array();
2001 2189
 
@@ -2067,7 +2255,10 @@  discard block
 block discarded – undo
2067 2255
 			return false;
2068 2256
 		}
2069 2257
 
2070
-		if (is_numeric($status)) $status = $status_code_short[$status];
2258
+		if (is_numeric($status))
2259
+		{
2260
+			$status = $status_code_short[$status];
2261
+		}
2071 2262
 
2072 2263
 		$uid = self::combine_user($user_type, $user_id);
2073 2264
 		$user_id_md5 = null;
@@ -2087,16 +2278,25 @@  discard block
 block discarded – undo
2087 2278
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.time().')';
2088 2279
 		}
2089 2280
 
2090
-		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2281
+		if ($status == 'G')
2282
+		{
2283
+			// remove group invitations, as we dont store them in the db
2091 2284
 		{
2092 2285
 			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2286
+		}
2093 2287
 			$ret = $this->db->affected_rows();
2094 2288
 		}
2095 2289
 		else
2096 2290
 		{
2097 2291
 			$set = array('cal_status' => $status);
2098
-			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2099
-			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2292
+			if ($user_type == 'e' || $attendee)
2293
+			{
2294
+				$set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2295
+			}
2296
+			if (!is_null($role) && $role != 'REQ-PARTICIPANT')
2297
+			{
2298
+				$set['cal_role'] = $role;
2299
+			}
2100 2300
 			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2101 2301
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2102 2302
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
@@ -2129,7 +2329,10 @@  discard block
 block discarded – undo
2129 2329
 	{
2130 2330
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2131 2331
 		$update = array('cal_end' => $end);
2132
-		if (isset($exception)) $update['recur_exception'] = $exception;
2332
+		if (isset($exception))
2333
+		{
2334
+			$update['recur_exception'] = $exception;
2335
+		}
2133 2336
 
2134 2337
 		$this->db->insert($this->dates_table, $update, array(
2135 2338
 			'cal_id' => $cal_id,
@@ -2144,7 +2347,11 @@  discard block
 block discarded – undo
2144 2347
 		{
2145 2348
 			foreach($participants as $uid => $status)
2146 2349
 			{
2147
-				if ($status == 'G') continue;	// dont save group-invitations
2350
+				if ($status == 'G')
2351
+				{
2352
+					continue;
2353
+				}
2354
+				// dont save group-invitations
2148 2355
 
2149 2356
 				$type = '';
2150 2357
 				$id = null;
@@ -2373,7 +2580,10 @@  discard block
 block discarded – undo
2373 2580
 		}
2374 2581
 		$alarm['cal_id'] = $cal_id;		// we need the back-reference
2375 2582
 		// add an alarm uid, if none is given
2376
-		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
2583
+		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid'))
2584
+		{
2585
+			$alarm['uid'] = (string)new Horde_Support_Uuid;
2586
+		}
2377 2587
 		//error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace());
2378 2588
 		// allways store job with the alarm owner as job-owner to get eg. the correct from address
2379 2589
 		if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner']))
@@ -2382,10 +2592,16 @@  discard block
 block discarded – undo
2382 2592
 		}
2383 2593
 
2384 2594
 		// update the modification information of the related event
2385
-		if ($update_modified) $this->updateModified($cal_id, true);
2595
+		if ($update_modified)
2596
+		{
2597
+			$this->updateModified($cal_id, true);
2598
+		}
2386 2599
 
2387 2600
 		// update cache, if used
2388
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2601
+		if (isset(self::$alarm_cache))
2602
+		{
2603
+			$this->read_alarms($cal_id, true);
2604
+		}
2389 2605
 
2390 2606
 		return $id;
2391 2607
 	}
@@ -2408,7 +2624,10 @@  discard block
 block discarded – undo
2408 2624
 				$this->async->cancel_timer($id);
2409 2625
 			}
2410 2626
 			// update cache, if used
2411
-			if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false);
2627
+			if (isset(self::$alarm_cache))
2628
+			{
2629
+				$this->read_alarms($cal_id, false);
2630
+			}
2412 2631
 		}
2413 2632
 		return count($alarms);
2414 2633
 	}
@@ -2431,7 +2650,10 @@  discard block
 block discarded – undo
2431 2650
 		$ret = $this->async->cancel_timer($id);
2432 2651
 
2433 2652
 		// update cache, if used
2434
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2653
+		if (isset(self::$alarm_cache))
2654
+		{
2655
+			$this->read_alarms($cal_id, true);
2656
+		}
2435 2657
 
2436 2658
 		return $ret;
2437 2659
 	}
@@ -2455,11 +2677,14 @@  discard block
 block discarded – undo
2455 2677
 			$user_id = null;
2456 2678
 			self::split_user($old_user,$user_type,$user_id);
2457 2679
 
2458
-			if ($user_type == 'u')	// only accounts can be owners of events
2680
+			if ($user_type == 'u')
2681
+			{
2682
+				// only accounts can be owners of events
2459 2683
 			{
2460 2684
 				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2461 2685
 				{
2462 2686
 					$this->delete($row['cal_id']);
2687
+			}
2463 2688
 				}
2464 2689
 			}
2465 2690
 			$this->db->delete($this->user_table,array(
@@ -2487,11 +2712,14 @@  discard block
 block discarded – undo
2487 2712
 			{
2488 2713
 				$ids[] = $row['cal_id'];
2489 2714
 			}
2490
-			if ($ids) $this->db->delete($this->user_table,array(
2715
+			if ($ids)
2716
+			{
2717
+				$this->db->delete($this->user_table,array(
2491 2718
 				'cal_user_type' => 'u',
2492 2719
 				'cal_user_id' => $old_user,
2493 2720
 				'cal_id' => $ids,
2494 2721
 			),__LINE__,__FILE__,'calendar');
2722
+			}
2495 2723
 			// now change participant in the rest to contain new user instead of old user
2496 2724
 			$this->db->update($this->user_table,array(
2497 2725
 				'cal_user_id' => $new_user,
@@ -2516,8 +2744,14 @@  discard block
 block discarded – undo
2516 2744
 	{
2517 2745
 		$participant_status = array();
2518 2746
 		$where = array('cal_id' => $cal_id);
2519
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2520
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2747
+		if ($start != 0 && $end == 0)
2748
+		{
2749
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2750
+		}
2751
+		if ($start == 0 && $end != 0)
2752
+		{
2753
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2754
+		}
2521 2755
 		if ($start != 0 && $end != 0)
2522 2756
 		{
2523 2757
 			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2528,7 +2762,10 @@  discard block
 block discarded – undo
2528 2762
 			// inititalize the array
2529 2763
 			$participant_status[$row['cal_recur_date']] = null;
2530 2764
 		}
2531
-		if (is_null($uid)) return $participant_status;
2765
+		if (is_null($uid))
2766
+		{
2767
+			return $participant_status;
2768
+		}
2532 2769
 		$user_type = $user_id = null;
2533 2770
 		self::split_user($uid, $user_type, $user_id, true);
2534 2771
 
@@ -2537,8 +2774,14 @@  discard block
 block discarded – undo
2537 2774
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2538 2775
 			'cal_user_id'   => $user_id,
2539 2776
 		);
2540
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2541
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2777
+		if ($start != 0 && $end == 0)
2778
+		{
2779
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2780
+		}
2781
+		if ($start == 0 && $end != 0)
2782
+		{
2783
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2784
+		}
2542 2785
 		if ($start != 0 && $end != 0)
2543 2786
 		{
2544 2787
 			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2628,17 +2871,26 @@  discard block
 block discarded – undo
2628 2871
 	 */
2629 2872
 	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2630 2873
 	{
2631
-		if (!is_array($event)) return false;
2874
+		if (!is_array($event))
2875
+		{
2876
+			return false;
2877
+		}
2632 2878
 		$cal_id = (int) $event['id'];
2633 2879
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2634 2880
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2635
-		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
2881
+		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE)
2882
+		{
2883
+			return false;
2884
+		}
2636 2885
 
2637 2886
 		$days = array();
2638 2887
 
2639 2888
 		$expand_all = (!$this->isWholeDay($event) && $tz_id && $tz_id != $event['tzid']);
2640 2889
 
2641
-		if ($filter == 'tz_only' && !$expand_all) return $days;
2890
+		if ($filter == 'tz_only' && !$expand_all)
2891
+		{
2892
+			return $days;
2893
+		}
2642 2894
 
2643 2895
 		$remote = in_array($filter, array('tz_rrule', 'rrule'));
2644 2896
 
@@ -2681,7 +2933,10 @@  discard block
 block discarded – undo
2681 2933
 					$remote_rrule->next_no_exception();
2682 2934
 				}
2683 2935
 				$egw_rrule->next_no_exception();
2684
-				if (!$egw_rrule->valid()) return $days;
2936
+				if (!$egw_rrule->valid())
2937
+				{
2938
+					return $days;
2939
+				}
2685 2940
 			}
2686 2941
 			$day = $egw_rrule->current();
2687 2942
 			$locts = (int)Api\DateTime::to($day,'server');
@@ -2835,7 +3090,11 @@  discard block
 block discarded – undo
2835 3090
 			}
2836 3091
 		}
2837 3092
 
2838
-		if (empty($participants)) return false; // occurrence does not exist at all yet
3093
+		if (empty($participants))
3094
+		{
3095
+			return false;
3096
+		}
3097
+		// occurrence does not exist at all yet
2839 3098
 
2840 3099
 		foreach ($recurrence_zero as $uid => $status)
2841 3100
 		{
@@ -2892,7 +3151,9 @@  discard block
 block discarded – undo
2892 3151
 			}
2893 3152
 			if (!isset($participants[$uid])
2894 3153
 				|| $participants[$uid] != $status)
2895
-				return true;
3154
+			{
3155
+							return true;
3156
+			}
2896 3157
 			unset($participants[$uid]);
2897 3158
 		}
2898 3159
 		return (!empty($participants));
@@ -2906,7 +3167,10 @@  discard block
 block discarded – undo
2906 3167
 	 */
2907 3168
 	function isWholeDay($event)
2908 3169
 	{
2909
-		if (!isset($event['start']) || !isset($event['end'])) return false;
3170
+		if (!isset($event['start']) || !isset($event['end']))
3171
+		{
3172
+			return false;
3173
+		}
2910 3174
 
2911 3175
 		if (empty($event['tzid']))
2912 3176
 		{
@@ -2968,8 +3232,14 @@  discard block
 block discarded – undo
2968 3232
 	 */
2969 3233
 	function updateModified($id, $update_master=false, $time=null, $modifier=null)
2970 3234
 	{
2971
-		if (is_null($time) || !$time) $time = time();
2972
-		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
3235
+		if (is_null($time) || !$time)
3236
+		{
3237
+			$time = time();
3238
+		}
3239
+		if (is_null($modifier))
3240
+		{
3241
+			$modifier = $GLOBALS['egw_info']['user']['account_id'];
3242
+		}
2973 3243
 
2974 3244
 		$this->db->update($this->cal_table,
2975 3245
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
Please login to merge, or discard this patch.
Upper-Lower-Casing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			"	CASE WHEN recur_type IS NULL THEN egw_cal.range_start ELSE cal_start END AS cal_start,\n".
253 253
 			"	CASE WHEN recur_type IS NULL THEN egw_cal.range_end ELSE cal_end END AS cal_end\n".
254 254
 			// using time-limited range view, instead of complete table, give a big performance plus
255
-			"FROM $egw_cal\n".
255
+			"from $egw_cal\n".
256 256
 			"JOIN egw_cal_user ON egw_cal_user.cal_id=egw_cal.cal_id\n".
257 257
 			// need to left join dates, as egw_cal_user.recur_date is null for non-recuring event
258 258
 			"LEFT JOIN egw_cal_dates ON egw_cal_user.cal_id=egw_cal_dates.cal_id AND egw_cal_dates.cal_start=egw_cal_user.cal_recur_date\n".
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 			$where[] = 'cal_start >= '.(int)$recur_date;
346 346
 			$group_by = 'GROUP BY '.$cols;
347 347
 			$cols .= ',MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end';
348
-			$join = "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join";
348
+			$join = "join $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join";
349 349
 		}
350 350
 		else
351 351
 		{
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 		$cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted');
871 871
 		$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
872 872
 
873
-		$join = "JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ".
873
+		$join = "join $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ".
874 874
 			"LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id ".
875 875
 			$rejected_by_user_join;
876 876
 		// dates table join only needed to enum recuring events, we use a time-range limited view here too
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
947 947
 				foreach(array_keys($selects) as $key)
948 948
 				{
949
-					$selects[$key]['cols'] = "DISTINCT $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date";
949
+					$selects[$key]['cols'] = "distinct $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date";
950 950
 					if (!$params['enum_recuring'])
951 951
 					{
952 952
 						$selects[$key]['cols'] = str_replace(array('cal_start','cal_end'),
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 			{
1398 1398
 				$old_repeats = $this->db->select($this->repeats_table, "$this->repeats_table.*,range_end AS recur_enddate",
1399 1399
 					"$this->repeats_table.cal_id=".(int)$cal_id, __LINE__, __FILE__,
1400
-					false, '', 'calendar', 0, "JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch();
1400
+					false, '', 'calendar', 0, "join $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch();
1401 1401
 			}
1402 1402
 			$where = array('cal_id' => $cal_id);
1403 1403
 			// read only timezone id, to check if it is changed
@@ -1762,13 +1762,13 @@  discard block
 block discarded – undo
1762 1762
 		if ($move_start)
1763 1763
 		{
1764 1764
 			// move the recur-date of the participants
1765
-			$this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1765
+			$this->db->query("update $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1766 1766
 				((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__);
1767 1767
 		}
1768 1768
 		if ($move_start || $move_end)
1769 1769
 		{
1770 1770
 			// move the event and it's recurrences
1771
-			$this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1771
+			$this->db->query("update $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1772 1772
 				((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__);
1773 1773
 		}
1774 1774
 		return $this->db->affected_rows();
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
 			),__LINE__,__FILE__,'calendar');
2469 2469
 
2470 2470
 			// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
2471
-			foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2471
+			foreach($this->db->select($this->cal_table,"distinct $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2472 2472
 				False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2473 2473
 			{
2474 2474
 				$this->delete($row['cal_id']);
Please login to merge, or discard this patch.