Completed
Push — 14.2 ( f2fc75...83e303 )
by Ralf
29:05
created
filemanager/inc/class.filemanager_ui.inc.php 1 patch
Spacing   +203 added lines, -205 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			$_GET = etemplate::array_stripslashes($_GET);
54 54
 		}
55 55
 		// do we have root rights
56
-		if (egw_session::appsession('is_root','filemanager'))
56
+		if (egw_session::appsession('is_root', 'filemanager'))
57 57
 		{
58 58
 			egw_vfs::$is_root = true;
59 59
 		}
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 		if (!static::$views_init)
73 73
 		{
74 74
 			// translate our labels
75
-			foreach(static::$views as &$label)
75
+			foreach (static::$views as &$label)
76 76
 			{
77 77
 				$label = lang($label);
78 78
 			}
79 79
 			// search for plugins with additional filemanager views
80
-			foreach($GLOBALS['egw']->hooks->process('filemanager_views') as $views)
80
+			foreach ($GLOBALS['egw']->hooks->process('filemanager_views') as $views)
81 81
 			{
82 82
 				if (is_array($views)) static::$views += $views;
83 83
 			}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public static function get_view()
95 95
 	{
96
-		$view =& egw_cache::getSession('filemanager', 'view');
96
+		$view = & egw_cache::getSession('filemanager', 'view');
97 97
 		if (isset($_GET['view']))
98 98
 		{
99 99
 			$view = $_GET['view'];
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			'open' => array(
118 118
 				'caption' => lang('Open'),
119 119
 				'icon' => '',
120
-				'group' => $group=1,
120
+				'group' => $group = 1,
121 121
 				'allowOnMultiple' => false,
122 122
 				'onExecute' => 'javaScript:app.filemanager.open',
123 123
 				'default' => true
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 			),
171 171
 			// DRAG and DROP events
172 172
 			'file_drag' => array(
173
-				'dragType' => array('file','link'),
173
+				'dragType' => array('file', 'link'),
174 174
 				'type' => 'drag',
175 175
 				'onExecute' => 'javaScript:app.filemanager.drag'
176 176
 			),
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		}
210 210
 		else
211 211
 		{
212
-			foreach(egw_sharing::$modes as $mode => $data)
212
+			foreach (egw_sharing::$modes as $mode => $data)
213 213
 			{
214 214
 				$actions['mail']['children']['mail_'.$mode] = array(
215 215
 					'caption' => $data['label'],
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return string merge application or NULL if no property found
233 233
 	 */
234
-	private static function get_mergeapp($path, $scope='self')
234
+	private static function get_mergeapp($path, $scope = 'self')
235 235
 	{
236 236
 		$app = null;
237
-		switch($scope)
237
+		switch ($scope)
238 238
 		{
239 239
 			case 'self':
240 240
 				$props = egw_vfs::propfind($path, static::$merge_prop_namespace);
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 			case 'parents':
244 244
 				// search for props in parent directories
245 245
 				$currentpath = $path;
246
-				while($dir = egw_vfs::dirname($currentpath))
246
+				while ($dir = egw_vfs::dirname($currentpath))
247 247
 				{
248 248
 					$props = egw_vfs::propfind($dir, static::$merge_prop_namespace);
249
-					if(!empty($props))
249
+					if (!empty($props))
250 250
 					{
251 251
 						// found prop in parent directory
252 252
 						return $app = $props[0]['val'];
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
 	 * @param array $content
266 266
 	 * @param string $msg
267 267
 	 */
268
-	function index(array $content=null,$msg=null)
268
+	function index(array $content = null, $msg = null)
269 269
 	{
270 270
 		if (!is_array($content))
271 271
 		{
272 272
 			$content = array(
273
-				'nm' => egw_session::appsession('index','filemanager'),
273
+				'nm' => egw_session::appsession('index', 'filemanager'),
274 274
 			);
275 275
 			if (!is_array($content['nm']))
276 276
 			{
277 277
 				$content['nm'] = array(
278
-					'get_rows'       =>	'filemanager.filemanager_ui.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
279
-					'filter'         => '',	// current dir only
280
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
281
-					'no_cat'         => True,	// I  disable the cat-selectbox
282
-					'lettersearch'   => True,	// I  show a lettersearch
283
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
284
-					'start'          =>	0,		// IO position in list
285
-					'order'          =>	'name',	// IO name of the column to sort after (optional for the sortheaders)
286
-					'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
287
-					'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
278
+					'get_rows'       =>	'filemanager.filemanager_ui.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
279
+					'filter'         => '', // current dir only
280
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
281
+					'no_cat'         => True, // I  disable the cat-selectbox
282
+					'lettersearch'   => True, // I  show a lettersearch
283
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
284
+					'start'          =>	0, // IO position in list
285
+					'order'          =>	'name', // IO name of the column to sort after (optional for the sortheaders)
286
+					'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
287
+					'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
288 288
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
289 289
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
290 290
 					'actions'        => static::get_actions(),
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 					'is_parent_value'=> egw_vfs::DIR_MIME_TYPE,
296 296
 					'header_left'    => 'filemanager.index.header_left',
297 297
 					'favorites'      => true,
298
-					'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
298
+					'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink')
299 299
 				);
300 300
 				$content['nm']['path'] = static::get_home_dir();
301 301
 			}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 			}
317 317
 			if (isset($_GET['path']) && ($path = $_GET['path']))
318 318
 			{
319
-				switch($path)
319
+				switch ($path)
320 320
 				{
321 321
 					case '..':
322 322
 						$path = egw_vfs::dirname($content['nm']['path']);
@@ -325,13 +325,13 @@  discard block
 block discarded – undo
325 325
 						$path = static::get_home_dir();
326 326
 						break;
327 327
 				}
328
-				if ($path[0] == '/' && egw_vfs::stat($path,true) && egw_vfs::is_dir($path) && egw_vfs::check_access($path,egw_vfs::READABLE))
328
+				if ($path[0] == '/' && egw_vfs::stat($path, true) && egw_vfs::is_dir($path) && egw_vfs::check_access($path, egw_vfs::READABLE))
329 329
 				{
330 330
 					$content['nm']['path'] = $path;
331 331
 				}
332 332
 				else
333 333
 				{
334
-					$msg .= lang('The requested path %1 is not available.',egw_vfs::decodePath($path));
334
+					$msg .= lang('The requested path %1 is not available.', egw_vfs::decodePath($path));
335 335
 				}
336 336
 				// reset lettersearch as it confuses users (they think the dir is empty)
337 337
 				$content['nm']['searchletter'] = false;
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
 		}
342 342
 		$view = static::get_view();
343 343
 
344
-		if (strpos($view,'::') !== false && version_compare(PHP_VERSION,'5.3.0','<'))
344
+		if (strpos($view, '::') !== false && version_compare(PHP_VERSION, '5.3.0', '<'))
345 345
 		{
346
-			$view = explode('::',$view);
346
+			$view = explode('::', $view);
347 347
 		}
348
-		call_user_func($view,$content,$msg);
348
+		call_user_func($view, $content, $msg);
349 349
 	}
350 350
 
351 351
 	/**
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise
359 359
 	 * @return boolean true is root user given, false otherwise (including logout / empty $user)
360 360
 	 */
361
-	protected function sudo($user='',$password=null,&$is_setup=null)
361
+	protected function sudo($user = '', $password = null, &$is_setup = null)
362 362
 	{
363 363
 		if (!$user)
364 364
 		{
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 		else
368 368
 		{
369 369
 			// config user & password
370
-			$is_setup = egw_session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash'];
370
+			$is_setup = egw_session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash'];
371 371
 			// or vfs root user from setup >> configuration
372
-			$is_root = $is_setup ||	$GLOBALS['egw_info']['server']['vfs_root_user'] &&
373
-				in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) &&
372
+			$is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] &&
373
+				in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) &&
374 374
 				$GLOBALS['egw']->auth->authenticate($user, $password, 'text');
375 375
 		}
376 376
 		//echo "<p>".__METHOD__."('$user','$password',$is_setup) user_pw_hash(...)='".egw_session::user_pw_hash($user,$password)."', config_hash='{$GLOBALS['egw_info']['server']['config_hash']}' --> returning ".array2string($is_root)."</p>\n";
377
-		egw_session::appsession('is_setup','filemanager',$is_setup);
378
-		return egw_session::appsession('is_root','filemanager',egw_vfs::$is_root = $is_root);
377
+		egw_session::appsession('is_setup', 'filemanager', $is_setup);
378
+		return egw_session::appsession('is_root', 'filemanager', egw_vfs::$is_root = $is_root);
379 379
 	}
380 380
 
381 381
 	/**
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 	 * @param array $content
385 385
 	 * @param string $msg
386 386
 	 */
387
-	function listview(array $content=null,$msg=null)
387
+	function listview(array $content = null, $msg = null)
388 388
 	{
389 389
 		$tpl = new etemplate_new('filemanager.index');
390 390
 
391
-		if($msg) egw_framework::message($msg);
391
+		if ($msg) egw_framework::message($msg);
392 392
 
393 393
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
394 394
 		{
395 395
 			if ($content['nm']['action'])
396 396
 			{
397
-				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
398
-				if($msg) egw_framework::message($msg);
397
+				$msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']);
398
+				if ($msg) egw_framework::message($msg);
399 399
 
400 400
 				// clean up after action
401 401
 				unset($content['nm']['selected']);
@@ -406,10 +406,10 @@  discard block
 block discarded – undo
406 406
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
407 407
 				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
408 408
 			}
409
-			elseif($content['nm']['rows']['delete'])
409
+			elseif ($content['nm']['rows']['delete'])
410 410
 			{
411
-				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
412
-				if($msg) egw_framework::message($msg);
411
+				$msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']);
412
+				if ($msg) egw_framework::message($msg);
413 413
 
414 414
 				// clean up after action
415 415
 				unset($content['nm']['rows']['delete']);
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
422 422
 			}
423 423
 			unset($content['nm']['rows']);
424
-			egw_session::appsession('index','filemanager',$content['nm']);
424
+			egw_session::appsession('index', 'filemanager', $content['nm']);
425 425
 		}
426 426
 
427 427
 		// be tolerant with (in previous versions) not correct urlencoded pathes
428
-		if ($content['nm']['path'][0] == '/' && !egw_vfs::stat($content['nm']['path'],true) && egw_vfs::stat(urldecode($content['nm']['path'])))
428
+		if ($content['nm']['path'][0] == '/' && !egw_vfs::stat($content['nm']['path'], true) && egw_vfs::stat(urldecode($content['nm']['path'])))
429 429
 		{
430 430
 			$content['nm']['path'] = urldecode($content['nm']['path']);
431 431
 		}
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 				list($button) = each($content['button']);
437 437
 				unset($content['button']);
438 438
 			}
439
-			switch($button)
439
+			switch ($button)
440 440
 			{
441 441
 				case 'upload':
442 442
 					if (!$content['upload'])
443 443
 					{
444
-						egw_framework::message(lang('You need to select some files first!'),'error');
444
+						egw_framework::message(lang('You need to select some files first!'), 'error');
445 445
 						break;
446 446
 					}
447 447
 					$upload_success = $upload_failure = array();
448
-					foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
448
+					foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
449 449
 					{
450 450
 						// encode chars which special meaning in url/vfs (some like / get removed!)
451
-						$to = egw_vfs::concat($content['nm']['path'],egw_vfs::encodePathComponent($upload['name']));
451
+						$to = egw_vfs::concat($content['nm']['path'], egw_vfs::encodePathComponent($upload['name']));
452 452
 						if ($upload &&
453 453
 							(egw_vfs::is_writable($content['nm']['path']) || egw_vfs::is_writable($to)) &&
454
-							copy($upload['tmp_name'],egw_vfs::PREFIX.$to))
454
+							copy($upload['tmp_name'], egw_vfs::PREFIX.$to))
455 455
 						{
456 456
 							$upload_success[] = $upload['name'];
457 457
 						}
@@ -463,12 +463,11 @@  discard block
 block discarded – undo
463 463
 					$content['nm']['msg'] = '';
464 464
 					if ($upload_success)
465 465
 					{
466
-						egw_framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') :
467
-							lang('%1 successful uploaded.',implode(', ',$upload_success)));
466
+						egw_framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success)));
468 467
 					}
469 468
 					if ($upload_failure)
470 469
 					{
471
-						egw_framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error');
470
+						egw_framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error');
472 471
 					}
473 472
 					break;
474 473
 			}
@@ -489,17 +488,17 @@  discard block
 block discarded – undo
489 488
 			$tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv');
490 489
 		}
491 490
 		// Set view button to match current settings
492
-		if($content['nm']['view'] == 'tile')
491
+		if ($content['nm']['view'] == 'tile')
493 492
 		{
494
-			$tpl->setElementAttribute('nm[buttons][button][change_view]','label',lang('List view'));
495
-			$tpl->setElementAttribute('nm[buttons][button][change_view]','image','list_row');
493
+			$tpl->setElementAttribute('nm[buttons][button][change_view]', 'label', lang('List view'));
494
+			$tpl->setElementAttribute('nm[buttons][button][change_view]', 'image', 'list_row');
496 495
 
497 496
 		}
498 497
 		// if initial load is done via GET request (idots template or share.php)
499 498
 		// get_rows cant call app.filemanager.set_readonly, so we need to do that here
500 499
 		$content['initial_path_readonly'] = !egw_vfs::is_writable($content['nm']['path']);
501 500
 
502
-		$tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm']));
501
+		$tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm']));
503 502
 	}
