Passed
Pull Request — master (#46)
by Neo
33:01
created
filemanager/inc/class.filemanager_ui.inc.php 4 patches
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -536,6 +536,9 @@  discard block
 block discarded – undo
536 536
 	 * @param int &$errs=null on return number of errors
537 537
 	 * @param int &$dirs=null on return number of dirs deleted
538 538
 	 * @param int &$files=null on return number of files deleted
539
+	 * @param integer $errs
540
+	 * @param integer $files
541
+	 * @param integer $dirs
539 542
 	 * @return string success or failure message displayed to the user
540 543
 	 */
541 544
 	static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null)
@@ -704,6 +707,9 @@  discard block
 block discarded – undo
704 707
 	 * @param int &$errs=null on return number of errors
705 708
 	 * @param int &$dirs=null on return number of dirs deleted
706 709
 	 * @param int &$files=null on return number of files deleted
710
+	 * @param integer $errs
711
+	 * @param integer $dirs
712
+	 * @param integer $files
707 713
 	 * @return string
708 714
 	 */
709 715
 	public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null)
@@ -1325,7 +1331,6 @@  discard block
 block discarded – undo
1325 1331
 	 *
1326 1332
 	 * @param string $action eg. 'delete', ...
1327 1333
 	 * @param array $selected selected path(s)
1328
-	 * @param string $dir=null current directory
1329 1334
 	 * @see static::action()
1330 1335
 	 */
1331 1336
 	public static function ajax_action($action, $selected, $dir=null, $props=null)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1420,7 +1420,7 @@
 block discarded – undo
1420 1420
 					if (Vfs::file_exists($target) && $app_dir)
1421 1421
 					{
1422 1422
 						if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir);
1423
-						error_log("Symlinking $target to $app_dir");
1423
+						error_log("symlinking $target to $app_dir");
1424 1424
 						Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name'])));
1425 1425
 					}
1426 1426
 				}
Please login to merge, or discard this patch.
Spacing   +205 added lines, -207 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 		if (!static::$views_init)
82 82
 		{
83 83
 			// translate our labels
84
-			foreach(static::$views as &$label)
84
+			foreach (static::$views as &$label)
85 85
 			{
86 86
 				$label = lang($label);
87 87
 			}
88 88
 			// search for plugins with additional filemanager views
89
-			foreach(Api\Hooks::process('filemanager_views') as $views)
89
+			foreach (Api\Hooks::process('filemanager_views') as $views)
90 90
 			{
91 91
 				if (is_array($views)) static::$views += $views;
92 92
 			}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public static function get_view()
104 104
 	{
105
-		$view =& Api\Cache::getSession('filemanager', 'view');
105
+		$view = & Api\Cache::getSession('filemanager', 'view');
106 106
 		if (isset($_GET['view']))
107 107
 		{
108 108
 			$view = $_GET['view'];
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 	 * @param type $actions
121 121
 	 * @return type
122 122
 	 */
123
-	public static function convertActionsToselOptions ($actions)
123
+	public static function convertActionsToselOptions($actions)
124 124
 	{
125
-		$sel_options = array ();
125
+		$sel_options = array();
126 126
 		foreach ($actions as $action => $value)
127 127
 		{
128
-			$sel_options[$action] = array (
128
+			$sel_options[$action] = array(
129 129
 				'label' => $value['caption'],
130 130
 				'icon'	=> $value['icon']
131 131
 			);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			'open' => array(
145 145
 				'caption' => lang('Open'),
146 146
 				'icon' => '',
147
-				'group' => $group=1,
147
+				'group' => $group = 1,
148 148
 				'allowOnMultiple' => false,
149 149
 				'onExecute' => 'javaScript:app.filemanager.open',
150 150
 				'default' => true
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 				'caption' => 'New',
154 154
 				'group' => $group,
155 155
 				'disableClass' => 'noEdit',
156
-				'children' => array (
157
-					'document' => array (
156
+				'children' => array(
157
+					'document' => array(
158 158
 						'caption' => 'Document',
159 159
 						'icon' => 'new',
160 160
 						'onExecute' => 'javaScript:app.filemanager.create_new',
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				'caption' => lang('Edit settings'),
174 174
 				'group' => $group,
175 175
 				'allowOnMultiple' => false,
176
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.filemanager.viewEntry':'javaScript:app.filemanager.editprefs',
176
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.filemanager.viewEntry' : 'javaScript:app.filemanager.editprefs',
177 177
 				'mobileViewTemplate' => 'file?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/filemanager/templates/mobile/file.xet'))
178 178
 			),
179 179
 			'share' => array(
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			),
253 253
 			// DRAG and DROP events
254 254
 			'file_drag' => array(
255
-				'dragType' => array('file','link'),
255
+				'dragType' => array('file', 'link'),
256 256
 				'type' => 'drag',
257 257
 				'onExecute' => 'javaScript:app.filemanager.drag'
258 258
 			),
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		);
288 288
 
289 289
 		if (isset($GLOBALS['egw_info']['user']['apps']['mail'])) {
290
-			foreach(Vfs\Sharing::$modes as $mode => $data)
290
+			foreach (Vfs\Sharing::$modes as $mode => $data)
291 291
 			{
292 292
 				$actions['share']['children']['mail_'.$mode] = array(
293 293
 					'caption' => $data['label'],
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 		}
304 304
 
305 305
 		// This would be done automatically, but we're overriding
306
-		foreach($actions as $action_id => $action)
306
+		foreach ($actions as $action_id => $action)
307 307
 		{
308
-			if($action['type'] == 'drop' && $action['caption'])
308
+			if ($action['type'] == 'drop' && $action['caption'])
309 309
 			{
310 310
 				$action['type'] = 'popup';
311
-				if($action['acceptedTypes'] == 'file')
311
+				if ($action['acceptedTypes'] == 'file')
312 312
 				{
313 313
 					$action['enabled'] = 'javaScript:app.filemanager.paste_enabled';
314 314
 				}
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
 	 *
329 329
 	 * @return string merge application or NULL if no property found
330 330
 	 */
331
-	private static function get_mergeapp($path, $scope='self')
331
+	private static function get_mergeapp($path, $scope = 'self')
332 332
 	{
333 333
 		$app = null;
334
-		switch($scope)
334
+		switch ($scope)
335 335
 		{
336 336
 			case 'self':
337 337
 				$props = Vfs::propfind($path, static::$merge_prop_namespace);
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
 			case 'parents':
341 341
 				// search for props in parent directories
342 342
 				$currentpath = $path;
343
-				while($dir = Vfs::dirname($currentpath))
343
+				while ($dir = Vfs::dirname($currentpath))
344 344
 				{
345 345
 					$props = Vfs::propfind($dir, static::$merge_prop_namespace);
346
-					if(!empty($props))
346
+					if (!empty($props))
347 347
 					{
348 348
 						// found prop in parent directory
349 349
 						return $app = $props[0]['val'];
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 * @param array $content
363 363
 	 * @param string $msg
364 364
 	 */
365
-	function index(array $content=null,$msg=null)
365
+	function index(array $content = null, $msg = null)
366 366
 	{
367 367
 		if (!is_array($content))
368 368
 		{
@@ -372,16 +372,16 @@  discard block
 block discarded – undo
372 372
 			if (!is_array($content['nm']))
373 373
 			{
374 374
 				$content['nm'] = array(
375
-					'get_rows'       =>	'filemanager.filemanager_ui.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
376
-					'filter'         => '',	// current dir only
377
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
378
-					'no_cat'         => True,	// I  disable the cat-selectbox
379
-					'lettersearch'   => True,	// I  show a lettersearch
380
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
381
-					'start'          =>	0,		// IO position in list
382
-					'order'          =>	'name',	// IO name of the column to sort after (optional for the sortheaders)
383
-					'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
384
-					'default_cols'   => '!comment,ctime',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
375
+					'get_rows'       =>	'filemanager.filemanager_ui.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
376
+					'filter'         => '', // current dir only
377
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
378
+					'no_cat'         => True, // I  disable the cat-selectbox
379
+					'lettersearch'   => True, // I  show a lettersearch
380
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
381
+					'start'          =>	0, // IO position in list
382
+					'order'          =>	'name', // IO name of the column to sort after (optional for the sortheaders)
383
+					'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
384
+					'default_cols'   => '!comment,ctime', // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
385 385
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
386 386
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
387 387
 					'row_id'         => 'path',
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 					'parent_id'      => 'dir',
390 390
 					'is_parent'      => 'is_dir',
391 391
 					'favorites'      => true,
392
-					'placeholder_actions' => array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
392
+					'placeholder_actions' => array('mkdir', 'paste', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink')
393 393
 				);
394 394
 				$content['nm']['path'] = static::get_home_dir();
395 395
 			}
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 			}
412 412
 			if (isset($_GET['path']) && ($path = $_GET['path']))
413 413
 			{
414
-				switch($path)
414
+				switch ($path)
415 415
 				{
416 416
 					case '..':
417 417
 						$path = Vfs::dirname($content['nm']['path']);
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 						$path = static::get_home_dir();
421 421
 						break;
422 422
 				}
423
-				if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE))
423
+				if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE))
424 424
 				{
425 425
 					$content['nm']['path'] = $path;
426 426
 				}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		}
437 437
 		$view = static::get_view();
438 438
 
439
-		call_user_func($view,$content,$msg);
439
+		call_user_func($view, $content, $msg);
440 440
 	}
441 441
 
442 442
 	/**
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	 * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise
450 450
 	 * @return boolean true is root user given, false otherwise (including logout / empty $user)
451 451
 	 */
452
-	protected function sudo($user='',$password=null,&$is_setup=null)
452
+	protected function sudo($user = '', $password = null, &$is_setup = null)
453 453
 	{
454 454
 		if (!$user)
455 455
 		{
@@ -458,15 +458,15 @@  discard block
 block discarded – undo
458 458
 		else
459 459
 		{
460 460
 			// config user & password
461
-			$is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash'];
461
+			$is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash'];
462 462
 			// or vfs root user from setup >> configuration
463
-			$is_root = $is_setup ||	$GLOBALS['egw_info']['server']['vfs_root_user'] &&
464
-				in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) &&
463
+			$is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] &&
464
+				in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) &&
465 465
 				$GLOBALS['egw']->auth->authenticate($user, $password, 'text');
466 466
 		}
467 467
 		//error_log(__METHOD__."('$user','$password',$is_setup) user_pw_hash(...)='".Api\Session::user_pw_hash($user,$password)."', config_hash='{$GLOBALS['egw_info']['server']['config_hash']}' --> returning ".array2string($is_root));
468
-		Api\Cache::setSession('filemanager', 'is_setup',$is_setup);
469
-		Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root);
468
+		Api\Cache::setSession('filemanager', 'is_setup', $is_setup);
469
+		Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root);
470 470
 		return Vfs::$is_root;
471 471
 	}
472 472
 
@@ -476,18 +476,18 @@  discard block
 block discarded – undo
476 476
 	 * @param array $content
477 477
 	 * @param string $msg
478 478
 	 */
479
-	function listview(array $content=null,$msg=null)
479
+	function listview(array $content = null, $msg = null)
480 480
 	{
481 481
 		$tpl = new Etemplate('filemanager.index');
482 482
 
483
-		if($msg) Framework::message($msg);
483
+		if ($msg) Framework::message($msg);
484 484
 
485 485
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
486 486
 		{
487 487
 			if ($content['nm']['action'])
488 488
 			{
489
-				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
490
-				if($msg) Framework::message($msg);
489
+				$msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']);
490
+				if ($msg) Framework::message($msg);
491 491
 
492 492
 				// clean up after action
493 493
 				unset($content['nm']['selected']);
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
499 499
 				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
500 500
 			}
501
-			elseif($content['nm']['rows']['delete'])
501
+			elseif ($content['nm']['rows']['delete'])
502 502
 			{
503
-				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
504
-				if($msg) Framework::message($msg);
503
+				$msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']);
504
+				if ($msg) Framework::message($msg);
505 505
 
506 506
 				// clean up after action
507 507
 				unset($content['nm']['rows']['delete']);
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
514 514
 			}
515 515
 			unset($content['nm']['rows']);
516
-			Api\Cache::setSession('filemanager', 'index',$content['nm']);
516
+			Api\Cache::setSession('filemanager', 'index', $content['nm']);
517 517
 		}
518 518
 
519 519
 		// be tolerant with (in previous versions) not correct urlencoded pathes
520
-		if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path'])))
520
+		if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path'])))
521 521
 		{
522 522
 			$content['nm']['path'] = urldecode($content['nm']['path']);
523 523
 		}
@@ -528,22 +528,22 @@  discard block
 block discarded – undo
528 528
 				list($button) = each($content['button']);
529 529
 				unset($content['button']);
530 530
 			}
531
-			switch($button)
531
+			switch ($button)
532 532
 			{
533 533
 				case 'upload':
534 534
 					if (!$content['upload'])
535 535
 					{
536
-						Framework::message(lang('You need to select some files first!'),'error');
536
+						Framework::message(lang('You need to select some files first!'), 'error');
537 537
 						break;
538 538
 					}
539 539
 					$upload_success = $upload_failure = array();
540
-					foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
540
+					foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
541 541
 					{
542 542
 						// encode chars which special meaning in url/vfs (some like / get removed!)
543
-						$to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name']));
543
+						$to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name']));
544 544
 						if ($upload &&
545 545
 							(Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) &&
546
-							copy($upload['tmp_name'],Vfs::PREFIX.$to))
546
+							copy($upload['tmp_name'], Vfs::PREFIX.$to))
547 547
 						{
548 548
 							$upload_success[] = $upload['name'];
549 549
 						}
@@ -555,12 +555,11 @@  discard block
 block discarded – undo
555 555
 					$content['nm']['msg'] = '';
556 556
 					if ($upload_success)
557 557
 					{
558
-						Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') :
559
-							lang('%1 successful uploaded.',implode(', ',$upload_success)));
558
+						Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success)));
560 559
 					}
561 560
 					if ($upload_failure)
562 561
 					{
563
-						Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error');
562
+						Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error');
564 563
 					}
565 564
 					break;
566 565
 			}
@@ -584,16 +583,16 @@  discard block
 block discarded – undo
584 583
 			$tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv');
585 584
 		}
586 585
 		// Set view button to match current settings
587
-		if($content['nm']['view'] == 'tile')
586
+		if ($content['nm']['view'] == 'tile')
588 587
 		{
589
-			$tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view'));
590
-			$tpl->setElementAttribute('nm[button][change_view]','image','list_row');
588
+			$tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view'));
589
+			$tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row');
591 590
 		}
592 591
 		// if initial load is done via GET request (idots template or share.php)
593 592
 		// get_rows cant call app.filemanager.set_readonly, so we need to do that here
594 593
 		$content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']);
595 594
 
596
-		$tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm']));
595
+		$tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm']));
597 596
 	}
598 597
 
599 598
 	/**
@@ -629,7 +628,7 @@  discard block
 block discarded – undo
629 628
 	 * @param int &$files=null on return number of files deleted
630 629
 	 * @return string success or failure message displayed to the user
631 630
 	 */
632
-	static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null)
631
+	static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null)
633 632
 	{
634 633
 		if (!count($selected))
635 634
 		{
@@ -637,20 +636,20 @@  discard block
 block discarded – undo
637 636
 		}
638 637
 		$errs = $dirs = $files = 0;
639 638
 
640
-		switch($action)
639
+		switch ($action)
641 640
 		{
642 641
 
643 642
 			case 'delete':
644
-				return static::do_delete($selected,$errs,$files,$dirs);
643
+				return static::do_delete($selected, $errs, $files, $dirs);
645 644
 
646 645
 			case 'mail':
647 646
 			case 'copy':
648
-				foreach($selected as $path)
647
+				foreach ($selected as $path)
649 648
 				{
650 649
 					if (strpos($path, 'mail::') === 0 && $path = substr($path, 6))
651 650
 					{
652 651
 						// Support for dropping mail in filemanager - Pass mail back to mail app
653
-						if(ExecMethod2('mail.mail_ui.vfsSaveMessages', $path, $dir))
652
+						if (ExecMethod2('mail.mail_ui.vfsSaveMessages', $path, $dir))
654 653
 						{
655 654
 							++$files;
656 655
 						}
@@ -661,8 +660,8 @@  discard block
 block discarded – undo
661 660
 					}
662 661
 					elseif (!Vfs::is_dir($path))
663 662
 					{
664
-						$to = Vfs::concat($dir,Vfs::basename($path));
665
-						if ($path != $to && Vfs::copy($path,$to))
663
+						$to = Vfs::concat($dir, Vfs::basename($path));
664
+						if ($path != $to && Vfs::copy($path, $to))
666 665
 						{
667 666
 							++$files;
668 667
 						}
@@ -674,19 +673,19 @@  discard block
 block discarded – undo
674 673
 					else
675 674
 					{
676 675
 						$len = strlen(dirname($path));
677
-						foreach(Vfs::find($path) as $p)
676
+						foreach (Vfs::find($path) as $p)
678 677
 						{
679
-							$to = $dir.substr($p,$len);
678
+							$to = $dir.substr($p, $len);
680 679
 							if ($to == $p)	// cant copy into itself!
681 680
 							{
682 681
 								++$errs;
683 682
 								continue;
684 683
 							}
685
-							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
684
+							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE))
686 685
 							{
687 686
 								++$dirs;
688 687
 							}
689
-							elseif(!$is_dir && Vfs::copy($p,$to))
688
+							elseif (!$is_dir && Vfs::copy($p, $to))
690 689
 							{
691 690
 								++$files;
692 691
 							}
@@ -699,15 +698,15 @@  discard block
 block discarded – undo
699 698
 				}
700 699
 				if ($errs)
701 700
 				{
702
-					return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files);
701
+					return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files);
703 702
 				}
704
-				return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files);
703
+				return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files);
705 704
 
706 705
 			case 'move':
707
-				foreach($selected as $path)
706
+				foreach ($selected as $path)
708 707
 				{
709
-					$to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir;
710
-					if ($path != $to && Vfs::rename($path,$to))
708
+					$to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir;
709
+					if ($path != $to && Vfs::rename($path, $to))
711 710
 					{
712 711
 						++$files;
713 712
 					}
@@ -718,17 +717,17 @@  discard block
 block discarded – undo
718 717
 				}
719 718
 				if ($errs)
720 719
 				{
721
-					return lang('%1 errors moving (%2 files moved)!',$errs,$files);
720
+					return lang('%1 errors moving (%2 files moved)!', $errs, $files);
722 721
 				}
723
-				return lang('%1 files moved.',$files);
722
+				return lang('%1 files moved.', $files);
724 723
 
725 724
 			case 'symlink':	// symlink given files to $dir
726
-				foreach((array)$selected as $target)
725
+				foreach ((array)$selected as $target)
727 726
 				{
728 727
 					$link = Vfs::concat($dir, Vfs::basename($target));
729
-					if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true)))
728
+					if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true)))
730 729
 					{
731
-						if(!$ok)
730
+						if (!$ok)
732 731
 						{
733 732
 							$errs++;
734 733
 							continue;
@@ -750,15 +749,14 @@  discard block
 block discarded – undo
750 749
 				}
751 750
 				if (count((array)$selected) == 1)
752 751
 				{
753
-					return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) :
754
-						lang('Error creating symlink to target %1!', Vfs::decodePath($target));
752
+					return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target));
755 753
 				}
756 754
 				$ret = lang('%1 elements linked.', $files);
757 755
 				if ($errs)
758 756
 				{
759
-					$ret = lang('%1 errors linking (%2)!',$errs, $ret);
757
+					$ret = lang('%1 errors linking (%2)!', $errs, $ret);
760 758
 				}
761
-				return $ret;//." Vfs::symlink('$target', '$link')";
759
+				return $ret; //." Vfs::symlink('$target', '$link')";
762 760
 
763 761
 			case 'createdir':
764 762
 				$dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected);
@@ -774,13 +772,13 @@  discard block
 block discarded – undo
774 772
 
775 773
 			default:
776 774
 				list($action, $settings) = explode('_', $action, 2);
777
-				switch($action)
775
+				switch ($action)
778 776
 				{
779 777
 					case 'document':
780 778
 						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
781 779
 						$document_merge = new filemanager_merge(Vfs::decodePath($dir));
782 780
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
783
-						if($msg) return $msg;
781
+						if ($msg) return $msg;
784 782
 						$errs = count($selected);
785 783
 						return false;
786 784
 				}
@@ -797,12 +795,12 @@  discard block
 block discarded – undo
797 795
 	 * @param int &$files=null on return number of files deleted
798 796
 	 * @return string
799 797
 	 */
800
-	public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null)
798
+	public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null)
801 799
 	{
802 800
 		$dirs = $files = $errs = 0;
803 801
 		// we first delete all selected links (and files)
804 802
 		// feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link!
805
-		foreach($selected as $key => $path)
803
+		foreach ($selected as $key => $path)
806 804
 		{
807 805
 			if (!Vfs::is_dir($path) || Vfs::is_link($path))
808 806
 			{
@@ -820,21 +818,21 @@  discard block
 block discarded – undo
820 818
 		if ($selected)	// somethings left to delete
821 819
 		{
822 820
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
823
-			foreach((array)$selected as $path)
821
+			foreach ((array)$selected as $path)
824 822
 			{
825 823
 				if (Vfs::isProtectedDir($path))
826 824
 				{
827 825
 					$errs++;
828
-					return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path));
826
+					return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path));
829 827
 				}
830 828
 			}
831 829
 			// now we use find to loop through all files and dirs: (selected only contains dirs now)
832 830
 			// - depth=true to get first the files and then the dir containing it
833 831
 			// - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs
834 832
 			// - show-deleted=false to not (finally) deleted versioned files
835
-			foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path)
833
+			foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path)
836 834
 			{
837
-				if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0))
835
+				if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0))
838 836
 				{
839 837
 					++$dirs;
840 838
 				}
@@ -850,13 +848,13 @@  discard block
 block discarded – undo
850 848
 		}
851 849
 		if ($errs)
852 850
 		{
853
-			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files);
851
+			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files);
854 852
 		}
855 853
 		if ($dirs)
856 854
 		{
857
-			return lang('%1 directories and %2 files deleted.',$dirs,$files);
855
+			return lang('%1 directories and %2 files deleted.', $dirs, $files);
858 856
 		}
859
-		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files);
857
+		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files);
860 858
 	}
861 859
 
862 860
 	/**
@@ -871,37 +869,37 @@  discard block
 block discarded – undo
871 869
 		if (!$query['csv_export'])
872 870
 		{
873 871
 			Api\Cache::setSession('filemanager', 'index',
874
-				array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions'))));
872
+				array_diff_key($query, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
875 873
 		}
876
-		if(!$query['path']) $query['path'] = static::get_home_dir();
874
+		if (!$query['path']) $query['path'] = static::get_home_dir();
877 875
 
878 876
 		// Change template to match selected view
879
-		if($query['view'])
877
+		if ($query['view'])
880 878
 		{
881 879
 			$query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile');
882 880
 
883 881
 			// Store as preference but only for index, not home
884
-			if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
882
+			if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
885 883
 			{
886
-				$GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']);
884
+				$GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']);
887 885
 				$GLOBALS['egw']->preferences->save_repository();
888 886
 			}
889 887
 		}
890 888
 		// be tolerant with (in previous versions) not correct urlencoded pathes
891
-		if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path'])))
889
+		if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path'])))
892 890
 		{
893 891
 			$query['path'] = urldecode($query['path']);
894 892
 		}
895
-		if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE))
893
+		if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE))
896 894
 		{
897 895
 			// only redirect, if it would be to some other location, gives redirect-loop otherwise
898 896
 			if ($query['path'] != ($path = static::get_home_dir()))
899 897
 			{
900 898
 				// we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give
901 899
 				// an appropriate message
902
-				Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index',
900
+				Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index',
903 901
 					'path' => $path,
904
-					'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])),
902
+					'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])),
905 903
 					'ajax' => 'true'
906 904
 				));
907 905
 			}
@@ -910,7 +908,7 @@  discard block
 block discarded – undo
910 908
 		}
911 909
 		$rows = $dir_is_writable = array();
912 910
 		$vfs_options = $this->get_vfs_options($query);
913
-		foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row)
911
+		foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row)
914 912
 		{
915 913
 			//echo $path; _debug_array($row);
916 914
 
@@ -928,7 +926,7 @@  discard block
 block discarded – undo
928 926
 
929 927
 				$row['class'] .= 'isDir ';
930 928
 				$row['is_dir'] = 1;
931
-				if(!$dir_is_writable[$path])
929
+				if (!$dir_is_writable[$path])
932 930
 				{
933 931
 					$row['class'] .= 'noEdit ';
934 932
 				}
@@ -940,32 +938,32 @@  discard block
 block discarded – undo
940 938
 
941 939
 			$row['class'] .= !$dir_is_writable[$dir] ? 'noDelete' : '';
942 940
 			$row['download_url'] = Vfs::download_url($path);
943
-			$row['gid'] = -abs($row['gid']);	// gid are positive, but we use negagive account_id for groups internal
941
+			$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
944 942
 
945 943
 			$rows[++$n] = $row;
946 944
 			$path2n[$path] = $n;
947 945
 		}
948 946
 		// query comments and cf's for the displayed rows
949
-		$cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
947
+		$cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
950 948
 
951 949
 		// Always include comment in tiles
952
-		if($query['view'] == 'tile')
950
+		if ($query['view'] == 'tile')
953 951
 		{
954 952
 			$cols_to_show[] = 'comment';
955 953
 		}
956
-		$all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#';
957
-		if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) &&
954
+		$all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#';
955
+		if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) &&
958 956
 			($path2props = Vfs::propfind(array_keys($path2n))))
959 957
 		{
960
-			foreach($path2props as $path => $props)
958
+			foreach ($path2props as $path => $props)
961 959
 			{
962
-				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
963
-				$row =& $rows[$path2n[$path]];
964
-				if ( !is_array($props) ) continue;
965
-				foreach($props as $prop)
960
+				unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2
961
+				$row = & $rows[$path2n[$path]];
962
+				if (!is_array($props)) continue;
963
+				foreach ($props as $prop)
966 964
 				{
967
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
968
-					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
965
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue;
966
+					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...';
969 967
 				}
970 968
 			}
971 969
 		}
@@ -977,7 +975,7 @@  discard block
 block discarded – undo
977 975
 		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager')
978 976
 		{
979 977
 			// we need our app.css file
980
-			if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
978
+			if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
981 979
 			{
982 980
 				$css_file = '/filemanager/templates/default/app.css';
983 981
 			}
@@ -993,35 +991,35 @@  discard block
 block discarded – undo
993 991
 	 */
994 992
 	protected function get_vfs_options($query)
995 993
 	{
996
-		if($query['searchletter'] && !empty($query['search']))
994
+		if ($query['searchletter'] && !empty($query['search']))
997 995
 		{
998
-			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
996
+			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
999 997
 			if ($query['searchletter'] == strtolower($query['search'][0]))
1000 998
 			{
1001
-				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'.
1002
-					str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i';
999
+				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'.
1000
+					str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i';
1003 1001
 			}
1004 1002
 		}
1005 1003
 		elseif ($query['searchletter'])
1006 1004
 		{
1007 1005
 			$namefilter = '/^'.$query['searchletter'].'/i';
1008 1006
 		}
1009
-		elseif(!empty($query['search']))
1007
+		elseif (!empty($query['search']))
1010 1008
 		{
1011
-			$namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
1009
+			$namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
1012 1010
 		}
1013 1011
 
1014 1012
 		// Re-map so 'No filters' favorite ('') is depth 1
1015 1013
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
1016 1014
 
1017 1015
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
1018
-		if($filter == 5) $maxdepth = 2;
1016
+		if ($filter == 5) $maxdepth = 2;
1019 1017
 		$n = 0;
1020 1018
 		$vfs_options = array(
1021 1019
 			'mindepth' => 1,
1022 1020
 			'maxdepth' => $maxdepth,
1023 1021
 			'dirsontop' => $filter <= 1,
1024
-			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'),
1022
+			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'),
1025 1023
 			'order' => $query['order'], 'sort' => $query['sort'],
1026 1024
 			'limit' => (int)$query['num_rows'].','.(int)$query['start'],
1027 1025
 			'need_mime' => true,
@@ -1029,7 +1027,7 @@  discard block
 block discarded – undo
1029 1027
 			'hidden' => $filter == 3,
1030 1028
 			'follow' => $filter == 5,
1031 1029
 		);
1032
-		if($query['col_filter']['mime'])
1030
+		if ($query['col_filter']['mime'])
1033 1031
 		{
1034 1032
 			$vfs_options['mime'] = $query['col_filter']['mime'];
1035 1033
 		}
@@ -1043,7 +1041,7 @@  discard block
 block discarded – undo
1043 1041
 	 * @param array $content
1044 1042
 	 * @param string $msg
1045 1043
 	 */
1046
-	function file(array $content=null,$msg='')
1044
+	function file(array $content = null, $msg = '')
1047 1045
 	{
1048 1046
 		$tpl = new Etemplate('filemanager.file');
1049 1047
 
@@ -1053,9 +1051,9 @@  discard block
 block discarded – undo
1053 1051
 			{
1054 1052
 				$msg .= $_GET['msg'];
1055 1053
 			}
1056
-			if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) ||	// ?, # need to stay encoded!
1054
+			if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded!
1057 1055
 				// actions enclose pathes containing comma with "
1058
-				($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) ||
1056
+				($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) ||
1059 1057
 				!($stat = Vfs::lstat($path)))
1060 1058
 			{
1061 1059
 				$msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat);
@@ -1068,10 +1066,10 @@  discard block
 block discarded – undo
1068 1066
 				$content['path'] = $path;
1069 1067
 				$content['hsize'] = Vfs::hsize($stat['size']);
1070 1068
 				$content['mime'] = Vfs::mime_content_type($path);
1071
-				$content['gid'] *= -1;	// our widgets use negative gid's
1069
+				$content['gid'] *= -1; // our widgets use negative gid's
1072 1070
 				if (($props = Vfs::propfind($path)))
1073 1071
 				{
1074
-					foreach($props as $prop)
1072
+					foreach ($props as $prop)
1075 1073
 					{
1076 1074
 						$content[$prop['name']] = $prop['val'];
1077 1075
 					}
@@ -1084,9 +1082,9 @@  discard block
 block discarded – undo
1084 1082
 			$content['tabs'] = $_GET['tabs'];
1085 1083
 			if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path)))
1086 1084
 			{
1087
-				$content['perms']['executable'] = (int)!!($content['mode'] & 0111);
1085
+				$content['perms']['executable'] = (int)!!($content['mode']&0111);
1088 1086
 				$mask = 6;
1089
-				if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000)
1087
+				if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000)
1090 1088
 				{
1091 1089
 					$content['text_content'] = file_get_contents(Vfs::PREFIX.$path);
1092 1090
 				}
@@ -1096,19 +1094,19 @@  discard block
 block discarded – undo
1096 1094
 				//currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201);
1097 1095
 				$mask = 7;
1098 1096
 			}
1099
-			foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift)
1097
+			foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift)
1100 1098
 			{
1101
-				$content['perms'][$name] = ($content['mode'] >> $shift) & $mask;
1099
+				$content['perms'][$name] = ($content['mode'] >> $shift)&$mask;
1102 1100
 			}
1103
-			$content['is_owner'] = Vfs::has_owner_rights($path,$content);
1101
+			$content['is_owner'] = Vfs::has_owner_rights($path, $content);
1104 1102
 		}
1105 1103
 		else
1106 1104
 		{
1107 1105
 			//_debug_array($content);
1108
-			$path =& $content['path'];
1106
+			$path = & $content['path'];
1109 1107
 
1110 1108
 			list($button) = @each($content['button']); unset($content['button']);
1111
-			if(!$button && $content['sudo'])
1109
+			if (!$button && $content['sudo'])
1112 1110
 			{
1113 1111
 				// Button to stop sudo is not in button namespace
1114 1112
 				$button = 'sudo';
@@ -1117,21 +1115,21 @@  discard block
 block discarded – undo
1117 1115
 			// need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field
1118 1116
 			if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user'])
1119 1117
 			{
1120
-				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ?
1118
+				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ?
1121 1119
 					lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ?
1122 1120
 					lang('Wrong username or password!') : lang('Root access stopped.'));
1123 1121
 				unset($content['sudo']);
1124 1122
 				$content['is_owner'] = Vfs::has_owner_rights($path);
1125 1123
 			}
1126
-			if (in_array($button,array('save','apply')))
1124
+			if (in_array($button, array('save', 'apply')))
1127 1125
 			{
1128 1126
 				$props = array();
1129 1127
 				$perm_changed = $perm_failed = 0;
1130
-				foreach($content['old'] as $name => $old_value)
1128
+				foreach ($content['old'] as $name => $old_value)
1131 1129
 				{
1132 1130
 					if (isset($content[$name]) && ($old_value != $content[$name] ||
1133 1131
 						// do not check for modification, if modify_subs is checked!
1134
-						$content['modify_subs'] && in_array($name,array('uid','gid','perms'))) &&
1132
+						$content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) &&
1135 1133
 						($name != 'uid' || Vfs::$is_root))
1136 1134
 					{
1137 1135
 						if ($name == 'name')
@@ -1145,23 +1143,23 @@  discard block
 block discarded – undo
1145 1143
 							$to = Vfs::concat($dir, $content['name']);
1146 1144
 							if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to)
1147 1145
 							{
1148
-								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1149
-									lang('To overwrite the existing file store again.',lang($button)));
1146
+								$tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'.
1147
+									lang('To overwrite the existing file store again.', lang($button)));
1150 1148
 								$content['confirm_overwrite'] = $to;
1151 1149
 								if ($button == 'save') $button = 'apply';
1152 1150
 								continue;
1153 1151
 							}
1154
-							if (Vfs::rename($path,$to))
1152
+							if (Vfs::rename($path, $to))
1155 1153
 							{
1156
-								$msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' ';
1154
+								$msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' ';
1157 1155
 								$content['old']['name'] = $content[$name];
1158 1156
 								$path = $to;
1159
-								$content['mime'] = Api\MimeMagic::filename2mime($path);	// recheck mime type
1160
-								$refresh_path = Vfs::dirname($path);	// for renames, we have to refresh the parent
1157
+								$content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type
1158
+								$refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent
1161 1159
 							}
1162 1160
 							else
1163 1161
 							{
1164
-								$msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' ';
1162
+								$msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' ';
1165 1163
 								if (Vfs::deny_script($to))
1166 1164
 								{
1167 1165
 									$msg .= lang('You are NOT allowed to upload a script!').' ';
@@ -1181,7 +1179,7 @@  discard block
 block discarded – undo
1181 1179
 									'val'	=> (!empty($content[$name]) ? $content[$name] : null),
1182 1180
 								),
1183 1181
 							);
1184
-							if (Vfs::proppatch($path,$mergeprop))
1182
+							if (Vfs::proppatch($path, $mergeprop))
1185 1183
 							{
1186 1184
 								$content['old'][$name] = $content[$name];
1187 1185
 								$msg .= lang('Setting for document merge saved.');
@@ -1193,22 +1191,22 @@  discard block
 block discarded – undo
1193 1191
 						}
1194 1192
 						else
1195 1193
 						{
1196
-							static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod');
1197
-							$cmd = array('EGroupware\\Api\\Vfs',$name2cmd[$name]);
1194
+							static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod');
1195
+							$cmd = array('EGroupware\\Api\\Vfs', $name2cmd[$name]);
1198 1196
 							$value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name];
1199 1197
 							if ($content['modify_subs'])
1200 1198
 							{
1201 1199
 								if ($name == 'perms')
1202 1200
 								{
1203
-									$changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value));
1204
-									$changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666));	// no execute for files
1201
+									$changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value));
1202
+									$changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files
1205 1203
 								}
1206 1204
 								else
1207 1205
 								{
1208
-									$changed = Vfs::find($path,null,$cmd,array($value));
1206
+									$changed = Vfs::find($path, null, $cmd, array($value));
1209 1207
 								}
1210 1208
 								$ok = $failed = 0;
