Completed
Push — 14.2 ( 5702a1...375f73 )
by Nathan
38:22
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_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   +300 added lines, -302 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // types of messsages send by calendar_boupdate::send_update
15
-define('MSG_DELETED',0);
16
-define('MSG_MODIFIED',1);
17
-define('MSG_ADDED',2);
18
-define('MSG_REJECTED',3);
19
-define('MSG_TENTATIVE',4);
20
-define('MSG_ACCEPTED',5);
21
-define('MSG_ALARM',6);
22
-define('MSG_DISINVITE',7);
23
-define('MSG_DELEGATED',8);
15
+define('MSG_DELETED', 0);
16
+define('MSG_MODIFIED', 1);
17
+define('MSG_ADDED', 2);
18
+define('MSG_REJECTED', 3);
19
+define('MSG_TENTATIVE', 4);
20
+define('MSG_ACCEPTED', 5);
21
+define('MSG_ALARM', 6);
22
+define('MSG_DISINVITE', 7);
23
+define('MSG_DELEGATED', 8);
24 24
 
25 25
 /**
26 26
  * Class to access AND manipulate all calendar data (business object)
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	function __construct()
83 83
 	{
84
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
84
+		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True);
85 85
 
86
-		parent::__construct();	// calling the parent constructor
86
+		parent::__construct(); // calling the parent constructor
87 87
 
88
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
88
+		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True);
89 89
 	}
90 90
 
91 91
 	/**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * +      + +  C   +	which is clearly wrong for everything with a maximum quantity > 1
113 113
 	 * ++++++++ ++++++++
114 114
 	 */
115
-	function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
115
+	function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
116 116
 	{
117 117
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
118 118
 		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		if ($this->debug > 1 || $this->debug == 'update')
121 121
 		{
122 122
 			$this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)',
123
-				false,$event,$ignore_conflicts,$touch_modified,$ignore_acl);
123
+				false, $event, $ignore_conflicts, $touch_modified, $ignore_acl);
124 124
 		}
125 125
 		// check some minimum requirements:
126 126
 		// - new events need start, end and title
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 		}
149 149
 
150 150
 		// check if user has the permission to update / create the event
151
-		if (!$ignore_acl && (!$new_event && !$this->check_perms(EGW_ACL_EDIT,$event['id']) ||
152
-			$new_event && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner'])) &&
153
-			!$this->check_perms(EGW_ACL_ADD,0,$event['owner']))
151
+		if (!$ignore_acl && (!$new_event && !$this->check_perms(EGW_ACL_EDIT, $event['id']) ||
152
+			$new_event && !$this->check_perms(EGW_ACL_EDIT, 0, $event['owner'])) &&
153
+			!$this->check_perms(EGW_ACL_ADD, 0, $event['owner']))
154 154
 		{
155
-			$messages[] = lang('Access to calendar of %1 denied!',common::grab_owner_name($event['owner']));
155
+			$messages[] = lang('Access to calendar of %1 denied!', common::grab_owner_name($event['owner']));
156 156
 			return false;
157 157
 		}
158 158
 		if ($new_event)
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 		}
162 162
 		else
163 163
 		{
164
-			$old_event = $this->read((int)$event['id'],null,$ignore_acl);
164
+			$old_event = $this->read((int)$event['id'], null, $ignore_acl);
165 165
 		}
166 166
 
167 167
 		// do we need to check, if user is allowed to invite the invited participants
168
-		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event)))
168
+		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event)))
169 169
 		{
170 170
 			// report removed participants back to user
171
-			foreach($removed as $key => $account_id)
171
+			foreach ($removed as $key => $account_id)
172 172
 			{
173 173
 				$removed[$key] = $this->participant_name($account_id);
174 174
 			}
175
-			$messages[] = lang('%1 participants removed because of missing invite grants',count($removed)).
176
-				': '.implode(', ',$removed);
175
+			$messages[] = lang('%1 participants removed because of missing invite grants', count($removed)).
176
+				': '.implode(', ', $removed);
177 177
 		}
178 178
 		// check category based ACL
179 179
 		if ($event['category'])
180 180
 		{
181
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
181
+			if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']);
182 182
 			if (!$old_event || !isset($old_event['category']))
183 183
 			{
184 184
 				$old_event['category'] = array();
@@ -187,38 +187,38 @@  discard block
 block discarded – undo
187 187
 			{
188 188
 				$old_event['category'] = explode(',', $old_event['category']);
189 189
 			}
190
-			foreach($event['category'] as $key => $cat_id)
190
+			foreach ($event['category'] as $key => $cat_id)
191 191
 			{
192 192
 				// check if user is allowed to update event categories
193
-				if ((!$old_event || !in_array($cat_id,$old_event['category'])) &&
194
-					self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false)
193
+				if ((!$old_event || !in_array($cat_id, $old_event['category'])) &&
194
+					self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false)
195 195
 				{
196 196
 					unset($event['category'][$key]);
197 197
 					// report removed category to user
198 198
 					$removed_cats[$cat_id] = $this->categories->id2name($cat_id);
199
-					continue;	// no further check, as cat was removed
199
+					continue; // no further check, as cat was removed
200 200
 				}
201 201
 				// for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown
202 202
 				if (!$status_reset_to_unknown &&
203
-					self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false &&
203
+					self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false &&
204 204
 					(!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end']))
205 205
 				{
206
-					foreach((array)$event['participants'] as $uid => $status)
206
+					foreach ((array)$event['participants'] as $uid => $status)
207 207
 					{
208 208
 						$q = $r = null;
209
-						calendar_so::split_status($status,$q,$r);
209
+						calendar_so::split_status($status, $q, $r);
210 210
 						if ($status != 'U')
211 211
 						{
212
-							$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
212
+							$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
213 213
 							// todo: report reset status to user
214 214
 						}
215 215
 					}
216
-					$status_reset_to_unknown = true;	// once is enough
216
+					$status_reset_to_unknown = true; // once is enough
217 217
 				}
218 218
 			}
219 219
 			if ($removed_cats)
220 220
 			{
221
-				$messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats));
221
+				$messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats));
222 222
 			}
223 223
 			if ($status_reset_to_unknown)
224 224
 			{
@@ -229,61 +229,61 @@  discard block
 block discarded – undo
229 229
 		if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']))
230 230
 		{
231 231
 			$types_with_quantity = array();
232
-			foreach($this->resources as $type => $data)
232
+			foreach ($this->resources as $type => $data)
233 233
 			{
234 234
 				if ($data['max_quantity']) $types_with_quantity[] = $type;
235 235
 			}
236 236
 			// get all NOT rejected participants and evtl. their quantity
237 237
 			$quantity = $users = array();
238
-			foreach($event['participants'] as $uid => $status)
238
+			foreach ($event['participants'] as $uid => $status)
239 239
 			{
240
-				calendar_so::split_status($status,$q,$r);
241
-				if ($status[0] == 'R') continue;	// ignore rejected participants
240
+				calendar_so::split_status($status, $q, $r);
241
+				if ($status[0] == 'R') continue; // ignore rejected participants
242 242
 
243 243
 				if ($uid < 0)	// group, check it's members too
244 244
 				{
245
-					$users += (array)$GLOBALS['egw']->accounts->members($uid,true);
245
+					$users += (array)$GLOBALS['egw']->accounts->members($uid, true);
246 246
 					$users = array_unique($users);
247 247
 				}
248 248
 				$users[] = $uid;
249
-				if (in_array($uid[0],$types_with_quantity))
249
+				if (in_array($uid[0], $types_with_quantity))
250 250
 				{
251 251
 					$quantity[$uid] = $q;
252 252
 				}
253 253
 			}
254 254
 			//$start = microtime(true);
255
-			$overlapping_events =& $this->search(array(
255
+			$overlapping_events = & $this->search(array(
256 256
 				'start' => $event['start'],
257 257
 				'end'   => $event['end'],
258 258
 				'users' => $users,
259
-				'ignore_acl' => true,	// otherwise we get only events readable by the user
260
-				'enum_groups' => true,	// otherwise group-events would not block time
259
+				'ignore_acl' => true, // otherwise we get only events readable by the user
260
+				'enum_groups' => true, // otherwise group-events would not block time
261 261
 				'query' => array(
262 262
 					'cal_non_blocking' => 0,
263 263
 				),
264
-				'no_integration' => true,	// do NOT use integration of other apps
264
+				'no_integration' => true, // do NOT use integration of other apps
265 265
 			));
266 266
 			//error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s');
267 267
 			if ($this->debug > 2 || $this->debug == 'update')
268 268
 			{
269
-				$this->debug_message('calendar_boupdate::update() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$event['start'],$event['end']);
269
+				$this->debug_message('calendar_boupdate::update() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $event['start'], $event['end']);
270 270
 			}
271 271
 			$max_quantity = $possible_quantity_conflicts = $conflicts = array();
272
-			foreach((array) $overlapping_events as $k => $overlap)
272
+			foreach ((array)$overlapping_events as $k => $overlap)
273 273
 			{
274
-				if ($overlap['id'] == $event['id'] ||	// that's the event itself
275
-					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
274
+				if ($overlap['id'] == $event['id'] || // that's the event itself
275
+					$overlap['id'] == $event['reference'] || // event is an exception of overlap
276 276
 					$overlap['non_blocking'])			// that's a non_blocking event
277 277
 				{
278 278
 					continue;
279 279
 				}
280 280
 				if ($this->debug > 3 || $this->debug == 'update')
281 281
 				{
282
-					$this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap);
282
+					$this->debug_message('calendar_boupdate::update() checking overlapping event %1', false, $overlap);
283 283
 				}
284 284
 				// check if the overlap is with a rejected participant or within the allowed quantity
285
-				$common_parts = array_intersect($users,array_keys($overlap['participants']));
286
-				foreach($common_parts as $n => $uid)
285
+				$common_parts = array_intersect($users, array_keys($overlap['participants']));
286
+				foreach ($common_parts as $n => $uid)
287 287
 				{
288 288
 					$status = $overlap['participants'][$uid];
289 289
 					calendar_so::split_status($status, $q, $r);
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 						unset($common_parts[$n]);
293 293
 						continue;
294 294
 					}
295
-					if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity))
295
+					if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity))
296 296
 					{
297
-						continue;	// no quantity check: quantity allways 1 ==> conflict
297
+						continue; // no quantity check: quantity allways 1 ==> conflict
298 298
 					}
299 299
 					if (!isset($max_quantity[$uid]))
300 300
 					{
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 					$quantity[$uid] += $q;
305 305
 					if ($quantity[$uid] <= $max_quantity[$uid])
306 306
 					{
307
-						$possible_quantity_conflicts[$uid][] =& $overlapping_events[$k];	// an other event can give the conflict
307
+						$possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict
308 308
 						unset($common_parts[$n]);
309 309
 						continue;
310 310
 					}
@@ -314,20 +314,20 @@  discard block
 block discarded – undo
314 314
 				{
315 315
 					if ($this->debug > 3 || $this->debug == 'update')
316 316
 					{
317
-						$this->debug_message('calendar_boupdate::update() conflicts with the following participants found %1',false,$common_parts);
317
+						$this->debug_message('calendar_boupdate::update() conflicts with the following participants found %1', false, $common_parts);
318 318
 					}
319
-					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k];
319
+					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k];
320 320
 				}
321 321
 			}
322 322
 			// check if we are withing the allowed quantity and if not add all events using that resource
323 323
 			// seems this function is doing very strange things, it gives empty conflicts
324
-			foreach($max_quantity as $uid => $max)
324
+			foreach ($max_quantity as $uid => $max)
325 325
 			{
326 326
 				if ($quantity[$uid] > $max)
327 327
 				{
328
-					foreach((array)$possible_quantity_conflicts[$uid] as $conflict)
328
+					foreach ((array)$possible_quantity_conflicts[$uid] as $conflict)
329 329
 					{
330
-						$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k];
330
+						$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k];
331 331
 					}
332 332
 				}
333 333
 			}
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 
336 336
 			if (count($conflicts))
337 337
 			{
338
-				foreach($conflicts as $key => $conflict)
338
+				foreach ($conflicts as $key => $conflict)
339 339
 				{
340
-						$conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']);
341
-					if (!$this->check_perms(EGW_ACL_READ,$conflict))
340
+						$conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']);
341
+					if (!$this->check_perms(EGW_ACL_READ, $conflict))
342 342
 					{
343 343
 						$conflicts[$key] = array(
344 344
 							'id'    => $conflict['id'],
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 				}
352 352
 				if ($this->debug > 2 || $this->debug == 'update')
353 353
 				{
354
-					$this->debug_message('calendar_boupdate::update() %1 conflicts found %2',false,count($conflicts),$conflicts);
354
+					$this->debug_message('calendar_boupdate::update() %1 conflicts found %2', false, count($conflicts), $conflicts);
355 355
 				}
356 356
 				return $conflicts;
357 357
 			}
@@ -365,33 +365,33 @@  discard block
 block discarded – undo
365 365
 			return $cal_id;
366 366
 		}
367 367
 
368
-		$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
368
+		$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
369 369
 		//echo "new $cal_id="; _debug_array($event);
370 370
 
371
-		if($old_event['deleted'] && $event['deleted'] == null)
371
+		if ($old_event['deleted'] && $event['deleted'] == null)
372 372
 		{
373 373
 			// Restored, bring back links
374 374
 			egw_link::restore('calendar', $cal_id);
375 375
 		}
376 376
 		if ($this->log_file)
377 377
 		{
378
-			$this->log2file($event2save,$event,$old_event);
378
+			$this->log2file($event2save, $event, $old_event);
379 379
 		}
380 380
 		// send notifications
381
-		if(!$skip_notification)
381
+		if (!$skip_notification)
382 382
 		{
383 383
 			if ($new_event)
384 384
 			{
385
-				$this->send_update(MSG_ADDED,$event['participants'],'',$event);
385
+				$this->send_update(MSG_ADDED, $event['participants'], '', $event);
386 386
 			}
387 387
 			else // update existing event
388 388
 			{
389
-				$this->check4update($event,$old_event);
389
+				$this->check4update($event, $old_event);
390 390
 			}
391 391
 		}
392 392
 
393 393
 		// notify the link-class about the update, as other apps may be subscribt to it
394
-		egw_link::notify_update('calendar',$cal_id,$event);
394
+		egw_link::notify_update('calendar', $cal_id, $event);
395 395
 
396 396
 		return $cal_id;
397 397
 	}
@@ -403,22 +403,22 @@  discard block
 block discarded – undo
403 403
 	 * @param array $old_event =null old event with already invited participants
404 404
 	 * @return array removed participants because of missing invite grants
405 405
 	 */
406
-	public function remove_no_acl_invite(array &$event,array $old_event=null)
406
+	public function remove_no_acl_invite(array &$event, array $old_event = null)
407 407
 	{
408 408
 		if (!$this->require_acl_invite)
409 409
 		{
410
-			return array();	// nothing to check, everyone can invite everyone else
410
+			return array(); // nothing to check, everyone can invite everyone else
411 411
 		}
412 412
 		if ($event['id'] && is_null($old_event))
413 413
 		{
414 414
 			$old_event = $this->read($event['id']);
415 415
 		}
416 416
 		$removed = array();
417
-		foreach(array_keys((array)$event['participants']) as $uid)
417
+		foreach (array_keys((array)$event['participants']) as $uid)
418 418
 		{
419 419
 			if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid))
420 420
 			{
421
-				unset($event['participants'][$uid]);	// remove participant
421
+				unset($event['participants'][$uid]); // remove participant
422 422
 				$removed[] = $uid;
423 423
 			}
424 424
 		}
@@ -434,19 +434,19 @@  discard block
 block discarded – undo
434 434
 	 */
435 435
 	public function check_acl_invite($uid)
436 436
 	{
437
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
437
+		if (!is_numeric($uid)) return true; // nothing implemented for resources so far
438 438
 
439 439
 		if (!$this->require_acl_invite)
440 440
 		{
441
-			$ret = true;	// no grant required
441
+			$ret = true; // no grant required
442 442
 		}
443 443
 		elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g')
444 444
 		{
445
-			$ret = true;	// grant only required for groups
445
+			$ret = true; // grant only required for groups
446 446
 		}
447 447
 		else
448 448
 		{
449
-			$ret = $this->check_perms(EGW_ACL_INVITE,0,$uid);
449
+			$ret = $this->check_perms(EGW_ACL_INVITE, 0, $uid);
450 450
 		}
451 451
 		//error_log(__METHOD__."($uid) = ".array2string($ret));
452 452
 		//echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n";
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 	 * @param array $old_event the event before the update
461 461
 	 * @todo check if there is a real change, not assume every save is a change
462 462
 	 */
463
-	function check4update($new_event,$old_event)
463
+	function check4update($new_event, $old_event)
464 464
 	{
465 465
 		//error_log(__METHOD__."($new_event[title])");
466 466
 		$modified = $added = $deleted = array();
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
 		//echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n";
469 469
 
470 470
 		// Find modified and deleted participants ...
471
-		foreach($old_event['participants'] as $old_userid => $old_status)
471
+		foreach ($old_event['participants'] as $old_userid => $old_status)
472 472
 		{
473
-			if(isset($new_event['participants'][$old_userid]))
473
+			if (isset($new_event['participants'][$old_userid]))
474 474
 			{
475 475
 				$modified[$old_userid] = $new_event['participants'][$old_userid];
476 476
 			}
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 			}
481 481
 		}
482 482
 		// Find new participants ...
483
-		foreach(array_keys((array)$new_event['participants']) as $new_userid)
483
+		foreach (array_keys((array)$new_event['participants']) as $new_userid)
484 484
 		{
485
-			if(!isset($old_event['participants'][$new_userid]))
485
+			if (!isset($old_event['participants'][$new_userid]))
486 486
 			{
487 487
 				$added[$new_userid] = 'U';
488 488
 			}
489 489
 		}
490 490
 		//echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n";
491
-		if(count($added) || count($modified) || count($deleted))
491
+		if (count($added) || count($modified) || count($deleted))
492 492
 		{
493
-			if(count($added))
493
+			if (count($added))
494 494
 			{
495
-				$this->send_update(MSG_ADDED,$added,$old_event,$new_event);
495
+				$this->send_update(MSG_ADDED, $added, $old_event, $new_event);
496 496
 			}
497
-			if(count($modified))
497
+			if (count($modified))
498 498
 			{
499
-				$this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event);
499
+				$this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event);
500 500
 			}
501
-			if(count($deleted))
501
+			if (count($deleted))
502 502
 			{
503
-				$this->send_update(MSG_DISINVITE,$deleted,$new_event);
503
+				$this->send_update(MSG_DISINVITE, $deleted, $new_event);
504 504
 			}
505 505
 		}
506 506
 	}
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
 	 * @param string $status of current user
518 518
 	 * @return boolean true = update requested, false otherwise
519 519
 	 */
520
-	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null)
520
+	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null)
521 521
 	{
522 522
 		if ($msg_type == MSG_ALARM)
523 523
 		{
524
-			return True;	// always True for now
524
+			return True; // always True for now
525 525
 		}
526 526
 		$want_update = 0;
527 527
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 		//
530 530
 		$msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED;
531 531
 
532
-		switch($ru = $part_prefs['calendar']['receive_updates'])
532
+		switch ($ru = $part_prefs['calendar']['receive_updates'])
533 533
 		{
534 534
 			case 'responses':
535 535
 				++$want_update;
@@ -543,8 +543,8 @@  discard block
 block discarded – undo
543 543
 			default:
544 544
 				if (is_array($new_event) && is_array($old_event))
545 545
 				{
546
-					$diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])),
547
-						abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end'])));
546
+					$diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])),
547
+						abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end'])));
548 548
 					$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
549 549
 					if ($msg_type == MSG_MODIFIED && $diff > $check)
550 550
 					{
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 				if (!is_numeric($userid) && $role == 'CHAIR' &&
565 565
 					($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED))))
566 566
 				{
567
-					switch($msg_type)
567
+					switch ($msg_type)
568 568
 					{
569 569
 						case MSG_DELETED:	// treat deleting event as rejection to organizer
570 570
 							$msg_type = MSG_REJECTED;
571 571
 							break;
572 572
 						case MSG_ADDED:		// new events use added, but organizer needs status
573
-							switch($status[0])
573
+							switch ($status[0])
574 574
 							{
575 575
 								case 'A': $msg_type = MSG_ACCEPTED; break;
576 576
 								case 'R': $msg_type = MSG_REJECTED; break;
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 	 * @param string $role ='REQ-PARTICIPANT'
596 596
 	 * @return boolean true if user requested to be notified, false if not
597 597
 	 */
598
-	static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT')
598
+	static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT')
599 599
 	{
600 600
 		// check if email is from a user
601 601
 		if (is_numeric($user_or_email))
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 				)
620 620
 			);
621 621
 		}
622
-		switch($ical_method)
622
+		switch ($ical_method)
623 623
 		{
624 624
 			default:
625 625
 			case 'REQUEST':
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
 	 * @param string& $action=null on return verbose name
645 645
 	 * @param string& $msg=null on return notification message
646 646
 	 */
647
-	function msg_type2ical_method($msg_type, &$action=null, &$msg=null)
647
+	function msg_type2ical_method($msg_type, &$action = null, &$msg = null)
648 648
 	{
649
-		switch($msg_type)
649
+		switch ($msg_type)
650 650
 		{
651 651
 			case MSG_DELETED:
652 652
 				$action = 'Canceled';
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 		$msg = $this->cal_prefs['notify'.$pref];
699 699
 		if (empty($msg))
700 700
 		{
701
-			$msg = $this->cal_prefs['notifyAdded'];	// use a default
701
+			$msg = $this->cal_prefs['notifyAdded']; // use a default
702 702
 		}
703 703
 		//error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'");
704 704
 		return $method;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 	 * @param int $user =0 User who started the notify, default current user
715 715
 	 * @return bool true/false
716 716
 	 */
717
-	function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0)
717
+	function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0)
718 718
 	{
719 719
 		//error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event));
720 720
 		if (!is_array($to_notify))
@@ -726,11 +726,11 @@  discard block
 block discarded – undo
726 726
 		$owner = $old_event ? $old_event['owner'] : $new_event['owner'];
727 727
 		if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM)
728 728
 		{
729
-			$to_notify[$owner] = 'OCHAIR';	// always include the event-owner
729
+			$to_notify[$owner] = 'OCHAIR'; // always include the event-owner
730 730
 		}
731 731
 
732 732
 		// ignore events in the past (give a tolerance of 10 seconds for the script)
733
-		if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
733
+		if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
734 734
 		{
735 735
 			return False;
736 736
 		}
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 			$restore_tz = $tz;
741 741
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
742 742
 		}
743
-		$temp_user = $GLOBALS['egw_info']['user'];	// save user-date of the enviroment to restore it after
743
+		$temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after
744 744
 
745 745
 		if (!$user)
746 746
 		{
@@ -756,17 +756,17 @@  discard block
 block discarded – undo
756 756
 		$event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event;
757 757
 
758 758
 		// add all group-members to the notification, unless they are already participants
759
-		foreach($to_notify as $userid => $statusid)
759
+		foreach ($to_notify as $userid => $statusid)
760 760
 		{
761 761
 			if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' &&
762 762
 				($members = $GLOBALS['egw']->accounts->member($userid)))
763 763
 			{
764
-				foreach($members as $member)
764
+				foreach ($members as $member)
765 765
 				{
766 766
 					$member = $member['account_id'];
767 767
 					if (!isset($to_notify[$member]))
768 768
 					{
769
-						$to_notify[$member] = 'G';	// Group-invitation
769
+						$to_notify[$member] = 'G'; // Group-invitation
770 770
 					}
771 771
 				}
772 772
 			}
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		if ($old_event) $olddate = new egw_time($old_event['start']);
779 779
 		//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
780 780
 		$owner_prefs = $ics = null;
781
-		foreach($to_notify as $userid => $statusid)
781
+		foreach ($to_notify as $userid => $statusid)
782 782
 		{
783 783
 			$res_info = $quantity = $role = null;
784 784
 			calendar_so::split_status($statusid, $quantity, $role);
@@ -801,14 +801,14 @@  discard block
 block discarded – undo
801 801
 
802 802
 				if (!isset($userid))
803 803
 				{
804
-					if (empty($res_info['email'])) continue;	// no way to notify
804
+					if (empty($res_info['email'])) continue; // no way to notify
805 805
 					// check if event-owner wants non-EGroupware users notified
806 806
 					if (is_null($owner_prefs))
807 807
 					{
808 808
 						$preferences = new preferences($owner);
809 809
 						$owner_prefs = $preferences->read_repository();
810 810
 					}
811
-					if ($role != 'CHAIR' &&		// always notify externals CHAIRs
811
+					if ($role != 'CHAIR' && // always notify externals CHAIRs
812 812
 						(empty($owner_prefs['calendar']['notify_externals']) ||
813 813
 						$owner_prefs['calendar']['notify_externals'] == 'no'))
814 814
 					{
@@ -820,12 +820,12 @@  discard block
 block discarded – undo
820 820
 
821 821
 			if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g')
822 822
 			{
823
-				continue;	// dont notify rejected participants or groups
823
+				continue; // dont notify rejected participants or groups
824 824
 			}
825 825
 
826
-			if($userid != $GLOBALS['egw_info']['user']['account_id'] ||
826
+			if ($userid != $GLOBALS['egw_info']['user']['account_id'] ||
827 827
 				($userid == $GLOBALS['egw_info']['user']['account_id'] &&
828
-					$user_prefs['calendar']['receive_own_updates']==1) ||
828
+					$user_prefs['calendar']['receive_own_updates'] == 1) ||
829 829
 				$msg_type == MSG_ALARM)
830 830
 			{
831 831
 				$tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop)
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
 				{
834 834
 					$preferences = new preferences($userid);
835 835
 					$GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository();
836
-					$GLOBALS['egw']->accounts->get_account_name($userid,$lid,$tfn,$tln);
837
-					$fullname = common::display_fullname('',$tfn,$tln);
836
+					$GLOBALS['egw']->accounts->get_account_name($userid, $lid, $tfn, $tln);
837
+					$fullname = common::display_fullname('', $tfn, $tln);
838 838
 				}
839 839
 				else	// external email address: use preferences of event-owner, plus some hardcoded settings (eg. ical notification)
840 840
 				{
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 					}
846 846
 					$part_prefs = $owner_prefs;
847 847
 					$part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals'];
848
-					$part_prefs['calendar']['update_format'] = 'ical';	// use ical format
848
+					$part_prefs['calendar']['update_format'] = 'ical'; // use ical format
849 849
 					$fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid;
850 850
 				}
851 851
 				$m_type = $msg_type;
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
874 874
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
875 875
 				$timeformat = $part_prefs['common']['timeformat'];
876
-				switch($timeformat)
876
+				switch ($timeformat)
877 877
 				{
878 878
 			  		case '24':
879 879
 						$timeformat = 'H:i';
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 						$timeformat = 'h:i a';
883 883
 						break;
884 884
 				}
885
-				$timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat;
885
+				$timeformat = $part_prefs['common']['dateformat'].', '.$timeformat;
886 886
 
887 887
 				$startdate->setTimezone($timezone);
888 888
 				$details['startdate'] = $startdate->format($timeformat);
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 				$details['enddate'] = $enddate->format($timeformat);
892 892
 
893 893
 				$modified->setTimezone($timezone);
894
-				$details['updated'] = $modified->format($timeformat) . ', ' . common::grab_owner_name($event['modifier']);
894
+				$details['updated'] = $modified->format($timeformat).', '.common::grab_owner_name($event['modifier']);
895 895
 
896 896
 				if ($old_event != False)
897 897
 				{
@@ -900,15 +900,14 @@  discard block
 block discarded – undo
900 900
 				}
901 901
 				//error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]");
902 902
 
903
-				list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
903
+				list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
904 904
 				// alarm is NOT an iCal method, therefore we have to use extened (no iCal)
905
-				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
905
+				switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
906 906
 				{
907
-					case 'ical':
908
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
907
+					case 'ical' : if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
909 908
 						{
910 909
 							$calendar_ical = new calendar_ical();
911
-							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
910
+							$calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ
912 911
 							// we need to pass $event[id] so iCal class reads event again,
913 912
 							// as event is in user TZ, but iCal class expects server TZ!
914 913
 							$ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']),
@@ -927,11 +926,11 @@  discard block
 block discarded – undo
927 926
 					case 'extended':
928 927
 
929 928
 						$details_body = lang('Event Details follow').":\n";
930
-						foreach($event_arr as $key => $val)
929
+						foreach ($event_arr as $key => $val)
931 930
 						{
932
-							if(!empty($details[$key]))
931
+							if (!empty($details[$key]))
933 932
 							{
934
-								switch($key)
933
+								switch ($key)
935 934
 								{
936 935
 							 		case 'access':
937 936
 									case 'priority':
@@ -940,7 +939,7 @@  discard block
 block discarded – undo
940 939
 									case 'title':
941 940
 										break;
942 941
 									default:
943
-										$details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
942
+										$details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]);
944 943
 										break;
945 944
 							 	}
946 945
 							}
@@ -948,7 +947,7 @@  discard block
 block discarded – undo
948 947
 						break;
949 948
 				}
950 949
 				// send via notification_app
951
-				if($GLOBALS['egw_info']['apps']['notifications']['enabled'])
950
+				if ($GLOBALS['egw_info']['apps']['notifications']['enabled'])
952 951
 				{
953 952
 					try {
954 953
 						//error_log(__METHOD__."() notifying $userid from $senderid: $subject");
@@ -972,7 +971,7 @@  discard block
 block discarded – undo
972 971
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
973 972
 						$notification->set_popuplinks(array($details['link_arr']));
974 973
 
975
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
974
+						if (is_array($attachment)) { $notification->set_attachments(array($attachment)); }
976 975
 						$notification->send();
977 976
 					}
978 977
 					catch (Exception $exception) {
@@ -1004,14 +1003,14 @@  discard block
 block discarded – undo
1004 1003
 		return true;
1005 1004
 	}
1006 1005
 
1007
-	function get_update_message($event,$added)
1006
+	function get_update_message($event, $added)
1008 1007
 	{
1009 1008
 		$nul = null;
1010
-		$details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul);
1009
+		$details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul);
1011 1010
 
1012 1011
 		$notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified'];
1013 1012
 
1014
-		return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
1013
+		return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
1015 1014
 	}
1016 1015
 
1017 1016
 	/**
@@ -1025,37 +1024,37 @@  discard block
 block discarded – undo
1025 1024
 		//echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n";
1026 1025
 		$GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner'];
1027 1026
 
1028
-		$event_time_user = egw_time::server2user($alarm['time'] + $alarm['offset']);	// alarm[time] is in server-time, read requires user-time
1029
-		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user)))
1027
+		$event_time_user = egw_time::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time
1028
+		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user)))
1030 1029
 		{
1031
-			return False;	// event not found
1030
+			return False; // event not found
1032 1031
 		}
1033 1032
 		if ($alarm['all'])
1034 1033
 		{
1035 1034
 			$to_notify = $event['participants'];
1036 1035
 		}
1037
-		elseif ($this->check_perms(EGW_ACL_READ,$event))	// checks agains $this->owner set to $alarm[owner]
1036
+		elseif ($this->check_perms(EGW_ACL_READ, $event))	// checks agains $this->owner set to $alarm[owner]
1038 1037
 		{
1039 1038
 			$to_notify[$alarm['owner']] = 'A';
1040 1039
 		}
1041 1040
 		else
1042 1041
 		{
1043
-			return False;	// no rights
1042
+			return False; // no rights
1044 1043
 		}
1045 1044
 		// need to load calendar translations and set currentapp, so calendar can reload a different lang
1046 1045
 		translation::add_app('calendar');
1047 1046
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
1048 1047
 
1049
-		$ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
1048
+		$ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']);
1050 1049
 
1051 1050
 		// create a new alarm for recuring events for the next event, if one exists
1052
-		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1)))
1051
+		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1)))
1053 1052
 		{
1054 1053
 			$alarm['time'] = $this->date2ts($event['start']) - $alarm['offset'];
1055 1054
 			unset($alarm['times']);
1056 1055
 			unset($alarm['next']);
1057 1056
 			//error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm));
1058
-			$this->save_alarm($alarm['cal_id'], $alarm, false);	// false = do NOT update timestamp, as nothing changed for iCal clients
1057
+			$this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients
1059 1058
 		}
1060 1059
 		return $ret;
1061 1060
 	}
@@ -1071,15 +1070,15 @@  discard block
 block discarded – undo
1071 1070
 	 * DEPRECATED: we allways (have to) update timestamp, as they are required for sync!
1072 1071
 	 * @return int|boolean $cal_id > 0 or false on error (eg. permission denied)
1073 1072
 	 */
1074
-	function save($event,$ignore_acl=false,$updateTS=true)
1073
+	function save($event, $ignore_acl = false, $updateTS = true)
1075 1074
 	{
1076 1075
 		unset($updateTS);
1077 1076
 		//error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)");
1078 1077
 
1079 1078
 		// check if user has the permission to update / create the event
1080
-		if (!$ignore_acl && ($event['id'] && !$this->check_perms(EGW_ACL_EDIT,$event['id']) ||
1081
-			!$event['id'] && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner']) &&
1082
-			!$this->check_perms(EGW_ACL_ADD,0,$event['owner'])))
1079
+		if (!$ignore_acl && ($event['id'] && !$this->check_perms(EGW_ACL_EDIT, $event['id']) ||
1080
+			!$event['id'] && !$this->check_perms(EGW_ACL_EDIT, 0, $event['owner']) &&
1081
+			!$this->check_perms(EGW_ACL_ADD, 0, $event['owner'])))
1083 1082
 		{
1084 1083
 			return false;
1085 1084
 		}
@@ -1124,19 +1123,19 @@  discard block
 block discarded – undo
1124 1123
 				$time->setUser();
1125 1124
 				$save_event['recur_enddate'] = egw_time::to($time, 'ts');
1126 1125
 			}
1127
-			$timestamps = array('modified','created');
1126
+			$timestamps = array('modified', 'created');
1128 1127
 			// all-day events are handled in server time
1129 1128
 			$event['tzid'] = $save_event['tzid'] = egw_time::$server_timezone->getName();
1130 1129
 		}
1131 1130
 		else
1132 1131
 		{
1133
-			$timestamps = array('start','end','modified','created','recur_enddate','recurrence');
1132
+			$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence');
1134 1133
 		}
1135 1134
 		// we run all dates through date2ts, to adjust to server-time and the possible date-formats
1136
-		foreach($timestamps as $ts)
1135
+		foreach ($timestamps as $ts)
1137 1136
 		{
1138 1137
 			// we convert here from user-time to timestamps in server-time!
1139
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1138
+			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0;
1140 1139
 		}
1141 1140
 		// convert tzid name to integer tz_id, of set user default
1142 1141
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1146,7 +1145,7 @@  discard block
 block discarded – undo
1146 1145
 		// same with the recur exceptions
1147 1146
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
1148 1147
 		{
1149
-			foreach($event['recur_exception'] as &$date)
1148
+			foreach ($event['recur_exception'] as &$date)
1150 1149
 			{
1151 1150
 				if ($event['whole_day'])
1152 1151
 				{
@@ -1155,7 +1154,7 @@  discard block
 block discarded – undo
1155 1154
 				}
1156 1155
 				else
1157 1156
 				{
1158
-					$date = $this->date2ts($date,true);
1157
+					$date = $this->date2ts($date, true);
1159 1158
 				}
1160 1159
 			}
1161 1160
 			unset($date);
@@ -1163,7 +1162,7 @@  discard block
 block discarded – undo
1163 1162
 		// same with the alarms
1164 1163
 		if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start']))
1165 1164
 		{
1166
-			foreach($event['alarm'] as $id => &$alarm)
1165
+			foreach ($event['alarm'] as $id => &$alarm)
1167 1166
 			{
1168 1167
 				// remove alarms belonging to not longer existing or rejected participants
1169 1168
 				if ($alarm['owner'] && isset($event['participants']))
@@ -1181,15 +1180,14 @@  discard block
 block discarded – undo
1181 1180
 		// update all existing alarm times, in case alarm got moved and alarms are not include in $event
1182 1181
 		if ($old_event && is_array($old_event['alarm']) && isset($event['start']))
1183 1182
 		{
1184
-			foreach($old_event['alarm'] as $id => &$alarm)
1183
+			foreach ($old_event['alarm'] as $id => &$alarm)
1185 1184
 			{
1186 1185
 				if (!isset($event['alarm'][$id]))
1187 1186
 				{
1188 1187
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1189 1188
 					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1190 1189
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1191
-					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1192
-						$old_event['participants'][$alarm['owner']];
1190
+					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']];
1193 1191
 					if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R')
1194 1192
 					{
1195 1193
 						$this->so->save_alarm($event['id'], $alarm);
@@ -1215,7 +1213,7 @@  discard block
 block discarded – undo
1215 1213
 		}
1216 1214
 		$set_recurrences = false;
1217 1215
 		$set_recurrences_start = 0;
1218
-		if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1216
+		if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1219 1217
 		{
1220 1218
 			$save_event['id'] = $cal_id;
1221 1219
 			// unset participants to enforce the default stati for all added recurrences
@@ -1227,7 +1225,7 @@  discard block
 block discarded – undo
1227 1225
 		// create links for new participants from addressbook, if configured
1228 1226
 		if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants'])
1229 1227
 		{
1230
-			foreach($event['participants'] as $uid => $status)
1228
+			foreach ($event['participants'] as $uid => $status)
1231 1229
 			{
1232 1230
 				$user_type = $user_id = null;
1233 1231
 				calendar_so::split_user($uid, $user_type, $user_id);
@@ -1240,7 +1238,7 @@  discard block
 block discarded – undo
1240 1238
 
1241 1239
 		// Update history
1242 1240
 		$tracking = new calendar_tracking($this);
1243
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1241
+		if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id;
1244 1242
 		$tracking->track($event, $old_event);
1245 1243
 
1246 1244
 		return $cal_id;
@@ -1255,16 +1253,16 @@  discard block
 block discarded – undo
1255 1253
 	 * @param array|int $event event array or id of the event
1256 1254
 	 * @return boolean
1257 1255
 	 */
1258
-	function check_status_perms($uid,$event)
1256
+	function check_status_perms($uid, $event)
1259 1257
 	{
1260 1258
 		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1261 1259
 		{
1262 1260
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1263 1261
 
1264
-			return $this->check_perms(EGW_ACL_EDIT,0,$event['owner']);
1262
+			return $this->check_perms(EGW_ACL_EDIT, 0, $event['owner']);
1265 1263
 		}
1266 1264
 		// check if we have a category acl for the event or not (null)
1267
-		$access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event);
1265
+		$access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event);
1268 1266
 		if (!is_null($access))
1269 1267
 		{
1270 1268
 			return $access;
@@ -1274,17 +1272,17 @@  discard block
 block discarded – undo
1274 1272
 		{
1275 1273
 			$resource = $this->resource_info($uid);
1276 1274
 
1277
-			return EGW_ACL_EDIT & $resource['rights'];
1275
+			return EGW_ACL_EDIT&$resource['rights'];
1278 1276
 		}
1279 1277
 		if (!is_array($event) && !($event = $this->read($event))) return false;
1280 1278
 
1281 1279
 		// regular user and groups (need to check memberships too)
1282 1280
 		if (!isset($event['participants'][$uid]))
1283 1281
 		{
1284
-			$memberships = $GLOBALS['egw']->accounts->memberships($uid,true);
1282
+			$memberships = $GLOBALS['egw']->accounts->memberships($uid, true);
1285 1283
 		}
1286 1284
 		$memberships[] = $uid;
1287
-		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(EGW_ACL_EDIT,0,$uid);
1285
+		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(EGW_ACL_EDIT, 0, $uid);
1288 1286
 	}
1289 1287
 
1290 1288
 	/**
@@ -1298,16 +1296,16 @@  discard block
 block discarded – undo
1298 1296
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1299 1297
 	 * 	null = cat has no acl
1300 1298
 	 */
1301
-	function check_cat_acl($right,$event)
1299
+	function check_cat_acl($right, $event)
1302 1300
 	{
1303 1301
 		if (!is_array($event)) $event = $this->read($event);
1304 1302
 
1305 1303
 		$ret = null;
1306 1304
 		if ($event['category'])
1307 1305
 		{
1308
-			foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id)
1306
+			foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id)
1309 1307
 			{
1310
-				$access = self::has_cat_right($right,$cat_id,$this->user);
1308
+				$access = self::has_cat_right($right, $cat_id, $this->user);
1311 1309
 				if ($access === true)
1312 1310
 				{
1313 1311
 					$ret = true;
@@ -1315,7 +1313,7 @@  discard block
 block discarded – undo
1315 1313
 				}
1316 1314
 				if ($access === false)
1317 1315
 				{
1318
-					$ret = false;	// cat denies access --> check further cats
1316
+					$ret = false; // cat denies access --> check further cats
1319 1317
 				}
1320 1318
 			}
1321 1319
 		}
@@ -1336,12 +1334,12 @@  discard block
 block discarded – undo
1336 1334
 	 * @param int $cat_id =null null to return array with all cats
1337 1335
 	 * @return array with account_id => right pairs
1338 1336
 	 */
1339
-	public static function get_cat_rights($cat_id=null)
1337
+	public static function get_cat_rights($cat_id = null)
1340 1338
 	{
1341 1339
 		if (!isset(self::$cat_rights_cache))
1342 1340
 		{
1343
-			self::$cat_rights_cache = egw_cache::getSession('calendar','cat_rights',
1344
-				array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar'));
1341
+			self::$cat_rights_cache = egw_cache::getSession('calendar', 'cat_rights',
1342
+				array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar'));
1345 1343
 		}
1346 1344
 		//echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n";
1347 1345
 		return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache;
@@ -1354,7 +1352,7 @@  discard block
 block discarded – undo
1354 1352
 	 * @param int $user
1355 1353
 	 * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together
1356 1354
 	 */
1357
-	public static function set_cat_rights($cat_id,$user,$rights)
1355
+	public static function set_cat_rights($cat_id, $user, $rights)
1358 1356
 	{
1359 1357
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1360 1358
 		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
@@ -1364,15 +1362,15 @@  discard block
 block discarded – undo
1364 1362
 			if ($rights)
1365 1363
 			{
1366 1364
 				self::$cat_rights_cache['L'.$cat_id][$user] = $rights;
1367
-				$GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights);
1365
+				$GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights);
1368 1366
 			}
1369 1367
 			else
1370 1368
 			{
1371 1369
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1372 1370
 				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1373
-				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1371
+				$GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user);
1374 1372
 			}
1375
-			egw_cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
1373
+			egw_cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache);
1376 1374
 		}
1377 1375
 	}
1378 1376
 
@@ -1383,9 +1381,9 @@  discard block
 block discarded – undo
1383 1381
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1384 1382
 	 * 	null = cat has no acl
1385 1383
 	 */
1386
-	public static function has_cat_right($right,$cat_id,$user)
1384
+	public static function has_cat_right($right, $cat_id, $user)
1387 1385
 	{
1388
-		static $cache=null;
1386
+		static $cache = null;
1389 1387
 
1390 1388
 		if (!isset($cache[$cat_id]))
1391 1389
 		{
@@ -1393,21 +1391,21 @@  discard block
 block discarded – undo
1393 1391
 			$cat_rights = self::get_cat_rights($cat_id);
1394 1392
 			if (!is_null($cat_rights))
1395 1393
 			{
1396
-				static $memberships=null;
1394
+				static $memberships = null;
1397 1395
 				if (is_null($memberships))
1398 1396
 				{
1399
-					$memberships = $GLOBALS['egw']->accounts->memberships($user,true);
1397
+					$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1400 1398
 					$memberships[] = $user;
1401 1399
 				}
1402
-				foreach($cat_rights as $uid => $value)
1400
+				foreach ($cat_rights as $uid => $value)
1403 1401
 				{
1404 1402
 					$all |= $value;
1405
-					if (in_array($uid,$memberships)) $own |= $value;
1403
+					if (in_array($uid, $memberships)) $own |= $value;
1406 1404
 				}
1407 1405
 			}
1408
-			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
1406
+			foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask)
1409 1407
 			{
1410
-				$cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask);
1408
+				$cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask);
1411 1409
 			}
1412 1410
 		}
1413 1411
 		//echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n";
@@ -1427,13 +1425,13 @@  discard block
 block discarded – undo
1427 1425
 	 * @param boolean $skip_notification =false true: do not send notification messages
1428 1426
 	 * @return int number of changed recurrences
1429 1427
 	 */
1430
-	function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false)
1428
+	function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false)
1431 1429
 	{
1432 1430
 		unset($updateTS);
1433 1431
 
1434 1432
 		$cal_id = is_array($event) ? $event['id'] : $event;
1435 1433
 		//echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n";
1436
-		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event)))
1434
+		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event)))
1437 1435
 		{
1438 1436
 			return false;
1439 1437
 		}