504 503
 
505 504
 	/**
@@ -535,7 +534,7 @@  discard block
 block discarded – undo
535 534
 	 * @param int &$files=null on return number of files deleted
536 535
 	 * @return string success or failure message displayed to the user
537 536
 	 */
538
-	static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null)
537
+	static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null)
539 538
 	{
540 539
 		if (!count($selected))
541 540
 		{
@@ -543,20 +542,20 @@  discard block
 block discarded – undo
543 542
 		}
544 543
 		$errs = $dirs = $files = 0;
545 544
 
546
-		switch($action)
545
+		switch ($action)
547 546
 		{
548 547
 
549 548
 			case 'delete':
550
-				return static::do_delete($selected,$errs,$files,$dirs);
549
+				return static::do_delete($selected, $errs, $files, $dirs);
551 550
 
552 551
 			case 'mail':
553 552
 			case 'copy':
554
-				foreach($selected as $path)
553
+				foreach ($selected as $path)
555 554
 				{
556 555
 					if (strpos($path, 'mail::') === 0 && $path = substr($path, 6))
557 556
 					{
558 557
 						// Support for dropping mail in filemanager - Pass mail back to mail app
559
-						if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
558
+						if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
560 559
 						{
561 560
 							++$files;
562 561
 						}
@@ -567,8 +566,8 @@  discard block
 block discarded – undo
567 566
 					}
568 567
 					elseif (!egw_vfs::is_dir($path))
569 568
 					{
570
-						$to = egw_vfs::concat($dir,egw_vfs::basename($path));
571
-						if ($path != $to && egw_vfs::copy($path,$to))
569
+						$to = egw_vfs::concat($dir, egw_vfs::basename($path));
570
+						if ($path != $to && egw_vfs::copy($path, $to))
572 571
 						{
573 572
 							++$files;
574 573
 						}
@@ -580,19 +579,19 @@  discard block
 block discarded – undo
580 579
 					else
581 580
 					{
582 581
 						$len = strlen(dirname($path));
583
-						foreach(egw_vfs::find($path) as $p)
582
+						foreach (egw_vfs::find($path) as $p)
584 583
 						{
585
-							$to = $dir.substr($p,$len);
584
+							$to = $dir.substr($p, $len);
586 585
 							if ($to == $p)	// cant copy into itself!
587 586
 							{
588 587
 								++$errs;
589 588
 								continue;
590 589
 							}
591
-							if (($is_dir = egw_vfs::is_dir($p)) && egw_vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
590
+							if (($is_dir = egw_vfs::is_dir($p)) && egw_vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE))
592 591
 							{
593 592
 								++$dirs;
594 593
 							}
595
-							elseif(!$is_dir && egw_vfs::copy($p,$to))
594
+							elseif (!$is_dir && egw_vfs::copy($p, $to))
596 595
 							{
597 596
 								++$files;
598 597
 							}
@@ -605,15 +604,15 @@  discard block
 block discarded – undo
605 604
 				}
606 605
 				if ($errs)
607 606
 				{
608
-					return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files);
607
+					return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files);
609 608
 				}
610
-				return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files);
609
+				return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files);
611 610
 
612 611
 			case 'move':
613
-				foreach($selected as $path)
612
+				foreach ($selected as $path)
614 613
 				{
615
-					$to = egw_vfs::is_dir($dir) || count($selected) > 1 ? egw_vfs::concat($dir,egw_vfs::basename($path)) : $dir;
616
-					if ($path != $to && egw_vfs::rename($path,$to))
614
+					$to = egw_vfs::is_dir($dir) || count($selected) > 1 ? egw_vfs::concat($dir, egw_vfs::basename($path)) : $dir;
615
+					if ($path != $to && egw_vfs::rename($path, $to))
617 616
 					{
618 617
 						++$files;
619 618
 					}
@@ -624,17 +623,17 @@  discard block
 block discarded – undo
624 623
 				}
625 624
 				if ($errs)
626 625
 				{
627
-					return lang('%1 errors moving (%2 files moved)!',$errs,$files);
626
+					return lang('%1 errors moving (%2 files moved)!', $errs, $files);
628 627
 				}
629
-				return lang('%1 files moved.',$files);
628
+				return lang('%1 files moved.', $files);
630 629
 
631 630
 			case 'symlink':	// symlink given files to $dir
632
-				foreach((array)$selected as $target)
631
+				foreach ((array)$selected as $target)
633 632
 				{
634 633
 					$link = egw_vfs::concat($dir, egw_vfs::basename($target));
635
-					if (!egw_vfs::stat($dir) || ($ok = egw_vfs::mkdir($dir,0,true)))
634
+					if (!egw_vfs::stat($dir) || ($ok = egw_vfs::mkdir($dir, 0, true)))
636 635
 					{
637
-						if(!$ok)
636
+						if (!$ok)
638 637
 						{
639 638
 							$errs++;
640 639
 							continue;
@@ -656,15 +655,14 @@  discard block
 block discarded – undo
656 655
 				}
657 656
 				if (count((array)$selected) == 1)
658 657
 				{
659
-					return $files ? lang('Symlink to %1 created.', egw_vfs::decodePath($target)) :
660
-						lang('Error creating symlink to target %1!', egw_vfs::decodePath($target));
658
+					return $files ? lang('Symlink to %1 created.', egw_vfs::decodePath($target)) : lang('Error creating symlink to target %1!', egw_vfs::decodePath($target));
661 659
 				}
662 660
 				$ret = lang('%1 elements linked.', $files);
663 661
 				if ($errs)
664 662
 				{
665
-					$ret = lang('%1 errors linking (%2)!',$errs, $ret);
663
+					$ret = lang('%1 errors linking (%2)!', $errs, $ret);
666 664
 				}
667
-				return $ret;//." egw_vfs::symlink('$target', '$link')";
665
+				return $ret; //." egw_vfs::symlink('$target', '$link')";
668 666
 
669 667
 			case 'createdir':
670 668
 				$dst = egw_vfs::concat($dir, is_array($selected) ? $selected[0] : $selected);
@@ -680,13 +678,13 @@  discard block
 block discarded – undo
680 678
 
681 679
 			default:
682 680
 				list($action, $settings) = explode('_', $action, 2);
683
-				switch($action)
681
+				switch ($action)
684 682
 				{
685 683
 					case 'document':
686 684
 						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
687 685
 						$document_merge = new filemanager_merge(egw_vfs::decodePath($dir));
688 686
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
689
-						if($msg) return $msg;
687
+						if ($msg) return $msg;
690 688
 						$errs = count($selected);
691 689
 						return false;
692 690
 				}
@@ -703,12 +701,12 @@  discard block
 block discarded – undo
703 701
 	 * @param int &$files=null on return number of files deleted
704 702
 	 * @return string
705 703
 	 */
706
-	public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null)
704
+	public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null)
707 705
 	{
708 706
 		$dirs = $files = $errs = 0;
709 707
 		// we first delete all selected links (and files)
710 708
 		// feeding the links to dirs to egw_vfs::find() deletes the content of the dirs, not just the link!
711
-		foreach($selected as $key => $path)
709
+		foreach ($selected as $key => $path)
712 710
 		{
713 711
 			if (!egw_vfs::is_dir($path) || egw_vfs::is_link($path))
714 712
 			{
@@ -726,21 +724,21 @@  discard block
 block discarded – undo
726 724
 		if ($selected)	// somethings left to delete
727 725
 		{
728 726
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
729
-			foreach((array)$selected as $path)
727
+			foreach ((array)$selected as $path)
730 728
 			{
731
-				if (preg_match('/^\/?(home|apps|)\/*$/',$path))
729
+				if (preg_match('/^\/?(home|apps|)\/*$/', $path))
732 730
 				{
733 731
 					$errs++;
734
-					return lang("Cautiously rejecting to remove folder '%1'!",egw_vfs::decodePath($path));
732
+					return lang("Cautiously rejecting to remove folder '%1'!", egw_vfs::decodePath($path));
735 733
 				}
736 734
 			}
737 735
 			// now we use find to loop through all files and dirs: (selected only contains dirs now)
738 736
 			// - depth=true to get first the files and then the dir containing it
739 737
 			// - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs
740 738
 			// - show-deleted=false to not (finally) deleted versioned files
741
-			foreach(egw_vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path)
739
+			foreach (egw_vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path)
742 740
 			{
743
-				if (($is_dir = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)) && egw_vfs::rmdir($path,0))
741
+				if (($is_dir = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)) && egw_vfs::rmdir($path, 0))
744 742
 				{
745 743
 					++$dirs;
746 744
 				}
@@ -756,13 +754,13 @@  discard block
 block discarded – undo
756 754
 		}
757 755
 		if ($errs)
758 756
 		{
759
-			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files);
757
+			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files);
760 758
 		}
761 759
 		if ($dirs)
762 760
 		{
763
-			return lang('%1 directories and %2 files deleted.',$dirs,$files);
761
+			return lang('%1 directories and %2 files deleted.', $dirs, $files);
764 762
 		}
765
-		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files);
763
+		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files);
766 764
 	}
