Completed
Push — 14.2 ( e07840...cec2da )
by Ralf
83:18 queued 52:04
created
importexport/inc/class.importexport_iface_egw_record.inc.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -35,6 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * reads record from backend if identifier is given.
36 36
 	 *
37 37
 	 * @param string $_identifier
38
+	 * @return void
38 39
 	 */
39 40
 	public function __construct( $_identifier='' );
40 41
 	
@@ -50,6 +51,7 @@  discard block
 block discarded – undo
50 51
 	 *
51 52
 	 * @param string $_attribute_name
52 53
 	 * @param data $data
54
+	 * @return void
53 55
 	 */
54 56
 	public function __set($_attribute_name, $data);
55 57
 	
@@ -126,6 +128,7 @@  discard block
 block discarded – undo
126 128
 	/**
127 129
 	 * destructor
128 130
 	 *
131
+	 * @return void
129 132
 	 */
130 133
 	public function __destruct();
131 134
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param string $_identifier
38 38
 	 */
39
-	public function __construct( $_identifier='' );
39
+	public function __construct($_identifier = '');
40 40
 	
41 41
 	/**
42 42
 	 * magic method to set attributes of record
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return string identifier
99 99
 	 */
100
-	public function save ( $_dst_identifier );
100
+	public function save($_dst_identifier);
101 101
 	
102 102
 	/**
103 103
 	 * copys current record to record identified by $_dst_identifier
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @param string $_dst_identifier
106 106
 	 * @return string dst_identifier
107 107
 	 */
108
-	public function copy ( $_dst_identifier );
108
+	public function copy($_dst_identifier);
109 109
 	
110 110
 	/**
111 111
 	 * moves current record to record identified by $_dst_identifier
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 	 * @param string $_dst_identifier
115 115
 	 * @return string dst_identifier
116 116
 	 */
117
-	public function move ( $_dst_identifier );
117
+	public function move($_dst_identifier);
118 118
 	
119 119
 	/**
120 120
 	 * delets current record from backend
121 121
 	 * @return void
122 122
 	 *
123 123
 	 */
124
-	public function delete ();
124
+	public function delete();
125 125
 	
126 126
 	/**
127 127
 	 * destructor
Please login to merge, or discard this patch.
importexport/inc/class.importexport_iface_import_plugin.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@
 block discarded – undo
29 29
 	/**
30 30
 	 * imports entries according to given definition object.
31 31
 	 *
32
-	 * @param stram $_stram
33
-	 * @param definition $_definition
32
+	 * @param stram $_stream
33
+	 * @param importexport_definition $_definition
34 34
 	 * @return int number of successful imports
35 35
 	 */
36 36
 	public function import( $_stream, importexport_definition $_definition );
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -88,33 +88,33 @@
 block discarded – undo
88 88
 	public function get_selectors_etpl();
89 89
 
90 90
 	/**
91
-	* Returns errors that were encountered during importing
92
-	* Maximum of one error message per record, but you can concatenate them if you need to
93
-	*
94
-	* @return Array (
95
-	*	record_# => error message
96
-	*	)
97
-	*/
91
+	 * Returns errors that were encountered during importing
92
+	 * Maximum of one error message per record, but you can concatenate them if you need to
93
+	 *
94
+	 * @return Array (
95
+	 *	record_# => error message
96
+	 *	)
97
+	 */
98 98
 	public function get_errors();
99 99
 
100 100
 	/**
101
-	* Returns warnings that were encountered during importing
102
-	* Maximum of one warning message per record, but you can concatenate them if you need to
103
-	*
104
-	* @return Array (
105
-	*	record_# => warning message
106
-	*	)
107
-	*/
101
+	 * Returns warnings that were encountered during importing
102
+	 * Maximum of one warning message per record, but you can concatenate them if you need to
103
+	 *
104
+	 * @return Array (
105
+	 *	record_# => warning message
106
+	 *	)
107
+	 */
108 108
 	public function get_warnings();
109 109
 
110 110
 	/**
111
-	* Returns a list of actions taken, and the number of records for that action.
112
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
113
-	*
114
-	* @return Array (
115
-	*	action => record count
116
-	* )
117
-	*/
111
+	 * Returns a list of actions taken, and the number of records for that action.
112
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
113
+	 *
114
+	 * @return Array (
115
+	 *	action => record count
116
+	 * )
117
+	 */
118 118
 	public function get_results();
119 119
 
120 120
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * @param definition $_definition
34 34
 	 * @return int number of successful imports
35 35
 	 */
36
-	public function import( $_stream, importexport_definition $_definition );
36
+	public function import($_stream, importexport_definition $_definition);
37 37
 
38 38
 	/**
39 39
 	 * Reads entries, and presents them back as they will be understood
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@
 block discarded – undo
24 24
  * So this interface just garanties the interaction with userinterfaces. It
25 25
  * has nothing to do with datatypes.
26 26
  */