@@ -1442,16 +1440,16 @@  discard block
 block discarded – undo
1442 1440
 		if ($this->log)
1443 1441
 		{
1444 1442
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1445
-				"($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile);
1443
+				"($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile);
1446 1444
 		}
1447 1445
 		$old_event = $this->read($cal_id, $recur_date, false, 'server');
1448
-		if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0],
1449
-				is_numeric($uid)?$uid:substr($uid,1),$status,
1450
-				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1446
+		if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0],
1447
+				is_numeric($uid) ? $uid : substr($uid, 1), $status,
1448
+				$recur_date ? $this->date2ts($recur_date, true) : 0, $role)))
1451 1449
 		{
1452 1450
 			if ($status == 'R')	// remove alarms belonging to rejected participants
1453 1451
 			{
1454
-				foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1452
+				foreach (isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1455 1453
 				{
1456 1454
 					if ((string)$alarm['owner'] === (string)$uid)
1457 1455
 					{
@@ -1474,8 +1472,8 @@  discard block
 block discarded – undo
1474 1472
 			if (isset($status2msg[$status]) && !$skip_notification)
1475 1473
 			{
1476 1474
 				if (!is_array($event)) $event = $this->read($cal_id);
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);
1475
+				if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event
1476
+				$this->send_update($status2msg[$status], $event['participants'], $event);
1479 1477
 			}
1480 1478
 
1481 1479
 			// Update history
@@ -1495,14 +1493,14 @@  discard block
 block discarded – undo
1495 1493
 	 * @param int $recur_date =0 date to change, or 0 = all since now
1496 1494
 	 * @param boolean $skip_notification Do not send notifications.  Parameter passed on to set_status().
1497 1495
 	 */
1498
-	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1496
+	function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false)
1499 1497
 	{
1500 1498
 		if (!isset($new_event['participants'])) return;
1501 1499
 
1502 1500
 		// check the old list against the new list
1503 1501
 		foreach ($old_event['participants'] as $userid => $status)
1504 1502
   		{
1505
-            if (!isset($new_event['participants'][$userid])){
1503
+            if (!isset($new_event['participants'][$userid])) {
1506 1504
             	// Attendee will be deleted this way
1507 1505
             	$new_event['participants'][$userid] = 'G';
1508 1506
             }
@@ -1515,7 +1513,7 @@  discard block
 block discarded – undo
1515 1513
 		// write the changes
1516 1514
 		foreach ($new_event['participants'] as $userid => $status)
1517 1515
 		{
1518
-			$this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification);
1516
+			$this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification);
1519 1517
 		}
1520 1518
     }
1521 1519
 
@@ -1530,43 +1528,43 @@  discard block
 block discarded – undo
1530 1528
 	 * @param int &$exceptions_kept=null on return number of kept exceptions
1531 1529
 	 * @return boolean true on success, false on error (usually permission denied)
1532 1530
 	 */
1533
-	function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false,
1534
-		$delete_exceptions=true, &$exceptions_kept=null)
1531
+	function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false,
1532
+		$delete_exceptions = true, &$exceptions_kept = null)
1535 1533
 	{
1536 1534
 		//error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)");
1537
-		if (!($event = $this->read($cal_id,$recur_date)) ||
1538
-			!$ignore_acl && !$this->check_perms(EGW_ACL_DELETE,$event))
1535
+		if (!($event = $this->read($cal_id, $recur_date)) ||
1536
+			!$ignore_acl && !$this->check_perms(EGW_ACL_DELETE, $event))
1539 1537
 		{
1540 1538
 			return false;
1541 1539
 		}
1542 1540
 
1543 1541
 		// Don't send notification if the event has already been deleted
1544
-		if(!$event['deleted'] && !$skip_notification)
1542
+		if (!$event['deleted'] && !$skip_notification)
1545 1543
 		{
1546
-			$this->send_update(MSG_DELETED,$event['participants'],$event);
1544
+			$this->send_update(MSG_DELETED, $event['participants'], $event);
1547 1545
 		}
1548 1546
 
1549 1547
 		if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE)
1550 1548
 		{
1551 1549
 			$config = config::read('phpgwapi');
1552
-			if(!$config['calendar_delete_history'] || $event['deleted'])
1550
+			if (!$config['calendar_delete_history'] || $event['deleted'])
1553 1551
 			{
1554 1552
 				$this->so->delete($cal_id);
1555 1553
 
1556 1554
 				// delete all links to the event
1557
-				egw_link::unlink(0,'calendar',$cal_id);
1555
+				egw_link::unlink(0, 'calendar', $cal_id);
1558 1556
 			}
1559 1557
 			elseif ($config['calendar_delete_history'])
1560 1558
 			{
1561 1559
 				// mark all links to the event as deleted, but keep them
1562
-				egw_link::unlink(0,'calendar',$cal_id,'','','',true);
1560
+				egw_link::unlink(0, 'calendar', $cal_id, '', '', '', true);
1563 1561
 
1564 1562
 				$event['deleted'] = $this->now;
1565 1563
 				$this->save($event, $ignore_acl);
1566 1564
 				// Actually delete alarms
1567 1565
 				if (isset($event['alarm']) && is_array($event['alarm']))
1568 1566
 				{
1569
-					foreach($event['alarm'] as $id => $alarm)
1567
+					foreach ($event['alarm'] as $id => $alarm)
1570 1568
 					{
1571 1569
 						$this->delete_alarm($id);
1572 1570
 					}
@@ -1589,7 +1587,7 @@  discard block
 block discarded – undo
1589 1587
 						if (!($exception = $this->read($id))) continue;
1590 1588
 						$exception['uid'] = common::generate_uid('calendar', $id);
1591 1589
 						$exception['reference'] = $exception['recurrence'] = 0;
1592
-						$this->update($exception, true, true, false, true, $msg=null, true);
1590
+						$this->update($exception, true, true, false, true, $msg = null, true);
1593 1591
 						++$exceptions_kept;
1594 1592
 					}
1595 1593
 				}
@@ -1601,9 +1599,9 @@  discard block
 block discarded – undo
1601 1599
 			if ($event['alarm'])
1602 1600
 			{
1603 1601
 				$next_recurrance = null;
1604
-				foreach($event['alarm'] as &$alarm)
1602
+				foreach ($event['alarm'] as &$alarm)
1605 1603
 				{
1606
-					if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date))
1604
+					if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date))
1607 1605
 					{
1608 1606
 						//error_log(__METHOD__.__LINE__.'->'.array2string($recur_date));
1609 1607
 						//error_log(__METHOD__.__LINE__.array2string($event));
@@ -1611,12 +1609,12 @@  discard block
 block discarded – undo
1611 1609
 						{
1612 1610
 							$checkdate = $recur_date;
1613 1611
 							//if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset'];
1614
-							if (($e = $this->read($cal_id,$checkdate+1)))
1612
+							if (($e = $this->read($cal_id, $checkdate + 1)))
1615 1613
 							{
1616 1614
 								$next_recurrance = $this->date2ts($e['start']);
1617 1615
 							}
1618 1616
 						}
1619
-						$alarm['time'] = $this->date2ts($next_recurrance, true);	// user to server-time
1617
+						$alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time
1620 1618
 						$alarm['cal_id'] = $cal_id;
1621 1619
 						unset($alarm['times']);
1622 1620
 						unset($alarm['next']);
@@ -1630,7 +1628,7 @@  discard block
 block discarded – undo
1630 1628
 			$event = $this->read($cal_id);
1631 1629
 			//if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer;
1632 1630
 			$event['recur_exception'][] = $recur_date;
1633
-			$this->save($event);// updates the content-history
1631
+			$this->save($event); // updates the content-history
1634 1632
 		}
1635 1633
 		if ($event['reference'])
1636 1634
 		{
@@ -1648,19 +1646,19 @@  discard block
 block discarded – undo
1648 1646
 	 * @param array $disinvited
1649 1647
 	 * @return array
1650 1648
 	 */
1651
-	function _get_event_details($event,$action,&$event_arr,$disinvited=array())
1649
+	function _get_event_details($event, $action, &$event_arr, $disinvited = array())
1652 1650
 	{
1653 1651
 		$details = array(			// event-details for the notify-msg
1654 1652
 			'id'          => $event['id'],
1655 1653
 			'action'      => lang($action),
1656 1654
 		);
1657 1655
 		$event_arr = $this->event2array($event);
1658
-		foreach($event_arr as $key => $val)
1656
+		foreach ($event_arr as $key => $val)
1659 1657
 		{
1660 1658
 			if ($key == 'recur_type') $key = 'repetition';
1661 1659
 			$details[$key] = $val['data'];
1662 1660
 		}
1663
-		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
1661
+		$details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : '';
1664 1662
 
1665 1663
 		$event_arr['link']['field'] = lang('URL');
1666 1664
 		$eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state
@@ -1681,7 +1679,7 @@  discard block
 block discarded – undo
1681 1679
 		 */
1682 1680
 		$link_arr = array();
1683 1681
 		$link_arr['text'] = $event['title'];
1684
-		$link_arr['view'] = array(	'menuaction' => 'calendar.calendar_uiforms.edit',
1682
+		$link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit',
1685 1683
 									'cal_id' => $event['id'],
1686 1684
 									'date' => $eventStart_arr['full'],
1687 1685
 									);
@@ -1689,11 +1687,11 @@  discard block
 block discarded – undo
1689 1687
 		$details['link_arr'] = $link_arr;
1690 1688
 
1691 1689
 		$dis = array();
1692
-		foreach($disinvited as $uid)
1690
+		foreach ($disinvited as $uid)
1693 1691
 		{
1694 1692
 			$dis[] = $this->participant_name($uid);
1695 1693
 		}
1696
-		$details['disinvited'] = implode(', ',$dis);
1694
+		$details['disinvited'] = implode(', ', $dis);
1697 1695
 		return $details;
1698 1696
 	}
1699 1697
 
@@ -1717,14 +1715,14 @@  discard block
 block discarded – undo
1717 1715
 			'data'	=> $event['description']
1718 1716
 		);
1719 1717
 
1720
-		foreach(explode(',',$event['category']) as $cat_id)
1718
+		foreach (explode(',', $event['category']) as $cat_id)
1721 1719
 		{
1722 1720
 			list($cat) = $GLOBALS['egw']->categories->return_single($cat_id);
1723 1721
 			$cat_string[] = stripslashes($cat['name']);
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.': '.common::grab_owner_name($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.': '.common::grab_owner_name($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 egw_time($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 $id => &$alarm)
1839
+		foreach ($event['alarm'] as $id => &$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(EGW_ACL_EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1863
+		if (!$cal_id || !$this->check_perms(EGW_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
 		$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now);
1873 1871
 
@@ -1882,11 +1880,11 @@  discard block
 block discarded – undo
1882 1880
 	 */
1883 1881
 	function delete_alarm($id)
1884 1882
 	{
1885
-		list(,$cal_id) = explode(':',$id);
1883
+		list(,$cal_id) = explode(':', $id);
1886 1884
 
1887
-		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(EGW_ACL_EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1885
+		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(EGW_ACL_EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1888 1886
 		{
1889
-			return false;	// no rights to delete the alarm
1887
+			return false; // no rights to delete the alarm
1890 1888
 		}
1891 1889
 
1892 1890
 		$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now);
@@ -1903,13 +1901,13 @@  discard block
 block discarded – undo
1903 1901
 	 *  by the ones the user normally does not see due to category permissions - used to preserve categories
1904 1902
 	 * @return array category ids (found, added and preserved categories)
1905 1903
 	 */
1906
-	function find_or_add_categories($catname_list, $old_event=null)
1904
+	function find_or_add_categories($catname_list, $old_event = null)
1907 1905
 	{
1908 1906
 		if (is_array($old_event) || $old_event > 0)
1909 1907
 		{
1910 1908
 			// preserve categories without users read access
1911 1909
 			if (!is_array($old_event)) $old_event = $this->read($old_event);
1912
-			$old_categories = explode(',',$old_event['category']);
1910
+			$old_categories = explode(',', $old_event['category']);
1913 1911
 			$old_cats_preserve = array();
1914 1912
 			if (is_array($old_categories) && count($old_categories) > 0)
1915 1913
 			{
@@ -1963,7 +1961,7 @@  discard block
 block discarded – undo
1963 1961
 	{
1964 1962
 		if (!is_array($cat_id_list))
1965 1963
 		{
1966
-			$cat_id_list = explode(',',$cat_id_list);
1964
+			$cat_id_list = explode(',', $cat_id_list);
1967 1965
 		}
1968 1966
 		$cat_list = array();
1969 1967
 		foreach ($cat_id_list as $cat_id)
@@ -1988,7 +1986,7 @@  discard block
 block discarded – undo
1988 1986
 	 *                              master	-> try to find a releated series master
1989 1987
 	 * @return array calendar_ids of matching entries
1990 1988
 	 */
1991
-	function find_event($event, $filter='exact')
1989
+	function find_event($event, $filter = 'exact')
1992 1990
 	{
1993 1991
 		$matchingEvents = array();
1994 1992
 		$query = array();
@@ -1996,14 +1994,14 @@  discard block
 block discarded – undo
1996 1994
 		if ($this->log)
1997 1995
 		{
1998 1996
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1999
-				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
1997
+				"($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile);
2000 1998
 		}
2001 1999
 
2002 2000
 		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2003 2001
 
2004 2002
 		if ($filter == 'master')
2005 2003
 		{
2006
-			$query[] = 'recur_type!='. MCAL_RECUR_NONE;
2004
+			$query[] = 'recur_type!='.MCAL_RECUR_NONE;
2007 2005
 			$query['cal_recurrence'] = 0;
2008 2006
 		}
2009 2007
 		elseif ($filter == 'exact')
@@ -2024,14 +2022,14 @@  discard block
 block discarded – undo
2024 2022
 			if ($this->log)
2025 2023
 			{
2026 2024
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2027
-					'(' . $event['id'] . ")[EventID]\n",3,$this->logfile);
2025
+					'('.$event['id'].")[EventID]\n", 3, $this->logfile);
2028 2026
 			}
2029 2027
 			if (($egwEvent = $this->read($event['id'], 0, false, 'server')))
2030 2028
 			{
2031 2029
 				if ($this->log)
2032 2030
 				{
2033 2031
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2034
-						'()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile);
2032
+						'()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile);
2035 2033
 				}
2036 2034
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE &&
2037 2035
 					(empty($event['uid']) || $event['uid'] == $egwEvent['uid']))
@@ -2050,7 +2048,7 @@  discard block
 block discarded – undo
2050 2048
 						$exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']);
2051 2049
 						if (in_array($event['recurrence'], $exceptions))
2052 2050
 						{
2053
-							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2051
+							$matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence'];
2054 2052
 						}
2055 2053
 					}
2056 2054
 				} elseif ($filter != 'master' && ($filter == 'exact' ||
@@ -2069,19 +2067,19 @@  discard block
 block discarded – undo
2069 2067
 
2070 2068
 		// only query calendars of users, we have READ-grants from
2071 2069
 		$users = array();
2072
-		foreach(array_keys($this->grants) as $user)
2070
+		foreach (array_keys($this->grants) as $user)
2073 2071
 		{
2074 2072
 			$user = trim($user);
2075
-			if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$user))
2073
+			if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY, 0, $user))
2076 2074
 			{
2077
-				if ($user && !in_array($user,$users))	// already added?
2075
+				if ($user && !in_array($user, $users))	// already added?
2078 2076
 				{
2079 2077
 					$users[] = $user;
2080 2078
 				}
2081 2079
 			}
2082 2080
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2083 2081
 			{
2084
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2082
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
2085 2083
 			}
2086 2084
 			// the further code is only for real users
2087 2085
 			if (!is_numeric($user)) continue;
@@ -2092,11 +2090,11 @@  discard block
 block discarded – undo
2092 2090
 				$members = $GLOBALS['egw']->accounts->member($user);
2093 2091
 				if (is_array($members))
2094 2092
 				{
2095
-					foreach($members as $member)
2093
+					foreach ($members as $member)
2096 2094
 					{
2097 2095
 						// use only members which gave the user a read-grant
2098
-						if (!in_array($member['account_id'],$users) &&
2099
-								$this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY,0,$member['account_id']))
2096
+						if (!in_array($member['account_id'], $users) &&
2097
+								$this->check_perms(EGW_ACL_READ|EGW_ACL_FREEBUSY, 0, $member['account_id']))
2100 2098
 						{
2101 2099
 							$users[] = $member['account_id'];
2102 2100
 						}
@@ -2108,9 +2106,9 @@  discard block
 block discarded – undo
2108 2106
 				$memberships = $GLOBALS['egw']->accounts->membership($user);
2109 2107
 				if (is_array($memberships))
2110 2108
 				{
2111
-					foreach($memberships as $group)
2109
+					foreach ($memberships as $group)
2112 2110
 					{
2113
-						if (!in_array($group['account_id'],$users))
2111
+						if (!in_array($group['account_id'], $users))
2114 2112
 						{
2115 2113
 							$users[] = $group['account_id'];
2116 2114
 						}
@@ -2134,24 +2132,24 @@  discard block
 block discarded – undo
2134 2132
 
2135 2133
 				// check length with some tolerance
2136 2134
 				$length = $event['end'] - $event['start'] - $delta;
2137
-				$query[] = ('(cal_end-cal_start)>' . $length);
2135
+				$query[] = ('(cal_end-cal_start)>'.$length);
2138 2136
 				$length += 2 * $delta;
2139
-				$query[] = ('(cal_end-cal_start)<' . $length);
2140
-				$query[] = ('cal_start>' . ($event['start'] - 86400));
2141
-				$query[] = ('cal_start<' . ($event['start'] + 86400));
2137
+				$query[] = ('(cal_end-cal_start)<'.$length);
2138
+				$query[] = ('cal_start>'.($event['start'] - 86400));
2139
+				$query[] = ('cal_start<'.($event['start'] + 86400));
2142 2140
 			}
2143 2141
 			elseif (isset($event['start']))
2144 2142
 			{
2145 2143
 				if ($filter == 'relax')
2146 2144
 				{
2147
-					$query[] = ('cal_start>' . ($event['start'] - 3600));
2148
-					$query[] = ('cal_start<' . ($event['start'] + 3600));
2145
+					$query[] = ('cal_start>'.($event['start'] - 3600));
2146
+					$query[] = ('cal_start<'.($event['start'] + 3600));
2149 2147
 				}
2150 2148
 				else
2151 2149
 				{
2152 2150
 					// we accept a tiny tolerance
2153
-					$query[] = ('cal_start>' . ($event['start'] - 2));
2154
-					$query[] = ('cal_start<' . ($event['start'] + 2));
2151
+					$query[] = ('cal_start>'.($event['start'] - 2));
2152
+					$query[] = ('cal_start<'.($event['start'] + 2));
2155 2153
 				}
2156 2154
 			}
2157 2155
 			if ($filter == 'relax')
@@ -2174,14 +2172,14 @@  discard block
 block discarded – undo
2174 2172
 			if ($this->log)
2175 2173
 			{
2176 2174
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2177
-					'(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile);
2175
+					'('.$event['uid'].")[EventUID]\n", 3, $this->logfile);
2178 2176
 			}
2179 2177
 		}
2180 2178
 
2181 2179
 		if ($this->log)
2182 2180
 		{
2183 2181
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2184
-				'[QUERY]: ' . array2string($query)."\n",3,$this->logfile);
2182
+				'[QUERY]: '.array2string($query)."\n", 3, $this->logfile);
2185 2183
 		}
2186 2184
 		if (!count($users) || !($foundEvents =
2187 2185
 			$this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query))))
@@ -2189,19 +2187,19 @@  discard block
 block discarded – undo
2189 2187
 			if ($this->log)
2190 2188
 			{
2191 2189
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2192
-				"[NO MATCH]\n",3,$this->logfile);
2190
+				"[NO MATCH]\n", 3, $this->logfile);
2193 2191
 			}
2194 2192
 			return $matchingEvents;
2195 2193
 		}
2196 2194
 
2197 2195
 		$pseudos = array();
2198 2196
 
2199
-		foreach($foundEvents as $egwEvent)
2197
+		foreach ($foundEvents as $egwEvent)
2200 2198
 		{
2201 2199
 			if ($this->log)
2202 2200
 			{
2203 2201
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2204
-					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2202
+					'[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile);
2205 2203
 			}
2206 2204
 
2207 2205
 			if (in_array($egwEvent['id'], $matchingEvents)) continue;
@@ -2275,7 +2273,7 @@  discard block
 block discarded – undo
2275 2273
 						if (in_array($event['recurrence'], $exceptions))
2276 2274
 						{
2277 2275
 							// We found a pseudo exception
2278
-							$matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']);
2276
+							$matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']);
2279 2277
 							break;
2280 2278
 						}
2281 2279
 					}
@@ -2293,7 +2291,7 @@  discard block
 block discarded – undo
2293 2291
 						if ($this->log)
2294 2292
 						{
2295 2293
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2296
-							"() egwEvent length does not match!\n",3,$this->logfile);
2294
+							"() egwEvent length does not match!\n", 3, $this->logfile);
2297 2295
 						}
2298 2296
 						continue;
2299 2297
 					}
@@ -2305,7 +2303,7 @@  discard block
 block discarded – undo
2305 2303
 						if ($this->log)
2306 2304
 						{
2307 2305
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2308
-							"() egwEvent is not a whole-day event!\n",3,$this->logfile);
2306
+							"() egwEvent is not a whole-day event!\n", 3, $this->logfile);
2309 2307
 						}
2310 2308
 						continue;
2311 2309
 					}
@@ -2326,8 +2324,8 @@  discard block
 block discarded – undo
2326 2324
 					if ($this->log)
2327 2325
 					{
2328 2326
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2329
-							"() event[$key] differ: '" . $event[$key] .
2330
-							"' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile);
2327
+							"() event[$key] differ: '".$event[$key].
2328
+							"' <> '".$egwEvent[$key]."'\n", 3, $this->logfile);
2331 2329
 					}
2332 2330
 					continue 2; // next foundEvent
2333 2331
 				}
@@ -2345,7 +2343,7 @@  discard block
 block discarded – undo
2345 2343
 						if ($this->log)
2346 2344
 						{
2347 2345
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2348
-							"() egwEvent category $cat_id is missing!\n",3,$this->logfile);
2346
+							"() egwEvent category $cat_id is missing!\n", 3, $this->logfile);
2349 2347
 						}
2350 2348
 						continue 2;
2351 2349
 					}
@@ -2357,7 +2355,7 @@  discard block
 block discarded – undo
2357 2355
 					{
2358 2356
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2359 2357
 							'() event has additional categories:'
2360
-							. array2string($newCategories)."\n",3,$this->logfile);
2358
+							. array2string($newCategories)."\n", 3, $this->logfile);
2361 2359
 					}
2362 2360
 					continue;
2363 2361
 				}
@@ -2377,7 +2375,7 @@  discard block
 block discarded – undo
2377 2375
 							if ($this->log)