767 765
 
768 766
 	/**
@@ -776,37 +774,37 @@  discard block
 block discarded – undo
776 774
 		// do NOT store query, if hierarchical data / children are requested
777 775
 		if (!$query['csv_export'])
778 776
 		{
779
-			egw_session::appsession('index','filemanager',$query);
777
+			egw_session::appsession('index', 'filemanager', $query);
780 778
 		}
781
-		if(!$query['path']) $query['path'] = static::get_home_dir();
779
+		if (!$query['path']) $query['path'] = static::get_home_dir();
782 780
 
783 781
 		// Change template to match selected view
784
-		if($query['view'])
782
+		if ($query['view'])
785 783
 		{
786 784
 			$query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile');
787 785
 
788 786
 			// Store as preference but only for index, not home
789
-			if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
787
+			if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
790 788
 			{
791
-				$GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']);
789
+				$GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']);
792 790
 				$GLOBALS['egw']->preferences->save_repository();
793 791
 			}
794 792
 		}
795 793
 		// be tolerant with (in previous versions) not correct urlencoded pathes
796
-		if (!egw_vfs::stat($query['path'],true) && egw_vfs::stat(urldecode($query['path'])))
794
+		if (!egw_vfs::stat($query['path'], true) && egw_vfs::stat(urldecode($query['path'])))
797 795
 		{
798 796
 			$query['path'] = urldecode($query['path']);
799 797
 		}
800
-		if (!egw_vfs::stat($query['path'],true) || !egw_vfs::is_dir($query['path']) || !egw_vfs::check_access($query['path'],egw_vfs::READABLE))
798
+		if (!egw_vfs::stat($query['path'], true) || !egw_vfs::is_dir($query['path']) || !egw_vfs::check_access($query['path'], egw_vfs::READABLE))
801 799
 		{
802 800
 			// only redirect, if it would be to some other location, gives redirect-loop otherwise
803 801
 			if ($query['path'] != ($path = static::get_home_dir()))
804 802
 			{
805 803
 				// we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give
806 804
 				// an appropriate message
807
-				egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index',
805
+				egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index',
808 806
 					'path' => $path,
809
-					'msg' => lang('The requested path %1 is not available.',egw_vfs::decodePath($query['path'])),
807
+					'msg' => lang('The requested path %1 is not available.', egw_vfs::decodePath($query['path'])),
810 808
 					'ajax' => 'true'
811 809
 				));
812 810
 			}
@@ -814,35 +812,35 @@  discard block
 block discarded – undo
814 812
 			return 0;
815 813
 		}
816 814
 		$rows = $dir_is_writable = array();
817
-		if($query['searchletter'] && !empty($query['search']))
815
+		if ($query['searchletter'] && !empty($query['search']))
818 816
 		{
819
-			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
817
+			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
820 818
 			if ($query['searchletter'] == strtolower($query['search'][0]))
821 819
 			{
822
-				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'.
823
-					str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i';
820
+				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'.
821
+					str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i';
824 822
 			}
825 823
 		}
826 824
 		elseif ($query['searchletter'])
827 825
 		{
828 826
 			$namefilter = '/^'.$query['searchletter'].'/i';
829 827
 		}
830
-		elseif(!empty($query['search']))
828
+		elseif (!empty($query['search']))
831 829
 		{
832
-			$namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
830
+			$namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
833 831
 		}
834 832
 
835 833
 		// Re-map so 'No filters' favorite ('') is depth 1
836 834
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
837 835
 
838 836
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
839
-		if($filter == 5) $maxdepth = 2;
837
+		if ($filter == 5) $maxdepth = 2;
840 838
 		$n = 0;
841 839
 		$vfs_options = array(
842 840
 			'mindepth' => 1,
843 841
 			'maxdepth' => $maxdepth,
844 842
 			'dirsontop' => $filter <= 1,
845
-			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'),
843
+			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'),
846 844
 			'order' => $query['order'], 'sort' => $query['sort'],
847 845
 			'limit' => (int)$query['num_rows'].','.(int)$query['start'],
848 846
 			'need_mime' => true,
@@ -850,11 +848,11 @@  discard block
 block discarded – undo
850 848
 			'hidden' => $filter == 3,
851 849
 			'follow' => $filter == 5,
852 850
 		);
853
-		if($query['col_filter']['mime'])
851
+		if ($query['col_filter']['mime'])
854 852
 		{
855 853
 			$vfs_options['mime'] = $query['col_filter']['mime'];
856 854
 		}
857
-		foreach(egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row)
855
+		foreach (egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row)
858 856
 		{
859 857
 			//echo $path; _debug_array($row);
860 858
 
@@ -868,32 +866,32 @@  discard block
 block discarded – undo
868 866
 				$row['class'] = 'isDir';
869 867
 			}
870 868
 			$row['download_url'] = egw_vfs::download_url($path);
871
-			$row['gid'] = -abs($row['gid']);	// gid are positive, but we use negagive account_id for groups internal
869
+			$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
872 870
 
873 871
 			$rows[++$n] = $row;
874 872
 			$path2n[$path] = $n;
875 873
 		}
876 874
 		// query comments and cf's for the displayed rows
877
-		$cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
875
+		$cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
878 876
 
879 877
 		// Always include comment in tiles
880
-		if($query['view'] == 'tile')
878
+		if ($query['view'] == 'tile')
881 879
 		{
882 880
 			$cols_to_show[] = 'comment';
883 881
 		}
884
-		$all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#';
885
-		if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) &&
882
+		$all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#';
883
+		if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) &&
886 884
 			($path2props = egw_vfs::propfind(array_keys($path2n))))
887 885
 		{
888
-			foreach($path2props as $path => $props)
886
+			foreach ($path2props as $path => $props)
889 887
 			{
890
-				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
891
-				$row =& $rows[$path2n[$path]];
892
-				if ( !is_array($props) ) continue;
893
-				foreach($props as $prop)
888
+				unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2
889
+				$row = & $rows[$path2n[$path]];
890
+				if (!is_array($props)) continue;
891
+				foreach ($props as $prop)
894 892
 				{
895
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
896
-					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
893
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue;
894
+					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...';
897 895
 				}
898 896
 			}
899 897
 		}
@@ -905,7 +903,7 @@  discard block
 block discarded – undo
905 903
 		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager')
906 904
 		{
907 905
 			// we need our app.css file
908
-			if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
906
+			if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
909 907
 			{
910 908
 				$css_file = '/filemanager/templates/default/app.css';
911 909
 			}
@@ -921,7 +919,7 @@  discard block
 block discarded – undo
921 919
 	 * @param array $content
922 920
 	 * @param string $msg
923 921
 	 */