27
-interface importexport_iface_import_plugin {
27
+interface importexport_iface_import_plugin
28
+{
28 29
 	
29 30
 	/**
30 31
 	 * imports entries according to given definition object.
Please login to merge, or discard this patch.
importexport/inc/class.importexport_iface_import_record.inc.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * cleanup
34 34
 	 *
35 35
 	 * @return 
36
-	 */
36
+	 void
37 37
 	public function __destruct( );
38 38
 
39 39
 	/**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @param array $_options options for specific backends
28 28
 	 * @return bool
29 29
 	 */
30
-	public function __construct( $_stream, array $_options );
30
+	public function __construct($_stream, array $_options);
31 31
 
32 32
 	/**
33 33
 	 * cleanup
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @param string _position may be: {first|last|next|previous|somenumber}
43 43
 	 * @return bool
44 44
 	 */
45
-	public function get_record( $_position = 'next' );
45
+	public function get_record($_position = 'next');
46 46
 
47 47
 	/**
48 48
 	 * Retruns total number of records for the open resource.
Please login to merge, or discard this patch.
importexport/inc/class.importexport_import_csv.inc.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	/**
138 138
 	 * updates $this->record
139 139
 	 *
140
-	 * @param mixed $_position
141
-	 * @return bool
140
+	 * @param string $_position
141
+	 * @return null|false
142 142
 	 */
143 143
 	private function get_raw_record( $_position = 'next' ) {
144 144
 		switch ($_position) {
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	/**
245 245
 	 * does conversions according to $this->conversion
246 246
 	 *
247
-	 * @return bool
247
+	 * @return boolean|null
248 248
 	 */
249 249
 	protected function do_conversions() {
250 250
 		if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) {
Please login to merge, or discard this patch.
Braces   +143 added lines, -61 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
  * @todo Throw away spechial chars and trim() entries ?
23 23
  * @todo Check for XSS like userinput! (see common_functions)
24 24
  */
25
-class importexport_import_csv implements importexport_iface_import_record { //, Iterator {
25
+class importexport_import_csv implements importexport_iface_import_record
26
+{
27
+//, Iterator {
26 28
 
27 29
 	const csv_max_linelength = 8000;
28 30
 	
@@ -83,10 +85,14 @@  discard block
 block discarded – undo
83 85
 	 * @param string $_resource resource containing data. May be each valid php-stream
84 86
 	 * @param array $_options options for the resource array with keys: charset and fieldsep
85 87
 	 */
86
-	public function __construct( $_resource,  array $_options ) {
88
+	public function __construct( $_resource,  array $_options )
89
+	{
87 90
 		$this->resource = $_resource;
88 91
 		$this->csv_fieldsep = $_options['fieldsep'];
89
-		if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
92
+		if($_options['charset'] == 'user')
93
+		{
94
+			$_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
95
+		}
90 96
 		$this->csv_charset = $_options['charset'];
91 97
 		return;
92 98
 	} // end of member function __construct
@@ -94,7 +100,8 @@  discard block
 block discarded – undo
94 100
 	/**
95 101
 	 * cleanup
96 102
 	 */
97
-	public function __destruct( ) {
103
+	public function __destruct( )
104
+	{
98 105
 	} // end of member function __destruct
99 106
 
100 107
 	/**
@@ -103,20 +110,27 @@  discard block
 block discarded – undo
103 110
 	 * @param mixed _position may be: {current|first|last|next|previous|somenumber}
104 111
 	 * @return mixed array with data / false if no furtor records
105 112
 	 */
106
-	public function get_record( $_position = 'next' ) {
113
+	public function get_record( $_position = 'next' )
114
+	{
107 115
 		
108
-		if ($this->get_raw_record( $_position ) === false) {
116
+		if ($this->get_raw_record( $_position ) === false)
117
+		{
109 118
 			return false;
110 119
 		}
111 120
 		
112 121
 		// skip empty records
113
-		if( count( array_unique( $this->record ) ) < 2 ) return $this->get_record( $_position );
122
+		if( count( array_unique( $this->record ) ) < 2 )
123
+		{
124
+			return $this->get_record( $_position );
125
+		}
114 126
 		
115
-		if ( !empty( $this->conversion ) ) {
127
+		if ( !empty( $this->conversion ) )
128
+		{
116 129
 			$this->do_conversions();
117 130
 		}
118 131
 		
119
-		if ( !empty( $this->mapping ) ) {
132
+		if ( !empty( $this->mapping ) )
133
+		{
120 134
 			$this->do_fieldmapping();
121 135
 		}
122 136
 		
@@ -128,8 +142,10 @@  discard block
 block discarded – undo
128 142
 	 *
129 143
 	 * @param int $_numToSkip
130 144
 	 */
131
-	public function skip_records( $_numToSkip ) {
132
-		while ( (int)$_numToSkip-- !== 0 ) {
145
+	public function skip_records( $_numToSkip )
146
+	{
147
+		while ( (int)$_numToSkip-- !== 0 )
148
+		{
133 149
 			fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep);
134 150
 		}
135 151
 	}
@@ -140,22 +156,27 @@  discard block
 block discarded – undo
140 156
 	 * @param mixed $_position
141 157
 	 * @return bool
142 158
 	 */
143
-	private function get_raw_record( $_position = 'next' ) {
144
-		switch ($_position) {
159
+	private function get_raw_record( $_position = 'next' )
160
+	{
161
+		switch ($_position)
162
+		{
145 163
 			case 'current' :
146
-				if ($this->current_position == 0) {
164
+				if ($this->current_position == 0)
165
+				{
147 166
 					return;
148 167
 				}
149 168
 				break;
150 169
 			case 'first' :
151
-				if (!$this->current_position == 0) {
170
+				if (!$this->current_position == 0)
171
+				{
152 172
 					$this->current_position = 0;
153 173
 					rewind($this->resource);
154 174
 				}
155 175
 				
156 176
 			case 'next' :
157 177
 				$csv_data = fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep);
158
-				if (!is_array($csv_data)) {
178
+				if (!is_array($csv_data))
179
+				{
159 180
 					return false;
160 181
 				}
161 182
 				$this->current_position++;
@@ -163,33 +184,41 @@  discard block
 block discarded – undo
163 184
 				break;
164 185
 				
165 186
 			case 'previous' :
166
-				if ($this->current_position < 2) {
187
+				if ($this->current_position < 2)
188
+				{
167 189
 					throw new Exception('Error: There is no previous record!');
168 190
 				}
169 191
 				$final_position = --$this->current_position;
170 192
 				$this->current_position = 0;
171 193
 				rewind($this->resource);
172
-				while ($this->current_position !== $final_position) {
194
+				while ($this->current_position !== $final_position)
195
+				{
173 196
 					$this->get_raw_record();
174 197
 				}
175 198
 				break;
176 199
 				
177 200
 			case 'last' :
178
-				while ($this->get_raw_record()) {}
201
+				while ($this->get_raw_record())
202
+				{
203
+}
179 204
 				break;
180 205
 				
181 206
 			default: //somenumber
182
-				if (!is_int($_position)) {
207
+				if (!is_int($_position))
208
+				{
183 209
 					throw new Exception('Error: $position must be one of {current|first|last|next|previous} or an integer value');
184 210
 				}
185
-				if ($_position == $this->current_position) {
211
+				if ($_position == $this->current_position)
212
+				{
186 213
 					break;
187 214
 				}
188
-				elseif ($_position < $this->current_position) {
215
+				elseif ($_position < $this->current_position)
216
+				{
189 217
 					$this->current_position = 0;
190 218
 					rewind($this->resource);
191 219
 				}
192
-				while ($this->current_position !== $_position) {
220
+				while ($this->current_position !== $_position)
221
+				{
193 222
 					$this->get_raw_record();
194 223
 				}
195 224
 				break;				
@@ -202,12 +231,16 @@  discard block
 block discarded – undo
202 231
 	 *
203 232
 	 * @return int
204 233
 	 */
205
-	public function get_num_of_records( ) {
206
-		if ($this->num_of_records > 0) {
234
+	public function get_num_of_records( )
235
+	{
236
+		if ($this->num_of_records > 0)
237
+		{
207 238
 			return $this->num_of_records;
208 239
 		}
209 240
 		$current_position = $this->current_position;
210
-		while ($this->get_raw_record()) {}
241
+		while ($this->get_raw_record())
242
+		{
243
+}
211 244
 		$this->num_of_records = $this->current_position;
212 245
 		$this->get_record($current_position);
213 246
 		return $this->num_of_records;
@@ -218,7 +251,8 @@  discard block
 block discarded – undo
218 251
 	 *
219 252
 	 * @return int
220 253
 	 */
221
-	public function get_current_position( ) {
254
+	public function get_current_position( )
255
+	{
222 256
 		
223 257
 		return $this->current_position;
224 258
 		
@@ -230,12 +264,16 @@  discard block
 block discarded – undo
230 264
 	 *
231 265
 	 * @return
232 266
 	 */
233
-	protected function do_fieldmapping( ) {
267
+	protected function do_fieldmapping( )
268
+	{
234 269
 		$record = $this->record;
235 270
 		$this->record = array();
236 271
 		foreach ($this->mapping as $cvs_idx => $new_idx)
237 272
 		{
238
-			if( $new_idx == '' ) continue;
273
+			if( $new_idx == '' )
274
+			{
275
+				continue;
276
+			}
239 277
 			$this->record[$new_idx] = $record[$cvs_idx];
240 278
 		}
241 279
 		return true;
@@ -246,8 +284,10 @@  discard block
 block discarded – undo
246 284
 	 *
247 285
 	 * @return bool
248 286
 	 */
249
-	protected function do_conversions() {
250
-		if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) {
287
+	protected function do_conversions()
288
+	{
289
+		if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class ))
290
+		{
251 291
 			$this->record = $record;
252 292
 			return;
253 293
 		}
@@ -264,16 +304,19 @@  discard block
 block discarded – undo
264 304
 	 *
265 305
 	 * @return string warnings, if any
266 306
 	 */
267
-	public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) {
307
+	public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0)
308
+	{
268 309
 		$warnings = array();
269 310
 
270 311
 		// Automatic conversions
271
-		if($appname) {
312
+		if($appname)
313
+		{
272 314
 
273 315
 			// Load translations
274 316
 			Api\Translation::add_app($appname);
275 317
 
276
-			if(!self::$cf_parse_cache[$appname]) {
318
+			if(!self::$cf_parse_cache[$appname])
319
+			{
277 320
 				$c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods);
278 321
 				self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
279 322
 			}
@@ -282,7 +325,10 @@  discard block
 block discarded – undo
282 325
 			// Add in any fields that are keys to another app
283 326
 			foreach((array)$fields['links'] as $link_field => $app)
284 327
 			{
285
-				if(is_numeric($link_field)) continue;
328
+				if(is_numeric($link_field))
329
+				{
330
+					continue;
331
+				}
286 332
 				$links[$link_field] = $app;
287 333
 				// Set it as a normal link field
288 334
 				$fields['links'][] = $link_field;
@@ -292,7 +338,8 @@  discard block
 block discarded – undo
292 338
 			// Not quite a recursive merge, since only one level
293 339
 			foreach($fields as $type => &$list)
294 340
 			{
295
-				if($c_fields[$type]) {
341
+				if($c_fields[$type])
342
+				{
296 343
 					$list = array_merge($c_fields[$type], $list);
297 344
 					unset($c_fields[$type]);
298 345
 				}
@@ -300,9 +347,12 @@  discard block
 block discarded – undo
300 347
 			$fields += $c_fields;
301 348
 			$selects += $c_selects;
302 349
 		}
303
-		if($fields) {
304
-			foreach((array)$fields['select'] as $name) {
305
-				if($record[$name] != null && is_array($selects) && $selects[$name]) {
350
+		if($fields)
351
+		{
352
+			foreach((array)$fields['select'] as $name)
353
+			{
354
+				if($record[$name] != null && is_array($selects) && $selects[$name])
355
+				{
306 356
 					$key = array_search(strtolower($record[$name]), array_map('strtolower',$selects[$name]));
307 357
 					if($key !== false)
308 358
 					{
@@ -311,11 +361,15 @@  discard block
 block discarded – undo
311 361
 					else
312 362
 					{
313 363
 						$key = array_search(strtolower($record[$name]), array_map('strtolower',array_map('lang',$selects[$name])));
314
-						if($key !== false) $record[$name] = $key;
364
+						if($key !== false)
365
+						{
366
+							$record[$name] = $key;
367
+						}
315 368
 					}
316 369
 				}
317 370
 			}
318
-			foreach((array)$fields['links'] as $name) {
371
+			foreach((array)$fields['links'] as $name)
372
+			{
319 373
 				if($record[$name] && $links[$name])
320 374
 				{
321 375
 					// Primary key to another app, not a link
@@ -357,15 +411,19 @@  discard block
 block discarded – undo
357 411
 								lang($links[$name]), $record[$name]).
358 412
  								' - ' . lang('no matches');
359 413
 							continue;
360
-						} else {
414
+						}
415
+						else
416
+						{
361 417
 							$record[$name] = key($results);
362 418
 						}
363 419
 					}
364 420
 				}
365 421
 			}
366
-			foreach((array)$fields['select-account'] as $name) {
422
+			foreach((array)$fields['select-account'] as $name)
423
+			{
367 424
 				// Compare against null to deal with empty arrays
368
-				if ($record[$name]) {
425
+				if ($record[$name])
426
+				{
369 427
 					// Automatically handle text owner without explicit translation
370 428
 					$new_owner = importexport_helper_functions::account_name2id($record[$name]);
371 429
 					if(count($new_owner) != count(explode(',',$record[$name])))
@@ -373,20 +431,26 @@  discard block
 block discarded – undo
373 431
 						// Unable to parse value into account
374 432
 						$warnings[] = $name . ': ' .lang('%1 is not a known user or group', $record[$name]);
375 433
 					}
376
-					if($new_owner != '') {
434
+					if($new_owner != '')
435
+					{
377 436
 						$record[$name] = $new_owner;
378
-					} else {
437
+					}
438
+					else
439
+					{
379 440
 						// Clear it to prevent trouble later on
380 441
 						$record[$name] = '';
381 442
 					}
382 443
 				}
383 444
 			}
384
-			foreach((array)$fields['select-bool'] as $name) {
385
-				if($record[$name] != null && $record[$name] != '') {
445
+			foreach((array)$fields['select-bool'] as $name)
446
+			{
447
+				if($record[$name] != null && $record[$name] != '')
448
+				{
386 449
 					$record[$name] = ($record[$name] == lang('Yes') || $record[$name] == '1' ? 1 : 0);
387 450
 				}
388 451
 			}
389
-			foreach((array)$fields['date-time'] as $name) {
452
+			foreach((array)$fields['date-time'] as $name)
453
+			{
390 454
 				if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0)
391 455
 				{
392 456
 					// Need to handle format first
@@ -412,7 +476,8 @@  discard block
 block discarded – undo
412 476
 								// Try again, anything goes
413 477
 								try {
414 478
 									$formatted = new Api\DateTime($record[$name]);
415
-								} catch (Exception $e) {
479
+								}
480
+								catch (Exception $e) {
416 481
 									$warnings[] = $name.': ' . $e->getMessage() . "\n" .
417 482
 										'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat;
418 483
 									continue;
@@ -434,7 +499,8 @@  discard block
 block discarded – undo
434 499
 					}
435 500
 					
436 501
 					if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) &&
437
-							in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) {
502
+							in_array($name, self::$cf_parse_cache[$appname][0]['date-time']))
503
+					{
438 504
 						// Custom fields stored in a particular format (from customfields_widget)
439 505
 						$record[$name] = date('Y-m-d H:i:s', $record[$name]);
440 506
 					}
@@ -444,7 +510,8 @@  discard block
 block discarded – undo
444 510
 					$record[$name] = null;
445 511
 				}
446 512
 			}
447
-			foreach((array)$fields['date'] as $name) {
513
+			foreach((array)$fields['date'] as $name)
514
+			{
448 515
 				if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0)
449 516
 				{
450 517
 					// Need to handle format first
@@ -458,7 +525,8 @@  discard block
 block discarded – undo
458 525
 					}
459 526
 					$record[$name] = Api\DateTime::server2user($record[$name],'ts');
460 527
 					if(is_array(self::$cf_parse_cache[$appname][0]['date']) &&
461
-							in_array($name, self::$cf_parse_cache[$appname][0]['date'])) {
528
+							in_array($name, self::$cf_parse_cache[$appname][0]['date']))
529
+					{
462 530
 						// Custom fields stored in a particular format (from customfields_widget)
463 531
 						$record[$name] = date('Y-m-d', $record[$name]);
464 532
 					}
@@ -470,26 +538,37 @@  discard block
 block discarded – undo
470 538
 			}
471 539
 			foreach((array)$fields['float'] as $name)
472 540
 			{
473
-				if($record[$name] != null && $record[$name] != '') {
541
+				if($record[$name] != null && $record[$name] != '')
542
+				{
474 543
 					$dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
475
-					if (empty($dec_point)) $dec_point = '.';
544
+					if (empty($dec_point))
545
+					{
546
+						$dec_point = '.';
547
+					}
476 548
 					$record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name])));
477 549
 				}
478 550
 			}
479 551
 
480 552
 			// Some custom methods for conversion
481
-			foreach((array)$methods as $name => $method) {
482
-				if($record[$name]) $record[$name] = ExecMethod($method, $record[$name]);
553
+			foreach((array)$methods as $name => $method)
554
+			{
555
+				if($record[$name])
556
+				{
557
+					$record[$name] = ExecMethod($method, $record[$name]);
558
+				}
483 559
 			}
484 560
 
485 561
 			// cat_name2id will use currentapp to create new categories
486 562
 			$current_app = $GLOBALS['egw_info']['flags']['currentapp'];
487
-			if($appname) {
563
+			if($appname)
564
+			{
488 565
 				$GLOBALS['egw_info']['flags']['currentapp'] = $appname;
489 566
 			}
490 567
 			$categories = new Api\Categories('',$appname);
491
-			foreach((array)$fields['select-cat'] as $name) {
492
-				if($record[$name]) {
568
+			foreach((array)$fields['select-cat'] as $name)
569
+			{
570
+				if($record[$name])
571
+				{
493 572
 					// Only parse name if it needs it
494 573
 					if($format == 1)
495 574
 					{
@@ -503,7 +582,10 @@  discard block
 block discarded – undo
503 582
 							$cat_id = importexport_helper_functions::cat_name2id($record[$name]);
504 583
 						}
505 584
 						// Don't clear it if it wasn't found
506
-						if($cat_id) $record[$name] = $cat_id;
585
+						if($cat_id)
586
+						{
587
+							$record[$name] = $cat_id;
588
+						}
507 589
 					}
508 590
 				}
509 591
 			}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@
 block discarded – undo
264 264
 	 *
265 265
 	 * @return string warnings, if any
266 266
 	 */
267
-	public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) {
267
+	public static function convert(array &$record, array $fields = array(), $appname = null, array $selects = array(), $format=0) {
268 268
 		$warnings = array();
269 269
 
270 270
 		// Automatic conversions
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	 * @param string $_resource resource containing data. May be each valid php-stream
81 81
 	 * @param array $_options options for the resource array with keys: charset and fieldsep
82 82
 	 */
83
-	public function __construct( $_resource,  array $_options ) {
83
+	public function __construct($_resource, array $_options) {
84 84
 		$this->resource = $_resource;
85 85
 		$this->csv_fieldsep = $_options['fieldsep'];
86
-		if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
86
+		if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
87 87
 		$this->csv_charset = $_options['charset'];
88 88
 		return;
89 89
 	} // end of member function __construct
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
 	 * @param mixed _position may be: {current|first|last|next|previous|somenumber}
101 101
 	 * @return mixed array with data / false if no furtor records
102 102
 	 */
103
-	public function get_record( $_position = 'next' ) {
103
+	public function get_record($_position = 'next') {
104 104
 		
105
-		if ($this->get_raw_record( $_position ) === false) {
105
+		if ($this->get_raw_record($_position) === false) {
106 106
 			return false;
107 107
 		}
108 108
 		
109 109
 		// skip empty records
110
-		if( count( array_unique( $this->record ) ) < 2 ) return $this->get_record( $_position );
110
+		if (count(array_unique($this->record)) < 2) return $this->get_record($_position);
111 111
 		
112
-		if ( !empty( $this->conversion ) ) {
112
+		if (!empty($this->conversion)) {
113 113
 			$this->do_conversions();
114 114
 		}
115 115
 		
116
-		if ( !empty( $this->mapping ) ) {
116
+		if (!empty($this->mapping)) {
117 117
 			$this->do_fieldmapping();
118 118
 		}
119 119
 		
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @param int $_numToSkip
127 127
 	 */
128
-	public function skip_records( $_numToSkip ) {
129
-		while ( (int)$_numToSkip-- !== 0 ) {
130
-			fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep);
128
+	public function skip_records($_numToSkip) {
129
+		while ((int)$_numToSkip-- !== 0) {
130
+			fgetcsv($this->resource, self::csv_max_linelength, $this->csv_fieldsep);
131 131
 		}
132 132
 	}
133 133
 	
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @param mixed $_position
138 138
 	 * @return bool
139 139
 	 */
140
-	private function get_raw_record( $_position = 'next' ) {
140
+	private function get_raw_record($_position = 'next') {
141 141
 		switch ($_position) {
142 142
 			case 'current' :
143 143
 				if ($this->current_position == 0) {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 				}
152 152
 				
153 153
 			case 'next' :
154
-				$csv_data = fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep);
154
+				$csv_data = fgetcsv($this->resource, self::csv_max_linelength, $this->csv_fieldsep);
155 155
 				if (!is_array($csv_data)) {
156 156
 					return false;
157 157
 				}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		$this->record = array();
233 233
 		foreach ($this->mapping as $cvs_idx => $new_idx)
234 234
 		{
235
-			if( $new_idx == '' ) continue;
235
+			if ($new_idx == '') continue;
236 236
 			$this->record[$new_idx] = $record[$cvs_idx];
237 237
 		}
238 238
 		return true;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	 * @return bool
245 245
 	 */
246 246
 	protected function do_conversions() {
247
-		if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) {
247
+		if ($record = importexport_helper_functions::conversion($this->record, $this->conversion, $this->conversion_class)) {
248 248
 			$this->record = $record;
249 249
 			return;
250 250
 		}
@@ -261,25 +261,25 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return string warnings, if any
263 263
 	 */
264
-	public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) {
264
+	public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format = 0) {
265 265
 		$warnings = array();
266 266
 
267 267
 		// Automatic conversions
268
-		if($appname) {
268
+		if ($appname) {
269 269
 
270 270
 			// Load translations
271 271
 			translation::add_app($appname);
272 272
 
273
-			if(!self::$cf_parse_cache[$appname]) {
273
+			if (!self::$cf_parse_cache[$appname]) {
274 274
 				$c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods);
275 275
 				self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
276 276
 			}
277 277
 			list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname];
278 278
 
279 279
 			// Add in any fields that are keys to another app
280
-			foreach((array)$fields['links'] as $link_field => $app)
280
+			foreach ((array)$fields['links'] as $link_field => $app)
281 281
 			{
282
-				if(is_numeric($link_field)) continue;
282
+				if (is_numeric($link_field)) continue;
283 283
 				$links[$link_field] = $app;
284 284
 				// Set it as a normal link field
285 285
 				$fields['links'][] = $link_field;
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 			}
288 288
 
289 289
 			// Not quite a recursive merge, since only one level
290
-			foreach($fields as $type => &$list)
290
+			foreach ($fields as $type => &$list)
291 291
 			{
292
-				if($c_fields[$type]) {
292
+				if ($c_fields[$type]) {
293 293
 					$list = array_merge($c_fields[$type], $list);
294 294
 					unset($c_fields[$type]);
295 295
 				}
@@ -297,36 +297,36 @@  discard block
 block discarded – undo
297 297
 			$fields += $c_fields;
298 298
 			$selects += $c_selects;
299 299
 		}
300
-		if($fields) {
301
-			foreach((array)$fields['select'] as $name) {
302
-				if($record[$name] != null && is_array($selects) && $selects[$name]) {
303
-					$key = array_search(strtolower($record[$name]), array_map('strtolower',$selects[$name]));
304
-					if($key !== false)
300
+		if ($fields) {
301
+			foreach ((array)$fields['select'] as $name) {
302
+				if ($record[$name] != null && is_array($selects) && $selects[$name]) {
303
+					$key = array_search(strtolower($record[$name]), array_map('strtolower', $selects[$name]));
304
+					if ($key !== false)
305 305
 					{
306 306
 						$record[$name] = $key;
307 307
 					}
308 308
 					else
309 309
 					{
310
-						$key = array_search(strtolower($record[$name]), array_map('strtolower',array_map('lang',$selects[$name])));
311
-						if($key !== false) $record[$name] = $key;
310
+						$key = array_search(strtolower($record[$name]), array_map('strtolower', array_map('lang', $selects[$name])));
311
+						if ($key !== false) $record[$name] = $key;
312 312
 					}
313 313
 				}
314 314
 			}
315
-			foreach((array)$fields['links'] as $name) {
316
-				if($record[$name] && $links[$name])
315
+			foreach ((array)$fields['links'] as $name) {
316
+				if ($record[$name] && $links[$name])
317 317
 				{
318 318
 					// Primary key to another app, not a link
319 319
 					// Text - search for a matching record
320
-					if(!is_numeric($record[$name]))
320
+					if (!is_numeric($record[$name]))
321 321
 					{
322 322
 						$results = egw_link::query($links[$name], $record[$name]);
323
-						if(count($results) >= 1)
323
+						if (count($results) >= 1)
324 324
 						{
325 325
 							// More than 1 result.  Check for exact match
326 326
 							$exact_count = 0;
327
-							foreach($results as $id => $title)
327
+							foreach ($results as $id => $title)
328 328
 							{
329
-								if($title == $record[$name])
329
+								if ($title == $record[$name])
330 330
 								{
331 331
 									$exact_count++;
332 332
 									$app_id = $id;
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 								unset($results[$id]);
336 336
 							}
337 337
 							// Too many exact matches, or none good enough
338
-							if($exact_count > 1 || count($results) == 0)
338
+							if ($exact_count > 1 || count($results) == 0)
339 339
 							{
340 340
 								$warnings[] = lang('Unable to link to %1 "%2"',
341 341
 									lang($links[$name]), $record[$name]).
342
- 									' - ' .lang('too many matches');
342
+ 									' - '.lang('too many matches');
343 343
 								continue;
344 344
 							}
345 345
 							elseif ($exact_count == 1)
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 						{
353 353
 							$warnings[] = lang('Unable to link to %1 "%2"',
354 354
 								lang($links[$name]), $record[$name]).
355
- 								' - ' . lang('no matches');
355
+ 								' - '.lang('no matches');
356 356
 							continue;
357 357
 						} else {
358 358
 							$record[$name] = key($results);
@@ -360,17 +360,17 @@  discard block
 block discarded – undo
360 360
 					}
361 361
 				}
362 362
 			}
363
-			foreach((array)$fields['select-account'] as $name) {
363
+			foreach ((array)$fields['select-account'] as $name) {
364 364
 				// Compare against null to deal with empty arrays
365 365
 				if ($record[$name]) {
366 366
 					// Automatically handle text owner without explicit translation
367 367
 					$new_owner = importexport_helper_functions::account_name2id($record[$name]);
368
-					if(count($new_owner) != count(explode(',',$record[$name])))
368
+					if (count($new_owner) != count(explode(',', $record[$name])))
369 369
 					{
370 370
 						// Unable to parse value into account
371
-						$warnings[] = $name . ': ' .lang('%1 is not a known user or group', $record[$name]);
371
+						$warnings[] = $name.': '.lang('%1 is not a known user or group', $record[$name]);
372 372
 					}
373
-					if($new_owner != '') {
373
+					if ($new_owner != '') {
374 374
 						$record[$name] = $new_owner;
375 375
 					} else {
376 376
 						// Clear it to prevent trouble later on
@@ -378,24 +378,24 @@  discard block
 block discarded – undo
378 378
 					}
379 379
 				}
380 380
 			}
381
-			foreach((array)$fields['select-bool'] as $name) {
382
-				if($record[$name] != null && $record[$name] != '') {
381
+			foreach ((array)$fields['select-bool'] as $name) {
382
+				if ($record[$name] != null && $record[$name] != '') {
383 383
 					$record[$name] = ($record[$name] == lang('Yes') || $record[$name] == '1' ? 1 : 0);
384 384
 				}
385 385
 			}
386
-			foreach((array)$fields['date-time'] as $name) {
386
+			foreach ((array)$fields['date-time'] as $name) {
387 387
 				if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0)
388 388
 				{
389 389
 					// Need to handle format first
390
-					if($format == 1)
390
+					if ($format == 1)
391 391
 					{
392 392
 						$formatted = egw_time::createFromFormat(
393
-							'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat,
393
+							'!'.egw_time::$user_dateformat.' '.egw_time::$user_timeformat,
394 394
 							$record[$name],
395 395
 							egw_time::$user_timezone
396 396
 						);
397 397
 
398
-						if(!$formatted && $errors = egw_time::getLastErrors())
398
+						if (!$formatted && $errors = egw_time::getLastErrors())
399 399
 						{
400 400
 							// Try again, without time
401 401
 							$formatted = egw_time::createFromFormat(
@@ -404,70 +404,70 @@  discard block
 block discarded – undo
404 404
 								egw_time::$user_timezone
405 405
 							);
406 406
 							
407
-							if(!$formatted && $errors = egw_time::getLastErrors())
407
+							if (!$formatted && $errors = egw_time::getLastErrors())
408 408
 							{
409 409
 								// Try again, anything goes
410 410
 								try {
411 411
 									$formatted = new egw_time($record[$name]);
412 412
 								} catch (Exception $e) {
413
-									$warnings[] = $name.': ' . $e->getMessage() . "\n" .
414
-										'Format: '.'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat;
413
+									$warnings[] = $name.': '.$e->getMessage()."\n".
414
+										'Format: '.'!'.egw_time::$user_dateformat.' '.egw_time::$user_timeformat;
415 415
 									continue;
416 416
 								}
417 417
 								$errors = egw_time::getLastErrors();
418
-								foreach($errors['errors'] as $char => $msg)
418
+								foreach ($errors['errors'] as $char => $msg)
419 419
 								{
420 420
 									$warnings[] = "$name: [$char] $msg\n".
421
-										'Format: '.'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat;
421
+										'Format: '.'!'.egw_time::$user_dateformat.' '.egw_time::$user_timeformat;
422 422
 								}
423 423
 							}
424 424
 						}
425
-						if($formatted)
425
+						if ($formatted)
426 426
 						{
427 427
 							$record[$name] = $formatted->getTimestamp();
428 428
 							// Timestamp is apparently in server time, but apps will do the same conversion
429
-							$record[$name] = egw_time::server2user($record[$name],'ts');
429
+							$record[$name] = egw_time::server2user($record[$name], 'ts');
430 430
 						}
431 431
 					}
432 432
 					
433
-					if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) &&
433
+					if (is_array(self::$cf_parse_cache[$appname][0]['date-time']) &&
434 434
 							in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) {
435 435
 						// Custom fields stored in a particular format (from customfields_widget)
436 436
 						$record[$name] = date('Y-m-d H:i:s', $record[$name]);
437 437
 					}
438 438
 				}
439
-				if(array_key_exists($name, $record) && strlen(trim($record[$name])) == 0)
439
+				if (array_key_exists($name, $record) && strlen(trim($record[$name])) == 0)
440 440
 				{
441 441
 					$record[$name] = null;
442 442
 				}
443 443
 			}
444
-			foreach((array)$fields['date'] as $name) {
444
+			foreach ((array)$fields['date'] as $name) {
445 445
 				if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0)
446 446
 				{
447 447
 					// Need to handle format first
448
-					if($format == 1)
448
+					if ($format == 1)
449 449
 					{
450 450
 						$formatted = egw_time::createFromFormat('!'.egw_time::$user_dateformat, $record[$name]);
451
-						if($formatted && $errors = egw_time::getLastErrors() && $errors['error_count'] == 0)
451
+						if ($formatted && $errors = egw_time::getLastErrors() && $errors['error_count'] == 0)
452 452
 						{
453 453
 							$record[$name] = $formatted->getTimestamp();
454 454
 						}
455 455
 					}
456
-					$record[$name] = egw_time::server2user($record[$name],'ts');
457
-					if(is_array(self::$cf_parse_cache[$appname][0]['date']) &&
456
+					$record[$name] = egw_time::server2user($record[$name], 'ts');
457
+					if (is_array(self::$cf_parse_cache[$appname][0]['date']) &&
458 458
 							in_array($name, self::$cf_parse_cache[$appname][0]['date'])) {
459 459
 						// Custom fields stored in a particular format (from customfields_widget)
460 460
 						$record[$name] = date('Y-m-d', $record[$name]);
461 461
 					}
462 462
 				}
463
-				if(array_key_exists($name, $record) && strlen(trim($record[$name])) == 0)
463
+				if (array_key_exists($name, $record) && strlen(trim($record[$name])) == 0)
464 464
 				{
465 465
 					$record[$name] = null;
466 466
 				}
467 467
 			}
468
-			foreach((array)$fields['float'] as $name)
468
+			foreach ((array)$fields['float'] as $name)
469 469
 			{
470
-				if($record[$name] != null && $record[$name] != '') {
470
+				if ($record[$name] != null && $record[$name] != '') {
471 471
 					$dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
472 472
 					if (empty($dec_point)) $dec_point = '.';
473 473
 					$record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name])));
@@ -475,23 +475,23 @@  discard block
 block discarded – undo
475 475
 			}
476 476
 
477 477
 			// Some custom methods for conversion
478
-			foreach((array)$methods as $name => $method) {
479
-				if($record[$name]) $record[$name] = ExecMethod($method, $record[$name]);
478
+			foreach ((array)$methods as $name => $method) {
479
+				if ($record[$name]) $record[$name] = ExecMethod($method, $record[$name]);
480 480
 			}
481 481
 
482 482
 			// cat_name2id will use currentapp to create new categories
483 483
 			$current_app = $GLOBALS['egw_info']['flags']['currentapp'];
484
-			if($appname) {
484
+			if ($appname) {
485 485
 				$GLOBALS['egw_info']['flags']['currentapp'] = $appname;
486 486
 			}
487
-			$categories = new categories('',$appname);
488
-			foreach((array)$fields['select-cat'] as $name) {
489
-				if($record[$name]) {
487
+			$categories = new categories('', $appname);
488
+			foreach ((array)$fields['select-cat'] as $name) {
489
+				if ($record[$name]) {
490 490
 					// Only parse name if it needs it
491
-					if($format == 1)
491
+					if ($format == 1)
492 492
 					{
493
-						$existing_cat = $categories->exists('all',$record[$name]);
494
-						if($existing_cat)
493
+						$existing_cat = $categories->exists('all', $record[$name]);
494
+						if ($existing_cat)
495 495
 						{
496 496
 							$cat_id = $existing_cat;
497 497
 						}
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
 							$cat_id = importexport_helper_functions::cat_name2id($record[$name]);
501 501
 						}
502 502
 						// Don't clear it if it wasn't found
503
-						if($cat_id) $record[$name] = $cat_id;
503
+						if ($cat_id) $record[$name] = $cat_id;
504 504
 					}
505 505
 				}
506 506
 			}
507 507
 			$GLOBALS['egw_info']['flags']['currentapp'] = $current_app;
508 508
 		}
509 509
 
510
-		return implode("\n",$warnings);
510
+		return implode("\n", $warnings);
511 511
 	}
512 512
 } // end of import_csv
513 513
 ?>
Please login to merge, or discard this patch.
importexport/inc/class.importexport_import_ui.inc.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -295,7 +295,7 @@
 block discarded – undo
295 295
 		 *
296 296
 		 * @param importexport_iface_import_plugin $plugin Instance of plugin to be used
297 297
 		 * @param resource $stream
298
-		 * @param importexport_definition $definition
298
+		 * @param importexport_definition $definition_obj
299 299
 		 * @return String HTML fragment illustrating how the data will be understood by Egw
300 300
 		 */
301 301
 		protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj)
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 		}
42 42
 
43 43
 		/**
44
-		*  Step user through importing their file
45
-		*/
44
+		 *  Step user through importing their file
45
+		 */
46 46
 		public function import_dialog($content = array()) {
47 47
 			$appname = $_GET['appname'] ? $_GET['appname'] : $content['appname'];
48 48
 			$definition = $_GET['definition'] ? $_GET['definition'] : $content['definition'];
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 
226 226
 		/**
227
-		* Get options for select boxes
228
-		*/
227
+		 * Get options for select boxes
228
+		 */
229 229
 		public static function get_select_options(Array $data) {
230 230
 			$options = array(
231 231
 				'delimiter' => array(
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 		}
275 275
 
276 276
 		/**
277
-		* Get definitions via ajax
278
-		*/
277
+		 * Get definitions via ajax
278
+		 */
279 279
 		public function ajax_get_definitions($appname, $file=null) {
280 280
 			$options = self::get_select_options(array('appname'=>$appname, 'file'=>$file));
281 281
 			$response = new xajaxResponse();
Please login to merge, or discard this patch.
Braces   +81 added lines, -35 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
  *
21 21
 */
22 22
 
23
-	class importexport_import_ui {
23
+	class importexport_import_ui
24
+	{
24 25
 
25 26
 		const _appname = 'importexport';
26 27
 
@@ -35,7 +36,8 @@  discard block
 block discarded – undo
35 36
 		 */
36 37
 		private $plugins;
37 38
 
38
-		public function __construct() {
39
+		public function __construct()
40
+		{
39 41
 			$this->plugins = importexport_helper_functions::get_plugins('all','import');
40 42
 			$GLOBALS['egw_info']['flags']['include_xajax'] = true;
41 43
 		}
@@ -43,7 +45,8 @@  discard block
 block discarded – undo
43 45
 		/**
44 46
 		*  Step user through importing their file
45 47
 		*/
46
-		public function import_dialog($content = array()) {
48
+		public function import_dialog($content = array())
49
+		{
47 50
 			$appname = $_GET['appname'] ? $_GET['appname'] : $content['appname'];
48 51
 			$definition = $_GET['definition'] ? $_GET['definition'] : $content['definition'];
49 52
 
@@ -57,16 +60,19 @@  discard block
 block discarded – undo
57 60
 			{
58 61
 				Api\Translation::add_app($appname);
59 62
 			}
60
-			if($content['import'] && $definition) {
63
+			if($content['import'] && $definition)
64
+			{
61 65
 				try {
62 66
 					$definition_obj = new importexport_definition($content['definition']);
63
-					if($content['dry-run']) {
67
+					if($content['dry-run'])
68
+					{
64 69
 						// Set this so plugin doesn't do any data changes
65 70
 						$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
66 71
 					}
67 72
 					$options =& $definition_obj->plugin_options;
68 73
 					$options['no_notification'] = $content['no_notifications'];
69
-					if($content['delimiter']) {
74
+					if($content['delimiter'])
75
+					{
70 76
 						$options['fieldsep'] =
71 77
 							$content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter'];
72 78
 					}
@@ -109,7 +115,8 @@  discard block
 block discarded – undo
109 115
 						// Keep file
110 116
 						if($dst_file)
111 117
 						{
112
-							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) {
118
+							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file))
119
+							{
113 120
 								$preserve['file']['tmp_name'] = $dst_file;
114 121
 							}
115 122
 						}
@@ -162,31 +169,41 @@  discard block
 block discarded – undo
162 169
 						Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
163 170
 					}
164 171
 					$total_processed = 0;
165
-					foreach($plugin->get_results() as $action => $a_count) {
172
+					foreach($plugin->get_results() as $action => $a_count)
173
+					{
166 174
 						$this->message .= "<br />\n" . lang($action) . ": $a_count";
167 175
 						$total_processed += $a_count;
168 176
 					}
169
-					if(count($plugin->get_warnings())) {
177
+					if(count($plugin->get_warnings()))
178
+					{
170 179
 						$this->message .= "<br />\n".lang('Warnings').':';
171
-						foreach($plugin->get_warnings() as $record => $message) {
180
+						foreach($plugin->get_warnings() as $record => $message)
181
+						{
172 182
 							$this->message .= "\n$record: $message";
173 183
 						}
174 184
 					}
175
-					if(count($plugin->get_errors())) {
185
+					if(count($plugin->get_errors()))
186
+					{
176 187
 						$this->message .= "<br />\n".lang('Problems during import:');
177
-						foreach($plugin->get_errors() as $record => $message) {
188
+						foreach($plugin->get_errors() as $record => $message)
189
+						{
178 190
 							$this->message .= "<br />\n$record: $message";
179 191
 						}
180
-						if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
192
+						if($count != $total_processed)
193
+						{
194
+							$this->message .= "<br />\n".lang('Some records may not have been imported');
195
+						}
181 196
 					}
182
-					if ($dst_file && $content['file']['tmp_name'] == $dst_file) {
197
+					if ($dst_file && $content['file']['tmp_name'] == $dst_file)
198
+					{
183 199
 						// Remove file
184 200
 						$cachefile->delete(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport',
185 201
 							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id'])));
186 202
 						unset($dst_file);
187 203
 					}
188 204
 
189
-				} catch (Exception $e) {
205
+				}
206
+				catch (Exception $e) {
190 207
 					$this->message .= $e->getMessage();
191 208
 				}
192 209
 			}
@@ -218,7 +235,10 @@  discard block
 block discarded – undo
218 235
 			$data['message'] = $this->message;
219 236
 			Framework::includeJS('.','importexport','importexport');
220 237
 
221
-			if($_GET['appname']) $readonlys['appname'] = true;
238
+			if($_GET['appname'])
239
+			{
240
+				$readonlys['appname'] = true;
241
+			}
222 242
 
223 243
 			$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
224 244
 		}
@@ -226,7 +246,8 @@  discard block
 block discarded – undo
226 246
 		/**
227 247
 		* Get options for select boxes
228 248
 		*/
229
-		public static function get_select_options(Array $data) {
249
+		public static function get_select_options(Array $data)
250
+		{
230 251
 			$options = array(
231 252
 				'delimiter' => array(
232 253
 					''	=>	lang('From definition'),
@@ -242,17 +263,20 @@  discard block
 block discarded – undo
242 263
 			(array)$apps = importexport_helper_functions::get_apps('import');
243 264
 			$options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps);
244 265
 
245
-			if($data['appname']) {
266
+			if($data['appname'])
267
+			{
246 268
 				$options['definition'] = array();
247 269
 
248
-				if($data['file'] && !is_array($data['file'])) {
270
+				if($data['file'] && !is_array($data['file']))
271
+				{
249 272
 					$extension = substr($data['file'], -3);
250 273
 				}
251 274
 				$definitions = new importexport_definitions_bo(array(
252 275
 					'type' => 'import',
253 276
 					'application' => $data['appname']
254 277
 				));
255
-				foreach ((array)$definitions->get_definitions() as $identifier) {
278
+				foreach ((array)$definitions->get_definitions() as $identifier)
279
+				{
256 280
 					try
257 281
 					{
258 282
 						$definition = new importexport_definition($identifier);
@@ -262,7 +286,8 @@  discard block
 block discarded – undo
262 286
 						// Permission error
263 287
 						continue;
264 288
 					}
265
-					if ($title = $definition->get_title()) {
289
+					if ($title = $definition->get_title())
290
+					{
266 291
 						$options['definition'][$title] = $title;
267 292
 					}
268 293
 					unset($definition);
@@ -276,12 +301,15 @@  discard block
 block discarded – undo
276 301
 		/**
277 302
 		* Get definitions via ajax
278 303
 		*/
279
-		public function ajax_get_definitions($appname, $file=null) {
304
+		public function ajax_get_definitions($appname, $file=null)
305
+		{
280 306
 			$options = self::get_select_options(array('appname'=>$appname, 'file'=>$file));
281 307
 			$response = new xajaxResponse();
282 308
 			$response->addScript("clear_options('exec[definition]');");
283
-			if(is_array($options['definition'])) {
284
-				foreach ($options['definition'] as $value => $title) {
309
+			if(is_array($options['definition']))
310
+			{
311
+				foreach ($options['definition'] as $value => $title)
312
+				{
285 313
 					$response->addScript("selectbox_add_option('exec[definition]','$title', '$value',false);");
286 314
 				}
287 315
 			}
@@ -317,9 +345,15 @@  discard block
 block discarded – undo
317 345
 				for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
318 346
 				{
319 347
 					$row_data = $import_csv->get_record();
320
-					if($row_data === false) break;
348
+					if($row_data === false)
349
+					{
350
+						break;
351
+					}
321 352
 					$rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data;
322
-					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
353
+					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'])
354
+					{
355
+						$row--;
356
+					}
323 357
 				}
324 358
 				$preview = Api\Html::table($rows);
325 359
 				rewind($stream);
@@ -328,19 +362,26 @@  discard block
 block discarded – undo
328 362
 			{
329 363
 				$preview = lang('Preview not supported by %1', $plugin->get_name());
330 364
 			}
331
-			if(count($plugin->get_warnings())) {
365
+			if(count($plugin->get_warnings()))
366
+			{
332 367
 				$this->message .= "<br />\n".lang('Warnings').':';
333
-				foreach($plugin->get_warnings() as $record => $message) {
368
+				foreach($plugin->get_warnings() as $record => $message)
369
+				{
334 370
 					$this->message .= "\n$record: $message";
335 371
 				}
336 372
 				$this->message .= "<br />\n";
337 373
 			};
338
-			if(count($plugin->get_errors())) {
374
+			if(count($plugin->get_errors()))
375
+			{
339 376
 				$this->message .= "<br />\n".lang('Problems during import:');
340
-				foreach($plugin->get_errors() as $record => $message) {
377
+				foreach($plugin->get_errors() as $record => $message)
378
+				{
341 379
 					$this->message .= "<br />\n$record: $message";
342 380
 				}
343
-				if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
381
+				if($count != $total_processed)
382
+				{
383
+					$this->message .= "<br />\n".lang('Some records may not have been imported');
384
+				}
344 385
 				$this->message .= "<br />\n";
345 386
 			}
346 387
 			return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview;
@@ -365,10 +406,16 @@  discard block
 block discarded – undo
365 406
 			$message_count = count($message);
366 407
 
367 408
 			// Only CSV files
368
-			if(!$options['csv_fields']) return true;
409
+			if(!$options['csv_fields'])
410
+			{
411
+				return true;
412
+			}
369 413
 
370 414
 			// Can't check if definition has no header
371
-			if($options['num_header_lines'] == 0) return true;
415
+			if($options['num_header_lines'] == 0)
416
+			{
417
+				return true;
418
+			}
372 419
 
373 420
 			$preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
374 421
 			$charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
@@ -412,8 +459,7 @@  discard block
 block discarded – undo
412 459
 				if($lang_defn == $lang_file ||
413 460
 					$lang_defn == mb_strtoupper($header) ||
414 461
 					$lang_file == mb_strtoupper($options['csv_fields'][$index])
415
-				)
416
-				{
462
+				) {
417 463
 					continue;
418 464
 				}
419 465
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@
 block discarded – undo
226 226
 		/**
227 227
 		* Get options for select boxes
228 228
 		*/
229
-		public static function get_select_options(Array $data) {
229
+		public static function get_select_options(array $data) {
230 230
 			$options = array(
231 231
 				'delimiter' => array(
232 232
 					''	=>	lang('From definition'),
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		private $plugins;
33 33
 
34 34
 		public function __construct() {
35
-			$this->plugins = importexport_helper_functions::get_plugins('all','import');
35
+			$this->plugins = importexport_helper_functions::get_plugins('all', 'import');
36 36
 			$GLOBALS['egw_info']['flags']['include_xajax'] = true;
37 37
 		}
38 38
 
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 			$template = new etemplate_new('importexport.import_dialog');
50 50
 
51 51
 			// Load application's translations
52
-			if($appname)
52
+			if ($appname)
53 53
 			{
54 54
 				translation::add_app($appname);
55 55
 			}
56
-			if($content['import'] && $definition) {
56
+			if ($content['import'] && $definition) {
57 57
 				try {
58 58
 					$definition_obj = new importexport_definition($content['definition']);
59
-					if($content['dry-run']) {
59
+					if ($content['dry-run']) {
60 60
 						// Set this so plugin doesn't do any data changes
61 61
 						$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
62 62
 					}
63
-					$options =& $definition_obj->plugin_options;
63
+					$options = & $definition_obj->plugin_options;
64 64
 					$options['no_notification'] = $content['no_notifications'];
65
-					if($content['delimiter']) {
65
+					if ($content['delimiter']) {
66 66
 						$options['fieldsep'] =
67 67
 							$content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter'];
68 68
 					}
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 					$plugin = new $definition_obj->plugin;
72 72
 
73 73
 					// Check file encoding matches import
74
-					$sample = file_get_contents($content['file']['tmp_name'],false, null, 0, 1024);
75
-					if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard')
74
+					$sample = file_get_contents($content['file']['tmp_name'], false, null, 0, 1024);
75
+					if ($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard')
76 76
 					{
77 77
 						$preference = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
78 78
 					}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 					}
83 83
 					$required = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
84 84
 					$encoding = translation::detect_encoding($sample, $required);
85
-					if($encoding && strtoupper($required) != strtoupper($encoding))
85
+					if ($encoding && strtoupper($required) != strtoupper($encoding))
86 86
 					{
87 87
 						$this->message = lang("Encoding mismatch.  Expected %1 file, you uploaded %2.<br />\n",
88 88
 							$required,
@@ -97,37 +97,37 @@  discard block
 block discarded – undo
97 97
 					$GLOBALS['egw_info']['flags']['currentapp'] = $appname;
98 98
 
99 99
 					// Destination if we need to hold the file
100
-					if($file)
100
+					if ($file)
101 101
 					{
102 102
 						$cachefile = new egw_cache_files(array());
103 103
 						$dst_file = $cachefile->filename(egw_cache::keys(egw_cache::INSTANCE, 'importexport',
104
-							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true),true);
104
+							'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true), true);
105 105
 						// Keep file
106
-						if($dst_file)
106
+						if ($dst_file)
107 107
 						{
108
-							if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) {
108
+							if ($content['file']['name'] && copy($content['file']['tmp_name'], $dst_file)) {
109 109
 								$preserve['file']['tmp_name'] = $dst_file;
110 110
 							}
111 111
 						}
112 112
 
113 113
 						// Check on matching columns
114 114
 						$check_message = array();
115
-						if(!self::check_file($file, $definition_obj, $check_message, $dst_file))
115
+						if (!self::check_file($file, $definition_obj, $check_message, $dst_file))
116 116
 						{
117 117
 							// Set this so plugin doesn't do any data changes
118 118
 							$content['dry-run'] = true;
119 119
 							importexport_helper_functions::$dry_run = true;
120
-							$this->message .= '<b>' . lang('Import aborted').":</b><br />\n";
120
+							$this->message .= '<b>'.lang('Import aborted').":</b><br />\n";
121 121
 							$definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true);
122 122
 						}
123
-						if(count($check_message))
123
+						if (count($check_message))
124 124
 						{
125
-							$this->message .= implode($check_message, "<br />\n") . "<br />\n";
125
+							$this->message .= implode($check_message, "<br />\n")."<br />\n";
126 126
 						}
127
-						if($content['dry-run'])
127
+						if ($content['dry-run'])
128 128
 						{
129 129
 							$preview = $this->preview($plugin, $file, $definition_obj);
130
-							if(trim($this->message) == '')
130
+							if (trim($this->message) == '')
131 131
 							{
132 132
 								// Clear first, to prevent request from being collected if the result is the same
133 133
 								$template->setElementAttribute('preview', 'value', '');
@@ -146,34 +146,34 @@  discard block
 block discarded – undo
146 146
 						$this->message .= lang('please select file to import'."<br />\n");
147 147
 					}
148 148
 
149
-					if($content['dry-run'])
149
+					if ($content['dry-run'])
150 150
 					{
151
-						$this->message .= '<b>' . lang('test only').":</b><br />\n";
151
+						$this->message .= '<b>'.lang('test only').":</b><br />\n";
152 152
 					}
153 153
 					$this->message .= lang('%1 records processed', $count);
154 154
 
155 155
 					// Refresh opening window
156
-					if(!$content['dry-run'])
156
+					if (!$content['dry-run'])
157 157
 					{
158
-						egw_framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
158
+						egw_framework::refresh_opener(lang('%1 records processed', $count), $appname, null, null, $appname);
159 159
 					}
160 160
 					$total_processed = 0;
161
-					foreach($plugin->get_results() as $action => $a_count) {
162
-						$this->message .= "<br />\n" . lang($action) . ": $a_count";
161
+					foreach ($plugin->get_results() as $action => $a_count) {
162
+						$this->message .= "<br />\n".lang($action).": $a_count";
163 163
 						$total_processed += $a_count;
164 164
 					}
165
-					if(count($plugin->get_warnings())) {
165
+					if (count($plugin->get_warnings())) {
166 166
 						$this->message .= "<br />\n".lang('Warnings').':';
167
-						foreach($plugin->get_warnings() as $record => $message) {
167
+						foreach ($plugin->get_warnings() as $record => $message) {
168 168
 							$this->message .= "\n$record: $message";
169 169
 						}
170 170
 					}
171
-					if(count($plugin->get_errors())) {
171
+					if (count($plugin->get_errors())) {
172 172
 						$this->message .= "<br />\n".lang('Problems during import:');
173
-						foreach($plugin->get_errors() as $record => $message) {
173
+						foreach ($plugin->get_errors() as $record => $message) {
174 174
 							$this->message .= "<br />\n$record: $message";
175 175
 						}
176
-						if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
176
+						if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
177 177
 					}
178 178
 					if ($dst_file && $content['file']['tmp_name'] == $dst_file) {
179 179
 						// Remove file
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 					$this->message .= $e->getMessage();
187 187
 				}
188 188
 			}
189
-			elseif($content['cancel'])
189
+			elseif ($content['cancel'])
190 190
 			{
191 191
 				$GLOBALS['egw']->js->set_onload('window.close();');
192 192
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				);
200 200
 			}
201 201
 
202
-			if(!array_key_exists('dry-run',$content))
202
+			if (!array_key_exists('dry-run', $content))
203 203
 			{
204 204
 				$data['dry-run'] = true;
205 205
 			}
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 			$data['appname'] = $preserve['appname'] = $appname ? $appname : ($definition_obj ? $definition_obj->application : '');
208 208
 			$data['definition'] = $definition;
209 209
 			$data['delimiter'] = $definition_obj->plugin_options['delimiter'];
210
-			$data['no_notifications'] = true;	// switch notifications off by default
210
+			$data['no_notifications'] = true; // switch notifications off by default
211 211
 
212 212
 			$sel_options = self::get_select_options($data);
213 213
 
214 214
 			$data['message'] = $this->message;
215
-			$GLOBALS['egw']->js->validate_file('.','importexport','importexport');
215
+			$GLOBALS['egw']->js->validate_file('.', 'importexport', 'importexport');
216 216
 
217
-			if($_GET['appname']) $readonlys['appname'] = true;
217
+			if ($_GET['appname']) $readonlys['appname'] = true;
218 218
 
219 219
 			$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
220 220
 		}
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 			);
237 237
 
238 238
 			(array)$apps = importexport_helper_functions::get_apps('import');
239
-			$options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps);
239
+			$options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps);
240 240
 
241
-			if($data['appname']) {
241
+			if ($data['appname']) {
242 242
 				$options['definition'] = array();
243 243
 
244
-				if($data['file'] && !is_array($data['file'])) {
244
+				if ($data['file'] && !is_array($data['file'])) {
245 245
 					$extension = substr($data['file'], -3);
246 246
 				}
247 247
 				$definitions = new importexport_definitions_bo(array(
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		/**
273 273
 		* Get definitions via ajax
274 274
 		*/
275
-		public function ajax_get_definitions($appname, $file=null) {
275
+		public function ajax_get_definitions($appname, $file = null) {
276 276
 			$options = self::get_select_options(array('appname'=>$appname, 'file'=>$file));
277 277
 			$response = new xajaxResponse();
278 278
 			$response->addScript("clear_options('exec[definition]');");
279
-			if(is_array($options['definition'])) {
279
+			if (is_array($options['definition'])) {
280 280
 				foreach ($options['definition'] as $value => $title) {
281 281
 					$response->addScript("selectbox_add_option('exec[definition]','$title', '$value',false);");
282 282
 				}
@@ -294,28 +294,28 @@  discard block
 block discarded – undo
294 294
 		 * @param importexport_definition $definition
295 295
 		 * @return String HTML fragment illustrating how the data will be understood by egw
296 296
 		 */
297
-		protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj)
297
+		protected function preview(importexport_iface_import_plugin&$plugin, &$stream, importexport_definition&$definition_obj)
298 298
 		{
299
-			if(method_exists($plugin, 'preview'))
299
+			if (method_exists($plugin, 'preview'))
300 300
 			{
301 301
 				$preview = $plugin->preview($stream, $definition_obj);
302 302
 			}
303
-			elseif($definition_obj->plugin_options['csv_fields'])
303
+			elseif ($definition_obj->plugin_options['csv_fields'])
304 304
 			{
305
-				$import_csv = new importexport_import_csv( $stream, array(
305
+				$import_csv = new importexport_import_csv($stream, array(
306 306
 					'fieldsep' => $definition_obj->plugin_options['fieldsep'],
307 307
 					'charset' => $definition_obj->plugin_options['charset'],
308 308
 				));
309 309
 				// set FieldMapping.
310 310
 				$import_csv->mapping = $definition_obj->plugin_options['field_mapping'];
311 311
 
312
-				$rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
313
-				for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
312
+				$rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th');
313
+				for ($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++)
314 314
 				{
315 315
 					$row_data = $import_csv->get_record();
316
-					if($row_data === false) break;
316
+					if ($row_data === false) break;
317 317
 					$rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data;
318
-					if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
318
+					if ($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
319 319
 				}
320 320
 				$preview = html::table($rows);
321 321
 				rewind($stream);
@@ -324,22 +324,22 @@  discard block
 block discarded – undo
324 324
 			{
325 325
 				$preview = lang('Preview not supported by %1', $plugin->get_name());
326 326
 			}
327
-			if(count($plugin->get_warnings())) {
327
+			if (count($plugin->get_warnings())) {
328 328
 				$this->message .= "<br />\n".lang('Warnings').':';
329
-				foreach($plugin->get_warnings() as $record => $message) {
329
+				foreach ($plugin->get_warnings() as $record => $message) {
330 330
 					$this->message .= "\n$record: $message";
331 331
 				}
332 332
 				$this->message .= "<br />\n";
333 333
 			};
334
-			if(count($plugin->get_errors())) {
334
+			if (count($plugin->get_errors())) {
335 335
 				$this->message .= "<br />\n".lang('Problems during import:');
336
-				foreach($plugin->get_errors() as $record => $message) {
336
+				foreach ($plugin->get_errors() as $record => $message) {
337 337
 					$this->message .= "<br />\n$record: $message";
338 338
 				}
339
-				if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
339
+				if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
340 340
 				$this->message .= "<br />\n";
341 341
 			}
342
-			return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview;
342
+			return '<div class="header">'.lang('Preview').' - '.$plugin->get_name().'</div>'.$preview;
343 343
 		}
344 344
 
345 345
 		/**
@@ -357,24 +357,24 @@  discard block
 block discarded – undo
357 357
 		 */
358 358
 		public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false)
359 359
 		{
360
-			$options =& $definition->plugin_options;
360
+			$options = & $definition->plugin_options;
361 361
 			$message_count = count($message);
362 362
 
363 363
 			// Only CSV files
364
-			if(!$options['csv_fields']) return true;
364
+			if (!$options['csv_fields']) return true;
365 365
 
366 366
 			// Can't check if definition has no header
367
-			if($options['num_header_lines'] == 0) return true;
367
+			if ($options['num_header_lines'] == 0) return true;
368 368
 
369 369
 			$preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
370 370
 			$charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
371 371
 
372 372
 			$data = fgetcsv($file, 8000, $options['fieldsep']);
373 373
 			rewind($file);
374
-			$data = translation::convert($data,$charset);
374
+			$data = translation::convert($data, $charset);
375 375
 
376 376
 			$ok = true;
377
-			if(count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields'])))
377
+			if (count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields'])))
378 378
 			{
379 379
 				$message[] = lang("Column mismatch.  Expected %1 columns, your file has %2.",
380 380
 					count($options['field_mapping']),
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
 				);
383 383
 				$ok = false;
384 384
 			}
385
-			foreach($data as $index => $header)
385
+			foreach ($data as $index => $header)
386 386
 			{
387
-				if($index < count($options['csv_fields']) && !$options['field_mapping'][$index])
387
+				if ($index < count($options['csv_fields']) && !$options['field_mapping'][$index])
388 388
 				{
389 389
 					// Skipped column in definition
390 390
 					continue;
@@ -396,16 +396,16 @@  discard block
 block discarded – undo
396 396
 				}
397 397
 
398 398
 				// Check for matching headers
399
-				if($options['csv_fields'][$index] == $header)
399
+				if ($options['csv_fields'][$index] == $header)
400 400
 				{
401 401
 					// Simple match
402 402
 					continue;
403 403
 				}
404 404
 				// Check column headers, taking into account different translations - make sure no *
405
-				$lang_defn = mb_strtoupper(translation::translate($options['csv_fields'][$index],false,''));
406
-				$lang_file = mb_strtoupper(translation::translate($header,false,''));
405
+				$lang_defn = mb_strtoupper(translation::translate($options['csv_fields'][$index], false, ''));
406
+				$lang_file = mb_strtoupper(translation::translate($header, false, ''));
407 407
 
408
-				if($lang_defn == $lang_file ||
408
+				if ($lang_defn == $lang_file ||
409 409
 					$lang_defn == mb_strtoupper($header) ||
410 410
 					$lang_file == mb_strtoupper($options['csv_fields'][$index])
411 411
 				)
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 				$file_message_id = translation::get_message_id($header, $definition->application);
418 418
 				$defn_message_id = translation::get_message_id($options['csv_fields'][$index], $definition->application);
419 419
 
420
-				if($file_message_id && $defn_message_id && $file_message_id == $defn_message_id)
420
+				if ($file_message_id && $defn_message_id && $file_message_id == $defn_message_id)
421 421
 				{
422 422
 					continue;
423 423
 				}
@@ -425,19 +425,19 @@  discard block
 block discarded – undo
425 425
 
426 426
 				// Problem
427 427
 				$message[] = lang("Column mismatch: %1 should be %2, not %3",
428
-					$index,$options['csv_fields'][$index], $header);
428
+					$index, $options['csv_fields'][$index], $header);
429 429
 				// But can still continue
430 430
 				// $ok = false;
431 431
 			}
432
-			if(!$ok || count($message) != $message_count)
432
+			if (!$ok || count($message) != $message_count)
433 433
 			{
434 434
 				// Add links for new / edit definition
435 435
 				$config = config::read('importexport');
436
-				if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions'])
436
+				if ($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions'])
437 437
 				{
438 438
 					$actions = '';
439 439
 					// New definition
440
-					$add_link = egw::link('/index.php',array(
440
+					$add_link = egw::link('/index.php', array(
441 441
 						'menuaction' => 'importexport.importexport_definitions_ui.edit',
442 442
 						'application' => $definition->application,
443 443
 						'plugin' => $definition->plugin,
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 							'menuaction' => 'importexport.importexport_import_ui.import_dialog',
450 450
 							// Don't set appname, or user won't be able to select & see their new definition
451 451
 							//'appname' => $definition->application,
452
-						)) . "';
452
+						))."';
453 453
 						egw_openWindowCentered2('$add_link','_blank',500,500,'yes');
454 454
 					";
455 455
 					$actions[] = lang('Create a <a href="%1">new definition</a> for this file', $add_link);
456 456
 
457 457
 					// Edit selected definition, if allowed
458
-					if($definition->owner == $GLOBALS['egw_info']['user']['account_id'] ||
458
+					if ($definition->owner == $GLOBALS['egw_info']['user']['account_id'] ||
459 459
 						!$definition->owner && $GLOBALS['egw_info']['user']['apps']['admin'])
460 460
 					{
461 461
 						$edit_link = array(
@@ -464,20 +464,20 @@  discard block
 block discarded – undo
464 464
 							// Jump to file step
465 465
 							'step' => 'wizard_step21'
466 466
 						);
467
-						if($dst_file)
467
+						if ($dst_file)
468 468
 						{
469 469
 							// Still have uploaded file, jump there
470
-							$GLOBALS['egw']->session->appsession('csvfile','',$dst_file);
470
+							$GLOBALS['egw']->session->appsession('csvfile', '', $dst_file);
471 471
 							$edit_link['step'] = 'wizard_step30';
472 472
 						}
473
-						$edit_link = egw::link('/index.php',$edit_link);
473
+						$edit_link = egw::link('/index.php', $edit_link);
474 474
 						$edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')";
475 475
 						$actions[] = lang('Edit definition <a href="%1">%2</a> to match your file',
476
-							$edit_link, $definition->name );
476
+							$edit_link, $definition->name);
477 477
 					}
478
-					$actions[] = lang('Edit your file to match the definition:') . ' '
479
-					. implode(array_map('lang',array_intersect_key($options['csv_fields'],$options['field_mapping'])),', ');
480
-					$message[] = "\n<li>".implode($actions,"\n<li>");
478
+					$actions[] = lang('Edit your file to match the definition:').' '
479
+					. implode(array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])), ', ');
480
+					$message[] = "\n<li>".implode($actions, "\n<li>");
481 481
 				}
482 482
 			}
483 483
 			return $ok;
Please login to merge, or discard this patch.
infolog/inc/class.infolog_import_infologs_csv.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@  discard block
 block discarded – undo
108 108
 	/**
109 109
 	 * imports entries according to given definition object.
110 110
 	 * @param resource $_stream
111
-	 * @param string $_charset
112
-	 * @param definition $_definition
111
+	 * @param importexport_definition $_definition
113 112
 	 */
114 113
 	public function import( $_stream, importexport_definition $_definition ) {
115 114
 		$import_csv = new importexport_import_csv( $_stream, array(
@@ -527,6 +526,7 @@  discard block
 block discarded – undo
527 526
 	 *
528 527
 	 * This is a copy of what's in importexport_basic_import_csv, and can go
529 528
 	 * away if this is changed to extend it
529
+	 * @param integer $record_num
530 530
 	 */
531 531
 	protected function link_by_cf($record_num, $app, $fieldname, $_value)
532 532
 	{
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	private $boinfolog;
75 75
 
76 76
 	/**
77
-	* For figuring out if a record has changed
78
-	*
79
-	* @var infolog_tracking::
80
-	*/
77
+	 * For figuring out if a record has changed
78
+	 *
79
+	 * @var infolog_tracking::
80
+	 */
81 81
 	protected $tracking;
82 82
 
83 83
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	protected $errors = array();
102 102
 
103 103
 	/**
104
- 	* List of actions, and how many times that action was taken
104
+	 * List of actions, and how many times that action was taken
105 105
 	 */
106 106
 	protected $results = array();
107 107
 
@@ -466,37 +466,37 @@  discard block
 block discarded – undo
466 466
 	}
467 467
 
468 468
 	/**
469
-	* Returns warnings that were encountered during importing
470
-	* Maximum of one warning message per record, but you can append if you need to
471
-	*
472
-	* @return Array (
473
-	*       record_# => warning message
474
-	*       )
475
-	*/
469
+	 * Returns warnings that were encountered during importing
470
+	 * Maximum of one warning message per record, but you can append if you need to
471
+	 *
472
+	 * @return Array (
473
+	 *       record_# => warning message
474
+	 *       )
475
+	 */
476 476
 	public function get_warnings() {
477 477
 		return $this->warnings;
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Returns errors that were encountered during importing
482
-	* Maximum of one error message per record, but you can append if you need to
483
-	*
484
-	* @return Array (
485
-	*       record_# => error message
486
-	*       )
487
-	*/
481
+	 * Returns errors that were encountered during importing
482
+	 * Maximum of one error message per record, but you can append if you need to
483
+	 *
484
+	 * @return Array (
485
+	 *       record_# => error message
486
+	 *       )
487
+	 */
488 488
 	public function get_errors() {
489 489
 		return $this->errors;
490 490
 	}
491 491
 
492 492
 	/**
493
-	* Returns a list of actions taken, and the number of records for that action.
494
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
495
-	*
496
-	* @return Array (
497
-	*       action => record count
498
-	* )
499
-	*/
493
+	 * Returns a list of actions taken, and the number of records for that action.
494
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
495
+	 *
496
+	 * @return Array (
497
+	 *       action => record count
498
+	 * )
499
+	 */
500 500
 	public function get_results() {
501 501
 		return $this->results;
502 502
 	}
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * class import_csv for infolog
16 16
  */
17
-class infolog_import_infologs_csv implements importexport_iface_import_plugin  {
17
+class infolog_import_infologs_csv implements importexport_iface_import_plugin {
18 18
 
19 19
 	private static $plugin_options = array(
20
-		'fieldsep', 		// char
21
-		'charset', 			// string
22
-		'contact_owner', 	// int
23
-		'update_cats', 			// string {override|add} overides record
20
+		'fieldsep', // char
21
+		'charset', // string
22
+		'contact_owner', // int
23
+		'update_cats', // string {override|add} overides record
24 24
 								// with cat(s) from csv OR add the cat from
25 25
 								// csv file to exeisting cat(s) of record
26 26
 		'num_header_lines', // int number of header lines
27 27
 		'field_conversion', // array( $csv_col_num => conversion)
28
-		'field_mapping',	// array( $csv_col_num => adb_filed)
29
-		'conditions',		/* => array containing condition arrays:
28
+		'field_mapping', // array( $csv_col_num => adb_filed)
29
+		'conditions', /* => array containing condition arrays:
30 30
 				'type' => exists, // exists
31 31
 				'string' => '#kundennummer',
32 32
 				'true' => array(
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * actions wich could be done to data entries
54 54
 	 */
55
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
55
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
56 56
 
57 57
 	/**
58 58
 	 * conditions for actions
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	protected static $conditions = array( 'exists' );
62
+	protected static $conditions = array('exists');
63 63
 
64 64
 	/**
65 65
 	 * @var definition
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param string $_charset
110 110
 	 * @param definition $_definition
111 111
 	 */
112
-	public function import( $_stream, importexport_definition $_definition ) {
113
-		$import_csv = new importexport_import_csv( $_stream, array(
112
+	public function import($_stream, importexport_definition $_definition) {
113
+		$import_csv = new importexport_import_csv($_stream, array(
114 114
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
115 115
 			'charset' => $_definition->plugin_options['charset'],
116 116
 		));
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
121 121
 
122 122
 		// dry run?
123
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
123
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
124 124
 
125 125
 		// fetch the infolog bo
126 126
 		$this->boinfolog = new infolog_bo();
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 		$import_csv->conversion_class = $this;
142 142
 
143 143
 		//check if file has a header lines
144
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
144
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
145 145
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
146
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
146
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
147 147
 			// First method is preferred
148 148
 			$import_csv->skip_records(1);
149 149
 		}
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
 		$this->errors = array();
169 169
 		$this->warnings = array();
170 170
 
171
-		while ( $record = $import_csv->get_record() ) {
171
+		while ($record = $import_csv->get_record()) {
172 172
 			$success = false;
173 173
 
174 174
 			// don't import empty records
175
-			if( count( array_unique( $record ) ) < 2 ) continue;
175
+			if (count(array_unique($record)) < 2) continue;
176 176
 
177 177
 			$lookups = $_lookups;
178 178
 
179 179
 			// Early detection of type, to load appropriate statuses
180
-			foreach(array($lookups['info_type'], array_map('strtolower',array_map('lang',$lookups['info_type']))) as $types)
180
+			foreach (array($lookups['info_type'], array_map('strtolower', array_map('lang', $lookups['info_type']))) as $types)
181 181
 			{
182
-				if($record['info_type'] && $key = array_search(strtolower($record['info_type']),$types))
182
+				if ($record['info_type'] && $key = array_search(strtolower($record['info_type']), $types))
183 183
 				{
184 184
 					$lookups['info_status'] = $this->boinfolog->status[$key];
185 185
 					break;
@@ -187,34 +187,34 @@  discard block
 block discarded – undo
187 187
 			}
188 188
 
189 189
 			$result = importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']);
190
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
190
+			if ($result) $this->warnings[$import_csv->get_current_position()] = $result;
191 191
 
192 192
 			// Make sure type is valid
193
-			if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
193
+			if (!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
194 194
 			{
195 195
 				// Check for translated type
196
-				$un_trans = translation::get_message_id($record['info_type'],'infolog');
197
-				if($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
196
+				$un_trans = translation::get_message_id($record['info_type'], 'infolog');
197
+				if ($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
198 198
 				{
199 199
 					$record['info_type'] = $un_trans;
200 200
 				}
201 201
 				else
202 202
 				{
203
-					$this->errors[$import_csv->get_current_position()] .= ($this->errors[$import_csv->get_current_position()] ? "\n":'').
203
+					$this->errors[$import_csv->get_current_position()] .= ($this->errors[$import_csv->get_current_position()] ? "\n" : '').
204 204
 						lang('Unknown type: %1', $record['info_type']);
205 205
 				}
206 206
 			}
207 207
 
208 208
 			// Set default status for type, if not specified
209
-			if(!$record['info_status'] && $record['info_type'])
209
+			if (!$record['info_status'] && $record['info_type'])
210 210
 			{
211 211
 				$record['info_status'] = $this->boinfolog->status['defaults'][$record['info_type']];
212 212
 			}
213 213
 
214 214
 			// Set owner, unless it's supposed to come from CSV file
215
-			if($_definition->plugin_options['owner_from_csv'])
215
+			if ($_definition->plugin_options['owner_from_csv'])
216 216
 			{
217
-				if(!is_numeric($record['info_owner']))
217
+				if (!is_numeric($record['info_owner']))
218 218
 				{
219 219
 					$this->errors[$import_csv->get_current_position()] = lang(
220 220
 						'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
@@ -231,51 +231,51 @@  discard block
 block discarded – undo
231 231
 			if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
232 232
 
233 233
 			// Responsible has to be an array
234
-			$record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0;
234
+			$record['info_responsible'] = $record['info_responsible'] ? explode(',', $record['info_responsible']) : 0;
235 235
 
236 236
 			// Special values
237 237
 			if ($record['addressbook'] && !is_numeric($record['addressbook']))
238 238
 			{
239
-				list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
240
-				$record['addressbook'] = importexport_basic_import_csv::addr_id($lastname,$firstname,$org_name);
239
+				list($lastname, $firstname, $org_name) = explode(',', $record['addressbook']);
240
+				$record['addressbook'] = importexport_basic_import_csv::addr_id($lastname, $firstname, $org_name);
241 241
 			}
242 242
 			if ($record['projectmanager'] && !is_numeric($record['projectmanager']))
243 243
 			{
244 244
 				$record['projectmanager'] = self::project_id($record['projectmanager']);
245 245
 			}
246 246
 
247
-			if ( $_definition->plugin_options['conditions'] )
247
+			if ($_definition->plugin_options['conditions'])
248 248
 			{
249
-				foreach ( $_definition->plugin_options['conditions'] as $condition )
249
+				foreach ($_definition->plugin_options['conditions'] as $condition)
250 250
 				{
251 251
 					$results = array();
252
-					switch ( $condition['type'] )
252
+					switch ($condition['type'])
253 253
 					{
254 254
 						// exists
255 255
 						case 'exists' :
256
-							if($record[$condition['string']]) {
257
-								$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
256
+							if ($record[$condition['string']]) {
257
+								$query['col_filter'] = array($condition['string'] => $record[$condition['string']],);
258 258
 								// Needed to query custom fields
259
-								if($condition['string'][0] == '#') $query['custom_fields'] = true;
259
+								if ($condition['string'][0] == '#') $query['custom_fields'] = true;
260 260
 								$results = $this->boinfolog->search($query);
261 261
 							}
262 262
 
263
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
263
+							if (is_array($results) && count(array_keys($results)) >= 1) {
264 264
 								// apply action to all records matching this exists condition
265 265
 								$action = $condition['true'];
266
-								foreach ( (array)$results as $contact ) {
266
+								foreach ((array)$results as $contact) {
267 267
 									$record['info_id'] = $contact['info_id'];
268 268
 									$record['info_owner'] = $contact['info_owner'];
269
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
270
-										if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
271
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
272
-										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $contact['cat_id'] ) ) );
269
+									if ($_definition->plugin_options['update_cats'] == 'add') {
270
+										if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']);
271
+										if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
272
+										$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $contact['cat_id'])));
273 273
 									}
274
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
274
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
275 275
 								}
276 276
 							} else {
277 277
 								$action = $condition['false'];
278
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
278
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
279 279
 							}
280 280
 							break;
281 281
 
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 			else
291 291
 			{
292 292
 				// unconditional insert
293
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
293
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
294 294
 			}
295
-			if($success) $count++;
296
-			if($this->warnings[$import_csv->get_current_position()]) {
297
-				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
295
+			if ($success) $count++;
296
+			if ($this->warnings[$import_csv->get_current_position()]) {
297
+				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n".array2string($record);
298 298
 			}
299
-			if($this->errors[$import_csv->get_current_position()]) {
300
-				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
299
+			if ($this->errors[$import_csv->get_current_position()]) {
300
+				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n".array2string($record);
301 301
 			}
302 302
 		}
303 303
 		return $count;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * @param array $_data contact data for the action
311 311
 	 * @return bool success or not
312 312
 	 */
313
-	private function action ( $_action, $_data, $record_num = 0 ) {
313
+	private function action($_action, $_data, $record_num = 0) {
314 314
 		$result = true;
315 315
 		switch ($_action) {
316 316
 			case 'none' :
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 				// Only update if there are changes
320 320
 				$old = $this->boinfolog->read($_data['info_id']);
321 321
 
322
-				if(!$this->definition->plugin_options['change_owner']) {
322
+				if (!$this->definition->plugin_options['change_owner']) {
323 323
 					// Don't change addressbook of an existing contact
324 324
 					unset($_data['owner']);
325 325
 				}
@@ -327,19 +327,19 @@  discard block
 block discarded – undo
327 327
 				// Merge to deal with fields not in import record
328 328
 				$_data = array_merge($old, $_data);
329 329
 				$changed = $this->tracking->changed_fields($_data, $old);
330
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
330
+				if (count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
331 331
 					break;
332 332
 				}
333 333
 
334 334
 				// Fall through
335 335
 			case 'insert' :
336
-				if ( $this->dry_run ) {
336
+				if ($this->dry_run) {
337 337
 					//print_r($_data);
338 338
 
339 339
 					// Check for link during dry run
340
-					if($_data['link_custom'])
340
+					if ($_data['link_custom'])
341 341
 					{
342
-						list($app, $app_id) = explode(':', $_data['link_custom'],2);
342
+						list($app, $app_id) = explode(':', $_data['link_custom'], 2);
343 343
 						$app_id = $this->link_by_cf($record_num, $app, $field, $app_id);
344 344
 					}
345 345
 
@@ -347,12 +347,12 @@  discard block
 block discarded – undo
347 347
 					break;
348 348
 				} else {
349 349
 					$result = $this->boinfolog->write(
350
-						$_data, true, 2,true, 	// 2 = dont touch modification date
350
+						$_data, true, 2, true, // 2 = dont touch modification date
351 351
 						$this->definition->plugin_options['no_notification']
352 352
 					);
353
-					if(!$result)
353
+					if (!$result)
354 354
 					{
355
-						if($result === false)
355
+						if ($result === false)
356 356
 						{
357 357
 							$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
358 358
 								$GLOBALS['egw']->accounts->id2name($_data['info_owner']),
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 		}
376 376
 
377 377
 		// Process some additional fields
378
-		if(!is_numeric($result)) {
378
+		if (!is_numeric($result)) {
379 379
 			return $result;
380 380
 		}
381 381
 		$info_link_id = $_data['info_link_id'];
382
-		foreach(self::$special_fields as $field => $desc) {
383
-			if(!$_data[$field]) continue;
384
-			if(strpos($field, 'link') === 0) {
385
-				list($app, $app_id) = explode(':', $_data[$field],2);
382
+		foreach (self::$special_fields as $field => $desc) {
383
+			if (!$_data[$field]) continue;
384
+			if (strpos($field, 'link') === 0) {
385
+				list($app, $app_id) = explode(':', $_data[$field], 2);
386 386
 
387 387
 				// Linking to another entry based on matching custom fields
388
-				if($field == 'link_custom')
388
+				if ($field == 'link_custom')
389 389
 				{
390 390
 					$app_id = $this->link_by_cf($record_num, $app, $field, $app_id);
391 391
 				}
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 			if ($app && $app_id) {
397 397
 				$id = $_data['info_id'] ? $_data['info_id'] : (int)$result;
398 398
 				//echo "<p>linking infolog:$id with $app:$app_id</p>\n";
399
-				$link_id = egw_link::link('infolog',$id,$app,$app_id);
399
+				$link_id = egw_link::link('infolog', $id, $app, $app_id);
400 400
 				if ($link_id && !$info_link_id)
401 401
 				{
402 402
 					$to_write = array(
403 403
 						'info_id'      => $id,
404 404
 						'info_link_id' => $link_id,
405 405
 					);
406
-					$this->boinfolog->write($to_write,False,false,true,true);	// last true = no notifications, as no real change
406
+					$this->boinfolog->write($to_write, False, false, true, true); // last true = no notifications, as no real change
407 407
 					$info_link_id = $link_id;
408 408
 				}
409 409
 			}
@@ -530,18 +530,18 @@  discard block
 block discarded – undo
530 530
 	{
531 531
 		$app_id = false;
532 532
 
533
-		list($custom_field, $value) = explode(':',$value);
533
+		list($custom_field, $value) = explode(':', $value);
534 534
 		// Find matching entry
535
-		if($app && $custom_field && $value)
535
+		if ($app && $custom_field && $value)
536 536
 		{
537 537
 			$cfs = config::get_customfields($app);
538 538
 			// Error if no custom fields, probably something wrong in definition
539
-			if(!$cfs[$custom_field])
539
+			if (!$cfs[$custom_field])
540 540
 			{
541 541
 				// Check for users specifing label instead of name
542
-				foreach($cfs as $name => $settings)
542
+				foreach ($cfs as $name => $settings)
543 543
 				{
544
-					if(strtolower($settings['label']) == strtolower($custom_field))
544
+					if (strtolower($settings['label']) == strtolower($custom_field))
545 545
 					{
546 546
 						$custom_field = $name;
547 547
 						break;
@@ -550,23 +550,23 @@  discard block
 block discarded – undo
550 550
 			}
551 551
 
552 552
 			// Couldn't find field, give an error - something's wrong
553
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
553
+			if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) {
554 554
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
555 555
 					$custom_field, lang($app));
556 556
 				return false;
557 557
 			}
558
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
558
+			if ($custom_field[0] != '#') $custom_field = '#'.$custom_field;
559 559
 
560 560
 			// Search
561
-			if(egw_link::get_registry($app, 'query'))
561
+			if (egw_link::get_registry($app, 'query'))
562 562
 			{
563
-				$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
563
+				$options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value)));
564 564
 				$result = egw_link::query($app, '', $options);
565 565
 
566 566
 				// Only one allowed
567
-				if(count($result) != 1)
567
+				if (count($result) != 1)
568 568
 				{
569
-					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
569
+					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '').
570 570
 						lang('Unable to link to %3 by custom field "%1": "%4".  %2 matches.',
571 571
 						$custom_field, count($result), lang($app), $options['filter'][0]
572 572
 					);
Please login to merge, or discard this patch.
Braces   +112 added lines, -43 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * class import_csv for infolog
16 16
  */
17
-class infolog_import_infologs_csv implements importexport_iface_import_plugin  {
17
+class infolog_import_infologs_csv implements importexport_iface_import_plugin
18
+{
18 19
 
19 20
 	private static $plugin_options = array(
20 21
 		'fieldsep', 		// char
@@ -109,7 +110,8 @@  discard block
 block discarded – undo
109 110
 	 * @param string $_charset
110 111
 	 * @param definition $_definition
111 112
 	 */
112
-	public function import( $_stream, importexport_definition $_definition ) {
113
+	public function import( $_stream, importexport_definition $_definition )
114
+	{
113 115
 		$import_csv = new importexport_import_csv( $_stream, array(
114 116
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
115 117
 			'charset' => $_definition->plugin_options['charset'],
@@ -141,9 +143,12 @@  discard block
 block discarded – undo
141 143
 		$import_csv->conversion_class = $this;
142 144
 
143 145
 		//check if file has a header lines
144
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
146
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
147
+		{
145 148
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
146
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
149
+		}
150
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
151
+		{
147 152
 			// First method is preferred
148 153
 			$import_csv->skip_records(1);
149 154
 		}
@@ -168,11 +173,15 @@  discard block
 block discarded – undo
168 173
 		$this->errors = array();
169 174
 		$this->warnings = array();
170 175
 
171
-		while ( $record = $import_csv->get_record() ) {
176
+		while ( $record = $import_csv->get_record() )
177
+		{
172 178
 			$success = false;
173 179
 
174 180
 			// don't import empty records
175
-			if( count( array_unique( $record ) ) < 2 ) continue;
181
+			if( count( array_unique( $record ) ) < 2 )
182
+			{
183
+				continue;
184
+			}
176 185
 
177 186
 			$lookups = $_lookups;
178 187
 
@@ -187,7 +196,10 @@  discard block
 block discarded – undo
187 196
 			}
188 197
 
189 198
 			$result = importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']);
190
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
199
+			if($result)
200
+			{
201
+				$this->warnings[$import_csv->get_current_position()] = $result;
202
+			}
191 203
 
192 204
 			// Make sure type is valid
193 205
 			if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
@@ -228,7 +240,10 @@  discard block
 block discarded – undo
228 240
 			{
229 241
 				$record['info_owner'] = $_definition->plugin_options['record_owner'];
230 242
 			}
231
-			if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
243
+			if (!isset($record['info_owner']))
244
+			{
245
+				$record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
246
+			}
232 247
 
233 248
 			// Responsible has to be an array
234 249
 			$record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0;
@@ -253,27 +268,42 @@  discard block
 block discarded – undo
253 268
 					{
254 269
 						// exists
255 270
 						case 'exists' :
256
-							if($record[$condition['string']]) {
271
+							if($record[$condition['string']])
272
+							{
257 273
 								$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
258 274
 								// Needed to query custom fields
259
-								if($condition['string'][0] == '#') $query['custom_fields'] = true;
275
+								if($condition['string'][0] == '#')
276
+								{
277
+									$query['custom_fields'] = true;
278
+								}
260 279
 								$results = $this->boinfolog->search($query);
261 280
 							}
262 281
 
263
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
282
+							if ( is_array( $results ) && count( array_keys( $results )) >= 1)
283
+							{
264 284
 								// apply action to all records matching this exists condition
265 285
 								$action = $condition['true'];
266
-								foreach ( (array)$results as $contact ) {
286
+								foreach ( (array)$results as $contact )
287
+								{
267 288
 									$record['info_id'] = $contact['info_id'];
268 289
 									$record['info_owner'] = $contact['info_owner'];
269
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
270
-										if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
271
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
290
+									if ( $_definition->plugin_options['update_cats'] == 'add' )
291
+									{
292
+										if ( !is_array( $contact['cat_id'] ) )
293
+										{
294
+											$contact['cat_id'] = explode( ',', $contact['cat_id'] );
295
+										}
296
+										if ( !is_array( $record['cat_id'] ) )
297
+										{
298
+											$record['cat_id'] = explode( ',', $record['cat_id'] );
299
+										}
272 300
 										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $contact['cat_id'] ) ) );
273 301
 									}
274 302
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
275 303
 								}
276
-							} else {
304
+							}
305
+							else
306
+							{
277 307
 								$action = $condition['false'];
278 308
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
279 309
 							}
@@ -284,7 +314,10 @@  discard block
 block discarded – undo
284 314
 							die('condition / action not supported!!!');
285 315
 							break;
286 316
 					}
287
-					if ($action['last']) break;
317
+					if ($action['last'])
318
+					{
319
+						break;
320
+					}
288 321
 				}
289 322
 			}
290 323
 			else
@@ -292,11 +325,16 @@  discard block
 block discarded – undo
292 325
 				// unconditional insert
293 326
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
294 327
 			}
295
-			if($success) $count++;
296
-			if($this->warnings[$import_csv->get_current_position()]) {
328
+			if($success)
329
+			{
330
+				$count++;
331
+			}
332
+			if($this->warnings[$import_csv->get_current_position()])
333
+			{
297 334
 				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
298 335
 			}
299
-			if($this->errors[$import_csv->get_current_position()]) {
336
+			if($this->errors[$import_csv->get_current_position()])
337
+			{
300 338
 				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
301 339
 			}
302 340
 		}
@@ -310,16 +348,19 @@  discard block
 block discarded – undo
310 348
 	 * @param array $_data contact data for the action
311 349
 	 * @return bool success or not
312 350
 	 */
313
-	private function action ( $_action, $_data, $record_num = 0 ) {
351
+	private function action ( $_action, $_data, $record_num = 0 )
352
+	{
314 353
 		$result = true;
315
-		switch ($_action) {
354
+		switch ($_action)
355
+		{
316 356
 			case 'none' :
317 357
 				return true;
318 358
 			case 'update' :
319 359
 				// Only update if there are changes
320 360
 				$old = $this->boinfolog->read($_data['info_id']);
321 361
 
322
-				if(!$this->definition->plugin_options['change_owner']) {
362
+				if(!$this->definition->plugin_options['change_owner'])
363
+				{
323 364
 					// Don't change addressbook of an existing contact
324 365
 					unset($_data['owner']);
325 366
 				}
@@ -327,13 +368,15 @@  discard block
 block discarded – undo
327 368
 				// Merge to deal with fields not in import record
328 369
 				$_data = array_merge($old, $_data);
329 370
 				$changed = $this->tracking->changed_fields($_data, $old);
330
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
371
+				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
372
+				{
331 373
 					break;
332 374
 				}
333 375
 
334 376
 				// Fall through
335 377
 			case 'insert' :
336
-				if ( $this->dry_run ) {
378
+				if ( $this->dry_run )
379
+				{
337 380
 					//print_r($_data);
338 381
 
339 382
 					// Check for link during dry run
@@ -345,7 +388,9 @@  discard block
 block discarded – undo
345 388
 
346 389
 					$this->results[$_action]++;
347 390
 					break;
348
-				} else {
391
+				}
392
+				else
393
+				{
349 394
 					$result = $this->boinfolog->write(
350 395
 						$_data, true, 2,true, 	// 2 = dont touch modification date
351 396
 						$this->definition->plugin_options['no_notification']
@@ -375,13 +420,19 @@  discard block
 block discarded – undo
375 420
 		}
376 421
 
377 422
 		// Process some additional fields
378
-		if(!is_numeric($result)) {
423
+		if(!is_numeric($result))
424
+		{
379 425
 			return $result;
380 426
 		}
381 427
 		$info_link_id = $_data['info_link_id'];
382
-		foreach(self::$special_fields as $field => $desc) {
383
-			if(!$_data[$field]) continue;
384
-			if(strpos($field, 'link') === 0) {
428
+		foreach(self::$special_fields as $field => $desc)
429
+		{
430
+			if(!$_data[$field])
431
+			{
432
+				continue;
433
+			}
434
+			if(strpos($field, 'link') === 0)
435
+			{
385 436
 				list($app, $app_id) = explode(':', $_data[$field],2);
386 437
 
387 438
 				// Linking to another entry based on matching custom fields
@@ -389,11 +440,14 @@  discard block
 block discarded – undo
389 440
 				{
390 441
 					$app_id = $this->link_by_cf($record_num, $app, $field, $app_id);
391 442
 				}
392
-			} else {
443
+			}
444
+			else
445
+			{
393 446
 				$app = $field;
394 447
 				$app_id = $_data[$field];
395 448
 			}
396
-			if ($app && $app_id) {
449
+			if ($app && $app_id)
450
+			{
397 451
 				$id = $_data['info_id'] ? $_data['info_id'] : (int)$result;
398 452
 				//echo "<p>linking infolog:$id with $app:$app_id</p>\n";
399 453
 				$link_id = egw_link::link('infolog',$id,$app,$app_id);
@@ -416,7 +470,8 @@  discard block
 block discarded – undo
416 470
 	 *
417 471
 	 * @return string name
418 472
 	 */
419
-	public static function get_name() {
473
+	public static function get_name()
474
+	{
420 475
 		return lang('Infolog CSV import');
421 476
 	}
422 477
 
@@ -425,7 +480,8 @@  discard block
 block discarded – undo
425 480
 	 *
426 481
 	 * @return string descriprion
427 482
 	 */
428
-	public static function get_description() {
483
+	public static function get_description()
484
+	{
429 485
 		return lang("Imports entries into the infolog from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
430 486
 	}
431 487
 
@@ -434,7 +490,8 @@  discard block
 block discarded – undo
434 490
 	 *
435 491
 	 * @return string suffix (comma seperated)
436 492
 	 */
437
-	public static function get_filesuffix() {
493
+	public static function get_filesuffix()
494
+	{
438 495
 		return 'csv';
439 496
 	}
440 497
 
@@ -450,7 +507,8 @@  discard block
 block discarded – undo
450 507
 	 * 		preserv		=> array,
451 508
 	 * )
452 509
 	 */
453
-	public function get_options_etpl() {
510
+	public function get_options_etpl()
511
+	{
454 512
 		// lets do it!
455 513
 	}
456 514
 
@@ -459,7 +517,8 @@  discard block
 block discarded – undo
459 517
 	 *
460 518
 	 * @return string etemplate name
461 519
 	 */
462
-	public function get_selectors_etpl() {
520
+	public function get_selectors_etpl()
521
+	{
463 522
 		// lets do it!
464 523
 	}
465 524
 
@@ -471,7 +530,8 @@  discard block
 block discarded – undo
471 530
 	*       record_# => warning message
472 531
 	*       )
473 532
 	*/
474
-	public function get_warnings() {
533
+	public function get_warnings()
534
+	{
475 535
 		return $this->warnings;
476 536
 	}
477 537
 
@@ -483,7 +543,8 @@  discard block
 block discarded – undo
483 543
 	*       record_# => error message
484 544
 	*       )
485 545
 	*/
486
-	public function get_errors() {
546
+	public function get_errors()
547
+	{
487 548
 		return $this->errors;
488 549
 	}
489 550
 
@@ -495,7 +556,8 @@  discard block
 block discarded – undo
495 556
 	*       action => record count
496 557
 	* )
497 558
 	*/
498
-	public function get_results() {
559
+	public function get_results()
560
+	{
499 561
 		return $this->results;
500 562
 	}
501 563
 	// end of iface_export_plugin
@@ -505,7 +567,10 @@  discard block
 block discarded – undo
505 567
 	{
506 568
 		static $boprojects;
507 569
 
508
-		if (!$num_or_title) return false;
570
+		if (!$num_or_title)
571
+		{
572
+			return false;
573
+		}
509 574
 
510 575
 		if (!is_object($boprojects))
511 576
 		{
@@ -550,12 +615,16 @@  discard block
 block discarded – undo
550 615
 			}
551 616
 
552 617
 			// Couldn't find field, give an error - something's wrong
553
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
618
+			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)])
619
+			{
554 620
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
555 621
 					$custom_field, lang($app));
556 622
 				return false;
557 623
 			}
558
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
624
+			if($custom_field[0] != '#')
625
+			{
626
+				$custom_field = '#' . $custom_field;
627
+			}
559 628
 
560 629
 			// Search
561 630
 			if(egw_link::get_registry($app, 'query'))
Please login to merge, or discard this patch.
infolog/inc/class.infolog_tracking.inc.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,6 @@
 block discarded – undo
125 125
 	/**
126 126
 	 * Constructor
127 127
 	 *
128
-	 * @param botracker $botracker
129 128
 	 * @return tracker_tracking
130 129
 	 */
131 130
 	function __construct(&$infolog_bo)
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	function __construct(&$infolog_bo)
129 129
 	{
130
-		parent::__construct('infolog');	// add custom fields from infolog
130
+		parent::__construct('infolog'); // add custom fields from infolog
131 131
 
132
-		$this->infolog =& $infolog_bo;
132
+		$this->infolog = & $infolog_bo;
133 133
 	}
134 134
 
135 135
 	/**
@@ -141,23 +141,23 @@  discard block
 block discarded – undo
141 141
 	 * @param array $old
142 142
 	 * @return string
143 143
 	 */
144
-	function get_subject($data,$old)
144
+	function get_subject($data, $old)
145 145
 	{
146 146
 		if ($data['prefix'])
147 147
 		{
148
-			$prefix = $data['prefix'];	// async notification
148
+			$prefix = $data['prefix']; // async notification
149 149
 		}
150 150
 		elseif (!$old || $old['info_status'] == 'deleted')
151 151
 		{
152
-			$prefix = lang('New %1',lang($this->infolog->enums['type'][$data['info_type']]));
152
+			$prefix = lang('New %1', lang($this->infolog->enums['type'][$data['info_type']]));
153 153
 		}
154
-		elseif($data['info_status'] == 'deleted')
154
+		elseif ($data['info_status'] == 'deleted')
155 155
 		{
156
-			$prefix = lang('%1 deleted',lang($this->infolog->enums['type'][$data['info_type']]));
156
+			$prefix = lang('%1 deleted', lang($this->infolog->enums['type'][$data['info_type']]));
157 157
 		}
158 158
 		else
159 159
 		{
160
-			$prefix = lang('%1 modified',lang($this->infolog->enums['type'][$data['info_type']]));
160
+			$prefix = lang('%1 modified', lang($this->infolog->enums['type'][$data['info_type']]));
161 161
 		}
162 162
 		return $prefix.': '.$data['info_subject'];
163 163
 	}
@@ -169,22 +169,22 @@  discard block
 block discarded – undo
169 169
 	 * @param array $old
170 170
 	 * @return string
171 171
 	 */
172
-	function get_message($data,$old)
172
+	function get_message($data, $old)
173 173
 	{
174
-		if ($data['message']) return $data['message'];	// async notification
174
+		if ($data['message']) return $data['message']; // async notification
175 175
 
176 176
 		if (!$old || $old['info_status'] == 'deleted')
177 177
 		{
178
-			return lang('New %1 created by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
179
-				common::grab_owner_name($this->infolog->user),$this->datetime('now'));
178
+			return lang('New %1 created by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
179
+				common::grab_owner_name($this->infolog->user), $this->datetime('now'));
180 180
 		}
181
-		elseif($data['info_status'] == 'deleted')
181
+		elseif ($data['info_status'] == 'deleted')
182 182
 		{
183
-			return lang('%1 deleted by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
183
+			return lang('%1 deleted by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
184 184
 				common::grab_owner_name($data['info_modifier']),
185 185
 				$this->datetime($data['info_datemodified']));
186 186
 		}
187
-		return lang('%1 modified by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
187
+		return lang('%1 modified by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
188 188
 			common::grab_owner_name($data['info_modifier']),
189 189
 			$this->datetime($data['info_datemodified']));
190 190
 	}
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
 	 * @param int|string $receiver nummeric account_id or email address
197 197
 	 * @return array of details as array with values for keys 'label','value','type'
198 198
 	 */
199
-	function get_details($data,$receiver=null)
199
+	function get_details($data, $receiver = null)
200 200
 	{
201
-		unset($receiver);	// not used, but required function signature
201
+		unset($receiver); // not used, but required function signature
202 202
 		//error_log(__METHOD__.__LINE__.' Data:'.array2string($data));
203 203
 		$responsible = array();
204 204
 		if ($data['info_responsible'])
205 205
 		{
206
-			foreach($data['info_responsible'] as $uid)
206
+			foreach ($data['info_responsible'] as $uid)
207 207
 			{
208 208
 				$responsible[] = common::grab_owner_name($uid);
209 209
 			}
@@ -212,31 +212,31 @@  discard block
 block discarded – undo
212 212
 		{
213 213
 			$id = ' #'.$data['info_id'];
214 214
 		}
215
-		foreach(array(
215
+		foreach (array(
216 216
 			'info_type'      => lang($this->infolog->enums['type'][$data['info_type']]).$id,
217 217
 			'info_from'      => $data['info_from'],
218 218
 			'info_addr'      => $data['info_addr'],
219 219
 			'info_cat'       => $data['info_cat'] ? $GLOBALS['egw']->categories->id2name($data['info_cat']) : '',
220 220
 			'info_priority'  => lang($this->infolog->enums['priority'][$data['info_priority']]),
221 221
 			'info_owner'     => common::grab_owner_name($data['info_owner']),
222
-			'info_status'    => lang($data['info_status']=='deleted'?'deleted':$this->infolog->status[$data['info_type']][$data['info_status']]),
222
+			'info_status'    => lang($data['info_status'] == 'deleted' ? 'deleted' : $this->infolog->status[$data['info_type']][$data['info_status']]),
223 223
 			'info_percent'   => (int)$data['info_percent'].'%',
224 224
 			'info_datecompleted' => $data['info_datecompleted'] ? $this->datetime($data['info_datecompleted']) : '',
225 225
 			'info_location'  => $data['info_location'],
226
-			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'],null) : '',
227
-			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'],null) : '',
228
-			'info_responsible' => implode(', ',$responsible),
226
+			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'], null) : '',
227
+			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'], null) : '',
228
+			'info_responsible' => implode(', ', $responsible),
229 229
 			'info_subject'   => $data['info_subject'],
230 230
 		) as $name => $value)
231 231
 		{
232 232
 			//error_log(__METHOD__.__LINE__.' Key:'.$name.' val:'.array2string($value));
233
-			if ($name=='info_from' && empty($value) && !empty($data['info_contact']) && is_array($data['link_to']['to_id']))
233
+			if ($name == 'info_from' && empty($value) && !empty($data['info_contact']) && is_array($data['link_to']['to_id']))
234 234
 			{
235 235
 				$lkeys = array_keys($data['link_to']['to_id']);
236
-				if (in_array($data['info_contact'],$lkeys))
236
+				if (in_array($data['info_contact'], $lkeys))
237 237
 				{
238
-					list($app,$id) = explode(':',$data['info_contact']);
239
-					if (!empty($app)&&!empty($id)) $value = egw_link::title($app,$id);
238
+					list($app, $id) = explode(':', $data['info_contact']);
239
+					if (!empty($app) && !empty($id)) $value = egw_link::title($app, $id);
240 240
 				}
241 241
 			}
242 242
 			$details[$name] = array(
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @param boolean $skip_notification = false do NOT send any notification
269 269
 	 * @return int|boolean false on error, integer number of changes logged or true for new entries ($old == null)
270 270
 	 */
271
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null,$skip_notification=false)
271
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null, $skip_notification = false)
272 272
 	{
273 273
 		//error_log(__METHOD__.__LINE__.' notify?'.($skip_notification?'no':'yes').function_backtrace());
274 274
 		$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
@@ -277,23 +277,23 @@  discard block
 block discarded – undo
277 277
 
278 278
 		if ($old && $this->field2history)
279 279
 		{
280
-			$changes = $this->save_history($data,$old,$deleted,$changed_fields);
280
+			$changes = $this->save_history($data, $old, $deleted, $changed_fields);
281 281
 		}
282 282
 
283 283
 		// Don't notify if the only change was to the modified date
284
-		if(is_null($changed_fields))
284
+		if (is_null($changed_fields))
285 285
 		{
286 286
 			$changed_fields = $this->changed_fields($data, $old);
287 287
 			$changes = count($changed_fields); // we need that since TRUE evaluates to 1
288 288
 		}
289 289
 		//error_log(__METHOD__.__LINE__.array2string($changed_fields));
290
-		if(is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
290
+		if (is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
291 291
 		{
292 292
 			return count($changes);
293 293
 		}
294 294
 
295 295
 		// do not run do_notifications if we have no changes
296
-		if ($changes && !$skip_notification && !$this->do_notifications($data,$old,$deleted))
296
+		if ($changes && !$skip_notification && !$this->do_notifications($data, $old, $deleted))
297 297
 		{
298 298
 			$changes = false;
299 299
 		}
@@ -311,16 +311,16 @@  discard block
 block discarded – undo
311 311
 	 * @param array $old = null old/last state of the entry or null for a new entry
312 312
 	 * @return mixed
313 313
 	 */
314
-	function get_config($name,$data,$old=null)
314
+	function get_config($name, $data, $old = null)
315 315
 	{
316
-		unset($old);	// not used, but required function signature
317
-		switch($name)
316
+		unset($old); // not used, but required function signature
317
+		switch ($name)
318 318
 		{
319 319
 			case 'copy':	// include the info_cc addresses
320
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
320
+				if ($data['info_access'] == 'private') return array(); // no copies for private entries
321 321
 				if ($data['info_cc'])
322 322
 				{
323
-					$config = preg_split('/, ?/',$data['info_cc']);
323
+					$config = preg_split('/, ?/', $data['info_cc']);
324 324
 				}
325 325
 				else
326 326
 				{
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 				break;
330 330
 			case self::CUSTOM_NOTIFICATION:
331 331
 				$info_config = config::read('infolog');
332
-				if(!$info_config[self::CUSTOM_NOTIFICATION])
332
+				if (!$info_config[self::CUSTOM_NOTIFICATION])
333 333
 				{
334 334
 					return '';
335 335
 				}
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
339 339
 
340 340
 				// Disabled
341
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
341
+				if (!$type_config['use_custom'] && !$global['use_custom']) return '';
342 342
 
343 343
 				// Type or globabl
344 344
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
Braces   +22 added lines, -5 removed lines patch added patch discarded remove patch
@@ -171,7 +171,11 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	function get_message($data,$old)
173 173
 	{
174
-		if ($data['message']) return $data['message'];	// async notification
174
+		if ($data['message'])
175
+		{
176
+			return $data['message'];
177
+		}
178
+		// async notification
175 179
 
176 180
 		if (!$old || $old['info_status'] == 'deleted')
177 181
 		{
@@ -236,14 +240,20 @@  discard block
 block discarded – undo
236 240
 				if (in_array($data['info_contact'],$lkeys))
237 241
 				{
238 242
 					list($app,$id) = explode(':',$data['info_contact']);
239
-					if (!empty($app)&&!empty($id)) $value = egw_link::title($app,$id);
243
+					if (!empty($app)&&!empty($id))
244
+					{
245
+						$value = egw_link::title($app,$id);
246
+					}
240 247
 				}
241 248
 			}
242 249
 			$details[$name] = array(
243 250
 				'label' => lang($this->field2label[$name]),
244 251
 				'value' => $value,
245 252
 			);
246
-			if ($name == 'info_subject') $details[$name]['type'] = 'summary';
253
+			if ($name == 'info_subject')
254
+			{
255
+				$details[$name]['type'] = 'summary';
256
+			}
247 257
 		}
248 258
 		$details['info_des'] = array(
249 259
 			'value' => $data['info_des'],
@@ -317,7 +327,11 @@  discard block
 block discarded – undo
317 327
 		switch($name)
318 328
 		{
319 329
 			case 'copy':	// include the info_cc addresses
320
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
330
+				if ($data['info_access'] == 'private')
331
+				{
332
+					return array();
333
+				}
334
+				// no copies for private entries
321 335
 				if ($data['info_cc'])
322 336
 				{
323 337
 					$config = preg_split('/, ?/',$data['info_cc']);
@@ -338,7 +352,10 @@  discard block
 block discarded – undo
338 352
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
339 353
 
340 354
 				// Disabled
341
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
355
+				if(!$type_config['use_custom'] && !$global['use_custom'])
356
+				{
357
+					return '';
358
+				}
342 359
 
343 360
 				// Type or globabl
344 361
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
json.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
  * callback if the session-check fails, redirects to login.php, if no valid basic auth credentials given
19 19
  *
20 20
  * @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type'
21
- * @return boolean|string true if we allow anon access and anon_account is set, a sessionid or false otherwise
21
+ * @return string|null true if we allow anon access and anon_account is set, a sessionid or false otherwise
22 22
  */
23 23
 function login_redirect(&$anon_account)
24 24
 {
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,9 +73,12 @@
 block discarded – undo
73 73
 
74 74
 if (isset($_GET['menuaction']))
75 75
 {
76
-	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)	// static method name app_something::method
76
+	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)
77
+	{
78
+		// static method name app_something::method
77 79
 	{
78 80
 		@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
81
+	}
79 82
 
80 83
 		if (substr($className, 0, 11) == 'EGroupware\\')
81 84
 		{
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		return $session_id;
26 26
 	}
27 27
 	unset($anon_account);
28
-	egw_json_request::isJSONRequest(true);	// because egw_json_request::parseRequest() is not (yet) called
28
+	egw_json_request::isJSONRequest(true); // because egw_json_request::parseRequest() is not (yet) called
29 29
 	$response = egw_json_response::get();
30 30
 	$response->redirect($GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10', true);
31 31
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	$message = null;
51 51
 	if (function_exists('_egw_log_exception'))
52 52
 	{
53
-		_egw_log_exception($e,$message);
53
+		_egw_log_exception($e, $message);
54 54
 	}
55 55
 	$response = egw_json_response::get();
56 56
 	$message .= ($message ? "\n\n" : '').$e->getMessage();
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 
75 75
 if (isset($_GET['menuaction']))
76 76
 {
77
-	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)	// static method name app_something::method
77
+	if (strpos($_GET['menuaction'], '::') !== false && strpos($_GET['menuaction'], '.') === false)	// static method name app_something::method
78 78
 	{
79
-		@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
80
-		list($appName) = explode('_',$className);
79
+		@list($className, $functionName, $handler) = explode('::', $_GET['menuaction']);
80
+		list($appName) = explode('_', $className);
81 81
 	}
82 82
 	else
83 83
 	{
84
-		@list($appName, $className, $functionName, $handler) = explode('.',$_GET['menuaction']);
84
+		@list($appName, $className, $functionName, $handler) = explode('.', $_GET['menuaction']);
85 85
 	}
86 86
 	//error_log("json.php: appName=$appName, className=$className, functionName=$functionName, handler=$handler");
87 87
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'noheader'		=> True,
92 92
 			'disable_Template_class'	=> True,
93 93
 			'autocreate_session_callback' => 'login_redirect',
94
-			'no_exception_handler' => true,	// we already installed our own
94
+			'no_exception_handler' => true, // we already installed our own
95 95
 			// only log ajax requests which represent former GET requests or submits
96 96
 			// cuts down updates to egw_access_log table
97 97
 			'no_dla_update' => !preg_match('/(\.etemplate_new\.ajax_process_content\.etemplate|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']),
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	//Check whether the request data is set
107 107
 	if (isset($GLOBALS['egw_unset_vars']['_POST[json_data]']))
108 108
 	{
109
-		$json->isJSONRequest(true);	// otherwise exception is not send back to client, as we have not yet called parseRequest()
109
+		$json->isJSONRequest(true); // otherwise exception is not send back to client, as we have not yet called parseRequest()
110 110
 		throw new egw_exception_assertion_failed("JSON Data contains script tags. Aborting...");
111 111
 	}
112 112
 	$json->parseRequest($_GET['menuaction'], $_REQUEST['json_data']);
@@ -114,4 +114,4 @@  discard block
 block discarded – undo
114 114
 	common::egw_exit();
115 115
 }
116 116
 
117
-throw new Exception($_SERVER['PHP_SELF'] . ' Invalid AJAX JSON Request');
117
+throw new Exception($_SERVER['PHP_SELF'].' Invalid AJAX JSON Request');
Please login to merge, or discard this patch.
mail/inc/class.mail_acl.inc.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -277,8 +277,6 @@
 block discarded – undo
277 277
 	 * Update ACL rights of a folder or including subfolders for an account(s)
278 278
 	 *
279 279
 	 * @param array $content content including the acl rights
280
-	 * @param Boolean $recursive boolean flag FALSE|TRUE. If it is FALSE, only the folder take in to account, but in case of TRUE
281
-	 *		the mailbox including all its subfolders will be considered.
282 280
 	 * @param string $msg Message
283 281
 	 *
284 282
 	 */
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 */
35 35
 	var $aclRightsAbbrvs = array(
36
-		'lrs'		=> array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'),
37
-		'lprs'		=> array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
38
-		'ilprs'		=> array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
39
-		'ilprsw'	=> array('label'=>'write','title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
40
-		'aeiklprstwx'=> array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
41
-		'custom'	=> array('label'=>'custom','title'=>'User defined combination of rights for the ACL'),
36
+		'lrs'		=> array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'),
37
+		'lprs'		=> array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
38
+		'ilprs'		=> array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
39
+		'ilprsw'	=> array('label'=>'write', 'title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
40
+		'aeiklprstwx'=> array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
41
+		'custom'	=> array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'),
42 42
 	);
43 43
 
44 44
 	/**
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	 * @param array $msg = ''
62 62
 	 *
63 63
 	 */
64
-	function edit(array $content=null ,$msg='')
64
+	function edit(array $content = null, $msg = '')
65 65
 	{
66 66
 		$tmpl = new Etemplate('mail.acl');
67 67
 		if (!is_array($content))
68 68
 		{
69
-			$acc_id = $_GET['acc_id']?$_GET['acc_id']:$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
69
+			$acc_id = $_GET['acc_id'] ? $_GET['acc_id'] : $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
70 70
 			if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin']))
71 71
 			{
72 72
 				Framework::window_close(lang('Permission denied'));
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$account = Mail\Account::read($acc_id, $account_id);
82 82
 		$this->imap = $account->imapServer(isset($account_id) ? (int)$account_id : false);
83 83
 
84
-		$mailbox = $_GET['mailbox']? base64_decode($_GET['mailbox']): $content['mailbox'][0];
84
+		$mailbox = $_GET['mailbox'] ? base64_decode($_GET['mailbox']) : $content['mailbox'][0];
85 85
 		if (empty($mailbox))
86 86
 		{
87 87
 			$mailbox = $this->imap->isAdminConnection ? $this->imap->getUserMailboxString($this->imap->isAdminConnection) : 'INBOX';
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 
112 112
 					foreach ($rights as $right)
113 113
 					{
114
-						$content['grid'][$n]['acl_'. $right] = true;
114
+						$content['grid'][$n]['acl_'.$right] = true;
115 115
 					}
116
-					$virtualD = array('e','t');
117
-					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'],array_intersect($rights,$virtuals['c']))? false: true; //c=kx more information rfc4314, Obsolote Rights
118
-					$content['grid'][$n]['acl_d'] = array_diff($virtualD,array_intersect($rights,$virtuals['d']))? false: true; //d=et more information rfc4314, Obsolote Rights
116
+					$virtualD = array('e', 't');
117
+					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'], array_intersect($rights, $virtuals['c'])) ? false : true; //c=kx more information rfc4314, Obsolote Rights
118
+					$content['grid'][$n]['acl_d'] = array_diff($virtualD, array_intersect($rights, $virtuals['d'])) ? false : true; //d=et more information rfc4314, Obsolote Rights
119 119
 
120 120
 					sort($rights);
121
-					$acl_abbrvs = implode('',$rights);
121
+					$acl_abbrvs = implode('', $rights);
122 122
 
123 123
 					if (array_key_exists($acl_abbrvs, $this->aclRightsAbbrvs))
124 124
 					{
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 				case 'apply':
160 160
 					if ($content)
161 161
 					{
162
-						$validation_err = $this->update_acl($content,$msg);
162
+						$validation_err = $this->update_acl($content, $msg);
163 163
 						if ($validation_err)
164 164
 						{
165 165
 							foreach ($validation_err as &$row)
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 					}
194 194
 					else
195 195
 					{
196
-						error_log(__METHOD__.__LINE__. "()" . "The remove_acl suppose to return an array back, something is wrong there");
196
+						error_log(__METHOD__.__LINE__."()"."The remove_acl suppose to return an array back, something is wrong there");
197 197
 					}
198 198
 					Framework::message($msg);
199 199
 			}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		$sel_options['acl'] = $this->aclRightsAbbrvs;
203 203
 
204 204
 		//Make the account owner's fields all readonly as owner has all rights and should not be able to change them
205
-		foreach($content['grid'] as $key => $fields)
205
+		foreach ($content['grid'] as $key => $fields)
206 206
 		{
207 207
 			if ($fields['acc_id'] == $this->imap->acc_imap_username ||
208 208
 					$fields['acc_id'][0] == $this->imap->acc_imap_username)
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			));
236 236
 		}
237 237
 
238
-		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv,2);
238
+		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv, 2);
239 239
 	}
240 240
 
241 241
 	/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		$mailbox = $imap->isAdminConnection ? $imap->getUserMailboxString($imap->isAdminConnection) : 'INBOX';
255 255
 
256 256
 		$folders = array();
257
-		foreach(self::getSubfolders($mailbox, $imap) as $folder)
257
+		foreach (self::getSubfolders($mailbox, $imap) as $folder)
258 258
 		{
259 259
 			if (stripos($folder, $_GET['query']) !== false)
260 260
 			{
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param string $msg Message
283 283
 	 *
284 284
 	 */
285
-	function update_acl ($content, &$msg)
285
+	function update_acl($content, &$msg)
286 286
 	{
287 287
 		$validator = array();
288 288
 
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
 			{
299 299
 				if ($value[$key] == true)
300 300
 				{
301
-					$right = explode("acl_" ,$key);
301
+					$right = explode("acl_", $key);
302 302
 					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
303 303
 					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
304
-					$options['rights'] .=  $right[1];
304
+					$options['rights'] .= $right[1];
305 305
 				}
306 306
 			}
307 307
 			$username = $content['grid'][$keys]['acc_id'] == $this->imap->acc_imap_username
308
-				?$content['grid'][$keys]['acc_id']:$content['grid'][$keys]['acc_id'][0];
308
+				? $content['grid'][$keys]['acc_id'] : $content['grid'][$keys]['acc_id'][0];
309 309
 			//error_log(__METHOD__."(".__LINE__.") setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
310 310
 			if (is_numeric($username) && ($u = $this->imap->getMailBoxUserName($username)))
311 311
 			{
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			if (!empty($username))
315 315
 			{
316 316
 				//error_log(__METHOD__."() setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
317
-				if (($ret=$this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
317
+				if (($ret = $this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
318 318
 				{
319 319
 					$msg = lang("The Folder %1 's ACLs saved", $content['mailbox']);
320 320
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 			}
327 327
 			else
328 328
 			{
329
-				if($keys !== count($content['grid']))
329
+				if ($keys !== count($content['grid']))
330 330
 				{
331 331
 					array_push($validator, $keys);
332 332
 					$msg = lang("Error:Could not save the ACL! Because some names are empty!");
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 * Retrive Folder ACL rights
344 344
 	 * @todo rights 'c' and 'd' should be fixed
345 345
 	 */
346
-	function retrive_acl ($mailbox, &$msg)
346
+	function retrive_acl($mailbox, &$msg)
347 347
 	{
348 348
 		if (($acl = $this->getACL($mailbox)))
349 349
 		 {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	function remove_acl($content, &$msg)
370 370
 	{
371
-		$row_num = array_keys($content['grid']['delete'],"pressed");
371
+		$row_num = array_keys($content['grid']['delete'], "pressed");
372 372
 		if ($row_num) $row_num = $row_num[0];
373 373
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
374 374
 		$identifier = $content['grid'][$row_num]['acc_id'][0];
@@ -378,24 +378,24 @@  discard block
 block discarded – undo
378 378
 			$identifier = $u;
379 379
 		}
380 380
 		//error_log(__METHOD__.__LINE__."(".$content['mailbox'].", ".$identifier.", ".$recursive.")");
381
-		if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive)))
381
+		if (($res = $this->deleteACL($content['mailbox'], $identifier, $recursive)))
382 382
 		{
383 383
 			unset($content['grid'][$row_num]);
384 384
 			unset($content['grid']['delete']);
385 385
 			if ($recursive)
386 386
 			{
387
-				$msg = lang("The %1 's acl, including its subfolders, removed from the %2",$content['mailbox'],$identifier);
387
+				$msg = lang("The %1 's acl, including its subfolders, removed from the %2", $content['mailbox'], $identifier);
388 388
 			}
389 389
 			else
390 390
 			{
391
-				$msg = lang("The %1 's acl removed from the %2",$content['mailbox'],$identifier);
391
+				$msg = lang("The %1 's acl removed from the %2", $content['mailbox'], $identifier);
392 392
 			}
393 393
 
394 394
 			return array_combine(range(1, count($content['grid'])), array_values($content['grid']));
395 395
 		}
396 396
 		else
397 397
 		{
398
-			$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier);
398
+			$msg = lang("An error happend while trying to remove ACL rights from the account %1!", $identifier);
399 399
 			return false;
400 400
 		}
401 401
 	}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 *
411 411
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success
412 412
 	 */
413
-	function deleteACL ($mailbox, $identifier, $recursive)
413
+	function deleteACL($mailbox, $identifier, $recursive)
414 414
 	{
415 415
 		if ($recursive)
416 416
 		{
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 		{
421 421
 			$folders = (array)$mailbox;
422 422
 		}
423
-		foreach($folders as $sbFolders)
423
+		foreach ($folders as $sbFolders)
424 424
 		{
425 425
 			try
426 426
 			{
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 			}
429 429
 			catch (Exception $e)
430 430
 			{
431
-				error_log(__METHOD__. "Could not delete ACL rights of folder " . $mailbox . " for account ". $identifier ." because of " .$e->getMessage());
431
+				error_log(__METHOD__."Could not delete ACL rights of folder ".$mailbox." for account ".$identifier." because of ".$e->getMessage());
432 432
 				return false;
433 433
 			}
434 434
 		}
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success,
472 472
 	 *
473 473
 	 */
474
-	function setACL($mailbox, $identifier,$options, $recursive, &$msg)
474
+	function setACL($mailbox, $identifier, $options, $recursive, &$msg)
475 475
 	{
476 476
 		if ($recursive)
477 477
 		{
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
 		{
482 482
 			$folders = (array)$mailbox;
483 483
 		}
484
-		foreach($folders as $sbFolders)
484
+		foreach ($folders as $sbFolders)
485 485
 		{
486 486
 			try
487 487
 			{
488
-				$this->imap->setACL($sbFolders,$identifier,$options);
488
+				$this->imap->setACL($sbFolders, $identifier, $options);
489 489
 			}
490 490
 			catch (Exception $e)
491 491
 			{
492 492
 				$msg = $e->getMessage();
493
-				error_log(__METHOD__. "Could not set ACL rights on folder " . $mailbox . " for account ". $identifier . " because of " .$e->getMessage());
493
+				error_log(__METHOD__."Could not set ACL rights on folder ".$mailbox." for account ".$identifier." because of ".$e->getMessage());
494 494
 				return false;
495 495
 			}
496 496
 		}
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 	 * @param String $mailbox folder name that needs to be read
504 504
 	 * @return Boolean FALSE in case of any exceptions and if TRUE in case of success,
505 505
 	 */
506
-	function getACL ($mailbox)
506
+	function getACL($mailbox)
507 507
 	{
508 508
 		try
509 509
 		{
510 510
 			$acl = $this->imap->getACL($mailbox);
511 511
 			return $acl;
512 512
 		} catch (Exception $e) {
513
-			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . " because of " .$e->getMessage());
513
+			error_log(__METHOD__."Could not get ACL rights from folder ".$mailbox." because of ".$e->getMessage());
514 514
 			return false;
515 515
 		}
516 516
 	}
Please login to merge, or discard this patch.
Braces   +32 added lines, -9 removed lines patch added patch discarded remove patch
@@ -95,7 +95,10 @@  discard block
 block discarded – undo
95 95
 			//Todo: Implement autocomplete_url function with admin stuffs consideration
96 96
 		}
97 97
 		// Unset the content if folder is changed, in order to read acl rights for new selected folder
98
-		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete'])) unset($content);
98
+		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete']))
99
+		{
100
+			unset($content);
101
+		}
99 102
 
100 103
 		if (!is_array($content))
101 104
 		{
@@ -170,7 +173,9 @@  discard block
 block discarded – undo
170 173
 
171 174
 						//Add new row at the end
172 175
 						if ($content['grid'][count($content['grid'])]['acc_id'])
173
-							array_push($content['grid'], array('acc_id'=>''));
176
+						{
177
+													array_push($content['grid'], array('acc_id'=>''));
178
+						}
174 179
 					}
175 180
 					else
176 181
 					{
@@ -178,7 +183,10 @@  discard block
 block discarded – undo
178 183
 					}
179 184
 					//Send message
180 185
 					Framework::message($msg);
181
-					if ($button == "apply") break;
186
+					if ($button == "apply")
187
+					{
188
+						break;
189
+					}
182 190
 
183 191
 				//Fall through
184 192
 				case 'cancel':
@@ -299,8 +307,16 @@  discard block
 block discarded – undo
299 307
 				if ($value[$key] == true)
300 308
 				{
301 309
 					$right = explode("acl_" ,$key);
302
-					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
303
-					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
310
+					if ($right[1] === 'c')
311
+					{
312
+						$right[1] = 'kx';
313
+					}
314
+					// c = kx , rfc 4314
315
+					if ($right[1] === 'd')
316
+					{
317
+						$right[1] = 'et';
318
+					}
319
+					// d = et , rfc 4314
304 320
 					$options['rights'] .=  $right[1];
305 321
 				}
306 322
 			}
@@ -346,7 +362,7 @@  discard block
 block discarded – undo
346 362
 	function retrive_acl ($mailbox, &$msg)
347 363
 	{
348 364
 		if (($acl = $this->getACL($mailbox)))
349
-		 {
365
+		{
350 366
 			$msg = lang('ACL rights retrived successfully');
351 367
 			return $acl;
352 368
 		 }
@@ -369,10 +385,16 @@  discard block
 block discarded – undo
369 385
 	function remove_acl($content, &$msg)
370 386
 	{
371 387
 		$row_num = array_keys($content['grid']['delete'],"pressed");
372
-		if ($row_num) $row_num = $row_num[0];
388
+		if ($row_num)
389
+		{
390
+			$row_num = $row_num[0];
391
+		}
373 392
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
374 393
 		$identifier = $content['grid'][$row_num]['acc_id'][0];
375
-		if (is_array($content['mailbox'])) $content['mailbox'] = $content['mailbox'][0];
394
+		if (is_array($content['mailbox']))
395
+		{
396
+			$content['mailbox'] = $content['mailbox'][0];
397
+		}
376 398
 		if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier)))
377 399
 		{
378 400
 			$identifier = $u;
@@ -509,7 +531,8 @@  discard block
 block discarded – undo
509 531
 		{
510 532
 			$acl = $this->imap->getACL($mailbox);
511 533
 			return $acl;
512
-		} catch (Exception $e) {
534
+		}
535
+		catch (Exception $e) {
513 536
 			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . " because of " .$e->getMessage());
514 537
 			return false;
515 538
 		}
Please login to merge, or discard this patch.