2378 2376
 							{
2379 2377
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2380
-								"() additional event['participants']: $attendee\n",3,$this->logfile);
2378
+								"() additional event['participants']: $attendee\n", 3, $this->logfile);
2381 2379
 							}
2382 2380
 							continue 2;
2383 2381
 						}
@@ -2400,8 +2398,8 @@  discard block
 block discarded – undo
2400 2398
 						if ($this->log)
2401 2399
 						{
2402 2400
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2403
-								'() missing event[participants]: ' .
2404
-								array2string($egwEvent['participants'])."\n",3,$this->logfile);
2401
+								'() missing event[participants]: '.
2402
+								array2string($egwEvent['participants'])."\n", 3, $this->logfile);
2405 2403
 						}
2406 2404
 						continue;
2407 2405
 					}
@@ -2413,7 +2411,7 @@  discard block
 block discarded – undo
2413 2411
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE)
2414 2412
 				{
2415 2413
 					// We found a pseudo Exception
2416
-					$pseudos[] = $egwEvent['id'] . ':' . $event['start'];
2414
+					$pseudos[] = $egwEvent['id'].':'.$event['start'];
2417 2415
 					continue;
2418 2416
 				}
2419 2417
 			}
@@ -2435,7 +2433,7 @@  discard block
 block discarded – undo
2435 2433
 							if ($this->log)
2436 2434
 							{
2437 2435
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2438
-								"() additional event['recur_exception']: $day\n",3,$this->logfile);
2436
+								"() additional event['recur_exception']: $day\n", 3, $this->logfile);
2439 2437
 							}
2440 2438
 							continue 2;
2441 2439
 						}
@@ -2445,8 +2443,8 @@  discard block
 block discarded – undo
2445 2443
 						if ($this->log)
2446 2444
 						{
2447 2445
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2448
-								'() missing event[recur_exception]: ' .
2449
-								array2string($event['recur_exception'])."\n",3,$this->logfile);
2446
+								'() missing event[recur_exception]: '.
2447
+								array2string($event['recur_exception'])."\n", 3, $this->logfile);
2450 2448
 						}
2451 2449
 						continue;
2452 2450
 					}
@@ -2461,8 +2459,8 @@  discard block
 block discarded – undo
2461 2459
 						if ($this->log)
2462 2460
 						{
2463 2461
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2464
-								"() events[$key] differ: " . $event[$key] .
2465
-								' <> ' . $egwEvent[$key]."\n",3,$this->logfile);
2462
+								"() events[$key] differ: ".$event[$key].
2463
+								' <> '.$egwEvent[$key]."\n", 3, $this->logfile);
2466 2464
 						}
2467 2465
 						continue 2;
2468 2466
 					}
@@ -2478,7 +2476,7 @@  discard block
 block discarded – undo
2478 2476
 			if ($this->log)
2479 2477
 			{
2480 2478
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2481
-					"() new exception for series found.\n",3,$this->logfile);
2479
+					"() new exception for series found.\n", 3, $this->logfile);
2482 2480
 			}
2483 2481
 			$matchingEvents = array();
2484 2482
 		}
@@ -2489,7 +2487,7 @@  discard block
 block discarded – undo
2489 2487
 		if ($this->log)
2490 2488
 		{
2491 2489
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2492
-				'[MATCHES]:' . array2string($matches)."\n",3,$this->logfile);
2490
+				'[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile);
2493 2491
 		}
2494 2492
 		return $matches;
2495 2493
 	}
@@ -2562,7 +2560,7 @@  discard block
 block discarded – undo
2562 2560
 				if ($this->log)
2563 2561
 				{
2564 2562
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2565
-					"()[MASTER]: $eventID\n",3,$this->logfile);
2563
+					"()[MASTER]: $eventID\n", 3, $this->logfile);
2566 2564
 				}
2567 2565
 				$type = 'SERIES-EXCEPTION';
2568 2566
 				if (($master_event = $this->read($eventID, 0, false, 'server')))
@@ -2583,7 +2581,7 @@  discard block
 block discarded – undo
2583 2581
 					}
2584 2582
 					elseif (in_array($event['start'], $master_event['recur_exception']))
2585 2583
 					{
2586
-						$type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2584
+						$type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2587 2585
 						$recurrence_event = $master_event;
2588 2586
 						$recurrence_event['start'] = $event['start'];
2589 2587
 						$recurrence_event['end'] -= $master_event['start'] - $event['start'];
@@ -2600,8 +2598,8 @@  discard block
 block discarded – undo
2600 2598
 							if ($this->log)
2601 2599
 							{
2602 2600
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2603
-									'() try occurrence ' . $egw_rrule->current()
2604
-									. " ($occurrence)\n",3,$this->logfile);
2601
+									'() try occurrence '.$egw_rrule->current()
2602
+									. " ($occurrence)\n", 3, $this->logfile);
2605 2603
 							}
2606 2604
 							if ($event['start'] == $occurrence)
2607 2605
 							{
@@ -2634,8 +2632,8 @@  discard block
 block discarded – undo
2634 2632
 			// default if we cannot find a proof for a fundamental change
2635 2633
 			// the recurrence_event is the master event with start and end adjusted to the recurrence
2636 2634
 			// check for changed data
2637
-			foreach (array('start','end','uid','title','location','description',
2638
-				'priority','public','special','non_blocking') as $key)
2635
+			foreach (array('start', 'end', 'uid', 'title', 'location', 'description',
2636
+				'priority', 'public', 'special', 'non_blocking') as $key)
2639 2637
 			{
2640 2638
 				if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key])