924
-	function file(array $content=null,$msg='')
922
+	function file(array $content = null, $msg = '')
925 923
 	{
926 924
 		$tpl = new etemplate_new('filemanager.file');
927 925
 
@@ -931,9 +929,9 @@  discard block
 block discarded – undo
931 929
 			{
932 930
 				$msg .= $_GET['msg'];
933 931
 			}
934
-			if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) ||	// ?, # need to stay encoded!
932
+			if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded!
935 933
 				// actions enclose pathes containing comma with "
936
-				($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) ||
934
+				($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) ||
937 935
 				!($stat = egw_vfs::lstat($path)))
938 936
 			{
939 937
 				$msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat);
@@ -946,10 +944,10 @@  discard block
 block discarded – undo
946 944
 				$content['path'] = $path;
947 945
 				$content['hsize'] = egw_vfs::hsize($stat['size']);
948 946
 				$content['mime'] = egw_vfs::mime_content_type($path);
949
-				$content['gid'] *= -1;	// our widgets use negative gid's
947
+				$content['gid'] *= -1; // our widgets use negative gid's
950 948
 				if (($props = egw_vfs::propfind($path)))
951 949
 				{
952
-					foreach($props as $prop)
950
+					foreach ($props as $prop)
953 951
 					{
954 952
 						$content[$prop['name']] = $prop['val'];
955 953
 					}
@@ -962,9 +960,9 @@  discard block
 block discarded – undo
962 960
 			$content['tabs'] = $_GET['tabs'];
963 961
 			if (!($content['is_dir'] = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)))