1211
-								foreach($changed as &$r)
1209
+								foreach ($changed as &$r)
1212 1210
 								{
1213 1211
 									if ($r)
1214 1212
 									{
@@ -1221,32 +1219,32 @@  discard block
 block discarded – undo
1221 1219
 								}
1222 1220
 								if ($ok && !$failed)
1223 1221
 								{
1224
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1222
+									if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren'));
1225 1223
 									$content['old'][$name] = $content[$name];
1226 1224
 								}
1227
-								elseif($failed)
1225
+								elseif ($failed)
1228 1226
 								{
1229
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1230
-										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1227
+									if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren').
1228
+										($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : ''));
1231 1229
 								}
1232 1230
 							}
1233
-							elseif (call_user_func_array($cmd,array($path,$value)))
1231
+							elseif (call_user_func_array($cmd, array($path, $value)))
1234 1232
 							{
1235
-								$msg .= lang('Permissions of %1 changed.',$path);
1233
+								$msg .= lang('Permissions of %1 changed.', $path);
1236 1234
 								$content['old'][$name] = $content[$name];
1237 1235
 							}
1238 1236
 							else
1239 1237
 							{
1240
-								$msg .= lang('Failed to change permissions of %1!',$path);
1238
+								$msg .= lang('Failed to change permissions of %1!', $path);
1241 1239
 							}
1242 1240
 						}
1243 1241
 					}
1244 1242
 				}
1245 1243
 				if ($props)
1246 1244
 				{
1247
-					if (Vfs::proppatch($path,$props))
1245
+					if (Vfs::proppatch($path, $props))
1248 1246
 					{
1249
-						foreach($props as $prop)
1247
+						foreach ($props as $prop)
1250 1248
 						{
1251 1249
 							$content['old'][$prop['name']] = $prop['val'];
1252 1250
 						}
@@ -1263,8 +1261,8 @@  discard block
 block discarded – undo
1263 1261
 				if ($content['eacl']['delete'])
1264 1262
 				{
1265 1263
 					list($ino_owner) = each($content['eacl']['delete']);
1266
-					list(, $owner) = explode('-',$ino_owner,2);	// $owner is a group and starts with a minus!
1267
-					$msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1264
+					list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus!
1265
+					$msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1268 1266
 				}
1269 1267
 				elseif ($button == 'eacl')
1270 1268
 				{
@@ -1274,7 +1272,7 @@  discard block
 block discarded – undo
1274 1272
 					}
1275 1273
 					else
1276 1274
 					{
1277
-						$msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ?
1275
+						$msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ?
1278 1276
 							lang('ACL added.') : lang('Error adding the ACL!');
1279 1277
 					}
1280 1278
 				}
@@ -1284,7 +1282,7 @@  discard block
 block discarded – undo
1284 1282
 		}
1285 1283
 		if ($content['is_link'] && !Vfs::stat($path))
1286 1284
 		{
1287
-			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']);
1285
+			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']);
1288 1286
 		}
1289 1287
 		$content['link'] = Egw::link(Vfs::download_url($path));
1290 1288
 		$content['icon'] = Vfs::mime_icon($content['mime']);
@@ -1293,11 +1291,11 @@  discard block
 block discarded – undo
1293 1291
 		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1294 1292
 		// only owner can change group & perms
1295 1293
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1296
-			Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs
1294
+			Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs') || // no uid, gid or perms in oldvfs
1297 1295
 				 !Vfs::is_writable($path))
1298 1296
 		{
1299 1297
 			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1300
-			foreach($content['perms'] as $name => $value)
1298
+			foreach ($content['perms'] as $name => $value)
1301 1299
 			{
1302 1300
 				$readonlys['perms['.$name.']'] = true;
1303 1301
 			}
@@ -1316,38 +1314,38 @@  discard block
 block discarded – undo
1316 1314
 		}
1317 1315
 		elseif (!Vfs::is_writable($path))
1318 1316
 		{
1319
-			foreach($cfs as $name => $data)
1317
+			foreach ($cfs as $name => $data)
1320 1318
 			{
1321 1319
 				$readonlys['#'.$name] = true;
1322 1320
 			}
1323 1321
 		}
1324
-		$readonlys['tabs']['filemanager.file.eacl'] = true;	// eacl off by default
1322
+		$readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default
1325 1323
 		if ($content['is_dir'])
1326 1324
 		{
1327
-			$readonlys['tabs']['filemanager.file.preview'] = true;	// no preview tab for dirs
1328
-			$sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1325
+			$readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs
1326
+			$sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1329 1327
 				7 => lang('Display and modification of content'),
1330 1328
 				5 => lang('Display of content'),
1331 1329
 				0 => lang('No access'),
1332 1330
 			);
1333
-			if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false &&	// backend supports eacl
1331
+			if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl
1334 1332
 				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)	// leave eACL tab disabled for sharing
1335 1333
 			{
1336
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1337
-				foreach($content['eacl'] as &$eacl)
1334
+				unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again
1335
+				foreach ($content['eacl'] as &$eacl)
1338 1336
 				{
1339
-					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
1337
+					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/');
1340 1338
 					$readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] ||
1341 1339
 						$eacl['path'] != $content['path'] || !$content['is_owner'];
1342 1340
 				}
1343
-				array_unshift($content['eacl'],false);	// make the keys start with 1, not 0
1341
+				array_unshift($content['eacl'], false); // make the keys start with 1, not 0
1344 1342
 				$content['eacl']['owner'] = 0;
1345 1343
 				$content['eacl']['rights'] = 5;
1346 1344
 			}
1347 1345
 		}
1348 1346
 		else
1349 1347
 		{
1350
-			$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1348
+			$sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1351 1349
 				6 => lang('Read & write access'),
1352 1350
 				4 => lang('Read access only'),
1353 1351
 				0 => lang('No access'),
@@ -1357,11 +1355,11 @@  discard block
 block discarded – undo
1357 1355
 		// mergeapp
1358 1356
 		$content['mergeapp'] = static::get_mergeapp($path, 'self');
1359 1357
 		$content['mergeapp_parent'] = static::get_mergeapp($path, 'parents');
1360
-		if(!empty($content['mergeapp']))
1358
+		if (!empty($content['mergeapp']))
1361 1359
 		{
1362 1360
 			$content['mergeapp_effective'] = $content['mergeapp'];
1363 1361
 		}
1364
-		elseif(!empty($content['mergeapp_parent']))
1362
+		elseif (!empty($content['mergeapp_parent']))
1365 1363
 		{
1366 1364
 			$content['mergeapp_effective'] = $content['mergeapp_parent'];
1367 1365
 		}
@@ -1373,7 +1371,7 @@  discard block
 block discarded – undo
1373 1371
 		$mergeapp_list = Link::app_list('merge');
1374 1372
 		unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list
1375 1373
 		$mergeapp_empty = !empty($content['mergeapp_parent'])
1376
-			? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : '';
1374
+			? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : '';
1377 1375
 		$sel_options['mergeapp'] = array(''	=> $mergeapp_empty);
1378 1376
 		$sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list;
1379 1377
 		// mergeapp other gui options
@@ -1390,7 +1388,7 @@  discard block
 block discarded – undo
1390 1388
 				'comment' => (string)$content['comment'],
1391 1389
 				'mergeapp' => $content['mergeapp']
1392 1390
 			);
1393
-			if ($cfs) foreach($cfs as $name => $data)
1391
+			if ($cfs) foreach ($cfs as $name => $data)
1394 1392
 			{
1395 1393
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1396 1394
 			}
@@ -1398,31 +1396,31 @@  discard block
 block discarded – undo
1398 1396
 		if (Vfs::$is_root)
1399 1397
 		{
1400 1398
 			$tpl->setElementAttribute('sudouser', 'label', 'Logout');
1401
-			$tpl->setElementAttribute('sudouser', 'help','Log out as superuser');
1399
+			$tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser');
1402 1400
 			// Need a more complex submit because button type is buttononly, which doesn't submit
1403
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")');
1401
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")');
1404 1402
 
1405 1403
 		}
1406 1404
 		elseif ($button == 'sudo')
1407 1405
 		{
1408 1406
 			$tpl->setElementAttribute('sudouser', 'label', 'Superuser');
1409
-			$tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights');
1410
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")');
1407
+			$tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights');
1408
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")');
1411 1409
 		}
1412 1410
 		else if (self::is_anonymous($GLOBALS['egw_info']['user']['account_id']))
1413 1411
 		{
1414 1412
 			// Just hide sudo for anonymous users
1415 1413
 			$readonlys['sudouser'] = true;
1416 1414
 		}
1417
-		if (($extra_tabs = Vfs::getExtraInfo($path,$content)))
1415
+		if (($extra_tabs = Vfs::getExtraInfo($path, $content)))
1418 1416
 		{
1419 1417
 			// add to existing tabs in template
1420 1418
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1421 1419
 
1422
-			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1420
+			$tabs = & $tpl->getElementAttribute('tabs', 'tabs');
1423 1421
 			if (true) $tabs = array();
1424 1422
 
1425
-			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1423
+			foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1426 1424
 			{
1427 1425
 				$tabs[] = array(
1428 1426
 					'label' =>	$extra_tab['label'],
@@ -1445,7 +1443,7 @@  discard block
 block discarded – undo
1445 1443
 		Framework::window_focus();
1446 1444
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path);
1447 1445
 
1448
-		$tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2);
1446
+		$tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2);
1449 1447
 	}
1450 1448
 
1451 1449
 	/**
@@ -1467,7 +1465,7 @@  discard block
 block discarded – undo
1467 1465
 	 * @param string $dir=null current directory
1468 1466
 	 * @see static::action()
1469 1467
 	 */
1470
-	public static function ajax_action($action, $selected, $dir=null, $props=null)
1468
+	public static function ajax_action($action, $selected, $dir = null, $props = null)
1471 1469
 	{
1472 1470
 		// do we have root rights, need to run here too, as method is static and therefore does NOT run __construct
1473 1471
 		if (Api\Cache::getSession('filemanager', 'is_root'))
@@ -1486,15 +1484,15 @@  discard block
 block discarded – undo
1486 1484
 
1487 1485
 		if (!isset($dir)) $dir = array_pop($selected);
1488 1486
 
1489
-		switch($action)
1487
+		switch ($action)
1490 1488
 		{
1491 1489
 			case 'upload':
1492 1490
 				$script_error = 0;
1493
-				foreach($selected as $tmp_name => &$data)
1491
+				foreach ($selected as $tmp_name => &$data)
1494 1492
 				{
1495 1493
 					$path = Vfs::concat($dir, Vfs::encodePathComponent($data['name']));
1496 1494
 
1497
-					if(Vfs::deny_script($path))
1495
+					if (Vfs::deny_script($path))
1498 1496
 					{
1499 1497
 						if (!isset($script_error))
1500 1498
 						{
@@ -1516,7 +1514,7 @@  discard block
 block discarded – undo
1516 1514
 					{
1517 1515
 						if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
1518 1516
 						{
1519
-							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name);
1517
+							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name);
1520 1518
 						}
1521 1519
 						else
1522 1520
 						{
@@ -1575,16 +1573,16 @@  discard block
 block discarded – undo
1575 1573
 			case 'link':
1576 1574
 				// First upload
1577 1575
 				$arr = static::ajax_action('upload', $selected, $dir, $props);
1578
-				$app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true);
1576
+				$app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true);
1579 1577
 
1580
-				foreach($arr['uploaded'] as $file)
1578
+				foreach ($arr['uploaded'] as $file)
1581 1579
 				{
1582
-					$target=Vfs::concat($dir,Vfs::encodePathComponent($file['name']));
1580
+					$target = Vfs::concat($dir, Vfs::encodePathComponent($file['name']));
1583 1581
 					if (Vfs::file_exists($target) && $app_dir)
1584 1582
 					{
1585 1583
 						if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir);
1586 1584
 						error_log("Symlinking $target to $app_dir");
1587
-						Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name'])));
1585
+						Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name'])));
1588 1586
 					}
1589 1587
 				}
1590 1588
 				// Must return to avoid adding to $response again
@@ -1606,7 +1604,7 @@  discard block
 block discarded – undo
1606 1604
 	 */
1607 1605
 	private function perms2mode(array $perms)
1608 1606
 	{
1609
-		$mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other'];
1607
+		$mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other'];
1610 1608
 		if ($mode['executable'])
1611 1609
 		{
1612 1610
 			$mode |= 0111;
Please login to merge, or discard this patch.
Braces   +144 added lines, -37 removed lines patch added patch discarded remove patch
@@ -88,7 +88,10 @@  discard block
 block discarded – undo
88 88
 			// search for plugins with additional filemanager views
89 89
 			foreach(Api\Hooks::process('filemanager_views') as $views)
90 90
 			{
91
-				if (is_array($views)) static::$views += $views;
91
+				if (is_array($views))
92
+				{
93
+					static::$views += $views;
94
+				}
92 95
 			}
93 96
 			static::$views_init = true;
94 97
 		}
@@ -286,7 +289,8 @@  discard block
 block discarded – undo
286 289
 			)
287 290
 		);
288 291
 
289
-		if (isset($GLOBALS['egw_info']['user']['apps']['mail'])) {
292
+		if (isset($GLOBALS['egw_info']['user']['apps']['mail']))
293
+		{
290 294
 			foreach(Vfs\Sharing::$modes as $mode => $data)
291 295
 			{
292 296
 				$actions['share']['children']['mail_'.$mode] = array(
@@ -397,7 +401,10 @@  discard block
 block discarded – undo
397 401
 			$content['nm']['home_dir'] = static::get_home_dir();
398 402
 			$content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view'];
399 403
 
400
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
404
+			if (isset($_GET['msg']))
405
+			{
406
+				$msg = $_GET['msg'];
407
+			}
401 408
 
402 409
 			// Blank favorite set via GET needs special handling for path
403 410
 			if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank')
@@ -431,7 +438,10 @@  discard block
 block discarded – undo
431 438
 				// reset lettersearch as it confuses users (they think the dir is empty)
432 439
 				$content['nm']['searchletter'] = false;
433 440
 				// switch recusive display off
434
-				if (!$content['nm']['filter']) $content['nm']['filter'] = '';
441
+				if (!$content['nm']['filter'])
442
+				{
443
+					$content['nm']['filter'] = '';
444
+				}
435 445
 			}
436 446
 		}
437 447
 		$view = static::get_view();
@@ -480,37 +490,70 @@  discard block
 block discarded – undo
480 490
 	{
481 491
 		$tpl = new Etemplate('filemanager.index');
482 492
 
483
-		if($msg) Framework::message($msg);
493
+		if($msg)
494
+		{
495
+			Framework::message($msg);
496
+		}
484 497
 
485 498
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
486 499
 		{
487 500
 			if ($content['nm']['action'])
488 501
 			{
489 502
 				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
490
-				if($msg) Framework::message($msg);
503
+				if($msg)
504
+				{
505
+					Framework::message($msg);
506
+				}
491 507
 
492 508
 				// clean up after action
493 509
 				unset($content['nm']['selected']);
494 510
 				// reset any occasion where action may be stored, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete
495
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
496
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
497
-				if (isset($content['nm_action'])) unset($content['nm_action']);
511
+				if (isset($content['nm']['action']))
512
+				{
513
+					unset($content['nm']['action']);
514
+				}
515
+				if (isset($content['nm']['nm_action']))
516
+				{
517
+					unset($content['nm']['nm_action']);
518
+				}
519
+				if (isset($content['nm_action']))
520
+				{
521
+					unset($content['nm_action']);
522
+				}
498 523
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
499
-				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
524
+				if (isset($content['nm']['rows']['delete']))
525
+				{
526
+					unset($content['nm']['rows']['delete']);
527
+				}
500 528
 			}
501 529
 			elseif($content['nm']['rows']['delete'])
502 530
 			{
503 531
 				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
504
-				if($msg) Framework::message($msg);
532
+				if($msg)
533
+				{
534
+					Framework::message($msg);
535
+				}
505 536
 
506 537
 				// clean up after action
507 538
 				unset($content['nm']['rows']['delete']);
508 539
 				// reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow
509 540
 				// we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete
510
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
511
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
512
-				if (isset($content['nm_action'])) unset($content['nm_action']);
513
-				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
541
+				if (isset($content['nm']['action']))
542
+				{
543
+					unset($content['nm']['action']);
544
+				}
545
+				if (isset($content['nm']['nm_action']))
546
+				{
547
+					unset($content['nm']['nm_action']);
548
+				}
549
+				if (isset($content['nm_action']))
550
+				{
551
+					unset($content['nm_action']);
552
+				}
553
+				if (isset($content['nm']['selected']))
554
+				{
555
+					unset($content['nm']['selected']);
556
+				}
514 557
 			}
515 558
 			unset($content['nm']['rows']);
516 559
 			Api\Cache::setSession('filemanager', 'index',$content['nm']);
@@ -677,9 +720,12 @@  discard block
 block discarded – undo
677 720
 						foreach(Vfs::find($path) as $p)
678 721
 						{
679 722
 							$to = $dir.substr($p,$len);
680
-							if ($to == $p)	// cant copy into itself!
723
+							if ($to == $p)
724
+							{
725
+								// cant copy into itself!
681 726
 							{
682 727
 								++$errs;
728
+							}
683 729
 								continue;
684 730
 							}
685 731
 							if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
@@ -734,7 +780,10 @@  discard block
 block discarded – undo
734 780
 							continue;
735 781
 						}
736 782
 					}
737
-					if ($target[0] != '/') $target = Vfs::concat($dir, $target);
783
+					if ($target[0] != '/')
784
+					{
785
+						$target = Vfs::concat($dir, $target);
786
+					}
738 787
 					if (!Vfs::stat($target))
739 788
 					{
740 789
 						return lang('Link target %1 not found!', Vfs::decodePath($target));
@@ -777,10 +826,16 @@  discard block
 block discarded – undo
777 826
 				switch($action)
778 827
 				{
779 828
 					case 'document':
780
-						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
829
+						if (!$settings)
830
+						{
831
+							$settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
832
+						}
781 833
 						$document_merge = new filemanager_merge(Vfs::decodePath($dir));
782 834
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
783
-						if($msg) return $msg;
835
+						if($msg)
836
+						{
837
+							return $msg;
838
+						}
784 839
 						$errs = count($selected);
785 840
 						return false;
786 841
 				}
@@ -817,7 +872,9 @@  discard block
 block discarded – undo
817 872
 				unset($selected[$key]);
818 873
 			}
819 874
 		}
820
-		if ($selected)	// somethings left to delete
875
+		if ($selected)
876
+		{
877
+			// somethings left to delete
821 878
 		{
822 879
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
823 880
 			foreach((array)$selected as $path)
@@ -825,6 +882,7 @@  discard block
 block discarded – undo
825 882
 				if (Vfs::isProtectedDir($path))
826 883
 				{
827 884
 					$errs++;
885
+		}
828 886
 					return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path));
829 887
 				}
830 888
 			}
@@ -873,7 +931,10 @@  discard block
 block discarded – undo
873 931
 			Api\Cache::setSession('filemanager', 'index',
874 932
 				array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions'))));
875 933
 		}
876
-		if(!$query['path']) $query['path'] = static::get_home_dir();
934
+		if(!$query['path'])
935
+		{
936
+			$query['path'] = static::get_home_dir();
937
+		}
877 938
 
878 939
 		// Change template to match selected view
879 940
 		if($query['view'])
@@ -961,10 +1022,16 @@  discard block
 block discarded – undo
961 1022
 			{
962 1023
 				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
963 1024
 				$row =& $rows[$path2n[$path]];
964
-				if ( !is_array($props) ) continue;
1025
+				if ( !is_array($props) )
1026
+				{
1027
+					continue;
1028
+				}
965 1029
 				foreach($props as $prop)
966 1030
 				{
967
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
1031
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show))
1032
+					{
1033
+						continue;
1034
+					}
968 1035
 					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
969 1036
 				}
970 1037
 			}
@@ -1015,7 +1082,10 @@  discard block
 block discarded – undo
1015 1082
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
1016 1083
 
1017 1084
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
1018
-		if($filter == 5) $maxdepth = 2;
1085
+		if($filter == 5)
1086
+		{
1087
+			$maxdepth = 2;
1088
+		}
1019 1089
 		$n = 0;
1020 1090
 		$vfs_options = array(
1021 1091
 			'mindepth' => 1,
@@ -1139,7 +1209,10 @@  discard block
 block discarded – undo
1139 1209
 							if (!($dir = Vfs::dirname($path)))
1140 1210
 							{
1141 1211
 								$msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false";
1142
-								if ($button == 'save') $button = 'apply';
1212
+								if ($button == 'save')
1213
+								{
1214
+									$button = 'apply';
1215
+								}
1143 1216
 								continue;
1144 1217
 							}
1145 1218
 							$to = Vfs::concat($dir, $content['name']);
@@ -1148,7 +1221,10 @@  discard block
 block discarded – undo
1148 1221
 								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1149 1222
 									lang('To overwrite the existing file store again.',lang($button)));
1150 1223
 								$content['confirm_overwrite'] = $to;
1151
-								if ($button == 'save') $button = 'apply';
1224
+								if ($button == 'save')
1225
+								{
1226
+									$button = 'apply';
1227
+								}
1152 1228
 								continue;
1153 1229
 							}
1154 1230
 							if (Vfs::rename($path,$to))
@@ -1221,13 +1297,19 @@  discard block
 block discarded – undo
1221 1297
 								}
1222 1298
 								if ($ok && !$failed)
1223 1299
 								{
1224
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1300
+									if(!$perm_changed++)
1301
+									{
1302
+										$msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1303
+									}
1225 1304
 									$content['old'][$name] = $content[$name];
1226 1305
 								}
1227 1306
 								elseif($failed)
1228 1307
 								{
1229
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1308
+									if(!$perm_failed++)
1309
+									{
1310
+										$msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1230 1311
 										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1312
+									}
1231 1313
 								}
1232 1314
 							}
1233 1315
 							elseif (call_user_func_array($cmd,array($path,$value)))
@@ -1280,7 +1362,10 @@  discard block
 block discarded – undo
1280 1362
 				}
1281 1363
 			}
1282 1364
 			Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*');
1283
-			if ($button == 'save') Framework::window_close();
1365
+			if ($button == 'save')
1366
+			{
1367
+				Framework::window_close();
1368
+			}
1284 1369
 		}
1285 1370
 		if ($content['is_link'] && !Vfs::stat($path))
1286 1371
 		{
@@ -1290,13 +1375,19 @@  discard block
 block discarded – undo
1290 1375
 		$content['icon'] = Vfs::mime_icon($content['mime']);
1291 1376
 		$content['msg'] = $msg;
1292 1377
 
1293
-		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1378
+		if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid'])
1379
+		{
1380
+			$content['ro_uid_root'] = 'root';
1381
+		}
1294 1382
 		// only owner can change group & perms
1295 1383
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1296 1384
 			Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs
1297 1385
 				 !Vfs::is_writable($path))
1298 1386
 		{
1299
-			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1387
+			if (!$content['gid'])
1388
+			{
1389
+				$content['ro_gid_root'] = 'root';
1390
+			}
1300 1391
 			foreach($content['perms'] as $name => $value)
1301 1392
 			{
1302 1393
 				$readonlys['perms['.$name.']'] = true;
@@ -1331,9 +1422,13 @@  discard block
 block discarded – undo
1331 1422
 				0 => lang('No access'),
1332 1423
 			);
1333 1424
 			if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false &&	// backend supports eacl
1334
-				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)	// leave eACL tab disabled for sharing
1425
+				$GLOBALS['egw_info']['user']['account_id'] == Vfs::$user)
1426
+			{
1427
+				// leave eACL tab disabled for sharing
1335 1428
 			{
1336
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1429
+				unset($readonlys['tabs']['filemanager.file.eacl']);
1430
+			}
1431
+			// --> switch the tab on again
1337 1432
 				foreach($content['eacl'] as &$eacl)
1338 1433
 				{
1339 1434
 					$eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
@@ -1390,10 +1485,13 @@  discard block
 block discarded – undo
1390 1485
 				'comment' => (string)$content['comment'],
1391 1486
 				'mergeapp' => $content['mergeapp']
1392 1487
 			);
1393
-			if ($cfs) foreach($cfs as $name => $data)
1488
+			if ($cfs)
1489
+			{
1490
+				foreach($cfs as $name => $data)
1394 1491
 			{
1395 1492
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1396 1493
 			}
1494
+			}
1397 1495
 		}
1398 1496
 		if (Vfs::$is_root)