2641 2639
 				{
@@ -2693,10 +2691,10 @@  discard block
 block discarded – undo
2693 2691
      * @param &$event	the event we are working on
2694 2692
      *
2695 2693
      */
2696
-    function server2usertime (&$event)
2694
+    function server2usertime(&$event)
2697 2695
     {
2698 2696
 		// we run all dates through date2usertime, to adjust to user-time
2699
-		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2697
+		foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts)
2700 2698
 		{
2701 2699
 			// we convert here from server-time to timestamps in user-time!
2702 2700
 			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
@@ -2704,7 +2702,7 @@  discard block
 block discarded – undo
2704 2702
 		// same with the recur exceptions
2705 2703
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
2706 2704
 		{
2707
-			foreach($event['recur_exception'] as $n => $date)
2705
+			foreach ($event['recur_exception'] as $n => $date)
2708 2706
 			{
2709 2707
 				$event['recur_exception'][$n] = $this->date2usertime($date);
2710 2708
 			}
@@ -2712,7 +2710,7 @@  discard block
 block discarded – undo
2712 2710
 		// same with the alarms
2713 2711
 		if (isset($event['alarm']) && is_array($event['alarm']))
2714 2712
 		{
2715
-			foreach($event['alarm'] as $id => $alarm)
2713
+			foreach ($event['alarm'] as $id => $alarm)
2716 2714
 			{
2717 2715
 				$event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']);
2718 2716
 			}
@@ -2729,7 +2727,7 @@  discard block
 block discarded – undo
2729 2727
 	{
2730 2728
 		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2731 2729
 		{
2732
-			$this->so->purge(time() - 365*24*3600*(float)$age);
2730
+			$this->so->purge(time() - 365 * 24 * 3600 * (float)$age);
2733 2731
 		}
2734 2732
 	}
2735 2733
 }
Please login to merge, or discard this patch.
Braces   +216 added lines, -55 removed lines patch added patch discarded remove patch
@@ -81,11 +81,17 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	function __construct()
83 83
 	{
84
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
84
+		if ($this->debug > 0)
85
+		{
86
+			$this->debug_message('calendar_boupdate::__construct() started',True);
87
+		}
85 88
 
86 89
 		parent::__construct();	// calling the parent constructor
87 90
 
88
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
91
+		if ($this->debug > 0)
92
+		{
93
+			$this->debug_message('calendar_boupdate::__construct() finished',True);
94
+		}
89 95
 	}
90 96
 
91 97
 	/**
@@ -115,7 +121,10 @@  discard block
 block discarded – undo
115 121
 	function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
116 122
 	{
117 123
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
118
-		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
124
+		if (!is_array($messages))
125
+		{
126
+			$messages = $messages ? (array)$messages : array();
127
+		}
119 128
 
120 129
 		if ($this->debug > 1 || $this->debug == 'update')
121 130
 		{
@@ -135,10 +144,13 @@  discard block
 block discarded – undo
135 144
 
136 145
 		$status_reset_to_unknown = false;
137 146
 
138
-		if (($new_event = !$event['id']))	// some defaults for new entries
147
+		if (($new_event = !$event['id']))
148
+		{
149
+			// some defaults for new entries
139 150
 		{
140 151
 			// if no owner given, set user to owner
141 152
 			if (!$event['owner']) $event['owner'] = $this->user;
153
+		}
142 154
 			// set owner as participant if none is given
143 155
 			if (!is_array($event['participants']) || !count($event['participants']))
144 156
 			{
@@ -178,7 +190,10 @@  discard block
 block discarded – undo
178 190
 		// check category based ACL
179 191
 		if ($event['category'])
180 192
 		{
181
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
193
+			if (!is_array($event['category']))
194
+			{
195
+				$event['category'] = explode(',',$event['category']);
196
+			}
182 197
 			if (!$old_event || !isset($old_event['category']))
183 198
 			{
184 199
 				$old_event['category'] = array();
@@ -231,18 +246,28 @@  discard block
 block discarded – undo
231 246
 			$types_with_quantity = array();
232 247
 			foreach($this->resources as $type => $data)
233 248
 			{
234
-				if ($data['max_quantity']) $types_with_quantity[] = $type;
249
+				if ($data['max_quantity'])
250
+				{
251
+					$types_with_quantity[] = $type;
252
+				}
235 253
 			}
236 254
 			// get all NOT rejected participants and evtl. their quantity
237 255
 			$quantity = $users = array();
238 256
 			foreach($event['participants'] as $uid => $status)
239 257
 			{
240 258
 				calendar_so::split_status($status,$q,$r);
241
-				if ($status[0] == 'R') continue;	// ignore rejected participants
259
+				if ($status[0] == 'R')
260
+				{
261
+					continue;
262
+				}
263
+				// ignore rejected participants
242 264
 
243
-				if ($uid < 0)	// group, check it's members too
265
+				if ($uid < 0)
266
+				{
267
+					// group, check it's members too
244 268
 				{
245 269
 					$users += (array)$GLOBALS['egw']->accounts->members($uid,true);
270
+				}
246 271
 					$users = array_unique($users);
247 272
 				}
248 273
 				$users[] = $uid;
@@ -273,10 +298,13 @@  discard block
 block discarded – undo
273 298
 			{
274 299
 				if ($overlap['id'] == $event['id'] ||	// that's the event itself
275 300
 					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
276
-					$overlap['non_blocking'])			// that's a non_blocking event
301
+					$overlap['non_blocking'])
302
+				{
303
+					// that's a non_blocking event
277 304
 				{
278 305
 					continue;
279 306
 				}
307
+				}
280 308
 				if ($this->debug > 3 || $this->debug == 'update')
281 309
 				{
282 310
 					$this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap);
@@ -434,7 +462,11 @@  discard block
 block discarded – undo
434 462
 	 */
435 463
 	public function check_acl_invite($uid)
436 464
 	{
437
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
465
+		if (!is_numeric($uid))
466
+		{
467
+			return true;
468
+		}
469
+		// nothing implemented for resources so far
438 470
 
439 471
 		if (!$this->require_acl_invite)
440 472
 		{
@@ -775,14 +807,20 @@  discard block
 block discarded – undo
775 807
 		$startdate = new egw_time($event['start']);
776 808
 		$enddate = new egw_time($event['end']);
777 809
 		$modified = new egw_time($event['modified']);
778
-		if ($old_event) $olddate = new egw_time($old_event['start']);
810
+		if ($old_event)
811
+		{
812
+			$olddate = new egw_time($old_event['start']);
813
+		}
779 814
 		//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
780 815
 		$owner_prefs = $ics = null;
781 816
 		foreach($to_notify as $userid => $statusid)
782 817
 		{
783 818
 			$res_info = $quantity = $role = null;
784 819
 			calendar_so::split_status($statusid, $quantity, $role);
785
-			if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
820
+			if ($this->debug > 0)
821
+			{
822
+				error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
823
+			}
786 824
 
787 825
 			if (!is_numeric($userid))
788 826
 			{
@@ -801,7 +839,11 @@  discard block
 block discarded – undo
801 839
 
802 840
 				if (!isset($userid))
803 841
 				{
804
-					if (empty($res_info['email'])) continue;	// no way to notify
842
+					if (empty($res_info['email']))
843
+					{
844
+						continue;
845
+					}
846
+					// no way to notify
805 847
 					// check if event-owner wants non-EGroupware users notified
806 848
 					if (is_null($owner_prefs))
807 849
 					{
@@ -866,11 +908,20 @@  discard block
 block discarded – undo
866 908
 				$details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event,
867 909
 					$action, $event_arr, $disinvited);
868 910
 				$details['to-fullname'] = $fullname;
869
-				if (isset($tfn)) $details['to-firstname'] = $tfn;
870
-				if (isset($tln)) $details['to-lastname'] = $tln;
911
+				if (isset($tfn))
912
+				{
913
+					$details['to-firstname'] = $tfn;
914
+				}
915
+				if (isset($tln))
916
+				{
917
+					$details['to-lastname'] = $tln;
918
+				}
871 919
 
872 920
 				// 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
873
-				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
921
+				if (!isset($part_prefs['common']['tz']))
922
+				{
923
+					$part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
924
+				}
874 925
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
875 926
 				$timeformat = $part_prefs['common']['timeformat'];
876 927
 				switch($timeformat)
@@ -905,9 +956,12 @@  discard block
 block discarded – undo
905 956
 				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
906 957
 				{
907 958
 					case 'ical':
908
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
959
+						if (is_null($ics) || $m_type != $msg_type)
960
+						{
961
+							// need different ical for organizer notification
909 962
 						{
910 963
 							$calendar_ical = new calendar_ical();
964
+						}
911 965
 							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
912 966
 							// we need to pass $event[id] so iCal class reads event again,
913 967
 							// as event is in user TZ, but iCal class expects server TZ!
@@ -921,7 +975,10 @@  discard block
 block discarded – undo
921 975
 							'encoding' => '8bit',
922 976
 							'type' => 'text/calendar; method='.$method,
923 977
 						);
924
-						if ($m_type != $msg_type) unset($ics);
978
+						if ($m_type != $msg_type)
979
+						{
980
+							unset($ics);
981
+						}
925 982
 						$subject = isset($cleared_event) ? $cleared_event['title'] : $event['title'];
926 983
 						// fall through
927 984
 					case 'extended':
@@ -972,7 +1029,9 @@  discard block
 block discarded – undo
972 1029
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
973 1030
 						$notification->set_popuplinks(array($details['link_arr']));
974 1031
 
975
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1032
+						if(is_array($attachment))
1033
+						{
1034
+$notification->set_attachments(array($attachment)); }
976 1035
 						$notification->send();
977 1036
 					}
978 1037
 					catch (Exception $exception) {
@@ -999,7 +1058,10 @@  discard block
 block discarded – undo
999 1058
 			translation::init();
1000 1059
 		}
1001 1060
 		// restore timezone, in case we had to reset it to server-timezone
1002
-		if ($restore_tz) date_default_timezone_set($restore_tz);
1061
+		if ($restore_tz)
1062
+		{
1063
+			date_default_timezone_set($restore_tz);
1064
+		}
1003 1065
 
1004 1066
 		return true;
1005 1067
 	}
@@ -1034,10 +1096,13 @@  discard block
 block discarded – undo
1034 1096
 		{
1035 1097
 			$to_notify = $event['participants'];
1036 1098
 		}
1037
-		elseif ($this->check_perms(EGW_ACL_READ,$event))	// checks agains $this->owner set to $alarm[owner]
1099
+		elseif ($this->check_perms(EGW_ACL_READ,$event))
1100
+		{
1101
+			// checks agains $this->owner set to $alarm[owner]
1038 1102
 		{
1039 1103
 			$to_notify[$alarm['owner']] = 'A';
1040 1104
 		}
1105
+		}
1041 1106
 		else
1042 1107
 		{
1043 1108
 			return False;	// no rights
@@ -1087,7 +1152,10 @@  discard block
 block discarded – undo
1087 1152
 		if ($event['id'])
1088 1153
 		{
1089 1154
 			// invalidate the read-cache if it contains the event we store now
1090
-			if ($event['id'] == self::$cached_event['id']) self::$cached_event = array();
1155
+			if ($event['id'] == self::$cached_event['id'])
1156
+			{
1157
+				self::$cached_event = array();
1158
+			}
1091 1159
 			$old_event = $this->read($event['id'], $event['recurrence'], false, 'server');
1092 1160
 		}
1093 1161
 		else
@@ -1095,7 +1163,10 @@  discard block
 block discarded – undo
1095 1163
 			$old_event = null;
1096 1164
 		}
1097 1165
 
1098
-		if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
1166
+		if (!isset($event['whole_day']))
1167
+		{
1168
+			$event['whole_day'] = $this->isWholeDay($event);
1169
+		}
1099 1170
 		$save_event = $event;
1100 1171
 		if ($event['whole_day'])
1101 1172
 		{
@@ -1136,7 +1207,10 @@  discard block
 block discarded – undo
1136 1207
 		foreach($timestamps as $ts)
1137 1208
 		{
1138 1209
 			// we convert here from user-time to timestamps in server-time!
1139
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1210
+			if (isset($event[$ts]))
1211
+			{
1212
+				$event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1213
+			}
1140 1214
 		}
1141 1215
 		// convert tzid name to integer tz_id, of set user default
1142 1216
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1186,7 +1260,10 @@  discard block
 block discarded – undo
1186 1260
 				if (!isset($event['alarm'][$id]))
1187 1261
 				{
1188 1262
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1189
-					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1263
+					if ($alarm['time'] < time())
1264
+					{
1265
+						calendar_so::shift_alarm($event, $alarm);
1266
+					}
1190 1267
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1191 1268
 					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1192 1269
 						$old_event['participants'][$alarm['owner']];
@@ -1222,7 +1299,10 @@  discard block
 block discarded – undo
1222 1299
 			unset($save_event['participants']);
1223 1300
 			$this->set_recurrences($save_event, $set_recurrences_start);
1224 1301
 		}
1225
-		if ($updateTS) $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, $event['id'] ? 'modify' : 'add', $this->now);
1302
+		if ($updateTS)
1303
+		{
1304
+			$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, $event['id'] ? 'modify' : 'add', $this->now);
1305
+		}
1226 1306
 
1227 1307
 		// create links for new participants from addressbook, if configured
1228 1308
 		if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants'])
@@ -1240,7 +1320,10 @@  discard block
 block discarded – undo
1240 1320
 
1241 1321
 		// Update history
1242 1322
 		$tracking = new calendar_tracking($this);
1243
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1323
+		if (empty($event['id']) && !empty($cal_id))
1324
+		{
1325
+			$event['id']=$cal_id;
1326
+		}
1244 1327
 		$tracking->track($event, $old_event);
1245 1328
 
1246 1329
 		return $cal_id;
@@ -1257,9 +1340,12 @@  discard block
 block discarded – undo
1257 1340
 	 */
1258 1341
 	function check_status_perms($uid,$event)
1259 1342
 	{
1260
-		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1343
+		if ($uid[0] == 'c' || $uid[0] == 'e')
1344
+		{
1345
+			// for contact we use the owner of the event
1261 1346
 		{
1262 1347
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1348
+		}
1263 1349
 
1264 1350
 			return $this->check_perms(EGW_ACL_EDIT,0,$event['owner']);
1265 1351
 		}
@@ -1270,13 +1356,19 @@  discard block
 block discarded – undo
1270 1356
 			return $access;
1271 1357
 		}
1272 1358
 		// no access or denied access because of category acl --> regular check
1273
-		if (!is_numeric($uid))	// this is eg. for resources (r123)
1359
+		if (!is_numeric($uid))
1360
+		{
1361
+			// this is eg. for resources (r123)
1274 1362
 		{
1275 1363
 			$resource = $this->resource_info($uid);
1364
+		}
1276 1365
 
1277 1366
 			return EGW_ACL_EDIT & $resource['rights'];
1278 1367
 		}
1279
-		if (!is_array($event) && !($event = $this->read($event))) return false;
1368
+		if (!is_array($event) && !($event = $this->read($event)))
1369
+		{
1370
+			return false;
1371
+		}
1280 1372
 
1281 1373
 		// regular user and groups (need to check memberships too)
1282 1374
 		if (!isset($event['participants'][$uid]))
@@ -1300,7 +1392,10 @@  discard block
 block discarded – undo
1300 1392
 	 */
1301 1393
 	function check_cat_acl($right,$event)
1302 1394
 	{
1303
-		if (!is_array($event)) $event = $this->read($event);
1395
+		if (!is_array($event))
1396
+		{
1397
+			$event = $this->read($event);
1398
+		}
1304 1399
 
1305 1400
 		$ret = null;
1306 1401
 		if ($event['category'])
@@ -1357,7 +1452,10 @@  discard block
 block discarded – undo
1357 1452
 	public static function set_cat_rights($cat_id,$user,$rights)
1358 1453
 	{
1359 1454
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1360
-		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
1455
+		if (!isset(self::$cat_rights_cache))
1456
+		{
1457
+			self::get_cat_rights($cat_id);
1458
+		}
1361 1459
 
1362 1460
 		if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user])
1363 1461
 		{
@@ -1369,7 +1467,10 @@  discard block
 block discarded – undo
1369 1467
 			else
1370 1468
 			{
1371 1469
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1372
-				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1470
+				if (!self::$cat_rights_cache['L'.$cat_id])
1471
+				{
1472
+					unset(self::$cat_rights_cache['L'.$cat_id]);
1473
+				}
1373 1474
 				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1374 1475
 			}
1375 1476
 			egw_cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
@@ -1402,7 +1503,10 @@  discard block
 block discarded – undo
1402 1503
 				foreach($cat_rights as $uid => $value)
1403 1504
 				{
1404 1505
 					$all |= $value;
1405
-					if (in_array($uid,$memberships)) $own |= $value;
1506
+					if (in_array($uid,$memberships))
1507
+					{
1508
+						$own |= $value;
1509
+					}
1406 1510
 				}
1407 1511
 			}
1408 1512
 			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
@@ -1449,13 +1553,16 @@  discard block
 block discarded – undo
1449 1553
 				is_numeric($uid)?$uid:substr($uid,1),$status,
1450 1554
 				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1451 1555
 		{
1452
-			if ($status == 'R')	// remove alarms belonging to rejected participants
1556
+			if ($status == 'R')
1557
+			{
1558
+				// remove alarms belonging to rejected participants
1453 1559
 			{
1454 1560
 				foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1455 1561
 				{
1456 1562
 					if ((string)$alarm['owner'] === (string)$uid)
1457 1563
 					{
1458 1564
 						$this->so->delete_alarm($id);
1565
+			}
1459 1566
 						//error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
1460 1567
 					}
1461 1568
 				}
@@ -1473,8 +1580,15 @@  discard block
 block discarded – undo
1473 1580
 			);
1474 1581
 			if (isset($status2msg[$status]) && !$skip_notification)
1475 1582
 			{
1476
-				if (!is_array($event)) $event = $this->read($cal_id);
1477
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1583
+				if (!is_array($event))
1584
+				{
1585
+					$event = $this->read($cal_id);
1586
+				}
1587
+				if (isset($recur_date))
1588
+				{
1589
+					$event = $this->read($event['id'],$recur_date);
1590
+				}
1591
+				//re-read the actually edited recurring event
1478 1592
 				$this->send_update($status2msg[$status],$event['participants'],$event);
1479 1593
 			}
1480 1594
 
@@ -1497,12 +1611,16 @@  discard block
 block discarded – undo
1497 1611
 	 */
1498 1612
 	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1499 1613
 	{
1500
-		if (!isset($new_event['participants'])) return;
1614
+		if (!isset($new_event['participants']))
1615
+		{
1616
+			return;
1617
+		}
1501 1618
 
1502 1619
 		// check the old list against the new list
1503 1620
 		foreach ($old_event['participants'] as $userid => $status)
1504
-  		{
1505
-            if (!isset($new_event['participants'][$userid])){
1621
+		{
1622
+            if (!isset($new_event['participants'][$userid]))
1623
+            {
1506 1624
             	// Attendee will be deleted this way
1507 1625
             	$new_event['participants'][$userid] = 'G';
1508 1626
             }
@@ -1586,7 +1704,10 @@  discard block
 block discarded – undo
1586 1704
 					}
1587 1705
 					else
1588 1706
 					{
1589
-						if (!($exception = $this->read($id))) continue;
1707
+						if (!($exception = $this->read($id)))
1708
+						{
1709
+							continue;
1710
+						}
1590 1711
 						$exception['uid'] = common::generate_uid('calendar', $id);
1591 1712
 						$exception['reference'] = $exception['recurrence'] = 0;
1592 1713
 						$this->update($exception, true, true, false, true, $msg=null, true);
@@ -1657,7 +1778,10 @@  discard block
 block discarded – undo
1657 1778
 		$event_arr = $this->event2array($event);
1658 1779
 		foreach($event_arr as $key => $val)
1659 1780
 		{
1660
-			if ($key == 'recur_type') $key = 'repetition';
1781
+			if ($key == 'recur_type')
1782
+			{
1783
+				$key = 'repetition';
1784
+			}
1661 1785
 			$details[$key] = $val['data'];
1662 1786
 		}
1663 1787
 		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
@@ -1830,7 +1954,10 @@  discard block
 block discarded – undo
1830 1954
 	 */
1831 1955
 	function check_move_alarms(Array &$event, Array $old_event = null, egw_time $instance_date = null)
1832 1956
 	{
1833
-		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1957
+		if ($old_event !== null && $event['start'] == $old_event['start'])
1958
+		{
1959
+			return;
1960
+		}
1834 1961
 
1835 1962
 		$time = new egw_time($event['start']);
1836 1963
 		if(!is_array($event['alarm']))
@@ -1908,7 +2035,10 @@  discard block
 block discarded – undo
1908 2035
 		if (is_array($old_event) || $old_event > 0)
1909 2036
 		{
1910 2037
 			// preserve categories without users read access
1911
-			if (!is_array($old_event)) $old_event = $this->read($old_event);
2038
+			if (!is_array($old_event))
2039
+			{
2040
+				$old_event = $this->read($old_event);
2041
+			}
1912 2042
 			$old_categories = explode(',',$old_event['category']);
1913 2043
 			$old_cats_preserve = array();
1914 2044
 			if (is_array($old_categories) && count($old_categories) > 0)
@@ -1999,7 +2129,10 @@  discard block
 block discarded – undo
1999 2129
 				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2000 2130
 		}
2001 2131
 
2002
-		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2132
+		if (!isset($event['recurrence']))
2133
+		{
2134
+			$event['recurrence'] = 0;
2135
+		}
2003 2136
 
2004 2137
 		if ($filter == 'master')
2005 2138
 		{
@@ -2053,19 +2186,26 @@  discard block
 block discarded – undo
2053 2186
 							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2054 2187
 						}
2055 2188
 					}
2056
-				} elseif ($filter != 'master' && ($filter == 'exact' ||
2189
+				}
2190
+				elseif ($filter != 'master' && ($filter == 'exact' ||
2057 2191
 							$event['recur_type'] == $egwEvent['recur_type'] &&
2058 2192
 							strpos($egwEvent['title'], $event['title']) === 0))
2059 2193
 				{
2060 2194
 					$matchingEvents[] = $egwEvent['id']; // we found the event
2061 2195
 				}
2062 2196
 			}
2063
-			if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents;
2197
+			if (!empty($matchingEvents) || $filter == 'exact')
2198
+			{
2199
+				return $matchingEvents;
2200
+			}
2064 2201
 		}
2065 2202
 		unset($event['id']);
2066 2203
 
2067 2204
 		// No chance to find a master without [U]ID
2068
-		if ($filter == 'master' && empty($event['uid'])) return $matchingEvents;
2205
+		if ($filter == 'master' && empty($event['uid']))
2206
+		{
2207
+			return $matchingEvents;
2208
+		}
2069 2209
 
2070 2210
 		// only query calendars of users, we have READ-grants from
2071 2211
 		$users = array();
@@ -2074,17 +2214,23 @@  discard block
 block discarded – undo
2074 2214
 			$user = trim($user);
2075 2215
 			if ($this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|EGW_ACL_FREEBUSY,0,$user))
2076 2216
 			{
2077
-				if ($user && !in_array($user,$users))	// already added?
2217
+				if ($user && !in_array($user,$users))
2218
+				{
2219
+					// already added?
2078 2220
 				{
2079 2221
 					$users[] = $user;
2080 2222
 				}
2223
+				}
2081 2224
 			}
2082 2225
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2083 2226
 			{
2084 2227
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2085 2228
 			}
2086 2229
 			// the further code is only for real users
2087
-			if (!is_numeric($user)) continue;
2230
+			if (!is_numeric($user))
2231
+			{
2232
+				continue;
2233
+			}
2088 2234
 
2089 2235
 			// for groups we have to include the members
2090 2236
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
@@ -2164,7 +2310,10 @@  discard block
 block discarded – undo
2164 2310
 			}
2165 2311
 			foreach ($matchFields as $key)
2166 2312
 			{
2167
-				if (isset($event[$key])) $query['cal_'.$key] = $event[$key];
2313
+				if (isset($event[$key]))
2314
+				{
2315
+					$query['cal_'.$key] = $event[$key];
2316
+				}
2168 2317
 			}
2169 2318
 		}
2170 2319
 
@@ -2204,7 +2353,10 @@  discard block
 block discarded – undo
2204 2353
 					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2205 2354
 			}
2206 2355
 
2207
-			if (in_array($egwEvent['id'], $matchingEvents)) continue;
2356
+			if (in_array($egwEvent['id'], $matchingEvents))
2357
+			{
2358
+				continue;
2359
+			}
2208 2360
 
2209 2361
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
2210 2362
 			if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id'])))
@@ -2371,13 +2523,16 @@  discard block
 block discarded – undo
2371 2523
 					foreach ($event['participants'] as $attendee => $status)
2372 2524
 					{
2373 2525
 						if (!isset($egwEvent['participants'][$attendee]) &&
2374
-								$attendee != $egwEvent['owner']) // ||
2526
+								$attendee != $egwEvent['owner'])
2527
+						{
2528
+							// ||
2375 2529
 							//(!$relax && $egw_event['participants'][$attendee] != $status))
2376 2530
 						{
2377 2531
 							if ($this->log)
2378 2532
 							{
2379 2533
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2380 2534
 								"() additional event['participants']: $attendee\n",3,$this->logfile);
2535
+						}
2381 2536
 							}
2382 2537
 							continue 2;
2383 2538
 						}
@@ -2699,7 +2854,10 @@  discard block
 block discarded – undo
2699 2854
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2700 2855
 		{
2701 2856
 			// we convert here from server-time to timestamps in user-time!
2702
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2857
+			if (isset($event[$ts]))
2858
+			{
2859
+				$event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2860
+			}
2703 2861
 		}
2704 2862
 		// same with the recur exceptions
2705 2863
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
@@ -2727,9 +2885,12 @@  discard block
 block discarded – undo
2727 2885
 	 */
2728 2886
 	function purge($age)
2729 2887
 	{
2730
-		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2888
+		if (is_numeric($age) && $age > 0)
2889
+		{
2890
+			// just make sure bogus values dont delete everything
2731 2891
 		{
2732 2892
 			$this->so->purge(time() - 365*24*3600*(float)$age);
2733 2893
 		}
2894
+		}
2734 2895
 	}
2735 2896
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1707,12 +1707,12 @@  discard block
 block discarded – undo
1707 1707
 	 */
1708 1708
 	function event2array($event)
1709 1709
 	{
1710
-		$var['title'] = Array(
1710
+		$var['title'] = array(
1711 1711
 			'field'		=> lang('Title'),
1712 1712
 			'data'		=> $event['title']
1713 1713
 		);
1714 1714
 
1715
-		$var['description'] = Array(
1715
+		$var['description'] = array(
1716 1716
 			'field'	=> lang('Description'),
1717 1717
 			'data'	=> $event['description']
1718 1718
 		);
@@ -1722,48 +1722,48 @@  discard block
 block discarded – undo
1722 1722
 			list($cat) = $GLOBALS['egw']->categories->return_single($cat_id);
1723 1723
 			$cat_string[] = stripslashes($cat['name']);
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'	=> common::grab_owner_name($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']).', '.common::grab_owner_name($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 egw_time $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, egw_time $instance_date = null)
1831
+	function check_move_alarms(array &$event, array $old_event = null, egw_time $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_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.
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.
Braces   +75 added lines, -32 removed lines patch added patch discarded remove patch
@@ -17,7 +17,8 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * class import_csv for calendar
19 19
  */
20
-class calendar_import_csv extends importexport_basic_import_csv  {
20
+class calendar_import_csv extends importexport_basic_import_csv
21
+{
21 22
 
22 23
 	/**
23 24
 	 * actions wich could be done to data entries
@@ -83,8 +84,10 @@  discard block
 block discarded – undo
83 84
 		$options['owner'] = $options['owner'] ? $options['owner'] : $this->user;
84 85
 
85 86
 		// Set owner, unless it's supposed to come from CSV file
86
-		if($options['owner_from_csv']) {
87
-			if(!is_numeric($record['owner'])) {
87
+		if($options['owner_from_csv'])
88
+		{
89
+			if(!is_numeric($record['owner']))
90
+			{
88 91
 				$this->errors[$import_csv->get_current_position()] = lang(
89 92
 					'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
90 93
 					$record->owner,
@@ -106,14 +109,16 @@  discard block
 block discarded – undo
106 109
 		}
107 110
 
108 111
 		// Parse particpants
109
-		if ($record->participants && !is_array($record->participants)) {
112
+		if ($record->participants && !is_array($record->participants))
113
+		{
110 114
 			// Importing participants in human friendly format:
111 115
 			// Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+
112 116
 			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants);
113 117
 			$p_participants = array();
114 118
 			$missing = array();
115 119
 			list($lines, $p, $names, $quantity, $status, $role) = $participants;
116
-			foreach($names as $key => $name) {
120
+			foreach($names as $key => $name)
121
+			{
117 122
 				//error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}");
118 123
 
119 124
 				// Search for direct account name, then user in accounts first
@@ -121,9 +126,13 @@  discard block
 block discarded – undo
121 126
 				$id = importexport_helper_functions::account_name2id($name);
122 127
 
123 128
 				// If not found, or not an exact match to a user (account_name2id is pretty generous)
124
-				if(!$id || $names[$key] !== $this->bo->participant_name($id)) {
129
+				if(!$id || $names[$key] !== $this->bo->participant_name($id))
130
+				{
125 131
 					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1));
126
-					if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
132
+					if($contacts)
133
+					{
134
+						$id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
135
+					}
127 136
 				}
128 137
 				if(!$id)
129 138
 				{
@@ -131,7 +140,10 @@  discard block
 block discarded – undo
131 140
 					foreach($this->bo->resources as $resource)
132 141
 					{
133 142
 						// Can't search for email
134
-						if($resource['app'] == 'email') continue;
143
+						if($resource['app'] == 'email')
144
+						{
145
+							continue;
146
+						}
135 147
 						// Special resource search, since it does special stuff in link_query
136 148
 						if($resource['app'] == 'resources')
137 149
 						{
@@ -140,7 +152,8 @@  discard block
 block discarded – undo
140 152
 								$this->resource_so = new resources_so();
141 153
 							}
142 154
 							$result = $this->resource_so->search($search,'res_id');
143
-							if(count($result) >= 1) {
155
+							if(count($result) >= 1)
156
+							{
144 157
 								$id = $resource['type'].$result[0]['res_id'];
145 158
 								break;
146 159
 							}
@@ -159,7 +172,8 @@  discard block
 block discarded – undo
159 172
 						}
160 173
 					}
161 174
 				}
162
-				if($id) {
175
+				if($id)
176
+				{
163 177
 					$p_participants[$id] = calendar_so::combine_status(
164 178
 						$this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0],
165 179
 						$quantity[$key] ? $quantity[$key] : 1,
@@ -188,27 +202,38 @@  discard block
 block discarded – undo
188 202
 		}
189 203
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
190 204
 
191
-		if ( $options['conditions'] ) {
192
-			foreach ( $options['conditions'] as $condition ) {
205
+		if ( $options['conditions'] )
206
+		{
207
+			foreach ( $options['conditions'] as $condition )
208
+			{
193 209
 				$records = array();
194
-				switch ( $condition['type'] ) {
210
+				switch ( $condition['type'] )
211
+				{
195 212
 					// exists
196 213
 					case 'exists' :
197 214
 						// Check for that record
198 215
 						$result = $this->exists($record, $condition, $records);
199 216
 
200
-						if ( is_array( $records ) && count( $records ) >= 1) {
217
+						if ( is_array( $records ) && count( $records ) >= 1)
218
+						{
201 219
 							// apply action to all records matching this exists condition
202 220
 							$action = $condition['true'];
203
-							foreach ( (array)$records as $event ) {
221
+							foreach ( (array)$records as $event )
222
+							{
204 223
 								$record->id = $event['id'];
205
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
206
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
224
+								if ( $this->definition->plugin_options['update_cats'] == 'add' )
225
+								{
226
+									if ( !is_array( $record->category ) )
227
+									{
228
+										$record->category = explode( ',', $record->category );
229
+									}
207 230
 									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
208 231
 								}
209 232
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
210 233
 							}
211
-						} else {
234
+						}
235
+						else
236
+						{
212 237
 							$action = $condition['false'];
213 238
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
214 239
 						}
@@ -219,9 +244,14 @@  discard block
 block discarded – undo
219 244
 						die('condition / action not supported!!!');
220 245
 						break;
221 246
 				}
222
-				if ($action['last']) break;
247
+				if ($action['last'])
248
+				{
249
+					break;
250
+				}
223 251
 			}
224
-		} else {
252
+		}
253
+		else
254
+		{
225 255
 			// unconditional insert
226 256
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
227 257
 		}
@@ -240,12 +270,14 @@  discard block
 block discarded – undo
240 270
 	 */
241 271
 	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
242 272
 	{
243
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
273
+		if($record->__get($condition['string']) && $condition['string'] == 'id')
274
+		{
244 275
 			$event = $this->bo->read($record->__get($condition['string']));
245 276
 			$records = array($event);
246 277
 		}
247 278
 
248
-		if ( is_array( $records ) && count( $records ) >= 1) {
279
+		if ( is_array( $records ) && count( $records ) >= 1)
280
+		{
249 281
 			return true;
250 282
 		}
251 283
 		return false;
@@ -261,7 +293,8 @@  discard block
 block discarded – undo
261 293
 	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
262 294
 	{
263 295
 		$_data = $record->get_record_array();
264
-		switch ($_action) {
296
+		switch ($_action)
297
+		{
265 298
 			case 'none' :
266 299
 				return true;
267 300
 			case 'update' :
@@ -269,7 +302,8 @@  discard block
 block discarded – undo
269 302
 				$old = $this->bo->read($_data['id']);
270 303
 
271 304
 				// Don't change a user account into a record
272
-				if(!$this->definition->plugin_options['change_owner']) {
305
+				if(!$this->definition->plugin_options['change_owner'])
306
+				{
273 307
 					// Don't change owner of an existing record
274 308
 					unset($_data['owner']);
275 309
 				}
@@ -277,23 +311,27 @@  discard block
 block discarded – undo
277 311
 				// Merge to deal with fields not in import record
278 312
 				$_data = array_merge($old, $_data);
279 313
 				$changed = $this->tracking->changed_fields($_data, $old);
280
-				if(count($changed) == 0) {
314
+				if(count($changed) == 0)
315
+				{
281 316
 					return true;
282 317
 				}
283 318
 				// Fall through
284 319
 			case 'insert' :
285
-				if($_action == 'insert') {
320
+				if($_action == 'insert')
321
+				{
286 322
 					// Backend doesn't like inserting with ID specified, can overwrite existing
287 323
 					unset($_data['id']);
288 324
 				}
289 325
 				// Make sure participants are set
290
-				if(!$_data['participants']) {
326
+				if(!$_data['participants'])
327
+				{
291 328
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
292 329
 					$_data['participants'] = array(
293 330
 						$user => 'U'
294 331
 					);
295 332
 				}
296
-				if ( $this->dry_run ) {
333
+				if ( $this->dry_run )
334
+				{
297 335
 					//print_r($_data);
298 336
 					// User is interested in conflict checks, do so for dry run
299 337
 					// Otherwise, conflicts are just ignored and imported anyway
@@ -309,7 +347,9 @@  discard block
 block discarded – undo
309 347
 					}
310 348
 					$this->results[$_action]++;
311 349
 					return true;
312
-				} else {
350
+				}
351
+				else
352
+				{
313 353
 					$messages = null;
314 354
 					$result = $this->bo->update( $_data, 
315 355
 						!$this->definition->plugin_options['skip_conflicts'],
@@ -360,7 +400,8 @@  discard block
 block discarded – undo
360 400
 	 *
361 401
 	 * @return string name
362 402
 	 */
363
-	public static function get_name() {
403
+	public static function get_name()
404
+	{
364 405
 		return lang('Calendar CSV import');
365 406
 	}
366 407
 
@@ -369,7 +410,8 @@  discard block
 block discarded – undo
369 410
 	 *
370 411
 	 * @return string descriprion
371 412
 	 */
372
-	public static function get_description() {
413
+	public static function get_description()
414
+	{
373 415
 		return lang("Imports events into your Calendar from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
374 416
 	}
375 417
 
@@ -378,7 +420,8 @@  discard block
 block discarded – undo
378 420
 	 *
379 421
 	 * @return string suffix (comma seperated)
380 422
 	 */
381
-	public static function get_filesuffix() {
423
+	public static function get_filesuffix()
424
+	{
382 425
 		return 'csv';
383 426
 	}
384 427
 
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * class import_csv for calendar
19 19
  */
20
-class calendar_import_csv extends importexport_basic_import_csv  {
20
+class calendar_import_csv extends importexport_basic_import_csv {
21 21
 
22 22
 	/**
23 23
 	 * actions wich could be done to data entries
24 24
 	 */
25
-	protected static $actions = array( 'none', 'update', 'insert' );
25
+	protected static $actions = array('none', 'update', 'insert');
26 26
 
27 27
 	/**
28 28
 	 * conditions for actions
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * Set up tracker
46 46
 	 */
47
-	protected function init(importexport_definition &$definition)
47
+	protected function init(importexport_definition&$definition)
48 48
 	{
49 49
 		// fetch the addressbook bo
50
-		$this->bo= new calendar_boupdate();
50
+		$this->bo = new calendar_boupdate();
51 51
 
52 52
 		// Get the tracker for changes
53 53
 		$this->tracking = new calendar_tracking();
54 54
 
55 55
 		// Used for participants
56
-		$this->status_map = array_flip(array_map('lang',$this->bo->verbose_status));
56
+		$this->status_map = array_flip(array_map('lang', $this->bo->verbose_status));
57 57
 		$this->role_map = array_flip($this->bo->roles);
58 58
 
59 59
 		$this->lookups = array(
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return boolean success
78 78
 	 */
79
-	public function import_record(\importexport_iface_egw_record &$record, &$import_csv)
79
+	public function import_record(\importexport_iface_egw_record&$record, &$import_csv)
80 80
 	{
81 81
 		// set eventOwner
82
-		$options =& $this->definition->plugin_options;
82
+		$options = & $this->definition->plugin_options;
83 83
 		$options['owner'] = $options['owner'] ? $options['owner'] : $this->user;
84 84
 
85 85
 		// Set owner, unless it's supposed to come from CSV file
86
-		if($options['owner_from_csv']) {
87
-			if(!is_numeric($record['owner'])) {
86
+		if ($options['owner_from_csv']) {
87
+			if (!is_numeric($record['owner'])) {
88 88
 				$this->errors[$import_csv->get_current_position()] = lang(
89 89
 					'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
90 90
 					$record->owner,
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		}
100 100
 		
101 101
 		// Handle errors in length or start/end date
102
-		if($record->start > $record->end)
102
+		if ($record->start > $record->end)
103 103
 		{
104 104
 			$record->end = $record->start + $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60;
105 105
 			$this->warnings[$import_csv->get_current_position()] = lang('error: starttime has to be before the endtime !!!');
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 		if ($record->participants && !is_array($record->participants)) {
110 110
 			// Importing participants in human friendly format:
111 111
 			// Name (quantity)? (status) Role[, Name (quantity)? (status) Role]+
112
-			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/',$record->participants,$participants);
112
+			preg_match_all('/(([^(]+?)(?: \(([\d]+)\))? \(([^,)]+)\)(?: ([^ ,]+))?)(?:, )?/', $record->participants, $participants);
113 113
 			$p_participants = array();
114 114
 			$missing = array();
115 115
 			list($lines, $p, $names, $quantity, $status, $role) = $participants;
116
-			foreach($names as $key => $name) {
116
+			foreach ($names as $key => $name) {
117 117
 				//error_log("Name: $name Quantity: {$quantity[$key]} Status: {$status[$key]} Role: {$role[$key]}");
118 118
 
119 119
 				// Search for direct account name, then user in accounts first
@@ -121,26 +121,26 @@  discard block
 block discarded – undo
121 121
 				$id = importexport_helper_functions::account_name2id($name);
122 122
 
123 123
 				// If not found, or not an exact match to a user (account_name2id is pretty generous)
124
-				if(!$id || $names[$key] !== $this->bo->participant_name($id)) {
125
-					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search,array('contact_id','account_id'),'org_name,n_family,n_given,cat_id,contact_email','','%',false,'OR',array(0,1));
126
-					if($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
124
+				if (!$id || $names[$key] !== $this->bo->participant_name($id)) {
125
+					$contacts = ExecMethod2('addressbook.addressbook_bo.search', $search, array('contact_id', 'account_id'), 'org_name,n_family,n_given,cat_id,contact_email', '', '%', false, 'OR', array(0, 1));
126
+					if ($contacts) $id = $contacts[0]['account_id'] ? $contacts[0]['account_id'] : 'c'.$contacts[0]['contact_id'];
127 127
 				}
128
-				if(!$id)
128
+				if (!$id)
129 129
 				{
130 130
 					// Use calendar's registered resources to find participant
131
-					foreach($this->bo->resources as $resource)
131
+					foreach ($this->bo->resources as $resource)
132 132
 					{
133 133
 						// Can't search for email
134
-						if($resource['app'] == 'email') continue;
134
+						if ($resource['app'] == 'email') continue;
135 135
 						// Special resource search, since it does special stuff in link_query
136
-						if($resource['app'] == 'resources')
136
+						if ($resource['app'] == 'resources')
137 137
 						{
138
-							if(!$this->resource_so)
138
+							if (!$this->resource_so)
139 139
 							{
140 140
 								$this->resource_so = new resources_so();
141 141
 							}
142
-							$result = $this->resource_so->search($search,'res_id');
143
-							if(count($result) >= 1) {
142
+							$result = $this->resource_so->search($search, 'res_id');
143
+							if (count($result) >= 1) {
144 144
 								$id = $resource['type'].$result[0]['res_id'];
145 145
 								break;
146 146
 							}
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 							$link_options = array();
152 152
 							$result = Link::query($resource['app'], $search, $link_options);
153 153
 
154
-							if($result)
154
+							if ($result)
155 155
 							{
156
-								$id = $resource['type'] . key($result);
156
+								$id = $resource['type'].key($result);
157 157
 								break;
158 158
 							}
159 159
 						}
160 160
 					}
161 161
 				}
162
-				if($id) {
162
+				if ($id) {
163 163
 					$p_participants[$id] = calendar_so::combine_status(
164 164
 						$this->status_map[lang($status[$key])] ? $this->status_map[lang($status[$key])] : $status[$key][0],
165 165
 						$quantity[$key] ? $quantity[$key] : 1,
@@ -170,47 +170,47 @@  discard block
 block discarded – undo
170 170
 				{
171 171
 					$missing[] = $name;
172 172
 				}
173
-				if(count($missing) > 0)
173
+				if (count($missing) > 0)
174 174
 				{
175
-					$this->warnings[$import_csv->get_current_position()] = $record->title . ' ' . lang('participants') . ': ' .
176
-						lang('Contact not found!') . '<br />'.implode(", ",$missing);
175
+					$this->warnings[$import_csv->get_current_position()] = $record->title.' '.lang('participants').': '.
176
+						lang('Contact not found!').'<br />'.implode(", ", $missing);
177 177
 				}
178 178
 			}
179 179
 			$record->participants = $p_participants;
180 180
 		}
181 181
 
182
-		if($record->recurrence)
182
+		if ($record->recurrence)
183 183
 		{
184
-			list($record->recur_type, $record->recur_interval) = explode('/',$record->recurrence,2);
184
+			list($record->recur_type, $record->recur_interval) = explode('/', $record->recurrence, 2);
185 185
 			$record->recur_interval = trim($record->recur_interval);
186
-			$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower',$this->lookups['recurrence']));
186
+			$record->recur_type = array_search(strtolower(trim($record->recur_type)), array_map('strtolower', $this->lookups['recurrence']));
187 187
 			unset($record->recurrence);
188 188
 		}
189 189
 		$record->tzid = calendar_timezones::id2tz($record->tz_id);
190 190
 
191
-		if ( $options['conditions'] ) {
192
-			foreach ( $options['conditions'] as $condition ) {
191
+		if ($options['conditions']) {
192
+			foreach ($options['conditions'] as $condition) {
193 193
 				$records = array();
194
-				switch ( $condition['type'] ) {
194
+				switch ($condition['type']) {
195 195
 					// exists
196 196
 					case 'exists' :
197 197
 						// Check for that record
198 198
 						$result = $this->exists($record, $condition, $records);
199 199
 
200
-						if ( is_array( $records ) && count( $records ) >= 1) {
200
+						if (is_array($records) && count($records) >= 1) {
201 201
 							// apply action to all records matching this exists condition
202 202
 							$action = $condition['true'];
203
-							foreach ( (array)$records as $event ) {
203
+							foreach ((array)$records as $event) {
204 204
 								$record->id = $event['id'];
205
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
206
-									if ( !is_array( $record->category ) ) $record->category = explode( ',', $record->category );
207
-									$record->category = implode( ',', array_unique( array_merge( $record->category, $event['category'] ) ) );
205
+								if ($this->definition->plugin_options['update_cats'] == 'add') {
206
+									if (!is_array($record->category)) $record->category = explode(',', $record->category);
207
+									$record->category = implode(',', array_unique(array_merge($record->category, $event['category'])));
208 208
 								}
209
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
209
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
210 210
 							}
211 211
 						} else {
212 212
 							$action = $condition['false'];
213
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
213
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
214 214
 						}
215 215
 						break;
216 216
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 			}
224 224
 		} else {
225 225
 			// unconditional insert
226
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
226
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
227 227
 		}
228 228
 		
229 229
 		return $success;
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return boolean
240 240
 	 */
241
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$records = array())
241
+	protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$records = array())
242 242
 	{
243
-		if($record->__get($condition['string']) && $condition['string'] == 'id') {
243
+		if ($record->__get($condition['string']) && $condition['string'] == 'id') {
244 244
 			$event = $this->bo->read($record->__get($condition['string']));
245 245
 			$records = array($event);
246 246
 		}
247 247
 
248
-		if ( is_array( $records ) && count( $records ) >= 1) {
248
+		if (is_array($records) && count($records) >= 1) {
249 249
 			return true;
250 250
 		}
251 251
 		return false;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @param array $_data record data for the action
259 259
 	 * @return bool success or not
260 260
 	 */
261
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
261
+	protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0)
262 262
 	{
263 263
 		$_data = $record->get_record_array();
264 264
 		switch ($_action) {
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 				$old = $this->bo->read($_data['id']);
270 270
 
271 271
 				// Don't change a user account into a record
272
-				if(!$this->definition->plugin_options['change_owner']) {
272
+				if (!$this->definition->plugin_options['change_owner']) {
273 273
 					// Don't change owner of an existing record
274 274
 					unset($_data['owner']);
275 275
 				}
@@ -277,30 +277,30 @@  discard block
 block discarded – undo
277 277
 				// Merge to deal with fields not in import record
278 278
 				$_data = array_merge($old, $_data);
279 279
 				$changed = $this->tracking->changed_fields($_data, $old);
280
-				if(count($changed) == 0) {
280
+				if (count($changed) == 0) {
281 281
 					return true;
282 282
 				}
283 283
 				// Fall through
284 284
 			case 'insert' :
285
-				if($_action == 'insert') {
285
+				if ($_action == 'insert') {
286 286
 					// Backend doesn't like inserting with ID specified, can overwrite existing
287 287
 					unset($_data['id']);
288 288
 				}
289 289
 				// Make sure participants are set
290
-				if(!$_data['participants']) {
290
+				if (!$_data['participants']) {
291 291
 					$user = $_data['owner'] ? $_data['owner'] : $this->user;
292 292
 					$_data['participants'] = array(
293 293
 						$user => 'U'
294 294
 					);
295 295
 				}
296
-				if ( $this->dry_run ) {
296
+				if ($this->dry_run) {
297 297
 					//print_r($_data);
298 298
 					// User is interested in conflict checks, do so for dry run
299 299
 					// Otherwise, conflicts are just ignored and imported anyway
300
-					if($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking'])
300
+					if ($this->definition->plugin_options['skip_conflicts'] && !$_data['non_blocking'])
301 301
 					{
302 302
 						$conflicts = $this->bo->conflicts($_data);
303
-						if($conflicts)
303
+						if ($conflicts)
304 304
 						{
305 305
 							$this->conflict_warning($record_num, $conflicts);
306 306
 							$this->results['skipped']++;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 					return true;
312 312
 				} else {
313 313
 					$messages = null;
314
-					$result = $this->bo->update( $_data, 
314
+					$result = $this->bo->update($_data, 
315 315
 						!$this->definition->plugin_options['skip_conflicts'],
316 316
 						true, $this->is_admin, true, $messages,
317 317
 						$this->definition->plugin_options['no_notification']
318 318
 					);
319
-					if(!$result)
319
+					if (!$result)
320 320
 					{
321
-						$this->errors[$record_num] = lang('Unable to save') . "\n" .
322
-							implode("\n",$messages);
321
+						$this->errors[$record_num] = lang('Unable to save')."\n".
322
+							implode("\n", $messages);
323 323
 					}
324 324
 					else if (is_array($result))
325 325
 					{
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 	 */
350 350
 	protected function conflict_warning($record_num, &$conflicts)
351 351
 	{
352
-		$this->warnings[$record_num] = lang('Conflicts') . ':';
353
-		foreach($conflicts as $conflict)
352
+		$this->warnings[$record_num] = lang('Conflicts').':';
353
+		foreach ($conflicts as $conflict)
354 354
 		{
355
-			$this->warnings[$record_num] .= "<br />\n" . Api\DateTime::to($conflict['start']) . "\t" . $conflict['title'];
355
+			$this->warnings[$record_num] .= "<br />\n".Api\DateTime::to($conflict['start'])."\t".$conflict['title'];
356 356
 		}
357 357
 	}
358 358
 
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 	 *
389 389
 	 * @param egw_record $row_entry
390 390
 	 */
391
-	protected function row_preview(importexport_iface_egw_record &$row_entry)
391
+	protected function row_preview(importexport_iface_egw_record&$row_entry)
392 392
 	{
393
-		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true));
393
+		$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true));
394 394
 	}
395 395
 
396 396
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
calendar/inc/class.calendar_timezones.inc.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -204,6 +204,7 @@
 block discarded – undo
204 204
 	 *
205 205
 	 * @param boolean &$updated=null on return true if update was neccessary, false if tz's were already up to date
206 206
 	 * @param string $file ='calendar/setup/timezones.sqlite' filename relative to EGW_SERVER_ROOT
207
+	 * @param boolean $updated
207 208
 	 * @return string message about update
208 209
 	 * @throws Api\Exception\WrongParameter if $file is not readable or wrong format/version
209 210
 	 * @throws Api\Exception\WrongUserinput if no PDO sqlite support
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public static function DateTimeZone($tzid)
71 71
 	{
72
-		if (($id = self::tz2id($tzid,'alias')))
72
+		if (($id = self::tz2id($tzid, 'alias')))
73 73
 		{
74 74
 			$tzid = self::id2tz($id);
75 75
 		}
@@ -87,34 +87,34 @@  discard block
 block discarded – undo
87 87
 	 * @param string $what ='id' what to return, default id, null for whole array
88 88
 	 * @return int tz_id or null if not found
89 89
 	 */
90
-	public static function tz2id($tzid,$what='id')
90
+	public static function tz2id($tzid, $what = 'id')
91 91
 	{
92
-		$id =& self::$tz2id[$tzid];
92
+		$id = & self::$tz2id[$tzid];
93 93
 
94 94
 		if (!isset($id))
95 95
 		{
96
-			if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array(
96
+			if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array(
97 97
 				'tz_tzid' => $tzid,
98
-			),__LINE__,__FILE__,false,'','calendar')->fetch()))
98
+			), __LINE__, __FILE__, false, '', 'calendar')->fetch()))
99 99
 			{
100 100
 				$id = $data['tz_id'];
101
-				self::$tz_cache[$id] = egw_db::strip_array_keys($data,'tz_');
101
+				self::$tz_cache[$id] = egw_db::strip_array_keys($data, 'tz_');
102 102
 			}
103 103
 		}
104 104
 		// check if we can find a 3-part America timezone eg. check 'America/Argentina/Buenos_Aires' for 'America/Buenos_Aires'
105 105
 		if (!isset($id) && stripos($tzid, 'America/') === 0 && count($parts = explode('/', $tzid)) == 2)
106 106
 		{
107
-			if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array(
107
+			if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array(
108 108
 				'tz_tzid LIKE '.$GLOBALS['egw']->db->quote($parts[0].'/%/'.$parts[1]),
109
-			),__LINE__,__FILE__,false,'','calendar')->fetch()))
109
+			), __LINE__, __FILE__, false, '', 'calendar')->fetch()))
110 110
 			{
111 111
 				$id = $data['tz_id'];
112
-				self::$tz_cache[$id] = egw_db::strip_array_keys($data,'tz_');
112
+				self::$tz_cache[$id] = egw_db::strip_array_keys($data, 'tz_');
113 113
 			}
114 114
 		}
115 115
 		if (isset($id) && $what != 'id')
116 116
 		{
117
-			return self::id2tz($id,$what);
117
+			return self::id2tz($id, $what);
118 118
 		}
119 119
 		return $id;
120 120
 	}
@@ -132,24 +132,24 @@  discard block
 block discarded – undo
132 132
 	 * @param string $what ='tzid' what data to return or null for whole data array, with keys 'id', 'tzid', 'component', 'alias', 'latitude', 'longitude'
133 133
 	 * @return mixed false: if not found
134 134
 	 */
135
-	public static function id2tz($id,$what='tzid')
135
+	public static function id2tz($id, $what = 'tzid')
136 136
 	{
137
-		$data =& self::$tz_cache[$id];
137
+		$data = & self::$tz_cache[$id];
138 138
 
139 139
 		if (!isset($data))
140 140
 		{
141
-			if (($data = $GLOBALS['egw']->db->select(self::TABLE,'*',array(
141
+			if (($data = $GLOBALS['egw']->db->select(self::TABLE, '*', array(
142 142
 				'tz_id' => $id,
143
-			),__LINE__,__FILE__,false,'','calendar')->fetch()))
143
+			), __LINE__, __FILE__, false, '', 'calendar')->fetch()))
144 144
 			{
145
-				$data = egw_db::strip_array_keys($data,'tz_');
145
+				$data = egw_db::strip_array_keys($data, 'tz_');
146 146
 				self::$tz2id[$data['tzid']] = $id;
147 147
 			}
148 148
 		}
149 149
 		// if not tzid queried, resolve aliases automatically
150 150
 		if ($data && $data['alias'] && $what != 'tzid' && $what != 'alias')
151 151
 		{
152
-			$data = self::id2tz($data['alias'],null);
152
+			$data = self::id2tz($data['alias'], null);
153 153
 		}
154 154
 		return !$data ? $data : ($what ? $data[$what] : $data);
155 155
 	}
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public static function init_static()
170 170
 	{
171
-		self::$tz_cache =& egw_cache::getSession(__CLASS__,'tz_cache');
172
-		self::$tz2id =& egw_cache::getSession(__CLASS__,'tz2id');
171
+		self::$tz_cache = & egw_cache::getSession(__CLASS__, 'tz_cache');
172
+		self::$tz2id = & egw_cache::getSession(__CLASS__, 'tz2id');
173 173
 
174 174
 		// init cache with mapping UTC <--> -1, as UTC is no real timezone, but we need to be able to use it in calendar
175 175
 		if (!is_array(self::$tz2id))
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 		{
187 187
 			$updated = false;
188 188
 			$msg = self::import_zones($updated);
189
-			if ($updated) error_log($msg);	// log that timezones have been updated
189
+			if ($updated) error_log($msg); // log that timezones have been updated
190 190
 
191 191
 			$alias_msg = self::import_tz_aliases($updated);
192
-			if ($updated) error_log($alias_msg);	// log that timezone aliases have been updated
192
+			if ($updated) error_log($alias_msg); // log that timezone aliases have been updated
193 193
 
194 194
 			self::$import_msg = $msg.'<br/>'.$alias_msg;
195 195
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @throws egw_exception_wrong_userinput for broken sqlite extension
209 209
 	 * @link https://hg.mozilla.org/comm-central/raw-file/tip/calendar/timezones/zones.json
210 210
 	 */
211
-	public static function import_zones(&$updated=null, $file='calendar/setup/zones.json')
211
+	public static function import_zones(&$updated = null, $file = 'calendar/setup/zones.json')
212 212
 	{
213 213
 		$path = EGW_SERVER_ROOT.'/'.$file;
214 214
 
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 		{
231 231
 			$updated = false;
232 232
 			fclose($fp);
233
-			return lang('Nothing to update, version is already %1.',$config['tz_version']);	// we already have the right
233
+			return lang('Nothing to update, version is already %1.', $config['tz_version']); // we already have the right
234 234
 		}
235
-		$json .= fread($fp, 1024*1024);
235
+		$json .= fread($fp, 1024 * 1024);
236 236
 		fclose($fp);
237 237
 		if (!($zones = json_decode($json, true)) || !isset($zones['aliases']) || !isset($zones['zones']))
238 238
 		{
@@ -240,38 +240,38 @@  discard block
 block discarded – undo
240 240
 		}
241 241
 		// import zones first and then aliases
242 242
 		$tz2id = array();
243
-		foreach(array('zones', 'aliases') as $type)
243
+		foreach (array('zones', 'aliases') as $type)
244 244
 		{
245
-			foreach($zones[$type] as $tzid => $data)
245
+			foreach ($zones[$type] as $tzid => $data)
246 246
 			{
247 247
 				if ($type == 'aliases')
248 248
 				{
249 249
 					$data = array('alias' => $tz2id[$data['aliasTo']]);
250
-					if (!$data['alias']) continue;	// there's no such tzid
250
+					if (!$data['alias']) continue; // there's no such tzid
251 251
 				}
252 252
 				// check if already in database
253
-				$tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array(
253
+				$tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones', 'tz_id', array(
254 254
 						'tz_tzid' => $tzid,
255
-					),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
255
+					), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
256 256
 
257
-				$GLOBALS['egw']->db->insert('egw_cal_timezones',array(
257
+				$GLOBALS['egw']->db->insert('egw_cal_timezones', array(
258 258
 					'tz_alias' => $data['alias'],
259 259
 					'tz_latitude' => $data['latitude'],
260 260
 					'tz_longitude' => $data['longitude'],
261 261
 					'tz_component' => $data['ics'],
262
-				),array(
262
+				), array(
263 263
 					'tz_tzid' => $tzid,
264
-				),__LINE__,__FILE__,'calendar');
264
+				), __LINE__, __FILE__, 'calendar');
265 265
 
266 266
 				// only query last insert id, if not already in database (gives warning for PostgreSQL)
267
-				if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
267
+				if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones', 'tz_id');
268 268
 			}
269 269
 		}
270 270
 		config::save_value('tz_version', $tz_version, 'phpgwapi');
271 271
 
272 272
 		//_debug_array($tz2id);
273 273
 		$updated = true;
274
-		return lang('Timezones updated to version %1 (%2 records updated).',$tz_version,count($tz2id));
274
+		return lang('Timezones updated to version %1 (%2 records updated).', $tz_version, count($tz2id));
275 275
 	}
276 276
 
277 277
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @return string message about update
283 283
 	 * @throws egw_exception_wrong_parameter if $file is not readable or wrong format/version
284 284
 	 */
285
-	public static function import_tz_aliases(&$updated=null,$file='calendar/setup/tz_aliases.inc.php')
285
+	public static function import_tz_aliases(&$updated = null, $file = 'calendar/setup/tz_aliases.inc.php')
286 286
 	{
287 287
 		$path = EGW_SERVER_ROOT.'/'.$file;
288 288
 
@@ -295,27 +295,27 @@  discard block
 block discarded – undo
295 295
 		if ($tz_aliases_mtime === $config['tz_aliases_mtime'])
296 296
 		{
297 297
 			$updated = false;
298
-			return lang('Nothing to update, version is already %1.',$tz_aliases_mtime);
298
+			return lang('Nothing to update, version is already %1.', $tz_aliases_mtime);
299 299
 		}
300 300
 		$tz_aliases = array();
301
-		include($path);	// sets $tz_aliases
301
+		include($path); // sets $tz_aliases
302 302
 
303 303
 		$updates = 0;
304
-		foreach($tz_aliases as $alias => $tzid)
304
+		foreach ($tz_aliases as $alias => $tzid)
305 305
 		{
306
-			if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) &&	// not in DB or different
306
+			if ((!($alias_id = self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) && // not in DB or different
307 307
 				($tz_id = self::tz2id($tzid)))	// given tzid for alias exists in DB
308 308
 			{
309
-				$GLOBALS['egw']->db->insert('egw_cal_timezones',array(
309
+				$GLOBALS['egw']->db->insert('egw_cal_timezones', array(
310 310
 					'tz_alias' => $tz_id,
311
-				),array(
311
+				), array(
312 312
 					'tz_tzid' => $alias,
313
-				),__LINE__,__FILE__,'calendar');
313
+				), __LINE__, __FILE__, 'calendar');
314 314
 				++$updates;
315 315
 			}
316 316
 			//error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).",  self::tz2id('$tzid')=".array2string($tz_id));
317 317
 		}
318
-		config::save_value('tz_aliases_mtime',$tz_aliases_mtime,$app='phpgwapi');
318
+		config::save_value('tz_aliases_mtime', $tz_aliases_mtime, $app = 'phpgwapi');
319 319
 
320 320
 		//_debug_array($tz2id);
321 321
 		$updated = true;
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 		}
357 357
 		// $vtimezone is a string with a single VTIMEZONE component, afaik Horde_Icalendar can not add it directly
358 358
 		// --> we have to parse it and let Horde_Icalendar add it again
359
-		$horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE',$container=false);
360
-		$horde_vtimezone->parsevCalendar($vtimezone,'VTIMEZONE');
359
+		$horde_vtimezone = Horde_Icalendar::newComponent('VTIMEZONE', $container = false);
360
+		$horde_vtimezone->parsevCalendar($vtimezone, 'VTIMEZONE');
361 361
 		// DTSTART is in UTC time, Horde_Icalendar parses it in server timezone, which we need to set again for printing
362 362
 		$standard = $horde_vtimezone->findComponent('STANDARD');
363 363
 		if (is_a($standard, 'Horde_Icalendar'))
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 	 * @param string $type ='vcalendar' 'tzid' or everything tz2id supports, default 'vcalendar' = full vcalendar component
389 389
 	 * @return string
390 390
 	 */
391
-	public static function user_timezone($user=null, $type='vcalendar')
391
+	public static function user_timezone($user = null, $type = 'vcalendar')
392 392
 	{
393 393
 		if (!$user || $user == $GLOBALS['egw_info']['user']['account_id'])
394 394
 		{
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 			case 'vcalendar':
408 408
 				// checking type of $val, now we included the object definition (no need to always include it!)
409 409
 				$vcal = new Horde_Icalendar;
410
-				$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
410
+				$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
411 411
 					strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
412 412
 				self::add_vtimezone($vcal, $tzid);
413 413
 				$tzid = $vcal->exportvCalendar('utf-8');
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 			case 'tzid':
416 416
 				break;
417 417
 			default:
418
-				$tzid = self::tz2id($tzid,$type == 'vcalendar' ? 'component' : $type);
418
+				$tzid = self::tz2id($tzid, $type == 'vcalendar' ? 'component' : $type);
419 419
 				break;
420 420
 		}
421 421
 		return $tzid;
Please login to merge, or discard this patch.
Braces   +27 added lines, -6 removed lines patch added patch discarded remove patch
@@ -186,10 +186,18 @@  discard block
 block discarded – undo
186 186
 		{
187 187
 			$updated = false;
188 188
 			$msg = self::import_zones($updated);
189
-			if ($updated) error_log($msg);	// log that timezones have been updated
189
+			if ($updated)
190
+			{
191
+				error_log($msg);
192
+			}
193
+			// log that timezones have been updated
190 194
 
191 195
 			$alias_msg = self::import_tz_aliases($updated);
192
-			if ($updated) error_log($alias_msg);	// log that timezone aliases have been updated
196
+			if ($updated)
197
+			{
198
+				error_log($alias_msg);
199
+			}
200
+			// log that timezone aliases have been updated
193 201
 
194 202
 			self::$import_msg = $msg.'<br/>'.$alias_msg;
195 203
 
@@ -247,7 +255,11 @@  discard block
 block discarded – undo
247 255
 				if ($type == 'aliases')
248 256
 				{
249 257
 					$data = array('alias' => $tz2id[$data['aliasTo']]);
250
-					if (!$data['alias']) continue;	// there's no such tzid
258
+					if (!$data['alias'])
259
+					{
260
+						continue;
261
+					}
262
+					// there's no such tzid
251 263
 				}
252 264
 				// check if already in database
253 265
 				$tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array(
@@ -264,7 +276,10 @@  discard block
 block discarded – undo
264 276
 				),__LINE__,__FILE__,'calendar');
265 277
 
266 278
 				// only query last insert id, if not already in database (gives warning for PostgreSQL)
267
-				if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
279
+				if (!$tz2id[$tzid])
280
+				{
281
+					$tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
282
+				}
268 283
 			}
269 284
 		}
270 285
 		config::save_value('tz_version', $tz_version, 'phpgwapi');
@@ -304,13 +319,16 @@  discard block
 block discarded – undo
304 319
 		foreach($tz_aliases as $alias => $tzid)
305 320
 		{
306 321
 			if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) &&	// not in DB or different
307
-				($tz_id = self::tz2id($tzid)))	// given tzid for alias exists in DB
322
+				($tz_id = self::tz2id($tzid)))
323
+			{
324
+				// given tzid for alias exists in DB
308 325
 			{
309 326
 				$GLOBALS['egw']->db->insert('egw_cal_timezones',array(
310 327
 					'tz_alias' => $tz_id,
311 328
 				),array(
312 329
 					'tz_tzid' => $alias,
313 330
 				),__LINE__,__FILE__,'calendar');
331
+			}
314 332
 				++$updates;
315 333
 			}
316 334
 			//error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).",  self::tz2id('$tzid')=".array2string($tz_id));
@@ -400,7 +418,10 @@  discard block
 block discarded – undo
400 418
 			$prefs = $prefs_obj->read();
401 419
 			$tzid = $prefs['common']['tz'];
402 420
 		}
403
-		if (!$tzid) $tzid = egw_time::$server_timezone->getName();
421
+		if (!$tzid)
422
+		{
423
+			$tzid = egw_time::$server_timezone->getName();
424
+		}
404 425
 
405 426
 		switch ($type)
406 427
 		{
Please login to merge, or discard this patch.
doc/fix_depricated.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * Fix depricated stuff in a given file
24 24
  *
25 25
  * @param string $file filename
26
- * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
26
+ * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created
27 27
  * @return boolean false on error
28 28
  */
29 29
 function fix_depricated($file,$replace_file=false)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
  * Loop recursive through directory and call fix_depricated for each php file
147 147
  *
148 148
  * @param string $dir
149
- * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
149
+ * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created
150 150
  * @return boolean false on error
151 151
  */
152 152
 function fix_depricated_recursive($dir,$replace_file=false)
@@ -174,7 +174,6 @@  discard block
 block discarded – undo
174 174
 /**
175 175
  * Give usage
176 176
  *
177
- * @param string $error=null
178 177
  */
179 178
 function usage($error=null)
180 179
 {
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -26,47 +26,47 @@  discard block
 block discarded – undo
26 26
  * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
27 27
  * @return boolean false on error
28 28
  */
29
-function fix_depricated($file,$replace_file=false)
29
+function fix_depricated($file, $replace_file = false)
30 30
 {
31 31
 	$orig = $lines = file_get_contents($file);
32 32
 	if ($lines === false) return false;
33 33
 	global $prog;
34
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
34
+	if (basename($file) == $prog) return true; // dont fix ourself ;-)
35 35
 
36 36
 	// PHP Deprecated:  Assigning the return value of new by reference is deprecated
37
-	if (preg_match('/= *& *new /m',$lines))
37
+	if (preg_match('/= *& *new /m', $lines))
38 38
 	{
39
-		$lines = preg_replace('/= *& *new /','= new ',$lines);
39
+		$lines = preg_replace('/= *& *new /', '= new ', $lines);
40 40
 	}
41 41
 	// PHP Deprecated:  Function split() is deprecated
42
-	if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m',$lines,$matches))
42
+	if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m', $lines, $matches))
43 43
 	{
44 44
 		$replace = array();
45 45
 		//print_r($matches);
46
-		foreach($matches[1] as $key => $pattern)
46
+		foreach ($matches[1] as $key => $pattern)
47 47
 		{
48 48
 			$full_pattern = $matches[0][$key];
49 49
 			// single char --> just explode
50
-			if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern,0,2) == '"\\')
50
+			if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern, 0, 2) == '"\\')
51 51
 			{
52
-				$replace[$full_pattern] = str_replace('split','explode',$full_pattern);
52
+				$replace[$full_pattern] = str_replace('split', 'explode', $full_pattern);
53 53
 			}
54 54
 			else
55 55
 			{
56
-				$preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0];
57
-				if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
58
-				$replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern);
56
+				$preg_pattern = $pattern[0].'/'.str_replace('/', '\\\\/', substr($pattern, 1, -1)).'/'.$pattern[0];
57
+				if (strpos($full_pattern, 'spliti')) $preg_pattern = substr($preg_pattern, 0, -1).'i'.$pattern[0];
58
+				$replace[$full_pattern] = str_replace(array('spliti', 'split', $pattern), array('preg_split', 'preg_split', $preg_pattern), $full_pattern);
59 59
 			}
60 60
 		}
61 61
 		//print_r($replace);
62
-		$lines = strtr($lines,$replace);
62
+		$lines = strtr($lines, $replace);
63 63
 	}
64 64
 	// PHP Deprecated:  Function ereg() is deprecated
65
-	if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m',$lines,$matches))
65
+	if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m', $lines, $matches))
66 66
 	{
67 67
 		$replace = array();
68 68
 		//print_r($matches);
69
-		foreach($matches[1] as $key => $pattern)
69
+		foreach ($matches[1] as $key => $pattern)
70 70
 		{
71 71
 			$full_pattern = $matches[0][$key];
72 72
 			$what = $matches[2][$key];
@@ -75,25 +75,25 @@  discard block
 block discarded – undo
75 75
 			if (preg_quote($pattern) == $pattern)
76 76
 			{
77 77
 
78
-				$replace[$full_pattern] = (strpos($full_pattern,'eregi')!==false?'strposi':'strpos').'('.$what.','.$pattern.
79
-					') '.($full_pattern[0]=='!'?'===':'!==').' false'.$matches[4][$key];
78
+				$replace[$full_pattern] = (strpos($full_pattern, 'eregi') !== false ? 'strposi' : 'strpos').'('.$what.','.$pattern.
79
+					') '.($full_pattern[0] == '!' ? '===' : '!==').' false'.$matches[4][$key];
80 80
 			}
81 81
 			else
82 82
 			{
83 83
 				// full ereg regular expression --> preg_match
84
-				$preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'");
85
-				$replace[$full_pattern] = str_replace(array('eregi','ereg',$pattern),array('preg_match','preg_match',$preg_pattern),$full_pattern);
84
+				$preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'");
85
+				$replace[$full_pattern] = str_replace(array('eregi', 'ereg', $pattern), array('preg_match', 'preg_match', $preg_pattern), $full_pattern);
86 86
 			}
87 87
 		}
88 88
 		//print_r($replace);
89
-		$lines = strtr($lines,$replace);
89
+		$lines = strtr($lines, $replace);
90 90
 	}
91 91
 	// PHP Deprecated:  Function ereg_replace() is deprecated
92
-	if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m',$lines,$matches))
92
+	if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m', $lines, $matches))
93 93
 	{
94 94
 		$replace = array();
95 95
 		//print_r($matches);
96
-		foreach($matches[1] as $key => $pattern)
96
+		foreach ($matches[1] as $key => $pattern)
97 97
 		{
98 98
 			$full_pattern = $matches[0][$key];
99 99
 			$other = $matches[2][$key];
@@ -101,41 +101,41 @@  discard block
 block discarded – undo
101 101
 			// simple replace --> use str_replace()
102 102
 			if (preg_quote($pattern) == $pattern)
103 103
 			{
104
-				$replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace'),array('stri_replace','str_replace'),$full_pattern);
104
+				$replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace'), array('stri_replace', 'str_replace'), $full_pattern);
105 105
 			}
106 106
 			else
107 107
 			{
108 108
 				// full ereg regular expression --> preg_replace
109
-				$preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'");
110
-				$replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace',$pattern),
111
-					array('preg_replace','preg_replace',$preg_pattern),$full_pattern);
109
+				$preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'");
110
+				$replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace', $pattern),
111
+					array('preg_replace', 'preg_replace', $preg_pattern), $full_pattern);
112 112
 			}
113 113
 		}
114 114
 		//print_r($replace);
115
-		$lines = strtr($lines,$replace);
115
+		$lines = strtr($lines, $replace);
116 116
 	}
117 117
 	// remove extra '/' from regular expressions
118
-	$lines = str_replace(array("'/'.'","'.'/'","'.'/i'"),array("'/","/'","/i'"),$lines);
118
+	$lines = str_replace(array("'/'.'", "'.'/'", "'.'/i'"), array("'/", "/'", "/i'"), $lines);
119 119
 
120 120
 	// fix call to not longer existing PDO method $result->fetchSingle()
121
-	$lines = str_replace('->fetchSingle(','->fetchColumn(',$lines);
121
+	$lines = str_replace('->fetchSingle(', '->fetchColumn(', $lines);
122 122
 
123 123
 	// fix calls to deprecated call_user_method(_array)?(method,object[,args])
124
-	if (preg_match('/call_user_method(_array)?\(/',$lines,$matches))
124
+	if (preg_match('/call_user_method(_array)?\(/', $lines, $matches))
125 125
 	{
126
-		$lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/','call_user_func(array(\\2,\\1)\\3',$lines);
127
-		$lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/','call_user_func_array(array(\\2,\\1)\\3',$lines);
126
+		$lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/', 'call_user_func(array(\\2,\\1)\\3', $lines);
127
+		$lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/', 'call_user_func_array(array(\\2,\\1)\\3', $lines);
128 128
 	}
129 129
 
130 130
 	if ($lines != $orig)
131 131
 	{
132
-		file_put_contents($file.'53',$lines);
133
-		system('/usr/bin/php -l '.$file.'53',$ret);
132
+		file_put_contents($file.'53', $lines);
133
+		system('/usr/bin/php -l '.$file.'53', $ret);
134 134
 		system('/usr/bin/diff -u '.$file.' '.$file.'53');
135 135
 		if (!$ret && $replace_file)
136 136
 		{
137 137
 			unlink($file);
138
-			rename($file.'53',$file);
138
+			rename($file.'53', $file);
139 139
 		}
140 140
 		return !$ret;
141 141
 	}
@@ -149,25 +149,25 @@  discard block
 block discarded – undo
149 149
  * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created
150 150
  * @return boolean false on error
151 151
  */
152
-function fix_depricated_recursive($dir,$replace_file=false)
152
+function fix_depricated_recursive($dir, $replace_file = false)
153 153
 {
154 154
 	if (!is_dir($dir)) return false;
155 155
 
156
-	foreach(scandir($dir) as $file)
156
+	foreach (scandir($dir) as $file)
157 157
 	{
158 158
 		if ($file == '.' || $file == '..') continue;
159 159
 
160 160
 		if (is_dir($dir.'/'.$file))
161 161
 		{
162
-			fix_depricated_recursive($dir.'/'.$file,$replace_file);
162
+			fix_depricated_recursive($dir.'/'.$file, $replace_file);
163 163
 		}
164
-		elseif(substr($file,-4) == '.php')
164
+		elseif (substr($file, -4) == '.php')
165 165
 		{
166
-			echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': ';
167
-			fix_depricated($dir.'/'.$file,$replace_file);
166
+			echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': ';
167
+			fix_depricated($dir.'/'.$file, $replace_file);
168 168
 		}
169 169
 	}
170
-	echo "\r".str_repeat(' ',100)."\r";
170
+	echo "\r".str_repeat(' ', 100)."\r";
171 171
 	return true;
172 172
 }
173 173
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @param string $error=null
178 178
  */
179
-function usage($error=null)
179
+function usage($error = null)
180 180
 {
181 181
 	global $prog;
182 182
 	echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n";
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
 if (!$args) usage();
191 191
 
192 192
 $replace_file = false;
193
-while(($arg = array_shift($args)))
193
+while (($arg = array_shift($args)))
194 194
 {
195
-	switch($arg)
195
+	switch ($arg)
196 196
 	{
197 197
 		case '-h':
198 198
 		case '--help':
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
 if (!is_dir($arg))
218 218
 {
219
-	fix_depricated($arg,$replace_file);
219
+	fix_depricated($arg, $replace_file);
220 220
 }
221 221
 else
222 222
 {
223
-	fix_depricated_recursive($arg,$replace_file);
223
+	fix_depricated_recursive($arg, $replace_file);
224 224
 }
225 225
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +41 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,10 +14,13 @@  discard block
 block discarded – undo
14 14
  * @version $Id$
15 15
  */
16 16
 
17
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling as web-page
17
+if (php_sapi_name() !== 'cli')
18
+{
19
+	// security precaution: forbit calling as web-page
18 20
 {
19 21
 	die('<h1>fix_depricated.php must NOT be called as web-page --> exiting !!!</h1>');
20 22
 }
23
+}
21 24
 
22 25
 /**
23 26
  * Fix depricated stuff in a given file
@@ -29,9 +32,16 @@  discard block
 block discarded – undo
29 32
 function fix_depricated($file,$replace_file=false)
30 33
 {
31 34
 	$orig = $lines = file_get_contents($file);
32
-	if ($lines === false) return false;
35
+	if ($lines === false)
36
+	{
37
+		return false;
38
+	}
33 39
 	global $prog;
34
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
40
+	if (basename($file) == $prog)
41
+	{
42
+		return true;
43
+	}
44
+	// dont fix ourself ;-)
35 45
 
36 46
 	// PHP Deprecated:  Assigning the return value of new by reference is deprecated
37 47
 	if (preg_match('/= *& *new /m',$lines))
@@ -54,7 +64,10 @@  discard block
 block discarded – undo
54 64
 			else
55 65
 			{
56 66
 				$preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0];
57
-				if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
67
+				if (strpos($full_pattern,'spliti'))
68
+				{
69
+					$preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0];
70
+				}
58 71
 				$replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern);
59 72
 			}
60 73
 		}
@@ -151,11 +164,17 @@  discard block
 block discarded – undo
151 164
  */
152 165
 function fix_depricated_recursive($dir,$replace_file=false)
153 166
 {
154
-	if (!is_dir($dir)) return false;
167
+	if (!is_dir($dir))
168
+	{
169
+		return false;
170
+	}
155 171
 
156 172
 	foreach(scandir($dir) as $file)
157 173
 	{
158
-		if ($file == '.' || $file == '..') continue;
174
+		if ($file == '.' || $file == '..')
175
+		{
176
+			continue;
177
+		}
159 178
 
160 179
 		if (is_dir($dir.'/'.$file))
161 180
 		{
@@ -180,14 +199,20 @@  discard block
 block discarded – undo
180 199
 {
181 200
 	global $prog;
182 201
 	echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n";
183
-	if ($error) echo $error."\n\n";
202
+	if ($error)
203
+	{
204
+		echo $error."\n\n";
205
+	}
184 206
 	exit($error ? 1 : 0);
185 207
 }
186 208
 
187 209
 $args = $_SERVER['argv'];
188 210
 $prog = basename(array_shift($args));
189 211
 
190
-if (!$args) usage();
212
+if (!$args)
213
+{
214
+	usage();
215
+}
191 216
 
192 217
 $replace_file = false;
193 218
 while(($arg = array_shift($args)))
@@ -204,15 +229,21 @@  discard block
 block discarded – undo
204 229
 			break;
205 230
 
206 231
 		default:
207
-			if ($args)	// not last argument
232
+			if ($args)
233
+			{
234
+				// not last argument
208 235
 			{
209 236
 				usage("Unknown argument '$arg'!");
210 237
 			}
238
+			}
211 239
 			break 2;
212 240
 	}
213 241
 }
214 242
 
215
-if (!file_exists($arg)) usage("Error: $arg not found!");
243
+if (!file_exists($arg))
244
+{
245
+	usage("Error: $arg not found!");
246
+}
216 247
 
217 248
 if (!is_dir($arg))
218 249
 {
Please login to merge, or discard this patch.
doc/rpm-build/checkout-build-archives.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -464,6 +464,7 @@  discard block
 block discarded – undo
464 464
  *
465 465
  * @param string $name
466 466
  * @param string $value =null value to use, default $config[$name]
467
+ * @return string
467 468
  */
468 469
 function config_translate($name, $value=null)
469 470
 {
@@ -1194,7 +1195,7 @@  discard block
 block discarded – undo
1194 1195
  * Runs given shell command, exists with error-code after echoing the output of the failed command (if not already running verbose)
1195 1196
  *
1196 1197
  * @param string $cmd
1197
- * @param array& $output=null $output of command, only if !$verbose !!!
1198
+ * @param array& $output $output of command, only if !$verbose !!!
1198 1199
  * @param int|array $no_bailout =null exit code(s) to NOT bail out
1199 1200
  * @return int exit code of $cmd
1200 1201
  */
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	curl_setopt($c, CURLOPT_URL, $url);
442 442
 
443 443
 	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
444
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
444
+	if ($verbose) echo "sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
445 445
 
446 446
 	if (($response = curl_exec($c)) === false)
447 447
 	{
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		if ($pattern[0] != '/' && strpos($log->msg,$pattern) !== false ||
675 675
 			$pattern[0] == '/' && preg_match($pattern,$log->msg,$matches))
676 676
 		{
677
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
677
+			if ($verbose) echo "revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
678 678
 			return (int)$log['revision'];
679 679
 		}
680 680
 	}
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			if ($content != $content_was)
756 756
 			{
757 757
 				file_put_contents($path,$content);
758
-				if ($verbose) echo "Updated $path\n";
758
+				if ($verbose) echo "updated $path\n";
759 759
 				++$n;
760 760
 			}
761 761
 		}
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	}
884 884
 	foreach($config['types'] as $type)
885 885
 	{
886
-		echo "Creating $type archives\n";
886
+		echo "creating $type archives\n";
887 887
 		$tar_type = $type == 'tar.bz2' ? 'j' : 'z';
888 888
 
889 889
 		$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 
1006 1006
 	if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#')
1007 1007
 	{
1008
-		echo "Running $cmd\n";
1008
+		echo "running $cmd\n";
1009 1009
 		run_cmd($cmd);
1010 1010
 	}
1011 1011
 	// fix permissions
Please login to merge, or discard this patch.
Braces   +232 added lines, -57 removed lines patch added patch discarded remove patch
@@ -10,10 +10,13 @@  discard block
 block discarded – undo
10 10
  * @version $Id$
11 11
  */
12 12
 
13
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
13
+if (php_sapi_name() !== 'cli')
14
+{
15
+	// security precaution: forbit calling setup-cli as web-page
14 16
 {
15 17
 	die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>');
16 18
 }
19
+}
17 20
 date_default_timezone_set('Europe/Berlin');	// to get ride of 5.3 warnings
18 21
 
19 22
 $verbose = 0;
@@ -135,7 +138,10 @@  discard block
 block discarded – undo
135 138
 			case 'release':
136 139
 			case 'copychangelog':
137 140
 				$config[$name] = $value;
138
-				if ($value) array_unshift($config['run'],$name);
141
+				if ($value)
142
+				{
143
+					array_unshift($config['run'],$name);
144
+				}
139 145
 				break;
140 146
 
141 147
 			case 'editchangelog':
@@ -151,7 +157,10 @@  discard block
 block discarded – undo
151 157
 				{
152 158
 					usage("Path '$value' not found!");
153 159
 				}
154
-				if (!in_array('obs',$config['run'])) $config['run'][] = 'obs';
160
+				if (!in_array('obs',$config['run']))
161
+				{
162
+					$config['run'][] = 'obs';
163
+				}
155 164
 				// fall through
156 165
 			default:
157 166
 				$config[$name] = $value;
@@ -209,7 +218,10 @@  discard block
 block discarded – undo
209 218
 	}
210 219
 
211 220
 	$cmd = $config['git'].' log '.escapeshellarg($last_tag.'..HEAD');
212
-	if (getcwd() != $path) $cmd = 'cd '.$path.'; '.$cmd;
221
+	if (getcwd() != $path)
222
+	{
223
+		$cmd = 'cd '.$path.'; '.$cmd;
224
+	}
213 225
 	$output = null;
214 226
 	run_cmd($cmd, $output);
215 227
 
@@ -240,7 +252,10 @@  discard block
 block discarded – undo
240 252
 {
241 253
 	global $config, $verbose;
242 254
 
243
-	if ($verbose) echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n";
255
+	if ($verbose)
256
+	{
257
+		echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n";
258
+	}
244 259
 
245 260
 	if (!is_dir($config['checkoutdir']))
246 261
 	{
@@ -271,12 +286,21 @@  discard block
 block discarded – undo
271 286
 		elseif (isset($module) && preg_match('/^checkout\s*=\s*(git\s+clone\s+(-b\s+[0-9.]+\s+)?((git|http)[^ ]+)|svn\s+checkout\s+((svn|http)[^ ]+))/', $line, $matches))
272 287
 		{
273 288
 			$repo = $url = substr($matches[1], 0, 3) == 'svn' ? $matches[5] : $matches[3];
274
-			if (substr($matches[1], 0, 3) == 'svn') $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo);
289
+			if (substr($matches[1], 0, 3) == 'svn')
290
+			{
291
+				$repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo);
292
+			}
275 293
 			$modules[$repo][$config['aliasdir'].($module ? '/'.$module : '')] = $url;
276
-			if ($module === '' && !isset($baseurl)) $baseurl = str_replace('/egroupware.git', '', $url);
294
+			if ($module === '' && !isset($baseurl))
295
+			{
296
+				$baseurl = str_replace('/egroupware.git', '', $url);
297
+			}
277 298
 		}
278 299
 	}
279
-	if ($verbose) print_r($modules);
300
+	if ($verbose)
301
+	{
302
+		print_r($modules);
303
+	}
280 304
 	return $modules;
281 305
 }
282 306
 
@@ -343,7 +367,11 @@  discard block
 block discarded – undo
343 367
 
344 368
 	$config['tag'] = config_translate('tag');	// allow to use config vars like $version in tag
345 369
 
346
-	if (empty($config['tag'])) return;	// otherwise we copy everything in svn root!
370
+	if (empty($config['tag']))
371
+	{
372
+		return;
373
+	}
374
+	// otherwise we copy everything in svn root!
347 375
 
348 376
 	echo "Creating tag $config[tag]\n";
349 377
 
@@ -359,7 +387,10 @@  discard block
 block discarded – undo
359 387
 	global $config,$verbose;
360 388
 
361 389
 	// push local changes to Github incl. tags
362
-	if ($verbose) echo "Pushing changes and tags\n";
390
+	if ($verbose)
391
+	{
392
+		echo "Pushing changes and tags\n";
393
+	}
363 394
 	chdir($config['checkoutdir']);
364 395
 	run_cmd($config['mr']. ' up');		// in case someone else pushed something
365 396
 	chdir($config['checkoutdir']);
@@ -421,7 +452,10 @@  discard block
 block discarded – undo
421 452
 	{
422 453
 		$target = config_translate('release');	// allow to use config vars like $svnbranch in module
423 454
 		$cmd = $config['rsync'].' '.$archives.' '.$target;
424
-		if ($verbose) echo $cmd."\n";
455
+		if ($verbose)
456
+		{
457
+			echo $cmd."\n";
458
+		}
425 459
 		passthru($cmd);
426 460
 	}
427 461
 }
@@ -454,25 +488,40 @@  discard block
 block discarded – undo
454 488
 	{
455 489
 		case 'POST':
456 490
 			curl_setopt($c, CURLOPT_POST, true);
457
-			if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT);
491
+			if (is_array($data))
492
+			{
493
+				$data = json_encode($data, JSON_FORCE_OBJECT);
494
+			}
458 495
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
459 496
 			break;
460 497
 		case 'GET':
461
-			if(count($data)) $url .= '?' . http_build_query($data);
498
+			if(count($data))
499
+			{
500
+				$url .= '?' . http_build_query($data);
501
+			}
462 502
 			break;
463 503
 		case 'FILE':
464 504
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
465 505
 			curl_setopt($c, CURLOPT_POST, true);
466 506
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
467
-			if(count($data)) $url .= '?' . http_build_query($data);
507
+			if(count($data))
508
+			{
509
+				$url .= '?' . http_build_query($data);
510
+			}
468 511
 			break;
469 512
 		default:
470 513
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
471 514
 	}
472 515
 	curl_setopt($c, CURLOPT_URL, $url);
473 516
 
474
-	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
475
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
517
+	if (is_string($data))
518
+	{
519
+		$short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
520
+	}
521
+	if ($verbose)
522
+	{
523
+		echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
524
+	}
476 525
 
477 526
 	if (($response = curl_exec($c)) === false)
478 527
 	{
@@ -483,7 +532,10 @@  discard block
 block discarded – undo
483 532
 		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
484 533
 	}
485 534
 
486
-	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
535
+	if ($verbose)
536
+	{
537
+		echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
538
+	}
487 539
 
488 540
 	curl_close($c);
489 541
 
@@ -500,13 +552,19 @@  discard block
 block discarded – undo
500 552
 {
501 553
 	global $config;
502 554
 
503
-	if (!isset($value)) $value = $config[$name];
555
+	if (!isset($value))
556
+	{
557
+		$value = $config[$name];
558
+	}
504 559
 	if (is_string($value) && strpos($value, '$') !== false)
505 560
 	{
506 561
 		$translate = array();
507 562
 		foreach($config as $n => $val)
508 563
 		{
509
-			if (is_string($val)) $translate['$'.$n] = $val;
564
+			if (is_string($val))
565
+			{
566
+				$translate['$'.$n] = $val;
567
+			}
510 568
 		}
511 569
 		$value = strtr($value, $translate);
512 570
 	}
@@ -608,7 +666,10 @@  discard block
 block discarded – undo
608 666
 	if (is_null($revision))
609 667
 	{
610 668
 		list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url);
611
-		if (empty($branch)) $branch = $config['version'];
669
+		if (empty($branch))
670
+		{
671
+			$branch = $config['version'];
672
+		}
612 673
 		$tags_url .= '/tags';
613 674
 		$pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|';
614 675
 		$matches = null;
@@ -634,11 +695,18 @@  discard block
 block discarded – undo
634 695
 	$message = '';
635 696
 	foreach($xml as $log)
636 697
 	{
637
-		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue;	// no match --> ignore
698
+		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix)))
699
+		{
700
+			continue;
701
+		}
702
+		// no match --> ignore
638 703
 
639 704
 		$message .= $msg."\n";
640 705
 	}
641
-	if ($verbose) echo $message;
706
+	if ($verbose)
707
+	{
708
+		echo $message;
709
+	}
642 710
 
643 711
 	return $message;
644 712
 }
@@ -669,7 +737,10 @@  discard block
 block discarded – undo
669 737
 	{
670 738
 		return null;
671 739
 	}
672
-	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg;
740
+	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix)
741
+	{
742
+		$msg = $prefix.$msg;
743
+	}
673 744
 
674 745
 	return $msg;
675 746
 }
@@ -706,7 +777,10 @@  discard block
 block discarded – undo
706 777
 		if (!$is_regexp && strpos($log->paths->path, $pattern) !== false ||
707 778
 			$is_regexp && preg_match($pattern, $log->paths->path, $matches))
708 779
 		{
709
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
780
+			if ($verbose)
781
+			{
782
+				echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
783
+			}
710 784
 			return (int)$log['revision'];
711 785
 		}
712 786
 	}
@@ -726,7 +800,10 @@  discard block
 block discarded – undo
726 800
 	{
727 801
 		usage("Path '$config[obs]' not found!");
728 802
 	}
729
-	if ($verbose) echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n";
803
+	if ($verbose)
804
+	{
805
+		echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n";
806
+	}
730 807
 	run_cmd('osc up '.$config['obs']);
731 808
 
732 809
 	$n = 0;
@@ -746,10 +823,16 @@  discard block
 block discarded – undo
746 823
 			if (basename($path) != basename($new_name))
747 824
 			{
748 825
 				unlink($path);
749
-				if ($verbose) echo "rm $path\n";
826
+				if ($verbose)
827
+				{
828
+					echo "rm $path\n";
829
+				}
750 830
 			}
751 831
 			copy($new_name,dirname($path).'/'.basename($new_name));
752
-			if ($verbose) echo "cp $new_name ".dirname($path)."/\n";
832
+			if ($verbose)
833
+			{
834
+				echo "cp $new_name ".dirname($path)."/\n";
835
+			}
753 836
 			++$n;
754 837
 		}
755 838
 		// if we have no changelog (eg. because commands run separate), try parsing it from changelog file
@@ -787,7 +870,10 @@  discard block
 block discarded – undo
787 870
 			if ($content != $content_was)
788 871
 			{
789 872
 				file_put_contents($path,$content);
790
-				if ($verbose) echo "Updated $path\n";
873
+				if ($verbose)
874
+				{
875
+					echo "Updated $path\n";
876
+				}
791 877
 				++$n;
792 878
 			}
793 879
 		}
@@ -825,9 +911,12 @@  discard block
 block discarded – undo
825 911
 			}
826 912
 			$n += empty($lines[$n+1]) ? 2 : 1;	// overead empty line behind header
827 913
 			$logentry = '';
828
-			while($lines[$n])	// entry is terminated by empty line
914
+			while($lines[$n])
915
+			{
916
+				// entry is terminated by empty line
829 917
 			{
830 918
 				$logentry .= (substr($lines[$n], 0, 2) == '  ' ? substr($lines[$n], 2) : $lines[$n])."\n";
919
+			}
831 920
 				++$n;
832 921
 			}
833 922
 			return substr($logentry, 0, -1);	// remove training "\n"
@@ -848,7 +937,10 @@  discard block
 block discarded – undo
848 937
 
849 938
 	list($header) = explode("\n", $content);
850 939
 	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
851
-	if (substr($config['changelog'],0,2) != '  ') $config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
940
+	if (substr($config['changelog'],0,2) != '  ')
941
+	{
942
+		$config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
943
+	}
852 944
 	$content = $new_header."\n\n".$config['changelog'].
853 945
 		"\n\n -- ".$config['changelog_packager'].'  '.date('r')."\n\n".$content;
854 946
 
@@ -862,10 +954,13 @@  discard block
 block discarded – undo
862 954
 {
863 955
 	global $config;
864 956
 
865
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
957
+	if (substr($config['sourcedir'],0,2) == '~/')
958
+	{
959
+		// sha1_file cant deal with '~/rpm'
866 960
 	{
867 961
 		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
868 962
 	}
963
+	}
869 964
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
870 965
 
871 966
 	if (!file_exists($sumsfile))
@@ -876,11 +971,17 @@  discard block
 block discarded – undo
876 971
 	// signing it
877 972
 	if (empty($config['gpg']) || !file_exists($config['gpg']))
878 973
 	{
879
-		if (!empty($config['gpg'])) echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n";
974
+		if (!empty($config['gpg']))
975
+		{
976
+			echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n";
977
+		}
880 978
 		return;
881 979
 	}
882 980
 	echo "Signing sha1sum file:\n";
883
-	if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc');
981
+	if (file_exists($sumsfile.'.asc'))
982
+	{
983
+		unlink($sumsfile.'.asc');
984
+	}
884 985
 	$cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile;
885 986
 	run_cmd($cmd);
886 987
 	unlink($sumsfile);	// delete the unsigned file
@@ -893,11 +994,17 @@  discard block
 block discarded – undo
893 994
 {
894 995
 	global $config;
895 996
 
896
-	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true);
897
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
997
+	if (!file_exists($config['sourcedir']))
998
+	{
999
+		mkdir($config['sourcedir'],0755,true);
1000
+	}
1001
+	if (substr($config['sourcedir'],0,2) == '~/')
1002
+	{
1003
+		// sha1_file cant deal with '~/rpm'
898 1004
 	{
899 1005
 		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
900 1006
 	}
1007
+	}
901 1008
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
902 1009
 	$sums = '';
903 1010
 
@@ -935,12 +1042,22 @@  discard block
 block discarded – undo
935 1042
 				{
936 1043
 					foreach((array)$config['all-add'] as $add)
937 1044
 					{
938
-						if (substr($add, -4) != '.tar') continue;	// probably a module
939
-						if (!($tar = realpath($add))) throw new Exception("File '$add' not found!");
1045
+						if (substr($add, -4) != '.tar')
1046
+						{
1047
+							continue;
1048
+						}
1049
+						// probably a module
1050
+						if (!($tar = realpath($add)))
1051
+						{
1052
+							throw new Exception("File '$add' not found!");
1053
+						}
940 1054
 						$cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar;
941 1055
 					}
942 1056
 				}
943
-				if (file_exists($file.'.bz2')) $cmd .= '; rm -f '.$file.'.bz2';
1057
+				if (file_exists($file.'.bz2'))
1058
+				{
1059
+					$cmd .= '; rm -f '.$file.'.bz2';
1060
+				}
944 1061
 				$cmd .= '; '.$config['bzip2'].' '.$file;
945 1062
 				// run cmd now and continue without adding all tar-ball to sums, as we dont want to publish it
946 1063
 				run_cmd($cmd);
@@ -961,7 +1078,10 @@  discard block
 block discarded – undo
961 1078
 
962 1079
 		foreach($config['extra'] as $name => $modules)
963 1080
 		{
964
-			if (is_numeric($name)) $name = $modules;
1081
+			if (is_numeric($name))
1082
+			{
1083
+				$name = $modules;
1084
+			}
965 1085
 			$dirs = ' egroupware/'.implode(' egroupware/', (array)$modules);
966 1086
 			$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
967 1087
 			switch($type)
@@ -1002,7 +1122,10 @@  discard block
 block discarded – undo
1002 1122
 	{
1003 1123
 		echo "Updating virus signatures\n";
1004 1124
 		$cmd = '/usr/bin/sudo '.$config['freshclam'];
1005
-		if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n";
1125
+		if (!$verbose && function_exists('posix_getuid') && posix_getuid())
1126
+		{
1127
+			echo $cmd."\n";
1128
+		}
1006 1129
 		$output = null;
1007 1130
 		run_cmd($cmd,$output,1);	// 1 = ignore already up to date database
1008 1131
 	}
@@ -1030,7 +1153,10 @@  discard block
 block discarded – undo
1030 1153
 	}
1031 1154
 
1032 1155
 	// we need to stash uncommited changes like .mrconfig, before copying
1033
-	if (file_exists($config['checkoutdir'].'/.git')) run_cmd("cd $config[checkoutdir]; git stash");
1156
+	if (file_exists($config['checkoutdir'].'/.git'))
1157
+	{
1158
+		run_cmd("cd $config[checkoutdir]; git stash");
1159
+	}
1034 1160
 
1035 1161
 	try {
1036 1162
 		$cmd = '/usr/bin/rsync -r --delete --delete-excluded --exclude .svn --exclude .git\* --exclude .mrconfig --exclude node_modules/ '.$config['checkoutdir'].'/ '.$config['egw_buildroot'].'/'.$config['aliasdir'].'/';
@@ -1039,8 +1165,14 @@  discard block
 block discarded – undo
1039 1165
 	catch (Exception $e) {
1040 1166
 		// catch failures to pop stash, before throwing exception
1041 1167
 	}
1042
-	if (file_exists($config['checkoutdir'].'/.git')) run_cmd("git stash pop");
1043
-	if (isset($e)) throw $e;
1168
+	if (file_exists($config['checkoutdir'].'/.git'))
1169
+	{
1170
+		run_cmd("git stash pop");
1171
+	}
1172
+	if (isset($e))
1173
+	{
1174
+		throw $e;
1175
+	}
1044 1176
 
1045 1177
 	if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#')
1046 1178
 	{
@@ -1125,9 +1257,12 @@  discard block
 block discarded – undo
1125 1257
 				if ($ret || substr($line,0,5) == 'URL: ')
1126 1258
 				{
1127 1259
 					$url = substr($line,5);
1128
-					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1260
+					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)
1261
+					{
1262
+						// wrong branch (or no svn dir)
1129 1263
 					{
1130 1264
 						echo "Checkout is of wrong branch --> deleting it\n";
1265
+					}
1131 1266
 						system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout
1132 1267
 						clearstatcache();
1133 1268
 					}
@@ -1174,19 +1309,31 @@  discard block
 block discarded – undo
1174 1309
 	$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
1175 1310
 	$url = $svnbranch.'/'.$config['svnalias'];
1176 1311
 	$cmd = $svn.' propget svn:externals --strict '.$url;
1177
-	if ($verbose) echo $cmd."\n";
1312
+	if ($verbose)
1313
+	{
1314
+		echo $cmd."\n";
1315
+	}
1178 1316
 	$output = $ret = null;
1179 1317
 	exec($cmd,$output,$ret);
1180 1318
 	$config['modules'] = array();
1181 1319
 	foreach($output as $line)
1182 1320
 	{
1183 1321
 		$line = trim($line);
1184
-		if (empty($line) || $line[0] == '#') continue;
1322
+		if (empty($line) || $line[0] == '#')
1323
+		{
1324
+			continue;
1325
+		}
1185 1326
 		list($path,$url) = preg_split('/[ \t\r\n]+/',$line);
1186 1327
 		$matches = null;
1187
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1328
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches))
1329
+		{
1330
+			die("Invalid SVN URL: $url\n");
1331
+		}
1188 1332
 		$repo = $matches[1];
1189
-		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1333
+		if ($repo == 'http://svn.egroupware.org/egroupware')
1334
+		{
1335
+			$repo = 'svn+ssh://[email protected]/egroupware';
1336
+		}
1190 1337
 		$config['modules'][$repo][$path] = $url;
1191 1338
 	}
1192 1339
 	// process extra modules
@@ -1195,13 +1342,25 @@  discard block
 block discarded – undo
1195 1342
 		$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1196 1343
 		$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1197 1344
 		$url .= $module;
1198
-		if (strpos($module,'://') !== false) $module = basename($module);
1199
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1345
+		if (strpos($module,'://') !== false)
1346
+		{
1347
+			$module = basename($module);
1348
+		}
1349
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches))
1350
+		{
1351
+			die("Invalid SVN URL: $url\n");
1352
+		}
1200 1353
 		$repo = $matches[1];
1201
-		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1354
+		if ($repo == 'http://svn.egroupware.org/egroupware')
1355
+		{
1356
+			$repo = 'svn+ssh://[email protected]/egroupware';
1357
+		}
1202 1358
 		$config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url;
1203 1359
 	}
1204
-	if ($verbose) print_r($config['modules']);
1360
+	if ($verbose)
1361
+	{
1362
+		print_r($config['modules']);
1363
+	}
1205 1364
 	return $config['modules'];
1206 1365
 }
1207 1366
 
@@ -1212,7 +1371,11 @@  discard block
 block discarded – undo
1212 1371
 {
1213 1372
 	global $config,$svn;
1214 1373
 
1215
-	if (empty($config['svntag'])) return;	// otherwise we copy everything in svn root!
1374
+	if (empty($config['svntag']))
1375
+	{
1376
+		return;
1377
+	}
1378
+	// otherwise we copy everything in svn root!
1216 1379
 
1217 1380
 	$config['svntag'] = config_translate('svntag');	// allow to use config vars like $version in tag
1218 1381
 
@@ -1251,11 +1414,17 @@  discard block
 block discarded – undo
1251 1414
 	{
1252 1415
 		$output[] = $cmd;
1253 1416
 		exec($cmd,$output,$ret);
1254
-		if ($verbose) echo implode("\n",$output)."\n";
1417
+		if ($verbose)
1418
+		{
1419
+			echo implode("\n",$output)."\n";
1420
+		}
1255 1421
 	}
1256 1422
 	if ($ret && !in_array($ret,(array)$no_bailout))
1257 1423
 	{
1258
-		if (!$verbose) echo implode("\n",$output)."\n";
1424
+		if (!$verbose)
1425
+		{
1426
+			echo implode("\n",$output)."\n";
1427
+		}
1259 1428
 		throw new Exception("Error during '$cmd' --> aborting",$ret);
1260 1429
 	}
1261 1430
 	return $ret;
@@ -1301,7 +1470,10 @@  discard block
 block discarded – undo
1301 1470
 	echo "options and their defaults:\n";
1302 1471
 	if ($verbose)
1303 1472
 	{
1304
-		if (!isset($config['modules'])) $config['modules'] = get_modules_per_repo();
1473
+		if (!isset($config['modules']))
1474
+		{
1475
+			$config['modules'] = get_modules_per_repo();
1476
+		}
1305 1477
 	}
1306 1478
 	else
1307 1479
 	{
@@ -1309,7 +1481,10 @@  discard block
 block discarded – undo
1309 1481
 	}
1310 1482
 	foreach($config as $name => $default)
1311 1483
 	{
1312
-		if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES);
1484
+		if (is_array($default))
1485
+		{
1486
+			$default = json_encode ($default, JSON_UNESCAPED_SLASHES);
1487
+		}
1313 1488
 		echo '--'.str_pad($name,20).$default."\n";
1314 1489
 	}
1315 1490
 	if ($error)
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 {
15 15
 	die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>');
16 16
 }
17
-date_default_timezone_set('Europe/Berlin');	// to get ride of 5.3 warnings
17
+date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings
18 18
 
19 19
 $verbose = 0;
20 20
 $config = array(
21 21
 	'packagename' => 'egroupware-epl',
22
-	'version' => '14.3',        // '14.3'
22
+	'version' => '14.3', // '14.3'
23 23
 	'packaging' => date('Ymd'), // '20160520'
24
-	'branch'  => '14.2',        // checked out branch
25
-	'tag' => '$version.$packaging',	// name of tag
24
+	'branch'  => '14.2', // checked out branch
25
+	'tag' => '$version.$packaging', // name of tag
26 26
 	'checkoutdir' => realpath(__DIR__.'/../..'),
27 27
 	'egw_buildroot' => '/tmp/build_root/epl_14.2_buildroot',
28 28
 	'sourcedir' => '/home/download/stylite-epl/egroupware-epl-14.2',
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 	'svnalias' => 'aliases/default-ssh',    // default alias
35 35
 	'extra' => array('$stylitebase/$svnbranch/stylite', '$stylitebase/$svnbranch/esyncpro', '$stylitebase/trunk/archive'),//, '$stylitebase/$svnbranch/groups'), //,'svn+ssh://[email protected]/stylite/trunk/eventmgr'),
36 36
 	*/
37
-	'extra' => array('stylite', 'esyncpro', 'archive'),	// create an extra archive for given apps
37
+	'extra' => array('stylite', 'esyncpro', 'archive'), // create an extra archive for given apps
38 38
 		// these apps are placed in egroupware-epl-contrib archive
39 39
 		//'contrib' => array('phpgwapi', 'etemplate', 'jdots', 'phpbrain', 'wiki', 'sambaadmin', 'sitemgr', 'phpfreechat')),
40
-	'aliasdir' => 'egroupware',             // directory created by the alias
41
-	'types' => array('tar.bz2','tar.gz','zip','all.tar.bz2'),
40
+	'aliasdir' => 'egroupware', // directory created by the alias
41
+	'types' => array('tar.bz2', 'tar.gz', 'zip', 'all.tar.bz2'),
42 42
 	// add given extra-apps or (uncompressed!) archives to above all.tar.bz2 archive
43 43
 	'all-add' => array(/*'contrib',*/ '/home/stylite/epl-trunk/phpfreechat_data_public.tar'),
44 44
 	// diverse binaries we need
@@ -55,35 +55,35 @@  discard block
 block discarded – undo
55 55
 	'gpg' => trim(`which gpg`),
56 56
 	'editor' => trim(`which vi`),
57 57
 	'rsync' => trim(`which rsync`).' --progress -e ssh --exclude "*-stylite-*" --exclude "*-esyncpro-*"',
58
-	'composer' => ($composer=trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '',
58
+	'composer' => ($composer = trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs' : '',
59 59
 	'after-checkout' => 'rm -rf */source */templates/*/source',
60 60
 	'packager' => '[email protected]',
61 61
 	'obs' => '/home/stylite/obs/stylite-epl',
62
-	'obs_package_alias' => '',	// name used in obs package, if different from packagename
63
-	'changelog' => false,   // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
62
+	'obs_package_alias' => '', // name used in obs package, if different from packagename
63
+	'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
64 64
 	'changelog_packager' => 'Ralf Becker <[email protected]>',
65 65
 	'editchangelog' => '* ',
66 66
 	//'sfuser' => 'ralfbecker',
67 67
 	//'release' => '$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/eGroupware-$version/eGroupware-$version.$packaging/',
68 68
 	'copychangelog' => '$sourcedir/README', //'$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/README',
69 69
 	'skip' => array(),
70
-	'run' => array('checkout','editchangelog','tag','copy','virusscan','create','sign','obs','copychangelog'),
70
+	'run' => array('checkout', 'editchangelog', 'tag', 'copy', 'virusscan', 'create', 'sign', 'obs', 'copychangelog'),
71 71
 	'patchCmd' => '# run cmd after copy eg. "cd $egw_buildroot; patch -p1 /path/to/patch"',
72
-	'github_user' => 'ralfbecker',	// Github user for following token
73
-	'github_token' => '',	// Github repo personal access token from above user
72
+	'github_user' => 'ralfbecker', // Github user for following token
73
+	'github_token' => '', // Github repo personal access token from above user
74 74
 );
75 75
 
76 76
 // process config from command line
77 77
 $argv = $_SERVER['argv'];
78 78
 $prog = array_shift($argv);
79 79
 
80
-while(($arg = array_shift($argv)))
80
+while (($arg = array_shift($argv)))
81 81
 {
82 82
 	if ($arg == '-v' || $arg == '--verbose')
83 83
 	{
84 84
 		++$verbose;
85 85
 	}
86
-	elseif($arg == '-h' || $arg == '--help')
86
+	elseif ($arg == '-h' || $arg == '--help')
87 87
 	{
88 88
 		if (in_array('editchangelog', $config['skip']) || !in_array('editchangelog', $config['run']))
89 89
 		{
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 		}
92 92
 		usage();
93 93
 	}
94
-	elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)]))
94
+	elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)]))
95 95
 	{
96 96
 		$value = array_shift($argv);
97
-		switch($name)
97
+		switch ($name)
98 98
 		{
99 99
 			case 'extra':	// stored as array and allow to add/delete items with +/- prefix
100 100
 			case 'types':
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 				{
118 118
 					$value = array_unique(preg_split('/[ ,]+/', $value));
119 119
 				}
120
-				switch($op)
120
+				switch ($op)
121 121
 				{
122 122
 					case '+':
123 123
 						$config[$name] = array_unique(array_merge($config[$name], $value));
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 			case 'release':
136 136
 			case 'copychangelog':
137 137
 				$config[$name] = $value;
138
-				if ($value) array_unshift($config['run'],$name);
138
+				if ($value) array_unshift($config['run'], $name);
139 139
 				break;
140 140
 
141 141
 			case 'editchangelog':
142 142
 				$config[$name] = $value ? $value : true;
143
-				if (!in_array('editchangelog',$config['run']))
143
+				if (!in_array('editchangelog', $config['run']))
144 144
 				{
145
-					array_unshift($config['run'],'editchangelog');
145
+					array_unshift($config['run'], 'editchangelog');
146 146
 				}
147 147
 				break;
148 148
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 				{
152 152
 					usage("Path '$value' not found!");
153 153
 				}
154
-				if (!in_array('obs',$config['run'])) $config['run'][] = 'obs';
154
+				if (!in_array('obs', $config['run'])) $config['run'][] = 'obs';
155 155
 				// fall through
156 156
 			default:
157 157
 				$config[$name] = $value;
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 }
170 170
 $svn = $config['svn'];
171 171
 
172
-$run = array_diff($config['run'],$config['skip']);
172
+$run = array_diff($config['run'], $config['skip']);
173 173
 
174 174
 // if we dont edit the changelog, set packaging from changelog
175 175
 if (!in_array('editchangelog', $run))
176 176
 {
177 177
 	parse_current_changelog(true);
178 178
 }
179
-foreach($run as $func)
179
+foreach ($run as $func)
180 180
 {
181
-	chdir(dirname(__FILE__));	// make relative filenames work, if other command changes dir
181
+	chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir
182 182
 	call_user_func('do_'.$func);
183 183
 }
184 184
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
  * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages
194 194
  * @return string with changelog
195 195
  */
196
-function get_changelog_from_git($_path, $log_pattern=null, &$last_tag=null, $prefix='* ')
196
+function get_changelog_from_git($_path, $log_pattern = null, &$last_tag = null, $prefix = '* ')
197 197
 {
198 198
 	//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
199 199
 	global $config;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	run_cmd($cmd, $output);
215 215
 
216 216
 	$changelog = '';
217
-	foreach($output as $line)
217
+	foreach ($output as $line)
218 218
 	{
219 219
 		if (substr($line, 0, 4) == "    " && ($msg = _match_log_pattern(substr($line, 4), $log_pattern, $prefix)))
220 220
 		{
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
 	{
247 247
 		throw new Exception("checkout directory '{$config['checkoutdir']} does NOT exists or is NO directory!");
248 248
 	}
249
-	if (!($mrconfig = file_get_contents($path=$config['checkoutdir'].'/.mrconfig')))
249
+	if (!($mrconfig = file_get_contents($path = $config['checkoutdir'].'/.mrconfig')))
250 250
 	{
251 251
 		throw new Exception("$path not found!");
252 252
 	}
253 253
 	$module = $baseurl = null;
254 254
 	$modules = array();
255
-	foreach(explode("\n", $mrconfig) as $line)
255
+	foreach (explode("\n", $mrconfig) as $line)
256 256
 	{
257 257
 		$matches = null;
258 258
 		if (isset($baseurl))
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$cmd = $config['git'].' clone '.(!empty($config['branch']) ? ' -b '.$config['branch'] : '').
318 318
 			' [email protected]:EGroupware/egroupware.git '.$config['checkoutdir'];
319 319
 		run_cmd($cmd);
320
-		run_cmd('mr up');	// need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!)
320
+		run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!)
321 321
 	}
322 322
 	elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir']))
323 323
 	{
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 	}
342 342
 	chdir($config['checkoutdir']);
343 343
 
344
-	$config['tag'] = config_translate('tag');	// allow to use config vars like $version in tag
344
+	$config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag
345 345
 
346
-	if (empty($config['tag'])) return;	// otherwise we copy everything in svn root!
346
+	if (empty($config['tag'])) return; // otherwise we copy everything in svn root!
347 347
 
348 348
 	echo "Creating tag $config[tag]\n";
349 349
 
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
  */
357 357
 function do_release()
358 358
 {
359
-	global $config,$verbose;
359
+	global $config, $verbose;
360 360
 
361 361
 	// push local changes to Github incl. tags
362 362
 	if ($verbose) echo "Pushing changes and tags\n";
363 363
 	chdir($config['checkoutdir']);
364
-	run_cmd($config['mr']. ' up');		// in case someone else pushed something
364
+	run_cmd($config['mr'].' up'); // in case someone else pushed something
365 365
 	chdir($config['checkoutdir']);
366
-	run_cmd($config['git'].' push');	// regular commits like changelog
366
+	run_cmd($config['git'].' push'); // regular commits like changelog
367 367
 	$tag = config_translate('tag');
368
-	run_cmd($config['mr']. ' push origin '.$tag);	// pushing tags in all apps
368
+	run_cmd($config['mr'].' push origin '.$tag); // pushing tags in all apps
369 369
 
370 370
 	if (empty($config['github_user']) || empty($config['github_token']))
371 371
 	{
@@ -382,26 +382,26 @@  discard block
 block discarded – undo
382 382
 		'body' => $config['changelog'],
383 383
 	);
384 384
 	$response = github_api("/repos/EGroupware/egroupware/releases", $data);
385
-	$upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']);	// remove {?name,label} template
385
+	$upload_url = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template
386 386
 
387 387
 	$archives = $config['sourcedir'].'/*egroupware-epl-'.$config['version'].'.'.$config['packaging'].'*';
388 388
 
389
-	foreach(glob($archives) as $path)
389
+	foreach (glob($archives) as $path)
390 390
 	{
391 391
 		$label = null;
392 392
 		if (substr($path, -4) == '.zip')
393 393
 		{
394 394
 			$content_type = 'application/zip';
395 395
 		}
396
-		elseif(substr($path, -7) == '.tar.gz')
396
+		elseif (substr($path, -7) == '.tar.gz')
397 397
 		{
398 398
 			$content_type = 'application/x-gzip';
399 399
 		}
400
-		elseif(substr($path, -8) == '.tar.bz2')
400
+		elseif (substr($path, -8) == '.tar.bz2')
401 401
 		{
402 402
 			$content_type = 'application/x-bzip2';
403 403
 		}
404
-		elseif(substr($path, -8) == '.txt.asc')
404
+		elseif (substr($path, -8) == '.txt.asc')
405 405
 		{
406 406
 			$content_type = 'text/plain';
407 407
 			$label = 'Signed hashes of downloads';
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 
420 420
 	if (!empty($config['release']))
421 421
 	{
422
-		$target = config_translate('release');	// allow to use config vars like $svnbranch in module
422
+		$target = config_translate('release'); // allow to use config vars like $svnbranch in module
423 423
 		$cmd = $config['rsync'].' '.$archives.' '.$target;
424 424
 		if ($verbose) echo $cmd."\n";
425 425
 		passthru($cmd);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
  * @throws Exception
438 438
  * @return array with response
439 439
  */
440
-function github_api($_url, $data, $method='POST', $upload=null, $content_type=null)
440
+function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null)
441 441
 {
442 442
 	global $config, $verbose;
443 443
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	curl_setopt($c, CURLOPT_TIMEOUT, 240);
451 451
 	curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
452 452
 
453
-	switch($method)
453
+	switch ($method)
454 454
 	{
455 455
 		case 'POST':
456 456
 			curl_setopt($c, CURLOPT_POST, true);
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
 			curl_setopt($c, CURLOPT_POSTFIELDS, $data);
459 459
 			break;
460 460
 		case 'GET':
461
-			if(count($data)) $url .= '?' . http_build_query($data);
461
+			if (count($data)) $url .= '?'.http_build_query($data);
462 462
 			break;
463 463
 		case 'FILE':
464 464
 			curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type"));
465 465
 			curl_setopt($c, CURLOPT_POST, true);
466 466
 			curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload));
467
-			if(count($data)) $url .= '?' . http_build_query($data);
467
+			if (count($data)) $url .= '?'.http_build_query($data);
468 468
 			break;
469 469
 		default:
470 470
 			throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!");
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	curl_setopt($c, CURLOPT_URL, $url);
473 473
 
474 474
 	if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data;
475
-	if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n";
475
+	if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n";
476 476
 
477 477
 	if (($response = curl_exec($c)) === false)
478 478
 	{
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 		curl_setopt($c, CURLOPT_HEADER, true);
481 481
 		curl_setopt($c, CURLOPT_RETURNTRANSFER, false);
482 482
 		curl_exec($c);
483
-		throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:''));
483
+		throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : ''));
484 484
 	}
485 485
 
486 486
 	if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n";
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
  * @param string $name
497 497
  * @param string $value =null value to use, default $config[$name]
498 498
  */
499
-function config_translate($name, $value=null)
499
+function config_translate($name, $value = null)
500 500
 {
501 501
 	global $config;
502 502
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	if (is_string($value) && strpos($value, '$') !== false)
505 505
 	{
506 506
 		$translate = array();
507
-		foreach($config as $n => $val)
507
+		foreach ($config as $n => $val)
508 508
 		{
509 509
 			if (is_string($val)) $translate['$'.$n] = $val;
510 510
 		}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
  */
531 531
 function do_editchangelog()
532 532
 {
533
-	global $config,$svn;
533
+	global $config, $svn;
534 534
 
535 535
 	echo "Querying changelog from Git/SVN\n";
536 536
 	if (!isset($config['modules']))
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	// query changelog per repo
541 541
 	$changelog = '';
542 542
 	$last_tag = null;
543
-	foreach($config['modules'] as $branch_url => $modules)
543
+	foreach ($config['modules'] as $branch_url => $modules)
544 544
 	{
545 545
 		$revision = null;
546 546
 		if (substr($branch_url, -4) == '.git')
@@ -553,15 +553,15 @@  discard block
 block discarded – undo
553 553
 			$changelog .= get_changelog_from_svn($branch_url, $config['editchangelog'], $revision);
554 554
 		}
555 555
 	}
556
-	$logfile = tempnam('/tmp','checkout-build-archives');
557
-	file_put_contents($logfile,$changelog);
556
+	$logfile = tempnam('/tmp', 'checkout-build-archives');
557
+	file_put_contents($logfile, $changelog);
558 558
 	$cmd = $config['editor'].' '.escapeshellarg($logfile);
559 559
 	passthru($cmd);
560 560
 	$config['changelog'] = file_get_contents($logfile);
561 561
 	// remove trailing newlines
562
-	while (substr($config['changelog'],-1) == "\n")
562
+	while (substr($config['changelog'], -1) == "\n")
563 563
 	{
564
-		$config['changelog'] = substr($config['changelog'],0,-1);
564
+		$config['changelog'] = substr($config['changelog'], 0, -1);
565 565
 	}
566 566
 	// allow user to abort, by deleting the changelog
567 567
 	if (strlen($config['changelog']) <= 2)
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 	run_cmd($cmd);
587 587
 
588 588
 	// update obs changelogs (so all changlogs are updated in case of a later error and changelog step can be skiped)
589
-	do_obs(true);	// true: only update debian.changes in obs checkouts
589
+	do_obs(true); // true: only update debian.changes in obs checkouts
590 590
 }
591 591
 
592 592
 /**
@@ -600,41 +600,41 @@  discard block
 block discarded – undo
600 600
  * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages
601 601
  * @return string with changelog
602 602
  */
603
-function get_changelog_from_svn($branch_url, $log_pattern=null, &$revision=null, $prefix='* ')
603
+function get_changelog_from_svn($branch_url, $log_pattern = null, &$revision = null, $prefix = '* ')
604 604
 {
605 605
 	//echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n";
606
-	global $config,$verbose,$svn;
606
+	global $config, $verbose, $svn;
607 607
 
608 608
 	if (is_null($revision))
609 609
 	{
610
-		list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url);
610
+		list($tags_url, $branch) = preg_split('#/(branches/|trunk)#', $branch_url);
611 611
 		if (empty($branch)) $branch = $config['version'];
612 612
 		$tags_url .= '/tags';
613
-		$pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|';
613
+		$pattern = '|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|';
614 614
 		$matches = null;
615
-		$revision = get_last_svn_tag($tags_url,$pattern,$matches);
615
+		$revision = get_last_svn_tag($tags_url, $pattern, $matches);
616 616
 		$tag = $matches[1];
617 617
 	}
618
-	elseif(!is_numeric($revision))
618
+	elseif (!is_numeric($revision))
619 619
 	{
620
-		$revision = get_last_svn_tag($tags_url,$tag=$revision);
620
+		$revision = get_last_svn_tag($tags_url, $tag = $revision);
621 621
 	}
622 622
 	$cmd = $svn.' log --xml -r '.escapeshellarg($revision.':HEAD').' '.escapeshellarg($branch_url);
623 623
 	if (($v = $verbose))
624 624
 	{
625 625
 		echo "Querying SVN for log from r$revision".($tag ? " ($tag)" : '').":\n$cmd\n";
626
-		$verbose = false;	// otherwise no $output!
626
+		$verbose = false; // otherwise no $output!
627 627
 	}
628 628
 	$output = array();
629
-	run_cmd($cmd,$output);
629
+	run_cmd($cmd, $output);
630 630
 	$verbose = $v;
631
-	array_shift($output);	// remove the command
631
+	array_shift($output); // remove the command
632 632
 
633
-	$xml = simplexml_load_string($output=implode("\n",$output));
633
+	$xml = simplexml_load_string($output = implode("\n", $output));
634 634
 	$message = '';
635
-	foreach($xml as $log)
635
+	foreach ($xml as $log)
636 636
 	{
637
-		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue;	// no match --> ignore
637
+		if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore
638 638
 
639 639
 		$message .= $msg."\n";
640 640
 	}
@@ -651,25 +651,25 @@  discard block
 block discarded – undo
651 651
  * @param string $prefix ='* '
652 652
  * @return string
653 653
  */
654
-function _match_log_pattern($msg, $log_pattern, $prefix='* ')
654
+function _match_log_pattern($msg, $log_pattern, $prefix = '* ')
655 655
 {
656 656
 	$pattern_len = strlen($log_pattern);
657 657
 	$prefix_len = strlen($prefix);
658 658
 
659 659
 	$matches = null;
660
-	if ($log_pattern[0] == '/' && preg_match($log_pattern,$msg,$matches))
660
+	if ($log_pattern[0] == '/' && preg_match($log_pattern, $msg, $matches))
661 661
 	{
662 662
 		$msg = $matches[1];
663 663
 	}
664
-	elseif($log_pattern && $log_pattern[0] != '/' && substr($msg,0,$pattern_len) == $log_pattern)
664
+	elseif ($log_pattern && $log_pattern[0] != '/' && substr($msg, 0, $pattern_len) == $log_pattern)
665 665
 	{
666
-		list($msg) = explode("\n",$msg);
666
+		list($msg) = explode("\n", $msg);
667 667
 	}
668
-	elseif($log_pattern)
668
+	elseif ($log_pattern)
669 669
 	{
670 670
 		return null;
671 671
 	}
672
-	if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg;
672
+	if ($prefix_len && substr($msg, 0, $prefix_len) != $prefix) $msg = $prefix.$msg;
673 673
 
674 674
 	return $msg;
675 675
 }
@@ -683,30 +683,30 @@  discard block
 block discarded – undo
683 683
  * @param array &$matches=null on return matches of preg_match
684 684
  * @return int revision of last svn tag matching pattern
685 685
  */
686
-function get_last_svn_tag($tags_url,$pattern,&$matches=null)
686
+function get_last_svn_tag($tags_url, $pattern, &$matches = null)
687 687
 {
688
-	global $verbose,$svn;
688
+	global $verbose, $svn;
689 689
 
690 690
 	$cmd = $svn.' log --xml --limit 40 -v '.escapeshellarg($tags_url);
691 691
 	if (($v = $verbose))
692 692
 	{
693 693
 		echo "Querying SVN for last tags\n$cmd\n";
694
-		$verbose = false;	// otherwise no $output!
694
+		$verbose = false; // otherwise no $output!
695 695
 	}
696 696
 	$output = array();
697
-	run_cmd($cmd,$output);
697
+	run_cmd($cmd, $output);
698 698
 	$verbose = $v;
699
-	array_shift($output);	// remove the command
699
+	array_shift($output); // remove the command
700 700
 
701
-	$xml = simplexml_load_string($output=implode("\n",$output));
701
+	$xml = simplexml_load_string($output = implode("\n", $output));
702 702
 	$is_regexp = $pattern[0] == substr($pattern, -1);
703
-	foreach($xml as $log)
703
+	foreach ($xml as $log)
704 704
 	{
705 705
 		//print_r($log);
706 706
 		if (!$is_regexp && strpos($log->paths->path, $pattern) !== false ||
707 707
 			$is_regexp && preg_match($pattern, $log->paths->path, $matches))
708 708
 		{
709
-			if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n";
709
+			if ($verbose) echo "Revision {$log['revision']} matches".($matches ? ': '.$matches[1] : '')."\n";
710 710
 			return (int)$log['revision'];
711 711
 		}
712 712
 	}
@@ -718,9 +718,9 @@  discard block
 block discarded – undo
718 718
  *
719 719
  * @param boolean $only_update_changelog =false true update debian.changes, but nothing else, nor commit it
720 720
  */
721
-function do_obs($only_update_changelog=false)
721
+function do_obs($only_update_changelog = false)
722 722
 {
723
-	global $config,$verbose;
723
+	global $config, $verbose;
724 724
 
725 725
 	if (!is_dir($config['obs']))
726 726
 	{
@@ -730,25 +730,25 @@  discard block
 block discarded – undo
730 730
 	run_cmd('osc up '.$config['obs']);
731 731
 
732 732
 	$n = 0;
733
-	foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
733
+	foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
734 734
 	{
735 735
 		if (basename(dirname($path)) == '.osc' ||
736 736
 			!preg_match('/\/('.preg_quote($config['packagename']).
737 737
 				($config['obs_package_alias'] ? '|'.preg_quote($config['obs_package_alias']) : '').
738
-				')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/',$path))
738
+				')[a-z-]*-('.preg_quote($config['version']).'|14.2|trunk)/', $path))
739 739
 		{
740 740
 			continue;
741 741
 		}
742 742
 		$matches = null;
743
-		if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/',$path,$matches) &&
744
-			file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
743
+		if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/', $path, $matches) &&
744
+			file_exists($new_name = $config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
745 745
 		{
746 746
 			if (basename($path) != basename($new_name))
747 747
 			{
748 748
 				unlink($path);
749 749
 				if ($verbose) echo "rm $path\n";
750 750
 			}
751
-			copy($new_name,dirname($path).'/'.basename($new_name));
751
+			copy($new_name, dirname($path).'/'.basename($new_name));
752 752
 			if ($verbose) echo "cp $new_name ".dirname($path)."/\n";
753 753
 			++$n;
754 754
 		}
@@ -758,35 +758,35 @@  discard block
 block discarded – undo
758 758
 			$config['changelog'] = parse_current_changelog();
759 759
 		}
760 760
 		// updating dsc, spec and changelog files
761
-		if (!$only_update_changelog && (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') ||
761
+		if (!$only_update_changelog && (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') ||
762 762
 			!empty($config['changelog']) && basename($path) == 'debian.changes')
763 763
 		{
764 764
 			$content = $content_was = file_get_contents($path);
765 765
 
766
-			if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec')
766
+			if (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec')
767 767
 			{
768
-				$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m','Version: '.$config['version'].'.'.$config['packaging'],$content);
768
+				$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m', 'Version: '.$config['version'].'.'.$config['packaging'], $content);
769 769
 			}
770
-			if (substr($path,-4) == '.dsc')
770
+			if (substr($path, -4) == '.dsc')
771 771
 			{
772 772
 				$content = preg_replace('/^(Debtransform-Tar: '.preg_quote($config['packagename']).'[a-z-]*)-'.
773 773
 					preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/m',
774
-					'\\1-'.$config['version'].'.'.$config['packaging'].'\\2',$content);
774
+					'\\1-'.$config['version'].'.'.$config['packaging'].'\\2', $content);
775 775
 			}
776
-			if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false)
776
+			if (basename($path) == 'debian.changes' && strpos($content, $config['version'].'.'.$config['packaging']) === false)
777 777
 			{
778 778
 				$content = update_changelog($content);
779 779
 			}
780
-			if (!empty($config['changelog']) && substr($path,-5) == '.spec' &&
781
-				($pos_changelog = strpos($content,'%changelog')) !== false)
780
+			if (!empty($config['changelog']) && substr($path, -5) == '.spec' &&
781
+				($pos_changelog = strpos($content, '%changelog')) !== false)
782 782
 			{
783 783
 				$pos_changelog += strlen("%changelog\n");
784
-				$content = substr($content,0,$pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n".
785
-					$config['changelog']."\n".substr($content,$pos_changelog);
784
+				$content = substr($content, 0, $pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n".
785
+					$config['changelog']."\n".substr($content, $pos_changelog);
786 786
 			}
787 787
 			if ($content != $content_was)
788 788
 			{
789
-				file_put_contents($path,$content);
789
+				file_put_contents($path, $content);
790 790
 				if ($verbose) echo "Updated $path\n";
791 791
 				++$n;
792 792
 			}
@@ -807,33 +807,33 @@  discard block
 block discarded – undo
807 807
  * @param boolean $set_packaging =false true: set packaging from last changelog entry
808 808
  * @return string changelog entries without header and footer lines
809 809
  */
810
-function parse_current_changelog($set_packaging=false)
810
+function parse_current_changelog($set_packaging = false)
811 811
 {
812 812
 	global $config;
813 813
 
814 814
 	$changelog = file_get_contents($config['checkoutdir'].'/doc/rpm-build/debian.changes');
815 815
 	$lines = explode("\n", $changelog, 100);
816 816
 	$matches = null;
817
-	foreach($lines as $n => $line)
817
+	foreach ($lines as $n => $line)
818 818
 	{
819
-		if (preg_match($preg='/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'.
819
+		if (preg_match($preg = '/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'.
820 820
 			($set_packaging ? '([0-9]+)' : preg_quote($config['packaging'])).'/', $line, $matches))
821 821
 		{
822 822
 			if ($set_packaging)
823 823
 			{
824 824
 				$config['packaging'] = $matches[1];
825 825
 			}
826
-			$n += empty($lines[$n+1]) ? 2 : 1;	// overead empty line behind header
826
+			$n += empty($lines[$n + 1]) ? 2 : 1; // overead empty line behind header
827 827
 			$logentry = '';
828
-			while($lines[$n])	// entry is terminated by empty line
828
+			while ($lines[$n])	// entry is terminated by empty line
829 829
 			{
830 830
 				$logentry .= (substr($lines[$n], 0, 2) == '  ' ? substr($lines[$n], 2) : $lines[$n])."\n";
831 831
 				++$n;
832 832
 			}
833
-			return substr($logentry, 0, -1);	// remove training "\n"
833
+			return substr($logentry, 0, -1); // remove training "\n"
834 834
 		}
835 835
 	}
836
-	return null;	// paragraph for current version NOT found
836
+	return null; // paragraph for current version NOT found
837 837
 }
838 838
 
839 839
 /**
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	global $config;
848 848
 
849 849
 	list($header) = explode("\n", $content);
850
-	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
851
-	if (substr($config['changelog'],0,2) != '  ') $config['changelog'] = '  '.implode("\n  ",explode("\n",$config['changelog']));
850
+	$new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/', '('.$config['version'].'.'.$config['packaging'].'\\1)', $header);
851
+	if (substr($config['changelog'], 0, 2) != '  ') $config['changelog'] = '  '.implode("\n  ", explode("\n", $config['changelog']));
852 852
 	$content = $new_header."\n\n".$config['changelog'].
853 853
 		"\n\n -- ".$config['changelog_packager'].'  '.date('r')."\n\n".$content;
854 854
 
@@ -862,9 +862,9 @@  discard block
 block discarded – undo
862 862
 {
863 863
 	global $config;
864 864
 
865
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
865
+	if (substr($config['sourcedir'], 0, 2) == '~/')	// sha1_file cant deal with '~/rpm'
866 866
 	{
867
-		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
867
+		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1);
868 868
 	}
869 869
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
870 870
 
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc');
884 884
 	$cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile;
885 885
 	run_cmd($cmd);
886
-	unlink($sumsfile);	// delete the unsigned file
886
+	unlink($sumsfile); // delete the unsigned file
887 887
 }
888 888
 
889 889
 /**
@@ -893,22 +893,22 @@  discard block
 block discarded – undo
893 893
 {
894 894
 	global $config;
895 895
 
896
-	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true);
897
-	if (substr($config['sourcedir'],0,2) == '~/')	// sha1_file cant deal with '~/rpm'
896
+	if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'], 0755, true);
897
+	if (substr($config['sourcedir'], 0, 2) == '~/')	// sha1_file cant deal with '~/rpm'
898 898
 	{
899
-		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1);
899
+		$config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1);
900 900
 	}
901 901
 	$sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt';
902 902
 	$sums = '';
903 903
 
904 904
 	chdir($config['egw_buildroot']);
905 905
 
906
-	if($config['extra'])
906
+	if ($config['extra'])
907 907
 	{
908 908
 		$exclude = $exclude_all = array();
909
-		foreach($config['extra'] as $name => $modules)
909
+		foreach ($config['extra'] as $name => $modules)
910 910
 		{
911
-			foreach((array)$modules as $module)
911
+			foreach ((array)$modules as $module)
912 912
 			{
913 913
 				$exclude[] = basename($module);
914 914
 				if (!empty($config['all-add']) && !in_array($module, $config['all-add']) && (is_int($name) || !in_array($name, $config['all-add'])))
@@ -918,24 +918,24 @@  discard block
 block discarded – undo
918 918
 			}
919 919
 		}
920 920
 		$exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude);
921
-		$exclude_all_extra =  $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : '';
921
+		$exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : '';
922 922
 	}
923
-	foreach($config['types'] as $type)
923
+	foreach ($config['types'] as $type)
924 924
 	{
925 925
 		echo "Creating $type archives\n";
926 926
 		$tar_type = $type == 'tar.bz2' ? 'j' : 'z';
927 927
 
928 928
 		$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
929
-		switch($type)
929
+		switch ($type)
930 930
 		{
931 931
 			case 'all.tar.bz2':	// single tar-ball for debian builds not easily supporting to use multiple
932 932
 				$file = $config['sourcedir'].'/'.$config['packagename'].'-all-'.$config['version'].'.'.$config['packaging'].'.tar';
933 933
 				$cmd = $config['tar'].' --owner=root --group=root -cf '.$file.$exclude_all_extra.' egroupware';
934 934
 				if (!empty($config['all-add']))
935 935
 				{
936
-					foreach((array)$config['all-add'] as $add)
936
+					foreach ((array)$config['all-add'] as $add)
937 937
 					{
938
-						if (substr($add, -4) != '.tar') continue;	// probably a module
938
+						if (substr($add, -4) != '.tar') continue; // probably a module
939 939
 						if (!($tar = realpath($add))) throw new Exception("File '$add' not found!");
940 940
 						$cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar;
941 941
 					}
@@ -959,15 +959,15 @@  discard block
 block discarded – undo
959 959
 		run_cmd($cmd);
960 960
 		$sums .= sha1_file($file)."\t".basename($file)."\n";
961 961
 
962
-		foreach($config['extra'] as $name => $modules)
962
+		foreach ($config['extra'] as $name => $modules)
963 963
 		{
964 964
 			if (is_numeric($name)) $name = $modules;
965 965
 			$dirs = ' egroupware/'.implode(' egroupware/', (array)$modules);
966 966
 			$file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type;
967
-			switch($type)
967
+			switch ($type)
968 968
 			{
969 969
 				case 'all.tar.bz2':
970
-					break;	// nothing to do
970
+					break; // nothing to do
971 971
 				case 'tar.bz2':
972 972
 				case 'tar.gz':
973 973
 					$cmd = $config['tar'].' --owner=root --group=root -c'.$tar_type.'f '.$file.$dirs;
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		}
983 983
 	}
984 984
 	// writing sha1sum file
985
-	file_put_contents($sumsfile,$sums);
985
+	file_put_contents($sumsfile, $sums);
986 986
 }
987 987
 
988 988
 /**
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
  */
991 991
 function do_virusscan()
992 992
 {
993
-	global $config,$verbose;
993
+	global $config, $verbose;
994 994
 
995 995
 	if (!file_exists($config['clamscan']) || !is_executable($config['clamscan']))
996 996
 	{
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 		$cmd = '/usr/bin/sudo '.$config['freshclam'];
1005 1005
 		if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n";
1006 1006
 		$output = null;
1007
-		run_cmd($cmd,$output,1);	// 1 = ignore already up to date database
1007
+		run_cmd($cmd, $output, 1); // 1 = ignore already up to date database
1008 1008
 	}
1009 1009
 	echo "Starting virusscan\n";
1010 1010
 	$cmd = $config['clamscan'].' --quiet -r '.$config['egw_buildroot'];
@@ -1061,12 +1061,12 @@  discard block
 block discarded – undo
1061 1061
  */
1062 1062
 function do_svncheckout()
1063 1063
 {
1064
-	global $config,$svn;
1064
+	global $config, $svn;
1065 1065
 
1066 1066
 	echo "Starting svn checkout/update\n";
1067 1067
 	if (!file_exists($config['checkoutdir']))
1068 1068
 	{
1069
-		mkdir($config['checkoutdir'],0755,true);
1069
+		mkdir($config['checkoutdir'], 0755, true);
1070 1070
 	}
1071 1071
 	elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir']))
1072 1072
 	{
@@ -1081,17 +1081,17 @@  discard block
 block discarded – undo
1081 1081
 		{
1082 1082
 			get_modules_per_repo();
1083 1083
 		}
1084
-		$config['svntag'] = config_translate('svntag');	// in case svntag command did not run, translate tag name
1084
+		$config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name
1085 1085
 
1086 1086
 		if (file_exists($config['aliasdir']))
1087 1087
 		{
1088
-			system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout, as we dont implement switching tags
1088
+			system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags
1089 1089
 			clearstatcache();
1090 1090
 		}
1091
-		foreach($config['modules'] as $repo => $modules)
1091
+		foreach ($config['modules'] as $repo => $modules)
1092 1092
 		{
1093 1093
 			$cmd = $svn.' co ';
1094
-			foreach($modules as $path => $url)
1094
+			foreach ($modules as $path => $url)
1095 1095
 			{
1096 1096
 				if ($path == $config['aliasdir'])
1097 1097
 				{
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 					$cmd = $svn.' co ';
1102 1102
 					continue;
1103 1103
 				}
1104
-				if(file_exists($config['aliasdir']))
1104
+				if (file_exists($config['aliasdir']))
1105 1105
 				{
1106 1106
 					die("'egroupware' applications must be first one in externals!\n");
1107 1107
 				}
@@ -1119,16 +1119,16 @@  discard block
 block discarded – undo
1119 1119
 			// check if correct branch
1120 1120
 			$cmd = 'LANG=C '.$svn.' info';
1121 1121
 			$output = $ret = null;
1122
-			exec($cmd,$output,$ret);
1123
-			foreach($output as $line)
1122
+			exec($cmd, $output, $ret);
1123
+			foreach ($output as $line)
1124 1124
 			{
1125
-				if ($ret || substr($line,0,5) == 'URL: ')
1125
+				if ($ret || substr($line, 0, 5) == 'URL: ')
1126 1126
 				{
1127
-					$url = substr($line,5);
1128
-					if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1127
+					$url = substr($line, 5);
1128
+					if ($ret || substr($url, 0, strlen($svnbranch)) != $svnbranch)	// wrong branch (or no svn dir)
1129 1129
 					{
1130 1130
 						echo "Checkout is of wrong branch --> deleting it\n";
1131
-						system('/bin/rm -rf .svn '.$config['aliasdir']);	// --> remove the whole checkout
1131
+						system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout
1132 1132
 						clearstatcache();
1133 1133
 					}
1134 1134
 					break;
@@ -1140,10 +1140,10 @@  discard block
 block discarded – undo
1140 1140
 		run_cmd($cmd);
1141 1141
 
1142 1142
 		chdir($config['aliasdir']);
1143
-		foreach($config['extra'] as $module)
1143
+		foreach ($config['extra'] as $module)
1144 1144
 		{
1145
-			$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1146
-			$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1145
+			$module = config_translate(null, $module); // allow to use config vars like $svnbranch in module
1146
+			$url = strpos($module, '://') === false ? $svnbranch.'/' : '';
1147 1147
 			$url .= $module;
1148 1148
 			$cmd = $svn.' co '.$url;
1149 1149
 			run_cmd($cmd);
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
  */
1169 1169
 function get_modules_per_svn_repo()
1170 1170
 {
1171
-	global $config,$svn,$verbose;
1171
+	global $config, $svn, $verbose;
1172 1172
 
1173 1173
 	// process alias/externals
1174 1174
 	$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
@@ -1176,27 +1176,27 @@  discard block
 block discarded – undo
1176 1176
 	$cmd = $svn.' propget svn:externals --strict '.$url;
1177 1177
 	if ($verbose) echo $cmd."\n";
1178 1178
 	$output = $ret = null;
1179
-	exec($cmd,$output,$ret);
1179
+	exec($cmd, $output, $ret);
1180 1180
 	$config['modules'] = array();
1181
-	foreach($output as $line)
1181
+	foreach ($output as $line)
1182 1182
 	{
1183 1183
 		$line = trim($line);
1184 1184
 		if (empty($line) || $line[0] == '#') continue;
1185
-		list($path,$url) = preg_split('/[ \t\r\n]+/',$line);
1185
+		list($path, $url) = preg_split('/[ \t\r\n]+/', $line);
1186 1186
 		$matches = null;
1187
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1187
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n");
1188 1188
 		$repo = $matches[1];
1189 1189
 		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1190 1190
 		$config['modules'][$repo][$path] = $url;
1191 1191
 	}
1192 1192
 	// process extra modules
1193
-	foreach($config['extra'] as $module)
1193
+	foreach ($config['extra'] as $module)
1194 1194
 	{
1195
-		$module = config_translate(null, $module);	// allow to use config vars like $svnbranch in module
1196
-		$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
1195
+		$module = config_translate(null, $module); // allow to use config vars like $svnbranch in module
1196
+		$url = strpos($module, '://') === false ? $svnbranch.'/' : '';
1197 1197
 		$url .= $module;
1198
-		if (strpos($module,'://') !== false) $module = basename($module);
1199
-		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n");
1198
+		if (strpos($module, '://') !== false) $module = basename($module);
1199
+		if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n");
1200 1200
 		$repo = $matches[1];
1201 1201
 		if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware';
1202 1202
 		$config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url;
@@ -1210,11 +1210,11 @@  discard block
 block discarded – undo
1210 1210
  */
1211 1211
 function do_svntag()
1212 1212
 {
1213
-	global $config,$svn;
1213
+	global $config, $svn;
1214 1214
 
1215
-	if (empty($config['svntag'])) return;	// otherwise we copy everything in svn root!
1215
+	if (empty($config['svntag'])) return; // otherwise we copy everything in svn root!
1216 1216
 
1217
-	$config['svntag'] = config_translate('svntag');	// allow to use config vars like $version in tag
1217
+	$config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag
1218 1218
 
1219 1219
 	echo "Creating SVN tag $config[svntag]\n";
1220 1220
 	if (!isset($config['modules']))
@@ -1222,9 +1222,9 @@  discard block
 block discarded – undo
1222 1222
 		get_modules_per_repo();
1223 1223
 	}
1224 1224
 	// create tags (per repo)
1225
-	foreach($config['modules'] as $repo => $modules)
1225
+	foreach ($config['modules'] as $repo => $modules)
1226 1226
 	{
1227
-		$cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ',$modules).' '.$repo.'/'.$config['svntag'].'/';
1227
+		$cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ', $modules).' '.$repo.'/'.$config['svntag'].'/';
1228 1228
 		run_cmd($cmd);
1229 1229
 	}
1230 1230
 }
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
  * @param int|array $no_bailout =null exit code(s) to NOT bail out
1238 1238
  * @return int exit code of $cmd
1239 1239
  */
1240
-function run_cmd($cmd,array &$output=null,$no_bailout=null)
1240
+function run_cmd($cmd, array &$output = null, $no_bailout = null)
1241 1241
 {
1242 1242
 	global $verbose;
1243 1243
 
@@ -1245,18 +1245,18 @@  discard block
 block discarded – undo
1245 1245
 	{
1246 1246
 		echo $cmd."\n";
1247 1247
 		$ret = null;
1248
-		system($cmd,$ret);
1248
+		system($cmd, $ret);
1249 1249
 	}
1250 1250
 	else
1251 1251
 	{
1252 1252
 		$output[] = $cmd;
1253
-		exec($cmd,$output,$ret);
1254
-		if ($verbose) echo implode("\n",$output)."\n";
1253
+		exec($cmd, $output, $ret);
1254
+		if ($verbose) echo implode("\n", $output)."\n";
1255 1255
 	}
1256
-	if ($ret && !in_array($ret,(array)$no_bailout))
1256
+	if ($ret && !in_array($ret, (array)$no_bailout))
1257 1257
 	{
1258
-		if (!$verbose) echo implode("\n",$output)."\n";
1259
-		throw new Exception("Error during '$cmd' --> aborting",$ret);
1258
+		if (!$verbose) echo implode("\n", $output)."\n";
1259
+		throw new Exception("Error during '$cmd' --> aborting", $ret);
1260 1260
 	}
1261 1261
 	return $ret;
1262 1262
 }
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 			return 'NULL';
1284 1284
 		case 'object':
1285 1285
 		case 'array':
1286
-			return str_replace(array("\n",'    '/*,'Array'*/),'',print_r($var,true));
1286
+			return str_replace(array("\n", '    '/*,'Array'*/), '', print_r($var, true));
1287 1287
 	}
1288 1288
 	return 'UNKNOWN TYPE!';
1289 1289
 }
@@ -1293,9 +1293,9 @@  discard block
 block discarded – undo
1293 1293
  *
1294 1294
  * @param string $error =null optional error-message
1295 1295
  */
1296
-function usage($error=null)
1296
+function usage($error = null)
1297 1297
 {
1298
-	global $prog,$config,$verbose;
1298
+	global $prog, $config, $verbose;
1299 1299
 
1300 1300
 	echo "Usage: $prog [-h|--help] [-v|--verbose] [options, ...]\n\n";
1301 1301
 	echo "options and their defaults:\n";
@@ -1305,12 +1305,12 @@  discard block
 block discarded – undo
1305 1305
 	}
1306 1306
 	else
1307 1307
 	{
1308
-		unset($config['modules']);	// they give an error, because of nested array and are quite lengthy
1308
+		unset($config['modules']); // they give an error, because of nested array and are quite lengthy
1309 1309
 	}
1310
-	foreach($config as $name => $default)
1310
+	foreach ($config as $name => $default)
1311 1311
 	{
1312
-		if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES);
1313
-		echo '--'.str_pad($name,20).$default."\n";
1312
+		if (is_array($default)) $default = json_encode($default, JSON_UNESCAPED_SLASHES);
1313
+		echo '--'.str_pad($name, 20).$default."\n";
1314 1314
 	}
1315 1315
 	if ($error)
1316 1316
 	{
Please login to merge, or discard this patch.
doc/rpm-build/post_install.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
  *
486 486
  * @param string $cmd
487 487
  * @param array &$output=null $output of command
488
- * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
488
+ * @param integer $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
489 489
  * @return int exit code of $cmd
490 490
  */
491 491
 function run_cmd($cmd,array &$output=null,$no_bailout=null)
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
  * Read one Univention secret/password eg. _ucr_secret('mysql')
713 713
  *
714 714
  * @param string $name
715
- * @return string|boolean
715
+ * @return false|string
716 716
  */
717 717
 function _ucr_secret($name)
718 718
 {
Please login to merge, or discard this patch.
Spacing   +80 added lines, -83 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	'php'         => '/usr/bin/php',
19 19
 	'source_dir'  => '/usr/share/egroupware',
20 20
 	'data_dir'    => '/var/lib/egroupware',
21
-	'header'      => '$data_dir/header.inc.php',	// symlinked to source_dir by rpm
21
+	'header'      => '$data_dir/header.inc.php', // symlinked to source_dir by rpm
22 22
 	'setup-cli'   => '$source_dir/setup/setup-cli.php',
23 23
 	'domain'      => 'default',
24 24
 	'config_user' => 'admin',
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	'db_user'     => 'egroupware',
31 31
 	'db_pass'     => randomstring(),
32 32
 	'db_grant_host' => 'localhost',
33
-	'db_root'     => 'root',	// mysql root user/pw to create database
33
+	'db_root'     => 'root', // mysql root user/pw to create database
34 34
 	'db_root_pw'  => '',
35 35
 	'backup'      => '',
36 36
 	'admin_user'  => 'sysop',
37 37
 	'admin_passwd'=> randomstring(),
38 38
 	'admin_email' => '',
39
-	'lang'        => 'en',	// languages for admin user and extra lang to install
39
+	'lang'        => 'en', // languages for admin user and extra lang to install
40 40
 	'charset'     => 'utf-8',
41 41
 	'start_db'    => '/sbin/service mysqld',
42 42
 	'autostart_db' => '/sbin/chkconfig --level 345 mysqld on',
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
 	'ldap_search_filter' => '(uid=%user)',
57 57
 	'ldap_group_context' => 'ou=groups,$base',
58 58
 	'ldap_encryption_type' => '',
59
-	'sambaadmin/sambasid'=> '',	// SID for sambaadmin
59
+	'sambaadmin/sambasid'=> '', // SID for sambaadmin
60 60
 	'mailserver'    => '',
61 61
 	'smtpserver'    => 'localhost,25',
62
-	'smtp'          => '',	// see setup-cli.php --help config
62
+	'smtp'          => '', // see setup-cli.php --help config
63 63
 	'imap'          => '',
64 64
 	'sieve'         => '',
65 65
 	'folder'        => '',
66
-	'install-update-app' => '',	// install or update a single (non-default) app
67
-	'webserver_user'=> 'apache',	// required to fix permissions
66
+	'install-update-app' => '', // install or update a single (non-default) app
67
+	'webserver_user'=> 'apache', // required to fix permissions
68 68
 	'php5enmod'     => '',
69 69
 );
70 70
 
71 71
 // read language from LANG enviroment variable
72 72
 if (($lang = isset($_ENV['LANG']) ? $_ENV['LANG'] : (isset($_SERVER['LANG']) ? $_SERVER['LANG'] : null)))
73 73
 {
74
-	@list($lang,$nat) = preg_split('/[_.]/',$lang);
75
-	if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw')))
74
+	@list($lang, $nat) = preg_split('/[_.]/', $lang);
75
+	if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw')))
76 76
 	{
77 77
 		$lang .= '-'.strtolower($nat);
78 78
 	}
@@ -85,16 +85,13 @@  discard block
 block discarded – undo
85 85
  *
86 86
  * @param string $distro =null default autodetect
87 87
  */
88
-function set_distro_defaults($distro=null)
88
+function set_distro_defaults($distro = null)
89 89
 {
90 90
 	global $config;
91 91
 	if (is_null($distro))
92 92
 	{
93
-		$distro = file_exists('/etc/SuSE-release') ? 'suse' :
94
-			(file_exists('/etc/mandriva-release') ? 'mandriva' :
95
-			(file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi',
96
-				file_get_contents('/etc/lsb-release')) ? 'univention' :
97
-			(file_exists('/etc/debian_version') ? 'debian' : 'rh')));
93
+		$distro = file_exists('/etc/SuSE-release') ? 'suse' : (file_exists('/etc/mandriva-release') ? 'mandriva' : (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi',
94
+				file_get_contents('/etc/lsb-release')) ? 'univention' : (file_exists('/etc/debian_version') ? 'debian' : 'rh')));
98 95
 	}
99 96
 	switch (($config['distro'] = $distro))
100 97
 	{
@@ -162,9 +159,9 @@  discard block
 block discarded – undo
162 159
 			}
163 160
 			elseif (!file_exists('/etc/init.d/mysqld') && file_exists('/etc/init.d/mysql'))
164 161
 			{
165
-				foreach(array('start_db','autostart_db') as $name)
162
+				foreach (array('start_db', 'autostart_db') as $name)
166 163
 				{
167
-					$config[$name] = str_replace('mysqld','mysql',$config[$name]);
164
+					$config[$name] = str_replace('mysqld', 'mysql', $config[$name]);
168 165
 				}
169 166
 			}
170 167
 			break;
@@ -180,48 +177,48 @@  discard block
 block discarded – undo
180 177
 if (($config_set = isset($_ENV['EGW_POST_INSTALL']) ? $_ENV['EGW_POST_INSTALL'] : @$_SERVER['EGW_POST_INSTALL']))
181 178
 {
182 179
 	$conf = array();
183
-	$config_set = preg_split('/[ \t]+/',trim($config_set));
184
-	while($config_set)
180
+	$config_set = preg_split('/[ \t]+/', trim($config_set));
181
+	while ($config_set)
185 182
 	{
186 183
 		$val = array_shift($config_set);
187 184
 		if (($quote = $val[0]) == "'" || $quote == '"')	// arguments might be quoted with ' or "
188 185
 		{
189
-			while (substr($val,-1) != $quote)
186
+			while (substr($val, -1) != $quote)
190 187
 			{
191 188
 				if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!');
192 189
 				$val .= ' '.array_shift($config_set);
193 190
 			}
194
-			$val = substr($val,1,-1);
191
+			$val = substr($val, 1, -1);
195 192
 		}
196 193
 		$conf[] = $val;
197 194
 	}
198
-	$argv = array_merge($conf,$argv);
195
+	$argv = array_merge($conf, $argv);
199 196
 }
200 197
 
201 198
 $auth_type_given = false;
202
-while(($arg = array_shift($argv)))
199
+while (($arg = array_shift($argv)))
203 200
 {
204 201
 	if ($arg == '-v' || $arg == '--verbose')
205 202
 	{
206 203
 		$verbose = true;
207 204
 	}
208
-	elseif($arg == '-h' || $arg == '--help')
205
+	elseif ($arg == '-h' || $arg == '--help')
209 206
 	{
210 207
 		usage();
211 208
 	}
212
-	elseif($arg == '--suse')
209
+	elseif ($arg == '--suse')
213 210
 	{
214 211
 		set_distro_defaults('suse');
215 212
 	}
216
-	elseif($arg == '--distro')
213
+	elseif ($arg == '--distro')
217 214
 	{
218 215
 		set_distro_defaults(array_shift($argv));
219 216
 	}
220
-	elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)]))
217
+	elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)]))
221 218
 	{
222 219
 		$config[$name] = array_shift($argv);
223 220
 
224
-		switch($name)
221
+		switch ($name)
225 222
 		{
226 223
 			case 'auth_type':
227 224
 				$auth_type_given = true;
@@ -242,18 +239,18 @@  discard block
 block discarded – undo
242 239
 }
243 240
 
244 241
 $replace = array();
245
-foreach($config as $name => $value)
242
+foreach ($config as $name => $value)
246 243
 {
247 244
 	$replace['$'.$name] = $value;
248
-	if (strpos($value,'$') !== false)
245
+	if (strpos($value, '$') !== false)
249 246
 	{
250
-		$config[$name] = strtr($value,$replace);
247
+		$config[$name] = strtr($value, $replace);
251 248
 	}
252 249
 }
253 250
 // basic config checks
254
-foreach(array('php','source_dir','data_dir','setup-cli') as $name)
251
+foreach (array('php', 'source_dir', 'data_dir', 'setup-cli') as $name)
255 252
 {
256
-	if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!');
253
+	if (!file_exists($config[$name])) bail_out(1, $config[$name].' not found!');
257 254
 }
258 255
 
259 256
 // fix important php.ini and conf.d/*.ini settings
@@ -278,7 +275,7 @@  discard block
 block discarded – undo
278 275
 	}
279 276
 	// create database
280 277
 	$setup_db = $setup_cli.' --setup-cmd-database sub_command=create_db';
281
-	foreach(array('domain','db_type','db_host','db_port','db_name','db_user','db_pass','db_root','db_root_pw','db_grant_host') as $name)
278
+	foreach (array('domain', 'db_type', 'db_host', 'db_port', 'db_name', 'db_user', 'db_pass', 'db_root', 'db_root_pw', 'db_grant_host') as $name)
282 279
 	{
283 280
 		$setup_db .= ' '.escapeshellarg($name.'='.$config[$name]);
284 281
 	}
@@ -286,7 +283,7 @@  discard block
 block discarded – undo
286 283
 
287 284
 	// check if ldap is required and initialise it
288 285
 	// we need to specify account_repository and auth_type to --install as extra config, otherwise install happens for sql!
289
-	@list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3);
286
+	@list($config['account_repository'], $config['auth_type'], $rest) = explode(',', $config['account-auth'], 3);
290 287
 	$extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']);
291 288
 	$extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type']));
292 289
 	if (empty($rest)) unset($config['account-auth']);
@@ -297,15 +294,15 @@  discard block
 block discarded – undo
297 294
 
298 295
 		$setup_ldap = $setup_cli.' --setup-cmd-ldap sub_command='.
299 296
 			($config['account_repository'] == 'ldap' ? 'create_ldap' : 'test_ldap');
300
-		foreach(array(
301
-			'domain','ldap_suffix','ldap_host','ldap_admin','ldap_admin_pw',	// non-egw params: only used for create
302
-			'ldap_base','ldap_root_dn','ldap_root_pw','ldap_context','ldap_search_filter','ldap_group_context',	// egw params
297
+		foreach (array(
298
+			'domain', 'ldap_suffix', 'ldap_host', 'ldap_admin', 'ldap_admin_pw', // non-egw params: only used for create
299
+			'ldap_base', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_search_filter', 'ldap_group_context', // egw params
303 300
 			'ldap_encryption_type', 'sambaadmin/sambasid',
304 301
 		) as $name)
305 302
 		{
306
-			if (strpos($value=$config[$name],'$') !== false)
303
+			if (strpos($value = $config[$name], '$') !== false)
307 304
 			{
308
-				$config[$name] = $value = strtr($value,array(
305
+				$config[$name] = $value = strtr($value, array(
309 306
 					'$suffix' => $config['ldap_suffix'],
310 307
 					'$base' => $config['ldap_base'],
311 308
 					'$admin_pw' => $config['ldap_admin_pw'],
@@ -313,7 +310,7 @@  discard block
 block discarded – undo
313 310
 			}
314 311
 			$setup_ldap .= ' '.escapeshellarg($name.'='.$value);
315 312
 
316
-			if (!in_array($name,array('domain','ldap_suffix','ldap_admin','ldap_admin_pw')))
313
+			if (!in_array($name, array('domain', 'ldap_suffix', 'ldap_admin', 'ldap_admin_pw')))
317 314
 			{
318 315
 				$extra_config .= ' '.escapeshellarg($name.'='.$value);
319 316
 			}
@@ -346,7 +343,7 @@  discard block
 block discarded – undo
346 343
 	}
347 344
 	// create mailserver config (fmail requires at least minimal config given as default, otherwise fatal error)
348 345
 	$setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']);
349
-	foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name)
346
+	foreach (array('account-auth', 'smtpserver', 'smtp', 'postfix', 'mailserver', 'imap', 'cyrus', 'sieve', 'folder') as $name)
350 347
 	{
351 348
 		if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
352 349
 	}
@@ -360,7 +357,7 @@  discard block
 block discarded – undo
360 357
 	// check if webserver is started and start it (permanent) if not
361 358
 	if ($config['start_webserver'])
362 359
 	{
363
-		exec(build_cmd('start_webserver', 'status'),$dummy,$ret);
360
+		exec(build_cmd('start_webserver', 'status'), $dummy, $ret);
364 361
 		if ($ret)
365 362
 		{
366 363
 			system(build_cmd('start_webserver', 'start'));
@@ -399,7 +396,7 @@  discard block
 block discarded – undo
399 396
 	// --> existing install --> update
400 397
 
401 398
 	// get user from header and replace password, as we dont know it
402
-	$old_password = patch_header($config['header'],$config['config_user'],$config['config_passwd']);
399
+	$old_password = patch_header($config['header'], $config['config_user'], $config['config_passwd']);
403 400
 	// register a shutdown function to put old password back in any case
404 401
 	register_shutdown_function(function() use (&$config, $old_password)
405 402
 	{
@@ -408,18 +405,18 @@  discard block
 block discarded – undo
408 405
 
409 406
 	// update egroupware
410 407
 	$setup_update = $setup_cli.' --update '.escapeshellarg('all,'.$config['config_user'].','.$config['config_passwd'].',,'.$config['install-update-app']);
411
-	$ret = run_cmd($setup_update,$output,array(4,15));
408
+	$ret = run_cmd($setup_update, $output, array(4, 15));
412 409
 
413
-	switch($ret)
410
+	switch ($ret)
414 411
 	{
415 412
 		case 4:		// header needs an update
416 413
 			$header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']);
417 414
 			run_cmd($header_update);
418
-			$ret = run_cmd($setup_update,$output,15);
415
+			$ret = run_cmd($setup_update, $output, 15);
419 416
 			if ($ret != 15) break;
420 417
 			// fall through
421 418
 		case 15:	// missing configuration (eg. mailserver)
422
-			if (!$verbose) echo implode("\n",(array)$output)."\n";
419
+			if (!$verbose) echo implode("\n", (array)$output)."\n";
423 420
 			break;
424 421
 
425 422
 		case 0:
@@ -462,18 +459,18 @@  discard block
 block discarded – undo
462 459
  * @param string $password new password
463 460
  * @return string old password
464 461
  */
465
-function patch_header($filename,&$user,$password)
462
+function patch_header($filename, &$user, $password)
466 463
 {
467 464
 	$header = file_get_contents($filename);
468 465
 
469 466
 	$umatches = $pmatches = null;
470
-	if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m",$header,$umatches) ||
471
-		!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",$header,$pmatches))
467
+	if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m", $header, $umatches) ||
468
+		!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", $header, $pmatches))
472 469
 	{
473
-		bail_out(99,"$filename is no regular EGroupware header.inc.php!");
470
+		bail_out(99, "$filename is no regular EGroupware header.inc.php!");
474 471
 	}
475
-	file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
476
-		"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header));
472
+	file_put_contents($filename, preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",
473
+		"\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';", $header));
477 474
 
478 475
 	$user = $umatches[1];
479 476
 
@@ -488,7 +485,7 @@  discard block
 block discarded – undo
488 485
  * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out
489 486
  * @return int exit code of $cmd
490 487
  */
491
-function run_cmd($cmd,array &$output=null,$no_bailout=null)
488
+function run_cmd($cmd, array &$output = null, $no_bailout = null)
492 489
 {
493 490
 	global $verbose;
494 491
 
@@ -496,16 +493,16 @@  discard block
 block discarded – undo
496 493
 	{
497 494
 		echo $cmd."\n";
498 495
 		$ret = null;
499
-		system($cmd,$ret);
496
+		system($cmd, $ret);
500 497
 	}
501 498
 	else
502 499
 	{
503 500
 		$output[] = $cmd;
504
-		exec($cmd,$output,$ret);
501
+		exec($cmd, $output, $ret);
505 502
 	}
506
-	if ($ret && $no_bailout !== true && !in_array($ret,(array)$no_bailout))
503
+	if ($ret && $no_bailout !== true && !in_array($ret, (array)$no_bailout))
507 504
 	{
508
-		bail_out($ret,$verbose?null:$output);
505
+		bail_out($ret, $verbose ? null : $output);
509 506
 	}
510 507
 	return $ret;
511 508
 }
@@ -516,9 +513,9 @@  discard block
 block discarded – undo
516 513
  * @param int $ret =1
517 514
  * @param array|string $output line(s) to output before temination notice
518 515
  */
519
-function bail_out($ret=1,$output=null)
516
+function bail_out($ret = 1, $output = null)
520 517
 {
521
-	if ($output) echo implode("\n",(array)$output);
518
+	if ($output) echo implode("\n", (array)$output);
522 519
 	echo "\n\nInstallation failed --> exiting!\n\n";
523 520
 	exit($ret);
524 521
 }
@@ -529,21 +526,21 @@  discard block
 block discarded – undo
529 526
  * @param int $len =16
530 527
  * @return string
531 528
  */
532
-function randomstring($len=16)
529
+function randomstring($len = 16)
533 530
 {
534 531
 	static $usedchars = array(
535
-		'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
536
-		'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
537
-		'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
538
-		'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
539
-		'@','!','%','&','(',')','=','?',';',':','#','_','-','<',
540
-		'>','|','[',']','}',	// dont add /\,'"{ as we have problems dealing with them
532
+		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
533
+		'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
534
+		'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
535
+		'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
536
+		'@', '!', '%', '&', '(', ')', '=', '?', ';', ':', '#', '_', '-', '<',
537
+		'>', '|', '[', ']', '}', // dont add /\,'"{ as we have problems dealing with them
541 538
 	);
542 539
 
543 540
 	$str = '';
544
-	for($i=0; $i < $len; $i++)
541
+	for ($i = 0; $i < $len; $i++)
545 542
 	{
546
-		$str .= $usedchars[mt_rand(0,count($usedchars)-1)];
543
+		$str .= $usedchars[mt_rand(0, count($usedchars) - 1)];
547 544
 	}
548 545
 	return $str;
549 546
 }
@@ -553,20 +550,20 @@  discard block
 block discarded – undo
553 550
  *
554 551
  * @param string $error =null optional error-message
555 552
  */
556
-function usage($error=null)
553
+function usage($error = null)
557 554
 {
558
-	global $prog,$config;
555
+	global $prog, $config;
559 556
 
560 557
 	echo "Usage: $prog [-h|--help] [-v|--verbose] [--distro=(suse|rh|debian)] [options, ...]\n\n";
561 558
 	echo "options and their defaults:\n";
562
-	foreach($config as $name => $default)
559
+	foreach ($config as $name => $default)
563 560
 	{
564
-		if (in_array($name, array('postfix','cyrus'))) continue;	// do NOT report deprecated options
565
-		if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16)
561
+		if (in_array($name, array('postfix', 'cyrus'))) continue; // do NOT report deprecated options
562
+		if (in_array($name, array('config_passwd', 'db_pass', 'admin_passwd', 'ldap_root_pw')) && strlen($config[$name]) == 16)
566 563
 		{
567 564
 			$default = '<16 char random string>';
568 565
 		}
569
-		echo '--'.str_pad($name,20).$default."\n";
566
+		echo '--'.str_pad($name, 20).$default."\n";
570 567
 	}
571 568
 	if ($error)
572 569
 	{
@@ -616,8 +613,8 @@  discard block
 block discarded – undo
616 613
 	$config['distro'] = 'univention';
617 614
 
618 615
 	// set lang from ucr locale, as cloud-config at least never has anything but EN set in enviroment
619
-	@list($lang,$nat) = preg_split('/[_.]/', _ucr_get('locale/default'));
620
-	if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw')))
616
+	@list($lang, $nat) = preg_split('/[_.]/', _ucr_get('locale/default'));
617
+	if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw')))
621 618
 	{
622 619
 		$lang .= '-'.strtolower($nat);
623 620
 	}
@@ -642,7 +639,7 @@  discard block
 block discarded – undo
642 639
 		// ldap password hash (our default blowfish_crypt seems not to work)
643 640
 		$config['ldap_encryption_type'] = 'sha512_crypt';
644 641
 
645
-		$config['account_min_id'] = 1200;	// UCS use 11xx for internal users/groups
642
+		$config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups
646 643
 
647 644
 		$config['account-auth'] = 'univention,ldap';
648 645
 
@@ -652,7 +649,7 @@  discard block
 block discarded – undo
652 649
 		// mailserver, see setup-cli.php --help config
653 650
 		if (($mailserver = exec('/usr/bin/univention-ldapsearch -x "(univentionAppID=mailserver_*)" univentionAppInstalledOnServer|sed -n "s/univentionAppInstalledOnServer: \(.*\)/\1/p"')) &&
654 651
 			// only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' &&
655
-			($domains=_ucr_get('mail/hosteddomains')))
652
+			($domains = _ucr_get('mail/hosteddomains')))
656 653
 		{
657 654
 			if (!is_array($domains)) $domains = explode("\n", $domains);
658 655
 			$domain = array_shift($domains);
@@ -692,12 +689,12 @@  discard block
 block discarded – undo
692 689
  */
693 690
 function _ucr_get($name)
694 691
 {
695
-	static $values=null;
692
+	static $values = null;
696 693
 	if (!isset($values))
697 694
 	{
698 695
 		$output = $matches = null;
699 696
 		exec('/usr/sbin/ucr dump', $output);
700
-		foreach($output as $line)
697
+		foreach ($output as $line)
701 698
 		{
702 699
 			if (preg_match("/^([^:]+): (.*)\n?$/", $line, $matches))
703 700
 			{
@@ -773,7 +770,7 @@  discard block
 block discarded – undo
773 770
  */
774 771
 function _size_with_unit($size)
775 772
 {
776
-	switch(strtoupper(substr($size, -1)))
773
+	switch (strtoupper(substr($size, -1)))
777 774
 	{
778 775
 		case 'G':
779 776
 			$size *= 1024;
Please login to merge, or discard this patch.
Braces   +90 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,10 +9,13 @@  discard block
 block discarded – undo
9 9
  * @version $Id$
10 10
  */
11 11
 
12
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling post_install as web-page
12
+if (php_sapi_name() !== 'cli')
13
+{
14
+	// security precaution: forbit calling post_install as web-page
13 15
 {
14 16
 	die('<h1>post_install.php must NOT be called as web-page --> exiting !!!</h1>');
15 17
 }
18
+}
16 19
 $verbose = false;
17 20
 $config = array(
18 21
 	'php'         => '/usr/bin/php',
@@ -100,7 +103,10 @@  discard block
 block discarded – undo
100 103
 	{
101 104
 		case 'suse':
102 105
 			// openSUSE 12.1+ no longer uses php5
103
-			if (file_exists('/usr/bin/php5')) $config['php'] = '/usr/bin/php5';
106
+			if (file_exists('/usr/bin/php5'))
107
+			{
108
+				$config['php'] = '/usr/bin/php5';
109
+			}
104 110
 			$config['start_db'] = '/sbin/service mysql';
105 111
 			$config['autostart_db'] = '/sbin/chkconfig --level 345 mysql on';
106 112
 			$config['start_webserver'] = '/sbin/service apache2';
@@ -130,7 +136,10 @@  discard block
 block discarded – undo
130 136
 			{
131 137
 				$config['php5enmod'] = '/usr/sbin/php5enmod';
132 138
 				// Ubuntu only needs "-s ALL" and Debian gives an error, because it does not support it
133
-				if (!file_exists('/etc/php5/conf.d/')) $config['php5enmod'] .= ' -s ALL';
139
+				if (!file_exists('/etc/php5/conf.d/'))
140
+				{
141
+					$config['php5enmod'] .= ' -s ALL';
142
+				}
134 143
 				$config['php5enmod'] .= ' mcrypt';
135 144
 			}
136 145
 			$config['autostart_db'] = '/usr/sbin/update-rc.d mysql defaults';
@@ -153,9 +162,12 @@  discard block
 block discarded – undo
153 162
 			// fall through
154 163
 		case 'rh':
155 164
 			// some MySQL packages (mysql.com, MariaDB, ...) use "mysql" as service name instead of RH default "mysqld"
156
-			if (file_exists('/usr/bin/systemctl'))	// RHEL 7
165
+			if (file_exists('/usr/bin/systemctl'))
166
+			{
167
+				// RHEL 7
157 168
 			{
158 169
 				$config['start_db'] = '/usr/bin/systemctl %s mariadb';
170
+			}
159 171
 				$config['autostart_db'] = build_cmd('start_db', 'enable');
160 172
 				$config['start_webserver'] = '/usr/bin/systemctl %s httpd';
161 173
 				$config['autostart_webserver'] = build_cmd('start_webserver', 'enable');
@@ -184,11 +196,14 @@  discard block
 block discarded – undo
184 196
 	while($config_set)
185 197
 	{
186 198
 		$val = array_shift($config_set);
187
-		if (($quote = $val[0]) == "'" || $quote == '"')	// arguments might be quoted with ' or "
199
+		if (($quote = $val[0]) == "'" || $quote == '"')
200
+		{
201
+			// arguments might be quoted with ' or "
188 202
 		{
189 203
 			while (substr($val,-1) != $quote)
190 204
 			{
191 205
 				if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!');
206
+		}
192 207
 				$val .= ' '.array_shift($config_set);
193 208
 			}
194 209
 			$val = substr($val,1,-1);
@@ -253,18 +268,24 @@  discard block
 block discarded – undo
253 268
 // basic config checks
254 269
 foreach(array('php','source_dir','data_dir','setup-cli') as $name)
255 270
 {
256
-	if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!');
257
-}
271
+	if (!file_exists($config[$name]))
272
+	{
273
+		bail_out(1,$config[$name].' not found!');
274
+	}
275
+	}
258 276
 
259 277
 // fix important php.ini and conf.d/*.ini settings
260 278
 check_fix_php_apc_ini();
261 279
 
262 280
 $setup_cli = $config['php'].' -d memory_limit=256M '.$config['setup-cli'];
263 281
 
264
-if (!file_exists($config['header']) || filesize($config['header']) < 200)	// default header redirecting to setup is 147 bytes
282
+if (!file_exists($config['header']) || filesize($config['header']) < 200)
283
+{
284
+	// default header redirecting to setup is 147 bytes
265 285
 {
266 286
 	// --> new install
267 287
 	$extra_config = '';
288
+}
268 289
 
269 290
 	// check for localhost if database server is started and start it (permanent) if not
270 291
 	if ($config['db_host'] == 'localhost' && $config['start_db'])
@@ -273,7 +294,10 @@  discard block
 block discarded – undo
273 294
 		if ($ret)
274 295
 		{
275 296
 			system(build_cmd('start_db', 'start'));
276
-			if (!empty($config['autostart_db'])) system($config['autostart_db']);
297
+			if (!empty($config['autostart_db']))
298
+			{
299
+				system($config['autostart_db']);
300
+			}
277 301
 		}
278 302
 	}
279 303
 	// create database
@@ -289,7 +313,10 @@  discard block
 block discarded – undo
289 313
 	@list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3);
290 314
 	$extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']);
291 315
 	$extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type']));
292
-	if (empty($rest)) unset($config['account-auth']);
316
+	if (empty($rest))
317
+	{
318
+		unset($config['account-auth']);
319
+	}
293 320
 	if ($config['account_repository'] == 'ldap' || $config['auth_type'] == 'ldap')
294 321
 	{
295 322
 		// set account_min_id to 1100 if not specified to NOT clash with system accounts
@@ -348,7 +375,10 @@  discard block
 block discarded – undo
348 375
 	$setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']);
349 376
 	foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name)
350 377
 	{
351
-		if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
378
+		if (!empty($config[$name]))
379
+		{
380
+			$setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]);
381
+		}
352 382
 	}
353 383
 	run_cmd($setup_mailserver);
354 384
 
@@ -364,7 +394,10 @@  discard block
 block discarded – undo
364 394
 		if ($ret)
365 395
 		{
366 396
 			system(build_cmd('start_webserver', 'start'));
367
-			if (!empty($config['autostart_webserver'])) system($config['autostart_webserver']);
397
+			if (!empty($config['autostart_webserver']))
398
+			{
399
+				system($config['autostart_webserver']);
400
+			}
368 401
 		}
369 402
 		else
370 403
 		{
@@ -416,10 +449,16 @@  discard block
 block discarded – undo
416 449
 			$header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']);
417 450
 			run_cmd($header_update);
418 451
 			$ret = run_cmd($setup_update,$output,15);
419
-			if ($ret != 15) break;
452
+			if ($ret != 15)
453
+			{
454
+				break;
455
+			}
420 456
 			// fall through
421 457
 		case 15:	// missing configuration (eg. mailserver)
422
-			if (!$verbose) echo implode("\n",(array)$output)."\n";
458
+			if (!$verbose)
459
+			{
460
+				echo implode("\n",(array)$output)."\n";
461
+			}
423 462
 			break;
424 463
 
425 464
 		case 0:
@@ -447,9 +486,15 @@  discard block
 block discarded – undo
447 486
 {
448 487
 	global $config;
449 488
 
450
-	if (isset($config[$cmd])) $cmd = $config[$cmd];
489
+	if (isset($config[$cmd]))
490
+	{
491
+		$cmd = $config[$cmd];
492
+	}
451 493
 
452
-	if (strpos($cmd, '%s')) return str_replace('%s', $arg, $cmd);
494
+	if (strpos($cmd, '%s'))
495
+	{
496
+		return str_replace('%s', $arg, $cmd);
497
+	}
453 498
 
454 499
 	return $cmd.' '.$arg;
455 500
 }
@@ -518,7 +563,10 @@  discard block
 block discarded – undo
518 563
  */
519 564
 function bail_out($ret=1,$output=null)
520 565
 {
521
-	if ($output) echo implode("\n",(array)$output);
566
+	if ($output)
567
+	{
568
+		echo implode("\n",(array)$output);
569
+	}
522 570
 	echo "\n\nInstallation failed --> exiting!\n\n";
523 571
 	exit($ret);
524 572
 }
@@ -561,7 +609,11 @@  discard block
 block discarded – undo
561 609
 	echo "options and their defaults:\n";
562 610
 	foreach($config as $name => $default)
563 611
 	{
564
-		if (in_array($name, array('postfix','cyrus'))) continue;	// do NOT report deprecated options
612
+		if (in_array($name, array('postfix','cyrus')))
613
+		{
614
+			continue;
615
+		}
616
+		// do NOT report deprecated options
565 617
 		if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16)
566 618
 		{
567 619
 			$default = '<16 char random string>';
@@ -654,7 +706,10 @@  discard block
 block discarded – undo
654 706
 			// only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' &&
655 707
 			($domains=_ucr_get('mail/hosteddomains')))
656 708
 		{
657
-			if (!is_array($domains)) $domains = explode("\n", $domains);
709
+			if (!is_array($domains))
710
+			{
711
+				$domains = explode("\n", $domains);
712
+			}
658 713
 			$domain = array_shift($domains);
659 714
 			// set "use auth with session credentials",tls,"not user editable","further identities"
660 715
 			$config['smtpserver'] = "$mailserver,465,,,yes,tls,no,yes";
@@ -664,13 +719,19 @@  discard block
 block discarded – undo
664 719
 			{
665 720
 				$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Dovecot';
666 721
 				// default with sieve port to 4190, as config is only available on host mailserver app is installed
667
-				if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) $sieve_port = 4190;
722
+				if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port')))
723
+				{
724
+					$sieve_port = 4190;
725
+				}
668 726
 			}
669 727
 			else
670 728
 			{
671 729
 				$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Cyrus';
672 730
 				// default with sieve port to 4190, as config is only available on host mailserver app is installed
673
-				if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190;
731
+				if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port')))
732
+				{
733
+					$sieve_port = 4190;
734
+				}
674 735
 			}
675 736
 			// set folders so mail creates them on first login, UCS does not automatic
676 737
 			$config['folder'] = 'INBOX/Sent,INBOX/Trash,INBOX/Drafts,INBOX/Templates,INBOX/Spam';
@@ -735,7 +796,10 @@  discard block
 block discarded – undo
735 796
 		$shm_size = ini_get('apc.shm_size');
736 797
 		$shm_segments = ini_get('apc.shm_segments');
737 798
 		// ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit
738
-		if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) $shm_size .= 'M';
799
+		if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576))
800
+		{
801
+			$shm_size .= 'M';
802
+		}
739 803
 
740 804
 		$size = _size_with_unit($shm_size) * $shm_segments;
741 805
 		//echo "shm_size=$shm_size, shm_segments=$shm_segments --> $size, numeric_size=$numeric_size\n";
@@ -751,7 +815,10 @@  discard block
 block discarded – undo
751 815
 				file_exists($path = $matches[1]) && ($apc_ini = file_get_contents($path)))
752 816
 			{
753 817
 				$new_shm_size = 128 / $shm_segments;
754
-				if (!$numeric_size) $new_shm_size .= 'M';
818
+				if (!$numeric_size)
819
+				{
820
+					$new_shm_size .= 'M';
821
+				}
755 822
 				if (preg_match('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', $apc_ini))
756 823
 				{
757 824
 					file_put_contents($path, preg_replace('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', 'apc.shm_size='.$new_shm_size, $apc_ini));
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_hooks.inc.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
 	/**
92 92
 	 * Entries for filemanagers's admin menu
93 93
 	 *
94
-	 * @param string|array $location ='admin' hook name or params
94
+	 * @param string $location ='admin' hook name or params
95 95
 	 */
96 96
 	static function admin($location = 'admin')
97 97
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		);
106 106
 		if ($location == 'admin')
107 107
 		{
108
-        	display_section(self::$appname,$file);
108
+			display_section(self::$appname,$file);
109 109
 		}
110 110
 		else
111 111
 		{
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 			'yes' => lang('Yes')
129 129
 		);
130 130
 
131
-        $settings = array(
131
+		$settings = array(
132 132
 			'startfolder'	=> array(
133 133
 				'type'		=> 'input',
134 134
 				'name'		=> 'startfolder',
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 		//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
35 35
 		$config = config::read(self::$appname);
36 36
 		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
37
-		$file_prefs    = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
37
+		$file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
38 38
 		if ($location == 'sidebox_menu')
39 39
 		{
40
-			$title = $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '. lang('Menu');
40
+			$title = $GLOBALS['egw_info']['apps'][self::$appname]['title'].' '.lang('Menu');
41 41
 			$file = array();
42
-			if($GLOBALS['egw_info']['apps']['stylite'])
42
+			if ($GLOBALS['egw_info']['apps']['stylite'])
43 43
 			{
44 44
 				// add "file a file" (upload) dialog
45 45
 				$file[] = array(
46 46
 					'text' => 'File a file',
47
-					'link' => "javascript:egw_openWindowCentered2('".egw::link('/index.php',array(
47
+					'link' => "javascript:egw_openWindowCentered2('".egw::link('/index.php', array(
48 48
 							'menuaction'=>'stylite.stylite_filemanager.upload',
49
-						),false)."','_blank',550,350)",
49
+						), false)."','_blank',550,350)",
50 50
 					'app'  => 'phpgwapi',
51 51
 					'icon' => 'upload',
52 52
 				);
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 			// add selection for available views, if we have more then one
55 55
 			if (count(filemanager_ui::init_views()) > 1)
56 56
 			{
57
-				$index_url = egw::link('/index.php',array('menuaction' => 'filemanager.filemanager_ui.index'),false);
57
+				$index_url = egw::link('/index.php', array('menuaction' => 'filemanager.filemanager_ui.index'), false);
58 58
 				$file[] = array(
59
-					'text' => html::select('filemanager_view',filemanager_ui::get_view(),filemanager_ui::$views,false,
59
+					'text' => html::select('filemanager_view', filemanager_ui::get_view(), filemanager_ui::$views, false,
60 60
 						' onchange="'."egw_appWindow('filemanager').location='$index_url&view='+this.value;".
61 61
 						'" style="width: 100%;"'),
62 62
 					'no_lang' => True,
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 			}
66 66
 			if ($file_prefs['showhome'] != 'no')
67 67
 			{
68
-				$file['Your home directory'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$homepath,'ajax'=>'true'));
68
+				$file['Your home directory'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$homepath, 'ajax'=>'true'));
69 69
 			}
70 70
 			if ($file_prefs['showusers'] != 'no')
71 71
 			{
72
-				$file['Users and groups'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$basepath,'ajax'=>'true'));
72
+				$file['Users and groups'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$basepath, 'ajax'=>'true'));
73 73
 			}
74
-			if (!empty($file_prefs['showbase']) && $file_prefs['showbase']=='yes')
74
+			if (!empty($file_prefs['showbase']) && $file_prefs['showbase'] == 'yes')
75 75
 			{
76
-				$file['Basedirectory'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true'));
76
+				$file['Basedirectory'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$rootpath, 'ajax'=>'true'));
77 77
 			}
78
-			if (!empty($file_prefs['startfolder'])) $file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
79
-			for ($i=1; $i<=self::$foldercount; $i++)
78
+			if (!empty($file_prefs['startfolder'])) $file['Startfolder'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$file_prefs['startfolder'], 'ajax'=>'true'));
79
+			for ($i = 1; $i <= self::$foldercount; $i++)
80 80
 			{
81 81
 				if (!empty($file_prefs['folderlink'.$i]))
82 82
 				{
83
-					$foldername = array_pop(explode('/',$file_prefs['folderlink'.$i]));
84
-					$file[lang('Link %1: %2',$i,$foldername)]= egw::link('/index.php',array(
83
+					$foldername = array_pop(explode('/', $file_prefs['folderlink'.$i]));
84
+					$file[lang('Link %1: %2', $i, $foldername)] = egw::link('/index.php', array(
85 85
 						'menuaction' => self::$appname.'.filemanager_ui.index',
86 86
 						'path'       => $file_prefs['folderlink'.$i],
87 87
 						'nolang'     => true,
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 					));
90 90
 				}
91 91
 			}
92
-			$file['Placeholders'] = egw::link('/index.php','menuaction=filemanager.filemanager_merge.show_replacements');
93
-			$file['Shared files'] = egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true');
94
-			display_sidebox(self::$appname,$title,$file);
92
+			$file['Placeholders'] = egw::link('/index.php', 'menuaction=filemanager.filemanager_merge.show_replacements');
93
+			$file['Shared files'] = egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&ajax=true');
94
+			display_sidebox(self::$appname, $title, $file);
95 95
 		}
96 96
 		if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname);
97 97
 	}
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 		if (is_array($location)) $location = $location['location'];
107 107
 
108 108
 		$file = Array(
109
-			'Site Configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname='.self::$appname),
110
-			'Custom fields' => egw::link('/index.php','menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'),
111
-			'Check virtual filesystem' => egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'),
109
+			'Site Configuration' => egw::link('/index.php', 'menuaction=admin.uiconfig.index&appname='.self::$appname),
110
+			'Custom fields' => egw::link('/index.php', 'menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'),
111
+			'Check virtual filesystem' => egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.fsck'),
112 112
 			'VFS mounts and versioning' => egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index'),
113 113
 		);
114 114
 		if ($location == 'admin')
115 115
 		{
116
-        	display_section(self::$appname,$file);
116
+        	display_section(self::$appname, $file);
117 117
 		}
118 118
 		else
119 119
 		{
120
-			display_sidebox(self::$appname,lang('Admin'),$file);
120
+			display_sidebox(self::$appname, lang('Admin'), $file);
121 121
 		}
122 122
 	}
123 123
 
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 				'admin'		=> False,
148 148
 			),
149 149
 		);
150
-		for ($i=1; $i <= self::$foldercount; $i++)
150
+		for ($i = 1; $i <= self::$foldercount; $i++)
151 151
 		{
152
-			$settings['folderlink'.$i]	= array(
152
+			$settings['folderlink'.$i] = array(
153 153
 				'type'		=> 'input',
154 154
 				'name'		=> 'folderlink'.$i,
155 155
 				'size'		=> 60,
156 156
 				'default'	=> '',
157 157
 				'label' 	=> lang('Enter the complete VFS path to specify a fast access link to a folder').' ('.$i.').',
158
-				'run_lang'  => -1,	// -1 = no lang on label
158
+				'run_lang'  => -1, // -1 = no lang on label
159 159
 				'xmlrpc'	=> True,
160 160
 				'admin'		=> False
161 161
 			);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 				'type'		=> 'select',
177 177
 				'name'		=> 'showhome',
178 178
 				'values'	=> $yes_no,
179
-				'label' 	=> lang('Show link "%1" in side box menu?',lang('Your home directory')),
179
+				'label' 	=> lang('Show link "%1" in side box menu?', lang('Your home directory')),
180 180
 				'xmlrpc'	=> True,
181 181
 				'admin'		=> False,
182 182
 				'forced'   => 'yes',
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 				'type'		=> 'select',
186 186
 				'name'		=> 'showusers',
187 187
 				'values'	=> $yes_no,
188
-				'label' 	=> lang('Show link "%1" in side box menu?',lang('Users and groups')),
188
+				'label' 	=> lang('Show link "%1" in side box menu?', lang('Users and groups')),
189 189
 				'xmlrpc'	=> True,
190 190
 				'admin'		=> False,
191 191
 				'forced'   => 'yes',
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 			'size'   => 60,
198 198
 			'label'  => 'Default document to insert entries',
199 199
 			'name'   => 'default_document',
200
-			'help'   => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.',lang('filemanager')).' '.
200
+			'help'   => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('filemanager')).' '.
201 201
 				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '.
202
-				lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
202
+				lang('The following document-types are supported:').implode(',', bo_merge::get_file_extensions()),
203 203
 			'run_lang' => false,
204 204
 			'xmlrpc' => True,
205 205
 			'admin'  => False,
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 			'label'  => 'Directory with documents to insert entries',
211 211
 			'name'   => 'document_dir',
212 212
 			'help'   => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the %1 data inserted.', lang('filemanager')).' '.
213
-				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','name').' '.
214
-				lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
213
+				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '.
214
+				lang('The following document-types are supported:').implode(',', bo_merge::get_file_extensions()),
215 215
 			'run_lang' => false,
216 216
 			'xmlrpc' => True,
217 217
 			'admin'  => False,
Please login to merge, or discard this patch.
Braces   +20 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,10 @@  discard block
 block discarded – undo
33 33
 		$homepath = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
34 34
 		//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
35 35
 		$config = config::read(self::$appname);
36
-		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
36
+		if (!empty($config['max_folderlinks']))
37
+		{
38
+			self::$foldercount = (int)$config['max_folderlinks'];
39
+		}
37 40
 		$file_prefs    = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
38 41
 		if ($location == 'sidebox_menu')
39 42
 		{
@@ -75,7 +78,10 @@  discard block
 block discarded – undo
75 78
 			{
76 79
 				$file['Basedirectory'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true'));
77 80
 			}
78
-			if (!empty($file_prefs['startfolder'])) $file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
81
+			if (!empty($file_prefs['startfolder']))
82
+			{
83
+				$file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
84
+			}
79 85
 			for ($i=1; $i<=self::$foldercount; $i++)
80 86
 			{
81 87
 				if (!empty($file_prefs['folderlink'.$i]))
@@ -93,7 +99,10 @@  discard block
 block discarded – undo
93 99
 			$file['Shared files'] = egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true');
94 100
 			display_sidebox(self::$appname,$title,$file);
95 101
 		}
96
-		if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname);
102
+		if ($GLOBALS['egw_info']['user']['apps']['admin'])
103
+		{
104
+			self::admin(self::$appname);
105
+		}
97 106
 	}
98 107
 
99 108
 	/**
@@ -103,7 +112,10 @@  discard block
 block discarded – undo
103 112
 	 */
104 113
 	static function admin($location = 'admin')
105 114
 	{
106
-		if (is_array($location)) $location = $location['location'];
115
+		if (is_array($location))
116
+		{
117
+			$location = $location['location'];
118
+		}
107 119
 
108 120
 		$file = Array(
109 121
 			'Site Configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname='.self::$appname),
@@ -129,7 +141,10 @@  discard block
 block discarded – undo
129 141
 	static function settings()
130 142
 	{
131 143
 		$config = config::read(self::$appname);
132
-		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
144
+		if (!empty($config['max_folderlinks']))
145
+		{
146
+			self::$foldercount = (int)$config['max_folderlinks'];
147
+		}
133 148
 
134 149
 		$yes_no = array(
135 150
 			'no'  => lang('No'),
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -464,7 +464,7 @@
 block discarded – undo
464 464
 	{
465 465
 		unset($args);	// unused, but required by function signature
466 466
 		$appname = 'preferences';
467
-		$file = Array(
467
+		$file = array(
468 468
 			'Site configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'),
469 469
 		);
470 470
 		display_section($appname, $file);
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_shares.inc.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -127,8 +127,7 @@
 block discarded – undo
127 127
 	/**
128 128
 	 * Show files shared
129 129
 	 *
130
-	 * @param array $content=null
131
-	 * @param string $msg=''
130
+	 * @param array $content
132 131
 	 */
133 132
 	public function index(array $content=null)
134 133
 	{
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,10 @@
 block discarded – undo
101 101
 				$row['type'] = $row['share_writable'] ? Sharing::WRITABLE : Sharing::READONLY;
102 102
 			}
103 103
 			$row['share_passwd'] = (boolean)$row['share_passwd'];
104
-			if ($row['share_with']) $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']);
104
+			if ($row['share_with'])
105
+			{
106
+				$row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']);
107
+			}
105 108
 		}
106 109
 		return $total;
107 110
 	}
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		// sudo handling
42 42
 		parent::__construct();
43
-		self::$is_setup = egw_session::appsession('is_setup','filemanager');
43
+		self::$is_setup = egw_session::appsession('is_setup', 'filemanager');
44 44
 		self::$tmp_dir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/';
45 45
 	}
46 46
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$readonlys = null;
85 85
 		$total = egw_sharing::so()->get_rows($query, $rows, $readonlys);
86 86
 
87
-		foreach($rows as &$row)
87
+		foreach ($rows as &$row)
88 88
 		{
89 89
 			if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir)
90 90
 			{
@@ -125,21 +125,21 @@  discard block
 block discarded – undo
125 125
 	 * @param array $content=null
126 126
 	 * @param string $msg=''
127 127
 	 */
128
-	public function index(array $content=null)
128
+	public function index(array $content = null)
129 129
 	{
130 130
 		if (!is_array($content))
131 131
 		{
132 132
 			$content = array(
133 133
 				'nm' => array(
134
-					'get_rows'       =>	'filemanager.filemanager_shares.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
135
-					'no_filter'      => True,	// current dir only
136
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
137
-					'no_cat'         => True,	// I  disable the cat-selectbox
138
-					'lettersearch'   => false,	// I  show a lettersearch
139
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
140
-					'start'          =>	0,		// IO position in list
141
-					'order'          =>	'share_created',	// IO name of the column to sort after (optional for the sortheaders)
142
-					'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
134
+					'get_rows'       =>	'filemanager.filemanager_shares.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
135
+					'no_filter'      => True, // current dir only
136
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
137
+					'no_cat'         => True, // I  disable the cat-selectbox
138
+					'lettersearch'   => false, // I  show a lettersearch
139
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
140
+					'start'          =>	0, // IO position in list
141
+					'order'          =>	'share_created', // IO name of the column to sort after (optional for the sortheaders)
142
+					'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
143 143
 					//'default_cols'   => '!',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
144 144
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
145 145
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 		elseif ($content['nm']['action'])
153 153
 		{
154
-			switch($content['nm']['action'])
154
+			switch ($content['nm']['action'])
155 155
 			{
156 156
 				case 'delete':
157 157
 					$where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']);
Please login to merge, or discard this patch.