964 962
 			{
965
-				$content['perms']['executable'] = (int)!!($content['mode'] & 0111);
963
+				$content['perms']['executable'] = (int)!!($content['mode']&0111);
966 964
 				$mask = 6;
967
-				if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000)
965
+				if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000)
968 966
 				{
969 967
 					$content['text_content'] = file_get_contents(egw_vfs::PREFIX.$path);
970 968
 				}
@@ -974,19 +972,19 @@  discard block
 block discarded – undo
974 972
 				//currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201);
975 973
 				$mask = 7;
976 974
 			}
977
-			foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift)
975
+			foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift)
978 976
 			{
979
-				$content['perms'][$name] = ($content['mode'] >> $shift) & $mask;
977
+				$content['perms'][$name] = ($content['mode'] >> $shift)&$mask;
980 978
 			}
981
-			$content['is_owner'] = egw_vfs::has_owner_rights($path,$content);
979
+			$content['is_owner'] = egw_vfs::has_owner_rights($path, $content);
982 980
 		}
983 981
 		else
984 982
 		{
985 983
 			//_debug_array($content);
986
-			$path =& $content['path'];
984
+			$path = & $content['path'];
987 985
 
988 986
 			list($button) = @each($content['button']); unset($content['button']);
989
-			if(!$button && $content['sudo'])
987
+			if (!$button && $content['sudo'])
990 988
 			{
991 989
 				// Button to stop sudo is not in button namespace
992 990
 				$button = 'sudo';
@@ -995,45 +993,45 @@  discard block
 block discarded – undo
995 993
 			// need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field
996 994
 			if ($button == 'sudo' && egw_vfs::$is_root || $button == 'setup' && $content['sudo']['user'])
997 995
 			{
998
-				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ?
996
+				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ?
999 997
 					lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ?
1000 998
 					lang('Wrong username or password!') : lang('Root access stopped.'));
1001 999
 				unset($content['sudo']);
1002 1000
 				$content['is_owner'] = egw_vfs::has_owner_rights($path);
1003 1001
 			}
1004
-			if (in_array($button,array('save','apply')))
1002
+			if (in_array($button, array('save', 'apply')))
1005 1003
 			{
1006 1004
 				$props = array();
1007 1005
 				$perm_changed = $perm_failed = 0;
1008
-				foreach($content['old'] as $name => $old_value)
1006
+				foreach ($content['old'] as $name => $old_value)
1009 1007
 				{
1010 1008
 					if (isset($content[$name]) && ($old_value != $content[$name] ||
1011 1009
 						// do not check for modification, if modify_subs is checked!
1012
-						$content['modify_subs'] && in_array($name,array('uid','gid','perms'))) &&
1010
+						$content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) &&
1013 1011
 						($name != 'uid' || egw_vfs::$is_root))
1014 1012
 					{
1015 1013
 						if ($name == 'name')
1016 1014
 						{
1017
-							$to = egw_vfs::concat(egw_vfs::dirname($path),$content['name']);
1015
+							$to = egw_vfs::concat(egw_vfs::dirname($path), $content['name']);
1018 1016
 							if (file_exists(egw_vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to)
1019 1017
 							{
1020
-								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1021
-									lang('To overwrite the existing file store again.',lang($button)));
1018
+								$tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'.
1019
+									lang('To overwrite the existing file store again.', lang($button)));
1022 1020
 								$content['confirm_overwrite'] = $to;
1023 1021
 								if ($button == 'save') $button = 'apply';
1024 1022
 								continue;
1025 1023
 							}
1026
-							if (egw_vfs::rename($path,$to))
1024
+							if (egw_vfs::rename($path, $to))
1027 1025
 							{
1028
-								$msg .= lang('Renamed %1 to %2.',egw_vfs::decodePath(basename($path)),egw_vfs::decodePath(basename($to))).' ';
1026
+								$msg .= lang('Renamed %1 to %2.', egw_vfs::decodePath(basename($path)), egw_vfs::decodePath(basename($to))).' ';
1029 1027
 								$content['old']['name'] = $content[$name];
1030 1028
 								$path = $to;
1031
-								$content['mime'] = mime_magic::filename2mime($path);	// recheck mime type
1032
-								$refresh_path = egw_vfs::dirname($path);	// for renames, we have to refresh the parent
1029
+								$content['mime'] = mime_magic::filename2mime($path); // recheck mime type
1030
+								$refresh_path = egw_vfs::dirname($path); // for renames, we have to refresh the parent
1033 1031
 							}
1034 1032
 							else
1035 1033
 							{
1036
-								$msg .= lang('Rename of %1 to %2 failed!',egw_vfs::decodePath(basename($path)),egw_vfs::decodePath(basename($to))).' ';
1034
+								$msg .= lang('Rename of %1 to %2 failed!', egw_vfs::decodePath(basename($path)), egw_vfs::decodePath(basename($to))).' ';
1037 1035
 								if (egw_vfs::deny_script($to))
1038 1036
 								{
1039 1037
 									$msg .= lang('You are NOT allowed to upload a script!').' ';
@@ -1053,7 +1051,7 @@  discard block
 block discarded – undo
1053 1051
 									'val'	=> (!empty($content[$name]) ? $content[$name] : null),
1054 1052
 								),
1055 1053
 							);
1056
-							if (egw_vfs::proppatch($path,$mergeprop))
1054
+							if (egw_vfs::proppatch($path, $mergeprop))
1057 1055
 							{
1058 1056
 								$content['old'][$name] = $content[$name];
1059 1057
 								$msg .= lang('Setting for document merge saved.');
@@ -1065,22 +1063,22 @@  discard block
 block discarded – undo
1065 1063
 						}
1066 1064
 						else
1067 1065
 						{
1068
-							static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod');
1069
-							$cmd = array('egw_vfs',$name2cmd[$name]);
1066
+							static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod');
1067
+							$cmd = array('egw_vfs', $name2cmd[$name]);
1070 1068
 							$value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name];
1071 1069
 							if ($content['modify_subs'])
1072 1070
 							{
1073 1071
 								if ($name == 'perms')
1074 1072
 								{
1075
-									$changed = egw_vfs::find($path,array('type'=>'d'),$cmd,array($value));
1076
-									$changed += egw_vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666));	// no execute for files
1073
+									$changed = egw_vfs::find($path, array('type'=>'d'), $cmd, array($value));
1074
+									$changed += egw_vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files
1077 1075
 								}
1078 1076
 								else
1079 1077
 								{
1080
-									$changed = egw_vfs::find($path,null,$cmd,array($value));
1078
+									$changed = egw_vfs::find($path, null, $cmd, array($value));
1081 1079
 								}
1082 1080
 								$ok = $failed = 0;
1083
-								foreach($changed as &$r)
1081
+								foreach ($changed as &$r)
1084 1082
 								{
1085 1083
 									if ($r)
1086 1084
 									{
@@ -1093,32 +1091,32 @@  discard block
 block discarded – undo
1093 1091
 								}
1094 1092
 								if ($ok && !$failed)
1095 1093
 								{
1096
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1094
+									if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren'));
1097 1095
 									$content['old'][$name] = $content[$name];
1098 1096
 								}
1099
-								elseif($failed)
1097
+								elseif ($failed)
1100 1098
 								{
1101
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1102
-										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1099
+									if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren').
1100
+										($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : ''));
1103 1101
 								}
1104 1102
 							}
1105
-							elseif (call_user_func_array($cmd,array($path,$value)))
1103
+							elseif (call_user_func_array($cmd, array($path, $value)))
1106 1104
 							{
1107
-								$msg .= lang('Permissions of %1 changed.',$path);
1105
+								$msg .= lang('Permissions of %1 changed.', $path);
1108 1106
 								$content['old'][$name] = $content[$name];
1109 1107
 							}
1110 1108
 							else
1111 1109
 							{
1112
-								$msg .= lang('Failed to change permissions of %1!',$path);
1110
+								$msg .= lang('Failed to change permissions of %1!', $path);
1113 1111
 							}
1114 1112
 						}