1399 1497
 		{
@@ -1420,7 +1518,10 @@  discard block
 block discarded – undo
1420 1518
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1421 1519
 
1422 1520
 			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1423
-			if (true) $tabs = array();
1521
+			if (true)
1522
+			{
1523
+				$tabs = array();
1524
+			}
1424 1525
 
1425 1526
 			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1426 1527
 			{
@@ -1484,7 +1585,10 @@  discard block
 block discarded – undo
1484 1585
 			'files' => 0,
1485 1586
 		);
1486 1587
 
1487
-		if (!isset($dir)) $dir = array_pop($selected);
1588
+		if (!isset($dir))
1589
+		{
1590
+			$dir = array_pop($selected);
1591
+		}
1488 1592
 
1489 1593
 		switch($action)
1490 1594
 		{
@@ -1582,7 +1686,10 @@  discard block
 block discarded – undo
1582 1686
 					$target=Vfs::concat($dir,Vfs::encodePathComponent($file['name']));
1583 1687
 					if (Vfs::file_exists($target) && $app_dir)
1584 1688
 					{
1585
-						if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir);
1689
+						if (!Vfs::file_exists($app_dir))
1690
+						{
1691
+							Vfs::mkdir($app_dir);
1692
+						}
1586 1693
 						error_log("Symlinking $target to $app_dir");
1587 1694
 						Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name'])));
1588 1695
 					}
Please login to merge, or discard this patch.
home/inc/class.home_ui.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@
 block discarded – undo
155 155
 	 * Get a list of the user's portlets, and their associated values & settings, for display
156 156
 	 *
157 157
 	 * Actual portlet content is provided by each portlet.
158
-	 * @param template etemplate so attributes can be set
158
+	 * @param template Etemplate so attributes can be set
159 159
 	 */
160 160
 	protected function get_user_portlets(Etemplate &$template)
161 161
 	{
Please login to merge, or discard this patch.
Braces   +58 added lines, -16 removed lines patch added patch discarded remove patch
@@ -76,7 +76,10 @@  discard block
 block discarded – undo
76 76
 		{
77 77
 			$id = $p_data['id'];
78 78
 
79
-			if(!$id) continue;
79
+			if(!$id)
80
+			{
81
+				continue;
82
+			}
80 83
 			$portlet = $this->get_portlet($id, $p_data, $content, $attrs, true);
81 84
 		}
82 85
 
@@ -135,7 +138,10 @@  discard block
 block discarded – undo
135 138
 			{
136 139
 				foreach($children['children'] as $portlet => $app_portlet)
137 140
 				{
138
-					if(!is_array($app_portlet)) continue;
141
+					if(!is_array($app_portlet))
142
+					{
143
+						continue;
144
+					}
139 145
 					$app_portlet['class'] = $portlet;
140 146
 					$app_portlet['id'] = 'drop_' . $app_portlet['id'];
141 147
 					$app_portlet['onExecute'] = $drop_execute;
@@ -166,14 +172,21 @@  discard block
 block discarded – undo
166 172
 			if(strpos($id,'portlet_') !== 0 || // Not a portlet
167 173
 				in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here
168 174
 				!is_array($context) // Not a valid portlet (probably user deleted a default)
169
-			) continue;
175
+			)
176
+			{
177
+				continue;
178
+			}
170 179
 
171 180
 			$classname = $context['class'];
172 181
 
173 182
 			// Avoid portlets for apps user can't use (eg. from defaults/forced)
174 183
 			list($app,$other) = explode('_',$classname);
175
-			if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other;
176
-			if(!$GLOBALS['egw_info']['user']['apps'][$app]) {
184
+			if(!$GLOBALS['egw_info']['apps'][$app])
185
+			{
186
+				$app .='_'.$other;
187
+			}
188
+			if(!$GLOBALS['egw_info']['user']['apps'][$app])
189
+			{
177 190
 				continue;
178 191
 			}
179 192
 
@@ -189,7 +202,10 @@  discard block
 block discarded – undo
189 202
 			$settings = $portlet->get_properties();
190 203
 			foreach($settings as $key => $setting)
191 204
 			{
192
-				if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
205
+				if(is_array($setting) && !array_key_exists('type',$setting))
206
+				{
207
+					unset($settings[$key]);
208
+				}
193 209
 			}
194 210
 			$settings += $context;
195 211
 			foreach(home_portlet::$common_attributes as $attr)
@@ -229,7 +245,10 @@  discard block
 block discarded – undo
229 245
 	 */
230 246
 	protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false)
231 247
 	{
232
-		if(!$context['class']) $context['class'] = 'home_link_portlet';
248
+		if(!$context['class'])
249
+		{
250
+			$context['class'] = 'home_link_portlet';
251
+		}
233 252
 
234 253
 		// This should be set already, but just in case the execution path
235 254
 		// is different from normal...
@@ -250,7 +269,10 @@  discard block
 block discarded – undo
250 269
 		$settings = $portlet->get_properties();
251 270
 		foreach($settings as $key => $setting)
252 271
 		{
253
-			if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
272
+			if(is_array($setting) && !array_key_exists('type',$setting))
273
+			{
274
+				unset($settings[$key]);
275
+			}
254 276
 		}
255 277
 		$settings += $context;
256 278
 		foreach(home_portlet::$common_attributes as $attr)
@@ -314,7 +336,10 @@  discard block
 block discarded – undo
314 336
 		foreach($sorted_apps as $appname)
315 337
 		{
316 338
 			// If there's already [new] settings, or no preference, skip it
317
-			if($content[$appname]) continue;
339
+			if($content[$appname])
340
+			{
341
+				continue;
342
+			}
318 343
 			$no_pref = true;
319 344
 			foreach($portal_oldvarnames as $varcheck)
320 345
 			{
@@ -349,7 +374,8 @@  discard block
 block discarded – undo
349 374
 	 */
350 375
 	protected function get_portlet_list()
351 376
 	{
352
-		$list = Api\Cache::getTree('home', 'portlet_classes', function() {
377
+		$list = Api\Cache::getTree('home', 'portlet_classes', function()
378
+		{
353 379
 			$list = array();
354 380
 			$classes = array();
355 381
 
@@ -363,9 +389,15 @@  discard block
 block discarded – undo
363 389
 			// Look through all known classes for portlets - for now, they need 'portlet' in the file name
364 390
 			foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname)
365 391
 			{
366
-				if(in_array($appname, array('phpgwapi', 'felamimail'))) continue;
392
+				if(in_array($appname, array('phpgwapi', 'felamimail')))
393
+				{
394
+					continue;
395
+				}
367 396
 				$files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/');
368
-				if(!$files) continue;
397
+				if(!$files)
398
+				{
399
+					continue;
400
+				}
369 401
 
370 402
 				foreach($files as $entry)
371 403
 				{
@@ -384,7 +416,10 @@  discard block
 block discarded – undo
384 416
 					}
385 417
 				}
386 418
 
387
-				if(!$classes[$appname]) continue;
419
+				if(!$classes[$appname])
420
+				{
421
+					continue;
422
+				}
388 423
 
389 424
 				// Build 'Add' actions for each discovered portlet.
390 425
 				// Portlets from other apps go in sub-actions
@@ -418,7 +453,8 @@  discard block
 block discarded – undo
418 453
 		// Filter list by current user's permissions
419 454
 		foreach(array_keys($list) as $appname)
420 455
 		{
421
-			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
456
+			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps'])))
457
+			{
422 458
 				if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
423 459
 				{
424 460
 					unset($list[$appname]);
@@ -638,7 +674,10 @@  discard block
 block discarded – undo
638 674
 	public static function ajax_set_default($action, $portlet_ids, $group)
639 675
 	{
640 676
 		// Admins only
641
-		if(!$GLOBALS['egw_info']['apps']['admin']) return;
677
+		if(!$GLOBALS['egw_info']['apps']['admin'])
678
+		{
679
+			return;
680
+		}
642 681
 
643 682
 		// Load the appropriate group
644 683
 		if($group)
@@ -701,7 +740,10 @@  discard block
 block discarded – undo
701 740
 		$preferences = $GLOBALS['egw']->preferences;
702 741
 		$preferences->read_repository();
703 742
 		$lang = $preferences->default['common']['lang'];
704
-		if (empty($lang)) $lang = 'en';
743
+		if (empty($lang))
744
+		{
745
+			$lang = 'en';
746
+		}
705 747
 
706 748
 		Api\Translation::add_app('calendar', $lang);
707 749
 		$weekview = lang('Weekview');
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
 		$content = array(
50 50
 			'portlets' => $this->get_user_portlets($template)
51 51
 		);
52
-		$template->setElementAttribute('home.index','actions',$this->get_actions());
52
+		$template->setElementAttribute('home.index', 'actions', $this->get_actions());
53 53
 
54 54
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('home');
55 55
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'home';
56 56
 
57 57
 		// Main screen message
58 58
 		Api\Translation::add_app('mainscreen');
59
-		$greeting = Api\Translation::translate('mainscreen_message',false,'');
59
+		$greeting = Api\Translation::translate('mainscreen_message', false, '');
60 60
 
61
-		if($greeting == 'mainscreen_message'|| empty($greeting))
61
+		if ($greeting == 'mainscreen_message' || empty($greeting))
62 62
 		{
63
-			Api\Translation::add_app('mainscreen','en');    // trying the en one
64
-			$greeting = Api\Translation::translate('mainscreen_message',false,'');
63
+			Api\Translation::add_app('mainscreen', 'en'); // trying the en one
64
+			$greeting = Api\Translation::translate('mainscreen_message', false, '');
65 65
 		}
66
-		if(!($greeting == 'mainscreen_message'|| empty($greeting)))
66
+		if (!($greeting == 'mainscreen_message' || empty($greeting)))
67 67
 		{
68 68
 			$content['mainscreen_message'] = $greeting;
69 69
 		}
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
 		// Now run the portlets themselves
74 74
 		$attrs = array();
75
-		foreach($content['portlets'] as $portlet => $p_data)
75
+		foreach ($content['portlets'] as $portlet => $p_data)
76 76
 		{
77 77
 			$id = $p_data['id'];
78 78
 
79
-			if(!$id) continue;
79
+			if (!$id) continue;
80 80
 			$portlet = $this->get_portlet($id, $p_data, $content, $attrs, true);
81 81
 		}
82 82
 
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 		$add_portlets = $portlets;
95 95
 		$change_for_add = function(&$add_portlets) use (&$change_for_add)
96 96
 		{
97
-			foreach($add_portlets as $id => &$add)
97
+			foreach ($add_portlets as $id => &$add)
98 98
 			{
99
-				if(is_array($add['children']))
99
+				if (is_array($add['children']))
100 100
 				{
101 101
 					$change_for_add($add['children']);
102 102
 				}
103
-				if($id && !$add['children'])
103
+				if ($id && !$add['children'])
104 104
 				{
105
-					$add['id'] = 'add_' . $id;
105
+					$add['id'] = 'add_'.$id;
106 106
 					$add['class'] = 'add_'.$id;
107 107
 				}
108 108
 			}
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 
122 122
 		// Add all known portlets as drop actions too.  If there are multiple matches, there will be a menu
123 123
 		$drop_execute = 'javaScript:app.home.add_from_drop';
124
-		foreach($portlets as $app => &$children)
124
+		foreach ($portlets as $app => &$children)
125 125
 		{
126 126
 			// Home portlets - uses link system, so all apps that support that are accepted
127
-			if(!$children['children'])
127
+			if (!$children['children'])
128 128
 			{
129 129
 				$children['class'] = $app;
130 130
 				$children['onExecute'] = $drop_execute;
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 			}
134 134
 			else
135 135
 			{
136
-				foreach($children['children'] as $portlet => $app_portlet)
136
+				foreach ($children['children'] as $portlet => $app_portlet)
137 137
 				{
138
-					if(!is_array($app_portlet)) continue;
138
+					if (!is_array($app_portlet)) continue;
139 139
 					$app_portlet['class'] = $portlet;
140
-					$app_portlet['id'] = 'drop_' . $app_portlet['id'];
140
+					$app_portlet['id'] = 'drop_'.$app_portlet['id'];
141 141
 					$app_portlet['onExecute'] = $drop_execute;
142 142
 					$app_portlet['acceptedTypes'] = $app;
143 143
 					$app_portlet['type'] = 'drop';
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	{
162 162
 		$portlets = array();
163 163
 
164
-		foreach((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context)
164
+		foreach ((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context)
165 165
 		{
166
-			if(strpos($id,'portlet_') !== 0 || // Not a portlet
166
+			if (strpos($id, 'portlet_') !== 0 || // Not a portlet
167 167
 				in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here
168 168
 				!is_array($context) // Not a valid portlet (probably user deleted a default)
169 169
 			) continue;
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 			$classname = $context['class'];
172 172
 
173 173
 			// Avoid portlets for apps user can't use (eg. from defaults/forced)
174
-			list($app,$other) = explode('_',$classname);
175
-			if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other;
176
-			if(!$GLOBALS['egw_info']['user']['apps'][$app]) {
174
+			list($app, $other) = explode('_', $classname);
175
+			if (!$GLOBALS['egw_info']['apps'][$app]) $app .= '_'.$other;
176
+			if (!$GLOBALS['egw_info']['user']['apps'][$app]) {
177 177
 				continue;
178 178
 			}
179 179
 
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 			// Get settings
188 188
 			// Exclude common attributes changed through UI and settings lacking a type
189 189
 			$settings = $portlet->get_properties();
190
-			foreach($settings as $key => $setting)
190
+			foreach ($settings as $key => $setting)
191 191
 			{
192
-				if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
192
+				if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]);
193 193
 			}
194 194
 			$settings += $context;
195
-			foreach(home_portlet::$common_attributes as $attr)
195
+			foreach (home_portlet::$common_attributes as $attr)
196 196
 			{
197 197
 				unset($settings[$attr]);
198 198
 			}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 			// Add in default for admins
206 206
 			self::create_default_actions($actions, $id);
207 207
 
208
-			$template->setElementAttribute("portlets[" . count($portlets) . "[$id]", 'actions', $actions);
208
+			$template->setElementAttribute("portlets[".count($portlets)."[$id]", 'actions', $actions);
209 209
 
210 210
 			$portlets[] = $portlet_content;
211 211
 		}
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false)
231 231
 	{
232
-		if(!$context['class']) $context['class'] = 'home_link_portlet';
232
+		if (!$context['class']) $context['class'] = 'home_link_portlet';
233 233
 
234 234
 		// This should be set already, but just in case the execution path
235 235
 		// is different from normal...
236
-		if(Api\Json\Response::isJSONResponse())
236
+		if (Api\Json\Response::isJSONResponse())
237 237
 		{
238 238
 			$GLOBALS['egw']->framework->response = Api\Json\Response::get();
239 239
 		}
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 
249 249
 		// Exclude common attributes changed through UI and settings lacking a type
250 250
 		$settings = $portlet->get_properties();
251
-		foreach($settings as $key => $setting)
251
+		foreach ($settings as $key => $setting)
252 252
 		{
253
-			if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
253
+			if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]);
254 254
 		}
255 255
 		$settings += $context;
256
-		foreach(home_portlet::$common_attributes as $attr)
256
+		foreach (home_portlet::$common_attributes as $attr)
257 257
 		{
258 258
 			unset($settings[$attr]);
259 259
 		}
@@ -268,31 +268,31 @@  discard block
 block discarded – undo
268 268
 		self::create_default_actions($attributes['actions'], $id);
269 269
 
270 270
 		// Set any provided common attributes (size, etc)
271
-		foreach(home_portlet::$common_attributes as $name)
271
+		foreach (home_portlet::$common_attributes as $name)
272 272
 		{
273
-			if(array_key_exists($name, $context))
273
+			if (array_key_exists($name, $context))
274 274
 			{
275 275
 				$attributes[$name] = $context[$name];
276 276
 			}
277 277
 		}
278
-		foreach($attributes as $attr => $value)
278
+		foreach ($attributes as $attr => $value)
279 279
 		{
280 280
 			$etemplate->setElementAttribute($id, $attr, $value);
281 281
 		}
282 282
 
283 283
 		// Make sure custom javascript is loaded
284 284
 		$appname = $context['appname'];
285
-		if(!$appname)
285
+		if (!$appname)
286 286
 		{
287
-			list($app) = explode('_',$classname);
288
-			if($GLOBALS['egw_info']['apps'][$app])
287
+			list($app) = explode('_', $classname);
288
+			if ($GLOBALS['egw_info']['apps'][$app])
289 289
 			{
290 290
 				$appname = $app;
291 291
 			}
292 292
 		}
293 293
 		Framework::includeJS('', $classname, $appname ? $appname : 'home');
294 294
 
295
-		if($full_exec)
295
+		if ($full_exec)
296 296
 		{
297 297
 			$content = $portlet->exec($id, $etemplate, $full_exec ? 2 : -1);
298 298
 		}
@@ -309,23 +309,23 @@  discard block
 block discarded – undo
309 309
 	protected function get_legacy_portlets(&$content, &$attributes)
310 310
 	{
311 311
 		$sorted_apps = array_keys($GLOBALS['egw_info']['user']['apps']);
312
-		$portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated', 'homepage_display');
312
+		$portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents', 'homeShowLatest', 'mainscreen_showmail', 'mainscreen_showbirthdays', 'mainscreen_show_new_updated', 'homepage_display');
313 313
 
314
-		foreach($sorted_apps as $appname)
314
+		foreach ($sorted_apps as $appname)
315 315
 		{
316 316
 			// If there's already [new] settings, or no preference, skip it
317
-			if($content[$appname]) continue;
317
+			if ($content[$appname]) continue;
318 318
 			$no_pref = true;
319
-			foreach($portal_oldvarnames as $varcheck)
319
+			foreach ($portal_oldvarnames as $varcheck)
320 320
 			{
321 321
 				$thisd = $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck];
322
-				if($thisd)
322
+				if ($thisd)
323 323
 				{
324 324
 					$no_pref = false;
325 325
 					break;
326 326
 				}
327 327
 			}
328
-			if($no_pref || !Api\Hooks::exists('home', $appname))
328
+			if ($no_pref || !Api\Hooks::exists('home', $appname))
329 329
 			{
330 330
 				continue;
331 331
 			}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 			$_content = '';
337 337
 			$_attributes = array();
338 338
 			$this->get_portlet($appname, $context, $_content, $_attributes);
339
-			if(trim($_content))
339
+			if (trim($_content))
340 340
 			{
341 341
 				$content[$appname] = $_content;
342 342
 				$attributes[$appname] = $_attributes;
@@ -355,24 +355,24 @@  discard block
 block discarded – undo
355 355
 
356 356
 			// Ignore some problem files and base classes that shouldn't be options
357 357
 			$ignore = array(
358
-				'.','..',
358
+				'.', '..',
359 359
 				'class.home_portlet.inc.php',
360 360
 				'class.home_legacy_portlet.inc.php',
361 361
 				'class.home_favorite_portlet.inc.php'
362 362
 			);
363 363
 			// Look through all known classes for portlets - for now, they need 'portlet' in the file name
364
-			foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname)
364
+			foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname)
365 365
 			{
366
-				if(in_array($appname, array('phpgwapi', 'felamimail'))) continue;
367
-				$files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/');
368
-				if(!$files) continue;
366
+				if (in_array($appname, array('phpgwapi', 'felamimail'))) continue;
367
+				$files = (array)@scandir(EGW_SERVER_ROOT.'/'.$appname.'/inc/');
368
+				if (!$files) continue;
369 369
 
370
-				foreach($files as $entry)
370
+				foreach ($files as $entry)
371 371
 				{
372
-					if (!in_array($entry, $ignore) && substr($entry,-8) == '.inc.php' && strpos($entry,'portlet'))
372
+					if (!in_array($entry, $ignore) && substr($entry, -8) == '.inc.php' && strpos($entry, 'portlet'))
373 373
 					{
374 374
 						list(,$classname) = explode('.', $entry);
375
-						if(class_exists($classname) &&
375
+						if (class_exists($classname) &&
376 376
 							in_array('home_portlet', class_parents($classname, false)))
377 377
 						{
378 378
 							$classes[$appname][] = $classname;
@@ -384,19 +384,19 @@  discard block
 block discarded – undo
384 384
 					}
385 385
 				}
386 386
 
387
-				if(!$classes[$appname]) continue;
387
+				if (!$classes[$appname]) continue;
388 388
 
389 389
 				// Build 'Add' actions for each discovered portlet.
390 390
 				// Portlets from other apps go in sub-actions
391
-				$add_to =& $list;
392
-				if($classes[$appname] && $appname != 'home')
391
+				$add_to = & $list;
392
+				if ($classes[$appname] && $appname != 'home')
393 393
 				{
394 394
 					$list[$appname] = array(
395 395
 						'caption' => lang($appname),
396 396
 					);
397
-					$add_to =& $list[$appname]['children'];
397
+					$add_to = & $list[$appname]['children'];
398 398
 				}
399
-				foreach($classes[$appname] as $portlet)
399
+				foreach ($classes[$appname] as $portlet)
400 400
 				{
401 401
 					$instance = new $portlet();
402 402
 					$desc = $instance->get_description();
@@ -416,10 +416,10 @@  discard block
 block discarded – undo
416 416
 		}, array(), 60);
417 417
 
418 418
 		// Filter list by current user's permissions
419
-		foreach(array_keys($list) as $appname)
419
+		foreach (array_keys($list) as $appname)
420 420
 		{
421
-			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
422
-				if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
421
+			if (in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
422
+				if (!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
423 423
 				{
424 424
 					unset($list[$appname]);
425 425
 				}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 */
437 437
 	protected static function create_default_actions(&$actions, $portlet_id = null)
438 438
 	{
439
-		if($GLOBALS['egw_info']['user']['apps']['admin'])
439
+		if ($GLOBALS['egw_info']['user']['apps']['admin'])
440 440
 		{
441 441
 			$actions['add_default'] = array(
442 442
 				'type'		=> 'popup',
@@ -446,25 +446,25 @@  discard block
 block discarded – undo
446 446
 				'icon'		=> 'preference'
447 447
 			);
448 448
 			// Customize for the given portlet
449
-			if($portlet_id !== null)
449
+			if ($portlet_id !== null)
450 450
 			{
451
-				foreach(array('forced','group','default') as $location)
451
+				foreach (array('forced', 'group', 'default') as $location)
452 452
 				{
453 453
 					$loc = $GLOBALS['egw']->preferences->$location;
454 454
 
455
-					if($loc['home'][$portlet_id])
455
+					if ($loc['home'][$portlet_id])
456 456
 					{
457 457
 						// If it's forced, no point in setting default
458
-						if($location == 'forced')
458
+						if ($location == 'forced')
459 459
 						{
460 460
 							unset($actions['add_default']);
461 461
 						}
462 462
 						// If it's a group, we'd like to know which
463
-						if($location == 'group')
463
+						if ($location == 'group')
464 464
 						{
465 465
 							$options = array('account_type' => 'groups');
466
-							$groups = Api\Accounts::link_query('',$options);
467
-							foreach(array_keys($groups) as $gid)
466
+							$groups = Api\Accounts::link_query('', $options);
467
+							foreach (array_keys($groups) as $gid)
468 468
 							{
469 469
 								$prefs = new Api\Preferences($gid);
470 470
 								$prefs->read_repository();
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 						}
478 478
 						$actions['remove_default_'.$location] = array(
479 479
 							'type'		=> 'popup',
480
-							'caption'	=> lang('Remove as default for %1',is_numeric($location) ? Api\Accounts::id2name($location,'account_fullname') : $location),
480
+							'caption'	=> lang('Remove as default for %1', is_numeric($location) ? Api\Accounts::id2name($location, 'account_fullname') : $location),
481 481
 							'onExecute'	=> 'javaScript:app.home.set_default',
482 482
 							'group'		=> 'Admins',
483 483
 							'portlet_group' => $location
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
 		}
489 489
 
490 490
 		// Change action for forced
491
-		if($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id])
491
+		if ($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id])
492 492
 		{
493 493
 			// No one can remove it
494 494
 			$actions['remove_portlet']['enabled'] = false;
495
-			$actions['remove_portlet']['caption'] .= ' ('.lang('Forced') .')';
495
+			$actions['remove_portlet']['caption'] .= ' ('.lang('Forced').')';
496 496
 
497 497
 			// Non-admins can't edit it
498
-			if($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin'])
498
+			if ($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin'])
499 499
 			{
500 500
 				$actions['edit_settings']['enabled'] = false;
501 501
 				$actions['edit_settings']['visible'] = false;
@@ -514,14 +514,14 @@  discard block
 block discarded – undo
514 514
 	public function ajax_set_properties($portlet_id, $attributes, $values, $group = false)
515 515
 	{
516 516
 		//error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)");
517
-		if(!$attributes)
517
+		if (!$attributes)
518 518
 		{
519 519
 			$attributes = array();
520 520
 		}
521 521
 
522
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
522
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
523 523
 		{
524
-			if($group == 'forced')
524
+			if ($group == 'forced')
525 525
 			{
526 526
 				// Quietly reject
527 527
 				return;
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 			// Not an admin, can only override.
530 530
 			$group = false;
531 531
 		}
532
-		if($group && $GLOBALS['egw_info']['user']['apps']['admin'])
532
+		if ($group && $GLOBALS['egw_info']['user']['apps']['admin'])
533 533
 		{
534 534
 			$prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
535 535
 		}
@@ -543,23 +543,23 @@  discard block
 block discarded – undo
543 543
 
544 544
 		$response = Api\Json\Response::get();
545 545
 
546
-		if($values =='~reload~')
546
+		if ($values == '~reload~')
547 547
 		{
548 548
 			$full_exec = true;
549 549
 			$values = array();
550 550
 		}
551
-		if($values == '~remove~')
551
+		if ($values == '~remove~')
552 552
 		{
553 553
 			// Already removed client side, needs to be removed permanently
554
-			$default = $prefs->default_prefs('home',$portlet_id) || $prefs->group['home'][$portlet_id];
554
+			$default = $prefs->default_prefs('home', $portlet_id) || $prefs->group['home'][$portlet_id];
555 555
 
556
-			if($default)
556
+			if ($default)
557 557
 			{
558 558
 				// Can't delete forced - not a UI option though
559
-				if(!$GLOBALS['egw']->preferences->forced['home'][$portlet_id])
559
+				if (!$GLOBALS['egw']->preferences->forced['home'][$portlet_id])
560 560
 				{
561 561
 					// Set a flag to override default instead of just delete
562
-					$GLOBALS['egw']->preferences->add('home',$portlet_id, 'deleted');
562
+					$GLOBALS['egw']->preferences->add('home', $portlet_id, 'deleted');
563 563
 					$GLOBALS['egw']->preferences->save_repository();
564 564
 				}
565 565
 			}
@@ -576,19 +576,19 @@  discard block
 block discarded – undo
576 576
 			// Remove some constant stuff that winds up here
577 577
 			unset($values['edit_template']);
578 578
 			unset($values['readonly']);
579
-			unset($values['disabled']);unset($values['no_lang']);
579
+			unset($values['disabled']); unset($values['no_lang']);
580 580
 			unset($values['actions']);
581 581
 			unset($values['statustext']);
582
-			unset($values['type']);unset($values['label']);unset($values['status']);
583
-			unset($values['value']);unset($values['align']);
582
+			unset($values['type']); unset($values['label']); unset($values['status']);
583
+			unset($values['value']); unset($values['align']);
584 584
 
585 585
 			// Get portlet settings, and merge new with old
586 586
 			$context = array_merge((array)$portlets[$portlet_id], $values);
587 587
 			$context['group'] = $group;
588 588
 
589 589
 			// Handle add IDs
590
-			$classname =& $context['class'];
591
-			if(strpos($classname,'add_') == 0 && !class_exists($classname))
590
+			$classname = & $context['class'];
591
+			if (strpos($classname, 'add_') == 0 && !class_exists($classname))
592 592
 			{
593 593
 				$add = true;
594 594
 				$classname = substr($classname, 4);
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
 			$portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec);
598 598
 
599 599
 			$context['class'] = get_class($portlet);
600
-			foreach($portlet->get_properties() as $property)
600
+			foreach ($portlet->get_properties() as $property)
601 601
 			{
602
-				if($values[$property['name']])
602
+				if ($values[$property['name']])
603 603
 				{
604 604
 					$context[$property['name']] = $values[$property['name']];
605 605
 				}
606
-				elseif($portlets[$portlet_id][$property['name']])
606
+				elseif ($portlets[$portlet_id][$property['name']])
607 607
 				{
608 608
 					$context[$property['name']] = $portlets[$portlet_id][$property['name']];
609 609
 				}
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 			$update = array('attributes' => $attributes);
614 614
 
615 615
 			// New portlet?  Flag going straight to edit mode
616
-			if($add)
616
+			if ($add)
617 617
 			{
618 618
 				$update['edit_settings'] = true;
619 619
 			}
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 		}
626 626
 
627 627
 		// Save updated preferences
628
-		$prefs->save_repository(True,$type);
628
+		$prefs->save_repository(True, $type);
629 629
 	}
630 630
 
631 631
 	/**
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 	public static function ajax_set_default($action, $portlet_ids, $group)
639 639
 	{
640 640
 		// Admins only
641
-		if(!$GLOBALS['egw_info']['apps']['admin']) return;
641
+		if (!$GLOBALS['egw_info']['apps']['admin']) return;
642 642
 
643 643
 		// Load the appropriate group
644
-		if($group)
644
+		if ($group)
645 645
 		{
646 646
 			$prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
647 647
 		}
@@ -653,30 +653,30 @@  discard block
 block discarded – undo
653 653
 
654 654
 		$type = is_numeric($group) ? "user" : $group;
655 655
 
656
-		if($action == 'add')
656
+		if ($action == 'add')
657 657
 		{
658
-			foreach($portlet_ids as $id)
658
+			foreach ($portlet_ids as $id)
659 659
 			{
660 660
 				Api\Json\Response::get()->call('egw.message', lang("Set default"));
661 661
 				// Current user is setting the default, copy their settings
662 662
 				$settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id];
663 663
 				$settings['group'] = $group;
664
-				$prefs->add('home',$id,$settings,$type);
664
+				$prefs->add('home', $id, $settings, $type);
665 665
 
666 666
 				// Remove user's copy
667
-				$GLOBALS['egw']->preferences->delete('home',$id);
667
+				$GLOBALS['egw']->preferences->delete('home', $id);
668 668
 				$GLOBALS['egw']->preferences->save_repository(true);
669 669
 			}
670 670
 		}
671 671
 		else if ($action == "delete")
672 672
 		{
673
-			foreach($portlet_ids as $id)
673
+			foreach ($portlet_ids as $id)
674 674
 			{
675 675
 				Api\Json\Response::get()->call('egw.message', lang("Removed default"));
676
-				$prefs->delete('home',$id, $type);
676
+				$prefs->delete('home', $id, $type);
677 677
 			}
678 678
 		}
679
-		$prefs->save_repository(false,$type);
679
+		$prefs->save_repository(false, $type);
680 680
 
681 681
 		// Update Api\Preferences client side for consistency
682 682
 		$prefs = $GLOBALS['egw']->preferences;
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 						'state' => array(
730 730
 							'cat_id' => '0',
731 731
 							'filter' => 'default',
732
-							'owner' => 0,	// current user
732
+							'owner' => 0, // current user
733 733
 							'sortby' => 'user',
734 734
 							'planner_days' => '0',
735 735
 							'view' => 'week',
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
 		{
779 779
 			unset($app_prefs['home']['portlet_setup142n']);
780 780
 		}
781
-		foreach($app_prefs as $app => $prefs)
781
+		foreach ($app_prefs as $app => $prefs)
782 782
 		{
783
-			foreach($prefs as $name => $value)
783
+			foreach ($prefs as $name => $value)
784 784
 			{
785 785
 				Api\Preferences::delete_preference($app, $name, 'default');
786 786
 				$preferences->add($app, $name, $value, 'default');
@@ -801,10 +801,10 @@  discard block
 block discarded – undo
801 801
 	 */
802 802
 	public static function setup_default_home()
803 803
 	{
804
-		switch($GLOBALS['egw_info']['server'][self::HOME_VERSION])
804
+		switch ($GLOBALS['egw_info']['server'][self::HOME_VERSION])
805 805
 		{
806 806
 			case self::CURRENT_HOME_VERSION:
807
-				return;	// already up to date --> nothing to do
807
+				return; // already up to date --> nothing to do
808 808
 
809 809
 			default:
810 810
 				call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION)));
Please login to merge, or discard this patch.
importexport/inc/class.importexport_basic_import_csv.inc.php 5 patches
Doc Comments   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -118,8 +118,7 @@  discard block
 block discarded – undo
118 118
 	/**
119 119
 	 * imports entries according to given definition object.
120 120
 	 * @param resource $_stream
121
-	 * @param string $_charset
122
-	 * @param definition $_definition
121
+	 * @param importexport_definition $_definition
123 122
 	 */
124 123
 	public function import( $_stream, importexport_definition $_definition ) {
125 124
 		$import_csv = new importexport_import_csv( $_stream, array(
@@ -222,7 +221,7 @@  discard block
 block discarded – undo
222 221
 	*
223 222
 	* Updates the count of actions taken
224 223
 	*
225
-	* @return boolean success
224
+	* @return null|boolean success
226 225
 	*/
227 226
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
228 227
 	{
@@ -274,7 +273,7 @@  discard block
 block discarded – undo
274 273
 	 * @param condition array = array('string' => field name)
275 274
 	 * @param matches - On return, will be filled with matching records
276 275
 	 *
277
-	 * @return boolean
276
+	 * @return boolean|null
278 277
 	 */
279 278
 	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array())
280 279
 	{
@@ -451,7 +450,7 @@  discard block
 block discarded – undo
451 450
 	/**
452 451
 	 * Allows an extending class to alter a row for preview
453 452
 	 *
454
-	 * @param egw_record $row_entry
453
+	 * @param importexport_iface_egw_record $row_entry
455 454
 	 */
456 455
 	protected function row_preview(importexport_iface_egw_record &$row_entry)
457 456
 	{
@@ -523,7 +522,7 @@  discard block
 block discarded – undo
523 522
 	 * Get the primary key for an entry based on a custom field
524 523
 	 * Returns key, so regular linking can take over
525 524
 	 *
526
-	 * @param int $record_number Row number, used for errors
525
+	 * @param int $record_num Row number, used for errors
527 526
 	 * @param string $app Target application name
528 527
 	 * @param string $value CSV value in the form of custom_field_name:value
529 528
 	 */
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		$record_class = isset(static::$record_class) ? static::$record_class : "{$app}_egw_record";
164 164
 
165 165
 		// Needed for categories to work right
166
-        $GLOBALS['egw_info']['flags']['currentapp'] = $app;
166
+		$GLOBALS['egw_info']['flags']['currentapp'] = $app;
167 167
 
168 168
 		$this->init($_definition);
169 169
 
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 	}
216 216
 
217 217
 	/**
218
-	*Import a single record
219
-	*
220
-	* You don't need to worry about mappings or translations, they've been done already.
221
-	* You do need to handle the conditions and the actions taken.
222
-	*
223
-	* Updates the count of actions taken
224
-	*
225
-	* @return boolean success
226
-	*/
218
+	 *Import a single record
219
+	 *
220
+	 * You don't need to worry about mappings or translations, they've been done already.
221
+	 * You do need to handle the conditions and the actions taken.
222
+	 *
223
+	 * Updates the count of actions taken
224
+	 *
225
+	 * @return boolean success
226
+	 */
227 227
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
228 228
 	{
229 229
 		if ( $this->definition->plugin_options['conditions'] ) {
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 * @param stream $stream
404 404
 	 * @param importexport_definition $definition
405 405
 	 * @return String HTML for preview
406
-         */
406
+	 */
407 407
 	public function preview( $stream, importexport_definition $definition )
408 408
 	{
409 409
 		$this->import($stream, $definition);
@@ -639,37 +639,37 @@  discard block
 block discarded – undo
639 639
 	}
640 640
 
641 641
 	/**
642
-	* Returns warnings that were encountered during importing
643
-	* Maximum of one warning message per record, but you can append if you need to
644
-	*
645
-	* @return Array (
646
-	*       record_# => warning message
647
-	*       )
648
-	*/
642
+	 * Returns warnings that were encountered during importing
643
+	 * Maximum of one warning message per record, but you can append if you need to
644
+	 *
645
+	 * @return Array (
646
+	 *       record_# => warning message
647
+	 *       )
648
+	 */
649 649
 	public function get_warnings() {
650 650
 		return $this->warnings;
651 651
 	}
652 652
 
653 653
 	/**
654
-	* Returns errors that were encountered during importing
655
-	* Maximum of one error message per record, but you can append if you need to
656
-	*
657
-	* @return Array (
658
-	*       record_# => error message
659
-	*       )
660
-	*/
654
+	 * Returns errors that were encountered during importing
655
+	 * Maximum of one error message per record, but you can append if you need to
656
+	 *
657
+	 * @return Array (
658
+	 *       record_# => error message
659
+	 *       )
660
+	 */
661 661
 	public function get_errors() {
662 662
 		return $this->errors;
663 663
 	}
664 664
 
665 665
 	/**
666
-	* Returns a list of actions taken, and the number of records for that action.
667
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
668
-	*
669
-	* @return Array (
670
-	*       action => record count
671
-	* )
672
-	*/
666
+	 * Returns a list of actions taken, and the number of records for that action.
667
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
668
+	 *
669
+	 * @return Array (
670
+	 *       action => record count
671
+	 * )
672
+	 */
673 673
 	public function get_results() {
674 674
 			return $this->results;
675 675
 	}
Please login to merge, or discard this patch.
Braces   +96 added lines, -36 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@  discard block
 block discarded – undo
18 18
  * should get you started on building a CSV plugin for an application fairly quickly.
19 19
  *
20 20
  */
21
-abstract class importexport_basic_import_csv implements importexport_iface_import_plugin  {
21
+abstract class importexport_basic_import_csv implements importexport_iface_import_plugin
22
+{
22 23
 
23 24
 	protected static $plugin_options = array(
24 25
 		'fieldsep', 		// char
@@ -121,7 +122,8 @@  discard block
 block discarded – undo
121 122
 	 * @param string $_charset
122 123
 	 * @param definition $_definition
123 124
 	 */
124
-	public function import( $_stream, importexport_definition $_definition ) {
125
+	public function import( $_stream, importexport_definition $_definition )
126
+	{
125 127
 		$import_csv = new importexport_import_csv( $_stream, array(
126 128
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
127 129
 			'charset' => $_definition->plugin_options['charset'],
@@ -143,9 +145,12 @@  discard block
 block discarded – undo
143 145
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
144 146
 
145 147
 		//check if file has a header lines
146
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
148
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
149
+		{
147 150
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
148
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
151
+		}
152
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
153
+		{
149 154
 			// First method is preferred
150 155
 			$import_csv->skip_records(1);
151 156
 		}
@@ -167,15 +172,22 @@  discard block
 block discarded – undo
167 172
 
168 173
 		$this->init($_definition);
169 174
 
170
-		while ( $record = $import_csv->get_record() ) {
175
+		while ( $record = $import_csv->get_record() )
176
+		{
171 177
 			$success = false;
172 178
 
173 179
 			// don't import empty records
174
-			if( count( array_unique( $record ) ) < 2 ) continue;
180
+			if( count( array_unique( $record ) ) < 2 )
181
+			{
182
+				continue;
183
+			}
175 184
 
176 185
 
177 186
 			$warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']);
178
-				if($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
187
+				if($warning)
188
+				{
189
+					$this->warnings[$import_csv->get_current_position()] = $warning;
190
+				}
179 191
 
180 192
 			$egw_record = new $record_class();
181 193
 			$egw_record->set_record($record);
@@ -185,7 +197,10 @@  discard block
 block discarded – undo
185 197
 			{
186 198
 				$this->do_special_fields($egw_record, $import_csv);
187 199
 			}
188
-			if($success) $count++;
200
+			if($success)
201
+			{
202
+				$count++;
203
+			}
189 204
 
190 205
 			// Add some more time
191 206
 			if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
@@ -226,10 +241,13 @@  discard block
 block discarded – undo
226 241
 	*/
227 242
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
228 243
 	{
229
-		if ( $this->definition->plugin_options['conditions'] ) {
230
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
244
+		if ( $this->definition->plugin_options['conditions'] )
245
+		{
246
+			foreach ( $this->definition->plugin_options['conditions'] as $condition )
247
+			{
231 248
 				$result = false;
232
-				switch ( $condition['type'] ) {
249
+				switch ( $condition['type'] )
250
+				{
233 251
 					// exists
234 252
 					case 'exists' :
235 253
 						// Check for that record
@@ -257,9 +275,14 @@  discard block
 block discarded – undo
257 275
 					$action = $condition['false'];
258 276
 					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
259 277
 				}
260
-				if ($action['stop']) break;
278
+				if ($action['stop'])
279
+				{
280
+					break;
281
+				}
261 282
 			}
262
-		} else {
283
+		}
284
+		else
285
+		{
263 286
 			// unconditional insert
264 287
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
265 288
 		}
@@ -343,9 +366,14 @@  discard block
 block discarded – undo
343 366
 			return;
344 367
 		}
345 368
 
346
-		foreach(self::$special_fields as $field => $desc) {
347
-			if(!$record->$field) continue;
348
-			if(strpos($field, 'link') === 0) {
369
+		foreach(self::$special_fields as $field => $desc)
370
+		{
371
+			if(!$record->$field)
372
+			{
373
+				continue;
374
+			}
375
+			if(strpos($field, 'link') === 0)
376
+			{
349 377
 				list($app, $app_id) = explode(':', $record->$field,2);
350 378
 
351 379
 				list($link, $type) = explode('_',$field);
@@ -364,7 +392,9 @@  discard block
 block discarded – undo
364 392
 						shift($result);
365 393
 					} while($result && !$app_id);
366 394
 				}
367
-			} else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) {
395
+			}
396
+			else if (in_array($field, array_keys($GLOBALS['egw_info']['apps'])))
397
+			{
368 398
 				$app = $field;
369 399
 				$app_id = $record->$field;
370 400
 
@@ -425,11 +455,16 @@  discard block
 block discarded – undo
425 455
 			$fields = $wizard->get_import_fields();
426 456
 			foreach($labels as $field => &$label)
427 457
 			{
428
-				if($fields[$field]) $label = $fields[$field];
458
+				if($fields[$field])
459
+				{
460
+					$label = $fields[$field];
461
+				}
429 462
 			}
430
-		} catch (Exception $e) {
463
+		}
464
+		catch (Exception $e) {
431 465
 			Api\Translation::add_app($definition->application);
432
-			foreach($labels as $field => &$label) {
466
+			foreach($labels as $field => &$label)
467
+			{
433 468
 				$label = lang($label);
434 469
 			}
435 470
 		}
@@ -468,7 +503,8 @@  discard block
 block discarded – undo
468 503
 	 * @param string $org_name
469 504
 	 * @return int|boolean Contact ID of first match, or false if none found
470 505
 	 */
471
-	public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) {
506
+	public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null)
507
+	{
472 508
 
473 509
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
474 510
 		static $contacts;
@@ -478,28 +514,40 @@  discard block
 block discarded – undo
478 514
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
479 515
 		}
480 516
 		$n_family = trim($n_family);
481
-		if(!is_null($n_given)) $n_given = trim($n_given);
517
+		if(!is_null($n_given))
518
+		{
519
+			$n_given = trim($n_given);
520
+		}
482 521
 		if (!is_object($contacts))
483 522
 		{
484 523
 			$contacts = new Api\Contacts();
485 524
 		}
486
-		if (!is_null($org_name))	// org_name given?
525
+		if (!is_null($org_name))
526
+		{
527
+			// org_name given?
487 528
 		{
488 529
 			$org_name = trim($org_name);
530
+		}
489 531
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
490 532
 			if (!count($addrs))
491 533
 			{
492 534
 				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
493 535
 			}
494 536
 		}
495
-		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
537
+		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))
538
+		{
539
+			// first name given and no result so far
496 540
 		{
497 541
 			$addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given));
498 542
 		}
499
-		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
543
+		}
544
+		if (is_null($n_given) && is_null($org_name))
545
+		{
546
+			// just one name given, check against fn (= full name)
500 547
 		{
501 548
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
502 549
 		}
550
+		}
503 551
 		if (count($addrs))
504 552
 		{
505 553
 			if(!$record || !$record->get_identifier())
@@ -551,13 +599,17 @@  discard block
 block discarded – undo
551 599
 			}
552 600
 
553 601
 			// Couldn't find field, give an error - something's wrong
554
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
602
+			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)])
603
+			{
555 604
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
556 605
 					$custom_field, lang($app));
557 606
 				return false;
558 607
 			}
559
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
560
-error_log("Searching for $custom_field = $value");
608
+			if($custom_field[0] != '#')
609
+			{
610
+				$custom_field = '#' . $custom_field;
611
+			}
612
+			error_log("Searching for $custom_field = $value");
561 613
 			// Search
562 614
 			if(Link::get_registry($app, 'query'))
563 615
 			{
@@ -591,7 +643,8 @@  discard block
 block discarded – undo
591 643
 	 *
592 644
 	 * @return string name
593 645
 	 */
594
-	public static function get_name() {
646
+	public static function get_name()
647
+	{
595 648
 		return lang('Basic CSV import');
596 649
 	}
597 650
 
@@ -600,7 +653,8 @@  discard block
 block discarded – undo
600 653
 	 *
601 654
 	 * @return string descriprion
602 655
 	 */
603
-	public static function get_description() {
656
+	public static function get_description()
657
+	{
604 658
 		return lang("Imports information from a CSV file.  This is only a base class, and doesn't do anything on its own.");
605 659
 	}
606 660
 
@@ -609,7 +663,8 @@  discard block
 block discarded – undo
609 663
 	 *
610 664
 	 * @return string suffix (comma seperated)
611 665
 	 */
612
-	public static function get_filesuffix() {
666
+	public static function get_filesuffix()
667
+	{
613 668
 		return 'csv';
614 669
 	}
615 670
 
@@ -625,7 +680,8 @@  discard block
 block discarded – undo
625 680
 	 * 		preserv		=> array,
626 681
 	 * )
627 682
 	 */
628
-	public function get_options_etpl() {
683
+	public function get_options_etpl()
684
+	{
629 685
 		// lets do it!
630 686
 	}
631 687
 
@@ -634,7 +690,8 @@  discard block
 block discarded – undo
634 690
 	 *
635 691
 	 * @return string etemplate name
636 692
 	 */
637
-	public function get_selectors_etpl() {
693
+	public function get_selectors_etpl()
694
+	{
638 695
 		// lets do it!
639 696
 	}
640 697
 
@@ -646,7 +703,8 @@  discard block
 block discarded – undo
646 703
 	*       record_# => warning message
647 704
 	*       )
648 705
 	*/
649
-	public function get_warnings() {
706
+	public function get_warnings()
707
+	{
650 708
 		return $this->warnings;
651 709
 	}
652 710
 
@@ -658,7 +716,8 @@  discard block
 block discarded – undo
658 716
 	*       record_# => error message
659 717
 	*       )
660 718
 	*/
661
-	public function get_errors() {
719
+	public function get_errors()
720
+	{
662 721
 		return $this->errors;
663 722
 	}
664 723
 
@@ -670,7 +729,8 @@  discard block
 block discarded – undo
670 729
 	*       action => record count
671 730
 	* )
672 731
 	*/
673
-	public function get_results() {
732
+	public function get_results()
733
+	{
674 734
 			return $this->results;
675 735
 	}
676 736
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return boolean
278 278
 	 */
279
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array())
279
+	protected function exists(importexport_iface_egw_record &$record, array &$condition, &$matches = array())
280 280
 	{
281 281
 	}
282 282
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @return boolean
290 290
 	 */
291
-	protected function equal(importexport_iface_egw_record &$record, Array &$condition)
291
+	protected function equal(importexport_iface_egw_record &$record, array &$condition)
292 292
 	{
293 293
 		$field = $condition['string'];
294 294
 		return $record->$field == $condition['op_2'];
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @return boolean
305 305
 	 */
306
-	protected function less_than(importexport_iface_egw_record &$record, Array &$condition)
306
+	protected function less_than(importexport_iface_egw_record &$record, array &$condition)
307 307
 	{
308 308
 		$field = $condition['string'];
309 309
 		return $record->$field < $condition['op_2'];
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,19 +18,19 @@  discard block
 block discarded – undo
18 18
  * should get you started on building a CSV plugin for an application fairly quickly.
19 19
  *
20 20
  */
21
-abstract class importexport_basic_import_csv implements importexport_iface_import_plugin  {
21
+abstract class importexport_basic_import_csv implements importexport_iface_import_plugin {
22 22
 
23 23
 	protected static $plugin_options = array(
24
-		'fieldsep', 		// char
25
-		'charset', 			// string
26
-		'record_owner', 	// int
27
-		'update_cats', 			// string {override|add} overides record
24
+		'fieldsep', // char
25
+		'charset', // string
26
+		'record_owner', // int
27
+		'update_cats', // string {override|add} overides record
28 28
 								// with cat(s) from csv OR add the cat from
29 29
 								// csv file to exeisting cat(s) of record
30 30
 		'num_header_lines', // int number of header lines
31 31
 		'field_conversion', // array( $csv_col_num => conversion)
32
-		'field_mapping',	// array( $csv_col_num => adb_filed)
33
-		'conditions',		/* => array containing condition arrays:
32
+		'field_mapping', // array( $csv_col_num => adb_filed)
33
+		'conditions', /* => array containing condition arrays:
34 34
 				'type' => exists, // exists
35 35
 				'string' => '#kundennummer',
36 36
 				'true' => array(
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * Actions wich could be done to data entries
49 49
 	 * If your plugin supports different actions, be sure to modify this array
50 50
 	 */
51
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
51
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
52 52
 
53 53
 	/**
54 54
 	 * Conditions for actions
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @var array
58 58
 	 */
59
-	protected static $conditions = array( 'exists', 'equal', 'less_than');
59
+	protected static $conditions = array('exists', 'equal', 'less_than');
60 60
 
61 61
 	/**
62 62
 	 * This is the definition that will be used to deal with the CSV file
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 	 * @param string $_charset
122 122
 	 * @param definition $_definition
123 123
 	 */
124
-	public function import( $_stream, importexport_definition $_definition ) {
125
-		$import_csv = new importexport_import_csv( $_stream, array(
124
+	public function import($_stream, importexport_definition $_definition) {
125
+		$import_csv = new importexport_import_csv($_stream, array(
126 126
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
127 127
 			'charset' => $_definition->plugin_options['charset'],
128 128
 		));
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 		$this->definition = $_definition;
131 131
 
132 132
 		// user, is admin ?
133
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
133
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
134 134
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
135 135
 
136 136
 		// dry run?
137
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
137
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
138 138
 
139 139
 		// set FieldMapping.
140 140
 		$import_csv->mapping = $_definition->plugin_options['field_mapping'];
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
144 144
 
145 145
 		//check if file has a header lines
146
-		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 147
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
148
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
148
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
149 149
 			// First method is preferred
150 150
 			$import_csv->skip_records(1);
151 151
 		}
@@ -167,38 +167,38 @@  discard block
 block discarded – undo
167 167
 
168 168
 		$this->init($_definition);
169 169
 
170
-		while ( $record = $import_csv->get_record() ) {
170
+		while ($record = $import_csv->get_record()) {
171 171
 			$success = false;
172 172
 
173 173
 			// don't import empty records
174
-			if( count( array_unique( $record ) ) < 2 ) continue;
174
+			if (count(array_unique($record)) < 2) continue;
175 175
 
176 176
 
177 177
 			$warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']);
178
-				if($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
178
+				if ($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
179 179
 
180 180
 			$egw_record = new $record_class();
181 181
 			$egw_record->set_record($record);
182 182
 			$success = $this->import_record($egw_record, $import_csv);
183 183
 
184
-			if($success)
184
+			if ($success)
185 185
 			{
186 186
 				$this->do_special_fields($egw_record, $import_csv);
187 187
 			}
188
-			if($success) $count++;
188
+			if ($success) $count++;
189 189
 
190 190
 			// Add some more time
191
-			if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
191
+			if ($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
192 192
 			{
193 193
 				set_time_limit(10);
194 194
 			}
195 195
 
196 196
 			// Keep a few records for preview, but process the whole file
197
-			if($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
197
+			if ($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
198 198
 			{
199 199
 				$this->preview_records[] = $egw_record;
200 200
 			}
201
-			if(count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES)
201
+			if (count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES)
202 202
 			{
203 203
 				$this->errors[] = 'Too many errors, aborted';
204 204
 				break;
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 	*/
227 227
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
228 228
 	{
229
-		if ( $this->definition->plugin_options['conditions'] ) {
230
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
229
+		if ($this->definition->plugin_options['conditions']) {
230
+			foreach ($this->definition->plugin_options['conditions'] as $condition) {
231 231
 				$result = false;
232
-				switch ( $condition['type'] ) {
232
+				switch ($condition['type']) {
233 233
 					// exists
234 234
 					case 'exists' :
235 235
 						// Check for that record
@@ -244,23 +244,23 @@  discard block
 block discarded – undo
244 244
 					default :
245 245
 						die('condition / action not supported!!!');
246 246
 				}
247
-				if($result)
247
+				if ($result)
248 248
 				{
249 249
 					// Apply true action to any matching records found
250 250
 					$action = $condition['true'];
251
-					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
251
+					$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
252 252
 				}
253 253
 				else
254 254
 				{
255 255
 					// Apply false action if no matching records found
256 256
 					$action = $condition['false'];
257
-					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
257
+					$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
258 258
 				}
259 259
 				if ($action['stop']) break;
260 260
 			}
261 261
 		} else {
262 262
 			// unconditional insert
263
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
263
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
264 264
 		}
265 265
 
266 266
 		return $success;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 * @param int $record_num Which record number is being dealt with.  Used for error messages.
322 322
 	 * @return bool success or not
323 323
 	 */
324
-	protected abstract function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 );
324
+	protected abstract function action($_action, importexport_iface_egw_record &$record, $record_num = 0);
325 325
 
326 326
 	/**
327 327
 	 * Handle special fields
@@ -336,46 +336,46 @@  discard block
 block discarded – undo
336 336
 		$id = $record->get_identifier();
337 337
 
338 338
 		// Warn if there's no ID unless it's a dry_run because there probably won't be an ID then
339
-		if(!$this->dry_run && !$id)
339
+		if (!$this->dry_run && !$id)
340 340
 		{
341 341
 			$this->warnings[$import_csv->get_current_position()] .= "Unable to link, no identifier for record";
342 342
 			return;
343 343
 		}
344 344
 
345
-		foreach(self::$special_fields as $field => $desc) {
346
-			if(!$record->$field) continue;
347
-			if(strpos($field, 'link') === 0) {
348
-				list($app, $app_id) = explode(':', $record->$field,2);
345
+		foreach (self::$special_fields as $field => $desc) {
346
+			if (!$record->$field) continue;
347
+			if (strpos($field, 'link') === 0) {
348
+				list($app, $app_id) = explode(':', $record->$field, 2);
349 349
 
350
-				list($link, $type) = explode('_',$field);
350
+				list($link, $type) = explode('_', $field);
351 351
 
352 352
 				// Searching, take first result
353
-				if($type == 'custom')
353
+				if ($type == 'custom')
354 354
 				{
355 355
 					$app_id = $this->link_by_cf($record, $app, $app_id, $import_csv->get_current_position());
356 356
 				}
357
-				else if($type == 'search')
357
+				else if ($type == 'search')
358 358
 				{
359 359
 					$result = Link::query($app, $app_id);
360 360
 					do
361 361
 					{
362 362
 						$app_id = key($result);
363 363
 						shift($result);
364
-					} while($result && !$app_id);
364
+					} while ($result && !$app_id);
365 365
 				}
366 366
 			} else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) {
367 367
 				$app = $field;
368 368
 				$app_id = $record->$field;
369 369
 
370 370
 				// Searching, take first result
371
-				if(!is_numeric($app_id))
371
+				if (!is_numeric($app_id))
372 372
 				{
373 373
 					$result = Link::query($app, $app_id);
374 374
 					do
375 375
 					{
376 376
 						$app_id = key($result);
377 377
 						shift($result);
378
-					} while($result && !$app_id);
378
+					} while ($result && !$app_id);
379 379
 				}
380 380
 			}
381 381
 			else if ($field == 'contact')
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			}
387 387
 			if (!$this->dry_run && $app && $app_id && ($app != $this->definition->application || $app_id != $id))
388 388
 			{
389
-				$link_id = Link::link($this->definition->application,$id,$app,$app_id);
389
+				$link_id = Link::link($this->definition->application, $id, $app, $app_id);
390 390
 			}
391 391
 		}
392 392
 	}
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
 	 * @param importexport_definition $definition
404 404
 	 * @return String HTML for preview
405 405
          */
406
-	public function preview( $stream, importexport_definition $definition )
406
+	public function preview($stream, importexport_definition $definition)
407 407
 	{
408 408
 		$this->import($stream, $definition);
409 409
 		rewind($stream);
410 410
 
411 411
 		// Set up result
412
-		$rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
412
+		$rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th');
413 413
 
414 414
 		// Load labels for app
415 415
 		$record_class = get_class($this->preview_records[0]);
@@ -418,27 +418,27 @@  discard block
 block discarded – undo
418 418
 		$labels = array_combine($definition->plugin_options['field_mapping'], $definition->plugin_options['field_mapping']);
419 419
 
420 420
 		$plugin = get_called_class();
421
-		$wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin);
421
+		$wizard_name = $definition->application.'_wizard_'.str_replace($definition->application.'_', '', $plugin);
422 422
 		try {
423 423
 			$wizard = new $wizard_name;
424 424
 			$fields = $wizard->get_import_fields();
425
-			foreach($labels as $field => &$label)
425
+			foreach ($labels as $field => &$label)
426 426
 			{
427
-				if($fields[$field]) $label = $fields[$field];
427
+				if ($fields[$field]) $label = $fields[$field];
428 428
 			}
429 429
 		} catch (Exception $e) {
430 430
 			Api\Translation::add_app($definition->application);
431
-			foreach($labels as $field => &$label) {
431
+			foreach ($labels as $field => &$label) {
432 432
 				$label = lang($label);
433 433
 			}
434 434
 		}
435 435
 
436 436
 		// Set up HTML
437 437
 		$rows['h1'] = $labels;
438
-		foreach($this->preview_records as $i => $row_data)
438
+		foreach ($this->preview_records as $i => $row_data)
439 439
 		{
440 440
 			// Convert to human-friendly
441
-			importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups);
441
+			importexport_export_csv::convert($row_data, $record_class::$types, $definition->application, $this->lookups);
442 442
 			$this->row_preview($row_data);
443 443
 			$rows[] = $row_data->get_record_array();
444 444
 		}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @param string $org_name
468 468
 	 * @return int|boolean Contact ID of first match, or false if none found
469 469
 	 */
470
-	public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) {
470
+	public static function addr_id($n_family, $n_given = null, $org_name = null, &$record = null) {
471 471
 
472 472
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
473 473
 		static $contacts;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
478 478
 		}
479 479
 		$n_family = trim($n_family);
480
-		if(!is_null($n_given)) $n_given = trim($n_given);
480
+		if (!is_null($n_given)) $n_given = trim($n_given);
481 481
 		if (!is_object($contacts))
482 482
 		{
483 483
 			$contacts = new Api\Contacts();
@@ -485,10 +485,10 @@  discard block
 block discarded – undo
485 485
 		if (!is_null($org_name))	// org_name given?
486 486
 		{
487 487
 			$org_name = trim($org_name);
488
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
488
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name");
489 489
 			if (!count($addrs))
490 490
 			{
491
-				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
491
+				$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name');
492 492
 			}
493 493
 		}
494 494
 		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
 		}
498 498
 		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
499 499
 		{
500
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
500
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn');
501 501
 		}
502 502
 		if (count($addrs))
503 503
 		{
504
-			if(!$record || !$record->get_identifier())
504
+			if (!$record || !$record->get_identifier())
505 505
 			{
506 506
 				return $addrs[0]['id'];
507 507
 			}
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 				{
512 512
 					$id = key($addrs);
513 513
 					array_shift($addrs);
514
-				} while($addrs && !$id && $id == $record->get_identifier());
514
+				} while ($addrs && !$id && $id == $record->get_identifier());
515 515
 				return $id;
516 516
 			}
517 517
 		}
@@ -526,22 +526,22 @@  discard block
 block discarded – undo
526 526
 	 * @param string $app Target application name
527 527
 	 * @param string $value CSV value in the form of custom_field_name:value
528 528
 	 */
529
-	protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value,$record_num)
529
+	protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value, $record_num)
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 = Api\Storage\Customfields::get($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,30 +550,30 @@  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
 error_log("Searching for $custom_field = $value");
560 560
 			// Search
561
-			if(Link::get_registry($app, 'query'))
561
+			if (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 = Link::query($app, '', $options);
565 565
 
566 566
 				// Only one allowed
567
-				if($record->get_identifier())
567
+				if ($record->get_identifier())
568 568
 				{
569
-					while(key($result) == $record->get_identifier())
569
+					while (key($result) == $record->get_identifier())
570 570
 					{
571 571
 						array_shift($result);
572 572
 					}
573 573
 				}
574
-				if(count($result) != 1)
574
+				if (count($result) != 1)
575 575
 				{
576
-					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
576
+					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '').
577 577
 						lang('Unable to link to %3 by custom field "%1": "%4".  %2 matches.',
578 578
 						$custom_field, count($result), lang($app), $options['filter'][0]
579 579
 					);
Please login to merge, or discard this patch.
importexport/inc/class.importexport_definitions_bo.inc.php 5 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -139,7 +139,6 @@  discard block
 block discarded – undo
139 139
 	/**
140 140
 	* Save a definition
141 141
 	*
142
-	* @param definition $definition
143 142
 	*/
144 143
 	public function save(Array $data) {
145 144
 		$definition = new importexport_definition();
@@ -209,7 +208,7 @@  discard block
 block discarded – undo
209 208
 	/**
210 209
 	 * imports definitions from file
211 210
 	 *
212
-	 * @param string $import_file
211
+	 * @param string $_import_file
213 212
 	 * @throws Exeption
214 213
 	 * @return void
215 214
 	 */
@@ -268,7 +267,6 @@  discard block
 block discarded – undo
268 267
 	 * It is not possible to handle some plugin options automatically, because they
269 268
 	 * just don't have equivalents.  (eg: What to do with unknown categories)
270 269
 	 *
271
-	 * @param importexport_definition $definition Import definition
272 270
 	 *
273 271
 	 * @return importexport_definition Export definition
274 272
 	 */
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -137,10 +137,10 @@
 block discarded – undo
137 137
 	}
138 138
 
139 139
 	/**
140
-	* Save a definition
141
-	*
142
-	* @param definition $definition
143
-	*/
140
+	 * Save a definition
141
+	 *
142
+	 * @param definition $definition
143
+	 */
144 144
 	public function save(Array $data) {
145 145
 		$definition = new importexport_definition();
146 146
 		$definition->set_record($data);
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	private $definitions;
33 33
 
34
-	public function __construct($_query=false, $ignore_acl = false)
34
+	public function __construct($_query = false, $ignore_acl = false)
35 35
 	{
36
-		$this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table );
36
+		$this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table);
37 37
 		if ($_query) {
38 38
 			$definitions = $this->so_sql->search($_query, false);
39 39
 			foreach ((array)$definitions as $definition) {
40
-				if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
40
+				if (self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
41 41
 			}
42 42
 		}
43 43
 	}
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	public function get_rows(&$query, &$rows, &$readonlys)
46 46
 	{
47 47
 		// Filter only definitions user is allowed to use
48
-		if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
48
+		if (!$GLOBALS['egw_info']['user']['apps']['admin']) {
49 49
 			$this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
50 50
 			$this_membership[] = $GLOBALS['egw_info']['user']['account_id'];
51 51
 			$sql .= ' (';
52 52
 			$read = array();
53
-			foreach($this_membership as $id)
53
+			foreach ($this_membership as $id)
54 54
 			{
55 55
 				$read[] = 'allowed_users '.
56 56
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.
57
-					$GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%');
57
+					$GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%');
58 58
 			}
59 59
 			$sql .= implode(' OR ', $read);
60 60
 			$sql .= ') OR owner = '.$GLOBALS['egw_info']['user']['account_id'];
@@ -62,37 +62,37 @@  discard block
 block discarded – undo
62 62
 		}
63 63
 		
64 64
 		// Handle allowed filter
65
-		if($query['col_filter']['allowed_users'])
65
+		if ($query['col_filter']['allowed_users'])
66 66
 		{
67 67
 			$allowed = array();
68
-			foreach((array)$query['col_filter']['allowed_users'] as $id)
68
+			foreach ((array)$query['col_filter']['allowed_users'] as $id)
69 69
 			{
70 70
 				$allowed[] = 'allowed_users '.
71 71
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.
72
-					$GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%');
72
+					$GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%');
73 73
 			}
74
-			if($allowed)
74
+			if ($allowed)
75 75
 			{
76 76
 				unset($query['col_filter']['allowed_users']);
77
-				$query['col_filter'][] = '('.implode(' OR ', $allowed) . ')';
77
+				$query['col_filter'][] = '('.implode(' OR ', $allowed).')';
78 78
 			}
79 79
 		}
80 80
 		
81 81
 		$total = $this->so_sql->get_rows($query, $rows, $readonlys);
82 82
 		$ro_count = 0;
83
-		foreach($rows as &$row) {
83
+		foreach ($rows as &$row) {
84 84
 			// Strip off leading + trailing ,
85
-			$row['allowed_users'] = substr($row['allowed_users'],1,-1);
85
+			$row['allowed_users'] = substr($row['allowed_users'], 1, -1);
86 86
 
87 87
 			$readonlys["edit[{$row['definition_id']}]"] = $readonlys["delete[{$row['definition_id']}]"] =
88 88
 				($row['owner'] != $GLOBALS['egw_info']['user']['account_id']) &&
89 89
 				!$GLOBALS['egw_info']['user']['apps']['admin'];
90
-			if($readonlys["edit[{$row['definition_id']}]"])
90
+			if ($readonlys["edit[{$row['definition_id']}]"])
91 91
 			{
92 92
 				$row['class'] .= 'rowNoEdit rowNoDelete';
93 93
 				$ro_count++;
94 94
 			}
95
-			$row['class'] .= ' ' . $row['type'];
95
+			$row['class'] .= ' '.$row['type'];
96 96
 		}
97 97
 		$readonlys['delete_selected'] = $ro_count == count($rows);
98 98
 		return $total;
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 		return $this->definitions;
108 108
 	}
109 109
 	public function read($definition_id) {
110
-		if(is_numeric($definition_id)) {
110
+		if (is_numeric($definition_id)) {
111 111
 			$this->so_sql->read($definition_id);
112 112
 			$definition = new importexport_definition($this->so_sql->data['name']);
113 113
 		} else {
114
-			$definition = new importexport_definition( $definition_id['name'] );
114
+			$definition = new importexport_definition($definition_id['name']);
115 115
 		}
116 116
 		return $definition->get_record_array();
117 117
 	}
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 		foreach ($keys as $index => $key) {
125 125
 			// Check for ownership
126 126
 			$definition = $this->read($key);
127
-			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
127
+			if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
128 128
 				// clear private cache
129
-				unset($this->definitions[array_search($key,$this->definitions)]);
129
+				unset($this->definitions[array_search($key, $this->definitions)]);
130 130
 			} else {
131 131
 				unset($keys[$index]);
132 132
 			}
133 133
 		}
134
-		if(count($keys) > 0) {
134
+		if (count($keys) > 0) {
135 135
 			$this->so_sql->delete(array('definition_id' => $keys));
136 136
 		}
137 137
 	}
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 	 * @return bool
155 155
 	 */
156 156
 	static public function is_permitted($_definition) {
157
-		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']);
157
+		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',', $_definition['allowed_users']);
158 158
 		$this_user_id = $GLOBALS['egw_info']['user']['account_id'];
159 159
 		$this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true);
160 160
 		$this_membership[] = $this_user_id;
161 161
 		$this_membership[] = 'all';
162
-		$alluser = array_intersect($allowed_user,$this_membership);
162
+		$alluser = array_intersect($allowed_user, $this_membership);
163 163
 		return ($this_user_id == $_definition['owner'] || count($alluser) > 0);
164 164
 	}
165 165
 
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 
179 179
 		$export_data['definitions'] = array();
180 180
 		foreach ($keys as $definition_id) {
181
-			$definition = new importexport_definition( $definition_id );
181
+			$definition = new importexport_definition($definition_id);
182 182
 			$export_data['definitions'][$definition->name] = $definition->get_record_array();
183 183
 			$export_data['definitions'][$definition->name]['allowed_users'] =
184 184
 				importexport_helper_functions::account_id2name(
185 185
 					$export_data['definitions'][$definition->name]['allowed_users']
186 186
 				);
187
-			if($export_date['definitions'][$definition->name]['owner']) {
187
+			if ($export_date['definitions'][$definition->name]['owner']) {
188 188
 				$export_data['definitions'][$definition->name]['owner'] =
189 189
 					importexport_helper_functions::account_id2name(
190 190
 						$export_data['definitions'][$definition->name]['owner']
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			unset($export_data['definitions'][$definition->name]['definition_id']);
196 196
 			unset($export_data['definitions'][$definition->name]['description']);
197 197
 			unset($export_data['definitions'][$definition->name]['user_timezone_read']);
198
-			if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
198
+			if (is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
199 199
 				unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']);
200 200
 			}
201 201
 			unset($definition);
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
 	 * @throws Exeption
214 214
 	 * @return void
215 215
 	 */
216
-	public static function import( $_import_file )
216
+	public static function import($_import_file)
217 217
 	{
218
-		if ( !is_file( $_import_file ) ) {
219
-			throw new Exception("'$_import_file' does not exist or is not readable" );
218
+		if (!is_file($_import_file)) {
219
+			throw new Exception("'$_import_file' does not exist or is not readable");
220 220
 		}
221 221
 
222
-		$data = importexport_arrayxml::xml2array( file_get_contents( $_import_file ) );
222
+		$data = importexport_arrayxml::xml2array(file_get_contents($_import_file));
223 223
 
224 224
 		$metainfo = $data['importExportDefinitions']['metainfo'];
225 225
 		$definitions = $data['importExportDefinitions']['definitions'];
226
-		unset ( $data );
226
+		unset ($data);
227 227
 
228 228
 		// convert charset into internal used charset
229 229
 		$definitions = Api\Translation::convert(
@@ -233,26 +233,26 @@  discard block
 block discarded – undo
233 233
 		);
234 234
 
235 235
 		// Avoid warning if no definitions found
236
-		if(!is_array($definitions)) return lang('None found');
236
+		if (!is_array($definitions)) return lang('None found');
237 237
 
238 238
 		// save definition(s) into internal table
239
-		foreach ( $definitions as $name => $definition_data )
239
+		foreach ($definitions as $name => $definition_data)
240 240
 		{
241 241
 			// convert allowed_user
242
-			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] );
243
-			if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
242
+			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id($definition_data['allowed_users']);
243
+			if ($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
244 244
 
245
-			$definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] );
245
+			$definition_data['owner'] = importexport_helper_functions::account_name2id($definition_data['owner']);
246 246
 
247
-			$definition = new importexport_definition( $definition_data['name'] );
247
+			$definition = new importexport_definition($definition_data['name']);
248 248
 
249 249
 			// Only update if the imported is newer
250
-			if(strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0)
250
+			if (strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0)
251 251
 			{
252 252
 				$definition_id = $definition->get_identifier() ? $definition->get_identifier() : NULL;
253 253
 
254
-				$definition->set_record( $definition_data );
255
-				$definition->save( $definition_id );
254
+				$definition->set_record($definition_data);
255
+				$definition->save($definition_id);
256 256
 			}
257 257
 		}
258 258
 		return $definitions;
@@ -275,28 +275,28 @@  discard block
 block discarded – undo
275 275
 	public static function export_from_import(importexport_definition $import)
276 276
 	{
277 277
 		// Only operates on import definitions
278
-		if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions');
278
+		if ($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions');
279 279
 
280 280
 		// Find export plugin
281
-		$plugin = str_replace('import', 'export',$import->plugin);
281
+		$plugin = str_replace('import', 'export', $import->plugin);
282 282
 		$plugin_list = importexport_helper_functions::get_plugins($import->application, 'export');
283
-		foreach($plugin_list as $appname => $type)
283
+		foreach ($plugin_list as $appname => $type)
284 284
 		{
285 285
 			$plugins = $type['export'];
286
-			foreach($plugins as $name => $label)
286
+			foreach ($plugins as $name => $label)
287 287
 			{
288
-				if($plugin == $name) break;
288
+				if ($plugin == $name) break;
289 289
 			}
290
-			if($plugin !== $name) $plugin = $name;
290
+			if ($plugin !== $name) $plugin = $name;
291 291
 		}
292 292
 
293 293
 		$export = new importexport_definition();
294 294
 
295 295
 		// Common settings
296
-		$export->name = str_replace('import', 'export',$import->name);
297
-		if($export->name == $import->name) $export->name = $export->name . '-export';
296
+		$export->name = str_replace('import', 'export', $import->name);
297
+		if ($export->name == $import->name) $export->name = $export->name.'-export';
298 298
 		$test = new importexport_definition($export->name);
299
-		if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
299
+		if ($test->name) $export->name = $export->name.'-'.$GLOBALS['egw_info']['user']['account_lid'];
300 300
 
301 301
 		$export->application = $import->application;
302 302
 		$export->plugin = $plugin;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		);
313 313
 
314 314
 		// Mapping
315
-		foreach($i_options['field_mapping'] as $col_num => $field)
315
+		foreach ($i_options['field_mapping'] as $col_num => $field)
316 316
 		{
317 317
 			// Try to use heading from import file, if possible
318 318
 			$e_options['mapping'][$field] = $i_options['csv_fields'][$col_num] ? $i_options['csv_fields'][$col_num] : $field;
Please login to merge, or discard this patch.
Braces   +77 added lines, -29 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * @todo make this class an egw_record_pool!
18 18
  */
19
-class importexport_definitions_bo {
19
+class importexport_definitions_bo
20
+{
20 21
 
21 22
 	const _appname = 'importexport';
22 23
 	const _defintion_table = 'egw_importexport_definitions';
@@ -34,10 +35,15 @@  discard block
 block discarded – undo
34 35
 	public function __construct($_query=false, $ignore_acl = false)
35 36
 	{
36 37
 		$this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table );
37
-		if ($_query) {
38
+		if ($_query)
39
+		{
38 40
 			$definitions = $this->so_sql->search($_query, false);
39
-			foreach ((array)$definitions as $definition) {
40
-				if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
41
+			foreach ((array)$definitions as $definition)
42
+			{
43
+				if(self::is_permitted($definition) || $ignore_acl)
44
+				{
45
+					$this->definitions[] = $definition['definition_id'];
46
+				}
41 47
 			}
42 48
 		}
43 49
 	}
@@ -45,7 +51,8 @@  discard block
 block discarded – undo
45 51
 	public function get_rows(&$query, &$rows, &$readonlys)
46 52
 	{
47 53
 		// Filter only definitions user is allowed to use
48
-		if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
54
+		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
55
+		{
49 56
 			$this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
50 57
 			$this_membership[] = $GLOBALS['egw_info']['user']['account_id'];
51 58
 			$sql .= ' (';
@@ -80,7 +87,8 @@  discard block
 block discarded – undo
80 87
 		
81 88
 		$total = $this->so_sql->get_rows($query, $rows, $readonlys);
82 89
 		$ro_count = 0;
83
-		foreach($rows as &$row) {
90
+		foreach($rows as &$row)
91
+		{
84 92
 			// Strip off leading + trailing ,
85 93
 			$row['allowed_users'] = substr($row['allowed_users'],1,-1);
86 94
 
@@ -103,14 +111,19 @@  discard block
 block discarded – undo
103 111
 	 *
104 112
 	 * @return array
105 113
 	 */
106
-	public function get_definitions() {
114
+	public function get_definitions()
115
+	{
107 116
 		return $this->definitions;
108 117
 	}
109
-	public function read($definition_id) {
110
-		if(is_numeric($definition_id)) {
118
+	public function read($definition_id)
119
+	{
120
+		if(is_numeric($definition_id))
121
+		{
111 122
 			$this->so_sql->read($definition_id);
112 123
 			$definition = new importexport_definition($this->so_sql->data['name']);
113
-		} else {
124
+		}
125
+		else
126
+		{
114 127
 			$definition = new importexport_definition( $definition_id['name'] );
115 128
 		}
116 129
 		return $definition->get_record_array();
@@ -120,18 +133,24 @@  discard block
 block discarded – undo
120 133
 	 *
121 134
 	 * @param array $keys
122 135
 	 */
123
-	public function delete($keys) {
124
-		foreach ($keys as $index => $key) {
136
+	public function delete($keys)
137
+	{
138
+		foreach ($keys as $index => $key)
139
+		{
125 140
 			// Check for ownership
126 141
 			$definition = $this->read($key);
127
-			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
142
+			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin'])
143
+			{
128 144
 				// clear private cache
129 145
 				unset($this->definitions[array_search($key,$this->definitions)]);
130
-			} else {
146
+			}
147
+			else
148
+			{
131 149
 				unset($keys[$index]);
132 150
 			}
133 151
 		}
134
-		if(count($keys) > 0) {
152
+		if(count($keys) > 0)
153
+		{
135 154
 			$this->so_sql->delete(array('definition_id' => $keys));
136 155
 		}
137 156
 	}
@@ -141,7 +160,8 @@  discard block
 block discarded – undo
141 160
 	*
142 161
 	* @param definition $definition
143 162
 	*/
144
-	public function save(Array $data) {
163
+	public function save(Array $data)
164
+	{
145 165
 		$definition = new importexport_definition();
146 166
 		$definition->set_record($data);
147 167
 		$definition->save($data['definition_id']);
@@ -153,7 +173,8 @@  discard block
 block discarded – undo
153 173
 	 * @param array $_definition
154 174
 	 * @return bool
155 175
 	 */
156
-	static public function is_permitted($_definition) {
176
+	static public function is_permitted($_definition)
177
+	{
157 178
 		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']);
158 179
 		$this_user_id = $GLOBALS['egw_info']['user']['account_id'];
159 180
 		$this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true);
@@ -177,25 +198,30 @@  discard block
 block discarded – undo
177 198
 		));
178 199
 
179 200
 		$export_data['definitions'] = array();
180
-		foreach ($keys as $definition_id) {
201
+		foreach ($keys as $definition_id)
202
+		{
181 203
 			$definition = new importexport_definition( $definition_id );
182 204
 			$export_data['definitions'][$definition->name] = $definition->get_record_array();
183 205
 			$export_data['definitions'][$definition->name]['allowed_users'] =
184 206
 				importexport_helper_functions::account_id2name(
185 207
 					$export_data['definitions'][$definition->name]['allowed_users']
186 208
 				);
187
-			if($export_date['definitions'][$definition->name]['owner']) {
209
+			if($export_date['definitions'][$definition->name]['owner'])
210
+			{
188 211
 				$export_data['definitions'][$definition->name]['owner'] =
189 212
 					importexport_helper_functions::account_id2name(
190 213
 						$export_data['definitions'][$definition->name]['owner']
191 214
 					);
192
-			} else {
215
+			}
216
+			else
217
+			{
193 218
 				unset($export_data['definitions'][$definition->name]['owner']);
194 219
 			}
195 220
 			unset($export_data['definitions'][$definition->name]['definition_id']);
196 221
 			unset($export_data['definitions'][$definition->name]['description']);
197 222
 			unset($export_data['definitions'][$definition->name]['user_timezone_read']);
198
-			if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
223
+			if(is_array($export_data['definitions'][$definition->name]['plugin_options']))
224
+			{
199 225
 				unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']);
200 226
 			}
201 227
 			unset($definition);
@@ -215,7 +241,8 @@  discard block
 block discarded – undo
215 241
 	 */
216 242
 	public static function import( $_import_file )
217 243
 	{
218
-		if ( !is_file( $_import_file ) ) {
244
+		if ( !is_file( $_import_file ) )
245
+		{
219 246
 			throw new Exception("'$_import_file' does not exist or is not readable" );
220 247
 		}
221 248
 
@@ -233,14 +260,20 @@  discard block
 block discarded – undo
233 260
 		);
234 261
 
235 262
 		// Avoid warning if no definitions found
236
-		if(!is_array($definitions)) return lang('None found');
263
+		if(!is_array($definitions))
264
+		{
265
+			return lang('None found');
266
+		}
237 267
 
238 268
 		// save definition(s) into internal table
239 269
 		foreach ( $definitions as $name => $definition_data )
240 270
 		{
241 271
 			// convert allowed_user
242 272
 			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] );
243
-			if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
273
+			if($definition_data['all_users'] && !$definition_data['allowed_users'])
274
+			{
275
+				$definition_data['allowed_users'] = 'all';
276
+			}
244 277
 
245 278
 			$definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] );
246 279
 
@@ -275,7 +308,10 @@  discard block
 block discarded – undo
275 308
 	public static function export_from_import(importexport_definition $import)
276 309
 	{
277 310
 		// Only operates on import definitions
278
-		if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions');
311
+		if($import->type != 'import')
312
+		{
313
+			throw new Api\Exception\WrongParameter('Only import definitions');
314
+		}
279 315
 
280 316
 		// Find export plugin
281 317
 		$plugin = str_replace('import', 'export',$import->plugin);
@@ -285,18 +321,30 @@  discard block
 block discarded – undo
285 321
 			$plugins = $type['export'];
286 322
 			foreach($plugins as $name => $label)
287 323
 			{
288
-				if($plugin == $name) break;
324
+				if($plugin == $name)
325
+				{
326
+					break;
327
+				}
328
+			}
329
+			if($plugin !== $name)
330
+			{
331
+				$plugin = $name;
289 332
 			}
290
-			if($plugin !== $name) $plugin = $name;
291 333
 		}
292 334
 
293 335
 		$export = new importexport_definition();
294 336
 
295 337
 		// Common settings
296 338
 		$export->name = str_replace('import', 'export',$import->name);
297
-		if($export->name == $import->name) $export->name = $export->name . '-export';
339
+		if($export->name == $import->name)
340
+		{
341
+			$export->name = $export->name . '-export';
342
+		}
298 343
 		$test = new importexport_definition($export->name);
299
-		if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
344
+		if($test->name)
345
+		{
346
+			$export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
347
+		}
300 348
 
301 349
 		$export->application = $import->application;
302 350
 		$export->plugin = $plugin;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
 	*
142 142
 	* @param definition $definition
143 143
 	*/
144
-	public function save(Array $data) {
144
+	public function save(array $data) {
145 145
 		$definition = new importexport_definition();
146 146
 		$definition->set_record($data);
147 147
 		$definition->save($data['definition_id']);
Please login to merge, or discard this patch.
importexport/inc/class.importexport_definitions_ui.inc.php 4 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	/**
83 83
 	 * List defined {im|ex}ports
84 84
 	 *
85
-	 * @param array $content=null
85
+	 * @param array $content
86 86
 	 */
87 87
 	function index($content = null,$msg='')
88 88
 	{
@@ -309,8 +309,9 @@  discard block
 block discarded – undo
309 309
 	 * @param int &$success number of succeded actions
310 310
 	 * @param int &$failed number of failed actions (not enought permissions)
311 311
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like %1 entries 'deleted'
312
-	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
313
-	 * @return boolean true if all actions succeded, false otherwise
312
+	 * @param string $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
313
+	 * @param string $msg
314
+	 * @return null|boolean true if all actions succeded, false otherwise
314 315
 	 */
315 316
 	function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
316 317
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -940,7 +940,7 @@
 block discarded – undo
940 940
 	 * Determine if the user is allowed to edit the definition
941 941
 	 *
942 942
 	 */
943
-	protected function can_edit(Array $definition)
943
+	protected function can_edit(array $definition)
944 944
 	{
945 945
 		if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'])
946 946
 		{
Please login to merge, or discard this patch.
Spacing   +139 added lines, -140 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		$GLOBALS['egw_info']['flags']['currentapp'] = self::_appname;
61 61
 
62 62
 		$this->etpl = new Etemplate();
63
-		$this->clock = Api\Html::image(self::_appname,'clock');
63
+		$this->clock = Api\Html::image(self::_appname, 'clock');
64 64
 		$this->steps = array(
65 65
 			'wizard_step10' => lang('Choose an application'),
66 66
 			'wizard_step20' => lang('Choose a plugin'),
@@ -77,18 +77,18 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @param array $content=null
79 79
 	 */
80
-	function index($content = null,$msg='')
80
+	function index($content = null, $msg = '')
81 81
 	{
82 82
 		$filter = array('name' => '*');
83 83
 
84
-		if($GLOBALS['egw_info']['user']['apps']['admin']) {
84
+		if ($GLOBALS['egw_info']['user']['apps']['admin']) {
85 85
 			// Any public definition
86
-			$filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')';
86
+			$filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = '.$GLOBALS['egw_info']['user']['account_id'].')';
87 87
 		} else {
88 88
 			// Filter private definitions
89 89
 			$filter['owner'] = $GLOBALS['egw_info']['user']['account_id'];
90 90
 			$config = Api\Config::read('phpgwapi');
91
-			if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) {
91
+			if ($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) {
92 92
 				$filter['type'] = 'import';
93 93
 			}
94 94
 		}
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 			if (isset($content['nm']['rows']['delete']))
100 100
 			{
101 101
 				$content['nm']['action'] = 'delete';
102
-				$content['nm']['selected'] = array_keys($content['nm']['rows']['delete'],'pressed');
102
+				$content['nm']['selected'] = array_keys($content['nm']['rows']['delete'], 'pressed');
103 103
 			}
104
-			elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false)
104
+			elseif (($button = array_search('pressed', $content['nm']['rows'])) !== false)
105 105
 			{
106 106
 				$selected = $content['nm']['rows']['selected'];
107
-				if(count($selected) < 1 || !is_array($selected)) exit();
107
+				if (count($selected) < 1 || !is_array($selected)) exit();
108 108
 				switch ($button)
109 109
 				{
110 110
 					case 'delete_selected' :
@@ -126,54 +126,54 @@  discard block
 block discarded – undo
126 126
 				else
127 127
 				{
128 128
 					// Action has an additional parameter
129
-					if(in_array($content['nm']['action'], array('owner', 'allowed')))
129
+					if (in_array($content['nm']['action'], array('owner', 'allowed')))
130 130
 					{
131 131
 						$action = $content['nm']['action'];
132
-						if($content['nm']['action'] == 'allowed')
132
+						if ($content['nm']['action'] == 'allowed')
133 133
 						{
134 134
 							$content['allowed'] = $content['allowed_popup']['allowed_private'] == 'true' ? null : (
135
-								$content['allowed_popup']['all_users']=='true' ? 'all' : implode(',',$content['allowed_popup']['allowed'])
135
+								$content['allowed_popup']['all_users'] == 'true' ? 'all' : implode(',', $content['allowed_popup']['allowed'])
136 136
 							);
137 137
 						}
138 138
 						else
139 139
 						{
140 140
 							$content['owner'] = $content['owner_popup']['owner'];
141 141
 						}
142
-						if(is_array($content[$content['nm']['action']]))
142
+						if (is_array($content[$content['nm']['action']]))
143 143
 						{
144
-							$content[$content['nm']['action']] = implode(',',$content[$content['nm']['action']]);
144
+							$content[$content['nm']['action']] = implode(',', $content[$content['nm']['action']]);
145 145
 						}
146
-						$content['nm']['action'] .= '_' . $content[$action];
146
+						$content['nm']['action'] .= '_'.$content[$action];
147 147
 						unset($content[$action]);
148 148
 						unset($content['allowed_popup']);
149 149
 					}
150
-					if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
151
-						$success,$failed,$action_msg,'index',$msg))
150
+					if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
151
+						$success, $failed, $action_msg, 'index', $msg))
152 152
 					{
153
-						$msg .= lang('%1 definition(s) %2',$success,$action_msg);
153
+						$msg .= lang('%1 definition(s) %2', $success, $action_msg);
154 154
 					}
155
-					elseif(empty($msg))
155
+					elseif (empty($msg))
156 156
 					{
157
-						$msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
157
+						$msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
158 158
 					}
159 159
 				}
160 160
 			}
161 161
 		}
162 162
 
163
-		if(!is_array($content['nm'])) {
163
+		if (!is_array($content['nm'])) {
164 164
 			$content['nm'] = array(
165 165
 				'get_rows'	=> 'importexport.importexport_definitions_ui.get_rows',
166 166
 				'no_cat'	=> true,
167 167
 				'no_filter'	=> true,
168 168
 				'no_filter2'	=> true,
169
-				'csv_fields'	=> false,	// Disable CSV export, uses own export
170
-				'default_cols'  => '!actions',  // switch legacy actions column and row off by default
169
+				'csv_fields'	=> false, // Disable CSV export, uses own export
170
+				'default_cols'  => '!actions', // switch legacy actions column and row off by default
171 171
 				'row_id'	=> 'definition_id',
172 172
 				'placeholder_actions' => array('add')
173 173
 			);
174
-			if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application'];
174
+			if ($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application'];
175 175
 		}
176
-		if(Api\Cache::getSession('importexport', 'index'))
176
+		if (Api\Cache::getSession('importexport', 'index'))
177 177
 		{
178 178
 			$content['nm'] = array_merge($content['nm'], Api\Cache::getSession('importexport', 'index'));
179 179
 		}
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 		);
191 191
 		foreach ($this->plugins as $appname => $options)
192 192
 		{
193
-			if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) {
193
+			if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) {
194 194
 				$sel_options['application'][$appname] = lang($appname);
195 195
 			}
196 196
 		}
197
-		if($msg) $content['msg'] = $msg;
197
+		if ($msg) $content['msg'] = $msg;
198 198
 
199 199
 		$etpl = new Etemplate(self::_appname.'.definition_index');
200
-		return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv );
200
+		return $etpl->exec(self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv);
201 201
 	}
202 202
 
203 203
 	private function get_actions() {
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		);
287 287
 
288 288
 		// Unset admin actions
289
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
289
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
290 290
 		{
291 291
 			unset($actions['schedule']);
292 292
 		}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
306 306
 	 * @return boolean true if all actions succeded, false otherwise
307 307
 	 */
308
-	function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
308
+	function action($action, $selected, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg)
309 309
 	{
310 310
 		//error_log( __METHOD__."('$action', ".array2string($selected).', '.array2string($use_all).",,, '$session_name')");
311 311
 		if ($use_all)
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 			// get the whole selection
314 314
 			$old_query = $query = is_array($session_name) ? $session_name : Api\Cache::getSession('importexport', $session_name);
315 315
 
316
-			@set_time_limit(0);				// switch off the execution time limit, as it's for big selections to small
317
-			$query['num_rows'] = -1;		// all
318
-			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
319
-			$this->get_rows($query,$rows,$readonlys);
316
+			@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
317
+			$query['num_rows'] = -1; // all
318
+			$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
319
+			$this->get_rows($query, $rows, $readonlys);
320 320
 
321 321
 			$selected = array();
322
-			foreach($rows as $row) {
322
+			foreach ($rows as $row) {
323 323
 				$selected[] = $row['definition_id'];
324 324
 			}
325
-			if(!is_array($session_name))
325
+			if (!is_array($session_name))
326 326
 			{
327 327
 				// Restore old query
328 328
 				Api\Cache::setSession('importexport', $session_name, $old_query);
@@ -334,18 +334,18 @@  discard block
 block discarded – undo
334 334
 
335 335
 		$bodefinitions = new importexport_definitions_bo(false, true);
336 336
 
337
-		switch($action) {
337
+		switch ($action) {
338 338
 			case 'allowed':
339 339
 				// Field is allowed_users, popup doesn't like _
340 340
 				$action = 'allowed_users';
341 341
 				// Fall through
342 342
 			case 'owner':
343
-				$action_msg = lang('changed'. ' ' . $action);
344
-				foreach($selected as $id) {
343
+				$action_msg = lang('changed'.' '.$action);
344
+				foreach ($selected as $id) {
345 345
 					$definition = $bodefinitions->read((int)$id);
346
-					if($definition['definition_id']) {
346
+					if ($definition['definition_id']) {
347 347
 						// Prevent private with no owner
348
-						if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id'];
348
+						if (!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id'];
349 349
 
350 350
 						$definition[$action] = $settings;
351 351
 						$bodefinitions->save($definition);
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 				$mime_type = ($GLOBALS['egw']->html->user_agent == 'msie' || $GLOBALS['egw']->html->user_agent == 'opera') ?
364 364
 					'application/octetstream' : 'application/octet-stream';
365 365
 				$name = 'importexport_definition.xml';
366
-				header('Content-Type: ' . $mime_type);
366
+				header('Content-Type: '.$mime_type);
367 367
 				header('Content-Disposition: attachment; filename="'.$name.'"');
368 368
 				echo $bodefinitions->export($selected);
369 369
 				exit();
@@ -372,16 +372,16 @@  discard block
 block discarded – undo
372 372
 			case 'copy':
373 373
 				$action_msg = lang('copied');
374 374
 				// Should only be one selected
375
-				foreach($selected as $id) {
375
+				foreach ($selected as $id) {
376 376
 					$definition = $bodefinitions->read((int)$id);
377
-					if($definition['definition_id']) {
377
+					if ($definition['definition_id']) {
378 378
 						unset($definition['definition_id']);
379
-						$definition['name'] = $settings ? $settings : $definition['name'] . ' copy';
379
+						$definition['name'] = $settings ? $settings : $definition['name'].' copy';
380 380
 						try {
381 381
 							$bodefinitions->save($definition);
382 382
 						} catch (Exception $e) {
383 383
 							try {
384
-								$definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid'];
384
+								$definition['name'] .= ' '.$GLOBALS['egw_info']['user']['account_lid'];
385 385
 								$bodefinitions->save($definition);
386 386
 							} catch (Exception $ex) {
387 387
 								$failed++;
@@ -396,16 +396,16 @@  discard block
 block discarded – undo
396 396
 			case 'createexport':
397 397
 				$action_msg = lang('created');
398 398
 				// Should only be one selected
399
-				foreach($selected as $id) {
399
+				foreach ($selected as $id) {
400 400
 					$definition = new importexport_definition($id);
401 401
 					try {
402 402
 						$export = $bodefinitions->export_from_import($definition);
403 403
 						$export->save();
404 404
 					} catch (Exception $e) {
405
-						if($export)
405
+						if ($export)
406 406
 						{
407 407
 							try {
408
-								$export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid'];
408
+								$export->name = $export->name.' '.$GLOBALS['egw_info']['user']['account_lid'];
409 409
 								$export->save();
410 410
 							} catch (Exception $ex) {
411 411
 								$failed++;
@@ -430,10 +430,10 @@  discard block
 block discarded – undo
430 430
 		Api\Cache::setSession('importexport', 'index', $query);
431 431
 
432 432
 		// Special handling for allowed users 'private'
433
-		if($query['col_filter']['allowed_users'] == 'private')
433
+		if ($query['col_filter']['allowed_users'] == 'private')
434 434
 		{
435 435
 			unset($query['col_filter']['allowed_users']);
436
-			$query['col_filter'][] = 'allowed_users = ' . $GLOBALS['egw']->db->quote(',,');
436
+			$query['col_filter'][] = 'allowed_users = '.$GLOBALS['egw']->db->quote(',,');
437 437
 		}
438 438
 		$bodefinitions = new importexport_definitions_bo($query['col_filter'], true);
439 439
 		// We don't care about readonlys for the UI
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 */
449 449
 	function edit()
450 450
 	{
451
-		if(!$_definition = $_GET['definition'])
451
+		if (!$_definition = $_GET['definition'])
452 452
 		{
453 453
 			$content = array(
454 454
 				'edit'		=> true,
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 			);
458 458
 
459 459
 			// Jump to a step
460
-			if($_GET['step'])
460
+			if ($_GET['step'])
461 461
 			{
462 462
 				$content['edit'] = false;
463 463
 				// Wizard will process previous step, then advance
464
-				$content['step'] = $this->get_step($_GET['step'],-1);
464
+				$content['step'] = $this->get_step($_GET['step'], -1);
465 465
 				$content['button']['next'] = 'pressed';
466 466
 				$this->wizard($content);
467 467
 			}
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 			}
473 473
 			return;
474 474
 		}
475
-		if(is_numeric($_GET['definition']))
475
+		if (is_numeric($_GET['definition']))
476 476
 		{
477 477
 			$definition = (int)$_GET['definition'];
478 478
 		}
@@ -484,31 +484,31 @@  discard block
 block discarded – undo
484 484
 		$definition = $bodefinitions->read($definition);
485 485
 		$definition['edit'] = true;
486 486
 		// Jump to a step
487
-		if($_GET['step'])
487
+		if ($_GET['step'])
488 488
 		{
489 489
 			$definition['edit'] = false;
490 490
 			// Wizard will process previous step, then advance
491
-			$definition['step'] = $_GET['step'];;
491
+			$definition['step'] = $_GET['step']; ;
492 492
 			$definition['button'] = array('next' => 'pressed');
493 493
 		}
494 494
 		$this->wizard($definition);
495 495
 	}
496 496
 
497
-	function wizard($content = null, $msg='')
497
+	function wizard($content = null, $msg = '')
498 498
 	{
499 499
 		$this->etpl->read('importexport.wizardbox');
500 500
 
501
-		if(is_array($content) &&! $content['edit'])
501
+		if (is_array($content) && !$content['edit'])
502 502
 		{
503
-			if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true));
503
+			if (self::_debug) error_log('importexport.wizard->$content '.print_r($content, true));
504 504
 			//foreach($content as $key => $val) error_log(" $key : ".array2string($val));
505 505
 			// fetch plugin object
506
-			if($content['plugin'] && $content['application'])
506
+			if ($content['plugin'] && $content['application'])
507 507
 			{
508
-				$wizard_name = $content['application'] . '_wizard_' . str_replace($content['application'] . '_', '', $content['plugin']);
508
+				$wizard_name = $content['application'].'_wizard_'.str_replace($content['application'].'_', '', $content['plugin']);
509 509
 
510 510
 				// we need to deal with the wizard object if exists
511
-				if (file_exists(EGW_SERVER_ROOT . '/'. $content['application']."/inc/class.$wizard_name.inc.php"))
511
+				if (file_exists(EGW_SERVER_ROOT.'/'.$content['application']."/inc/class.$wizard_name.inc.php"))
512 512
 				{
513 513
 					$wizard_plugin = $wizard_name;
514 514
 				}
@@ -517,38 +517,38 @@  discard block
 block discarded – undo
517 517
 					$wizard_plugin = $content['plugin'];
518 518
 				}
519 519
 				// App translations
520
-				if($content['application']) Api\Translation::add_app($content['application']);
520
+				if ($content['application']) Api\Translation::add_app($content['application']);
521 521
 
522 522
 				$this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin;
523 523
 
524 524
 				// Global object needs to be the same, or references to plugin don't work
525
-				if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this)
526
-					$GLOBALS['egw']->importexport_definitions_ui =& $this;
525
+				if (!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this)
526
+					$GLOBALS['egw']->importexport_definitions_ui = & $this;
527 527
 			}
528 528
 			// deal with buttons even if we are not on ajax
529
-			if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1)
529
+			if (isset($content['button']) && array_search('pressed', $content['button']) === false && count($content['button']) == 1)
530 530
 			{
531 531
 				$button = array_keys($content['button']);
532 532
 				$content['button'] = array($button[0] => 'pressed');
533 533
 			}
534 534
 
535 535
 			// post process submitted step
536
-			if($content['step'])
536
+			if ($content['step'])
537 537
 			{
538
-				if(!$this->can_edit($content))
538
+				if (!$this->can_edit($content))
539 539
 				{
540 540
 					// Each step changes definition, reload it
541 541
 					$bodefinitions = new importexport_definitions_bo();
542 542
 					$definition = $bodefinitions->read($content);
543 543
 					$content = $definition + array('step' => $content['step'], 'button' => $content['button']);
544 544
 				}
545
-				if(!key_exists($content['step'],$this->steps))
545
+				if (!key_exists($content['step'], $this->steps))
546 546
 				{
547
-					$next_step = $this->plugin->{$content['step']}($content,$sel_options,$readonlys,$preserv);
547
+					$next_step = $this->plugin->{$content['step']}($content, $sel_options, $readonlys, $preserv);
548 548
 				}
549 549
 				else
550 550
 				{
551
-					$next_step = $this->{$content['step']}($content,$sel_options,$readonlys,$preserv);
551
+					$next_step = $this->{$content['step']}($content, $sel_options, $readonlys, $preserv);
552 552
 				}
553 553
 			}
554 554
 			else
@@ -560,23 +560,23 @@  discard block
 block discarded – undo
560 560
 			$sel_options = $readonlys = $preserv = array();
561 561
 
562 562
 			// Disable finish button if required fields are missing
563
-			if(!$content['name'] || !$content['type'] || !$content['plugin'])
563
+			if (!$content['name'] || !$content['type'] || !$content['plugin'])
564 564
 			{
565 565
 				$readonlys['button[finish]'] = true;
566 566
 			}
567 567
 			do
568 568
 			{
569
-				if(!key_exists($next_step,$this->steps))
569
+				if (!key_exists($next_step, $this->steps))
570 570
 				{
571
-					$this->wizard_content_template = $this->plugin->$next_step($content,$sel_options,$readonlys,$preserv);
571
+					$this->wizard_content_template = $this->plugin->$next_step($content, $sel_options, $readonlys, $preserv);
572 572
 				}
573 573
 				else
574 574
 				{
575
-					$this->wizard_content_template = $this->$next_step($content,$sel_options,$readonlys,$preserv);
575
+					$this->wizard_content_template = $this->$next_step($content, $sel_options, $readonlys, $preserv);
576 576
 				}
577
-				if($this->wizard_content_template == self::SKIP)
577
+				if ($this->wizard_content_template == self::SKIP)
578 578
 				{
579
-					if(!key_exists($content['step'],$this->steps))
579
+					if (!key_exists($content['step'], $this->steps))
580 580
 					{
581 581
 						$next_step = $this->plugin->{$content['step']}($content);
582 582
 					}
@@ -585,9 +585,9 @@  discard block
 block discarded – undo
585 585
 						$next_step = $this->{$content['step']}($content);
586 586
 					}
587 587
 				}
588
-			} while($this->wizard_content_template == self::SKIP);
588
+			} while ($this->wizard_content_template == self::SKIP);
589 589
 
590
-			if(!$this->can_edit($content))
590
+			if (!$this->can_edit($content))
591 591
 			{
592 592
 				$readonlys[$this->wizard_content_template] = true;
593 593
 				$preserve = $content;
@@ -596,21 +596,21 @@  discard block
 block discarded – undo
596 596
 
597 597
 			unset($content['button']);
598 598
 			$content['wizard_content'] = $this->wizard_content_template;
599
-			$this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2);
599
+			$this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2);
600 600
 		}
601 601
 		else
602 602
 		{
603 603
 			// initial content
604 604
 			$sel_options = $readonlys = $preserv = array();
605 605
 			$readonlys['button[previous]'] = true;
606
-			if($content['edit'])
606
+			if ($content['edit'])
607 607
 			{
608 608
 				unset ($content['edit']);
609 609
 			}
610 610
 
611 611
 			$this->wizard_content_template = $this->wizard_step10($content, $sel_options, $readonlys, $preserv);
612 612
 
613
-			if(!$this->can_edit($content))
613
+			if (!$this->can_edit($content))
614 614
 			{
615 615
 				$readonlys[$this->wizard_content_template] = true;
616 616
 				$preserve = $content;
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 			}
619 619
 
620 620
 			$content['wizard_content'] = $this->wizard_content_template;
621
-			$this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2);
621
+			$this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2);
622 622
 		}
623 623
 	}
624 624
 
@@ -629,31 +629,31 @@  discard block
 block discarded – undo
629 629
 	 * @param int $step_width
630 630
 	 * @return string containing function name of next step
631 631
 	 */
632
-	function get_step ($curr_step, $step_width)
632
+	function get_step($curr_step, $step_width)
633 633
 	{
634 634
 		/*if($content['plugin'] && $content['application']&& !is_object($this->plugin))
635 635
 		{
636 636
 			$plugin_definition =  $this->plugins[$content['application']][$content['plugin']]['definition'];
637 637
 			if($plugin_definition) $this->plugin = new $plugin_definition;
638 638
 		}*/
639
-		if(is_object($this->plugin) && is_array($this->plugin->steps))
639
+		if (is_object($this->plugin) && is_array($this->plugin->steps))
640 640
 		{
641
-			$steps = array_merge($this->steps,$this->plugin->steps);
642
-			$steps = array_flip($steps); asort($steps);	$steps = array_flip($steps);
641
+			$steps = array_merge($this->steps, $this->plugin->steps);
642
+			$steps = array_flip($steps); asort($steps); $steps = array_flip($steps);
643 643
 		}
644 644
 		else
645 645
 		{
646 646
 			$steps = $this->steps;
647 647
 		}
648 648
 		$step_keys = array_keys($steps);
649
-		$nn = array_search($curr_step,$step_keys)+(int)$step_width;
650
-		return (key_exists($nn,$step_keys)) ? $step_keys[$nn] : 'wizard_finish';
649
+		$nn = array_search($curr_step, $step_keys) + (int)$step_width;
650
+		return (key_exists($nn, $step_keys)) ? $step_keys[$nn] : 'wizard_finish';
651 651
 	}
652 652
 
653 653
 
654 654
 	function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv)
655 655
 	{
656
-		if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true));
656
+		if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content, true));
657 657
 
658 658
 		// return from step10
659 659
 		if ($content['step'] == 'wizard_step10')
@@ -661,11 +661,11 @@  discard block
 block discarded – undo
661 661
 			switch (array_search('pressed', $content['button']))
662 662
 			{
663 663
 				case 'next':
664
-					return $this->get_step($content['step'],1);
664
+					return $this->get_step($content['step'], 1);
665 665
 				case 'finish':
666 666
 					return 'wizard_finish';
667 667
 				default :
668
-					return $this->wizard_step10($content,$sel_options,$readonlys,$preserv);
668
+					return $this->wizard_step10($content, $sel_options, $readonlys, $preserv);
669 669
 			}
670 670
 
671 671
 		}
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 			$content['text'] = $this->steps['wizard_step10'];
676 676
 			foreach ($this->plugins as $appname => $options)
677 677
 			{
678
-				if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) {
678
+				if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) {
679 679
 					$sel_options['application'][$appname] = lang($appname);
680 680
 				}
681 681
 			}
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 	// get plugin
692 692
 	function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv)
693 693
 	{
694
-		if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true));
694
+		if (self::_debug) error_log('importexport.'.get_class($this).'::wizard_step20->$content '.print_r($content, true));
695 695
 
696 696
 		// return from step20
697 697
 		if ($content['step'] == 'wizard_step20')
@@ -700,21 +700,21 @@  discard block
 block discarded – undo
700 700
 			{
701 701
 				case 'next':
702 702
 					// There's no real reason the plugin has to come from any of these, as long as it has a $steps variable
703
-					if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) {
703
+					if ($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) {
704 704
 						$content['type'] = 'import';
705
-					} elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) {
705
+					} elseif ($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin), 'export') !== false) {
706 706
 						$content['type'] = 'export';
707 707
 					} else {
708 708
 						throw new Api\Exception('Invalid plugin');
709 709
 					}
710
-					return $this->get_step($content['step'],1);
710
+					return $this->get_step($content['step'], 1);
711 711
 				case 'previous' :
712 712
 					$readonlys['button[previous]'] = true;
713
-					return $this->get_step($content['step'],-1);
713
+					return $this->get_step($content['step'], -1);
714 714
 				case 'finish':
715 715
 					return 'wizard_finish';
716 716
 				default :
717
-					return $this->wizard_step20($content,$sel_options,$readonlys,$preserv);
717
+					return $this->wizard_step20($content, $sel_options, $readonlys, $preserv);
718 718
 			}
719 719
 		}
720 720
 		// init step20
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 			$content['text'] = $this->steps['wizard_step20'];
724 724
 			$config = Api\Config::read('phpgwapi');
725 725
 			foreach ($this->plugins[$content['application']] as $type => $plugins) {
726
-				if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue;
727
-				foreach($plugins as $plugin => $name) {
726
+				if ($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue;
727
+				foreach ($plugins as $plugin => $name) {
728 728
 					$sel_options['plugin'][$plugin] = $name;
729 729
 				}
730 730
 			}
@@ -740,15 +740,15 @@  discard block
 block discarded – undo
740 740
 	// name
741 741
 	function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv)
742 742
 	{
743
-		if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true));
743
+		if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content, true));
744 744
 
745 745
 		// Check for duplicate name
746 746
 		$duplicate = isset($content['duplicate_error']);
747
-		if($content['name'] && !$duplicate)
747
+		if ($content['name'] && !$duplicate)
748 748
 		{
749 749
 			try {
750 750
 				$check_definition = new importexport_definition($content['name']);
751
-				if($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id'])
751
+				if ($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id'])
752 752
 				{
753 753
 					throw new Exception('Already exists');
754 754
 				}
@@ -758,21 +758,21 @@  discard block
 block discarded – undo
758 758
 
759 759
 				// Try some suggestions
760 760
 				$suggestions = array(
761
-					$content['name'] .'-'. $GLOBALS['egw_info']['user']['account_lid'],
762
-					$content['name'] .'-'. $GLOBALS['egw_info']['user']['account_id'],
763
-					$content['name'] .'-'. Api\DateTime::to('now', true),
761
+					$content['name'].'-'.$GLOBALS['egw_info']['user']['account_lid'],
762
+					$content['name'].'-'.$GLOBALS['egw_info']['user']['account_id'],
763
+					$content['name'].'-'.Api\DateTime::to('now', true),
764 764
 					//$content['name'] .'-'. rand(0,100),
765 765
 				);
766
-				foreach($suggestions as $key => $suggestion) {
766
+				foreach ($suggestions as $key => $suggestion) {
767 767
 					$sug_definition = new importexport_definition($suggestion);
768
-					if($sug_definition->definition_id) {
768
+					if ($sug_definition->definition_id) {
769 769
 						unset($suggestions[$key]);
770 770
 					}
771 771
 				}
772
-				if($suggestions) {
773
-					$content['duplicate_error'] .= '  '. lang('Try')." \n" . implode("\n", $suggestions);
772
+				if ($suggestions) {
773
+					$content['duplicate_error'] .= '  '.lang('Try')." \n".implode("\n", $suggestions);
774 774
 				}
775
-				return $this->get_step($content['step'],0);
775
+				return $this->get_step($content['step'], 0);
776 776
 			}
777 777
 		}
778 778
 
@@ -782,19 +782,19 @@  discard block
 block discarded – undo
782 782
 			switch (array_search('pressed', $content['button']))
783 783
 			{
784 784
 				case 'next':
785
-					return $this->get_step($content['step'],1);
785
+					return $this->get_step($content['step'], 1);
786 786
 				case 'previous' :
787
-					return $this->get_step($content['step'],-1);
787
+					return $this->get_step($content['step'], -1);
788 788
 				case 'finish':
789 789
 					return 'wizard_finish';
790 790
 				default :
791
-					return $this->wizard_step21($content,$sel_options,$readonlys,$preserv);
791
+					return $this->wizard_step21($content, $sel_options, $readonlys, $preserv);
792 792
 			}
793 793
 		}
794 794
 		// init step21
795 795
 		else
796 796
 		{
797
-			$content['text'] = $this->steps['wizard_step21'] . ($duplicate ? "\n".$content['duplicate_error'] : '');
797
+			$content['text'] = $this->steps['wizard_step21'].($duplicate ? "\n".$content['duplicate_error'] : '');
798 798
 			$content['step'] = 'wizard_step21';
799 799
 			unset($content['duplicate_error']);
800 800
 			$preserv = $content;
@@ -806,17 +806,16 @@  discard block
 block discarded – undo
806 806
 	// allowed users
807 807
 	function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv)
808 808
 	{
809
-		if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true));
809
+		if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content, true));
810 810
 
811 811
 		// return from step90
812 812
 		if ($content['step'] == 'wizard_step90')
813 813
 		{
814
-			if($this->can_edit($content))
814
+			if ($this->can_edit($content))
815 815
 			{
816
-				$content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ,'importexport') ?
817
-					($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) :
818
-					null;
819
-				$content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',',$content['allowed_users']));
816
+				$content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ, 'importexport') ?
817
+					($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : null;
818
+				$content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',', $content['allowed_users']));
820 819
 				unset($content['just_me']);
821 820
 			}
822 821
 
@@ -824,12 +823,12 @@  discard block
 block discarded – undo
824 823
 			switch (array_search('pressed', $content['button']))
825 824
 			{
826 825
 				case 'previous' :
827
-					return $this->get_step($content['step'],-1);
826
+					return $this->get_step($content['step'], -1);
828 827
 				case 'next':
829 828
 				case 'finish':
830 829
 					return 'wizard_finish';
831 830
 				default :
832
-					return $this->wizard_step90($content,$sel_options,$readonlys,$preserv);
831
+					return $this->wizard_step90($content, $sel_options, $readonlys, $preserv);
833 832
 			}
834 833
 		}
835 834
 		// init step90
@@ -840,10 +839,10 @@  discard block
 block discarded – undo
840 839
 			$preserv = $content;
841 840
 
842 841
 			// Set owner for non-admins
843
-			$content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) ==1) && $content['owner']);
844
-			$content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0',$content['allowed_users']) && $content['allowed_users'][0] == 'all' ||
842
+			$content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) == 1) && $content['owner']);
843
+			$content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0', $content['allowed_users']) && $content['allowed_users'][0] == 'all' ||
845 844
 			$content['allowed_users'] == 'all';
846
-			if(!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin'])
845
+			if (!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin'])
847 846
 			{
848 847
 				$content['allowed_users'] = array();
849 848
 				$readonlys['allowed_users'] = true;
@@ -859,11 +858,11 @@  discard block
 block discarded – undo
859 858
 				)
860 859
 			);
861 860
 			// Hide 'just me' checkbox, users get confused by read-only
862
-			if($readonlys['just_me'] || !$this->can_edit($content))
861
+			if ($readonlys['just_me'] || !$this->can_edit($content))
863 862
 			{
864 863
 				$content['no_just_me'] = true;
865 864
 			}
866
-			if($readonlys['all_users'] || !$this->can_edit($content))
865
+			if ($readonlys['all_users'] || !$this->can_edit($content))
867 866
 			{
868 867
 				$content['no_all_users'] = true;
869 868
 			}
@@ -876,7 +875,7 @@  discard block
 block discarded – undo
876 875
 
877 876
 	function wizard_finish(&$content)
878 877
 	{
879
-		if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true));
878
+		if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content, true));
880 879
 		// Take out some UI leavings
881 880
 		unset($content['text']);
882 881
 		unset($content['step']);
@@ -886,26 +885,26 @@  discard block
 block discarded – undo
886 885
 		$bodefinitions->save($content);
887 886
 		// This message is displayed if browser cant close window
888 887
 		$content['msg'] = lang('ImportExport wizard finished successfully!');
889
-		Framework::refresh_opener('','importexport');
888
+		Framework::refresh_opener('', 'importexport');
890 889
 		Framework::window_close();
891 890
 		return 'importexport.wizard_close';
892 891
 	}
893 892
 
894
-	function import_definition($content='')
893
+	function import_definition($content = '')
895 894
 	{
896 895
 		$bodefinitions = new importexport_definitions_bo();
897 896
 		if (is_array($content))
898 897
 		{
899
-			if($content['import_file']['tmp_name'])
898
+			if ($content['import_file']['tmp_name'])
900 899
 			{
901 900
 				$result = $bodefinitions->import($content['import_file']['tmp_name']);
902
-				$msg = lang('%1 definitions %2', count($result), lang('imported')) ."\n". implode("\n", array_keys($result));
901
+				$msg = lang('%1 definitions %2', count($result), lang('imported'))."\n".implode("\n", array_keys($result));
903 902
 				return $this->index(null, $msg);
904 903
 			}
905
-			if($content['update'])
904
+			if ($content['update'])
906 905
 			{
907 906
 				$applist = importexport_helper_functions::get_apps('all', true);
908
-				foreach($applist as $appname) {
907
+				foreach ($applist as $appname) {
909 908
 					importexport_helper_functions::load_defaults($appname);
910 909
 				}
911 910
 				return $this->index();
@@ -915,7 +914,7 @@  discard block
 block discarded – undo
915 914
 		{
916 915
 			$content = array();
917 916
 			$etpl = new etemplate(self::_appname.'.import_definition');
918
-			return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition',$content,array(),$readonlys,$preserv);
917
+			return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition', $content, array(), $readonlys, $preserv);
919 918
 		}
920 919
 	}
921 920
 
@@ -925,17 +924,17 @@  discard block
 block discarded – undo
925 924
 	 */
926 925
 	protected function can_edit(Array $definition)
927 926
 	{
928
-		if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'])
927
+		if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'])
929 928
 		{
930 929
 			// Definition belongs to user
931 930
 			return true;
932 931
 		}
933
-		elseif($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin'])
932
+		elseif ($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin'])
934 933
 		{
935 934
 			// Definition is unowned, and user is an admin
936 935
 			return true;
937 936
 		}
938
-		elseif(!$definition['definition_id'])
937
+		elseif (!$definition['definition_id'])
939 938
 		{
940 939
 			// Definition is in-progress, not saved yet
941 940
 			return true;
Please login to merge, or discard this patch.
Braces   +112 added lines, -42 removed lines patch added patch discarded remove patch
@@ -81,14 +81,18 @@  discard block
 block discarded – undo
81 81
 	{
82 82
 		$filter = array('name' => '*');
83 83
 
84
-		if($GLOBALS['egw_info']['user']['apps']['admin']) {
84
+		if($GLOBALS['egw_info']['user']['apps']['admin'])
85
+		{
85 86
 			// Any public definition
86 87
 			$filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')';
87
-		} else {
88
+		}
89
+		else
90
+		{
88 91
 			// Filter private definitions
89 92
 			$filter['owner'] = $GLOBALS['egw_info']['user']['account_id'];
90 93
 			$config = Api\Config::read('phpgwapi');
91
-			if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) {
94
+			if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted())
95
+			{
92 96
 				$filter['type'] = 'import';
93 97
 			}
94 98
 		}
@@ -104,7 +108,10 @@  discard block
 block discarded – undo
104 108
 			elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false)
105 109
 			{
106 110
 				$selected = $content['nm']['rows']['selected'];
107
-				if(count($selected) < 1 || !is_array($selected)) exit();
111
+				if(count($selected) < 1 || !is_array($selected))
112
+				{
113
+					exit();
114
+				}
108 115
 				switch ($button)
109 116
 				{
110 117
 					case 'delete_selected' :
@@ -160,7 +167,8 @@  discard block
 block discarded – undo
160 167
 			}
161 168
 		}
162 169
 
163
-		if(!is_array($content['nm'])) {
170
+		if(!is_array($content['nm']))
171
+		{
164 172
 			$content['nm'] = array(
165 173
 				'get_rows'	=> 'importexport.importexport_definitions_ui.get_rows',
166 174
 				'no_cat'	=> true,
@@ -171,7 +179,10 @@  discard block
 block discarded – undo
171 179
 				'row_id'	=> 'definition_id',
172 180
 				'placeholder_actions' => array('add')
173 181
 			);
174
-			if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application'];
182
+			if($_GET['application'])
183
+			{
184
+				$content['nm']['col_filter']['application'] = $_GET['application'];
185
+			}
175 186
 		}
176 187
 		if(Api\Cache::getSession('importexport', 'index'))
177 188
 		{
@@ -190,17 +201,22 @@  discard block
 block discarded – undo
190 201
 		);
191 202
 		foreach ($this->plugins as $appname => $options)
192 203
 		{
193
-			if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) {
204
+			if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin'])
205
+			{
194 206
 				$sel_options['application'][$appname] = lang($appname);
195 207
 			}
196 208
 		}
197
-		if($msg) $content['msg'] = $msg;
209
+		if($msg)
210
+		{
211
+			$content['msg'] = $msg;
212
+		}
198 213
 
199 214
 		$etpl = new Etemplate(self::_appname.'.definition_index');
200 215
 		return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv );
201 216
 	}
202 217
 
203
-	private function get_actions() {
218
+	private function get_actions()
219
+	{
204 220
 		$group = 0;
205 221
 		$actions = array(
206 222
 			'edit' => array(
@@ -319,7 +335,8 @@  discard block
 block discarded – undo
319 335
 			$this->get_rows($query,$rows,$readonlys);
320 336
 
321 337
 			$selected = array();
322
-			foreach($rows as $row) {
338
+			foreach($rows as $row)
339
+			{
323 340
 				$selected[] = $row['definition_id'];
324 341
 			}
325 342
 			if(!is_array($session_name))
@@ -334,18 +351,24 @@  discard block
 block discarded – undo
334 351
 
335 352
 		$bodefinitions = new importexport_definitions_bo(false, true);
336 353
 
337
-		switch($action) {
354
+		switch($action)
355
+		{
338 356
 			case 'allowed':
339 357
 				// Field is allowed_users, popup doesn't like _
340 358
 				$action = 'allowed_users';
341 359
 				// Fall through
342 360
 			case 'owner':
343 361
 				$action_msg = lang('changed'. ' ' . $action);
344
-				foreach($selected as $id) {
362
+				foreach($selected as $id)
363
+				{
345 364
 					$definition = $bodefinitions->read((int)$id);
346
-					if($definition['definition_id']) {
365
+					if($definition['definition_id'])
366
+					{
347 367
 						// Prevent private with no owner
348
-						if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id'];
368
+						if(!$definition['owner'] && !$settings)
369
+						{
370
+							$definition['owner'] = $GLOBALS['egw_info']['user']['account_id'];
371
+						}
349 372
 
350 373
 						$definition[$action] = $settings;
351 374
 						$bodefinitions->save($definition);
@@ -372,18 +395,22 @@  discard block
 block discarded – undo
372 395
 			case 'copy':
373 396
 				$action_msg = lang('copied');
374 397
 				// Should only be one selected
375
-				foreach($selected as $id) {
398
+				foreach($selected as $id)
399
+				{
376 400
 					$definition = $bodefinitions->read((int)$id);
377
-					if($definition['definition_id']) {
401
+					if($definition['definition_id'])
402
+					{
378 403
 						unset($definition['definition_id']);
379 404
 						$definition['name'] = $settings ? $settings : $definition['name'] . ' copy';
380 405
 						try {
381 406
 							$bodefinitions->save($definition);
382
-						} catch (Exception $e) {
407
+						}
408
+						catch (Exception $e) {
383 409
 							try {
384 410
 								$definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid'];
385 411
 								$bodefinitions->save($definition);
386
-							} catch (Exception $ex) {
412
+							}
413
+							catch (Exception $ex) {
387 414
 								$failed++;
388 415
 								$msg .= lang('Duplicate name, please choose another.');
389 416
 								continue;
@@ -396,18 +423,21 @@  discard block
 block discarded – undo
396 423
 			case 'createexport':
397 424
 				$action_msg = lang('created');
398 425
 				// Should only be one selected
399
-				foreach($selected as $id) {
426
+				foreach($selected as $id)
427
+				{
400 428
 					$definition = new importexport_definition($id);
401 429
 					try {
402 430
 						$export = $bodefinitions->export_from_import($definition);
403 431
 						$export->save();
404
-					} catch (Exception $e) {
432
+					}
433
+					catch (Exception $e) {
405 434
 						if($export)
406 435
 						{
407 436
 							try {
408 437
 								$export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid'];
409 438
 								$export->save();
410
-							} catch (Exception $ex) {
439
+							}
440
+							catch (Exception $ex) {
411 441
 								$failed++;
412 442
 								$msg .= lang('Duplicate name, please choose another.');
413 443
 								continue;
@@ -425,7 +455,8 @@  discard block
 block discarded – undo
425 455
 		return !$failed;
426 456
 	}
427 457
 
428
-	public function get_rows(&$query, &$rows, &$readonlys) {
458
+	public function get_rows(&$query, &$rows, &$readonlys)
459
+	{
429 460
 		$rows = array();
430 461
 		Api\Cache::setSession('importexport', 'index', $query);
431 462
 
@@ -500,7 +531,10 @@  discard block
 block discarded – undo
500 531
 
501 532
 		if(is_array($content) &&! $content['edit'])
502 533
 		{
503
-			if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true));
534
+			if(self::_debug)
535
+			{
536
+				error_log('importexport.wizard->$content '. print_r($content,true));
537
+			}
504 538
 			//foreach($content as $key => $val) error_log(" $key : ".array2string($val));
505 539
 			// fetch plugin object
506 540
 			if($content['plugin'] && $content['application'])
@@ -517,13 +551,18 @@  discard block
 block discarded – undo
517 551
 					$wizard_plugin = $content['plugin'];
518 552
 				}
519 553
 				// App translations
520
-				if($content['application']) Api\Translation::add_app($content['application']);
554
+				if($content['application'])
555
+				{
556
+					Api\Translation::add_app($content['application']);
557
+				}
521 558
 
522 559
 				$this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin;
523 560
 
524 561
 				// Global object needs to be the same, or references to plugin don't work
525 562
 				if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this)
526
-					$GLOBALS['egw']->importexport_definitions_ui =& $this;
563
+				{
564
+									$GLOBALS['egw']->importexport_definitions_ui =& $this;
565
+				}
527 566
 			}
528 567
 			// deal with buttons even if we are not on ajax
529 568
 			if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1)
@@ -653,7 +692,10 @@  discard block
 block discarded – undo
653 692
 
654 693
 	function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv)
655 694
 	{
656
-		if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true));
695
+		if(self::_debug)
696
+		{
697
+			error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true));
698
+		}
657 699
 
658 700
 		// return from step10
659 701
 		if ($content['step'] == 'wizard_step10')
@@ -675,7 +717,8 @@  discard block
 block discarded – undo
675 717
 			$content['text'] = $this->steps['wizard_step10'];
676 718
 			foreach ($this->plugins as $appname => $options)
677 719
 			{
678
-				if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) {
720
+				if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin'])
721
+				{
679 722
 					$sel_options['application'][$appname] = lang($appname);
680 723
 				}
681 724
 			}
@@ -691,7 +734,10 @@  discard block
 block discarded – undo
691 734
 	// get plugin
692 735
 	function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv)
693 736
 	{
694
-		if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true));
737
+		if(self::_debug)
738
+		{
739
+			error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true));
740
+		}
695 741
 
696 742
 		// return from step20
697 743
 		if ($content['step'] == 'wizard_step20')
@@ -700,11 +746,16 @@  discard block
 block discarded – undo
700 746
 			{
701 747
 				case 'next':
702 748
 					// There's no real reason the plugin has to come from any of these, as long as it has a $steps variable
703
-					if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) {
749
+					if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false)
750
+					{
704 751
 						$content['type'] = 'import';
705
-					} elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) {
752
+					}
753
+					elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false)
754
+					{
706 755
 						$content['type'] = 'export';
707
-					} else {
756
+					}
757
+					else
758
+					{
708 759
 						throw new Api\Exception('Invalid plugin');
709 760
 					}
710 761
 					return $this->get_step($content['step'],1);
@@ -722,9 +773,14 @@  discard block
 block discarded – undo
722 773
 		{
723 774
 			$content['text'] = $this->steps['wizard_step20'];
724 775
 			$config = Api\Config::read('phpgwapi');
725
-			foreach ($this->plugins[$content['application']] as $type => $plugins) {
726
-				if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue;
727
-				foreach($plugins as $plugin => $name) {
776
+			foreach ($this->plugins[$content['application']] as $type => $plugins)
777
+			{
778
+				if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export')
779
+				{
780
+					continue;
781
+				}
782
+				foreach($plugins as $plugin => $name)
783
+				{
728 784
 					$sel_options['plugin'][$plugin] = $name;
729 785
 				}
730 786
 			}
@@ -740,7 +796,10 @@  discard block
 block discarded – undo
740 796
 	// name
741 797
 	function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv)
742 798
 	{
743
-		if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true));
799
+		if(self::_debug)
800
+		{
801
+			error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true));
802
+		}
744 803
 
745 804
 		// Check for duplicate name
746 805
 		$duplicate = isset($content['duplicate_error']);
@@ -752,7 +811,8 @@  discard block
 block discarded – undo
752 811
 				{
753 812
 					throw new Exception('Already exists');
754 813
 				}
755
-			} catch (Exception $e) {
814
+			}
815
+			catch (Exception $e) {
756 816
 			//		throw new Exception('Already exists');
757 817
 				$content['duplicate_error'] = lang('Duplicate name, please choose another.');
758 818
 
@@ -763,13 +823,16 @@  discard block
 block discarded – undo
763 823
 					$content['name'] .'-'. Api\DateTime::to('now', true),
764 824
 					//$content['name'] .'-'. rand(0,100),
765 825
 				);
766
-				foreach($suggestions as $key => $suggestion) {
826
+				foreach($suggestions as $key => $suggestion)
827
+				{
767 828
 					$sug_definition = new importexport_definition($suggestion);
768
-					if($sug_definition->definition_id) {
829
+					if($sug_definition->definition_id)
830
+					{
769 831
 						unset($suggestions[$key]);
770 832
 					}
771 833
 				}
772
-				if($suggestions) {
834
+				if($suggestions)
835
+				{
773 836
 					$content['duplicate_error'] .= '  '. lang('Try')." \n" . implode("\n", $suggestions);
774 837
 				}
775 838
 				return $this->get_step($content['step'],0);
@@ -806,7 +869,10 @@  discard block
 block discarded – undo
806 869
 	// allowed users
807 870
 	function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv)
808 871
 	{
809
-		if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true));
872
+		if(self::_debug)
873
+		{
874
+			error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true));
875
+		}
810 876
 
811 877
 		// return from step90
812 878
 		if ($content['step'] == 'wizard_step90')
@@ -876,7 +942,10 @@  discard block
 block discarded – undo
876 942
 
877 943
 	function wizard_finish(&$content)
878 944
 	{
879
-		if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true));
945
+		if(self::_debug)
946
+		{
947
+			error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true));
948
+		}
880 949
 		// Take out some UI leavings
881 950
 		unset($content['text']);
882 951
 		unset($content['step']);
@@ -905,7 +974,8 @@  discard block
 block discarded – undo
905 974
 			if($content['update'])
906 975
 			{
907 976
 				$applist = importexport_helper_functions::get_apps('all', true);
908
-				foreach($applist as $appname) {
977
+				foreach($applist as $appname)
978
+				{
909 979
 					importexport_helper_functions::load_defaults($appname);
910 980
 				}
911 981
 				return $this->index();
Please login to merge, or discard this patch.
importexport/inc/class.importexport_export_csv.inc.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @param stram $_stream resource where records are exported to.
98 98
 	 * @param array _options options for specific backends
99
-	 * @return bool
99
+	 * @return boolean|null
100 100
 	 */
101 101
 	public function __construct( $_stream, array $_options ) {
102 102
 		if (!is_object($GLOBALS['egw']->translation)) {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * exports a record into resource of handle
152 152
 	 *
153 153
 	 * @param importexport_iface_egw_record record
154
-	 * @return bool
154
+	 * @return boolean|null
155 155
 	 */
156 156
 	public function export_record( importexport_iface_egw_record $_record ) {
157 157
 		$this->record = $_record;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * Uses the static variable $types to convert various datatypes.
286 286
 	 *
287
-	 * @param record Record to be converted
287
+	 * @param record importexport_iface_egw_record to be converted
288 288
 	 * @parem fields List of field types => field names to be converted
289 289
 	 * @param appname Current appname if you want to do custom fields too
290 290
 	 */
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 * @parem fields List of field types => field names to be converted
289 289
 	 * @param appname Current appname if you want to do custom fields too
290 290
 	 */
291
-	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) {
291
+	public static function convert(importexport_iface_egw_record &$record, array $fields = array(), $appname = null, $selects = array()) {
292 292
 		if($appname) {
293 293
 			if(!self::$cf_parse_cache[$appname]) {
294 294
 				$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 * @param char $delimiter
453 453
 	 * @param char $enclosure
454 454
 	 */
455
-	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){
455
+	protected function fputcsv($filePointer, array $dataArray, $delimiter, $enclosure){
456 456
 		$string = "";
457 457
 		$writeDelimiter = false;
458 458
 		foreach($dataArray as $dataElement) {
Please login to merge, or discard this patch.
Braces   +178 added lines, -70 removed lines patch added patch discarded remove patch
@@ -98,22 +98,32 @@  discard block
 block discarded – undo
98 98
 	 * @param array _options options for specific backends
99 99
 	 * @return bool
100 100
 	 */
101
-	public function __construct( $_stream, array $_options ) {
102
-		if (!is_object($GLOBALS['egw']->translation)) {
101
+	public function __construct( $_stream, array $_options )
102
+	{
103
+		if (!is_object($GLOBALS['egw']->translation))
104
+		{
103 105
 			$GLOBALS['egw']->translation = new Api\Translation();
104 106
 		}
105 107
 		$this->translation = &$GLOBALS['egw']->translation;
106 108
 		$this->handle = $_stream;
107
-		if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
109
+		if($_options['charset'] == 'user')
110
+		{
111
+			$_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
112
+		}
108 113
 		$this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8';
109
-		if ( !empty( $_options ) ) {
114
+		if ( !empty( $_options ) )
115
+		{
110 116
 			$this->csv_options = array_merge( $this->csv_options, $_options );
111 117
 		}
112 118
 		//error_log(__METHOD__.__LINE__.array2string($_options['appname']));
113
-		if(!Api\Storage\Merge::is_export_limit_excepted()) {
119
+		if(!Api\Storage\Merge::is_export_limit_excepted())
120
+		{
114 121
 			$this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']);
115 122
 			//error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit);
116
-			if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled');
123
+			if($this->export_limit == 'no')
124
+			{
125
+				throw new Api\Exception\NoPermission\Admin('Export disabled');
126
+			}
117 127
 		}
118 128
 	}
119 129
 	
@@ -122,15 +132,19 @@  discard block
 block discarded – undo
122 132
 	 *
123 133
 	 * @param array $_mapping egw_field_name => csv_field_name
124 134
 	 */
125
-	public function set_mapping( array &$_mapping) {
126
-		if ($this->num_of_records > 0) {
135
+	public function set_mapping( array &$_mapping)
136
+	{
137
+		if ($this->num_of_records > 0)
138
+		{
127 139
 			throw new Exception('Error: Field mapping can\'t be set during ongoing export!');
128 140
 		}
129
-		if($_mapping['all_custom_fields']) {
141
+		if($_mapping['all_custom_fields'])
142
+		{
130 143
 			// Field value is the appname, so we can pull the fields
131 144
 			$custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']);
132 145
 			unset($_mapping['all_custom_fields']);
133
-			foreach($custom as $field => $info) {
146
+			foreach($custom as $field => $info)
147
+			{
134 148
 				$_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field;
135 149
 			}
136 150
 		}
@@ -143,7 +157,8 @@  discard block
 block discarded – undo
143 157
 	 *
144 158
 	 * @param array $_conversion
145 159
 	 */
146
-	public function set_conversion( array $_conversion) {
160
+	public function set_conversion( array $_conversion)
161
+	{
147 162
 		$this->conversion = $_conversion;
148 163
 	}
149 164
 	
@@ -153,16 +168,23 @@  discard block
 block discarded – undo
153 168
 	 * @param importexport_iface_egw_record record
154 169
 	 * @return bool
155 170
 	 */
156
-	public function export_record( importexport_iface_egw_record $_record ) {
171
+	public function export_record( importexport_iface_egw_record $_record )
172
+	{
157 173
 		$this->record = $_record;
158 174
 		$this->record_array = $_record->get_record_array();
159 175
 		
160 176
 		// begin with fieldnames ?
161
-		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) {
162
-			if($this->csv_options['begin_with_fieldnames'] == 'label') {
177
+		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] )
178
+		{
179
+			if($this->csv_options['begin_with_fieldnames'] == 'label')
180
+			{
163 181
 				// Load translations for app
164 182
 				list($appname, $part2) = explode('_', get_class($_record));
165
-				if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
183
+				if(!$GLOBALS['egw_info']['apps'][$appname])
184
+				{
185
+					$appname .= $part2;
186
+				}
187
+				// Handle apps with _ in the name
166 188
 
167 189
 				// Get translations from wizard, if possible
168 190
 				if(!$this->csv_options['no_header_translation'])
@@ -180,11 +202,16 @@  discard block
 block discarded – undo
180 202
 								$label = $label != $fields[$field] ? $fields[$field] : lang($label);
181 203
 							}
182 204
 							// Make sure no *
183
-							if(substr($label,-1) == '*') $label = substr($label,0,-1);
205
+							if(substr($label,-1) == '*')
206
+							{
207
+								$label = substr($label,0,-1);
208
+							}
184 209
 						}
185
-					} catch (Exception $e) {
210
+					}
211
+					catch (Exception $e) {
186 212
 						Api\Translation::add_app($appname);
187
-						foreach($this->mapping as $field => &$label) {
213
+						foreach($this->mapping as $field => &$label)
214
+						{
188 215
 							$label = lang($label);
189 216
 						}
190 217
 					}
@@ -195,20 +222,24 @@  discard block
 block discarded – undo
195 222
 		}
196 223
 
197 224
 		// Check for limit
198
-		if($this->export_limit && $this->num_of_records >= $this->export_limit) {
225
+		if($this->export_limit && $this->num_of_records >= $this->export_limit)
226
+		{
199 227
 			return;
200 228
 		}
201 229
 		
202 230
 		// do conversions
203
-		if ( !empty( $this->conversion )) {
231
+		if ( !empty( $this->conversion ))
232
+		{
204 233
 			$this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion );
205 234
 		}
206 235
 		
207 236
 		// do fieldmapping
208
-		if ( !empty( $this->mapping ) ) {
237
+		if ( !empty( $this->mapping ) )
238
+		{
209 239
 			$record_data = $this->record_array;
210 240
 			$this->record_array = array();
211
-			foreach ($this->mapping as $egw_field => $csv_field) {
241
+			foreach ($this->mapping as $egw_field => $csv_field)
242
+			{
212 243
 				$this->record_array[$csv_field] = $record_data[$egw_field];
213 244
 			}
214 245
 		}
@@ -222,7 +253,8 @@  discard block
 block discarded – undo
222 253
 	 *
223 254
 	 * @return int
224 255
 	 */
225
-	public function get_num_of_records() {
256
+	public function get_num_of_records()
257
+	{
226 258
 		return $this->num_of_records;
227 259
 	}
228 260
 
@@ -236,14 +268,20 @@  discard block
 block discarded – undo
236 268
 	 *
237 269
 	 * @return Array of fields to be added to list of fields needing conversion
238 270
 	 */
239
-	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) {
240
-		if(!$appname) return;
271
+	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array())
272
+	{
273
+		if(!$appname)
274
+		{
275
+			return;
276
+		}
241 277
 
242 278
 		$fields = array();
243 279
 		$custom = Api\Storage\Customfields::get($appname);
244
-		foreach($custom as $name => $c_field) {
280
+		foreach($custom as $name => $c_field)
281
+		{
245 282
 			$name = '#' . $name;
246
-			switch($c_field['type']) {
283
+			switch($c_field['type'])
284
+			{
247 285
 				case 'date':
248 286
 					$fields['date'][] = $name;
249 287
 					break;
@@ -254,7 +292,8 @@  discard block
 block discarded – undo
254 292
 					$fields['select-account'][] = $name;
255 293
 					break;
256 294
 				case 'ajax_select':
257
-					if($c_field['values']['get_title']) {
295
+					if($c_field['values']['get_title'])
296
+					{
258 297
 						$methods[$name] = $c_field['values']['get_title'];
259 298
 						break;
260 299
 					}
@@ -269,7 +308,8 @@  discard block
 block discarded – undo
269 308
 					break;
270 309
 				default:
271 310
 					list($type) = explode('-',$c_field['type'],2);
272
-					if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
311
+					if(in_array($type, array_keys($GLOBALS['egw_info']['apps'])))
312
+					{
273 313
 						$fields['links'][] = $name;
274 314
 						$links[$name] = $c_field['type'];
275 315
 					}
@@ -288,9 +328,12 @@  discard block
 block discarded – undo
288 328
 	 * @parem fields List of field types => field names to be converted
289 329
 	 * @param appname Current appname if you want to do custom fields too
290 330
 	 */
291
-	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) {
292
-		if($appname) {
293
-			if(!self::$cf_parse_cache[$appname]) {
331
+	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array())
332
+	{
333
+		if($appname)
334
+		{
335
+			if(!self::$cf_parse_cache[$appname])
336
+			{
294 337
 				$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
295 338
 				self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
296 339
 			}
@@ -299,7 +342,10 @@  discard block
 block discarded – undo
299 342
 			// Add in any fields that are keys to another app
300 343
 			foreach((array)$fields['links'] as $link_field => $app)
301 344
 			{
302
-				if(is_numeric($link_field)) continue;
345
+				if(is_numeric($link_field))
346
+				{
347
+					continue;
348
+				}
303 349
 				$links[$link_field] = $app;
304 350
 				// Set it as a normal link field
305 351
 				$fields['links'][] = $link_field;
@@ -307,8 +353,10 @@  discard block
 block discarded – undo
307 353
 			}
308 354
 
309 355
 			// Not quite a recursive merge, since only one level
310
-			foreach($fields as $type => &$list) {
311
-				if($c_fields[$type]) {
356
+			foreach($fields as $type => &$list)
357
+			{
358
+				if($c_fields[$type])
359
+				{
312 360
 					$list = array_merge($c_fields[$type], $list);
313 361
 					unset($c_fields[$type]);
314 362
 				}
@@ -316,16 +364,22 @@  discard block
 block discarded – undo
316 364
 			$fields += $c_fields;
317 365
 			$selects += $c_selects;
318 366
 		}
319
-		foreach((array)$fields['select'] as $name) {
320
-			if($record->$name != null && is_array($selects) && $selects[$name]) {
367
+		foreach((array)$fields['select'] as $name)
368
+		{
369
+			if($record->$name != null && is_array($selects) && $selects[$name])
370
+			{
321 371
 				$record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name;
322
-				if(is_array($record->$name)) {
372
+				if(is_array($record->$name))
373
+				{
323 374
 					$names = array();
324
-					foreach($record->$name as $_name) {
375
+					foreach($record->$name as $_name)
376
+					{
325 377
 						$names[] = lang($selects[$name][$_name]);
326 378
 					}
327 379
 					$record->$name = implode(', ', $names);
328
-				} else {
380
+				}
381
+				else
382
+				{
329 383
 					$record->$name = lang($selects[$name][$record->$name]);
330 384
 				}
331 385
 			}
@@ -334,9 +388,12 @@  discard block
 block discarded – undo
334 388
 				$record->$name = '';
335 389
 			}
336 390
 		}
337
-		foreach((array)$fields['links'] as $name) {
338
-			if($record->$name) {
339
-				if(is_numeric($record->$name) && !$links[$name]) {
391
+		foreach((array)$fields['links'] as $name)
392
+		{
393
+			if($record->$name)
394
+			{
395
+				if(is_numeric($record->$name) && !$links[$name])
396
+				{
340 397
 					$link = Link::get_link($record->$name);
341 398
 					$links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']);
342 399
 					$record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']);
@@ -355,16 +412,22 @@  discard block
 block discarded – undo
355 412
 				$record->$name = '';
356 413
 			}
357 414
 		}
358
-		foreach((array)$fields['select-account'] as $name) {
415
+		foreach((array)$fields['select-account'] as $name)
416
+		{
359 417
 			// Compare against null to deal with empty arrays
360
-			if ($record->$name !== null) {
361
-				if(is_array($record->$name)) {
418
+			if ($record->$name !== null)
419
+			{
420
+				if(is_array($record->$name))
421
+				{
362 422
 					$names = array();
363
-					foreach($record->$name as $_name) {
423
+					foreach($record->$name as $_name)
424
+					{
364 425
 						$names[] = Api\Accounts::username($_name);
365 426
 					}
366 427
 					$record->$name = implode(', ', $names);
367
-				} else {
428
+				}
429
+				else
430
+				{
368 431
 					$record->$name = Api\Accounts::username($record->$name);
369 432
 				}
370 433
 			}
@@ -373,23 +436,49 @@  discard block
 block discarded – undo
373 436
 				$record->$name = '';
374 437
 			}
375 438
 		}
376
-		foreach((array)$fields['select-bool'] as $name) {
377
-			if($record->$name !== null) {
439
+		foreach((array)$fields['select-bool'] as $name)
440
+		{
441
+			if($record->$name !== null)
442
+			{
378 443
 				$record->$name = $record->$name ? lang('Yes') : lang('No');
379 444
 			}
380 445
 		}
381
-		foreach((array)$fields['date-time'] as $name) {
446
+		foreach((array)$fields['date-time'] as $name)
447
+		{
382 448
 			//if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format
383
-			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
384
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
385
-				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format
386
-			if (!$record->$name) $record->$name = '';
449
+			if ($record->$name && !is_numeric($record->$name))
450
+			{
451
+				$record->$name = strtotime($record->$name);
452
+			}
453
+			// Custom fields stored as string
454
+			if ($record->$name && is_numeric($record->$name))
455
+			{
456
+				$record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
457
+				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name);
458
+			}
459
+			// User date format
460
+			if (!$record->$name)
461
+			{
462
+				$record->$name = '';
463
+			}
387 464
 		}
388
-		foreach((array)$fields['date'] as $name) {
465
+		foreach((array)$fields['date'] as $name)
466
+		{
389 467
 			//if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format
390
-			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
391
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format
392
-			if (!$record->$name) $record->$name = '';
468
+			if ($record->$name && !is_numeric($record->$name))
469
+			{
470
+				$record->$name = strtotime($record->$name);
471
+			}
472
+			// Custom fields stored as string
473
+			if ($record->$name && is_numeric($record->$name))
474
+			{
475
+				$record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name);
476
+			}
477
+			// User date format
478
+			if (!$record->$name)
479
+			{
480
+				$record->$name = '';
481
+			}
393 482
 		}
394 483
 		foreach((array)$fields['float'] as $name)
395 484
 		{
@@ -397,7 +486,10 @@  discard block
 block discarded – undo
397 486
 			if (is_null($dec_separator))
398 487
 			{
399 488
 				$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
400
-				if (empty($dec_separator)) $dec_separator = '.';
489
+				if (empty($dec_separator))
490
+				{
491
+					$dec_separator = '.';
492
+				}
401 493
 				$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
402 494
 			}
403 495
 			if($record->$name && (string)$record->$name != '')
@@ -413,17 +505,27 @@  discard block
 block discarded – undo
413 505
 		}
414 506
 
415 507
 		// Some custom methods for conversion
416
-		foreach((array)$methods as $name => $method) {
417
-			if($record->$name) $record->$name = ExecMethod($method, $record->$name);
508
+		foreach((array)$methods as $name => $method)
509
+		{
510
+			if($record->$name)
511
+			{
512
+				$record->$name = ExecMethod($method, $record->$name);
513
+			}
418 514
 		}
419 515
 
420 516
 		static $cat_object;
421
-		if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname);
422
-		foreach((array)$fields['select-cat'] as $name) {
423
-			if($record->$name) {
517
+		if(is_null($cat_object))
518
+		{
519
+			$cat_object = new Api\Categories(false,$appname);
520
+		}
521
+		foreach((array)$fields['select-cat'] as $name)
522
+		{
523
+			if($record->$name)
524
+			{
424 525
 				$cats = array();
425 526
 				$ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name);
426
-				foreach($ids as $n => $cat_id) {
527
+				foreach($ids as $n => $cat_id)
528
+				{
427 529
 
428 530
 					if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id))
429 531
 					{
@@ -444,7 +546,8 @@  discard block
 block discarded – undo
444 546
 	 *
445 547
 	 * @return
446 548
 	 */
447
-	public function __destruct() {
549
+	public function __destruct()
550
+	{
448 551
 		
449 552
 	}
450 553
 
@@ -457,11 +560,16 @@  discard block
 block discarded – undo
457 560
 	 * @param char $delimiter
458 561
 	 * @param char $enclosure
459 562
 	 */
460
-	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){
563
+	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure)
564
+	{
461 565
 		$string = "";
462 566
 		$writeDelimiter = false;
463
-		foreach($dataArray as $dataElement) {
464
-			if($writeDelimiter) $string .= $delimiter;
567
+		foreach($dataArray as $dataElement)
568
+		{
569
+			if($writeDelimiter)
570
+			{
571
+				$string .= $delimiter;
572
+			}
465 573
 			$string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure;
466 574
 			$writeDelimiter = true;
467 575
 		}
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 	 * @param array _options options for specific backends
99 99
 	 * @return bool
100 100
 	 */
101
-	public function __construct( $_stream, array $_options ) {
101
+	public function __construct($_stream, array $_options) {
102 102
 		if (!is_object($GLOBALS['egw']->translation)) {
103 103
 			$GLOBALS['egw']->translation = new Api\Translation();
104 104
 		}
105 105
 		$this->translation = &$GLOBALS['egw']->translation;
106 106
 		$this->handle = $_stream;
107
-		if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
107
+		if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
108 108
 		$this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8';
109
-		if ( !empty( $_options ) ) {
110
-			$this->csv_options = array_merge( $this->csv_options, $_options );
109
+		if (!empty($_options)) {
110
+			$this->csv_options = array_merge($this->csv_options, $_options);
111 111
 		}
112 112
 		//error_log(__METHOD__.__LINE__.array2string($_options['appname']));
113
-		if(!Api\Storage\Merge::is_export_limit_excepted()) {
113
+		if (!Api\Storage\Merge::is_export_limit_excepted()) {
114 114
 			$this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']);
115 115
 			//error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit);
116
-			if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled');
116
+			if ($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled');
117 117
 		}
118 118
 	}
119 119
 	
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param array $_mapping egw_field_name => csv_field_name
124 124
 	 */
125
-	public function set_mapping( array &$_mapping) {
125
+	public function set_mapping(array &$_mapping) {
126 126
 		if ($this->num_of_records > 0) {
127 127
 			throw new Exception('Error: Field mapping can\'t be set during ongoing export!');
128 128
 		}
129
-		if($_mapping['all_custom_fields']) {
129
+		if ($_mapping['all_custom_fields']) {
130 130
 			// Field value is the appname, so we can pull the fields
131 131
 			$custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']);
132 132
 			unset($_mapping['all_custom_fields']);
133
-			foreach($custom as $field => $info) {
133
+			foreach ($custom as $field => $info) {
134 134
 				$_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field;
135 135
 			}
136 136
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @param array $_conversion
145 145
 	 */
146
-	public function set_conversion( array $_conversion) {
146
+	public function set_conversion(array $_conversion) {
147 147
 		$this->conversion = $_conversion;
148 148
 	}
149 149
 	
@@ -153,59 +153,59 @@  discard block
 block discarded – undo
153 153
 	 * @param importexport_iface_egw_record record
154 154
 	 * @return bool
155 155
 	 */
156
-	public function export_record( importexport_iface_egw_record $_record ) {
156
+	public function export_record(importexport_iface_egw_record $_record) {
157 157
 		$this->record = $_record;
158 158
 		$this->record_array = $_record->get_record_array();
159 159
 		
160 160
 		// begin with fieldnames ?
161
-		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) {
162
-			if($this->csv_options['begin_with_fieldnames'] == 'label') {
161
+		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames']) {
162
+			if ($this->csv_options['begin_with_fieldnames'] == 'label') {
163 163
 				// Load translations for app
164 164
 				list($appname, $part2) = explode('_', get_class($_record));
165
-				if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
165
+				if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
166 166
 
167 167
 				// Get translations from wizard, if possible
168
-				if(!$this->csv_options['no_header_translation'])
168
+				if (!$this->csv_options['no_header_translation'])
169 169
 				{
170 170
 					$backtrace = debug_backtrace();
171 171
 					$plugin = $backtrace[1]['class'];
172
-					$wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin);
172
+					$wizard_name = $appname.'_wizard_'.str_replace($appname.'_', '', $plugin);
173 173
 					try {
174 174
 						$wizard = new $wizard_name;
175 175
 						$fields = $wizard->get_export_fields();
176
-						foreach($this->mapping as $field => &$label)
176
+						foreach ($this->mapping as $field => &$label)
177 177
 						{
178
-							if($fields[$field])
178
+							if ($fields[$field])
179 179
 							{
180 180
 								$label = $label != $fields[$field] ? $fields[$field] : lang($label);
181 181
 							}
182 182
 							// Make sure no *
183
-							if(substr($label,-1) == '*') $label = substr($label,0,-1);
183
+							if (substr($label, -1) == '*') $label = substr($label, 0, -1);
184 184
 						}
185 185
 					} catch (Exception $e) {
186 186
 						Api\Translation::add_app($appname);
187
-						foreach($this->mapping as $field => &$label) {
187
+						foreach ($this->mapping as $field => &$label) {
188 188
 							$label = lang($label);
189 189
 						}
190 190
 					}
191 191
 				}
192 192
 			}
193
-			$mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record_array );
194
-			self::fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] );
193
+			$mapping = !empty($this->mapping) ? $this->mapping : array_keys($this->record_array);
194
+			self::fputcsv($this->handle, $mapping, $this->csv_options['delimiter'], $this->csv_options['enclosure']);
195 195
 		}
196 196
 
197 197
 		// Check for limit
198
-		if($this->export_limit && $this->num_of_records >= $this->export_limit) {
198
+		if ($this->export_limit && $this->num_of_records >= $this->export_limit) {
199 199
 			return;
200 200
 		}
201 201
 		
202 202
 		// do conversions
203
-		if ( !empty( $this->conversion )) {
204
-			$this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion );
203
+		if (!empty($this->conversion)) {
204
+			$this->record_array = importexport_helper_functions::conversion($this->record_array, $this->conversion);
205 205
 		}
206 206
 		
207 207
 		// do fieldmapping
208
-		if ( !empty( $this->mapping ) ) {
208
+		if (!empty($this->mapping)) {
209 209
 			$record_data = $this->record_array;
210 210
 			$this->record_array = array();
211 211
 			foreach ($this->mapping as $egw_field => $csv_field) {
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 			}
214 214
 		}
215 215
 		
216
-		self::fputcsv( $this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure'] );
216
+		self::fputcsv($this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure']);
217 217
 		$this->num_of_records++;
218 218
 	}
219 219
 
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 	 * @return Array of fields to be added to list of fields needing conversion
238 238
 	 */
239 239
 	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) {
240
-		if(!$appname) return;
240
+		if (!$appname) return;
241 241
 
242 242
 		$fields = array();
243 243
 		$custom = Api\Storage\Customfields::get($appname);
244
-		foreach($custom as $name => $c_field) {
245
-			$name = '#' . $name;
246
-			switch($c_field['type']) {
244
+		foreach ($custom as $name => $c_field) {
245
+			$name = '#'.$name;
246
+			switch ($c_field['type']) {
247 247
 				case 'date':
248 248
 					$fields['date'][] = $name;
249 249
 					break;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 					$fields['select-account'][] = $name;
255 255
 					break;
256 256
 				case 'ajax_select':
257
-					if($c_field['values']['get_title']) {
257
+					if ($c_field['values']['get_title']) {
258 258
 						$methods[$name] = $c_field['values']['get_title'];
259 259
 						break;
260 260
 					}
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 					$selects[$name] = $c_field['values'];
269 269
 					break;
270 270
 				default:
271
-					list($type) = explode('-',$c_field['type'],2);
272
-					if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
271
+					list($type) = explode('-', $c_field['type'], 2);
272
+					if (in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
273 273
 						$fields['links'][] = $name;
274 274
 						$links[$name] = $c_field['type'];
275 275
 					}
@@ -289,17 +289,17 @@  discard block
 block discarded – undo
289 289
 	 * @param appname Current appname if you want to do custom fields too
290 290
 	 */
291 291
 	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) {
292
-		if($appname) {
293
-			if(!self::$cf_parse_cache[$appname]) {
292
+		if ($appname) {
293
+			if (!self::$cf_parse_cache[$appname]) {
294 294
 				$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
295 295
 				self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
296 296
 			}
297 297
 			list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname];
298 298
 
299 299
 			// Add in any fields that are keys to another app
300
-			foreach((array)$fields['links'] as $link_field => $app)
300
+			foreach ((array)$fields['links'] as $link_field => $app)
301 301
 			{
302
-				if(is_numeric($link_field)) continue;
302
+				if (is_numeric($link_field)) continue;
303 303
 				$links[$link_field] = $app;
304 304
 				// Set it as a normal link field
305 305
 				$fields['links'][] = $link_field;
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 			}
308 308
 
309 309
 			// Not quite a recursive merge, since only one level
310
-			foreach($fields as $type => &$list) {
311
-				if($c_fields[$type]) {
310
+			foreach ($fields as $type => &$list) {
311
+				if ($c_fields[$type]) {
312 312
 					$list = array_merge($c_fields[$type], $list);
313 313
 					unset($c_fields[$type]);
314 314
 				}
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 			$fields += $c_fields;
317 317
 			$selects += $c_selects;
318 318
 		}
319
-		foreach((array)$fields['select'] as $name) {
320
-			if($record->$name != null && is_array($selects) && $selects[$name]) {
319
+		foreach ((array)$fields['select'] as $name) {
320
+			if ($record->$name != null && is_array($selects) && $selects[$name]) {
321 321
 				$record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name;
322
-				if(is_array($record->$name)) {
322
+				if (is_array($record->$name)) {
323 323
 					$names = array();
324
-					foreach($record->$name as $_name) {
324
+					foreach ($record->$name as $_name) {
325 325
 						$names[] = lang($selects[$name][$_name]);
326 326
 					}
327 327
 					$record->$name = implode(', ', $names);
@@ -334,18 +334,18 @@  discard block
 block discarded – undo
334 334
 				$record->$name = '';
335 335
 			}
336 336
 		}
337
-		foreach((array)$fields['links'] as $name) {
338
-			if($record->$name) {
339
-				if(is_numeric($record->$name) && !$links[$name]) {
337
+		foreach ((array)$fields['links'] as $name) {
338
+			if ($record->$name) {
339
+				if (is_numeric($record->$name) && !$links[$name]) {
340 340
 					$link = Link::get_link($record->$name);
341 341
 					$links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']);
342 342
 					$record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']);
343 343
 				}
344
-				if($links[$name])
344
+				if ($links[$name])
345 345
 				{
346 346
 					$record->$name = Link::title($links[$name], $record->$name);
347 347
 				}
348
-				else if ( is_array($record->$name) && $record->$name['app'] && $record->$name['id'])
348
+				else if (is_array($record->$name) && $record->$name['app'] && $record->$name['id'])
349 349
 				{
350 350
 					$record->$name = Link::title($record->$name['app'], $record->$name['id']);
351 351
 				}
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
 				$record->$name = '';
356 356
 			}
357 357
 		}
358
-		foreach((array)$fields['select-account'] as $name) {
358
+		foreach ((array)$fields['select-account'] as $name) {
359 359
 			// Compare against null to deal with empty arrays
360 360
 			if ($record->$name !== null) {
361
-				if(is_array($record->$name)) {
361
+				if (is_array($record->$name)) {
362 362
 					$names = array();
363
-					foreach($record->$name as $_name) {
363
+					foreach ($record->$name as $_name) {
364 364
 						$names[] = Api\Accounts::username($_name);
365 365
 					}
366 366
 					$record->$name = implode(', ', $names);
@@ -373,64 +373,64 @@  discard block
 block discarded – undo
373 373
 				$record->$name = '';
374 374
 			}
375 375
 		}
376
-		foreach((array)$fields['select-bool'] as $name) {
377
-			if($record->$name !== null) {
376
+		foreach ((array)$fields['select-bool'] as $name) {
377
+			if ($record->$name !== null) {
378 378
 				$record->$name = $record->$name ? lang('Yes') : lang('No');
379 379
 			}
380 380
 		}
381
-		foreach((array)$fields['date-time'] as $name) {
381
+		foreach ((array)$fields['date-time'] as $name) {
382 382
 			//if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format
383 383
 			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
384
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
385
-				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format
384
+			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '.
385
+				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'), $record->$name); // User date format
386 386
 			if (!$record->$name) $record->$name = '';
387 387
 		}
388
-		foreach((array)$fields['date'] as $name) {
388
+		foreach ((array)$fields['date'] as $name) {
389 389
 			//if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format
390 390
 			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
391 391
 			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format
392 392
 			if (!$record->$name) $record->$name = '';
393 393
 		}
394
-		foreach((array)$fields['float'] as $name)
394
+		foreach ((array)$fields['float'] as $name)
395 395
 		{
396
-			static $dec_separator,$thousands_separator;
396
+			static $dec_separator, $thousands_separator;
397 397
 			if (is_null($dec_separator))
398 398
 			{
399 399
 				$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
400 400
 				if (empty($dec_separator)) $dec_separator = '.';
401 401
 				$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
402 402
 			}
403
-			if($record->$name && (string)$record->$name != '')
403
+			if ($record->$name && (string)$record->$name != '')
404 404
 			{
405
-				if(!is_numeric($record->$name))
405
+				if (!is_numeric($record->$name))
406 406
 				{
407 407
 					$record->$name = floatval(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator).']/', '', $record->$name)));
408 408
 				}
409
-				$record->$name = number_format(str_replace(' ','',$record->$name), 2,
410
-					$dec_separator,$thousands_separator
409
+				$record->$name = number_format(str_replace(' ', '', $record->$name), 2,
410
+					$dec_separator, $thousands_separator
411 411
 				);
412 412
 			}
413 413
 		}
414 414
 
415 415
 		// Some custom methods for conversion
416
-		foreach((array)$methods as $name => $method) {
417
-			if($record->$name) $record->$name = ExecMethod($method, $record->$name);
416
+		foreach ((array)$methods as $name => $method) {
417
+			if ($record->$name) $record->$name = ExecMethod($method, $record->$name);
418 418
 		}
419 419
 
420 420
 		static $cat_object;
421
-		if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname);
422
-		foreach((array)$fields['select-cat'] as $name) {
423
-			if($record->$name) {
421
+		if (is_null($cat_object)) $cat_object = new Api\Categories(false, $appname);
422
+		foreach ((array)$fields['select-cat'] as $name) {
423
+			if ($record->$name) {
424 424
 				$cats = array();
425 425
 				$ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name);
426
-				foreach($ids as $n => $cat_id) {
426
+				foreach ($ids as $n => $cat_id) {
427 427
 
428
-					if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id))
428
+					if ($cat_id && $cat_object->check_perms(Acl::READ, $cat_id))
429 429
 					{
430 430
 						$cats[] = $cat_object->id2name($cat_id);
431 431
 					}
432 432
 				}
433
-				$record->$name = implode(', ',$cats);
433
+				$record->$name = implode(', ', $cats);
434 434
 			}
435 435
 			else
436 436
 			{
@@ -457,18 +457,18 @@  discard block
 block discarded – undo
457 457
 	 * @param char $delimiter
458 458
 	 * @param char $enclosure
459 459
 	 */
460
-	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){
460
+	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) {
461 461
 		$string = "";
462 462
 		$writeDelimiter = false;
463
-		foreach($dataArray as $dataElement) {
464
-			if($writeDelimiter) $string .= $delimiter;
465
-			$string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure;
463
+		foreach ($dataArray as $dataElement) {
464
+			if ($writeDelimiter) $string .= $delimiter;
465
+			$string .= $enclosure.str_replace(array("\r\n", '"'), array("\n", '""'), $dataElement).$enclosure;
466 466
 			$writeDelimiter = true;
467 467
 		}
468 468
 		$string .= "\n";
469 469
 		
470 470
 		// do charset translation
471
-		$string = $this->translation->convert( $string, $this->translation->charset(), $this->csv_charset );
471
+		$string = $this->translation->convert($string, $this->translation->charset(), $this->csv_charset);
472 472
 		
473 473
 		fwrite($filePointer, $string);
474 474
 			
Please login to merge, or discard this patch.
importexport/inc/class.importexport_helper_functions.inc.php 5 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	/**
124 124
 	 * converts accound_lid to account_id
125 125
 	 *
126
-	 * @param mixed $_account_lid comma seperated list or array with lids
126
+	 * @param mixed $_account_lids comma seperated list or array with lids
127 127
 	 * @return mixed comma seperated list or array with ids
128 128
 	 */
129 129
 	public static function account_name2id( &$_account_lids ) {
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	/**
204 204
 	 * converts account_ids to account_lids
205 205
 	 *
206
-	 * @param mixed $_account_ids comma seperated list or array with ids
206
+	 * @param mixed $_account_id comma seperated list or array with ids
207 207
 	 * @return mixed comma seperated list or array with lids
208 208
 	 */
209 209
 	public static function account_id2name( $_account_id ) {
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	/**
420 420
 	 * returns a list of importexport plugins
421 421
 	 *
422
-	 * @param string $_tpye {import | export | all}
422
+	 * @param string $_type {import | export | all}
423 423
 	 * @param string $_appname {<appname> | all}
424 424
 	 * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
425 425
 	 */
@@ -591,6 +591,7 @@  discard block
 block discarded – undo
591 591
 	 *
592 592
 	 * @param $app_name String name of app
593 593
 	 * @param $plugin_name Name of the plugin
594
+	 * @param importexport_wizard_basic_export_csv $wizard_plugin
594 595
 	 *
595 596
 	 * @return Array ([fieldname] => array(widget settings), ...)
596 597
 	 */
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@  discard block
 block discarded – undo
32 32
 	 * Relative date ranges for filtering
33 33
 	 */
34 34
 	public static $relative_dates = array(      // Start: year,month,day,week, End: year,month,day,week
35
-                'Today'       => array(0,0,0,0,  0,0,1,0),
36
-                'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
-                'This week'   => array(0,0,0,0,  0,0,0,1),
38
-                'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
-                'This month'  => array(0,0,0,0,  0,1,0,0),
40
-                'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
-                'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
-                'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
-                'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
-                'This year'   => array(0,0,0,0,  1,0,0,0),
45
-                'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
-                '2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
-                '3 years ago' => array(-3,0,0,0, -2,0,0,0),
48
-        );
35
+				'Today'       => array(0,0,0,0,  0,0,1,0),
36
+				'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
+				'This week'   => array(0,0,0,0,  0,0,0,1),
38
+				'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
+				'This month'  => array(0,0,0,0,  0,1,0,0),
40
+				'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
+				'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
+				'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
+				'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
+				'This year'   => array(0,0,0,0,  1,0,0,0),
45
+				'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
+				'2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
+				'3 years ago' => array(-3,0,0,0, -2,0,0,0),
48
+		);
49 49
 
50 50
 	/**
51
-	* Files known to cause problems, and will be skipped in a plugin scan
52
-	* If you put appname => true, the whole app will be skipped.
53
-	*/
51
+	 * Files known to cause problems, and will be skipped in a plugin scan
52
+	 * If you put appname => true, the whole app will be skipped.
53
+	 */
54 54
 	protected static $blacklist_files = array(
55 55
 		'api' => true,
56 56
 		'etemplate' => true,
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	);
65 65
 
66 66
 	/**
67
-	* Class used to provide extra conversion functions
68
-	*
69
-	* Passed in as a param to conversion()
70
-	*/
67
+	 * Class used to provide extra conversion functions
68
+	 *
69
+	 * Passed in as a param to conversion()
70
+	 */
71 71
 	protected static $cclass = null;
72 72
 
73 73
 	/**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		return $plugins;
446 446
 	}
447 447
 
448
-	public static function _get_plugins(Array $appnames, Array $types) {
448
+	public static function _get_plugins(array $appnames, array $types) {
449 449
 		$plugins = array();
450 450
 		foreach ($appnames as $appname) {
451 451
 			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	}
563 563
 
564 564
 	// Api\Cache needs this public
565
-	public static function _has_definitions(Array $appnames, Array $types) {
565
+	public static function _has_definitions(array $appnames, array $types) {
566 566
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
567 567
 		$list = array();
568 568
 		foreach((array)$def->get_definitions() as $id) {
Please login to merge, or discard this patch.
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
 	 * Relative date ranges for filtering
33 33
 	 */
34 34
 	public static $relative_dates = array(      // Start: year,month,day,week, End: year,month,day,week
35
-                'Today'       => array(0,0,0,0,  0,0,1,0),
36
-                'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
37
-                'This week'   => array(0,0,0,0,  0,0,0,1),
38
-                'Last week'   => array(0,0,0,-1, 0,0,0,0),
39
-                'This month'  => array(0,0,0,0,  0,1,0,0),
40
-                'Last month'  => array(0,-1,0,0, 0,0,0,0),
41
-                'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
42
-                'This quarter'=> array(0,0,0,0,  0,0,0,0),      // Just a marker, needs special handling
43
-                'Last quarter'=> array(0,-4,0,0, 0,-4,0,0),     // Just a marker
44
-                'This year'   => array(0,0,0,0,  1,0,0,0),
45
-                'Last year'   => array(-1,0,0,0, 0,0,0,0),
46
-                '2 years ago' => array(-2,0,0,0, -1,0,0,0),
47
-                '3 years ago' => array(-3,0,0,0, -2,0,0,0),
35
+                'Today'       => array(0, 0, 0, 0, 0, 0, 1, 0),
36
+                'Yesterday'   => array(0, 0, -1, 0, 0, 0, 0, 0),
37
+                'This week'   => array(0, 0, 0, 0, 0, 0, 0, 1),
38
+                'Last week'   => array(0, 0, 0, -1, 0, 0, 0, 0),
39
+                'This month'  => array(0, 0, 0, 0, 0, 1, 0, 0),
40
+                'Last month'  => array(0, -1, 0, 0, 0, 0, 0, 0),
41
+                'Last 3 months' => array(0, -3, 0, 0, 0, 0, 0, 0),
42
+                'This quarter'=> array(0, 0, 0, 0, 0, 0, 0, 0), // Just a marker, needs special handling
43
+                'Last quarter'=> array(0, -4, 0, 0, 0, -4, 0, 0), // Just a marker
44
+                'This year'   => array(0, 0, 0, 0, 1, 0, 0, 0),
45
+                'Last year'   => array(-1, 0, 0, 0, 0, 0, 0, 0),
46
+                '2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0),
47
+                '3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0),
48 48
         );
49 49
 
50 50
 	/**
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 	 * @param string $_format format of time string e.g.: d.m.Y H:i
86 86
 	 * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default
87 87
 	 */
88
-	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) {
89
-		if ( empty( $_format ) ) return strtotime( $_string );
90
-		$fparams = explode( ',', chunk_split( $_format, 1, ',' ) );
88
+	public static function custom_strtotime($_string, $_format = '', $_is_dst = -1) {
89
+		if (empty($_format)) return strtotime($_string);
90
+		$fparams = explode(',', chunk_split($_format, 1, ','));
91 91
 		$spos = 0;
92
-		foreach ( $fparams as $fparam ) {
93
-
94
-			switch ( $fparam ) {
95
-				case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break;
96
-				case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break;
97
-				case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break;
98
-				case 'Y': (int)$year = substr( $_string, $spos, 4 ); $spos += 4; break;
99
-				case 'H': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break;
100
-				case 'h': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break;
101
-				case 'i': (int)$min =  substr( $_string, $spos, 2 ); $spos += 2; break;
102
-				case 's': (int)$sec =  substr( $_string, $spos, 2 ); $spos += 2; break;
103
-				case 'O': (int)$offset = $year = substr( $_string, $spos, 5 ); $spos += 5; break;
92
+		foreach ($fparams as $fparam) {
93
+
94
+			switch ($fparam) {
95
+				case 'd': (int)$day = substr($_string, $spos, 2); $spos += 2; break;
96
+				case 'm': (int)$mon = substr($_string, $spos, 2); $spos += 2; break;
97
+				case 'y': (int)$year = substr($_string, $spos, 2); $spos += 2; break;
98
+				case 'Y': (int)$year = substr($_string, $spos, 4); $spos += 4; break;
99
+				case 'H': (int)$hour = substr($_string, $spos, 2); $spos += 2; break;
100
+				case 'h': (int)$hour = substr($_string, $spos, 2); $spos += 2; break;
101
+				case 'i': (int)$min = substr($_string, $spos, 2); $spos += 2; break;
102
+				case 's': (int)$sec = substr($_string, $spos, 2); $spos += 2; break;
103
+				case 'O': (int)$offset = $year = substr($_string, $spos, 5); $spos += 5; break;
104 104
 				case 'a': (int)$hour = $fparam == 'am' ? $hour : $hour + 12; break;
105 105
 				case 'A': (int)$hour = $fparam == 'AM' ? $hour : $hour + 12; break;
106 106
 				default: $spos++; // seperator
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 		$timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst);
112 112
 
113 113
 		// offset given?
114
-		if ( isset( $offset ) && strlen( $offset == 5 ) ) {
114
+		if (isset($offset) && strlen($offset == 5)) {
115 115
 			$operator = $offset{0};
116
-			$ohour = 60 * 60 * (int)substr( $offset, 1, 2 );
117
-			$omin = 60 * (int)substr( $offset, 3, 2 );
118
-			if ( $operator == '+' ) $timestamp += $ohour + $omin;
116
+			$ohour = 60 * 60 * (int)substr($offset, 1, 2);
117
+			$omin = 60 * (int)substr($offset, 3, 2);
118
+			if ($operator == '+') $timestamp += $ohour + $omin;
119 119
 			else $timestamp -= $ohour + $omin;
120 120
 		}
121 121
 		return $timestamp;
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	 * @param mixed $_account_lid comma seperated list or array with lids
127 127
 	 * @return mixed comma seperated list or array with ids
128 128
 	 */
129
-	public static function account_name2id( &$_account_lids ) {
130
-		$account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids );
129
+	public static function account_name2id(&$_account_lids) {
130
+		$account_lids = is_array($_account_lids) ? $_account_lids : explode(',', $_account_lids);
131 131
 		$skip = false;
132
-		foreach ( $account_lids as $key => $account_lid ) {
133
-			if($skip) {
132
+		foreach ($account_lids as $key => $account_lid) {
133
+			if ($skip) {
134 134
 				unset($account_lids[$key]);
135 135
 				$skip = false;
136 136
 				continue;
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 			$account_lid = trim($account_lid);
139 139
 
140 140
 			// Handle any IDs that slip in
141
-			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
141
+			if (is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
142 142
 				unset($account_lids[$key]);
143 143
 				$account_ids[] = (int)$account_lid;
144 144
 				continue;
145 145
 			}
146 146
 			// Check for [username]
147
-			if(strpos($account_lid,'[') !== false)
147
+			if (strpos($account_lid, '[') !== false)
148 148
 			{
149
-				if(preg_match('/\[(.+)\]/',$account_lid,$matches))
149
+				if (preg_match('/\[(.+)\]/', $account_lid, $matches))
150 150
 				{
151 151
 					$account_id = $GLOBALS['egw']->accounts->name2id($matches[1]);
152 152
 					unset($account_lids[$key]);
@@ -157,59 +157,59 @@  discard block
 block discarded – undo
157 157
 
158 158
 			// Handle users listed as Lastname, Firstname instead of login ID
159 159
 			// Do this first, in case their first name matches a username
160
-			if ( $account_lids[$key+1][0] == ' ')
160
+			if ($account_lids[$key + 1][0] == ' ')
161 161
 			{
162 162
 				$query = array('type' => 'accounts', 'query_type' => 'exact');
163
-				$given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key+1])));
163
+				$given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key + 1])));
164 164
 				$family = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lid)));
165 165
 				$ids = array_intersect_key($family, $given);
166
-				if($ids)
166
+				if ($ids)
167 167
 				{
168 168
 					$account_ids[] = key($ids);
169 169
 					unset($account_lids[$key]);
170 170
 					$skip = true; // Skip the next one, it's the first name
171
-					continue ;
171
+					continue;
172 172
 				}
173 173
 			}
174 174
 
175 175
 			// Deal with groups listed as <name> Group, remove the Group
176
-			if(substr(trim($account_lid),-strlen(lang('Group'))) == lang('Group'))
176
+			if (substr(trim($account_lid), -strlen(lang('Group'))) == lang('Group'))
177 177
 			{
178 178
 				$account_lid = trim(substr(trim($account_lid), 0, -strlen(lang('Group'))));
179 179
 			}
180 180
 			// Group <name> (no comma)
181
-			else if(strpos($account_lid, lang('Group')) === 0)
181
+			else if (strpos($account_lid, lang('Group')) === 0)
182 182
 			{
183 183
 				$account_lid = trim(substr(trim($account_lid), strlen(lang('Group'))));
184 184
 			}
185 185
 
186
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) {
186
+			if ($account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) {
187 187
 				$account_ids[] = $account_id;
188 188
 				unset($account_lids[$key]);
189 189
 				continue;
190 190
 			}
191
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) {
191
+			if ($account_id = $GLOBALS['egw']->accounts->name2id(trim($account_lid), 'account_fullname')) {
192 192
 				$account_ids[] = $account_id;
193 193
 				unset($account_lids[$key]);
194 194
 				continue;
195 195
 			}
196 196
 
197 197
 			// Handle groups listed as Group, <name>
198
-			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) {
198
+			if ($account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) {
199 199
 				$account_ids[] = $account_id;
200
-				unset($account_lids[$key-1]);
200
+				unset($account_lids[$key - 1]);
201 201
 				unset($account_lids[$key]);
202 202
 				continue;
203 203
 			}
204 204
 			// Group, <name> - remove the Group part
205
-			if($account_lid == lang('Group'))
205
+			if ($account_lid == lang('Group'))
206 206
 			{
207 207
 				unset($account_lids[$key]);
208 208
 				continue;
209 209
 			}
210 210
 		}
211
-		$_account_lids = (is_array($_account_lids) ? $account_lids : implode(',',array_unique($account_lids)));
212
-		return is_array( $_account_lids ) ? array_unique($account_ids) : implode( ',', array_unique((array)$account_ids ));
211
+		$_account_lids = (is_array($_account_lids) ? $account_lids : implode(',', array_unique($account_lids)));
212
+		return is_array($_account_lids) ? array_unique($account_ids) : implode(',', array_unique((array)$account_ids));
213 213
 
214 214
 	} // end of member function account_lid2id
215 215
 
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 	 * @param mixed $_account_ids comma seperated list or array with ids
220 220
 	 * @return mixed comma seperated list or array with lids
221 221
 	 */
222
-	public static function account_id2name( $_account_id ) {
223
-		$account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id );
224
-		foreach ( $account_ids as $account_id ) {
225
-			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) {
222
+	public static function account_id2name($_account_id) {
223
+		$account_ids = is_array($_account_id) ? $_account_id : explode(',', $_account_id);
224
+		foreach ($account_ids as $account_id) {
225
+			if ($account_lid = $GLOBALS['egw']->accounts->id2name($account_id)) {
226 226
 				$account_lids[] = $account_lid;
227 227
 			}
228 228
 		}
229
-		return is_array( $_account_id ) ? $account_lids : implode( ',', (array)$account_lids );
229
+		return is_array($_account_id) ? $account_lids : implode(',', (array)$account_lids);
230 230
 	} // end of member function account_id2lid
231 231
 
232 232
 	/**
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 * @param mixed _cat_ids comma seperated list or array
236 236
 	 * @return mixed comma seperated list or array with cat_names
237 237
 	 */
238
-	public static function cat_id2name( $_cat_ids ) {
239
-		$cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
240
-		foreach ( $cat_ids as $cat_id ) {
241
-			$cat_names[] = Api\Categories::id2name( (int)$cat_id );
238
+	public static function cat_id2name($_cat_ids) {
239
+		$cat_ids = is_array($_cat_ids) ? $_cat_ids : explode(',', $_cat_ids);
240
+		foreach ($cat_ids as $cat_id) {
241
+			$cat_names[] = Api\Categories::id2name((int)$cat_id);
242 242
 		}
243
-		return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
243
+		return is_array($_cat_ids) ? $cat_names : implode(',', (array)$cat_names);
244 244
 	} // end of member function category_id2name
245 245
 
246 246
 	/**
@@ -251,24 +251,24 @@  discard block
 block discarded – undo
251 251
 	 * @param int $parent Optional parent ID to use for new categories
252 252
 	 * @return mixed comma seperated list or array with cat_ids
253 253
 	 */
254
-	public static function cat_name2id( $_cat_names, $parent = 0 ) {
255
-		$cats = new Api\Categories();	// uses current user and app (egw_info[flags][currentapp])
254
+	public static function cat_name2id($_cat_names, $parent = 0) {
255
+		$cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp])
256 256
 
257
-		$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
258
-		foreach ( $cat_names as $cat_name ) {
257
+		$cat_names = is_array($_cat_names) ? $_cat_names : explode(',', $_cat_names);
258
+		foreach ($cat_names as $cat_name) {
259 259
 			$cat_name = trim($cat_name);
260
-			if ( $cat_name == '' ) continue;
261
-			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) {
262
-				$cat_id = $cats->add( array(
260
+			if ($cat_name == '') continue;
261
+			if (($cat_id = $cats->name2id($cat_name)) == 0 && !self::$dry_run) {
262
+				$cat_id = $cats->add(array(
263 263
 					'name' => $cat_name,
264 264
 					'parent' => $parent,
265 265
 					'access' => 'public',
266
-					'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')'
266
+					'descr' => $cat_name.' ('.lang('Automatically created by importexport').')'
267 267
 				));
268 268
 			}
269 269
 			$cat_ids[] = $cat_id;
270 270
 		}
271
-		return is_array( $_cat_names ) ? $cat_ids : implode( ',', (array)$cat_ids );
271
+		return is_array($_cat_names) ? $cat_ids : implode(',', (array)$cat_ids);
272 272
 
273 273
 	} // end of member function category_name2id
274 274
 
@@ -307,76 +307,76 @@  discard block
 block discarded – undo
307 307
 	 * @param object &$cclass calling class to process the '@ evals'
308 308
 	 * @return bool
309 309
 	 */
310
-	public static function conversion( &$_record,  $_conversion, &$_cclass = null ) {
311
-		if (empty( $_conversion ) ) return $_record;
310
+	public static function conversion(&$_record, $_conversion, &$_cclass = null) {
311
+		if (empty($_conversion)) return $_record;
312 312
 
313
-		self::$cclass =& $_cclass;
313
+		self::$cclass = & $_cclass;
314 314
 
315 315
 		$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion
316 316
 		$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment
317
-		$CPre = '|['; $CPos = ']';  // |[_record-idx] is expanded to the corespondig value
317
+		$CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value
318 318
 		$TPre = '|T{'; $TPos = '}'; // |{_record-idx} is trimmed
319
-		$CntlPre = '|TC{';		    // Filter all cntl-chars \x01-\x1f and trim
320
-		$CntlnCLPre  = '|TCnCL{';   // Like |C{ but allowes CR and LF
321
-		$INE = '|INE{';             // Only insert if stuff in ^^ is not empty
319
+		$CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim
320
+		$CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF
321
+		$INE = '|INE{'; // Only insert if stuff in ^^ is not empty
322 322
 
323
-		foreach ( $_conversion as $idx => $conversion_string ) {
324
-			if ( empty( $conversion_string ) ) continue;
323
+		foreach ($_conversion as $idx => $conversion_string) {
324
+			if (empty($conversion_string)) continue;
325 325
 
326 326
 			// fetch patterns ($rvalues)
327 327
 			$rvalues = array();
328
-			$pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
329
-			foreach( $pat_reps as $k => $pat_rep ) {
330
-				list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
331
-				if( $replace == '' ) {
328
+			$pat_reps = explode($PSep, stripslashes($conversion_string));
329
+			foreach ($pat_reps as $k => $pat_rep) {
330
+				list($pattern, $replace) = explode($ASep, $pat_rep, 2);
331
+				if ($replace == '') {
332 332
 					$replace = $pattern; $pattern = '^.*$';
333 333
 				}
334
-				$rvalues[$pattern] = $replace;	// replace two with only one, added by the form
334
+				$rvalues[$pattern] = $replace; // replace two with only one, added by the form
335 335
 			}
336 336
 
337 337
 			// conversion list may be longer than $_record aka (no_csv)
338
-			$val = array_key_exists( $idx, $_record ) ? $_record[$idx] : '';
338
+			$val = array_key_exists($idx, $_record) ? $_record[$idx] : '';
339 339
 
340 340
 			$c_functions = array('cat', 'account', 'strtotime', 'list');
341
-			if($_cclass) {
341
+			if ($_cclass) {
342 342
 				// Add in additional methods
343 343
 				$reflection = new ReflectionClass(get_class($_cclass));
344 344
 				$methods = $reflection->getMethods(ReflectionMethod::IS_STATIC);
345
-				foreach($methods as $method) {
345
+				foreach ($methods as $method) {
346 346
 					$c_functions[] = $method->name;
347 347
 				}
348 348
 			}
349 349
 			$c_functions = implode('|', $c_functions);
350
-			foreach ( $rvalues as $pattern => $replace ) {
350
+			foreach ($rvalues as $pattern => $replace) {
351 351
 				// Allow to include record indexes in pattern
352 352
 				$reg = '/\|\[([0-9]+)\]/';
353
-				while( preg_match( $reg, $pattern, $vars ) ) {
353
+				while (preg_match($reg, $pattern, $vars)) {
354 354
 					// expand all _record fields
355 355
 					$pattern = str_replace(
356
-						$CPre . $vars[1] . $CPos,
356
+						$CPre.$vars[1].$CPos,
357 357
 						$_record[array_search($vars[1], array_keys($_record))],
358 358
 						$pattern
359 359
 					);
360 360
 				}
361
-				if( preg_match('/'. (string)$pattern.'/', $val) ) {
361
+				if (preg_match('/'.(string)$pattern.'/', $val)) {
362 362
 
363
-					$val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val );
363
+					$val = preg_replace('/'.(string)$pattern.'/', $replace, (string)$val);
364 364
 
365 365
 					$reg = '/\|\[([a-zA-Z_0-9]+)\]/';
366
-					while( preg_match( $reg, $val, $vars ) ) {
366
+					while (preg_match($reg, $val, $vars)) {
367 367
 						// expand all _record fields
368 368
 						$val = str_replace(
369
-							$CPre . $vars[1] . $CPos,
369
+							$CPre.$vars[1].$CPos,
370 370
 							$_record[array_search($vars[1], array_keys($_record))],
371 371
 							$val
372 372
 						);
373 373
 					}
374
-					$val = preg_replace_callback( "/($c_functions)\(([^)]*)\)/i", array( self, 'c2_dispatcher') , $val );
374
+					$val = preg_replace_callback("/($c_functions)\(([^)]*)\)/i", array(self, 'c2_dispatcher'), $val);
375 375
 					break;
376 376
 				}
377 377
 			}
378 378
 			// clean each field
379
-			$val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array( self, 'strclean'), $val );
379
+			$val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array(self, 'strclean'), $val);
380 380
 
381 381
 			$_record[$idx] = $val;
382 382
 		}
@@ -390,42 +390,42 @@  discard block
 block discarded – undo
390 390
 	 *
391 391
 	 * @param array $_matches
392 392
 	 */
393
-	private static function c2_dispatcher( $_matches ) {
393
+	private static function c2_dispatcher($_matches) {
394 394
 		$action = &$_matches[1]; // cat or account ...
395
-		$data = &$_matches[2];   // datas for action
395
+		$data = &$_matches[2]; // datas for action
396 396
 
397
-		switch ( $action ) {
397
+		switch ($action) {
398 398
 			case 'strtotime' :
399
-				list( $string, $format ) = explode( ',', $data );
400
-				return self::custom_strtotime( trim( $string ), trim( $format ) );
399
+				list($string, $format) = explode(',', $data);
400
+				return self::custom_strtotime(trim($string), trim($format));
401 401
 			case 'list':
402
-				list( $split, $data, $index) = explode(',',$data);
402
+				list($split, $data, $index) = explode(',', $data);
403 403
 				$exploded = explode($split, $data);
404 404
 				// 1 based indexing for user ease
405 405
 				return $exploded[$index - 1];
406 406
 			default :
407
-				if(self::$cclass && method_exists(self::$cclass, $action)) {
407
+				if (self::$cclass && method_exists(self::$cclass, $action)) {
408 408
 					$class = get_class(self::$cclass);
409 409
 					return call_user_func("$class::$action", $data);
410 410
 				}
411
-				$method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' );
412
-				if(self::$cclass && method_exists(self::$cclass, $method)) {
411
+				$method = (string)$action.(is_int($data) ? '_id2name' : '_name2id');
412
+				if (self::$cclass && method_exists(self::$cclass, $method)) {
413 413
 					$class = get_class(self::$cclass);
414 414
 					return call_user_func("$class::$action", $data);
415 415
 				} else {
416
-					return self::$method( $data );
416
+					return self::$method($data);
417 417
 				}
418 418
 		}
419 419
 	}
420 420
 
421
-	private static function strclean( $_matches ) {
422
-		switch( $_matches[1] ) {
423
-			case '|T{' : return trim( $_matches[2] );
424
-			case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) );
425
-			case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) );
426
-			case '|INE{' : return preg_match( '/\^.+\^/', $_matches[2] ) ? $_matches[2] : '';
421
+	private static function strclean($_matches) {
422
+		switch ($_matches[1]) {
423
+			case '|T{' : return trim($_matches[2]);
424
+			case '|TC{' : return trim(preg_replace('/[\x01-\x1F]+/', '', $_matches[2]));
425
+			case '|TCnCL{' : return trim(preg_replace('/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2]));
426
+			case '|INE{' : return preg_match('/\^.+\^/', $_matches[2]) ? $_matches[2] : '';
427 427
 			default:
428
-				throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!');
428
+				throw new Exception('Error in conversion string! "'.substr($_matches[1], 0, -1).'" is not valid!');
429 429
 		}
430 430
 	}
431 431
 
@@ -436,23 +436,23 @@  discard block
 block discarded – undo
436 436
 	 * @param string $_appname {<appname> | all}
437 437
 	 * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
438 438
 	 */
439
-	public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
439
+	public static function get_plugins($_appname = 'all', $_type = 'all') {
440 440
 		$plugins = Api\Cache::getTree(
441 441
 			__CLASS__,
442 442
 			'plugins',
443
-			array('importexport_helper_functions','_get_plugins'),
443
+			array('importexport_helper_functions', '_get_plugins'),
444 444
 			array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
445 445
 			self::CACHE_EXPIRATION
446 446
 		);
447 447
 		$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
448
-		$types = $_type == 'all' ? array('import','export') : (array)$_type;
448
+		$types = $_type == 'all' ? array('import', 'export') : (array)$_type;
449 449
 
450 450
 		// Testing: comment out Api\Cache call, use this
451 451
 		//$plugins = self::_get_plugins($appnames, $types);
452
-		foreach($plugins as $appname => $_types) {
453
-			if(!in_array($appname, $appnames)) unset($plugins[$appname]);
452
+		foreach ($plugins as $appname => $_types) {
453
+			if (!in_array($appname, $appnames)) unset($plugins[$appname]);
454 454
 		}
455
-		foreach($plugins as $appname => $types) {
455
+		foreach ($plugins as $appname => $types) {
456 456
 			$plugins[$appname] = array_intersect_key($plugins[$appname], $types);
457 457
 		}
458 458
 		return $plugins;
@@ -461,25 +461,25 @@  discard block
 block discarded – undo
461 461
 	public static function _get_plugins(Array $appnames, Array $types) {
462 462
 		$plugins = array();
463 463
 		foreach ($appnames as $appname) {
464
-			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
464
+			if (array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
465 465
 
466
-			$appdir = EGW_INCLUDE_ROOT. "/$appname/inc";
467
-			if(!is_dir($appdir)) continue;
466
+			$appdir = EGW_INCLUDE_ROOT."/$appname/inc";
467
+			if (!is_dir($appdir)) continue;
468 468
 			$d = dir($appdir);
469 469
 
470 470
 			// step through each file in appdir
471 471
 			while (false !== ($entry = $d->read())) {
472 472
 				// Blacklisted?
473
-				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
473
+				if (is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
474 474
 				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue;
475 475
 				$classname = $matches[1];
476
-				$file = $appdir. '/'. $entry;
476
+				$file = $appdir.'/'.$entry;
477 477
 
478 478
 				foreach ($types as $type) {
479
-					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue;
479
+					if (!is_file($file) || strpos($entry, $type) === false || strpos($entry, 'wizard') !== false) continue;
480 480
 					require_once($file);
481 481
 					$reflectionClass = new ReflectionClass($classname);
482
-					if($reflectionClass->IsInstantiable() &&
482
+					if ($reflectionClass->IsInstantiable() &&
483 483
 							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) {
484 484
 						try {
485 485
 							$plugin_object = new $classname;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 			$d->close();
496 496
 
497 497
 			$config = Api\Config::read('importexport');
498
-			if($config['update'] == 'auto') {
498
+			if ($config['update'] == 'auto') {
499 499
 				self::load_defaults($appname);
500 500
 			}
501 501
 		}
@@ -510,37 +510,37 @@  discard block
 block discarded – undo
510 510
 	 * @return array $num => $appname
511 511
 	 */
512 512
 	public static function get_apps($_type, $ignore_acl = false) {
513
-		$apps = array_keys(self::get_plugins('all',$_type));
514
-		if($ignore_acl) return $apps;
513
+		$apps = array_keys(self::get_plugins('all', $_type));
514
+		if ($ignore_acl) return $apps;
515 515
 
516
-		foreach($apps as $key => $app) {
517
-			if(!self::has_definitions($app, $_type)) unset($apps[$key]);
516
+		foreach ($apps as $key => $app) {
517
+			if (!self::has_definitions($app, $_type)) unset($apps[$key]);
518 518
 		}
519 519
 		return $apps;
520 520
 	}
521 521
 
522 522
 	public static function load_defaults($appname) {
523 523
 		// Check for new definitions to import from $appname/setup/*.xml
524
-		$appdir = EGW_INCLUDE_ROOT. "/$appname/setup";
525
-		if(!is_dir($appdir)) return;
524
+		$appdir = EGW_INCLUDE_ROOT."/$appname/setup";
525
+		if (!is_dir($appdir)) return;
526 526
 		$d = dir($appdir);
527 527
 
528 528
 		// step through each file in app's setup
529 529
 		while (false !== ($entry = $d->read())) {
530
-			$file = $appdir. '/'. $entry;
531
-			list( $filename, $extension) = explode('.',$entry);
532
-			if ( $extension != 'xml' ) continue;
530
+			$file = $appdir.'/'.$entry;
531
+			list($filename, $extension) = explode('.', $entry);
532
+			if ($extension != 'xml') continue;
533 533
 			try {
534 534
 				// import will skip invalid files
535
-				importexport_definitions_bo::import( $file );
535
+				importexport_definitions_bo::import($file);
536 536
 			} catch (Exception $e) {
537
-				error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage());
537
+				error_log(__CLASS__.__FUNCTION__." import $appname definitions: ".$e->getMessage());
538 538
 			}
539 539
 		}
540 540
 		$d->close();
541 541
 	}
542 542
 
543
-	public static function guess_filetype( $_file ) {
543
+	public static function guess_filetype($_file) {
544 544
 
545 545
 	}
546 546
 
@@ -551,24 +551,24 @@  discard block
 block discarded – undo
551 551
 	 * @param string $_type {import | export | all}
552 552
 	 * @return boolean
553 553
 	 */
554
-	public static function has_definitions( $_appname = 'all', $_type = 'all' ) {
554
+	public static function has_definitions($_appname = 'all', $_type = 'all') {
555 555
 		$definitions = Api\Cache::getSession(
556 556
 			__CLASS__,
557 557
 			'has_definitions',
558
-			array('importexport_helper_functions','_has_definitions'),
558
+			array('importexport_helper_functions', '_has_definitions'),
559 559
 			array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
560 560
 			self::CACHE_EXPIRATION
561 561
 		);
562 562
 		$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
563
-		$types = $_type == 'all' ? array('import','export') : (array)$_type;
563
+		$types = $_type == 'all' ? array('import', 'export') : (array)$_type;
564 564
 
565 565
 		// Testing: Comment out cache call above, use this
566 566
 		//$definitions = self::_has_definitions($appnames, $types);
567 567
 
568
-		foreach($definitions as $appname => $_types) {
569
-			if(!in_array($appname, $appnames)) unset($definitions[$appname]);
568
+		foreach ($definitions as $appname => $_types) {
569
+			if (!in_array($appname, $appnames)) unset($definitions[$appname]);
570 570
 		}
571
-		foreach($definitions as $appname => $_types) {
571
+		foreach ($definitions as $appname => $_types) {
572 572
 			$definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types));
573 573
 		}
574 574
 		return !empty($definitions[$appname]);
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
 	public static function _has_definitions(Array $appnames, Array $types) {
579 579
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
580 580
 		$list = array();
581
-		foreach((array)$def->get_definitions() as $id) {
581
+		foreach ((array)$def->get_definitions() as $id) {
582 582
 			// Need to instanciate it to check, but if the user doesn't have permission, it throws an exception
583 583
 			try {
584 584
 				$definition = new importexport_definition($id);
585
-				if($def->is_permitted($definition->get_record_array())) {
585
+				if ($def->is_permitted($definition->get_record_array())) {
586 586
 					$list[$definition->application][$definition->type][] = $id;
587 587
 				}
588 588
 			} catch (Exception $e) {
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
 			$plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name();
615 615
 			$plugin_name = get_class($plugin);
616 616
 
617
-			if($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
-			if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname);
617
+			if ($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
+			if (!class_exists($record_classname)) throw new Exception('Bad class name '.$record_classname);
619 619
 
620
-			if(!$wizard_plugin)
620
+			if (!$wizard_plugin)
621 621
 			{
622
-				$wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name);
623
-				if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name);
622
+				$wizard_name = $app_name.'_wizard_'.str_replace($app_name.'_', '', $plugin_name);
623
+				if (!class_exists($wizard_name)) throw new Exception('Bad wizard name '.$wizard_name);
624 624
 				$wizard_plugin = new $wizard_name;
625 625
 			}
626 626
 		}
@@ -632,16 +632,16 @@  discard block
 block discarded – undo
632 632
 
633 633
 		// Get field -> label map and initialize fields using wizard field order
634 634
 		$fields = $export_fields = array();
635
-		if(method_exists($wizard_plugin, 'get_export_fields'))
635
+		if (method_exists($wizard_plugin, 'get_export_fields'))
636 636
 		{
637 637
 			$fields = $export_fields = $wizard_plugin->get_export_fields();
638 638
 		}
639 639
 
640
-		foreach($record_classname::$types as $type => $type_fields)
640
+		foreach ($record_classname::$types as $type => $type_fields)
641 641
 		{
642 642
 			// Only these for now, until filter methods for others are figured out
643
-			if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue;
644
-			foreach($type_fields as $field_name)
643
+			if (!in_array($type, array('select', 'select-cat', 'select-account', 'date', 'date-time'))) continue;
644
+			foreach ($type_fields as $field_name)
645 645
 			{
646 646
 				$fields[$field_name] = array(
647 647
 					'name' => $field_name,
@@ -652,21 +652,21 @@  discard block
 block discarded – undo
652 652
 		}
653 653
 		// Add custom fields
654 654
 		$custom = Api\Storage\Customfields::get($app_name);
655
-		foreach($custom as $field_name => $settings)
655
+		foreach ($custom as $field_name => $settings)
656 656
 		{
657 657
 			$settings['name'] = '#'.$field_name;
658 658
 			$fields['#'.$field_name] = $settings;
659 659
 		}
660 660
 
661
-		foreach($fields as $field_name => &$settings) {
661
+		foreach ($fields as $field_name => &$settings) {
662 662
 			// Can't really filter on these (or at least no generic, sane way figured out yet)
663
-			if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea')))
663
+			if (!is_array($settings) || in_array($settings['type'], array('text', 'button', 'label', 'url', 'url-email', 'url-phone', 'htmlarea')))
664 664
 			{
665 665
 				unset($fields[$field_name]);
666 666
 				continue;
667 667
 			}
668
-			if($settings['type'] == 'radio') $settings['type'] = 'select';
669
-			switch($settings['type'])
668
+			if ($settings['type'] == 'radio') $settings['type'] = 'select';
669
+			switch ($settings['type'])
670 670
 			{
671 671
 				case 'checkbox':
672 672
 					// This isn't quite right - there's only 2 options and you can select both
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			}
690 690
 		}
691 691
 
692
-		if(method_exists($plugin, 'get_filter_fields'))
692
+		if (method_exists($plugin, 'get_filter_fields'))
693 693
 		{
694 694
 			$plugin->get_filter_fields($fields);
695 695
 		}
@@ -705,65 +705,65 @@  discard block
 block discarded – undo
705 705
 	 */
706 706
 	public static function date_rel2abs($value)
707 707
 	{
708
-		if(is_array($value))
708
+		if (is_array($value))
709 709
 		{
710 710
 			$abs = array();
711
-			foreach($value as $key => $val)
711
+			foreach ($value as $key => $val)
712 712
 			{
713 713
 				$abs[$key] = self::date_rel2abs($val);
714 714
 			}
715 715
 			return $abs;
716 716
 		}
717
-		if($date = self::$relative_dates[$value])
717
+		if ($date = self::$relative_dates[$value])
718 718
 		{
719
-			$year  = (int) date('Y');
720
-			$month = (int) date('m');
721
-			$day   = (int) date('d');
722
-			$today = mktime(0,0,0,date('m'),date('d'),date('Y'));
719
+			$year  = (int)date('Y');
720
+			$month = (int)date('m');
721
+			$day   = (int)date('d');
722
+			$today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
723 723
 
724
-			list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $date;
724
+			list($syear, $smonth, $sday, $sweek, $eyear, $emonth, $eday, $eweek) = $date;
725 725
 
726
-			if(stripos($value, 'quarter') !== false)
726
+			if (stripos($value, 'quarter') !== false)
727 727
 			{
728 728
 				// Handle quarters
729
-				$start = mktime(0,0,0,((int)floor(($smonth+$month) / 3.1)) * 3 + 1, 1, $year);
730
-				$end = mktime(0,0,0,((int)floor(($emonth+$month) / 3.1)+1) * 3 + 1, 1, $year);
729
+				$start = mktime(0, 0, 0, ((int)floor(($smonth + $month) / 3.1)) * 3 + 1, 1, $year);
730
+				$end = mktime(0, 0, 0, ((int)floor(($emonth + $month) / 3.1) + 1) * 3 + 1, 1, $year);
731 731
 			}
732 732
 			elseif ($syear || $eyear)
733 733
 			{
734
-				$start = mktime(0,0,0,1,1,$syear+$year);
735
-				$end   = mktime(0,0,0,1,1,$eyear+$year);
734
+				$start = mktime(0, 0, 0, 1, 1, $syear + $year);
735
+				$end   = mktime(0, 0, 0, 1, 1, $eyear + $year);
736 736
 			}
737 737
 			elseif ($smonth || $emonth)
738 738
 			{
739
-				$start = mktime(0,0,0,$smonth+$month,1,$year);
740
-				$end   = mktime(0,0,0,$emonth+$month,1,$year);
739
+				$start = mktime(0, 0, 0, $smonth + $month, 1, $year);
740
+				$end   = mktime(0, 0, 0, $emonth + $month, 1, $year);
741 741
 			}
742 742
 			elseif ($sday || $eday)
743 743
 			{
744
-				$start = mktime(0,0,0,$month,$sday+$day,$year);
745
-				$end   = mktime(0,0,0,$month,$eday+$day,$year);
744
+				$start = mktime(0, 0, 0, $month, $sday + $day, $year);
745
+				$end   = mktime(0, 0, 0, $month, $eday + $day, $year);
746 746
 			}
747 747
 			elseif ($sweek || $eweek)
748 748
 			{
749
-				$wday = (int) date('w'); // 0=sun, ..., 6=sat
750
-				switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
749
+				$wday = (int)date('w'); // 0=sun, ..., 6=sat
750
+				switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
751 751
 				{
752 752
 					case 'Sunday':
753
-						$weekstart = $today - $wday * 24*60*60;
753
+						$weekstart = $today - $wday * 24 * 60 * 60;
754 754
 						break;
755 755
 					case 'Saturday':
756
-						$weekstart = $today - (6-$wday) * 24*60*60;
756
+						$weekstart = $today - (6 - $wday) * 24 * 60 * 60;
757 757
 						break;
758 758
 					case 'Moday':
759 759
 					default:
760
-						$weekstart = $today - ($wday ? $wday-1 : 6) * 24*60*60;
760
+						$weekstart = $today - ($wday ? $wday - 1 : 6) * 24 * 60 * 60;
761 761
 						break;
762 762
 				}
763
-				$start = $weekstart + $sweek*7*24*60*60;
764
-				$end   = $weekstart + $eweek*7*24*60*60;
763
+				$start = $weekstart + $sweek * 7 * 24 * 60 * 60;
764
+				$end   = $weekstart + $eweek * 7 * 24 * 60 * 60;
765 765
 			}
766
-			$end_param = $end - 24*60*60;
766
+			$end_param = $end - 24 * 60 * 60;
767 767
 
768 768
 			// Take 1 second off end to provide an inclusive range.for filtering
769 769
 			$end -= 1;
Please login to merge, or discard this patch.
Braces   +208 added lines, -82 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
  * class importexport_helper_functions (only static methods)
17 17
  * use importexport_helper_functions::method
18 18
  */
19
-class importexport_helper_functions {
19
+class importexport_helper_functions
20
+{
20 21
 
21 22
 	/**
22 23
 	 * Plugins are scanned and cached for all instances using this source path for given time (in seconds)
@@ -85,13 +86,19 @@  discard block
 block discarded – undo
85 86
 	 * @param string $_format format of time string e.g.: d.m.Y H:i
86 87
 	 * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default
87 88
 	 */
88
-	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) {
89
-		if ( empty( $_format ) ) return strtotime( $_string );
89
+	public static function custom_strtotime( $_string, $_format='', $_is_dst = -1)
90
+	{
91
+		if ( empty( $_format ) )
92
+		{
93
+			return strtotime( $_string );
94
+		}
90 95
 		$fparams = explode( ',', chunk_split( $_format, 1, ',' ) );
91 96
 		$spos = 0;
92
-		foreach ( $fparams as $fparam ) {
97
+		foreach ( $fparams as $fparam )
98
+		{
93 99
 
94
-			switch ( $fparam ) {
100
+			switch ( $fparam )
101
+			{
95 102
 				case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break;
96 103
 				case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break;
97 104
 				case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break;
@@ -111,12 +118,18 @@  discard block
 block discarded – undo
111 118
 		$timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst);
112 119
 
113 120
 		// offset given?
114
-		if ( isset( $offset ) && strlen( $offset == 5 ) ) {
121
+		if ( isset( $offset ) && strlen( $offset == 5 ) )
122
+		{
115 123
 			$operator = $offset{0};
116 124
 			$ohour = 60 * 60 * (int)substr( $offset, 1, 2 );
117 125
 			$omin = 60 * (int)substr( $offset, 3, 2 );
118
-			if ( $operator == '+' ) $timestamp += $ohour + $omin;
119
-			else $timestamp -= $ohour + $omin;
126
+			if ( $operator == '+' )
127
+			{
128
+				$timestamp += $ohour + $omin;
129
+			}
130
+			else {
131
+				$timestamp -= $ohour + $omin;
132
+			}
120 133
 		}
121 134
 		return $timestamp;
122 135
 	}
@@ -126,11 +139,14 @@  discard block
 block discarded – undo
126 139
 	 * @param mixed $_account_lid comma seperated list or array with lids
127 140
 	 * @return mixed comma seperated list or array with ids
128 141
 	 */
129
-	public static function account_name2id( &$_account_lids ) {
142
+	public static function account_name2id( &$_account_lids )
143
+	{
130 144
 		$account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids );
131 145
 		$skip = false;
132
-		foreach ( $account_lids as $key => $account_lid ) {
133
-			if($skip) {
146
+		foreach ( $account_lids as $key => $account_lid )
147
+		{
148
+			if($skip)
149
+			{
134 150
 				unset($account_lids[$key]);
135 151
 				$skip = false;
136 152
 				continue;
@@ -138,7 +154,8 @@  discard block
 block discarded – undo
138 154
 			$account_lid = trim($account_lid);
139 155
 
140 156
 			// Handle any IDs that slip in
141
-			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
157
+			if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid))
158
+			{
142 159
 				unset($account_lids[$key]);
143 160
 				$account_ids[] = (int)$account_lid;
144 161
 				continue;
@@ -183,19 +200,22 @@  discard block
 block discarded – undo
183 200
 				$account_lid = trim(substr(trim($account_lid), strlen(lang('Group'))));
184 201
 			}
185 202
 
186
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) {
203
+			if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid ))
204
+			{
187 205
 				$account_ids[] = $account_id;
188 206
 				unset($account_lids[$key]);
189 207
 				continue;
190 208
 			}
191
-			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) {
209
+			if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' ))
210
+			{
192 211
 				$account_ids[] = $account_id;
193 212
 				unset($account_lids[$key]);
194 213
 				continue;
195 214
 			}
196 215
 
197 216
 			// Handle groups listed as Group, <name>
198
-			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) {
217
+			if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid))
218
+			{
199 219
 				$account_ids[] = $account_id;
200 220
 				unset($account_lids[$key-1]);
201 221
 				unset($account_lids[$key]);
@@ -219,10 +239,13 @@  discard block
 block discarded – undo
219 239
 	 * @param mixed $_account_ids comma seperated list or array with ids
220 240
 	 * @return mixed comma seperated list or array with lids
221 241
 	 */
222
-	public static function account_id2name( $_account_id ) {
242
+	public static function account_id2name( $_account_id )
243
+	{
223 244
 		$account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id );
224
-		foreach ( $account_ids as $account_id ) {
225
-			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) {
245
+		foreach ( $account_ids as $account_id )
246
+		{
247
+			if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id ))
248
+			{
226 249
 				$account_lids[] = $account_lid;
227 250
 			}
228 251
 		}
@@ -235,9 +258,11 @@  discard block
 block discarded – undo
235 258
 	 * @param mixed _cat_ids comma seperated list or array
236 259
 	 * @return mixed comma seperated list or array with cat_names
237 260
 	 */
238
-	public static function cat_id2name( $_cat_ids ) {
261
+	public static function cat_id2name( $_cat_ids )
262
+	{
239 263
 		$cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
240
-		foreach ( $cat_ids as $cat_id ) {
264
+		foreach ( $cat_ids as $cat_id )
265
+		{
241 266
 			$cat_names[] = Api\Categories::id2name( (int)$cat_id );
242 267
 		}
243 268
 		return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
@@ -251,14 +276,20 @@  discard block
 block discarded – undo
251 276
 	 * @param int $parent Optional parent ID to use for new categories
252 277
 	 * @return mixed comma seperated list or array with cat_ids
253 278
 	 */
254
-	public static function cat_name2id( $_cat_names, $parent = 0 ) {
279
+	public static function cat_name2id( $_cat_names, $parent = 0 )
280
+	{
255 281
 		$cats = new Api\Categories();	// uses current user and app (egw_info[flags][currentapp])
256 282
 
257 283
 		$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
258
-		foreach ( $cat_names as $cat_name ) {
284
+		foreach ( $cat_names as $cat_name )
285
+		{
259 286
 			$cat_name = trim($cat_name);
260
-			if ( $cat_name == '' ) continue;
261
-			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) {
287
+			if ( $cat_name == '' )
288
+			{
289
+				continue;
290
+			}
291
+			if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run)
292
+			{
262 293
 				$cat_id = $cats->add( array(
263 294
 					'name' => $cat_name,
264 295
 					'parent' => $parent,
@@ -307,8 +338,12 @@  discard block
 block discarded – undo
307 338
 	 * @param object &$cclass calling class to process the '@ evals'
308 339
 	 * @return bool
309 340
 	 */
310
-	public static function conversion( &$_record,  $_conversion, &$_cclass = null ) {
311
-		if (empty( $_conversion ) ) return $_record;
341
+	public static function conversion( &$_record,  $_conversion, &$_cclass = null )
342
+	{
343
+		if (empty( $_conversion ) )
344
+		{
345
+			return $_record;
346
+		}
312 347
 
313 348
 		self::$cclass =& $_cclass;
314 349
 
@@ -320,15 +355,21 @@  discard block
 block discarded – undo
320 355
 		$CntlnCLPre  = '|TCnCL{';   // Like |C{ but allowes CR and LF
321 356
 		$INE = '|INE{';             // Only insert if stuff in ^^ is not empty
322 357
 
323
-		foreach ( $_conversion as $idx => $conversion_string ) {
324
-			if ( empty( $conversion_string ) ) continue;
358
+		foreach ( $_conversion as $idx => $conversion_string )
359
+		{
360
+			if ( empty( $conversion_string ) )
361
+			{
362
+				continue;
363
+			}
325 364
 
326 365
 			// fetch patterns ($rvalues)
327 366
 			$rvalues = array();
328 367
 			$pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
329
-			foreach( $pat_reps as $k => $pat_rep ) {
368
+			foreach( $pat_reps as $k => $pat_rep )
369
+			{
330 370
 				list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
331
-				if( $replace == '' ) {
371
+				if( $replace == '' )
372
+				{
332 373
 					$replace = $pattern; $pattern = '^.*$';
333 374
 				}
334 375
 				$rvalues[$pattern] = $replace;	// replace two with only one, added by the form
@@ -338,19 +379,23 @@  discard block
 block discarded – undo
338 379
 			$val = array_key_exists( $idx, $_record ) ? $_record[$idx] : '';
339 380
 
340 381
 			$c_functions = array('cat', 'account', 'strtotime', 'list');
341
-			if($_cclass) {
382
+			if($_cclass)
383
+			{
342 384
 				// Add in additional methods
343 385
 				$reflection = new ReflectionClass(get_class($_cclass));
344 386
 				$methods = $reflection->getMethods(ReflectionMethod::IS_STATIC);
345
-				foreach($methods as $method) {
387
+				foreach($methods as $method)
388
+				{
346 389
 					$c_functions[] = $method->name;
347 390
 				}
348 391
 			}
349 392
 			$c_functions = implode('|', $c_functions);
350
-			foreach ( $rvalues as $pattern => $replace ) {
393
+			foreach ( $rvalues as $pattern => $replace )
394
+			{
351 395
 				// Allow to include record indexes in pattern
352 396
 				$reg = '/\|\[([0-9]+)\]/';
353
-				while( preg_match( $reg, $pattern, $vars ) ) {
397
+				while( preg_match( $reg, $pattern, $vars ) )
398
+				{
354 399
 					// expand all _record fields
355 400
 					$pattern = str_replace(
356 401
 						$CPre . $vars[1] . $CPos,
@@ -358,12 +403,14 @@  discard block
 block discarded – undo
358 403
 						$pattern
359 404
 					);
360 405
 				}
361
-				if( preg_match('/'. (string)$pattern.'/', $val) ) {
406
+				if( preg_match('/'. (string)$pattern.'/', $val) )
407
+				{
362 408
 
363 409
 					$val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val );
364 410
 
365 411
 					$reg = '/\|\[([a-zA-Z_0-9]+)\]/';
366
-					while( preg_match( $reg, $val, $vars ) ) {
412
+					while( preg_match( $reg, $val, $vars ) )
413
+					{
367 414
 						// expand all _record fields
368 415
 						$val = str_replace(
369 416
 							$CPre . $vars[1] . $CPos,
@@ -390,11 +437,13 @@  discard block
 block discarded – undo
390 437
 	 *
391 438
 	 * @param array $_matches
392 439
 	 */
393
-	private static function c2_dispatcher( $_matches ) {
440
+	private static function c2_dispatcher( $_matches )
441
+	{
394 442
 		$action = &$_matches[1]; // cat or account ...
395 443
 		$data = &$_matches[2];   // datas for action
396 444
 
397
-		switch ( $action ) {
445
+		switch ( $action )
446
+		{
398 447
 			case 'strtotime' :
399 448
 				list( $string, $format ) = explode( ',', $data );
400 449
 				return self::custom_strtotime( trim( $string ), trim( $format ) );
@@ -404,22 +453,28 @@  discard block
 block discarded – undo
404 453
 				// 1 based indexing for user ease
405 454
 				return $exploded[$index - 1];
406 455
 			default :
407
-				if(self::$cclass && method_exists(self::$cclass, $action)) {
456
+				if(self::$cclass && method_exists(self::$cclass, $action))
457
+				{
408 458
 					$class = get_class(self::$cclass);
409 459
 					return call_user_func("$class::$action", $data);
410 460
 				}
411 461
 				$method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' );
412
-				if(self::$cclass && method_exists(self::$cclass, $method)) {
462
+				if(self::$cclass && method_exists(self::$cclass, $method))
463
+				{
413 464
 					$class = get_class(self::$cclass);
414 465
 					return call_user_func("$class::$action", $data);
415
-				} else {
466
+				}
467
+				else
468
+				{
416 469
 					return self::$method( $data );
417 470
 				}
418 471
 		}
419 472
 	}
420 473
 
421
-	private static function strclean( $_matches ) {
422
-		switch( $_matches[1] ) {
474
+	private static function strclean( $_matches )
475
+	{
476
+		switch( $_matches[1] )
477
+		{
423 478
 			case '|T{' : return trim( $_matches[2] );
424 479
 			case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) );
425 480
 			case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) );
@@ -436,7 +491,8 @@  discard block
 block discarded – undo
436 491
 	 * @param string $_appname {<appname> | all}
437 492
 	 * @return array(<appname> => array( <type> => array(<plugin> => <title>)))
438 493
 	 */
439
-	public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
494
+	public static function get_plugins( $_appname = 'all', $_type = 'all' )
495
+	{
440 496
 		$plugins = Api\Cache::getTree(
441 497
 			__CLASS__,
442 498
 			'plugins',
@@ -449,38 +505,63 @@  discard block
 block discarded – undo
449 505
 
450 506
 		// Testing: comment out Api\Cache call, use this
451 507
 		//$plugins = self::_get_plugins($appnames, $types);
452
-		foreach($plugins as $appname => $_types) {
453
-			if(!in_array($appname, $appnames)) unset($plugins[$appname]);
508
+		foreach($plugins as $appname => $_types)
509
+		{
510
+			if(!in_array($appname, $appnames))
511
+			{
512
+				unset($plugins[$appname]);
513
+			}
454 514
 		}
455
-		foreach($plugins as $appname => $types) {
515
+		foreach($plugins as $appname => $types)
516
+		{
456 517
 			$plugins[$appname] = array_intersect_key($plugins[$appname], $types);
457 518
 		}
458 519
 		return $plugins;
459 520
 	}
460 521
 
461
-	public static function _get_plugins(Array $appnames, Array $types) {
522
+	public static function _get_plugins(Array $appnames, Array $types)
523
+	{
462 524
 		$plugins = array();
463
-		foreach ($appnames as $appname) {
464
-			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
525
+		foreach ($appnames as $appname)
526
+		{
527
+			if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true)
528
+			{
529
+				continue;
530
+			}
465 531
 
466 532
 			$appdir = EGW_INCLUDE_ROOT. "/$appname/inc";
467
-			if(!is_dir($appdir)) continue;
533
+			if(!is_dir($appdir))
534
+			{
535
+				continue;
536
+			}
468 537
 			$d = dir($appdir);
469 538
 
470 539
 			// step through each file in appdir
471
-			while (false !== ($entry = $d->read())) {
540
+			while (false !== ($entry = $d->read()))
541
+			{
472 542
 				// Blacklisted?
473
-				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))  continue;
474
-				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue;
543
+				if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname]))
544
+				{
545
+					continue;
546
+				}
547
+				if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches))
548
+				{
549
+					continue;
550
+				}
475 551
 				$classname = $matches[1];
476 552
 				$file = $appdir. '/'. $entry;
477 553
 
478
-				foreach ($types as $type) {
479
-					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue;
554
+				foreach ($types as $type)
555
+				{
556
+					if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false)
557
+					{
558
+						continue;
559
+					}
480 560
 					require_once($file);
481 561
 					$reflectionClass = new ReflectionClass($classname);
482 562
 					if($reflectionClass->IsInstantiable() &&
483
-							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) {
563
+							$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin'))
564
+					{
484 565
 						try {
485 566
 							$plugin_object = new $classname;
486 567
 						}
@@ -495,7 +576,8 @@  discard block
 block discarded – undo
495 576
 			$d->close();
496 577
 
497 578
 			$config = Api\Config::read('importexport');
498
-			if($config['update'] == 'auto') {
579
+			if($config['update'] == 'auto')
580
+			{
499 581
 				self::load_defaults($appname);
500 582
 			}
501 583
 		}
@@ -509,38 +591,56 @@  discard block
 block discarded – undo
509 591
 	 * @param string $_type
510 592
 	 * @return array $num => $appname
511 593
 	 */
512
-	public static function get_apps($_type, $ignore_acl = false) {
594
+	public static function get_apps($_type, $ignore_acl = false)
595
+	{
513 596
 		$apps = array_keys(self::get_plugins('all',$_type));
514
-		if($ignore_acl) return $apps;
597
+		if($ignore_acl)
598
+		{
599
+			return $apps;
600
+		}
515 601
 
516
-		foreach($apps as $key => $app) {
517
-			if(!self::has_definitions($app, $_type)) unset($apps[$key]);
602
+		foreach($apps as $key => $app)
603
+		{
604
+			if(!self::has_definitions($app, $_type))
605
+			{
606
+				unset($apps[$key]);
607
+			}
518 608
 		}
519 609
 		return $apps;
520 610
 	}
521 611
 
522
-	public static function load_defaults($appname) {
612
+	public static function load_defaults($appname)
613
+	{
523 614
 		// Check for new definitions to import from $appname/setup/*.xml
524 615
 		$appdir = EGW_INCLUDE_ROOT. "/$appname/setup";
525
-		if(!is_dir($appdir)) return;
616
+		if(!is_dir($appdir))
617
+		{
618
+			return;
619
+		}
526 620
 		$d = dir($appdir);
527 621
 
528 622
 		// step through each file in app's setup
529
-		while (false !== ($entry = $d->read())) {
623
+		while (false !== ($entry = $d->read()))
624
+		{
530 625
 			$file = $appdir. '/'. $entry;
531 626
 			list( $filename, $extension) = explode('.',$entry);
532
-			if ( $extension != 'xml' ) continue;
627
+			if ( $extension != 'xml' )
628
+			{
629
+				continue;
630
+			}
533 631
 			try {
534 632
 				// import will skip invalid files
535 633
 				importexport_definitions_bo::import( $file );
536
-			} catch (Exception $e) {
634
+			}
635
+			catch (Exception $e) {
537 636
 				error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage());
538 637
 			}
539 638
 		}
540 639
 		$d->close();
541 640
 	}
542 641
 
543
-	public static function guess_filetype( $_file ) {
642
+	public static function guess_filetype( $_file )
643
+	{
544 644
 
545 645
 	}
546 646
 
@@ -551,7 +651,8 @@  discard block
 block discarded – undo
551 651
 	 * @param string $_type {import | export | all}
552 652
 	 * @return boolean
553 653
 	 */
554
-	public static function has_definitions( $_appname = 'all', $_type = 'all' ) {
654
+	public static function has_definitions( $_appname = 'all', $_type = 'all' )
655
+	{
555 656
 		$definitions = Api\Cache::getSession(
556 657
 			__CLASS__,
557 658
 			'has_definitions',
@@ -565,27 +666,36 @@  discard block
 block discarded – undo
565 666
 		// Testing: Comment out cache call above, use this
566 667
 		//$definitions = self::_has_definitions($appnames, $types);
567 668
 
568
-		foreach($definitions as $appname => $_types) {
569
-			if(!in_array($appname, $appnames)) unset($definitions[$appname]);
669
+		foreach($definitions as $appname => $_types)
670
+		{
671
+			if(!in_array($appname, $appnames))
672
+			{
673
+				unset($definitions[$appname]);
674
+			}
570 675
 		}
571
-		foreach($definitions as $appname => $_types) {
676
+		foreach($definitions as $appname => $_types)
677
+		{
572 678
 			$definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types));
573 679
 		}
574 680
 		return !empty($definitions[$appname]);
575 681
 	}
576 682
 
577 683
 	// Api\Cache needs this public
578
-	public static function _has_definitions(Array $appnames, Array $types) {
684
+	public static function _has_definitions(Array $appnames, Array $types)
685
+	{
579 686
 		$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
580 687
 		$list = array();
581
-		foreach((array)$def->get_definitions() as $id) {
688
+		foreach((array)$def->get_definitions() as $id)
689
+		{
582 690
 			// Need to instanciate it to check, but if the user doesn't have permission, it throws an exception
583 691
 			try {
584 692
 				$definition = new importexport_definition($id);
585
-				if($def->is_permitted($definition->get_record_array())) {
693
+				if($def->is_permitted($definition->get_record_array()))
694
+				{
586 695
 					$list[$definition->application][$definition->type][] = $id;
587 696
 				}
588
-			} catch (Exception $e) {
697
+			}
698
+			catch (Exception $e) {
589 699
 				// That one doesn't work, keep going
590 700
 			}
591 701
 			$definition = null;
@@ -614,13 +724,22 @@  discard block
 block discarded – undo
614 724
 			$plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name();
615 725
 			$plugin_name = get_class($plugin);
616 726
 
617
-			if($record_classname == null) $record_classname = $plugin::get_egw_record_class();
618
-			if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname);
727
+			if($record_classname == null)
728
+			{
729
+				$record_classname = $plugin::get_egw_record_class();
730
+			}
731
+			if(!class_exists($record_classname))
732
+			{
733
+				throw new Exception('Bad class name ' . $record_classname);
734
+			}
619 735
 
620 736
 			if(!$wizard_plugin)
621 737
 			{
622 738
 				$wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name);
623
-				if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name);
739
+				if(!class_exists($wizard_name))
740
+				{
741
+					throw new Exception('Bad wizard name ' . $wizard_name);
742
+				}
624 743
 				$wizard_plugin = new $wizard_name;
625 744
 			}
626 745
 		}
@@ -640,7 +759,10 @@  discard block
 block discarded – undo
640 759
 		foreach($record_classname::$types as $type => $type_fields)
641 760
 		{
642 761
 			// Only these for now, until filter methods for others are figured out
643
-			if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue;
762
+			if(!in_array($type, array('select','select-cat','select-account','date','date-time')))
763
+			{
764
+				continue;
765
+			}
644 766
 			foreach($type_fields as $field_name)
645 767
 			{
646 768
 				$fields[$field_name] = array(
@@ -658,14 +780,18 @@  discard block
 block discarded – undo
658 780
 			$fields['#'.$field_name] = $settings;
659 781
 		}
660 782
 
661
-		foreach($fields as $field_name => &$settings) {
783
+		foreach($fields as $field_name => &$settings)
784
+		{
662 785
 			// Can't really filter on these (or at least no generic, sane way figured out yet)
663 786
 			if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea')))
664 787
 			{
665 788
 				unset($fields[$field_name]);
666 789
 				continue;
667 790
 			}
668
-			if($settings['type'] == 'radio') $settings['type'] = 'select';
791
+			if($settings['type'] == 'radio')
792
+			{
793
+				$settings['type'] = 'select';
794
+			}
669 795
 			switch($settings['type'])
670 796
 			{
671 797
 				case 'checkbox':
Please login to merge, or discard this patch.
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_export_plugin.inc.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
 	 * and automatic conversions.  In most cases they are named <appname>_egw_record,
108 108
 	 * but projectmanager is an exception to this.
109 109
 	 *
110
-	 * @return string;
110
+	 * @return string
111 111
 	 */
112 112
 	public static function get_egw_record_class();
113 113
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@
 block discarded – undo
34 34
  *
35 35
  * get_selector();  //returns array
36 36
  */
37
-interface importexport_iface_export_plugin {
37
+interface importexport_iface_export_plugin
38
+{
38 39
 	
39 40
 	/**
40 41
 	 * exports entries according to given definition object.
Please login to merge, or discard this patch.