1115 1113
 					}
1116 1114
 				}
1117 1115
 				if ($props)
1118 1116
 				{
1119
-					if (egw_vfs::proppatch($path,$props))
1117
+					if (egw_vfs::proppatch($path, $props))
1120 1118
 					{
1121
-						foreach($props as $prop)
1119
+						foreach ($props as $prop)
1122 1120
 						{
1123 1121
 							$content['old'][$prop['name']] = $prop['val'];
1124 1122
 						}
@@ -1135,8 +1133,8 @@  discard block
 block discarded – undo
1135 1133
 				if ($content['eacl']['delete'])
1136 1134
 				{
1137 1135
 					list($ino_owner) = each($content['eacl']['delete']);
1138
-					list(, $owner) = explode('-',$ino_owner,2);	// $owner is a group and starts with a minus!
1139
-					$msg .= egw_vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1136
+					list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus!
1137
+					$msg .= egw_vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1140 1138
 				}
1141 1139
 				elseif ($button == 'eacl')
1142 1140
 				{
@@ -1146,7 +1144,7 @@  discard block
 block discarded – undo
1146 1144
 					}
1147 1145
 					else
1148 1146
 					{
1149
-						$msg .= egw_vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ?
1147
+						$msg .= egw_vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ?
1150 1148
 							lang('ACL added.') : lang('Error adding the ACL!');
1151 1149
 					}
1152 1150
 				}
@@ -1156,7 +1154,7 @@  discard block
 block discarded – undo
1156 1154
 		}
1157 1155
 		if ($content['is_link'] && !egw_vfs::stat($path))
1158 1156
 		{
1159
-			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']);
1157
+			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']);
1160 1158
 		}
1161 1159
 		$content['link'] = egw::link(egw_vfs::download_url($path));
1162 1160
 		$content['icon'] = egw_vfs::mime_icon($content['mime']);
@@ -1165,10 +1163,10 @@  discard block
 block discarded – undo
1165 1163
 		if (($readonlys['uid'] = !egw_vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1166 1164
 		// only owner can change group & perms
1167 1165
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1168
-			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs'))	// no uid, gid or perms in oldvfs
1166
+			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs'))	// no uid, gid or perms in oldvfs
1169 1167
 		{
1170 1168
 			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1171
-			foreach($content['perms'] as $name => $value)
1169
+			foreach ($content['perms'] as $name => $value)
1172 1170
 			{
1173 1171
 				$readonlys['perms['.$name.']'] = true;
1174 1172
 			}
@@ -1186,37 +1184,37 @@  discard block
 block discarded – undo
1186 1184
 		}
1187 1185
 		elseif (!egw_vfs::is_writable($path))
1188 1186
 		{
1189
-			foreach($cfs as $name => $data)
1187
+			foreach ($cfs as $name => $data)
1190 1188
 			{
1191 1189
 				$readonlys['#'.$name] = true;
1192 1190
 			}
1193 1191
 		}
1194
-		$readonlys['tabs']['filemanager.file.eacl'] = true;	// eacl off by default
1192
+		$readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default
1195 1193
 		if ($content['is_dir'])
1196 1194
 		{
1197
-			$readonlys['tabs']['filemanager.file.preview'] = true;	// no preview tab for dirs
1198
-			$sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1195
+			$readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs
1196
+			$sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1199 1197
 				7 => lang('Display and modification of content'),
1200 1198
 				5 => lang('Display of content'),
1201 1199
 				0 => lang('No access'),
1202 1200
 			);
1203
-			if(($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)	// backend supports eacl
1201
+			if (($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)	// backend supports eacl
1204 1202
 			{
1205
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1206
-				foreach($content['eacl'] as &$eacl)
1203
+				unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again
1204
+				foreach ($content['eacl'] as &$eacl)
1207 1205
 				{
1208
-					$eacl['path'] = rtrim(egw_vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
1206
+					$eacl['path'] = rtrim(egw_vfs::parse_url($eacl['path'], PHP_URL_PATH), '/');
1209 1207
 					$readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] ||
1210 1208
 						$eacl['path'] != $content['path'] || !$content['is_owner'];
1211 1209
 				}
1212
-				array_unshift($content['eacl'],false);	// make the keys start with 1, not 0
1210
+				array_unshift($content['eacl'], false); // make the keys start with 1, not 0
1213 1211
 				$content['eacl']['owner'] = 0;
1214 1212
 				$content['eacl']['rights'] = 5;
1215 1213
 			}
1216 1214
 		}
1217 1215
 		else
1218 1216
 		{
1219
-			$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1217
+			$sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1220 1218
 				6 => lang('Read & write access'),
1221 1219
 				4 => lang('Read access only'),
1222 1220
 				0 => lang('No access'),
@@ -1226,11 +1224,11 @@  discard block
 block discarded – undo
1226 1224
 		// mergeapp
1227 1225
 		$content['mergeapp'] = static::get_mergeapp($path, 'self');
1228 1226
 		$content['mergeapp_parent'] = static::get_mergeapp($path, 'parents');
1229
-		if(!empty($content['mergeapp']))
1227
+		if (!empty($content['mergeapp']))
1230 1228
 		{
1231 1229
 			$content['mergeapp_effective'] = $content['mergeapp'];
1232 1230
 		}
1233
-		elseif(!empty($content['mergeapp_parent']))
1231
+		elseif (!empty($content['mergeapp_parent']))
1234 1232
 		{
1235 1233
 			$content['mergeapp_effective'] = $content['mergeapp_parent'];
1236 1234
 		}
@@ -1242,7 +1240,7 @@  discard block
 block discarded – undo
1242 1240
 		$mergeapp_list = egw_link::app_list('merge');
1243 1241
 		unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list
1244 1242
 		$mergeapp_empty = !empty($content['mergeapp_parent'])
1245
-			? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : '';
1243
+			? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : '';
1246 1244
 		$sel_options['mergeapp'] = array(''	=> $mergeapp_empty);
1247 1245
 		$sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list;
1248 1246
 		// mergeapp other gui options
@@ -1259,7 +1257,7 @@  discard block
 block discarded – undo
1259 1257
 				'comment' => (string)$content['comment'],
1260 1258
 				'mergeapp' => $content['mergeapp']
1261 1259
 			);
1262
-			if ($cfs) foreach($cfs as $name => $data)
1260
+			if ($cfs) foreach ($cfs as $name => $data)
1263 1261
 			{
1264 1262
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1265 1263
 			}
@@ -1267,26 +1265,26 @@  discard block
 block discarded – undo
1267 1265
 		if (egw_vfs::$is_root)
1268 1266
 		{
1269 1267
 			$tpl->setElementAttribute('sudouser', 'label', 'Logout');
1270
-			$tpl->setElementAttribute('sudouser', 'help','Log out as superuser');
1268
+			$tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser');
1271 1269
 			// Need a more complex submit because button type is buttononly, which doesn't submit
1272
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")');
1270
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")');
1273 1271
 
1274 1272
 		}
1275 1273
 		elseif ($button == 'sudo')
1276 1274
 		{
1277 1275
 			$tpl->setElementAttribute('sudouser', 'label', 'Superuser');
1278
-			$tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights');
1279
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")');
1276
+			$tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights');
1277
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")');
1280 1278
 		}
1281
-		if (($extra_tabs = egw_vfs::getExtraInfo($path,$content)))
1279
+		if (($extra_tabs = egw_vfs::getExtraInfo($path, $content)))
1282 1280
 		{
1283 1281
 			// add to existing tabs in template
1284 1282
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1285 1283
 
1286
-			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1284
+			$tabs = & $tpl->getElementAttribute('tabs', 'tabs');
1287 1285
 			if (true) $tabs = array();
1288 1286
 
1289
-			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1287
+			foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1290 1288
 			{
1291 1289
 				$tabs[] = array(
1292 1290
 					'label' =>	$extra_tab['label'],
@@ -1309,7 +1307,7 @@  discard block
 block discarded – undo
1309 1307
 		egw_framework::window_focus();
1310 1308
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.egw_vfs::decodePath($path);
1311 1309
 
1312
-		$tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2);
1310
+		$tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2);
1313 1311
 	}
1314 1312
 
1315 1313
 	/**
@@ -1320,10 +1318,10 @@  discard block
 block discarded – undo
1320 1318
 	 * @param string $dir=null current directory
1321 1319
 	 * @see static::action()
1322 1320
 	 */
1323
-	public static function ajax_action($action, $selected, $dir=null, $props=null)
1321
+	public static function ajax_action($action, $selected, $dir = null, $props = null)
1324 1322
 	{
1325 1323
 		// do we have root rights, need to run here too, as method is static and therefore does NOT run __construct
1326
-		if (egw_session::appsession('is_root','filemanager'))
1324
+		if (egw_session::appsession('is_root', 'filemanager'))
1327 1325
 		{
1328 1326
 			egw_vfs::$is_root = true;
1329 1327
 		}
@@ -1339,15 +1337,15 @@  discard block
 block discarded – undo
1339 1337
 
1340 1338
 		if (!isset($dir)) $dir = array_pop($selected);
1341 1339
 
1342
-		switch($action)
1340
+		switch ($action)
1343 1341
 		{
1344 1342
 			case 'upload':
1345 1343
 				$script_error = 0;
1346
-				foreach($selected as $tmp_name => &$data)
1344
+				foreach ($selected as $tmp_name => &$data)
1347 1345
 				{
1348 1346
 					$path = egw_vfs::concat($dir, egw_vfs::encodePathComponent($data['name']));
1349 1347
 
1350
-					if(egw_vfs::deny_script($path))
1348
+					if (egw_vfs::deny_script($path))
1351 1349
 					{
1352 1350
 						if (!isset($script_error))
1353 1351
 						{
@@ -1369,7 +1367,7 @@  discard block
 block discarded – undo
1369 1367
 					{
1370 1368
 						if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
1371 1369
 						{
1372
-							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name);
1370
+							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name);
1373 1371
 						}
1374 1372
 						else
1375 1373
 						{
@@ -1404,16 +1402,16 @@  discard block
 block discarded – undo
1404 1402
 			case 'link':
1405 1403
 				// First upload
1406 1404
 				$arr = static::ajax_action('upload', $selected, $dir, $props);
1407
-				$app_dir = egw_link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true);
1405
+				$app_dir = egw_link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true);
1408 1406
 
1409
-				foreach($arr['uploaded'] as $file)
1407
+				foreach ($arr['uploaded'] as $file)
1410 1408
 				{
1411
-					$target=egw_vfs::concat($dir,egw_vfs::encodePathComponent($file['name']));
1409
+					$target = egw_vfs::concat($dir, egw_vfs::encodePathComponent($file['name']));
1412 1410
 					if (egw_vfs::file_exists($target) && $app_dir)
1413 1411
 					{
1414 1412
 						if (!egw_vfs::file_exists($app_dir)) egw_vfs::mkdir($app_dir);
1415 1413
 						error_log("Symlinking $target to $app_dir");
1416
-						egw_vfs::symlink($target, egw_vfs::concat($app_dir,egw_vfs::encodePathComponent($file['name'])));
1414
+						egw_vfs::symlink($target, egw_vfs::concat($app_dir, egw_vfs::encodePathComponent($file['name'])));
1417 1415
 					}
1418 1416
 				}
1419 1417
 				// Must return to avoid adding to $response again
@@ -1435,7 +1433,7 @@  discard block
 block discarded – undo
1435 1433
 	 */
1436 1434
 	private function perms2mode(array $perms)
1437 1435
 	{
1438
-		$mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other'];
1436
+		$mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other'];
1439 1437
 		if ($mode['executable'])
1440 1438
 		{
1441 1439
 			$mode |= 0111;
Please login to merge, or discard this patch.