Completed
Push — 14.2 ( 1730cb...8c75f3 )
by Ralf
73:29 queued 51:28
created
setup/inc/class.setup_detection.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@
 block discarded – undo
252 252
 	/**
253 253
 	 * Check if header exists and is up to date
254 254
 	 *
255
-	 * @return int 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok
255
+	 * @return string 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok
256 256
 	 */
257 257
 	function check_header()
258 258
 	{
Please login to merge, or discard this patch.
Braces   +20 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,7 +65,9 @@  discard block
 block discarded – undo
65 65
 					foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row)
66 66
 					{
67 67
 						$app = $row['app_name'];
68
-						if (!isset($setup_info[$app]))	// app source no longer there
68
+						if (!isset($setup_info[$app]))
69
+						{
70
+							// app source no longer there
69 71
 						{
70 72
 							$setup_info[$app] = array(
71 73
 								'name' => $app,
@@ -73,6 +75,7 @@  discard block
 block discarded – undo
73 75
 								'version' => 'deleted',
74 76
 							);
75 77
 						}
78
+						}
76 79
 						$setup_info[$app]['currentver'] = $row['app_version'];
77 80
 						$setup_info[$app]['enabled'] = $row['app_enabled'];
78 81
 					}
@@ -212,7 +215,9 @@  discard block
 block discarded – undo
212 215
 					if ($setup_info['depends'][$depkey]['status'] == False)
213 216
 					{
214 217
 						/* Only set this if it has not already failed to upgrade - Milosch */
215
-						if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
218
+						if($setup_info[$key]['status'] != 'F')
219
+						{
220
+							//&& $setup_info[$key]['status'] != 'C')
216 221
 						{
217 222
 							/* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install).
218 223
 							 * This should fix apps showing post-install dep failure when they are not yet installed.
@@ -220,6 +225,7 @@  discard block
 block discarded – undo
220 225
 							if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
221 226
 							{
222 227
 								$setup_info[$key]['status'] = 'D';
228
+						}
223 229
 							}
224 230
 							else
225 231
 							{
@@ -292,7 +298,10 @@  discard block
 block discarded – undo
292 298
 	 */
293 299
 	function check_db($setup_info=null)
294 300
 	{
295
-		if (!$setup_info) $setup_info = $GLOBALS['setup_info'];
301
+		if (!$setup_info)
302
+		{
303
+			$setup_info = $GLOBALS['setup_info'];
304
+		}
296 305
 
297 306
 		try {	// catch DB errors
298 307
 			if (!$GLOBALS['egw_setup']->db->Link_ID)
@@ -482,11 +491,14 @@  discard block
 block discarded – undo
482 491
 				{
483 492
 					echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val;
484 493
 				}
485
-				if(!in_array($val,$tables) && !in_array(strtolower($val),$tables))	// names in tables might be lowercase
494
+				if(!in_array($val,$tables) && !in_array(strtolower($val),$tables))
495
+				{
496
+					// names in tables might be lowercase
486 497
 				{
487 498
 					if($GLOBALS['DEBUG'])
488 499
 					{
489 500
 						echo '<br>check_app_tables(): ' . $val . ' missing!';
501
+				}
490 502
 					}
491 503
 					if(!$any)
492 504
 					{
@@ -543,9 +555,12 @@  discard block
 block discarded – undo
543 555
 			$msg = lang('does not exist');
544 556
 			return false;
545 557
 		}
546
-		if (!@is_writeable($dir) && $_SERVER['HTTP_HOST'])	// only do the check if we run by the webserver
558
+		if (!@is_writeable($dir) && $_SERVER['HTTP_HOST'])
559
+		{
560
+			// only do the check if we run by the webserver
547 561
 		{
548 562
 			$msg = lang('is not writeable by the webserver');
563
+		}
549 564
 			return false;
550 565
 		}
551 566
 		if ($check_in_docroot)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -464,7 +464,7 @@
 block discarded – undo
464 464
 		{
465 465
 			/* Make a copy, else we send some callers into an infinite loop */
466 466
 			$copy = $setup_info;
467
-			$tables = Array();
467
+			$tables = array();
468 468
 			try {
469 469
 				$table_names = $GLOBALS['egw_setup']->db->table_names();
470 470
 				foreach($table_names as $key => $val)
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 	{
26 26
 		$setup_info = array();
27 27
 		$d = dir(EGW_SERVER_ROOT);
28
-		while($entry=$d->read())
28
+		while ($entry = $d->read())
29 29
 		{
30
-			if($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT . '/' . $entry))
30
+			if ($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT.'/'.$entry))
31 31
 			{
32
-				$f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php';
33
-				if (@file_exists ($f))
32
+				$f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php';
33
+				if (@file_exists($f))
34 34
 				{
35 35
 					include($f);
36 36
 					$setup_info[$entry]['filename'] = $f;
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 	 * @param array $setup_info
51 51
 	 * @return array $setup_info
52 52
 	 */
53
-	function get_db_versions($setup_info=null)
53
+	function get_db_versions($setup_info = null)
54 54
 	{
55 55
 		try {	// catch DB errors
56 56
 			$GLOBALS['egw_setup']->set_table_names();
57 57
 
58
-			if($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table),true))
58
+			if ($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table), true))
59 59
 			{
60 60
 				/* one of these tables exists. checking for post/pre beta version */
61
-				if($GLOBALS['egw_setup']->applications_table != 'applications')
61
+				if ($GLOBALS['egw_setup']->applications_table != 'applications')
62 62
 				{
63
-					$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__);
64
-					while(@$GLOBALS['egw_setup']->db->next_record())
63
+					$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table, '*', false, __LINE__, __FILE__);
64
+					while (@$GLOBALS['egw_setup']->db->next_record())
65 65
 					{
66 66
 						$app = $GLOBALS['egw_setup']->db->f('app_name');
67 67
 						if (!isset($setup_info[$app]))	// app source no longer there
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 					}
78 78
 					/* This is to catch old setup installs that did not have phpgwapi listed as an app */
79 79
 					$tmp = @$setup_info['phpgwapi']['version']; /* save the file version */
80
-					if(!@$setup_info['phpgwapi']['currentver'])
80
+					if (!@$setup_info['phpgwapi']['currentver'])
81 81
 					{
82 82
 						$setup_info['phpgwapi']['currentver'] = $setup_info['admin']['currentver'];
83 83
 						$setup_info['phpgwapi']['version'] = $setup_info['admin']['currentver'];
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 				else
98 98
 				{
99 99
 					$GLOBALS['egw_setup']->db->query('select * from applications');
100
-					while(@$GLOBALS['egw_setup']->db->next_record())
100
+					while (@$GLOBALS['egw_setup']->db->next_record())
101 101
 					{
102
-						if($GLOBALS['egw_setup']->db->f('app_name') == 'admin')
102
+						if ($GLOBALS['egw_setup']->db->f('app_name') == 'admin')
103 103
 						{
104 104
 							$setup_info['phpgwapi']['currentver'] = $GLOBALS['egw_setup']->db->f('app_version');
105 105
 						}
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 	 * 	V	Version mismatch at end of upgrade (Not used, proposed only)
128 128
 	 * 	M	Missing files at start of upgrade (Not used, proposed only)
129 129
 	 */
130
-	function compare_versions($setup_info,$try_downgrade=false)
130
+	function compare_versions($setup_info, $try_downgrade = false)
131 131
 	{
132
-		foreach($setup_info as $key => $value)
132
+		foreach ($setup_info as $key => $value)
133 133
 		{
134 134
 			//echo '<br>'.$value['name'].'STATUS: '.$value['status'];
135 135
 			/* Only set this if it has not already failed to upgrade - Milosch */
136
-			if(!( (@$value['status'] == 'F') || (@$value['status'] == 'C') ))
136
+			if (!((@$value['status'] == 'F') || (@$value['status'] == 'C')))
137 137
 			{
138 138
 				//if ($setup_info[$key]['currentver'] > $setup_info[$key]['version'])
139
-				if(!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'],@$value['version']) ||
139
+				if (!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'], @$value['version']) ||
140 140
 					$value['version'] == 'deleted')
141 141
 				{
142 142
 					$setup_info[$key]['status'] = 'V';
143 143
 				}
144
-				elseif(@$value['currentver'] == @$value['version'])
144
+				elseif (@$value['currentver'] == @$value['version'])
145 145
 				{
146 146
 					$setup_info[$key]['status'] = 'C';
147 147
 				}
148
-				elseif($GLOBALS['egw_setup']->alessthanb(@$value['currentver'],@$value['version']))
148
+				elseif ($GLOBALS['egw_setup']->alessthanb(@$value['currentver'], @$value['version']))
149 149
 				{
150 150
 					$setup_info[$key]['status'] = 'U';
151 151
 				}
@@ -162,35 +162,35 @@  discard block
 block discarded – undo
162 162
 	function check_depends($setup_info)
163 163
 	{
164 164
 		/* Run the list of apps */
165
-		foreach($setup_info as $key => $value)
165
+		foreach ($setup_info as $key => $value)
166 166
 		{
167 167
 			/* Does this app have any depends */
168
-			if(isset($value['depends']))
168
+			if (isset($value['depends']))
169 169
 			{
170 170
 				/* If so find out which apps it depends on */
171
-				foreach($value['depends'] as $depkey => $depvalue)
171
+				foreach ($value['depends'] as $depkey => $depvalue)
172 172
 				{
173 173
 					/* I set this to False until we find a compatible version of this app */
174 174
 					$setup_info['depends'][$depkey]['status'] = False;
175 175
 					/* Now we loop thru the versions looking for a compatible version */
176 176
 
177
-					foreach($depvalue['versions'] as $depsvalue)
177
+					foreach ($depvalue['versions'] as $depsvalue)
178 178
 					{
179 179
 						$currentver = $setup_info[$depvalue['appname']]['currentver'];
180
-						if ($depvalue['appname'] == 'phpgwapi' && substr($currentver,0,6) == '0.9.99')
180
+						if ($depvalue['appname'] == 'phpgwapi' && substr($currentver, 0, 6) == '0.9.99')
181 181
 						{
182 182
 							$currentver = '0.9.14.508';
183 183
 						}
184 184
 						$major = $GLOBALS['egw_setup']->get_major($currentver);
185
-						if ($major >= $depsvalue || $major == $depsvalue && substr($major,0,strlen($depsvalue)+1) == $depsvalue.'.')
185
+						if ($major >= $depsvalue || $major == $depsvalue && substr($major, 0, strlen($depsvalue) + 1) == $depsvalue.'.')
186 186
 						{
187 187
 							$setup_info['depends'][$depkey]['status'] = True;
188 188
 						}
189 189
 						else	// check if majors are equal and minors greater or equal
190 190
 						{
191 191
 							$major_depsvalue = $GLOBALS['egw_setup']->get_major($depsvalue);
192
-							$tmp = explode('.',$depsvalue); $minor_depsvalue = array_pop($tmp);
193
-							$tmp2 = explode('.',$currentver); $minor = array_pop($tmp2);
192
+							$tmp = explode('.', $depsvalue); $minor_depsvalue = array_pop($tmp);
193
+							$tmp2 = explode('.', $currentver); $minor = array_pop($tmp2);
194 194
 							if ($major == $major_depsvalue && $minor <= $minor_depsvalue)
195 195
 							{
196 196
 								$setup_info['depends'][$depkey]['status'] = True;
@@ -203,17 +203,17 @@  discard block
 block discarded – undo
203 203
 				 Finally, we loop through the dependencies again to look for apps that still have a failure status
204 204
 				 If we find one, we set the apps overall status as a dependency failure.
205 205
 				*/
206
-				foreach($value['depends'] as $depkey => $depvalue)
206
+				foreach ($value['depends'] as $depkey => $depvalue)
207 207
 				{
208 208
 					if ($setup_info['depends'][$depkey]['status'] == False)
209 209
 					{
210 210
 						/* Only set this if it has not already failed to upgrade - Milosch */
211
-						if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
211
+						if ($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
212 212
 						{
213 213
 							/* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install).
214 214
 							 * This should fix apps showing post-install dep failure when they are not yet installed.
215 215
 							 */
216
-							if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
216
+							if ($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
217 217
 							{
218 218
 								$setup_info[$key]['status'] = 'D';
219 219
 							}
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 	 */
236 236
 	function upgrade_exclude($setup_info)
237 237
 	{
238
-		foreach($setup_info as $key => $value)
238
+		foreach ($setup_info as $key => $value)
239 239
 		{
240
-			if(isset($value['no_mass_update']))
240
+			if (isset($value['no_mass_update']))
241 241
 			{
242 242
 				unset($setup_info[$key]);
243 243
 			}
@@ -252,24 +252,24 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	function check_header()
254 254
 	{
255
-		if(!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200)
255
+		if (!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200)
256 256
 		{
257 257
 			$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One';
258 258
 			return '1';
259 259
 		}
260 260
 		else
261 261
 		{
262
-			if(!@isset($GLOBALS['egw_info']['server']['header_admin_password']))
262
+			if (!@isset($GLOBALS['egw_info']['server']['header_admin_password']))
263 263
 			{
264 264
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (No header admin password set)';
265 265
 				return '2';
266 266
 			}
267
-			elseif(!@isset($GLOBALS['egw_domain']))
267
+			elseif (!@isset($GLOBALS['egw_domain']))
268 268
 			{
269 269
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Add domains to your header.inc.php)';
270 270
 				return '3';
271 271
 			}
272
-			elseif(@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header'])
272
+			elseif (@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header'])
273 273
 			{
274 274
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)';
275 275
 				return '4';
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @param array $setup_info =null default use $GLOBALS['setup_info']
287 287
 	 * @return int 1=no database, 3=empty, 4=need upgrade, 10=complete
288 288
 	 */
289
-	function check_db($setup_info=null)
289
+	function check_db($setup_info = null)
290 290
 	{
291 291
 		if (!$setup_info) $setup_info = $GLOBALS['setup_info'];
292 292
 
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
 			if (!$GLOBALS['egw_setup']->db->Link_ID)
295 295
 			{
296 296
 				$old = error_reporting();
297
-				error_reporting($old & ~E_WARNING);	// no warnings
297
+				error_reporting($old&~E_WARNING); // no warnings
298 298
 				$GLOBALS['egw_setup']->db->connect();
299 299
 				error_reporting($old);
300 300
 
301 301
 				$GLOBALS['egw_setup']->set_table_names();
302 302
 			}
303 303
 		}
304
-		catch(egw_exception_db $e) {
304
+		catch (egw_exception_db $e) {
305 305
 			// ignore error
306 306
 		}
307 307
 
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
 			$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)';
311 311
 			return 1;
312 312
 		}
313
-		if(!isset($setup_info['phpgwapi']['currentver']))
313
+		if (!isset($setup_info['phpgwapi']['currentver']))
314 314
 		{
315 315
 			$setup_info = $this->get_db_versions($setup_info);
316 316
 		}
317 317
 		//_debug_array($setup_info);
318 318
 		if (isset($setup_info['phpgwapi']['currentver']))
319 319
 		{
320
-			if(@$setup_info['phpgwapi']['currentver'] == @$setup_info['phpgwapi']['version'])
320
+			if (@$setup_info['phpgwapi']['currentver'] == @$setup_info['phpgwapi']['version'])
321 321
 			{
322 322
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)';
323 323
 				return 10;
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	function check_config()
353 353
 	{
354
-		if(@$GLOBALS['egw_info']['setup']['stage']['db'] != 10)
354
+		if (@$GLOBALS['egw_info']['setup']['stage']['db'] != 10)
355 355
 		{
356 356
 			return '';
357 357
 		}
358 358
 
359 359
 		try {	// catch db errors
360
-			$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array('config_app' => 'phpgwapi'),__LINE__,__FILE__);
361
-			while($GLOBALS['egw_setup']->db->next_record())
360
+			$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table, 'config_name,config_value', array('config_app' => 'phpgwapi'), __LINE__, __FILE__);
361
+			while ($GLOBALS['egw_setup']->db->next_record())
362 362
 			{
363 363
 				$config[$GLOBALS['egw_setup']->db->f(0)] = $GLOBALS['egw_setup']->db->f(1);
364 364
 			}
@@ -368,23 +368,23 @@  discard block
 block discarded – undo
368 368
 			// ignore db errors
369 369
 		}
370 370
 		$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 2 (Needs Configuration)';
371
-		if(!count($config))
371
+		if (!count($config))
372 372
 		{
373 373
 			return 1;
374 374
 		}
375
-		$config_errors =& $GLOBALS['egw_info']['setup']['config_errors'];
375
+		$config_errors = & $GLOBALS['egw_info']['setup']['config_errors'];
376 376
 		$GLOBALS['egw_info']['setup']['config_errors'] = array();
377 377
 		$error_msg = null;
378
-		if (!$this->check_dir($config['temp_dir'],$error_msg))
378
+		if (!$this->check_dir($config['temp_dir'], $error_msg))
379 379
 		{
380
-			$config_errors[] = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg);
380
+			$config_errors[] = lang("Your temporary directory '%1' %2", $config['temp_dir'], $error_msg);
381 381
 		}
382 382
 
383 383
 		if ((!isset($config['file_repository']) || $config['file_repository'] == 'sql') &&
384 384
 			(!isset($config['file_store_contents']) || $config['file_store_contents'] == 'filesystem') &&
385
-			!$this->check_dir($config['files_dir'],$error_msg,true))
385
+			!$this->check_dir($config['files_dir'], $error_msg, true))
386 386
 		{
387
-			$config_errors[] = lang("Your files directory '%1' %2",$config['files_dir'],$error_msg);
387
+			$config_errors[] = lang("Your files directory '%1' %2", $config['files_dir'], $error_msg);
388 388
 		}
389 389
 		// set and create the default backup_dir
390 390
 		if (@is_writeable($config['files_dir']) && !$config['backup_dir'] && $config['file_store_contents'] == 'filesystem')
@@ -392,35 +392,35 @@  discard block
 block discarded – undo
392 392
 			$config['backup_dir'] = $config['files_dir'].'/db_backup';
393 393
 			if (!is_dir($config['backup_dir']) && mkdir($config['backup_dir']))
394 394
 			{
395
-				$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
395
+				$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
396 396
 					'config_value' => $config['backup_dir'],
397
-				),array(
397
+				), array(
398 398
 					'config_app'  => 'phpgwapi',
399 399
 					'config_name' => 'backup_dir',
400
-				),__LINE__,__FILE__);
400
+				), __LINE__, __FILE__);
401 401
 			}
402 402
 		}
403 403
 		if (isset($config['backup_mincount']))
404 404
 		{
405
-			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
405
+			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
406 406
 				'config_value' => $config['backup_mincount'],
407
-				),array(
407
+				), array(
408 408
 				'config_app'  => 'phpgwapi',
409 409
 				'config_name' => 'backup_mincount',
410
-			),__LINE__,__FILE__);
410
+			), __LINE__, __FILE__);
411 411
 		}
412 412
 		if (isset($config['backup_files']))
413 413
 		{
414
-			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
414
+			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
415 415
 				'config_value' => (int)$config['backup_files'],
416
-				),array(
416
+				), array(
417 417
 				'config_app'  => 'phpgwapi',
418 418
 				'config_name' => 'backup_files',
419
-			),__LINE__,__FILE__);
419
+			), __LINE__, __FILE__);
420 420
 		}
421
-		if (!$this->check_dir($config['backup_dir'],$error_msg,true))
421
+		if (!$this->check_dir($config['backup_dir'], $error_msg, true))
422 422
 		{
423
-			$config_errors[] = lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg);
423
+			$config_errors[] = lang("Your backup directory '%1' %2", $config['backup_dir'], $error_msg);
424 424
 		}
425 425
 		if ($config_errors)
426 426
 		{
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 
433 433
 	function check_lang($check = True)
434 434
 	{
435
-		if($check && $GLOBALS['egw_info']['setup']['stage']['db'] != 10)
435
+		if ($check && $GLOBALS['egw_info']['setup']['stage']['db'] != 10)
436 436
 		{
437 437
 			return '';
438 438
 		}
@@ -441,21 +441,21 @@  discard block
 block discarded – undo
441 441
 			$GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->get_db_versions($GLOBALS['setup_info']);
442 442
 		}
443 443
 		try {
444
-			$GLOBALS['egw_setup']->db->query($q = "SELECT DISTINCT lang FROM {$GLOBALS['egw_setup']->lang_table}",__LINE__,__FILE__);
444
+			$GLOBALS['egw_setup']->db->query($q = "SELECT DISTINCT lang FROM {$GLOBALS['egw_setup']->lang_table}", __LINE__, __FILE__);
445 445
 		}
446 446
 		catch (egw_exception_db $e) {
447 447
 			// ignore db error
448 448
 		}
449
-		if($e || $GLOBALS['egw_setup']->db->num_rows() == 0)
449
+		if ($e || $GLOBALS['egw_setup']->db->num_rows() == 0)
450 450
 		{
451 451
 			$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (No languages installed)';
452 452
 			return 1;
453 453
 		}
454
-		while(@$GLOBALS['egw_setup']->db->next_record())
454
+		while (@$GLOBALS['egw_setup']->db->next_record())
455 455
 		{
456 456
 			$GLOBALS['egw_info']['setup']['installed_langs'][$GLOBALS['egw_setup']->db->f('lang')] = $GLOBALS['egw_setup']->db->f('lang');
457 457
 		}
458
-		foreach($GLOBALS['egw_info']['setup']['installed_langs'] as $value)
458
+		foreach ($GLOBALS['egw_info']['setup']['installed_langs'] as $value)
459 459
 		{
460 460
 			$sql = "SELECT lang_name FROM {$GLOBALS['egw_setup']->languages_table} WHERE lang_id = '".$value."'";
461 461
 			$GLOBALS['egw_setup']->db->query($sql);
@@ -473,19 +473,19 @@  discard block
 block discarded – undo
473 473
 	 * @param $appname
474 474
 	 * @param $any		optional, set to True to see if any of the apps tables are installed
475 475
 	 */
476
-	function check_app_tables($appname,$any=False)
476
+	function check_app_tables($appname, $any = False)
477 477
 	{
478 478
 		$none = 0;
479 479
 		$setup_info = $GLOBALS['setup_info'];
480 480
 
481
-		if(@$setup_info[$appname]['tables'])
481
+		if (@$setup_info[$appname]['tables'])
482 482
 		{
483 483
 			/* Make a copy, else we send some callers into an infinite loop */
484 484
 			$copy = $setup_info;
485 485
 			$tables = Array();
486 486
 			try {
487 487
 				$table_names = $GLOBALS['egw_setup']->db->table_names();
488
-				foreach($table_names as $key => $val)
488
+				foreach ($table_names as $key => $val)
489 489
 				{
490 490
 					$tables[] = $val['table_name'];
491 491
 				}
@@ -494,19 +494,19 @@  discard block
 block discarded – undo
494 494
 				unset($e);
495 495
 				// ignore db error
496 496
 			}
497
-			foreach($copy[$appname]['tables'] as $key => $val)
497
+			foreach ($copy[$appname]['tables'] as $key => $val)
498 498
 			{
499
-				if($GLOBALS['DEBUG'])
499
+				if ($GLOBALS['DEBUG'])
500 500
 				{
501
-					echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val;
501
+					echo '<br>check_app_tables(): Checking: '.$appname.',table: '.$val;
502 502
 				}
503
-				if(!in_array($val,$tables) && !in_array(strtolower($val),$tables))	// names in tables might be lowercase
503
+				if (!in_array($val, $tables) && !in_array(strtolower($val), $tables))	// names in tables might be lowercase
504 504
 				{
505
-					if($GLOBALS['DEBUG'])
505
+					if ($GLOBALS['DEBUG'])
506 506
 					{
507
-						echo '<br>check_app_tables(): ' . $val . ' missing!';
507
+						echo '<br>check_app_tables(): '.$val.' missing!';
508 508
 					}
509
-					if(!$any)
509
+					if (!$any)
510 510
 					{
511 511
 						return False;
512 512
 					}
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
 				}
518 518
 				else
519 519
 				{
520
-					if($any)
520
+					if ($any)
521 521
 					{
522
-						if($GLOBALS['DEBUG'])
522
+						if ($GLOBALS['DEBUG'])
523 523
 						{
524 524
 							echo '<br>check_app_tables(): Some tables installed';
525 525
 						}
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 				}
529 529
 			}
530 530
 		}
531
-		if($none && $any)
531
+		if ($none && $any)
532 532
 		{
533
-			if($GLOBALS['DEBUG'])
533
+			if ($GLOBALS['DEBUG'])
534 534
 			{
535 535
 				echo '<br>check_app_tables(): No tables installed';
536 536
 			}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		}
539 539
 		else
540 540
 		{
541
-			if($GLOBALS['DEBUG'])
541
+			if ($GLOBALS['DEBUG'])
542 542
 			{
543 543
 				echo '<br>check_app_tables(): All tables installed';
544 544
 			}
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
 	 * @param boolean $check_in_docroot =false run an optional in docroot check
555 555
 	 * @return boolean
556 556
 	 */
557
-	static function check_dir($dir,&$msg,$check_in_docroot=false)
557
+	static function check_dir($dir, &$msg, $check_in_docroot = false)
558 558
 	{
559
-		if (!@is_dir($dir) && !@mkdir($dir,0700,true))
559
+		if (!@is_dir($dir) && !@mkdir($dir, 0700, true))
560 560
 		{
561 561
 			$msg = lang('does not exist');
562 562
 			return false;
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
 		}
569 569
 		if ($check_in_docroot)
570 570
 		{
571
-			$docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT']));
571
+			$docroots = array(realpath(EGW_SERVER_ROOT), realpath($_SERVER['DOCUMENT_ROOT']));
572 572
 			$dir = realpath($dir);
573 573
 
574 574
 			foreach ($docroots as $docroot)
575 575
 			{
576 576
 				$len = strlen($docroot);
577 577
 
578
-				if ($docroot == substr($dir,0,$len) && $len>0)
578
+				if ($docroot == substr($dir, 0, $len) && $len > 0)
579 579
 				{
580
-					$rest = substr($dir,$len);
580
+					$rest = substr($dir, $len);
581 581
 
582 582
 					if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR)
583 583
 					{
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_bo.inc.php 5 patches
Doc Comments   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @param statuses List of statuses to process, with sub-statuses in a 'substatus' array
263 263
 	 * @param labels Array of labels, pass array() and labels will be built in it
264
-	 * @param depth Current depth
264
+	 * @param depth integer depth
265 265
 	 *
266 266
 	 * @return None, labels are built in labels parameter
267 267
 	 */
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 *
306 306
 	 * @param array|int $data =null use $this->data or $this->data['ts_id'] (to fetch the data)
307 307
 	 * @param int $user =null for which user to check, default current user
308
-	 * @return boolean true if the rights are ok, false if no rights
308
+	 * @return null|boolean true if the rights are ok, false if no rights
309 309
 	 */
310 310
 	function check_statusForEditRights($data=null,$user=null)
311 311
 	{
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * @param int $required Acl::READ, EGW_ACL_WRITE, Acl::ADD, Acl::DELETE, EGW_ACL_BUDGET, EGW_ACL_EDIT_BUDGET
341 341
 	 * @param array|int $data =null project or project-id to use, default the project in $this->data
342 342
 	 * @param int $user =null for which user to check, default current user
343
-	 * @return boolean true if the rights are ok, null if not found, false if no rights
343
+	 * @return null|boolean true if the rights are ok, null if not found, false if no rights
344 344
 	 */
345 345
 	function check_acl($required,$data=null,$user=null)
346 346
 	{
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
398 398
 	 * @param boolean|string $only_keys =true True returns only keys, False returns all cols. comma seperated list of keys to return
399 399
 	 * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
400
-	 * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
400
+	 * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
401 401
 	 * @param string $wildcard ='' appended befor and after each criteria
402 402
 	 * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row
403 403
 	 * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
404
-	 * @param mixed $start =false if != false, return only maxmatch rows begining with start, or array($start,$num)
404
+	 * @param boolean $start =false if != false, return only maxmatch rows begining with start, or array($start,$num)
405 405
 	 * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
406 406
 	 * @param string $join ='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
407 407
 	 *	"LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
@@ -658,8 +658,6 @@  discard block
 block discarded – undo
658 658
 	 * delete / move all timesheets of a given user
659 659
 	 *
660 660
 	 * @param array $data
661
-	 * @param int $data['account_id'] owner to change
662
-	 * @param int $data['new_owner']  new owner or 0 for delete
663 661
 	 */
664 662
 	function deleteaccount($data)
665 663
 	{
@@ -686,7 +684,7 @@  discard block
 block discarded – undo
686 684
 	 *
687 685
 	 * @param array $keys =null if given array with col => value pairs to characterise single timesheet or null for $this->data
688 686
 	 * @param int $status =0
689
-	 * @return int affected rows, should be 1 if ok, 0 if an error
687
+	 * @return boolean affected rows, should be 1 if ok, 0 if an error
690 688
 	 */
691 689
 	function set_status($keys=null, $status=0)
692 690
 	{
@@ -816,7 +814,7 @@  discard block
 block discarded – undo
816 814
 	 * @param int $check Acl::READ for read and Acl::EDIT for write or delete access
817 815
 	 * @param string $rel_path =null currently not used in InfoLog
818 816
 	 * @param int $user =null for which user to check, default current user
819
-	 * @return boolean true if access is granted or false otherwise
817
+	 * @return null|boolean true if access is granted or false otherwise
820 818
 	 */
821 819
 	function file_access($id,$check,$rel_path=null,$user=null)
822 820
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -152,8 +152,8 @@
 block discarded – undo
152 152
 	const EXTRA_TABLE = 'egw_timesheet_extra';
153 153
 
154 154
 	/**
155
-	* Columns to search when user does a text search
156
-	*/
155
+	 * Columns to search when user does a text search
156
+	 */
157 157
 	var $columns_to_search = array('egw_timesheet.ts_id', 'ts_project', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_unitprice');
158 158
 
159 159
 	/**
Please login to merge, or discard this patch.
Braces   +78 added lines, -20 removed lines patch added patch discarded remove patch
@@ -167,12 +167,18 @@  discard block
 block discarded – undo
167 167
 	{
168 168
 		parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id');
169 169
 
170
-		if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value';
170
+		if ($this->customfields)
171
+		{
172
+			$this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value';
173
+		}
171 174
 		$this->config_data = Api\Config::read(TIMESHEET_APP);
172 175
 		$this->quantity_sum = $this->config_data['quantity_sum'] == 'true';
173 176
 
174 177
 		// Load & process statuses
175
-		if($this->config_data['status_labels']) $this->load_statuses();
178
+		if($this->config_data['status_labels'])
179
+		{
180
+			$this->load_statuses();
181
+		}
176 182
 
177 183
 		$this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now));
178 184
 
@@ -190,12 +196,16 @@  discard block
 block discarded – undo
190 196
 	protected function load_statuses()
191 197
 	{
192 198
 		$this->status_labels =&  $this->config_data['status_labels'];
193
-		if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels);
199
+		if (!is_array($this->status_labels))
200
+		{
201
+			$this->status_labels= array($this->status_labels);
202
+		}
194 203
 
195 204
 		foreach ($this->status_labels as $status_id => $label)
196 205
 		{
197 206
 			if (!is_array($label))
198
-			{	//old values, before parent status
207
+			{
208
+//old values, before parent status
199 209
 				$name = $label;
200 210
 				$label=array();
201 211
 				$label['name'] = $name;
@@ -243,7 +253,10 @@  discard block
 block discarded – undo
243 253
 	 */
244 254
 	function get_sub_status($status)
245 255
 	{
246
-		if (!isset($this->status_labels_config)) $this->load_statuses();
256
+		if (!isset($this->status_labels_config))
257
+		{
258
+			$this->load_statuses();
259
+		}
247 260
 		$stati = array($status);
248 261
 		foreach($this->status_labels_config as $stat)
249 262
 		{
@@ -319,9 +332,16 @@  discard block
 block discarded – undo
319 332
 			$data = $this->read($data,true);
320 333
 			$this->data = $save_data;
321 334
 
322
-			if (!$data) return null; 	// entry not found
335
+			if (!$data)
336
+			{
337
+				return null;
338
+			}
339
+			// entry not found
340
+		}
341
+		if (!$user)
342
+		{
343
+			$user = $this->user;
323 344
 		}
324
-		if (!$user) $user = $this->user;
325 345
 		if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status'])
326 346
 		{
327 347
 			if ($this->status_labels_config[$data['ts_status']]['admin'])
@@ -354,9 +374,16 @@  discard block
 block discarded – undo
354 374
 			$data = $this->read($data,true);
355 375
 			$this->data = $save_data;
356 376
 
357
-			if (!$data) return null; 	// entry not found
377
+			if (!$data)
378
+			{
379
+				return null;
380
+			}
381
+			// entry not found
382
+		}
383
+		if (!$user)
384
+		{
385
+			$user = $this->user;
358 386
 		}
359
-		if (!$user) $user = $this->user;
360 387
 		if ($user == $this->user)
361 388
 		{
362 389
 			$grants = $this->grants;
@@ -430,7 +457,10 @@  discard block
 block discarded – undo
430 457
 		}
431 458
 		else
432 459
 		{
433
-			if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
460
+			if (!is_array($filter['ts_owner']))
461
+			{
462
+				$filter['ts_owner'] = array($filter['ts_owner']);
463
+			}
434 464
 
435 465
 			foreach($filter['ts_owner'] as $key => $owner)
436 466
 			{
@@ -485,7 +515,10 @@  discard block
 block discarded – undo
485 515
 		$this->summary = $this->summary[0];
486 516
 		$this->summary['max_modified'] = Api\DateTime::server2user($this->summary['max_modified']);
487 517
 
488
-		if ($only_summary) return $this->summary;
518
+		if ($only_summary)
519
+		{
520
+			return $this->summary;
521
+		}
489 522
 
490 523
 		if ($this->show_sums && strpos($order_by,'ts_start') !== false && 	// sums only make sense if ordered by ts_start
491 524
 			$this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start')))
@@ -561,7 +594,10 @@  discard block
 block discarded – undo
561 594
 	 */
562 595
 	function save($keys=null,$touch_modified=true,$ignore_acl=false)
563 596
 	{
564
-		if ($keys) $this->data_merge($keys);
597
+		if ($keys)
598
+		{
599
+			$this->data_merge($keys);
600
+		}
565 601
 
566 602
 		if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(Acl::EDIT))
567 603
 		{
@@ -583,10 +619,13 @@  discard block
 block discarded – undo
583 619
 			$old =& $this->data;
584 620
 			$this->data =& $new;
585 621
 			$changed = array();
586
-			if (isset($old)) foreach($old as $name => $value)
622
+			if (isset($old))
623
+			{
624
+				foreach($old as $name => $value)
587 625
 			{
588 626
 				if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name;
589 627
 			}
628
+			}
590 629
 		}
591 630
 		if (isset($old) && !$changed)
592 631
 		{
@@ -703,7 +742,10 @@  discard block
 block discarded – undo
703 742
 		}
704 743
 
705 744
 		$this->data['ts_status'] = $status;
706
-		if ($this->save($ts_id)!=0) $ret = false;
745
+		if ($this->save($ts_id)!=0)
746
+		{
747
+			$ret = false;
748
+		}
707 749
 
708 750
 		return $ret;
709 751
 	}
@@ -747,10 +789,13 @@  discard block
 block discarded – undo
747 789
 			return $entry;
748 790
 		}
749 791
 		$format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
750
-		if (date('H:i',$entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
792
+		if (date('H:i',$entry['ts_start']) != '00:00')
793
+		{
794
+			// dont show 00:00 time, as it means date only
751 795
 		{
752 796
 			$format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i');
753 797
 		}
798
+		}
754 799
 		return date($format,$entry['ts_start']).': '.$entry['ts_title'];
755 800
 	}
756 801
 
@@ -796,14 +841,18 @@  discard block
 block discarded – undo
796 841
 	{
797 842
 		$limit = false;
798 843
 		$need_count = false;
799
-		if($options['start'] || $options['num_rows']) {
844
+		if($options['start'] || $options['num_rows'])
845
+		{
800 846
 			$limit = array($options['start'], $options['num_rows']);
801 847
 			$need_count = true;
802 848
 		}
803 849
 		$result = array();
804 850
 		foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts )
805 851
 		{
806
-			if ($ts) $result[$ts['ts_id']] = $this->link_title($ts);
852
+			if ($ts)
853
+			{
854
+				$result[$ts['ts_id']] = $this->link_title($ts);
855
+			}
807 856
 		}
808 857
 		$options['total'] = $need_count ? $this->total : count($result);
809 858
 		return $result;
@@ -922,7 +971,10 @@  discard block
 block discarded – undo
922 971
 				//error_log(__METHOD__."() setting pm_id=$pm_id --> ".array2string($update));
923 972
 			}
924 973
 		}
925
-		if ($backup) $this->data = $backup;
974
+		if ($backup)
975
+		{
976
+			$this->data = $backup;
977
+		}
926 978
 	}
927 979
 
928 980
 
@@ -947,7 +999,10 @@  discard block
 block discarded – undo
947 999
 			$first_pm_id = null;
948 1000
 			foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
949 1001
 			{
950
-				if (!isset($first_pm_id)) $first_pm_id = $pm_id;
1002
+				if (!isset($first_pm_id))
1003
+				{
1004
+					$first_pm_id = $pm_id;
1005
+				}
951 1006
 				if ($data['ts_project'] == Link::title('projectmanager', $pm_id))
952 1007
 				{
953 1008
 					$data['pm_id'] = $pm_id;
@@ -956,7 +1011,10 @@  discard block
 block discarded – undo
956 1011
 					break;
957 1012
 				}
958 1013
 			}
959
-			if (!isset($data['pm_id']) && isset($first_pm_id)) $data['pm_id'] = $first_pm_id;
1014
+			if (!isset($data['pm_id']) && isset($first_pm_id))
1015
+			{
1016
+				$data['pm_id'] = $first_pm_id;
1017
+			}
960 1018
 		}
961 1019
 		elseif ($data['ts_id'] && $data['pm_id'] && Link::title('projectmanager', $data['pm_id']) == $data['ts_project'])
962 1020
 		{
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 if (!defined('TIMESHEET_APP'))
14 14
 {
15
-	define('TIMESHEET_APP','timesheet');
15
+	define('TIMESHEET_APP', 'timesheet');
16 16
 }
17 17
 
18 18
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @var boolean
41 41
 	 */
42
-	var $quantity_sum=false;
42
+	var $quantity_sum = false;
43 43
 	/**
44 44
 	 * current user
45 45
 	 *
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @var array
53 53
 	 */
54 54
 	var $timestamps = array(
55
-		'ts_start','ts_modified'
55
+		'ts_start', 'ts_modified'
56 56
 	);
57 57
 	/**
58 58
 	 * Start of today in user-time
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 	 * @var array
67 67
 	 */
68 68
 	var $date_filters = array(	// Start: year,month,day,week, End: year,month,day,week
69
-		'Today'       => array(0,0,0,0,  0,0,1,0),
70
-		'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
71
-		'This week'   => array(0,0,0,0,  0,0,0,1),
72
-		'Last week'   => array(0,0,0,-1, 0,0,0,0),
73
-		'This month'  => array(0,0,0,0,  0,1,0,0),
74
-		'Last month'  => array(0,-1,0,0, 0,0,0,0),
75
-		'2 month ago' => array(0,-2,0,0, 0,-1,0,0),
76
-		'This year'   => array(0,0,0,0,  1,0,0,0),
77
-		'Last year'   => array(-1,0,0,0, 0,0,0,0),
78
-		'2 years ago' => array(-2,0,0,0, -1,0,0,0),
79
-		'3 years ago' => array(-3,0,0,0, -2,0,0,0),
69
+		'Today'       => array(0, 0, 0, 0, 0, 0, 1, 0),
70
+		'Yesterday'   => array(0, 0, -1, 0, 0, 0, 0, 0),
71
+		'This week'   => array(0, 0, 0, 0, 0, 0, 0, 1),
72
+		'Last week'   => array(0, 0, 0, -1, 0, 0, 0, 0),
73
+		'This month'  => array(0, 0, 0, 0, 0, 1, 0, 0),
74
+		'Last month'  => array(0, -1, 0, 0, 0, 0, 0, 0),
75
+		'2 month ago' => array(0, -2, 0, 0, 0, -1, 0, 0),
76
+		'This year'   => array(0, 0, 0, 0, 1, 0, 0, 0),
77
+		'Last year'   => array(-1, 0, 0, 0, 0, 0, 0, 0),
78
+		'2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0),
79
+		'3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0),
80 80
 	);
81 81
 	/**
82 82
 	 * Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @var array
103 103
 	 */
104
-	var $customfields=array();
104
+	var $customfields = array();
105 105
 	/**
106 106
 	 * Array with status label
107 107
 	 *
@@ -161,21 +161,21 @@  discard block
 block discarded – undo
161 161
 
162 162
 	function __construct()
163 163
 	{
164
-		parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id');
164
+		parent::__construct(TIMESHEET_APP, 'egw_timesheet', self::EXTRA_TABLE, '', 'ts_extra_name', 'ts_extra_value', 'ts_id');
165 165
 
166 166
 		if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value';
167 167
 		$this->config_data = config::read(TIMESHEET_APP);
168 168
 		$this->quantity_sum = $this->config_data['quantity_sum'] == 'true';
169 169
 
170 170
 		// Load & process statuses
171
-		if($this->config_data['status_labels']) $this->load_statuses();
171
+		if ($this->config_data['status_labels']) $this->load_statuses();
172 172
 
173
-		$this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now));
173
+		$this->today = mktime(0, 0, 0, date('m', $this->now), date('d', $this->now), date('Y', $this->now));
174 174
 
175 175
 		// save us in $GLOBALS['timesheet_bo'] for ExecMethod used in hooks
176 176
 		if (!is_object($GLOBALS['timesheet_bo']))
177 177
 		{
178
-			$GLOBALS['timesheet_bo'] =& $this;
178
+			$GLOBALS['timesheet_bo'] = & $this;
179 179
 		}
180 180
 		$this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
181 181
 	}
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	protected function load_statuses()
187 187
 	{
188
-		$this->status_labels =&  $this->config_data['status_labels'];
189
-		if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels);
188
+		$this->status_labels = &  $this->config_data['status_labels'];
189
+		if (!is_array($this->status_labels)) $this->status_labels = array($this->status_labels);
190 190
 
191 191
 		foreach ($this->status_labels as $status_id => $label)
192 192
 		{
193 193
 			if (!is_array($label))
194 194
 			{	//old values, before parent status
195 195
 				$name = $label;
196
-				$label=array();
196
+				$label = array();
197 197
 				$label['name'] = $name;
198 198
 				$label['parent'] = '';
199 199
 			}
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 		$map = array(
206 206
 			'' => array('substatus' => array())
207 207
 		);
208
-		foreach($this->status_labels_config as $id => &$status)
208
+		foreach ($this->status_labels_config as $id => &$status)
209 209
 		{
210 210
 			$status['substatus'] = array();
211 211
 			$map[$id] = &$status;
212 212
 		}
213
-		foreach($this->status_labels_config as &$status)
213
+		foreach ($this->status_labels_config as &$status)
214 214
 		{
215 215
 			$map[$status['parent']]['substatus'][] = &$status;
216 216
 		}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 
223 223
 		// Sort config based on tree
224 224
 		$sorted = array();
225
-		foreach($this->status_labels as $status_id => $label)
225
+		foreach ($this->status_labels as $status_id => $label)
226 226
 		{
227 227
 			$sorted[$status_id] = $this->status_labels_config[$status_id];
228 228
 			//$sorted[$status_id]['name'] = $label;
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	{
242 242
 		if (!isset($this->status_labels_config)) $this->load_statuses();
243 243
 		$stati = array($status);
244
-		foreach($this->status_labels_config as $stat)
244
+		foreach ($this->status_labels_config as $stat)
245 245
 		{
246 246
 			if ($stat['parent'] && in_array($stat['parent'], $stati))
247 247
 			{
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return None, labels are built in labels parameter
263 263
 	 */
264
-	protected function make_status_labels($statuses, &$labels, $depth=0)
264
+	protected function make_status_labels($statuses, &$labels, $depth = 0)
265 265
 	{
266
-		foreach($statuses as $status)
266
+		foreach ($statuses as $status)
267 267
 		{
268
-			$labels[$status['id']] = str_pad('',$depth*12, "&nbsp;",STR_PAD_LEFT).trim(str_replace('&nbsp;','',$status['name']));
269
-			if(count($status['substatus']) > 0)
268
+			$labels[$status['id']] = str_pad('', $depth * 12, "&nbsp;", STR_PAD_LEFT).trim(str_replace('&nbsp;', '', $status['name']));
269
+			if (count($status['substatus']) > 0)
270 270
 			{
271
-				$this->make_status_labels($status['substatus'], $labels, $depth+1);
271
+				$this->make_status_labels($status['substatus'], $labels, $depth + 1);
272 272
 			}
273 273
 		}
274 274
 	}
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	 * @param int $required =EGW_ACL_READ
280 280
 	 * @return array with uid => Username pairs
281 281
 	 */
282
-	function grant_list($required=EGW_ACL_READ)
282
+	function grant_list($required = EGW_ACL_READ)
283 283
 	{
284 284
 		$result = array();
285
-		foreach($this->grants as $uid => $grant)
285
+		foreach ($this->grants as $uid => $grant)
286 286
 		{
287
-			if ($grant & $required)
287
+			if ($grant&$required)
288 288
 			{
289 289
 				$result[$uid] = common::grab_owner_name($uid);
290 290
 			}
@@ -303,19 +303,19 @@  discard block
 block discarded – undo
303 303
 	 * @param int $user =null for which user to check, default current user
304 304
 	 * @return boolean true if the rights are ok, false if no rights
305 305
 	 */
306
-	function check_statusForEditRights($data=null,$user=null)
306
+	function check_statusForEditRights($data = null, $user = null)
307 307
 	{
308 308
 		if (is_null($data) || (int)$data == $this->data['ts_id'])
309 309
 		{
310
-			$data =& $this->data;
310
+			$data = & $this->data;
311 311
 		}
312 312
 		if (!is_array($data))
313 313
 		{
314 314
 			$save_data = $this->data;
315
-			$data = $this->read($data,true);
315
+			$data = $this->read($data, true);
316 316
 			$this->data = $save_data;
317 317
 
318
-			if (!$data) return null; 	// entry not found
318
+			if (!$data) return null; // entry not found
319 319
 		}
320 320
 		if (!$user) $user = $this->user;
321 321
 		if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status'])
@@ -338,19 +338,19 @@  discard block
 block discarded – undo
338 338
 	 * @param int $user =null for which user to check, default current user
339 339
 	 * @return boolean true if the rights are ok, null if not found, false if no rights
340 340
 	 */
341
-	function check_acl($required,$data=null,$user=null)
341
+	function check_acl($required, $data = null, $user = null)
342 342
 	{
343 343
 		if (is_null($data) || (int)$data == $this->data['ts_id'])
344 344
 		{
345
-			$data =& $this->data;
345
+			$data = & $this->data;
346 346
 		}
347 347
 		if (!is_array($data))
348 348
 		{
349 349
 			$save_data = $this->data;
350
-			$data = $this->read($data,true);
350
+			$data = $this->read($data, true);
351 351
 			$this->data = $save_data;
352 352
 
353
-			if (!$data) return null; 	// entry not found
353
+			if (!$data) return null; // entry not found
354 354
 		}
355 355
 		if (!$user) $user = $this->user;
356 356
 		if ($user == $this->user)
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 		}
360 360
 		else
361 361
 		{
362
-			$grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP,true,$user);
362
+			$grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP, true, $user);
363 363
 		}
364
-		$ret = $data && !!($grants[$data['ts_owner']] & $required);
364
+		$ret = $data && !!($grants[$data['ts_owner']]&$required);
365 365
 
366
-		if(($required & EGW_ACL_DELETE) && $this->config_data['history'] == 'history' &&
366
+		if (($required&EGW_ACL_DELETE) && $this->config_data['history'] == 'history' &&
367 367
 			$data['ts_status'] == self::DELETED_STATUS)
368 368
 		{
369 369
 			$ret = !!($GLOBALS['egw_info']['user']['apps']['admin']);
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 * @param int &$end
381 381
 	 * @return string
382 382
 	 */
383
-	function date_filter($name,&$start,&$end)
383
+	function date_filter($name, &$start, &$end)
384 384
 	{
385 385
 		return egw_time::sql_filter($name, $start, $end, 'ts_start', $this->date_filters);
386 386
 	}
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @param boolean $only_summary =false If true only return the sums as array with keys duration and price, default false
406 406
 	 * @return array of matching rows (the row is an array of the cols) or False
407 407
 	 */
408
-	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false,$only_summary=false)
408
+	function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $need_full_no_count = false, $only_summary = false)
409 409
 	{
410 410
 		//error_log(__METHOD__."(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')");
411 411
 		//echo "<p>".__METHOD__."(".print_r($criteria,true).",'$only_keys','$order_by',".print_r($extra_cols,true).",'$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
@@ -414,9 +414,9 @@  discard block
 block discarded – undo
414 414
 
415 415
 		if (!is_array($extra_cols))
416 416
 		{
417
-			$extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
417
+			$extra_cols = $extra_cols ? explode(',', $extra_cols) : array();
418 418
 		}
419
-		if ($only_keys === false || $this->show_sums && strpos($order_by,'ts_start') !== false)
419
+		if ($only_keys === false || $this->show_sums && strpos($order_by, 'ts_start') !== false)
420 420
 		{
421 421
 			$extra_cols[] = $total_sql.' AS ts_total';
422 422
 		}
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		{
429 429
 			if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
430 430
 
431
-			foreach($filter['ts_owner'] as $key => $owner)
431
+			foreach ($filter['ts_owner'] as $key => $owner)
432 432
 			{
433 433
 				if (!isset($this->grants[$owner]))
434 434
 				{
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 		}
443 443
 		else
444 444
 		{
445
-			$filter[] = '(ts_status ' . ($filter['ts_status'] == self::DELETED_STATUS ? '=':'!= ') . self::DELETED_STATUS .
446
-				($filter['ts_status'] == self::DELETED_STATUS ? '':' OR ts_status IS NULL') . ')';
445
+			$filter[] = '(ts_status '.($filter['ts_status'] == self::DELETED_STATUS ? '=' : '!= ').self::DELETED_STATUS.
446
+				($filter['ts_status'] == self::DELETED_STATUS ? '' : ' OR ts_status IS NULL').')';
447 447
 		}
448 448
 		if (!count($filter['ts_owner']))
449 449
 		{
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
 			$this->summary = array();
452 452
 			return array();
453 453
 		}
454
-		if ($only_summary==false && $criteria && $this->show_sums)
454
+		if ($only_summary == false && $criteria && $this->show_sums)
455 455
 		{
456 456
 			// if we have a criteria AND intend to show the sums we first query the affected ids,
457 457
 			// then we throw away criteria and filter, and replace the filter with the list of ids
458
-			$ids = parent::search($criteria,'egw_timesheet.ts_id as id','','',$wildcard,$empty,$op,false,$filter,$join);
458
+			$ids = parent::search($criteria, 'egw_timesheet.ts_id as id', '', '', $wildcard, $empty, $op, false, $filter, $join);
459 459
 			//_debug_array($ids);
460 460
 			if (empty($ids))
461 461
 			{
462
-				$this->summary = array('duration'=>0,'price'=>null,'quantity'=>0);
462
+				$this->summary = array('duration'=>0, 'price'=>null, 'quantity'=>0);
463 463
 				return array();
464 464
 			}
465 465
 			unset($criteria);
@@ -483,45 +483,45 @@  discard block
 block discarded – undo
483 483
 
484 484
 		if ($only_summary) return $this->summary;
485 485
 
486
-		if ($this->show_sums && strpos($order_by,'ts_start') !== false && 	// sums only make sense if ordered by ts_start
486
+		if ($this->show_sums && strpos($order_by, 'ts_start') !== false && // sums only make sense if ordered by ts_start
487 487
 			$this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start')))
488 488
 		{
489 489
 			$sum_sql = array(
490
-				'year'  => $this->db->date_format($from_unixtime_ts_start,'%Y'),
491
-				'month' => $this->db->date_format($from_unixtime_ts_start,'%Y%m'),
492
-				'week'  => $this->db->date_format($from_unixtime_ts_start,$GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'),
493
-				'day'   => $this->db->date_format($from_unixtime_ts_start,'%Y-%m-%d'),
490
+				'year'  => $this->db->date_format($from_unixtime_ts_start, '%Y'),
491
+				'month' => $this->db->date_format($from_unixtime_ts_start, '%Y%m'),
492
+				'week'  => $this->db->date_format($from_unixtime_ts_start, $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'),
493
+				'day'   => $this->db->date_format($from_unixtime_ts_start, '%Y-%m-%d'),
494 494
 			);
495
-			foreach($this->show_sums as $type)
495
+			foreach ($this->show_sums as $type)
496 496
 			{
497 497
 				$extra_cols[] = $sum_sql[$type].' AS ts_'.$type;
498 498
 				$extra_cols[] = '0 AS is_sum_'.$type;
499
-				$sum_extra_cols[] = str_replace('ts_start','MIN(ts_start)',$sum_sql[$type]);	// as we dont group by ts_start
499
+				$sum_extra_cols[] = str_replace('ts_start', 'MIN(ts_start)', $sum_sql[$type]); // as we dont group by ts_start
500 500
 				$sum_extra_cols[$type] = '0 AS is_sum_'.$type;
501 501
 			}
502 502
 			// regular entries
503
-			parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
503
+			parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count);
504 504
 
505
-			$sort = substr($order_by,8);
505
+			$sort = substr($order_by, 8);
506 506
 			$union_order = array();
507
-			$sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0);
508
-			foreach($this->show_sums as $type)
507
+			$sum_ts_id = array('year' => -3, 'month' => -2, 'week' => -1, 'day' => 0);
508
+			foreach ($this->show_sums as $type)
509 509
 			{
510
-				$union_order[] = 'ts_'.$type . ' ' . $sort;
510
+				$union_order[] = 'ts_'.$type.' '.$sort;
511 511
 				$union_order[] = 'is_sum_'.$type;
512 512
 				$sum_extra_cols[$type]{0} = '1';
513 513
 				// the $type sum
514
-				parent::search($criteria,array(
515
-					(string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration',
514
+				parent::search($criteria, array(
515
+					(string)$sum_ts_id[$type], "''", "''", "''", 'MIN(ts_start)', 'SUM(ts_duration) AS ts_duration',
516 516
 					($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'),
517
-					'0','NULL','0','0','0','0','0',"SUM($total_sql) AS ts_total"
518
-				),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
517
+					'0', 'NULL', '0', '0', '0', '0', '0', "SUM($total_sql) AS ts_total"
518
+				), 'GROUP BY '.$sum_sql[$type], $sum_extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count);
519 519
 				$sum_extra_cols[$type]{0} = '0';
520 520
 			}
521 521
 			$union_order[] = 'ts_start '.$sort;
522
-			return parent::search('','',implode(',',$union_order),'','',false,'',$start);
522
+			return parent::search('', '', implode(',', $union_order), '', '', false, '', $start);
523 523
 		}
524
-		return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
524
+		return parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count);
525 525
 	}
526 526
 
527 527
 	/**
@@ -531,16 +531,16 @@  discard block
 block discarded – undo
531 531
 	 * @param boolean $ignore_acl =false should the acl be checked
532 532
 	 * @return array|boolean array with timesheet entry, null if timesheet not found or false if no rights
533 533
 	 */
534
-	function read($ts_id,$ignore_acl=false)
534
+	function read($ts_id, $ignore_acl = false)
535 535
 	{
536 536
 		//error_log(__METHOD__."($ts_id,$ignore_acl) ".function_backtrace());
537 537
 		if (!(int)$ts_id || (int)$ts_id != $this->data['ts_id'] && !parent::read($ts_id))
538 538
 		{
539
-			return null;	// entry not found
539
+			return null; // entry not found
540 540
 		}
541 541
 		if (!$ignore_acl && !($ret = $this->check_acl(EGW_ACL_READ)))
542 542
 		{
543
-			return false;	// no read rights
543
+			return false; // no read rights
544 544
 		}
545 545
 		return $this->data;
546 546
 	}
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 	 * @param boolean $ignore_acl =false should the acl be checked, returns true if no edit-rigts
556 556
 	 * @return int 0 on success and errno != 0 else
557 557
 	 */
558
-	function save($keys=null,$touch_modified=true,$ignore_acl=false)
558
+	function save($keys = null, $touch_modified = true, $ignore_acl = false)
559 559
 	{
560 560
 		if ($keys) $this->data_merge($keys);
561 561
 
@@ -573,13 +573,13 @@  discard block
 block discarded – undo
573 573
 		// check if we have a real modification of an existing record
574 574
 		if ($this->data['ts_id'])
575 575
 		{
576
-			$new =& $this->data;
576
+			$new = & $this->data;
577 577
 			unset($this->data);
578 578
 			$this->read($new['ts_id']);
579
-			$old =& $this->data;
580
-			$this->data =& $new;
579
+			$old = & $this->data;
580
+			$this->data = & $new;
581 581
 			$changed = array();
582
-			if (isset($old)) foreach($old as $name => $value)
582
+			if (isset($old)) foreach ($old as $name => $value)
583 583
 			{
584 584
 				if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name;
585 585
 			}
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 		}
591 591
 
592 592
 		// Check for restore of deleted contact, restore held links
593
-		if($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS)
593
+		if ($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS)
594 594
 		{
595 595
 			egw_link::restore(TIMESHEET_APP, $new['ts_id']);
596 596
 		}
@@ -601,14 +601,14 @@  discard block
 block discarded – undo
601 601
 
602 602
 			$this->tracking->html_content_allow = true;
603 603
 		}
604
-		if ($this->tracking->track($this->data,$old,$this->user) === false)
604
+		if ($this->tracking->track($this->data, $old, $this->user) === false)
605 605
 		{
606
-			return implode(', ',$this->tracking->errors);
606
+			return implode(', ', $this->tracking->errors);
607 607
 		}
608 608
 		if (!($err = parent::save()))
609 609
 		{
610 610
 			// notify the link-class about the update, as other apps may be subscribt to it
611
-			egw_link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
611
+			egw_link::notify_update(TIMESHEET_APP, $this->data['ts_id'], $this->data);
612 612
 		}
613 613
 
614 614
 		return $err;
@@ -621,15 +621,15 @@  discard block
 block discarded – undo
621 621
 	 * @param boolean $ignore_acl =false should the acl be checked, returns false if no delete-rigts
622 622
 	 * @return int affected rows, should be 1 if ok, 0 if an error
623 623
 	 */
624
-	function delete($keys=null,$ignore_acl=false)
624
+	function delete($keys = null, $ignore_acl = false)
625 625
 	{
626
-		if (!is_array($keys) && (int) $keys)
626
+		if (!is_array($keys) && (int)$keys)
627 627
 		{
628
-			$keys = array('ts_id' => (int) $keys);
628
+			$keys = array('ts_id' => (int)$keys);
629 629
 		}
630 630
 		$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
631 631
 
632
-		if (!$ignore_acl && !$this->check_acl(EGW_ACL_DELETE,$ts_id) || !($old = $this->read($ts_id)))
632
+		if (!$ignore_acl && !$this->check_acl(EGW_ACL_DELETE, $ts_id) || !($old = $this->read($ts_id)))
633 633
 		{
634 634
 			return false;
635 635
 		}
@@ -640,12 +640,12 @@  discard block
 block discarded – undo
640 640
 			$delete = $old;
641 641
 			$delete['ts_status'] = self::DELETED_STATUS;
642 642
 			$ret = !($this->save($delete));
643
-			egw_link::unlink(0,TIMESHEET_APP,$ts_id,'','','',true);
643
+			egw_link::unlink(0, TIMESHEET_APP, $ts_id, '', '', '', true);
644 644
 		}
645 645
 		elseif (($ret = parent::delete($keys)) && $ts_id)
646 646
 		{
647 647
 			// delete all links to timesheet entry $ts_id
648
-			egw_link::unlink(0,TIMESHEET_APP,$ts_id);
648
+			egw_link::unlink(0, TIMESHEET_APP, $ts_id);
649 649
 		}
650 650
 		return $ret;
651 651
 	}
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	function deleteaccount($data)
661 661
 	{
662 662
 		$account_id = $data['account_id'];
663
-		$new_owner =  $data['new_owner'];
663
+		$new_owner = $data['new_owner'];
664 664
 
665 665
 		if (!$new_owner)
666 666
 		{
@@ -684,22 +684,22 @@  discard block
 block discarded – undo
684 684
 	 * @param int $status =0
685 685
 	 * @return int affected rows, should be 1 if ok, 0 if an error
686 686
 	 */
687
-	function set_status($keys=null, $status=0)
687
+	function set_status($keys = null, $status = 0)
688 688
 	{
689 689
 		$ret = true;
690
-		if (!is_array($keys) && (int) $keys)
690
+		if (!is_array($keys) && (int)$keys)
691 691
 		{
692
-			$keys = array('ts_id' => (int) $keys);
692
+			$keys = array('ts_id' => (int)$keys);
693 693
 		}
694 694
 		$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
695 695
 
696
-		if (!$this->check_acl(EGW_ACL_EDIT,$ts_id) || !$this->read($ts_id,true))
696
+		if (!$this->check_acl(EGW_ACL_EDIT, $ts_id) || !$this->read($ts_id, true))
697 697
 		{
698 698
 			return false;
699 699
 		}
700 700
 
701 701
 		$this->data['ts_status'] = $status;
702
-		if ($this->save($ts_id)!=0) $ret = false;
702
+		if ($this->save($ts_id) != 0) $ret = false;
703 703
 
704 704
 		return $ret;
705 705
 	}
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 		{
717 717
 			return array('duration' => 0, 'quantity' => 0, 'price' => 0, 'max_modified' => null);
718 718
 		}
719
-		return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true);
719
+		return $this->search(array('ts_id'=>$ids), true, '', '', '', false, 'AND', false, null, '', false, true);
720 720
 	}
721 721
 
722 722
 	/**
@@ -727,27 +727,27 @@  discard block
 block discarded – undo
727 727
 	 * @param int|array $entry int ts_id or array with timesheet entry
728 728
 	 * @return string/boolean string with title, null if timesheet not found, false if no perms to view it
729 729
 	 */
730
-	function link_title( $entry )
730
+	function link_title($entry)
731 731
 	{
732 732
 		if (!is_array($entry))
733 733
 		{
734 734
 			// need to preserve the $this->data
735
-			$backup =& $this->data;
735
+			$backup = & $this->data;
736 736
 			unset($this->data);
737
-			$entry = $this->read( $entry,false,false);
737
+			$entry = $this->read($entry, false, false);
738 738
 			// restore the data again
739
-			$this->data =& $backup;
739
+			$this->data = & $backup;
740 740
 		}
741 741
 		if (!$entry)
742 742
 		{
743 743
 			return $entry;
744 744
 		}
745 745
 		$format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
746
-		if (date('H:i',$entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
746
+		if (date('H:i', $entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
747 747
 		{
748 748
 			$format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i');
749 749
 		}
750
-		return date($format,$entry['ts_start']).': '.$entry['ts_title'];
750
+		return date($format, $entry['ts_start']).': '.$entry['ts_title'];
751 751
 	}
752 752
 
753 753
 	/**
@@ -758,18 +758,18 @@  discard block
 block discarded – undo
758 758
 	 * @param array $ids array with ts_id's
759 759
 	 * @return array with titles, see link_title
760 760
 	 */
761
-	function link_titles( array $ids )
761
+	function link_titles(array $ids)
762 762
 	{
763 763
 		$titles = array();
764
-		if (($entries = $this->search(array('ts_id' => $ids),'ts_id,ts_title,ts_start')))
764
+		if (($entries = $this->search(array('ts_id' => $ids), 'ts_id,ts_title,ts_start')))
765 765
 		{
766
-			foreach($entries as $entry)
766
+			foreach ($entries as $entry)
767 767
 			{
768 768
 				$titles[$entry['ts_id']] = $this->link_title($entry);
769 769
 			}
770 770
 		}
771 771
 		// we assume all not returned entries are not readable by the user, as we notify egw_link about all deletes
772
-		foreach($ids as $id)
772
+		foreach ($ids as $id)
773 773
 		{
774 774
 			if (!isset($titles[$id]))
775 775
 			{
@@ -788,16 +788,16 @@  discard block
 block discarded – undo
788 788
 	 * @param array $options Array of options for the search
789 789
 	 * @return array with ts_id - title pairs of the matching entries
790 790
 	 */
791
-	function link_query( $pattern, Array &$options = array() )
791
+	function link_query($pattern, Array &$options = array())
792 792
 	{
793 793
 		$limit = false;
794 794
 		$need_count = false;
795
-		if($options['start'] || $options['num_rows']) {
795
+		if ($options['start'] || $options['num_rows']) {
796 796
 			$limit = array($options['start'], $options['num_rows']);
797 797
 			$need_count = true;
798 798
 		}
799 799
 		$result = array();
800
-		foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts )
800
+		foreach ((array)$this->search($pattern, false, '', '', '%', false, 'OR', $limit, null, '', $need_count) as $ts)
801 801
 		{
802 802
 			if ($ts) $result[$ts['ts_id']] = $this->link_title($ts);
803 803
 		}
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
 	 * @param int $user =null for which user to check, default current user
815 815
 	 * @return boolean true if access is granted or false otherwise
816 816
 	 */
817
-	function file_access($id,$check,$rel_path=null,$user=null)
817
+	function file_access($id, $check, $rel_path = null, $user = null)
818 818
 	{
819
-		unset($rel_path);	// not used, but required by function signature
819
+		unset($rel_path); // not used, but required by function signature
820 820
 
821
-		return $this->check_acl($check,$id,$user);
821
+		return $this->check_acl($check, $id, $user);
822 822
 	}
823 823
 
824 824
 	/**
@@ -830,16 +830,16 @@  discard block
 block discarded – undo
830 830
 	 * @param string $newtitle => the new title of the project
831 831
 	 * @return boolean true for success, false for invalid parameters
832 832
 	 */
833
-	 function update_ts_project($oldtitle='', $newtitle='')
833
+	 function update_ts_project($oldtitle = '', $newtitle = '')
834 834
 	 {
835
-		if(strlen($oldtitle) > 0 && strlen($newtitle) > 0)
835
+		if (strlen($oldtitle) > 0 && strlen($newtitle) > 0)
836 836
 		{
837
-			$this->db->update('egw_timesheet',array(
837
+			$this->db->update('egw_timesheet', array(
838 838
 				'ts_project' => $newtitle,
839 839
 				'ts_title' => $newtitle,
840
-			),array(
840
+			), array(
841 841
 				'ts_project' => $oldtitle,
842
-			),__LINE__,__FILE__,TIMESHEET_APP);
842
+			), __LINE__, __FILE__, TIMESHEET_APP);
843 843
 
844 844
 			return true;
845 845
 		}
@@ -852,16 +852,16 @@  discard block
 block discarded – undo
852 852
 	 * @param int $pm_id ID of selected project
853 853
 	 * @return array containing link_id and ts_id
854 854
 	 */
855
-	function get_ts_links($pm_id=0)
855
+	function get_ts_links($pm_id = 0)
856 856
 	{
857
-		if($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
857
+		if ($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
858 858
 		{
859
-			$pm_ids = ExecMethod('projectmanager.projectmanager_bo.children',$pm_id);
859
+			$pm_ids = ExecMethod('projectmanager.projectmanager_bo.children', $pm_id);
860 860
 			$pm_ids[] = $pm_id;
861
-			$links = solink::get_links('projectmanager',$pm_ids,'timesheet');	// solink::get_links not egw_links::get_links!
861
+			$links = solink::get_links('projectmanager', $pm_ids, 'timesheet'); // solink::get_links not egw_links::get_links!
862 862
 			if ($links)
863 863
 			{
864
-				$links = array_unique(call_user_func_array('array_merge',$links));
864
+				$links = array_unique(call_user_func_array('array_merge', $links));
865 865
 			}
866 866
 			return $links;
867 867
 		}
@@ -879,17 +879,17 @@  discard block
 block discarded – undo
879 879
 	function notify($data)
880 880
 	{
881 881
 		//error_log(__METHOD__.'('.array2string($data).')');
882
-		$backup =& $this->data;	// backup internal data in case class got re-used by ExecMethod
882
+		$backup = & $this->data; // backup internal data in case class got re-used by ExecMethod
883 883
 		unset($this->data);
884 884
 
885 885
 		if ($data['target_app'] == 'projectmanager' && $this->read($data['id']))
886 886
 		{
887 887
 			$old_title = isset($data['data']) ? $data['data'][egw_link::OLD_LINK_TITLE] : null;
888
-			switch($data['type'])
888
+			switch ($data['type'])
889 889
 			{
890 890
 				case 'link':
891 891
 				case 'update':
892
-					if (empty($this->data['ts_project']) ||	// timesheet has not yet project set --> set just linked one
892
+					if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one
893 893
 						isset($old_title) && $this->data['ts_project'] === $old_title)
894 894
 					{
895 895
 						$pm_id = $data['target_id'];
@@ -931,17 +931,17 @@  discard block
 block discarded – undo
931 931
 	 * @param array $data =null if given works on that array and returns result, else works on internal data-array
932 932
 	 * @return array
933 933
 	 */
934
-	function db2data($data=null)
934
+	function db2data($data = null)
935 935
 	{
936 936
 		if (($intern = !is_array($data)))
937 937
 		{
938
-			$data =& $this->data;
938
+			$data = & $this->data;
939 939
 		}
940 940
 		// get pm_id from links and ts_project: either project matching ts_project or first found project
941 941
 		if (!isset($data['pm_id']) && $data['ts_id'])
942 942
 		{
943 943
 			$first_pm_id = null;
944
-			foreach(egw_link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
944
+			foreach (egw_link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
945 945
 			{
946 946
 				if (!isset($first_pm_id)) $first_pm_id = $pm_id;
947 947
 				if ($data['ts_project'] == egw_link::title('projectmanager', $pm_id))
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 			$data['ts_project_blur'] = $data['ts_project'];
960 960
 			$data['ts_project'] = '';
961 961
 		}
962
-		return parent::db2data($intern ? null : $data);	// important to use null, if $intern!
962
+		return parent::db2data($intern ? null : $data); // important to use null, if $intern!
963 963
 	}
964 964
 
965 965
 	/**
@@ -971,17 +971,17 @@  discard block
 block discarded – undo
971 971
 	 * @param array $data =null if given works on that array and returns result, else works on internal data-array
972 972
 	 * @return array
973 973
 	 */
974
-	function data2db($data=null)
974
+	function data2db($data = null)
975 975
 	{
976 976
 		if (($intern = !is_array($data)))
977 977
 		{
978
-			$data =& $this->data;
978
+			$data = & $this->data;
979 979
 		}
980 980
 		// allways store ts_project to be able to search for it, even if no custom project is set
981 981
 		if (empty($data['ts_project']) && !is_null($data['ts_project']))
982 982
 		{
983 983
 			$data['ts_project'] = $data['pm_id'] ? egw_link::title('projectmanager', $data['pm_id']) : '';
984 984
 		}
985
-		return parent::data2db($intern ? null : $data);	// important to use null, if $intern!
985
+		return parent::data2db($intern ? null : $data); // important to use null, if $intern!
986 986
 	}
987 987
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -572,7 +572,7 @@
 block discarded – undo
572 572
 	 * @param array $options Array of options for the search
573 573
 	 *
574 574
 	 */
575
-	function link_query( $pattern, Array &$options = array() )
575
+	function link_query( $pattern, array &$options = array() )
576 576
 	{
577 577
 		if (is_array($pattern))
578 578
 		{
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_export_csv.inc.php 5 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * Exports records as defined in $_definition
27 27
 	 *
28
-	 * @param egw_record $_definition
28
+	 * @param importexport_definition $_definition
29 29
 	 */
30 30
 	public function export( $_stream, importexport_definition $_definition) {
31 31
 		$options = $_definition->plugin_options;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * return html for options.
133 133
 	 * this way the plugin has all opportunities for options tab
134 134
 	 *
135
-	 * @return string html
135
+	 * @return boolean html
136 136
 	 */
137 137
 	public function get_options_etpl() {
138 138
 		return false;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@
 block discarded – undo
125 125
 	}
126 126
 
127 127
 	public static function get_mimetype() {
128
-                return 'text/csv';
129
-        }
128
+				return 'text/csv';
129
+		}
130 130
 
131 131
 	/**
132 132
 	 * return html for options.
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -27,51 +27,51 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param egw_record $_definition
29 29
 	 */
30
-	public function export( $_stream, importexport_definition $_definition) {
30
+	public function export($_stream, importexport_definition $_definition) {
31 31
 		$options = $_definition->plugin_options;
32 32
 
33 33
 		$this->ui = new timesheet_ui();
34 34
 		$selection = array();
35 35
 
36
-		if($options['selection'] == 'search') {
37
-			$query = $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP);
38
-			$query['num_rows'] = -1;	// all records
39
-			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
40
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
41
-		} elseif($options['selection'] == 'all') {
36
+		if ($options['selection'] == 'search') {
37
+			$query = $GLOBALS['egw']->session->appsession('index', TIMESHEET_APP);
38
+			$query['num_rows'] = -1; // all records
39
+			$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
40
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
41
+		} elseif ($options['selection'] == 'all') {
42 42
 			$query = array(
43 43
 				'num_rows' => -1,
44
-				'csv_export' => true,	// so get_rows method _can_ produce different content or not store state in the session
44
+				'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session
45 45
 			);
46
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
46
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
47 47
 		}
48
-		else if($options['selection'] == 'filter')
48
+		else if ($options['selection'] == 'filter')
49 49
 		{
50 50
 			$fields = importexport_helper_functions::get_filter_fields($_definition->application, $this);
51 51
 			$filter = $_definition->filter;
52 52
 			$query = array(
53 53
 				'num_rows' => -1,
54
-				'csv_export' => true,	// so get_rows method _can_ produce different content or not store state in the session
54
+				'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session
55 55
 				'col_filter' => array()
56 56
 			);
57 57
 
58 58
 			// Handle ranges
59
-			foreach($filter as $field => $value)
59
+			foreach ($filter as $field => $value)
60 60
 			{
61
-				if($field == 'cat_id')
61
+				if ($field == 'cat_id')
62 62
 				{
63 63
 					$query['cat_id'] = $value;
64 64
 					continue;
65 65
 				}
66 66
 				$query['col_filter'][$field] = $value;
67
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
67
+				if (!is_array($value) || (!$value['from'] && !$value['to'])) continue;
68 68
 
69 69
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
70
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
71
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
70
+				if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from'];
71
+				if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to'];
72 72
 				unset($query['col_filter'][$field]);
73 73
 			}
74
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
74
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
75 75
 		}
76 76
 
77 77
 
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		// support other selectors atm.
84 84
 		foreach ($selection as $identifier) {
85 85
 			$record = new timesheet_egw_record($identifier);
86
-			if($options['convert']) {
86
+			if ($options['convert']) {
87 87
 				importexport_export_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $this->selects);
88 88
 			} else {
89 89
 				// Implode arrays, so they don't say 'Array'
90
-				foreach($record->get_record_array() as $key => $value) {
91
-					if(is_array($value)) $record->$key = implode(',', $value);
90
+				foreach ($record->get_record_array() as $key => $value) {
91
+					if (is_array($value)) $record->$key = implode(',', $value);
92 92
 				}
93 93
  			}
94 94
 			$export_object->export_record($record);
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	public function get_selects()
152 152
 	{
153 153
 		$this->selects = array(
154
-			'ts_status'	=>	$this->ui->status_labels+array(lang('No status'))
154
+			'ts_status'	=>	$this->ui->status_labels + array(lang('No status'))
155 155
 		);
156
-		foreach($this->selects['ts_status'] as &$status) {
157
-			$status = str_replace('&nbsp;','',$status); // Remove &nbsp;
156
+		foreach ($this->selects['ts_status'] as &$status) {
157
+			$status = str_replace('&nbsp;', '', $status); // Remove &nbsp;
158 158
 		}
159 159
 
160 160
 	}
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function get_filter_fields(Array &$filters)
165 165
 	{
166
-		foreach($filters as $field_name => &$settings)
166
+		foreach ($filters as $field_name => &$settings)
167 167
 		{
168
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
168
+			if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
169 169
 		}
170 170
 	}
171 171
 
Please login to merge, or discard this patch.
Braces   +52 added lines, -20 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * export plugin of addressbook
16 16
  */
17
-class timesheet_export_csv implements importexport_iface_export_plugin {
17
+class timesheet_export_csv implements importexport_iface_export_plugin
18
+{
18 19
 
19 20
 	public function __construct()
20 21
 	{
@@ -27,18 +28,22 @@  discard block
 block discarded – undo
27 28
 	 *
28 29
 	 * @param egw_record $_definition
29 30
 	 */
30
-	public function export( $_stream, importexport_definition $_definition) {
31
+	public function export( $_stream, importexport_definition $_definition)
32
+	{
31 33
 		$options = $_definition->plugin_options;
32 34
 
33 35
 		$this->ui = new timesheet_ui();
34 36
 		$selection = array();
35 37
 
36
-		if($options['selection'] == 'search') {
38
+		if($options['selection'] == 'search')
39
+		{
37 40
 			$query = $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP);
38 41
 			$query['num_rows'] = -1;	// all records
39 42
 			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
40 43
 			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
41
-		} elseif($options['selection'] == 'all') {
44
+		}
45
+		elseif($options['selection'] == 'all')
46
+		{
42 47
 			$query = array(
43 48
 				'num_rows' => -1,
44 49
 				'csv_export' => true,	// so get_rows method _can_ produce different content or not store state in the session
@@ -64,11 +69,20 @@  discard block
 block discarded – undo
64 69
 					continue;
65 70
 				}
66 71
 				$query['col_filter'][$field] = $value;
67
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
72
+				if(!is_array($value) || (!$value['from'] && !$value['to']))
73
+				{
74
+					continue;
75
+				}
68 76
 
69 77
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
70
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
71
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
78
+				if($value['from'])
79
+				{
80
+					$query['col_filter'][] = "$field >= " . (int)$value['from'];
81
+				}
82
+				if($value['to'])
83
+				{
84
+					$query['col_filter'][] = "$field <= " . (int)$value['to'];
85
+				}
72 86
 				unset($query['col_filter'][$field]);
73 87
 			}
74 88
 			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
@@ -81,14 +95,22 @@  discard block
 block discarded – undo
81 95
 
82 96
 		// $options['selection'] is array of identifiers as this plugin doesn't
83 97
 		// support other selectors atm.
84
-		foreach ($selection as $identifier) {
98
+		foreach ($selection as $identifier)
99
+		{
85 100
 			$record = new timesheet_egw_record($identifier);
86
-			if($options['convert']) {
101
+			if($options['convert'])
102
+			{
87 103
 				importexport_export_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $this->selects);
88
-			} else {
104
+			}
105
+			else
106
+			{
89 107
 				// Implode arrays, so they don't say 'Array'
90
-				foreach($record->get_record_array() as $key => $value) {
91
-					if(is_array($value)) $record->$key = implode(',', $value);
108
+				foreach($record->get_record_array() as $key => $value)
109
+				{
110
+					if(is_array($value))
111
+					{
112
+						$record->$key = implode(',', $value);
113
+					}
92 114
 				}
93 115
  			}
94 116
 			$export_object->export_record($record);
@@ -102,7 +124,8 @@  discard block
 block discarded – undo
102 124
 	 *
103 125
 	 * @return string name
104 126
 	 */
105
-	public static function get_name() {
127
+	public static function get_name()
128
+	{
106 129
 		return lang('Timesheet CSV export');
107 130
 	}
108 131
 
@@ -111,7 +134,8 @@  discard block
 block discarded – undo
111 134
 	 *
112 135
 	 * @return string descriprion
113 136
 	 */
114
-	public static function get_description() {
137
+	public static function get_description()
138
+	{
115 139
 		return lang("Exports entries from your Timesheet into a CSV File. ");
116 140
 	}
117 141
 
@@ -120,11 +144,13 @@  discard block
 block discarded – undo
120 144
 	 *
121 145
 	 * @return string suffix
122 146
 	 */
123
-	public static function get_filesuffix() {
147
+	public static function get_filesuffix()
148
+	{
124 149
 		return 'csv';
125 150
 	}
126 151
 
127
-	public static function get_mimetype() {
152
+	public static function get_mimetype()
153
+	{
128 154
                 return 'text/csv';
129 155
         }
130 156
 
@@ -134,7 +160,8 @@  discard block
 block discarded – undo
134 160
 	 *
135 161
 	 * @return string html
136 162
 	 */
137
-	public function get_options_etpl() {
163
+	public function get_options_etpl()
164
+	{
138 165
 		return false;
139 166
 	}
140 167
 
@@ -142,7 +169,8 @@  discard block
 block discarded – undo
142 169
 	 * returns slectors of this plugin via xajax
143 170
 	 *
144 171
 	 */
145
-	public function get_selectors_etpl() {
172
+	public function get_selectors_etpl()
173
+	{
146 174
 		return array(
147 175
 			'name'	=> 'importexport.export_csv_selectors',
148 176
 		);
@@ -153,7 +181,8 @@  discard block
 block discarded – undo
153 181
 		$this->selects = array(
154 182
 			'ts_status'	=>	$this->ui->status_labels+array(lang('No status'))
155 183
 		);
156
-		foreach($this->selects['ts_status'] as &$status) {
184
+		foreach($this->selects['ts_status'] as &$status)
185
+		{
157 186
 			$status = str_replace('&nbsp;','',$status); // Remove &nbsp;
158 187
 		}
159 188
 
@@ -165,7 +194,10 @@  discard block
 block discarded – undo
165 194
 	{
166 195
 		foreach($filters as $field_name => &$settings)
167 196
 		{
168
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
197
+			if($this->selects[$field_name])
198
+			{
199
+				$settings['values'] = $this->selects[$field_name];
200
+			}
169 201
 		}
170 202
 	}
171 203
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -247,7 +247,7 @@
 block discarded – undo
247 247
 		$this->selects['info_status'] = $this->bo->get_status();
248 248
 	}
249 249
 
250
-	public function get_filter_fields(Array &$filters)
250
+	public function get_filter_fields(array &$filters)
251 251
 	{
252 252
 		foreach($filters as $field_name => &$settings)
253 253
 		{
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_import_csv.inc.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,8 +104,7 @@
 block discarded – undo
104 104
 	/**
105 105
 	 * imports entries according to given definition object.
106 106
 	 * @param resource $_stream
107
-	 * @param string $_charset
108
-	 * @param definition $_definition
107
+	 * @param importexport_definition $_definition
109 108
 	 */
110 109
 	public function import( $_stream, importexport_definition $_definition ) {
111 110
 		$import_csv = new importexport_import_csv( $_stream, array(
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	private $bo;
73 73
 
74 74
 	/**
75
-	* For figuring out if a record has changed
76
-	*/
75
+	 * For figuring out if a record has changed
76
+	 */
77 77
 	protected $tracking;
78 78
 
79 79
 	/**
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	protected $errors = array();
98 98
 
99 99
 	/**
100
-         * List of actions, and how many times that action was taken
101
-         */
102
-        protected $results = array();
100
+	 * List of actions, and how many times that action was taken
101
+	 */
102
+		protected $results = array();
103 103
 
104 104
 	/**
105 105
 	 * imports entries according to given definition object.
@@ -458,40 +458,40 @@  discard block
 block discarded – undo
458 458
 	}
459 459
 
460 460
 	/**
461
-        * Returns warnings that were encountered during importing
462
-        * Maximum of one warning message per record, but you can append if you need to
463
-        *
464
-        * @return Array (
465
-        *       record_# => warning message
466
-        *       )
467
-        */
468
-        public function get_warnings() {
461
+	 * Returns warnings that were encountered during importing
462
+	 * Maximum of one warning message per record, but you can append if you need to
463
+	 *
464
+	 * @return Array (
465
+	 *       record_# => warning message
466
+	 *       )
467
+	 */
468
+		public function get_warnings() {
469 469
 		return $this->warnings;
470 470
 	}
471 471
 
472 472
 	/**
473
-        * Returns errors that were encountered during importing
474
-        * Maximum of one error message per record, but you can append if you need to
475
-        *
476
-        * @return Array (
477
-        *       record_# => error message
478
-        *       )
479
-        */
480
-        public function get_errors() {
473
+	 * Returns errors that were encountered during importing
474
+	 * Maximum of one error message per record, but you can append if you need to
475
+	 *
476
+	 * @return Array (
477
+	 *       record_# => error message
478
+	 *       )
479
+	 */
480
+		public function get_errors() {
481 481
 		return $this->errors;
482 482
 	}
483 483
 
484 484
 	/**
485
-        * Returns a list of actions taken, and the number of records for that action.
486
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
487
-        *
488
-        * @return Array (
489
-        *       action => record count
490
-        * )
491
-        */
492
-        public function get_results() {
493
-                return $this->results;
494
-        }
485
+	 * Returns a list of actions taken, and the number of records for that action.
486
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
487
+	 *
488
+	 * @return Array (
489
+	 *       action => record count
490
+	 * )
491
+	 */
492
+		public function get_results() {
493
+				return $this->results;
494
+		}
495 495
 	// end of iface_export_plugin
496 496
 
497 497
 	// Extra conversion functions - must be static
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for timesheet
17 17
  */
18
-class timesheet_import_csv implements importexport_iface_import_plugin  {
18
+class timesheet_import_csv implements importexport_iface_import_plugin {
19 19
 
20 20
 	private static $plugin_options = array(
21
-		'fieldsep', 		// char
22
-		'charset', 			// string
23
-		'update_cats', 			// string {override|add} overides record
21
+		'fieldsep', // char
22
+		'charset', // string
23
+		'update_cats', // string {override|add} overides record
24 24
 								// with cat(s) from csv OR add the cat from
25 25
 								// csv file to exeisting cat(s) of record
26 26
 		'num_header_lines', // int number of header lines
27 27
 		'field_conversion', // array( $csv_col_num => conversion)
28
-		'field_mapping',	// array( $csv_col_num => adb_filed)
29
-		'conditions',		/* => array containing condition arrays:
28
+		'field_mapping', // array( $csv_col_num => adb_filed)
29
+		'conditions', /* => array containing condition arrays:
30 30
 				'type' => exists, // exists
31 31
 				'string' => '#kundennummer',
32 32
 				'true' => array(
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * actions wich could be done to data entries
52 52
 	 */
53
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
53
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
54 54
 
55 55
 	/**
56 56
 	 * conditions for actions
57 57
 	 *
58 58
 	 * @var array
59 59
 	 */
60
-	protected static $conditions = array( 'exists' );
60
+	protected static $conditions = array('exists');
61 61
 
62 62
 	/**
63 63
 	 * @var definition
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * @param string $_charset
106 106
 	 * @param definition $_definition
107 107
 	 */
108
-	public function import( $_stream, importexport_definition $_definition ) {
109
-		$import_csv = new importexport_import_csv( $_stream, array(
108
+	public function import($_stream, importexport_definition $_definition) {
109
+		$import_csv = new importexport_import_csv($_stream, array(
110 110
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
111 111
 			'charset' => $_definition->plugin_options['charset'],
112 112
 		));
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
117 117
 
118 118
 		// dry run?
119
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
119
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
120 120
 
121 121
 		// fetch the bo
122 122
 		$this->bo = new timesheet_bo();
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
 		$import_csv->conversion_class = $this;
135 135
 
136 136
 		//check if file has a header lines
137
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
137
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
138 138
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
139
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
139
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
140 140
 			// First method is preferred
141 141
 			$import_csv->skip_records(1);
142 142
 		}
143 143
 
144 144
 		// set Owner
145
-		$_definition->plugin_options['record_owner'] = isset( $_definition->plugin_options['record_owner'] ) ?
145
+		$_definition->plugin_options['record_owner'] = isset($_definition->plugin_options['record_owner']) ?
146 146
 			$_definition->plugin_options['record_owner'] : $this->user;
147 147
 
148 148
 		// Used to try to automatically match names to account IDs
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 		);
157 157
 
158 158
 		// Status need leading spaces removed
159
-		foreach($lookups['ts_status'] as $id => &$label) {
160
-			$label = str_replace('&nbsp;', '',trim($label));
161
-			if($label == '') unset($lookups['ts_status'][$id]);
159
+		foreach ($lookups['ts_status'] as $id => &$label) {
160
+			$label = str_replace('&nbsp;', '', trim($label));
161
+			if ($label == '') unset($lookups['ts_status'][$id]);
162 162
 		}
163 163
 
164 164
 		// Start counting successes
@@ -168,22 +168,22 @@  discard block
 block discarded – undo
168 168
 		// Failures
169 169
 		$this->errors = array();
170 170
 
171
-		while ( $record = $import_csv->get_record() ) {
171
+		while ($record = $import_csv->get_record()) {
172 172
 			$success = false;
173 173
 
174 174
 			// don't import empty records
175
-			if( count( array_unique( $record ) ) < 2 ) continue;
175
+			if (count(array_unique($record)) < 2) continue;
176 176
 
177 177
 			$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']);
178
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
178
+			if ($result) $this->warnings[$import_csv->get_current_position()] = $result;
179 179
 
180 180
 			// Automatically handle text categories without explicit translation
181
-			foreach(array('ts_status','cat_id') as $field) {
182
-				if(!is_numeric($record[$field])) {
183
-					$translate_key = 'translate'.(substr($field,0,2) == 'ts' ? substr($field,2) : '_cat_id');
184
-					if($key = array_search($record[$field], $lookups[$field])) {
181
+			foreach (array('ts_status', 'cat_id') as $field) {
182
+				if (!is_numeric($record[$field])) {
183
+					$translate_key = 'translate'.(substr($field, 0, 2) == 'ts' ? substr($field, 2) : '_cat_id');
184
+					if ($key = array_search($record[$field], $lookups[$field])) {
185 185
 						$record[$field] = $key;
186
-					} elseif(array_key_exists($translate_key, $_definition->plugin_options)) {
186
+					} elseif (array_key_exists($translate_key, $_definition->plugin_options)) {
187 187
 						$t_field = $_definition->plugin_options[$translate_key];
188 188
 						switch ($t_field) {
189 189
 							case '':
@@ -194,29 +194,29 @@  discard block
 block discarded – undo
194 194
 							case '~skip~':
195 195
 								continue 2;
196 196
 							default:
197
-								if(strpos($t_field, 'add') === 0) {
197
+								if (strpos($t_field, 'add') === 0) {
198 198
 									// Check for a parent
199
-									list($name, $parent_name) = explode('~',$t_field);
200
-									if($parent_name) {
199
+									list($name, $parent_name) = explode('~', $t_field);
200
+									if ($parent_name) {
201 201
 										$parent = importexport_helper_functions::cat_name2id($parent_name);
202 202
 									}
203 203
 
204
-									if($field == 'cat_id') {
204
+									if ($field == 'cat_id') {
205 205
 										$record[$field] = importexport_helper_functions::cat_name2id($record[$field], $parent);
206 206
 									} elseif ($field == 'ts_status') {
207 207
 										end($this->bo->status_labels);
208
-										$id = key($this->bo->status_labels)+1;
208
+										$id = key($this->bo->status_labels) + 1;
209 209
 										$this->bo->status_labels[$id] = $record[$field];
210 210
 										$this->bo->status_labels_config[$id] = array(
211 211
 											'name'   => $record[$field],
212 212
 											'parent' => $parent,
213 213
 											'admin'  => false
214 214
 										);
215
-										config::save_value('status_labels',$this->bo->status_labels_config,TIMESHEET_APP);
215
+										config::save_value('status_labels', $this->bo->status_labels_config, TIMESHEET_APP);
216 216
 										$lookups[$field][$id] = $name;
217 217
 										$record[$field] = $id;
218 218
 									}
219
-								} elseif($key = array_search($t_field, $lookups[$field])) {
219
+								} elseif ($key = array_search($t_field, $lookups[$field])) {
220 220
 									$record[$field] = $key;
221 221
 								} else {
222 222
 									$record[$field] = $t_field;
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 			}
229 229
 
230 230
 			// Set creator, unless it's supposed to come from CSV file
231
-			if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner']) {
232
-				if(!is_numeric($record['ts_owner'])) {
231
+			if ($_definition->plugin_options['owner_from_csv'] && $record['ts_owner']) {
232
+				if (!is_numeric($record['ts_owner'])) {
233 233
 					// Automatically handle text owner without explicit translation
234 234
 					$new_owner = importexport_helper_functions::account_name2id($record['ts_owner']);
235
-					if($new_owner == '') {
235
+					if ($new_owner == '') {
236 236
 						$this->errors[$import_csv->get_current_position()] = lang(
237 237
 							'Unable to convert "%1" to account ID.  Using plugin setting (%2) for %3.',
238 238
 							$record['ts_owner'],
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 			}
250 250
 
251 251
 			// Check account IDs
252
-			foreach(array('ts_modifier') as $field) {
253
-				if($record[$field] && !is_numeric($record[$field])) {
252
+			foreach (array('ts_modifier') as $field) {
253
+				if ($record[$field] && !is_numeric($record[$field])) {
254 254
 					// Try an automatic conversion
255 255
 					$account_id = importexport_helper_functions::account_name2id($record[$field]);
256
-					if($account_id && strtoupper(common::grab_owner_name($account_id)) == strtoupper($record[$field])) {
256
+					if ($account_id && strtoupper(common::grab_owner_name($account_id)) == strtoupper($record[$field])) {
257 257
 						$record[$field] = $account_id;
258 258
 					} else {
259 259
 						$this->errors[$import_csv->get_current_position()] = lang(
@@ -269,35 +269,35 @@  discard block
 block discarded – undo
269 269
 			// Special values
270 270
 			if ($record['addressbook'] && !is_numeric($record['addressbook']))
271 271
 			{
272
-				list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
273
-				$record['addressbook'] = self::addr_id($lastname,$firstname,$org_name);
272
+				list($lastname, $firstname, $org_name) = explode(',', $record['addressbook']);
273
+				$record['addressbook'] = self::addr_id($lastname, $firstname, $org_name);
274 274
 			}
275 275
 
276
-			if ( $_definition->plugin_options['conditions'] ) {
277
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
276
+			if ($_definition->plugin_options['conditions']) {
277
+				foreach ($_definition->plugin_options['conditions'] as $condition) {
278 278
 					$results = array();
279
-					switch ( $condition['type'] ) {
279
+					switch ($condition['type']) {
280 280
 						// exists
281 281
 						case 'exists' :
282
-							if($record[$condition['string']]) {
282
+							if ($record[$condition['string']]) {
283 283
 								$results = $this->bo->search(array($condition['string'] => $record[$condition['string']]));
284 284
 							}
285 285
 
286
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1 ) {
286
+							if (is_array($results) && count(array_keys($results)) >= 1) {
287 287
 								// apply action to all records matching this exists condition
288 288
 								$action = $condition['true'];
289
-								foreach ( (array)$results as $result ) {
289
+								foreach ((array)$results as $result) {
290 290
 									$record['ts_id'] = $result['ts_id'];
291
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
292
-										if ( !is_array( $result['cat_id'] ) ) $result['cat_id'] = explode( ',', $result['cat_id'] );
293
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
294
-										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $result['cat_id'] ) ) );
291
+									if ($_definition->plugin_options['update_cats'] == 'add') {
292
+										if (!is_array($result['cat_id'])) $result['cat_id'] = explode(',', $result['cat_id']);
293
+										if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
294
+										$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $result['cat_id'])));
295 295
 									}
296
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
296
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
297 297
 								}
298 298
 							} else {
299 299
 								$action = $condition['false'];
300
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
300
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
301 301
 							}
302 302
 							break;
303 303
 
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
 				}
311 311
 			} else {
312 312
 				// unconditional insert
313
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
313
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
314 314
 			}
315
-			if($success) $count++;
315
+			if ($success) $count++;
316 316
 		}
317 317
 		return $count;
318 318
 	}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @param array $_data tracker data for the action
325 325
 	 * @return bool success or not
326 326
 	 */
327
-	private function action ( $_action, $_data, $record_num = 0 ) {
327
+	private function action($_action, $_data, $record_num = 0) {
328 328
 		$result = true;
329 329
 		switch ($_action) {
330 330
 			case 'none' :
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 				$old_record = new timesheet_egw_record($_data['ts_id']);
335 335
 				$old = $old_record->get_record_array();
336 336
 
337
-				if(!$this->definition->plugin_options['change_owner']) {
337
+				if (!$this->definition->plugin_options['change_owner']) {
338 338
 					// Don't change creator of an existing ticket
339 339
 					unset($_data['ts_owner']);
340 340
 				}
@@ -342,35 +342,35 @@  discard block
 block discarded – undo
342 342
 				// Merge to deal with fields not in import record
343 343
 				$_data = array_merge($old, $_data);
344 344
 				$changed = $this->tracking->changed_fields($_data, $old);
345
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
345
+				if (count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
346 346
 					break;
347 347
 				}
348 348
 
349 349
 				// Clear old link, if different
350 350
 				if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id']) {
351
-					egw_link::unlink2(0,TIMESHEET_APP,$_data['ts_id'],0,'projectmanager',$old['pm_id']);
351
+					egw_link::unlink2(0, TIMESHEET_APP, $_data['ts_id'], 0, 'projectmanager', $old['pm_id']);
352 352
 				}
353 353
 				
354 354
 				// Fall through
355 355
 			case 'insert' :
356
-				if ( $this->dry_run ) {
356
+				if ($this->dry_run) {
357 357
 					//print_r($_data);
358 358
 					$this->results[$_action]++;
359 359
 					break;
360 360
 				} else {
361
-					$result = $this->bo->save( $_data);
361
+					$result = $this->bo->save($_data);
362 362
 					$_data['ts_id'] = $this->bo->data['ts_id'];
363 363
 
364 364
 					// Set projectmanager link
365 365
 					if ($_data['pm_id']) {
366
-						egw_link::link(TIMESHEET_APP,$_data['ts_id'],'projectmanager',$_data['pm_id']);
366
+						egw_link::link(TIMESHEET_APP, $_data['ts_id'], 'projectmanager', $_data['pm_id']);
367 367
 					}
368 368
 
369
-					if($result) {
369
+					if ($result) {
370 370
 						$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
371 371
 							$GLOBALS['egw']->accounts->id2name($_data['owner']),
372 372
 							lang($_action)
373
-						) . ' ' . $result;
373
+						).' '.$result;
374 374
 					} else {
375 375
 						$this->results[$_action]++;
376 376
 						$result = $this->bo->data['ts_id'];
@@ -382,22 +382,22 @@  discard block
 block discarded – undo
382 382
 		}
383 383
 
384 384
 		// Process some additional fields
385
-		if(!is_numeric($result)) {
385
+		if (!is_numeric($result)) {
386 386
 			return $result;
387 387
 		}
388 388
 		$_link_id = false;
389
-		foreach(self::$special_fields as $field => $desc) {
390
-			if(!$_data[$field]) continue;
389
+		foreach (self::$special_fields as $field => $desc) {
390
+			if (!$_data[$field]) continue;
391 391
 
392 392
 			// Links
393
-			if(strpos('link', $field) === 0) {
393
+			if (strpos('link', $field) === 0) {
394 394
 				list($app, $id) = explode(':', $_data[$field]);
395 395
 			} else {
396 396
 				$app = $field;
397 397
 				$id = $_data[$field];
398 398
 			}
399 399
 			if ($app && $app_id) {
400
-				$link_id = egw_link::link('timesheet',$id,$app,$app_id);
400
+				$link_id = egw_link::link('timesheet', $id, $app, $app_id);
401 401
 			}
402 402
 		}
403 403
 		return $result;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	// end of iface_export_plugin
494 494
 
495 495
 	// Extra conversion functions - must be static
496
-	public static function addr_id( $n_family,$n_given=null,$org_name=null ) {
496
+	public static function addr_id($n_family, $n_given = null, $org_name = null) {
497 497
 
498 498
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
499 499
 		static $contacts;
@@ -503,18 +503,18 @@  discard block
 block discarded – undo
503 503
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
504 504
 		}
505 505
 		$n_family = trim($n_family);
506
-		if(!is_null($n_given)) $n_given = trim($n_given);
506
+		if (!is_null($n_given)) $n_given = trim($n_given);
507 507
 		if (!is_object($contacts))
508 508
 		{
509
-			$contacts =& CreateObject('phpgwapi.contacts');
509
+			$contacts = & CreateObject('phpgwapi.contacts');
510 510
 		}
511 511
 		if (!is_null($org_name))        // org_name given?
512 512
 		{
513 513
 			$org_name = trim($org_name);
514
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
514
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name");
515 515
 			if (!count($addrs))
516 516
 			{
517
-				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
517
+				$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name');
518 518
 			}
519 519
 		}
520 520
 		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 		}
524 524
 		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
525 525
 		{
526
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
526
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn');
527 527
 		}
528 528
 		if (count($addrs))
529 529
 		{
Please login to merge, or discard this patch.
Braces   +179 added lines, -71 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for timesheet
17 17
  */
18
-class timesheet_import_csv implements importexport_iface_import_plugin  {
18
+class timesheet_import_csv implements importexport_iface_import_plugin
19
+{
19 20
 
20 21
 	private static $plugin_options = array(
21 22
 		'fieldsep', 		// char
@@ -105,7 +106,8 @@  discard block
 block discarded – undo
105 106
 	 * @param string $_charset
106 107
 	 * @param definition $_definition
107 108
 	 */
108
-	public function import( $_stream, importexport_definition $_definition ) {
109
+	public function import( $_stream, importexport_definition $_definition )
110
+	{
109 111
 		$import_csv = new importexport_import_csv( $_stream, array(
110 112
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
111 113
 			'charset' => $_definition->plugin_options['charset'],
@@ -134,9 +136,12 @@  discard block
 block discarded – undo
134 136
 		$import_csv->conversion_class = $this;
135 137
 
136 138
 		//check if file has a header lines
137
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
139
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
140
+		{
138 141
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
139
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
142
+		}
143
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
144
+		{
140 145
 			// First method is preferred
141 146
 			$import_csv->skip_records(1);
142 147
 		}
@@ -156,9 +161,13 @@  discard block
 block discarded – undo
156 161
 		);
157 162
 
158 163
 		// Status need leading spaces removed
159
-		foreach($lookups['ts_status'] as $id => &$label) {
164
+		foreach($lookups['ts_status'] as $id => &$label)
165
+		{
160 166
 			$label = str_replace('&nbsp;', '',trim($label));
161
-			if($label == '') unset($lookups['ts_status'][$id]);
167
+			if($label == '')
168
+			{
169
+				unset($lookups['ts_status'][$id]);
170
+			}
162 171
 		}
163 172
 
164 173
 		// Start counting successes
@@ -168,24 +177,37 @@  discard block
 block discarded – undo
168 177
 		// Failures
169 178
 		$this->errors = array();
170 179
 
171
-		while ( $record = $import_csv->get_record() ) {
180
+		while ( $record = $import_csv->get_record() )
181
+		{
172 182
 			$success = false;
173 183
 
174 184
 			// don't import empty records
175
-			if( count( array_unique( $record ) ) < 2 ) continue;
185
+			if( count( array_unique( $record ) ) < 2 )
186
+			{
187
+				continue;
188
+			}
176 189
 
177 190
 			$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']);
178
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
191
+			if($result)
192
+			{
193
+				$this->warnings[$import_csv->get_current_position()] = $result;
194
+			}
179 195
 
180 196
 			// Automatically handle text categories without explicit translation
181
-			foreach(array('ts_status','cat_id') as $field) {
182
-				if(!is_numeric($record[$field])) {
197
+			foreach(array('ts_status','cat_id') as $field)
198
+			{
199
+				if(!is_numeric($record[$field]))
200
+				{
183 201
 					$translate_key = 'translate'.(substr($field,0,2) == 'ts' ? substr($field,2) : '_cat_id');
184
-					if($key = array_search($record[$field], $lookups[$field])) {
202
+					if($key = array_search($record[$field], $lookups[$field]))
203
+					{
185 204
 						$record[$field] = $key;
186
-					} elseif(array_key_exists($translate_key, $_definition->plugin_options)) {
205
+					}
206
+					elseif(array_key_exists($translate_key, $_definition->plugin_options))
207
+					{
187 208
 						$t_field = $_definition->plugin_options[$translate_key];
188
-						switch ($t_field) {
209
+						switch ($t_field)
210
+						{
189 211
 							case '':
190 212
 							case '0':
191 213
 								// Skip that field
@@ -194,16 +216,21 @@  discard block
 block discarded – undo
194 216
 							case '~skip~':
195 217
 								continue 2;
196 218
 							default:
197
-								if(strpos($t_field, 'add') === 0) {
219
+								if(strpos($t_field, 'add') === 0)
220
+								{
198 221
 									// Check for a parent
199 222
 									list($name, $parent_name) = explode('~',$t_field);
200
-									if($parent_name) {
223
+									if($parent_name)
224
+									{
201 225
 										$parent = importexport_helper_functions::cat_name2id($parent_name);
202 226
 									}
203 227
 
204
-									if($field == 'cat_id') {
228
+									if($field == 'cat_id')
229
+									{
205 230
 										$record[$field] = importexport_helper_functions::cat_name2id($record[$field], $parent);
206
-									} elseif ($field == 'ts_status') {
231
+									}
232
+									elseif ($field == 'ts_status')
233
+									{
207 234
 										end($this->bo->status_labels);
208 235
 										$id = key($this->bo->status_labels)+1;
209 236
 										$this->bo->status_labels[$id] = $record[$field];
@@ -216,9 +243,13 @@  discard block
 block discarded – undo
216 243
 										$lookups[$field][$id] = $name;
217 244
 										$record[$field] = $id;
218 245
 									}
219
-								} elseif($key = array_search($t_field, $lookups[$field])) {
246
+								}
247
+								elseif($key = array_search($t_field, $lookups[$field]))
248
+								{
220 249
 									$record[$field] = $key;
221
-								} else {
250
+								}
251
+								else
252
+								{
222 253
 									$record[$field] = $t_field;
223 254
 								}
224 255
 								break;
@@ -228,11 +259,14 @@  discard block
 block discarded – undo
228 259
 			}
229 260
 
230 261
 			// Set creator, unless it's supposed to come from CSV file
231
-			if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner']) {
232
-				if(!is_numeric($record['ts_owner'])) {
262
+			if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner'])
263
+			{
264
+				if(!is_numeric($record['ts_owner']))
265
+				{
233 266
 					// Automatically handle text owner without explicit translation
234 267
 					$new_owner = importexport_helper_functions::account_name2id($record['ts_owner']);
235
-					if($new_owner == '') {
268
+					if($new_owner == '')
269
+					{
236 270
 						$this->errors[$import_csv->get_current_position()] = lang(
237 271
 							'Unable to convert "%1" to account ID.  Using plugin setting (%2) for %3.',
238 272
 							$record['ts_owner'],
@@ -240,22 +274,31 @@  discard block
 block discarded – undo
240 274
 							lang($this->bo->field2label['ts_owner'])
241 275
 						);
242 276
 						$record['ts_owner'] = $_definition->plugin_options['record_owner'];
243
-					} else {
277
+					}
278
+					else
279
+					{
244 280
 						$record['ts_owner'] = $new_owner;
245 281
 					}
246 282
 				}
247
-			} elseif ($_definition->plugin_options['record_owner']) {
283
+			}
284
+			elseif ($_definition->plugin_options['record_owner'])
285
+			{
248 286
 				$record['ts_owner'] = $_definition->plugin_options['record_owner'];
249 287
 			}
250 288
 
251 289
 			// Check account IDs
252
-			foreach(array('ts_modifier') as $field) {
253
-				if($record[$field] && !is_numeric($record[$field])) {
290
+			foreach(array('ts_modifier') as $field)
291
+			{
292
+				if($record[$field] && !is_numeric($record[$field]))
293
+				{
254 294
 					// Try an automatic conversion
255 295
 					$account_id = importexport_helper_functions::account_name2id($record[$field]);
256
-					if($account_id && strtoupper(common::grab_owner_name($account_id)) == strtoupper($record[$field])) {
296
+					if($account_id && strtoupper(common::grab_owner_name($account_id)) == strtoupper($record[$field]))
297
+					{
257 298
 						$record[$field] = $account_id;
258
-					} else {
299
+					}
300
+					else
301
+					{
259 302
 						$this->errors[$import_csv->get_current_position()] = lang(
260 303
 							'Unable to convert "%1" to account ID.  Using plugin setting (%2) for %3.',
261 304
 							$record[$field],
@@ -273,29 +316,44 @@  discard block
 block discarded – undo
273 316
 				$record['addressbook'] = self::addr_id($lastname,$firstname,$org_name);
274 317
 			}
275 318
 
276
-			if ( $_definition->plugin_options['conditions'] ) {
277
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
319
+			if ( $_definition->plugin_options['conditions'] )
320
+			{
321
+				foreach ( $_definition->plugin_options['conditions'] as $condition )
322
+				{
278 323
 					$results = array();
279
-					switch ( $condition['type'] ) {
324
+					switch ( $condition['type'] )
325
+					{
280 326
 						// exists
281 327
 						case 'exists' :
282
-							if($record[$condition['string']]) {
328
+							if($record[$condition['string']])
329
+							{
283 330
 								$results = $this->bo->search(array($condition['string'] => $record[$condition['string']]));
284 331
 							}
285 332
 
286
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1 ) {
333
+							if ( is_array( $results ) && count( array_keys( $results )) >= 1 )
334
+							{
287 335
 								// apply action to all records matching this exists condition
288 336
 								$action = $condition['true'];
289
-								foreach ( (array)$results as $result ) {
337
+								foreach ( (array)$results as $result )
338
+								{
290 339
 									$record['ts_id'] = $result['ts_id'];
291
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
292
-										if ( !is_array( $result['cat_id'] ) ) $result['cat_id'] = explode( ',', $result['cat_id'] );
293
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
340
+									if ( $_definition->plugin_options['update_cats'] == 'add' )
341
+									{
342
+										if ( !is_array( $result['cat_id'] ) )
343
+										{
344
+											$result['cat_id'] = explode( ',', $result['cat_id'] );
345
+										}
346
+										if ( !is_array( $record['cat_id'] ) )
347
+										{
348
+											$record['cat_id'] = explode( ',', $record['cat_id'] );
349
+										}
294 350
 										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $result['cat_id'] ) ) );
295 351
 									}
296 352
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
297 353
 								}
298
-							} else {
354
+							}
355
+							else
356
+							{
299 357
 								$action = $condition['false'];
300 358
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
301 359
 							}
@@ -306,13 +364,21 @@  discard block
 block discarded – undo
306 364
 							die('condition / action not supported!!!');
307 365
 							break;
308 366
 					}
309
-					if ($action['last']) break;
367
+					if ($action['last'])
368
+					{
369
+						break;
370
+					}
310 371
 				}
311
-			} else {
372
+			}
373
+			else
374
+			{
312 375
 				// unconditional insert
313 376
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
314 377
 			}
315
-			if($success) $count++;
378
+			if($success)
379
+			{
380
+				$count++;
381
+			}
316 382
 		}
317 383
 		return $count;
318 384
 	}
@@ -324,9 +390,11 @@  discard block
 block discarded – undo
324 390
 	 * @param array $_data tracker data for the action
325 391
 	 * @return bool success or not
326 392
 	 */
327
-	private function action ( $_action, $_data, $record_num = 0 ) {
393
+	private function action ( $_action, $_data, $record_num = 0 )
394
+	{
328 395
 		$result = true;
329
-		switch ($_action) {
396
+		switch ($_action)
397
+		{
330 398
 			case 'none' :
331 399
 				return true;
332 400
 			case 'update' :
@@ -334,7 +402,8 @@  discard block
 block discarded – undo
334 402
 				$old_record = new timesheet_egw_record($_data['ts_id']);
335 403
 				$old = $old_record->get_record_array();
336 404
 
337
-				if(!$this->definition->plugin_options['change_owner']) {
405
+				if(!$this->definition->plugin_options['change_owner'])
406
+				{
338 407
 					// Don't change creator of an existing ticket
339 408
 					unset($_data['ts_owner']);
340 409
 				}
@@ -342,36 +411,45 @@  discard block
 block discarded – undo
342 411
 				// Merge to deal with fields not in import record
343 412
 				$_data = array_merge($old, $_data);
344 413
 				$changed = $this->tracking->changed_fields($_data, $old);
345
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
414
+				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
415
+				{
346 416
 					break;
347 417
 				}
348 418
 
349 419
 				// Clear old link, if different
350
-				if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id']) {
420
+				if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id'])
421
+				{
351 422
 					egw_link::unlink2(0,TIMESHEET_APP,$_data['ts_id'],0,'projectmanager',$old['pm_id']);
352 423
 				}
353 424
 				
354 425
 				// Fall through
355 426
 			case 'insert' :
356
-				if ( $this->dry_run ) {
427
+				if ( $this->dry_run )
428
+				{
357 429
 					//print_r($_data);
358 430
 					$this->results[$_action]++;
359 431
 					break;
360
-				} else {
432
+				}
433
+				else
434
+				{
361 435
 					$result = $this->bo->save( $_data);
362 436
 					$_data['ts_id'] = $this->bo->data['ts_id'];
363 437
 
364 438
 					// Set projectmanager link
365
-					if ($_data['pm_id']) {
439
+					if ($_data['pm_id'])
440
+					{
366 441
 						egw_link::link(TIMESHEET_APP,$_data['ts_id'],'projectmanager',$_data['pm_id']);
367 442
 					}
368 443
 
369
-					if($result) {
444
+					if($result)
445
+					{
370 446
 						$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
371 447
 							$GLOBALS['egw']->accounts->id2name($_data['owner']),
372 448
 							lang($_action)
373 449
 						) . ' ' . $result;
374
-					} else {
450
+					}
451
+					else
452
+					{
375 453
 						$this->results[$_action]++;
376 454
 						$result = $this->bo->data['ts_id'];
377 455
 					}
@@ -382,21 +460,30 @@  discard block
 block discarded – undo
382 460
 		}
383 461
 
384 462
 		// Process some additional fields
385
-		if(!is_numeric($result)) {
463
+		if(!is_numeric($result))
464
+		{
386 465
 			return $result;
387 466
 		}
388 467
 		$_link_id = false;
389
-		foreach(self::$special_fields as $field => $desc) {
390
-			if(!$_data[$field]) continue;
468
+		foreach(self::$special_fields as $field => $desc)
469
+		{
470
+			if(!$_data[$field])
471
+			{
472
+				continue;
473
+			}
391 474
 
392 475
 			// Links
393
-			if(strpos('link', $field) === 0) {
476
+			if(strpos('link', $field) === 0)
477
+			{
394 478
 				list($app, $id) = explode(':', $_data[$field]);
395
-			} else {
479
+			}
480
+			else
481
+			{
396 482
 				$app = $field;
397 483
 				$id = $_data[$field];
398 484
 			}
399
-			if ($app && $app_id) {
485
+			if ($app && $app_id)
486
+			{
400 487
 				$link_id = egw_link::link('timesheet',$id,$app,$app_id);
401 488
 			}
402 489
 		}
@@ -408,7 +495,8 @@  discard block
 block discarded – undo
408 495
 	 *
409 496
 	 * @return string name
410 497
 	 */
411
-	public static function get_name() {
498
+	public static function get_name()
499
+	{
412 500
 		return lang('Timesheet CSV import');
413 501
 	}
414 502
 
@@ -417,7 +505,8 @@  discard block
 block discarded – undo
417 505
 	 *
418 506
 	 * @return string descriprion
419 507
 	 */
420
-	public static function get_description() {
508
+	public static function get_description()
509
+	{
421 510
 		return lang("Imports entries into the timesheet from a CSV File. ");
422 511
 	}
423 512
 
@@ -426,7 +515,8 @@  discard block
 block discarded – undo
426 515
 	 *
427 516
 	 * @return string suffix (comma seperated)
428 517
 	 */
429
-	public static function get_filesuffix() {
518
+	public static function get_filesuffix()
519
+	{
430 520
 		return 'csv';
431 521
 	}
432 522
 
@@ -442,7 +532,8 @@  discard block
 block discarded – undo
442 532
 	 * 		preserv		=> array,
443 533
 	 * )
444 534
 	 */
445
-	public function get_options_etpl() {
535
+	public function get_options_etpl()
536
+	{
446 537
 		// lets do it!
447 538
 	}
448 539
 
@@ -451,7 +542,8 @@  discard block
 block discarded – undo
451 542
 	 *
452 543
 	 * @return string etemplate name
453 544
 	 */
454
-	public function get_selectors_etpl() {
545
+	public function get_selectors_etpl()
546
+	{
455 547
 		// lets do it!
456 548
 	}
457 549
 
@@ -463,7 +555,8 @@  discard block
 block discarded – undo
463 555
         *       record_# => warning message
464 556
         *       )
465 557
         */
466
-        public function get_warnings() {
558
+        public function get_warnings()
559
+        {
467 560
 		return $this->warnings;
468 561
 	}
469 562
 
@@ -475,7 +568,8 @@  discard block
 block discarded – undo
475 568
         *       record_# => error message
476 569
         *       )
477 570
         */
478
-        public function get_errors() {
571
+        public function get_errors()
572
+        {
479 573
 		return $this->errors;
480 574
 	}
481 575
 
@@ -487,13 +581,15 @@  discard block
 block discarded – undo
487 581
         *       action => record count
488 582
         * )
489 583
         */
490
-        public function get_results() {
584
+        public function get_results()
585
+        {
491 586
                 return $this->results;
492 587
         }
493 588
 	// end of iface_export_plugin
494 589
 
495 590
 	// Extra conversion functions - must be static
496
-	public static function addr_id( $n_family,$n_given=null,$org_name=null ) {
591
+	public static function addr_id( $n_family,$n_given=null,$org_name=null )
592
+	{
497 593
 
498 594
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
499 595
 		static $contacts;
@@ -503,28 +599,40 @@  discard block
 block discarded – undo
503 599
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
504 600
 		}
505 601
 		$n_family = trim($n_family);
506
-		if(!is_null($n_given)) $n_given = trim($n_given);
602
+		if(!is_null($n_given))
603
+		{
604
+			$n_given = trim($n_given);
605
+		}
507 606
 		if (!is_object($contacts))
508 607
 		{
509 608
 			$contacts =& CreateObject('phpgwapi.contacts');
510 609
 		}
511
-		if (!is_null($org_name))        // org_name given?
610
+		if (!is_null($org_name))
611
+		{
612
+			// org_name given?
512 613
 		{
513 614
 			$org_name = trim($org_name);
615
+		}
514 616
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
515 617
 			if (!count($addrs))
516 618
 			{
517 619
 				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
518 620
 			}
519 621
 		}
520
-		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
622
+		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))
623
+		{
624
+			// first name given and no result so far
521 625
 		{
522 626
 			$addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given));
523 627
 		}
524
-		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
628
+		}
629
+		if (is_null($n_given) && is_null($org_name))
630
+		{
631
+			// just one name given, check against fn (= full name)
525 632
 		{
526 633
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
527 634
 		}
635
+		}
528 636
 		if (count($addrs))
529 637
 		{
530 638
 			return $addrs[0]['id'];
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_ui.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1053,7 +1053,7 @@
 block discarded – undo
1053 1053
 	 * @param int &$success number of succeded actions
1054 1054
 	 * @param int &$failed number of failed actions (not enought permissions)
1055 1055
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like %1 timesheets 'deleted'
1056
-	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1056
+	 * @param string $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1057 1057
 	 * @return boolean true if all actions succeded, false otherwise
1058 1058
 	 */
1059 1059
 	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -942,7 +942,7 @@
 block discarded – undo
942 942
 	 *
943 943
 	 * @return array see nextmatch_widget::egw_actions()
944 944
 	 */
945
-	public function get_actions(Array $query)
945
+	public function get_actions(array $query)
946 946
 	{
947 947
 		$actions = array(
948 948
 			'open' => array(	// does edit if allowed, otherwise view
Please login to merge, or discard this patch.
Spacing   +162 added lines, -163 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 
50 50
 	function view()
51 51
 	{
52
-		$this->edit(null,true);
52
+		$this->edit(null, true);
53 53
 	}
54 54
 
55
-	function edit($content = null,$view = false)
55
+	function edit($content = null, $view = false)
56 56
 	{
57 57
 		$etpl = new etemplate_new('timesheet.edit');
58 58
 		if (!is_array($content))
@@ -74,20 +74,19 @@  discard block
 block discarded – undo
74 74
 			{
75 75
 				$this->data = array(
76 76
 					'ts_start' => $this->today,
77
-					'start_time' => '',	// force empty start-time
78
-					'end_time' => egw_time::to($this->now,'H:i'),
77
+					'start_time' => '', // force empty start-time
78
+					'end_time' => egw_time::to($this->now, 'H:i'),
79 79
 					'ts_owner' => $GLOBALS['egw_info']['user']['account_id'],
80
-					'cat_id'   => (int) $_REQUEST['cat_id'],
80
+					'cat_id'   => (int)$_REQUEST['cat_id'],
81 81
 					'ts_status'=> $GLOBALS['egw_info']['user']['preferences']['timesheet']['predefined_status'],
82 82
 				);
83 83
 			}
84 84
 			$matches = null;
85
-			$referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] :
86
-				(strpos($_SERVER['HTTP_REFERER'],'/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
85
+			$referer = preg_match('/menuaction=([^&]+)/', $_SERVER['HTTP_REFERER'], $matches) ? $matches[1] : (strpos($_SERVER['HTTP_REFERER'], '/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
87 86
 
88 87
 			if (!$this->check_statusForEditRights($this->data))
89 88
 			{
90
-				$view = true;  //only admin can edit with this status
89
+				$view = true; //only admin can edit with this status
91 90
 				$only_admin_edit = true;
92 91
 				$msg = lang('only Admin can edit this status');
93 92
 			}
@@ -100,7 +99,7 @@  discard block
 block discarded – undo
100 99
 			{
101 100
 				if ($this->status_labels_config[$content['ts_status']]['admin'])
102 101
 				{
103
-					$view = true;  //only admin can edit with this status
102
+					$view = true; //only admin can edit with this status
104 103
 					$only_admin_edit = true;
105 104
 					$msg = lang('only Admin can edit this status');
106 105
 				}
@@ -114,29 +113,29 @@  discard block
 block discarded – undo
114 113
 			{
115 114
 				//$content['ts_start'] += $content['start_time'];
116 115
 				$start = new egw_time($content['ts_start']);
117
-				$start_time = explode(':',$content['start_time']);
118
-				$start->setTime($start_time[0],$start_time[1]);
116
+				$start_time = explode(':', $content['start_time']);
117
+				$start->setTime($start_time[0], $start_time[1]);
119 118
 				$content['ts_start'] = $start->format('ts');
120 119
 			}
121 120
 			if (isset($content['end_time']))		// end-time specified
122 121
 			{
123 122
 				$end = new egw_time($content['ts_start']);
124
-				$end_time = explode(':',$content['end_time']);
125
-				$end->setTime($end_time[0],$end_time[1]);
123
+				$end_time = explode(':', $content['end_time']);
124
+				$end->setTime($end_time[0], $end_time[1]);
126 125
 			}
127 126
 			if ($end && $start)	// start- & end-time --> calculate the duration
128 127
 			{
129 128
 				$content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60;
130 129
 				// check if negative duration is caused by wrap over midnight
131
-				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60)
130
+				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24 * 60)
132 131
 				{
133
-					$content['ts_duration'] += 24*60;
132
+					$content['ts_duration'] += 24 * 60;
134 133
 				}
135 134
 				//echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n";
136 135
 			}
137 136
 			elseif ($content['ts_duration'] && $end)	// no start, calculate from end and duration
138 137
 			{
139
-				$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
138
+				$content['ts_start'] = $end->format('ts') - 60 * $content['ts_duration'];
140 139
 				//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".egw_time::to($content['ts_start'])."</p>\n";
141 140
 			}
142 141
 			if ($content['ts_duration'] > 0) unset($content['end_time']);
@@ -146,18 +145,18 @@  discard block
 block discarded – undo
146 145
 			$referer = $content['referer'];
147 146
 			$content['ts_project_blur'] = $content['pm_id'] ? egw_link::title('projectmanager', $content['pm_id']) : '';
148 147
 			$this->data = $content;
149
-			foreach(array('button','view','referer','tabs','start_time') as $key)
148
+			foreach (array('button', 'view', 'referer', 'tabs', 'start_time') as $key)
150 149
 			{
151 150
 				unset($this->data[$key]);
152 151
 			}
153
-			switch($button)
152
+			switch ($button)
154 153
 			{
155 154
 				case 'edit':
156 155
 					if ($this->check_acl(EGW_ACL_EDIT) && !$only_admin_edit) $view = false;
157 156
 					break;
158 157
 
159 158
 				case 'undelete':
160
-					if($content['ts_status'] == self::DELETED_STATUS)
159
+					if ($content['ts_status'] == self::DELETED_STATUS)
161 160
 					{
162 161
 						unset($content['ts_status']);
163 162
 						$this->data['ts_status'] = '';
@@ -175,14 +174,14 @@  discard block
 block discarded – undo
175 174
 					}
176 175
 					if (!$this->data['ts_quantity'])
177 176
 					{
178
-						$etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!'));
177
+						$etpl->set_validation_error('ts_quantity', lang('Field must not be empty !!!'));
179 178
 					}
180 179
 					if ($this->data['ts_duration'] < 0)
181 180
 					{
182
-						$etpl->set_validation_error('start_time',lang('Starttime has to be before endtime !!!'));
181
+						$etpl->set_validation_error('start_time', lang('Starttime has to be before endtime !!!'));
183 182
 					}
184 183
 					// set ts_title to ts_project if short viewtype (title is not editable)
185
-					if($this->ts_viewtype == 'short')
184
+					if ($this->ts_viewtype == 'short')
186 185
 					{
187 186
 						$this->data['ts_title'] = $this->data['ts_project'];
188 187
 					}
@@ -193,9 +192,9 @@  discard block
 block discarded – undo
193 192
 
194 193
 						if (!$this->data['ts_title'])
195 194
 						{
196
-							$etpl->set_validation_error('ts_title',lang('Field must not be empty !!!'));
195
+							$etpl->set_validation_error('ts_title', lang('Field must not be empty !!!'));
197 196
 						}
198
-						elseif($button != 'save_new')
197
+						elseif ($button != 'save_new')
199 198
 						{
200 199
 							// remove title-blur for same behavior after apply, as for opening the saved entry again
201 200
 							unset($this->data['ts_title_blur']);
@@ -204,26 +203,26 @@  discard block
 block discarded – undo
204 203
 							unset($content['ts_project_blur']);
205 204
 						}
206 205
 					}
207
-					if ($etpl->validation_errors()) break;	// the user need to fix the error, before we can save the entry
206
+					if ($etpl->validation_errors()) break; // the user need to fix the error, before we can save the entry
208 207
 
209 208
 					// account for changed project --> remove old one from links and add new one
210
-					if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id'])
209
+					if ((int)$this->data['pm_id'] != (int)$this->data['old_pm_id'])
211 210
 					{
212 211
 						// update links accordingly
213 212
 						if ($this->data['pm_id'])
214 213
 						{
215
-							egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
214
+							egw_link::link(TIMESHEET_APP, $content['link_to']['to_id'], 'projectmanager', $this->data['pm_id']);
216 215
 						}
217 216
 						if ($this->data['old_pm_id'])
218 217
 						{
219
-							egw_link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
218
+							egw_link::unlink2(0, TIMESHEET_APP, $content['link_to']['to_id'], 0, 'projectmanager', $this->data['old_pm_id']);
220 219
 							unset($this->data['old_pm_id']);
221 220
 						}
222 221
 					}
223 222
 					// check if we are linked to a project, but that is NOT set as project
224 223
 					if (!$this->data['pm_id'] && is_array($content['link_to']['to_id']))
225 224
 					{
226
-						foreach($content['link_to']['to_id'] as $data)
225
+						foreach ($content['link_to']['to_id'] as $data)
227 226
 						{
228 227
 							if ($data['app'] == 'projectmanager')
229 228
 							{
@@ -244,26 +243,26 @@  discard block
 block discarded – undo
244 243
 						$msg = lang('Entry saved');
245 244
 						if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
246 245
 						{
247
-							egw_link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
246
+							egw_link::link(TIMESHEET_APP, $this->data['ts_id'], $content['link_to']['to_id']);
248 247
 						}
249 248
 					}
250 249
 					egw_framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
251 250
 					if ($button == 'apply') break;
252 251
 					if ($button == 'save_new')
253 252
 					{
254
-						$msg .= ', '.lang('creating new entry');		// giving some feedback to the user
253
+						$msg .= ', '.lang('creating new entry'); // giving some feedback to the user
255 254
 
256 255
 						if (!is_array($content['link_to']['to_id']))	// set links again, so new entry gets the same links as the existing one
257 256
 						{
258 257
 							$content['link_to']['to_id'] = 0;
259
-							foreach(egw_link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.egw_link::VFS_APPNAME) as $link)
258
+							foreach (egw_link::get_links(TIMESHEET_APP, $this->data['ts_id'], '!'.egw_link::VFS_APPNAME) as $link)
260 259
 							{
261
-								egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
260
+								egw_link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
262 261
 							}
263 262
 						}
264 263
 						// create a new entry
265 264
 						$this->data['ts_start'] += 60 * $this->data['ts_duration'];
266
-						foreach(array('ts_id','ts_title','ts_description','ts_duration','ts_quantity','ts_modified','ts_modifier') as $name)
265
+						foreach (array('ts_id', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_modified', 'ts_modifier') as $name)
267 266
 						{
268 267
 							unset($this->data[$name]);
269 268
 						}
@@ -283,7 +282,7 @@  discard block
 block discarded – undo
283 282
 						else
284 283
 						{
285 284
 							$msg = lang('Error deleting the entry!!!');
286
-							break;	// dont close window
285
+							break; // dont close window
287 286
 						}
288 287
 					}
289 288
 					// fall-through for save
@@ -296,7 +295,7 @@  discard block
 block discarded – undo
296 295
 			'referer' => $referer,
297 296
 			'ts_title_blur' => $content['ts_title_blur'],
298 297
 		);
299
-		$content = array_merge($this->data,array(
298
+		$content = array_merge($this->data, array(
300 299
 			'msg'  => $msg,
301 300
 			'view' => $view,
302 301
 			'tabs'  => $content['tabs'],
@@ -304,8 +303,8 @@  discard block
 block discarded – undo
304 303
 				'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] : $content['link_to']['to_id'],
305 304
 				'to_app' => TIMESHEET_APP,
306 305
 			),
307
-			'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0,3) : '',
308
-			'ts_quantity' => $this->data['ts_duration']/60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
306
+			'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0, 3) : '',
307
+			'ts_quantity' => $this->data['ts_duration'] / 60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
309 308
 			'start_time' => isset($this->data['start_time']) ? $this->data['start_time'] : $this->data['ts_start'],
310 309
 			'pm_integration' => $this->pm_integration,
311 310
 			'no_ts_status' => !$this->status_labels && ($this->data['ts_status'] != self::DELETED_STATUS),
@@ -315,10 +314,10 @@  discard block
 block discarded – undo
315 314
 		if (!$this->data['ts_id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
316 315
 		{
317 316
 			$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
318
-			foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
317
+			foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
319 318
 			{
320 319
 				$link_id = $link_ids[$n];
321
-				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
320
+				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// gard against XSS
322 321
 				{
323 322
 					switch ($link_app)
324 323
 					{
@@ -326,33 +325,33 @@  discard block
 block discarded – undo
326 325
 							$links[] = $link_id;
327 326
 							// fall-through;
328 327
 						default:
329
-							if(!$n)
328
+							if (!$n)
330 329
 							{
331 330
 								// get title from first linked app
332
-								$preserv['ts_title_blur'] = egw_link::title($link_app,$link_id);
331
+								$preserv['ts_title_blur'] = egw_link::title($link_app, $link_id);
333 332
 								// ask first linked app via "timesheet_set" hook, for further data to set, incl. links
334
-								if (($set = $GLOBALS['egw']->hooks->single(array('location'=>'timesheet_set','id'=>$link_id),$link_app)))
333
+								if (($set = $GLOBALS['egw']->hooks->single(array('location'=>'timesheet_set', 'id'=>$link_id), $link_app)))
335 334
 								{
336
-									foreach((array)$set['link_app'] as $i => $l_app)
335
+									foreach ((array)$set['link_app'] as $i => $l_app)
337 336
 									{
338
-										if (($l_id=$set['link_id'][$i])) egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
337
+										if (($l_id = $set['link_id'][$i])) egw_link::link(TIMESHEET_APP, $content['link_to']['to_id'], $l_app, $l_id);
339 338
 										if ($l_app == 'projectmanager') $links[] = $l_id;
340 339
 									}
341 340
 									unset($set['link_app']);
342 341
 									unset($set['link_id']);
343 342
 
344
-									$content = array_merge($content,$set);
343
+									$content = array_merge($content, $set);
345 344
 								}
346 345
 							}
347 346
 							break;
348 347
 					}
349
-					egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
348
+					egw_link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link_app, $link_id);
350 349
 				}
351 350
 			}
352 351
 		}
353 352
 		elseif ($this->data['ts_id'])
354 353
 		{
355
-			$links = egw_link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
354
+			$links = egw_link::get_links(TIMESHEET_APP, $this->data['ts_id'], 'projectmanager');
356 355
 		}
357 356
 		// make all linked projects availible for the pm-pricelist widget, to be able to choose prices from all
358 357
 		$content['all_pm_ids'] = array_values($links);
@@ -395,7 +394,7 @@  discard block
 block discarded – undo
395 394
 
396 395
 		if ($view)
397 396
 		{
398
-			foreach(array_merge(array_keys($this->data),array('pm_id','pl_id','link_to')) as $key)
397
+			foreach (array_merge(array_keys($this->data), array('pm_id', 'pl_id', 'link_to')) as $key)
399 398
 			{
400 399
 				$readonlys[$key] = true;
401 400
 			}
@@ -411,9 +410,9 @@  discard block
 block discarded – undo
411 410
 		{
412 411
 			$edit_grants[$content['ts_owner']] = common::grab_owner_name($content['ts_owner']);
413 412
 		}
414
-		$sel_options['ts_owner']  = $edit_grants;
415
-		$sel_options['ts_status']  = $this->status_labels;
416
-		if($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
413
+		$sel_options['ts_owner'] = $edit_grants;
414
+		$sel_options['ts_status'] = $this->status_labels;
415
+		if ($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
417 416
 		{
418 417
 			$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
419 418
 		}
@@ -423,19 +422,19 @@  discard block
 block discarded – undo
423 422
 		// supress unknow widget 'projectmanager-*', if projectmanager is not installed or old
424 423
 		if (!@file_exists(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.projectmanager_widget.inc.php'))
425 424
 		{
426
-			$etpl->set_cell_attribute('pm_id','disabled',true);
427
-			$etpl->set_cell_attribute('pl_id','disabled',true);
425
+			$etpl->set_cell_attribute('pm_id', 'disabled', true);
426
+			$etpl->set_cell_attribute('pl_id', 'disabled', true);
428 427
 		}
429 428
 
430
-		if($this->ts_viewtype == 'short')
429
+		if ($this->ts_viewtype == 'short')
431 430
 		{
432 431
 			$content['ts_viewtype'] = $readonlys['tabs']['notes'] = true;
433 432
 			$content['ts_description_short'] = $content['ts_description'];
434 433
 		}
435
-		if (!$this->customfields) $readonlys['tabs']['customfields'] = true;	// suppress tab if there are not customfields
436
-		if (!$this->data['ts_id']) $readonlys['tabs']['history']    = true;   //suppress history for the first loading without ID
434
+		if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields
435
+		if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID
437 436
 
438
-		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2);
437
+		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit', $content, $sel_options, $readonlys, $preserv, 2);
439 438
 	}
440 439
 
441 440
 	/**
@@ -448,7 +447,7 @@  discard block
 block discarded – undo
448 447
 	{
449 448
 		if (!$datetime) return 0;
450 449
 
451
-		return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime));
450
+		return $datetime - mktime(0, 0, 0, date('m', $datetime), date('d', $datetime), date('Y', $datetime));
452 451
 	}
453 452
 
454 453
 	/**
@@ -462,17 +461,17 @@  discard block
 block discarded – undo
462 461
 	 * @param boolean $id_only if true only return (via $rows) an array of contact-ids, dont save state to session
463 462
 	 * @return int total number of contacts matching the selection
464 463
 	 */
465
-	function get_rows(&$query_in,&$rows,&$readonlys,$id_only=false)
464
+	function get_rows(&$query_in, &$rows, &$readonlys, $id_only = false)
466 465
 	{
467 466
 		$this->show_sums = false;
468 467
 		if ($query_in['filter'])
469 468
 		{
470
-			$date_filter = $this->date_filter($query_in['filter'],$query_in['startdate'],$query_in['enddate']);
469
+			$date_filter = $this->date_filter($query_in['filter'], $query_in['startdate'], $query_in['enddate']);
471 470
 
472 471
 			if ($query_in['startdate'])
473 472
 			{
474
-				$start = explode('-',date('Y-m-d',$query_in['startdate']+12*60*60));
475
-				$end   = explode('-',date('Y-m-d',$query_in['enddate'] ? $query_in['enddate'] : $query_in['startdate']+7.5*24*60*60));
473
+				$start = explode('-', date('Y-m-d', $query_in['startdate'] + 12 * 60 * 60));
474
+				$end   = explode('-', date('Y-m-d', $query_in['enddate'] ? $query_in['enddate'] : $query_in['startdate'] + 7.5 * 24 * 60 * 60));
476 475
 
477 476
 				// show year-sums, if we are year-aligned (show full years)?
478 477
 				if ((int)$start[2] == 1 && (int)$start[1] == 1 && (int)$end[2] == 31 && (int)$end[1] == 12)
@@ -480,42 +479,42 @@  discard block
 block discarded – undo
480 479
 					$this->show_sums[] = 'year';
481 480
 				}
482 481
 				// show month-sums, if we are month-aligned (show full monthes)?
483
-				if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d',mktime(12,0,0,$end[1]+1,0,$end[0])))
482
+				if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d', mktime(12, 0, 0, $end[1] + 1, 0, $end[0])))
484 483
 				{
485 484
 					$this->show_sums[] = 'month';
486 485
 				}
487 486
 				// show week-sums, if we are week-aligned (show full weeks)?
488 487
 				$week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'];
489 488
 				if (!$week_start_day) $week_start_day = 'Sunday';
490
-				switch($week_start_day)
489
+				switch ($week_start_day)
491 490
 				{
492 491
 					case 'Sunday': $week_end_day = 'Saturday'; break;
493 492
 					case 'Monday': $week_end_day = 'Sunday'; break;
494 493
 					case 'Saturday': $week_end_day = 'Friday'; break;
495 494
 				}
496
-				$filter_start_day = date('l',$query_in['startdate']+12*60*60);
497
-				$filter_end_day   = $query_in['enddate'] ? date('l',$query_in['enddate']+12*60*60) : false;
495
+				$filter_start_day = date('l', $query_in['startdate'] + 12 * 60 * 60);
496
+				$filter_end_day   = $query_in['enddate'] ? date('l', $query_in['enddate'] + 12 * 60 * 60) : false;
498 497
 				//echo "<p align=right>prefs: $week_start_day - $week_end_day, filter: $filter_start_day - $filter_end_day</p>\n";
499 498
 				if ($filter_start_day == $week_start_day && (!$filter_end_day || $filter_end_day == $week_end_day))
500 499
 				{
501 500
 					$this->show_sums[] = 'week';
502 501
 				}
503 502
 				// show day-sums, if range <= 5 weeks
504
-				if (!$query_in['enddate'] || $query_in['enddate'] - $query_in['startdate'] < 36*24*60*60)
503
+				if (!$query_in['enddate'] || $query_in['enddate'] - $query_in['startdate'] < 36 * 24 * 60 * 60)
505 504
 				{
506 505
 					$this->show_sums[] = 'day';
507 506
 				}
508 507
 			}
509 508
 		}
510 509
 		//echo "<p align=right>show_sums=".print_r($this->show_sums,true)."</p>\n";
511
-		if (!$id_only && !$query_in['csv_export']) $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP,$query_in);
510
+		if (!$id_only && !$query_in['csv_export']) $GLOBALS['egw']->session->appsession('index', TIMESHEET_APP, $query_in);
512 511
 
513 512
 		// Refresh actions (undelete needs this)
514 513
 		$query_in['actions'] = $this->get_actions($query_in);
515 514
 
516
-		$query = $query_in;	// keep the original query
515
+		$query = $query_in; // keep the original query
517 516
 
518
-		if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
517
+		if ($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false, 'ts_unitprice'=>false, 'ts_total'=>false);
519 518
 		if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false;
520 519
 
521 520
 		//_debug_array($query['col_filter']);
@@ -542,10 +541,10 @@  discard block
 block discarded – undo
542 541
 		// handle linked filter (show only entries linked to a certain other entry)
543 542
 		if ($query['col_filter']['linked'])
544 543
 		{
545
-			list($app,$id) = explode(':',$query['col_filter']['linked']);
546
-			if (!($links = egw_link::get_links($app,$id,'timesheet')))
544
+			list($app, $id) = explode(':', $query['col_filter']['linked']);
545
+			if (!($links = egw_link::get_links($app, $id, 'timesheet')))
547 546
 			{
548
-				$rows = array();	// no infologs linked to project --> no rows to return
547
+				$rows = array(); // no infologs linked to project --> no rows to return
549 548
 				return 0;
550 549
 			}
551 550
 			if (!$query['col_filter']['ts_id'])
@@ -553,9 +552,9 @@  discard block
 block discarded – undo
553 552
 				$query['col_filter']['ts_id'] = array_values(array_unique($links));
554 553
 			}
555 554
 			// allow to combine with other filters using ts_id --> intersect ids
556
-			elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'],array_values(array_unique($links)))))
555
+			elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'], array_values(array_unique($links)))))
557 556
 			{
558
-				$rows = array();	// no infologs linked to project --> no rows to return
557
+				$rows = array(); // no infologs linked to project --> no rows to return
559 558
 				return 0;
560 559
 			}
561 560
 		}
@@ -579,13 +578,13 @@  discard block
 block discarded – undo
579 578
 			{
580 579
 				if (isset($this->status_labels_substatus['2level'][$status_id]))
581 580
 				{
582
-					$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'],$this->status_labels_substatus[$status_id]);
581
+					$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'], $this->status_labels_substatus[$status_id]);
583 582
 				}
584 583
 			}
585 584
 		}
586 585
 		if ((int)$query['filter2'] != (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'])
587 586
 		{
588
-			$GLOBALS['egw']->preferences->add(TIMESHEET_APP,'show_details',(int)$query['filter2']);
587
+			$GLOBALS['egw']->preferences->add(TIMESHEET_APP, 'show_details', (int)$query['filter2']);
589 588
 			$GLOBALS['egw']->preferences->save_repository(true);
590 589
 		}
591 590
 		// category filter: cat_id or ''=All cats or 0=No cat
@@ -608,7 +607,7 @@  discard block
 block discarded – undo
608 607
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.common::grab_owner_name($query['col_filter']['ts_owner']);
609 608
 			#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
610 609
 			#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
611
-			if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
610
+			if ($query['col_filter']['ts_owner'] < 0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']), $GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'], true));
612 611
 		}
613 612
 		else
614 613
 		{
@@ -621,51 +620,51 @@  discard block
 block discarded – undo
621 620
 			// generate a meaningful app-header / report title
622 621
 			if ($this->show_sums['month'])
623 622
 			{
624
-				if ((int)$start[1] == 1 && (int) $end[1] == 12)		// whole year(s)
623
+				if ((int)$start[1] == 1 && (int)$end[1] == 12)		// whole year(s)
625 624
 				{
626
-					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : '');
625
+					$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$start[0].($start[0] != $end[0] ? ' - '.$end[0] : '');
627 626
 				}
628 627
 				else
629 628
 				{
630
-					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0];
629
+					$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(date('F', $query['startdate'] + 12 * 60 * 60)).' '.$start[0];
631 630
 					if ($start[0] != $end[0] || $start[1] != $end[1])
632 631
 					{
633
-						$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . lang(date('F',$query['enddate']+12*60*60)) . ' ' . $end[0];
632
+						$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang(date('F', $query['enddate'] + 12 * 60 * 60)).' '.$end[0];
634 633
 					}
635 634
 				}
636 635
 			}
637 636
 			elseif ($this->show_sums['week'])
638 637
 			{
639
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang('week') . ' ' . date('W',$query['startdate']+36*60*60) . '/' . $start[0];
640
-				if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10*24*60*60)
638
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('week').' '.date('W', $query['startdate'] + 36 * 60 * 60).'/'.$start[0];
639
+				if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10 * 24 * 60 * 60)
641 640
 				{
642
-					$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . date('W',$query['enddate']-36*60*60) . '/' . $end[0];
641
+					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.date('W', $query['enddate'] - 36 * 60 * 60).'/'.$end[0];
643 642
 				}
644 643
 			}
645 644
 			elseif ($query['startdate'])
646 645
 			{
647 646
 				$df = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
648
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . common::show_date($query['startdate']+12*60*60,$df,false);
647
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.common::show_date($query['startdate'] + 12 * 60 * 60, $df, false);
649 648
 				if ($start != $end)
650 649
 				{
651
-					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.common::show_date($query['enddate']+12*60*60,$df,false);
650
+					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.common::show_date($query['enddate'] + 12 * 60 * 60, $df, false);
652 651
 				}
653 652
 			}
654 653
 		}
655
-		$total = parent::get_rows($query,$rows,$readonlys);
654
+		$total = parent::get_rows($query, $rows, $readonlys);
656 655
 
657 656
 		$ids = array();
658
-		foreach($rows as &$row)
657
+		foreach ($rows as &$row)
659 658
 		{
660 659
 			if ($row['ts_id'] > 0) $ids[] = $row['ts_id'];
661 660
 		}
662 661
 		if ($id_only)
663 662
 		{
664 663
 			$rows = $ids;
665
-			return $this->total;	// no need to set other fields or $readonlys
664
+			return $this->total; // no need to set other fields or $readonlys
666 665
 		}
667 666
 		$links = array();
668
-		$links3 = egw_link::get_links_multiple(TIMESHEET_APP,$ids,true,'projectmanager');	// only check for pm links!
667
+		$links3 = egw_link::get_links_multiple(TIMESHEET_APP, $ids, true, 'projectmanager'); // only check for pm links!
669 668
 		//as the full array is expected, we must supply the missing but needed (since expected further down) information
670 669
 		if (is_array($links3))
671 670
 		{
@@ -685,14 +684,14 @@  discard block
 block discarded – undo
685 684
 
686 685
 		$readonlys = array();
687 686
 		$have_cats = false;
688
-		foreach($rows as &$row)
687
+		foreach ($rows as &$row)
689 688
 		{
690 689
 			if ($row['cat_id']) $have_cats = true;
691 690
 
692 691
 			$row['class'] = 'row';
693 692
 			if ($row['ts_id'] <= 0)	// sums
694 693
 			{
695
-				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;	// fix for DSL change
694
+				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; // fix for DSL change
696 695
 
697 696
 				// Remove fake modified date, it breaks nextmatch checks
698 697
 				unset($row['ts_modified']);
@@ -700,23 +699,23 @@  discard block
 block discarded – undo
700 699
 				// Set flag to avoid actions on these rows
701 700
 				$row['no_actions'] = true;
702 701
 
703
-				switch($row['ts_id'])
702
+				switch ($row['ts_id'])
704 703
 				{
705 704
 					case 0:	// day-sum
706
-						$row['ts_title'] = lang('Sum %1:',lang(date('l',$row['ts_start'])).' '.common::show_date($row['ts_start'],
707
-						$GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],false));
705
+						$row['ts_title'] = lang('Sum %1:', lang(date('l', $row['ts_start'])).' '.common::show_date($row['ts_start'],
706
+						$GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], false));
708 707
 						$row['ts_id'] = 'sum-day-'.$row['ts_start'];
709 708
 						break;
710 709
 					case -1:	// week-sum
711
-						$row['ts_title'] = lang('Sum %1:',lang('week').' '.substr($row['ts_week'],4).'/'.substr($row['ts_week'],0,4));
710
+						$row['ts_title'] = lang('Sum %1:', lang('week').' '.substr($row['ts_week'], 4).'/'.substr($row['ts_week'], 0, 4));
712 711
 						$row['ts_id'] = 'sum-week-'.$row['ts_week'];
713 712
 						break;
714 713
 					case -2:	// month-sum
715
-						$row['ts_title'] = lang('Sum %1:',lang(date('F',$row['ts_start'])).' '.substr($row['ts_month'],0,4));
714
+						$row['ts_title'] = lang('Sum %1:', lang(date('F', $row['ts_start'])).' '.substr($row['ts_month'], 0, 4));
716 715
 						$row['ts_id'] = 'sum-month-'.$row['ts_month'];
717 716
 						break;
718 717
 					case -3:	// year-sum
719
-						$row['ts_title'] = lang('Sum %1:',$row['ts_year']);
718
+						$row['ts_title'] = lang('Sum %1:', $row['ts_year']);
720 719
 						$row['ts_id'] = 'sum-year-'.$row['ts_year'];
721 720
 						break;
722 721
 				}
@@ -726,11 +725,11 @@  discard block
 block discarded – undo
726 725
 				$row['titleClass'] = 'timesheet_titleSum';
727 726
 				continue;
728 727
 			}
729
-			if($row['ts_quantity'])
728
+			if ($row['ts_quantity'])
730 729
 			{
731 730
 				$row['ts_quantity'] = round($row['ts_quantity'], 2);
732 731
 			}
733
-			if (!$this->check_acl(EGW_ACL_EDIT,$row))
732
+			if (!$this->check_acl(EGW_ACL_EDIT, $row))
734 733
 			{
735 734
 				$row['class'] .= ' rowNoEdit ';
736 735
 			}
@@ -738,21 +737,21 @@  discard block
 block discarded – undo
738 737
 			{
739 738
 				$row['class'] .= ' rowNoEdit ';
740 739
 			}
741
-			if (!$this->check_acl(EGW_ACL_DELETE,$row))
740
+			if (!$this->check_acl(EGW_ACL_DELETE, $row))
742 741
 			{
743 742
 				$row['class'] .= ' rowNoDelete ';
744 743
 			}
745
-			if($row['ts_status'] != self::DELETED_STATUS)
744
+			if ($row['ts_status'] != self::DELETED_STATUS)
746 745
 			{
747 746
 				$row['class'] .= ' rowNoUndelete ';
748 747
 			}
749 748
 			if ($query['col_filter']['ts_project'])
750 749
 			{
751
-				unset($row['ts_project']);	// dont need or want to show it
750
+				unset($row['ts_project']); // dont need or want to show it
752 751
 			}
753 752
 			elseif ($links[$row['ts_id']])
754 753
 			{
755
-				foreach($links[$row['ts_id']] as $link)
754
+				foreach ($links[$row['ts_id']] as $link)
756 755
 				{
757 756
 					if ($link['app'] == 'projectmanager')
758 757
 					{
@@ -763,26 +762,26 @@  discard block
 block discarded – undo
763 762
 				}
764 763
 			}
765 764
 
766
-			if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
765
+			if (!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
767 766
 
768 767
 		}
769 768
 		if (!$have_cats || $query['cat_id']) $rows['no_cat_id'] = true;
770 769
 		if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint';
771 770
 		$rows['no_owner_col'] = $query['no_owner_col'];
772
-		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner')) $rows['no_owner_col'] = 1;
771
+		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'], 'ts_owner')) $rows['no_owner_col'] = 1;
773 772
 		if ($query['filter'])
774 773
 		{
775 774
 			$rows += $this->summary;
776 775
 		}
777 776
 		$rows['pm_integration'] = $this->pm_integration;
778
-		$rows['ts_viewtype'] =  $rows['no_ts_quantity'] =  $rows['no_ts_unitprice'] =  $rows['no_ts_total'] = $this->ts_viewtype == 'short';
777
+		$rows['ts_viewtype'] = $rows['no_ts_quantity'] = $rows['no_ts_unitprice'] = $rows['no_ts_total'] = $this->ts_viewtype == 'short';
779 778
 		if (!$rows['ts_viewtype'])
780 779
 		{
781 780
 			#_debug_array($query['selectcols']);
782 781
 			#ts_quantity,ts_unitprice,ts_total
783
-			if ($query['selectcols'] && strpos($query['selectcols'],'ts_quantity')===false) $rows['no_ts_quantity'] = 1;
784
-			if ($query['selectcols'] && strpos($query['selectcols'],'ts_unitprice')===false) $rows['no_ts_unitprice'] = 1;
785
-			if ($query['selectcols'] && strpos($query['selectcols'],'ts_total')===false) $rows['no_ts_total'] = 1;
782
+			if ($query['selectcols'] && strpos($query['selectcols'], 'ts_quantity') === false) $rows['no_ts_quantity'] = 1;
783
+			if ($query['selectcols'] && strpos($query['selectcols'], 'ts_unitprice') === false) $rows['no_ts_unitprice'] = 1;
784
+			if ($query['selectcols'] && strpos($query['selectcols'], 'ts_total') === false) $rows['no_ts_total'] = 1;
786 785
 		}
787 786
 		$rows['no_ts_status'] = strpos($query['selectcols'], 'ts_status') === false && !$this->config_data['history'] ||
788 787
 			$query['no_status'];
@@ -796,7 +795,7 @@  discard block
 block discarded – undo
796 795
 	 * @param array $content
797 796
 	 * @param string $msg
798 797
 	 */
799
-	function index($content = null,$msg='')
798
+	function index($content = null, $msg = '')
800 799
 	{
801 800
 		$etpl = new etemplate_new('timesheet.index');
802 801
 
@@ -833,26 +832,26 @@  discard block
 block discarded – undo
833 832
 			else
834 833
 			{
835 834
 				$success = $failed = $action_msg = null;
836
-				if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
837
-					$success,$failed,$action_msg,'index',$msg))
835
+				if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
836
+					$success, $failed, $action_msg, 'index', $msg))
838 837
 				{
839
-					$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
838
+					$msg .= lang('%1 timesheets(s) %2', $success, $action_msg);
840 839
 				}
841
-				elseif(empty($msg))
840
+				elseif (empty($msg))
842 841
 				{
843
-					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
842
+					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
844 843
 				}
845 844
 			}
846 845
 		}
847 846
 
848 847
 		$content = array(
849
-			'nm' => $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP),
848
+			'nm' => $GLOBALS['egw']->session->appsession('index', TIMESHEET_APP),
850 849
 			'msg' => $msg,
851 850
 		);
852 851
 		if (!is_array($content['nm']))
853 852
 		{
854 853
 			$date_filters = array('All');
855
-			foreach(array_keys($this->date_filters) as $name)
854
+			foreach (array_keys($this->date_filters) as $name)
856 855
 			{
857 856
 				$date_filters[$name] = $name;
858 857
 			}
@@ -861,9 +860,9 @@  discard block
 block discarded – undo
861 860
 			$content['nm'] = array(
862 861
 				'get_rows'       =>	TIMESHEET_APP.'.timesheet_ui.get_rows',
863 862
 				'options-filter' => $date_filters,
864
-				'options-filter2' => array('No details','Details'),
865
-				'order'          =>	'ts_start',// IO name of the column to sort after (optional for the sortheaders)
866
-				'sort'           =>	'DESC',// IO direction of the sort: 'ASC' or 'DESC'
863
+				'options-filter2' => array('No details', 'Details'),
864
+				'order'          =>	'ts_start', // IO name of the column to sort after (optional for the sortheaders)
865
+				'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
867 866
 				'header_left'    => 'timesheet.index.dates',
868 867
 				'header_row'     => 'timesheet.index.add',
869 868
 				'filter_onchange' => "app.timesheet.filter_change();",
@@ -872,13 +871,13 @@  discard block
 block discarded – undo
872 871
 				'row_id'         => 'ts_id',
873 872
 				'row_modified'   => 'ts_modified',
874 873
 				//'actions'        => $this->get_actions(),
875
-				'default_cols'   => '!legacy_actions',	// switch legacy actions column and row off by default
874
+				'default_cols'   => '!legacy_actions', // switch legacy actions column and row off by default
876 875
 				'pm_integration' => $this->pm_integration,
877 876
 			);
878 877
 		}
879 878
 		$content['nm']['actions'] = $this->get_actions($content['nm']);
880 879
 
881
-		if($_GET['search'])
880
+		if ($_GET['search'])
882 881
 		{
883 882
 			$content['nm']['search'] = $_GET['search'];
884 883
 		}
@@ -889,25 +888,25 @@  discard block
 block discarded – undo
889 888
 			'ts_owner'   => $read_grants,
890 889
 			'pm_id'      => array(lang('No project')),
891 890
 			'cat_id'     => array(array('value' => '', 'label' => lang('all')), array('value' => 0, 'label'=>lang('None'))),
892
-			'ts_status'  => $this->status_labels+array(lang('No status')),
891
+			'ts_status'  => $this->status_labels + array(lang('No status')),
893 892
 		);
894
-		if($this->config_data['history'])
893
+		if ($this->config_data['history'])
895 894
 		{
896 895
 			$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
897 896
 		}
898
-		$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1;	// 1 because of 'No status'
899
-		$content['nm']['favorites'] = true;		//Enable favorite
897
+		$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1; // 1 because of 'No status'
898
+		$content['nm']['favorites'] = true; //Enable favorite
900 899
 
901 900
 		if ($this->pm_integration != 'full')
902 901
 		{
903
-			$projects =& $this->query_list('ts_project');
902
+			$projects = & $this->query_list('ts_project');
904 903
 			if (!is_array($projects)) $projects = array();
905 904
 			$sel_options['ts_project'] = $projects + array(lang('No project'));
906 905
 		}
907 906
 
908 907
 		// dont show [Export] button if app is not availible to the user or we are on php4
909
-		$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int) phpversion() < 5;
910
-		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index',$content,$sel_options,$readonlys);
908
+		$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int)phpversion() < 5;
909
+		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index', $content, $sel_options, $readonlys);
911 910
 	}
912 911
 
913 912
 	/**
@@ -926,7 +925,7 @@  discard block
 block discarded – undo
926 925
 				'allowOnMultiple' => false,
927 926
 				'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
928 927
 				'popup' => egw_link::get_registry('timesheet', 'add_popup'),
929
-				'group' => $group=1,
928
+				'group' => $group = 1,
930 929
 				'disableClass' => 'th',
931 930
 			),
932 931
 /*
@@ -954,7 +953,7 @@  discard block
 block discarded – undo
954 953
 				'group' => $group,
955 954
 			),
956 955
 			'cat' => etemplate_widget_nextmatch::category_action(
957
-				'timesheet',++$group,'Change category','cat_'
956
+				'timesheet', ++$group, 'Change category', 'cat_'
958 957
 			),
959 958
 			'status' => array(
960 959
 				'icon' => 'apply',
@@ -1006,7 +1005,7 @@  discard block
 block discarded – undo
1006 1005
 			);
1007 1006
 		}
1008 1007
 		// enable additonal edit check for following actions, if they are generally available
1009
-		foreach(array('cat','status') as $action)
1008
+		foreach (array('cat', 'status') as $action)
1010 1009
 		{
1011 1010
 			if ($actions[$action]['enabled'])
1012 1011
 			{
@@ -1029,27 +1028,27 @@  discard block
 block discarded – undo
1029 1028
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1030 1029
 	 * @return boolean true if all actions succeded, false otherwise
1031 1030
 	 */
1032
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
1031
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg)
1033 1032
 	{
1034 1033
 		$success = $failed = 0;
1035 1034
 		if ($use_all)
1036 1035
 		{
1037 1036
 			// get the whole selection
1038
-			$query = is_array($session_name) ? $session_name : $GLOBALS['egw']->session->appsession($session_name,'timesheet');
1037
+			$query = is_array($session_name) ? $session_name : $GLOBALS['egw']->session->appsession($session_name, 'timesheet');
1039 1038
 
1040 1039
 			if ($use_all)
1041 1040
 			{
1042
-				@set_time_limit(0);			// switch off the execution time limit, as it's for big selections to small
1043
-				$query['num_rows'] = -1;	// all
1041
+				@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
1042
+				$query['num_rows'] = -1; // all
1044 1043
 				$readonlys = null;
1045
-				$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
1044
+				$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
1046 1045
 			}
1047 1046
 		}
1048 1047
 		//error_log(__METHOD__."('$action', ".array2string($checked).', '.array2string($use_all).",,, '$session_name')");
1049 1048
 
1050
-		if (substr($action,0,9) == 'to_status')
1049
+		if (substr($action, 0, 9) == 'to_status')
1051 1050
 		{
1052
-			$to_status = (int)substr($action,10);
1051
+			$to_status = (int)substr($action, 10);
1053 1052
 			$action = 'to_status';
1054 1053
 		}
1055 1054
 		else
@@ -1058,11 +1057,11 @@  discard block
 block discarded – undo
1058 1057
 			list($action, $settings) = explode('_', $action, 2);
1059 1058
 		}
1060 1059
 
1061
-		switch($action)
1060
+		switch ($action)
1062 1061
 		{
1063 1062
 			case 'delete':
1064 1063
 				$action_msg = lang('deleted');
1065
-				foreach((array)$checked as $n => $id)
1064
+				foreach ((array)$checked as $n => $id)
1066 1065
 				{
1067 1066
 					if ($this->delete($id))
1068 1067
 					{
@@ -1075,10 +1074,10 @@  discard block
 block discarded – undo
1075 1074
 				}
1076 1075
 				break;
1077 1076
 			case 'undelete':
1078
-				$action_msg =lang('recovered');
1079
-				foreach((array)$checked as $n => $id)
1077
+				$action_msg = lang('recovered');
1078
+				foreach ((array)$checked as $n => $id)
1080 1079
 				{
1081
-					if ($this->set_status($id,''))
1080
+					if ($this->set_status($id, ''))
1082 1081
 					{
1083 1082
 						$success++;
1084 1083
 					}
@@ -1089,10 +1088,10 @@  discard block
 block discarded – undo
1089 1088
 				}
1090 1089
 				break;
1091 1090
 			case 'to_status':
1092
-				$action_msg =lang('changed status');
1093
-				foreach((array)$checked as $n => $id)
1091
+				$action_msg = lang('changed status');
1092
+				foreach ((array)$checked as $n => $id)
1094 1093
 				{
1095
-					if ($this->set_status($id,$to_status))
1094
+					if ($this->set_status($id, $to_status))
1096 1095
 					{
1097 1096
 						$success++;
1098 1097
 					}
@@ -1105,10 +1104,10 @@  discard block
 block discarded – undo
1105 1104
 			case 'cat':
1106 1105
 				$cat_name = categories::id2name($settings);
1107 1106
 				$action_msg = lang('changed category to %1', $cat_name);
1108
-				foreach((array)$checked as $n => $id) {
1107
+				foreach ((array)$checked as $n => $id) {
1109 1108
 					$entry = $this->read($id);
1110 1109
 					$entry['cat_id'] = $settings;
1111
-					if($this->save($entry) == 0)
1110
+					if ($this->save($entry) == 0)
1112 1111
 					{
1113 1112
 						$success++;
1114 1113
 					}
@@ -1136,7 +1135,7 @@  discard block
 block discarded – undo
1136 1135
 	 * @param conetnt
1137 1136
 	 * @param view
1138 1137
 	 */
1139
-	function editstatus($content = null,$msg='')
1138
+	function editstatus($content = null, $msg = '')
1140 1139
 	{
1141 1140
 		// this function requires admin rights
1142 1141
 		$GLOBALS['egw_info']['flags']['admin_only'] = true;
@@ -1147,13 +1146,13 @@  discard block
 block discarded – undo
1147 1146
 			list($button) = @each($content['button']);
1148 1147
 			unset ($content['button']);
1149 1148
 
1150
-			switch($button)
1149
+			switch ($button)
1151 1150
 			{
1152 1151
 				case 'delete':
1153 1152
 					break;
1154 1153
 				case 'apply':
1155 1154
 				case 'save':
1156
-					foreach($content['statis'] as &$cat)
1155
+					foreach ($content['statis'] as &$cat)
1157 1156
 					{
1158 1157
 						$id = $cat['id'];
1159 1158
 						if (($cat ['name'] !== $this->status_labels_config[$id]) && ($cat ['name'] !== '') || ($cat ['parent'] !== $this->status_labels_config[$id]['parent']) && ($cat ['parent'] !== ''))
@@ -1167,7 +1166,7 @@  discard block
 block discarded – undo
1167 1166
 					}
1168 1167
 					if ($need_update)
1169 1168
 					{
1170
-						config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
1169
+						config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP);
1171 1170
 						$this->config_data = config::read(TIMESHEET_APP);
1172 1171
 						$this->load_statuses();
1173 1172
 						$msg .= lang('Status updated.');
@@ -1184,7 +1183,7 @@  discard block
 block discarded – undo
1184 1183
 			if (isset($this->status_labels_config[$id]))
1185 1184
 			{
1186 1185
 				unset($this->status_labels_config[$id]);
1187
-				config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
1186
+				config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP);
1188 1187
 				unset($this->status_labels[$id]);
1189 1188
 				$msg .= lang('Status deleted.');
1190 1189
 			}
@@ -1193,12 +1192,12 @@  discard block
 block discarded – undo
1193 1192
 		$i = 1;
1194 1193
 		$max_id = 0;
1195 1194
 		unset($content['statis']);
1196
-		foreach($this->status_labels_config as $id => $label)
1195
+		foreach ($this->status_labels_config as $id => $label)
1197 1196
 		{
1198
-			$content['statis'][$i]['name']= $label['name'];
1199
-			$content['statis'][$i]['id']= $id;
1200
-			$content['statis'][$i]['parent']= $label['parent'];
1201
-			$content['statis'][$i]['admin']= $label['admin'];
1197
+			$content['statis'][$i]['name'] = $label['name'];
1198
+			$content['statis'][$i]['id'] = $id;
1199
+			$content['statis'][$i]['parent'] = $label['parent'];
1200
+			$content['statis'][$i]['admin'] = $label['admin'];
1202 1201
 			$i++;
1203 1202
 			$max_id = max($id, $max_id);
1204 1203
 		}
@@ -1210,6 +1209,6 @@  discard block
 block discarded – undo
1210 1209
 		$preserv = $content;
1211 1210
 		$sel_options['parent'] = $this->status_labels;
1212 1211
 		$etpl = new etemplate_new('timesheet.editstatus');
1213
-		$etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,array(),$preserv);
1212
+		$etpl->exec('timesheet.timesheet_ui.editstatus', $content, $sel_options, array(), $preserv);
1214 1213
 	}
1215 1214
 }
Please login to merge, or discard this patch.
Braces   +179 added lines, -45 removed lines patch added patch discarded remove patch
@@ -57,7 +57,10 @@  discard block
 block discarded – undo
57 57
 		$etpl = new etemplate_new('timesheet.edit');
58 58
 		if (!is_array($content))
59 59
 		{
60
-			if ($_GET['msg']) $msg = strip_tags($_GET['msg']);
60
+			if ($_GET['msg'])
61
+			{
62
+				$msg = strip_tags($_GET['msg']);
63
+			}
61 64
 
62 65
 			if ($view || (int)$_GET['ts_id'])
63 66
 			{
@@ -110,23 +113,32 @@  discard block
 block discarded – undo
110 113
 				$content['ts_description'] = $content['ts_description_short'];
111 114
 			}
112 115
 			// we only need 2 out of 3 values from start-, end-time or duration (the date in ts_start is always required!)
113
-			if (isset($content['start_time']))		// start-time specified
116
+			if (isset($content['start_time']))
117
+			{
118
+				// start-time specified
114 119
 			{
115 120
 				//$content['ts_start'] += $content['start_time'];
116 121
 				$start = new egw_time($content['ts_start']);
122
+			}
117 123
 				$start_time = explode(':',$content['start_time']);
118 124
 				$start->setTime($start_time[0],$start_time[1]);
119 125
 				$content['ts_start'] = $start->format('ts');
120 126
 			}
121
-			if (isset($content['end_time']))		// end-time specified
127
+			if (isset($content['end_time']))
128
+			{
129
+				// end-time specified
122 130
 			{
123 131
 				$end = new egw_time($content['ts_start']);
132
+			}
124 133
 				$end_time = explode(':',$content['end_time']);
125 134
 				$end->setTime($end_time[0],$end_time[1]);
126 135
 			}
127
-			if ($end && $start)	// start- & end-time --> calculate the duration
136
+			if ($end && $start)
137
+			{
138
+				// start- & end-time --> calculate the duration
128 139
 			{
129 140
 				$content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60;
141
+			}
130 142
 				// check if negative duration is caused by wrap over midnight
131 143
 				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60)
132 144
 				{
@@ -134,12 +146,18 @@  discard block
 block discarded – undo
134 146
 				}
135 147
 				//echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n";
136 148
 			}
137
-			elseif ($content['ts_duration'] && $end)	// no start, calculate from end and duration
149
+			elseif ($content['ts_duration'] && $end)
150
+			{
151
+				// no start, calculate from end and duration
138 152
 			{
139 153
 				$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
154
+			}
140 155
 				//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".egw_time::to($content['ts_start'])."</p>\n";
141 156
 			}
142
-			if ($content['ts_duration'] > 0) unset($content['end_time']);
157
+			if ($content['ts_duration'] > 0)
158
+			{
159
+				unset($content['end_time']);
160
+			}
143 161
 			// now we only deal with start (date+time) and duration
144 162
 			list($button) = @each($content['button']);
145 163
 			$view = $content['view'];
@@ -153,7 +171,10 @@  discard block
 block discarded – undo
153 171
 			switch($button)
154 172
 			{
155 173
 				case 'edit':
156
-					if ($this->check_acl(EGW_ACL_EDIT) && !$only_admin_edit) $view = false;
174
+					if ($this->check_acl(EGW_ACL_EDIT) && !$only_admin_edit)
175
+					{
176
+						$view = false;
177
+					}
157 178
 					break;
158 179
 
159 180
 				case 'undelete':
@@ -167,12 +188,15 @@  discard block
 block discarded – undo
167 188
 				case 'save':
168 189
 				case 'save_new':
169 190
 				case 'apply':
170
-					if ((!$this->data['ts_quantity'] || $this->ts_viewtype == 'short') && $this->data['ts_duration'])	// set the quantity (in h) from the duration (in min)
191
+					if ((!$this->data['ts_quantity'] || $this->ts_viewtype == 'short') && $this->data['ts_duration'])
192
+					{
193
+						// set the quantity (in h) from the duration (in min)
171 194
 					{
172 195
 						// We need to keep the actual value of ts_quantity when we are storing it, as it is used in price calculation
173 196
 						// and rounding it causes miscalculation on prices
174 197
 						$this->data['ts_quantity'] = $this->data['ts_duration'] / 60.0;
175 198
 					}
199
+					}
176 200
 					if (!$this->data['ts_quantity'])
177 201
 					{
178 202
 						$etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!'));
@@ -204,7 +228,11 @@  discard block
 block discarded – undo
204 228
 							unset($content['ts_project_blur']);
205 229
 						}
206 230
 					}
207
-					if ($etpl->validation_errors()) break;	// the user need to fix the error, before we can save the entry
231
+					if ($etpl->validation_errors())
232
+					{
233
+						break;
234
+					}
235
+					// the user need to fix the error, before we can save the entry
208 236
 
209 237
 					// account for changed project --> remove old one from links and add new one
210 238
 					if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id'])
@@ -248,14 +276,20 @@  discard block
 block discarded – undo
248 276
 						}
249 277
 					}
250 278
 					egw_framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
251
-					if ($button == 'apply') break;
279
+					if ($button == 'apply')
280
+					{
281
+						break;
282
+					}
252 283
 					if ($button == 'save_new')
253 284
 					{
254 285
 						$msg .= ', '.lang('creating new entry');		// giving some feedback to the user
255 286
 
256
-						if (!is_array($content['link_to']['to_id']))	// set links again, so new entry gets the same links as the existing one
287
+						if (!is_array($content['link_to']['to_id']))
288
+						{
289
+							// set links again, so new entry gets the same links as the existing one
257 290
 						{
258 291
 							$content['link_to']['to_id'] = 0;
292
+						}
259 293
 							foreach(egw_link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.egw_link::VFS_APPNAME) as $link)
260 294
 							{
261 295
 								egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
@@ -318,12 +352,15 @@  discard block
 block discarded – undo
318 352
 			foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
319 353
 			{
320 354
 				$link_id = $link_ids[$n];
321
-				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
355
+				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
356
+				{
357
+					// gard against XSS
322 358
 				{
323 359
 					switch ($link_app)
324 360
 					{
325 361
 						case 'projectmanager':
326 362
 							$links[] = $link_id;
363
+				}
327 364
 							// fall-through;
328 365
 						default:
329 366
 							if(!$n)
@@ -335,8 +372,14 @@  discard block
 block discarded – undo
335 372
 								{
336 373
 									foreach((array)$set['link_app'] as $i => $l_app)
337 374
 									{
338
-										if (($l_id=$set['link_id'][$i])) egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
339
-										if ($l_app == 'projectmanager') $links[] = $l_id;
375
+										if (($l_id=$set['link_id'][$i]))
376
+										{
377
+											egw_link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
378
+										}
379
+										if ($l_app == 'projectmanager')
380
+										{
381
+											$links[] = $l_id;
382
+										}
340 383
 									}
341 384
 									unset($set['link_app']);
342 385
 									unset($set['link_id']);
@@ -432,8 +475,16 @@  discard block
 block discarded – undo
432 475
 			$content['ts_viewtype'] = $readonlys['tabs']['notes'] = true;
433 476
 			$content['ts_description_short'] = $content['ts_description'];
434 477
 		}
435
-		if (!$this->customfields) $readonlys['tabs']['customfields'] = true;	// suppress tab if there are not customfields
436
-		if (!$this->data['ts_id']) $readonlys['tabs']['history']    = true;   //suppress history for the first loading without ID
478
+		if (!$this->customfields)
479
+		{
480
+			$readonlys['tabs']['customfields'] = true;
481
+		}
482
+		// suppress tab if there are not customfields
483
+		if (!$this->data['ts_id'])
484
+		{
485
+			$readonlys['tabs']['history']    = true;
486
+		}
487
+		//suppress history for the first loading without ID
437 488
 
438 489
 		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2);
439 490
 	}
@@ -446,7 +497,10 @@  discard block
 block discarded – undo
446 497
 	 */
447 498
 	function datetime2time($datetime)
448 499
 	{
449
-		if (!$datetime) return 0;
500
+		if (!$datetime)
501
+		{
502
+			return 0;
503
+		}
450 504
 
451 505
 		return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime));
452 506
 	}
@@ -486,7 +540,10 @@  discard block
 block discarded – undo
486 540
 				}
487 541
 				// show week-sums, if we are week-aligned (show full weeks)?
488 542
 				$week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'];
489
-				if (!$week_start_day) $week_start_day = 'Sunday';
543
+				if (!$week_start_day)
544
+				{
545
+					$week_start_day = 'Sunday';
546
+				}
490 547
 				switch($week_start_day)
491 548
 				{
492 549
 					case 'Sunday': $week_end_day = 'Saturday'; break;
@@ -508,15 +565,24 @@  discard block
 block discarded – undo
508 565
 			}
509 566
 		}
510 567
 		//echo "<p align=right>show_sums=".print_r($this->show_sums,true)."</p>\n";
511
-		if (!$id_only && !$query_in['csv_export']) $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP,$query_in);
568
+		if (!$id_only && !$query_in['csv_export'])
569
+		{
570
+			$GLOBALS['egw']->session->appsession('index',TIMESHEET_APP,$query_in);
571
+		}
512 572
 
513 573
 		// Refresh actions (undelete needs this)
514 574
 		$query_in['actions'] = $this->get_actions($query_in);
515 575
 
516 576
 		$query = $query_in;	// keep the original query
517 577
 
518
-		if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
519
-		if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false;
578
+		if($this->ts_viewtype == 'short')
579
+		{
580
+			$query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
581
+		}
582
+		if ($query['no_status'])
583
+		{
584
+			$query_in['options-selectcols']['ts_status'] = false;
585
+		}
520 586
 
521 587
 		//_debug_array($query['col_filter']);
522 588
 		//echo "PM Integration:".$this->pm_integration.'<br>';
@@ -529,8 +595,14 @@  discard block
 block discarded – undo
529 595
 		{
530 596
 			//$query['col_filter']['ts_id'] = egw_link::get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet');
531 597
 			$query['col_filter']['ts_id'] = $this->get_ts_links($query['col_filter']['pm_id']);
532
-			if (empty($query['col_filter']['ts_id'])) $query['col_filter']['ts_id'] = -1;
533
-			if (!$query['col_filter']['ts_id']) $query['col_filter']['ts_id'] = 0;
598
+			if (empty($query['col_filter']['ts_id']))
599
+			{
600
+				$query['col_filter']['ts_id'] = -1;
601
+			}
602
+			if (!$query['col_filter']['ts_id'])
603
+			{
604
+				$query['col_filter']['ts_id'] = 0;
605
+			}
534 606
 		}
535 607
 		if ((string)$query['col_filter']['pm_id'] != '' && (string)$query['col_filter']['pm_id'] == '0')
536 608
 		{
@@ -594,10 +666,13 @@  discard block
 block discarded – undo
594 666
 			$cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']);
595 667
 			$query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id'];
596 668
 		}
597
-		elseif ((string)$query['cat_id'] == '0')	// no category
669
+		elseif ((string)$query['cat_id'] == '0')
670
+		{
671
+			// no category
598 672
 		{
599 673
 			$query['col_filter']['cat_id'] = null;
600 674
 		}
675
+		}
601 676
 		else	// all cats --> no filter
602 677
 		{
603 678
 			unset($query['col_filter']['cat_id']);
@@ -608,7 +683,10 @@  discard block
 block discarded – undo
608 683
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.common::grab_owner_name($query['col_filter']['ts_owner']);
609 684
 			#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
610 685
 			#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
611
-			if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
686
+			if ($query['col_filter']['ts_owner']<0)
687
+			{
688
+				$query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
689
+			}
612 690
 		}
613 691
 		else
614 692
 		{
@@ -621,10 +699,13 @@  discard block
 block discarded – undo
621 699
 			// generate a meaningful app-header / report title
622 700
 			if ($this->show_sums['month'])
623 701
 			{
624
-				if ((int)$start[1] == 1 && (int) $end[1] == 12)		// whole year(s)
702
+				if ((int)$start[1] == 1 && (int) $end[1] == 12)
703
+				{
704
+					// whole year(s)
625 705
 				{
626 706
 					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : '');
627 707
 				}
708
+				}
628 709
 				else
629 710
 				{
630 711
 					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0];
@@ -657,7 +738,10 @@  discard block
 block discarded – undo
657 738
 		$ids = array();
658 739
 		foreach($rows as &$row)
659 740
 		{
660
-			if ($row['ts_id'] > 0) $ids[] = $row['ts_id'];
741
+			if ($row['ts_id'] > 0)
742
+			{
743
+				$ids[] = $row['ts_id'];
744
+			}
661 745
 		}
662 746
 		if ($id_only)
663 747
 		{
@@ -687,12 +771,19 @@  discard block
 block discarded – undo
687 771
 		$have_cats = false;
688 772
 		foreach($rows as &$row)
689 773
 		{
690
-			if ($row['cat_id']) $have_cats = true;
774
+			if ($row['cat_id'])
775
+			{
776
+				$have_cats = true;
777
+			}
691 778
 
692 779
 			$row['class'] = 'row';
693
-			if ($row['ts_id'] <= 0)	// sums
780
+			if ($row['ts_id'] <= 0)
781
+			{
782
+				// sums
694 783
 			{
695
-				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;	// fix for DSL change
784
+				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;
785
+			}
786
+			// fix for DSL change
696 787
 
697 788
 				// Remove fake modified date, it breaks nextmatch checks
698 789
 				unset($row['ts_modified']);
@@ -721,7 +812,10 @@  discard block
 block discarded – undo
721 812
 						break;
722 813
 				}
723 814
 				$row['ts_start'] = $row['ts_unitprice'] = '';
724
-				if (!$this->quantity_sum) $row['ts_quantity'] = '';
815
+				if (!$this->quantity_sum)
816
+				{
817
+					$row['ts_quantity'] = '';
818
+				}
725 819
 				$row['class'] = 'th rowNoEdit rowNoDelete rowNoUndelete';
726 820
 				$row['titleClass'] = 'timesheet_titleSum';
727 821
 				continue;
@@ -763,13 +857,25 @@  discard block
 block discarded – undo
763 857
 				}
764 858
 			}
765 859
 
766
-			if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
860
+			if(!$row['titleClass'])
861
+			{
862
+				$row['titleClass'] = 'timesheet_titleDetails';
863
+			}
767 864
 
768 865
 		}
769
-		if (!$have_cats || $query['cat_id']) $rows['no_cat_id'] = true;
770
-		if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint';
866
+		if (!$have_cats || $query['cat_id'])
867
+		{
868
+			$rows['no_cat_id'] = true;
869
+		}
870
+		if ($query['col_filter']['ts_owner'])
871
+		{
872
+			$rows['ownerClass'] = 'noPrint';
873
+		}
771 874
 		$rows['no_owner_col'] = $query['no_owner_col'];
772
-		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner')) $rows['no_owner_col'] = 1;
875
+		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner'))
876
+		{
877
+			$rows['no_owner_col'] = 1;
878
+		}
773 879
 		if ($query['filter'])
774 880
 		{
775 881
 			$rows += $this->summary;
@@ -780,9 +886,18 @@  discard block
 block discarded – undo
780 886
 		{
781 887
 			#_debug_array($query['selectcols']);
782 888
 			#ts_quantity,ts_unitprice,ts_total
783
-			if ($query['selectcols'] && strpos($query['selectcols'],'ts_quantity')===false) $rows['no_ts_quantity'] = 1;
784
-			if ($query['selectcols'] && strpos($query['selectcols'],'ts_unitprice')===false) $rows['no_ts_unitprice'] = 1;
785
-			if ($query['selectcols'] && strpos($query['selectcols'],'ts_total')===false) $rows['no_ts_total'] = 1;
889
+			if ($query['selectcols'] && strpos($query['selectcols'],'ts_quantity')===false)
890
+			{
891
+				$rows['no_ts_quantity'] = 1;
892
+			}
893
+			if ($query['selectcols'] && strpos($query['selectcols'],'ts_unitprice')===false)
894
+			{
895
+				$rows['no_ts_unitprice'] = 1;
896
+			}
897
+			if ($query['selectcols'] && strpos($query['selectcols'],'ts_total')===false)
898
+			{
899
+				$rows['no_ts_total'] = 1;
900
+			}
786 901
 		}
787 902
 		$rows['no_ts_status'] = strpos($query['selectcols'], 'ts_status') === false && !$this->config_data['history'] ||
788 903
 			$query['no_status'];
@@ -800,7 +915,10 @@  discard block
 block discarded – undo
800 915
 	{
801 916
 		$etpl = new etemplate_new('timesheet.index');
802 917
 
803
-		if ($_GET['msg']) $msg = $_GET['msg'];
918
+		if ($_GET['msg'])
919
+		{
920
+			$msg = $_GET['msg'];
921
+		}
804 922
 		if ($content['nm']['rows']['delete'])
805 923
 		{
806 924
 			list($ts_id) = each($content['nm']['rows']['delete']);
@@ -813,9 +931,12 @@  discard block
 block discarded – undo
813 931
 				$msg = lang('Error deleting the entry!!!');
814 932
 			}
815 933
 		}
816
-		if (is_array($content) && isset($content['nm']['rows']['document']))  // handle insert in default document button like an action
934
+		if (is_array($content) && isset($content['nm']['rows']['document']))
935
+		{
936
+			// handle insert in default document button like an action
817 937
 		{
818 938
 			list($id) = @each($content['nm']['rows']['document']);
939
+		}
819 940
 			$content['nm']['action'] = 'document';
820 941
 			$content['nm']['selected'] = array($id);
821 942
 		}
@@ -884,7 +1005,10 @@  discard block
 block discarded – undo
884 1005
 		}
885 1006
 		$read_grants = $this->grant_list(EGW_ACL_READ);
886 1007
 		$content['nm']['no_owner_col'] = count($read_grants) == 1;
887
-		if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']) $content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'];
1008
+		if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'])
1009
+		{
1010
+			$content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'];
1011
+		}
888 1012
 		$sel_options = array(
889 1013
 			'ts_owner'   => $read_grants,
890 1014
 			'pm_id'      => array(lang('No project')),
@@ -901,7 +1025,10 @@  discard block
 block discarded – undo
901 1025
 		if ($this->pm_integration != 'full')
902 1026
 		{
903 1027
 			$projects =& $this->query_list('ts_project');
904
-			if (!is_array($projects)) $projects = array();
1028
+			if (!is_array($projects))
1029
+			{
1030
+				$projects = array();
1031
+			}
905 1032
 			$sel_options['ts_project'] = $projects + array(lang('No project'));
906 1033
 		}
907 1034
 
@@ -1105,7 +1232,8 @@  discard block
 block discarded – undo
1105 1232
 			case 'cat':
1106 1233
 				$cat_name = categories::id2name($settings);
1107 1234
 				$action_msg = lang('changed category to %1', $cat_name);
1108
-				foreach((array)$checked as $n => $id) {
1235
+				foreach((array)$checked as $n => $id)
1236
+				{
1109 1237
 					$entry = $this->read($id);
1110 1238
 					$entry['cat_id'] = $settings;
1111 1239
 					if($this->save($entry) == 0)
@@ -1120,7 +1248,10 @@  discard block
 block discarded – undo
1120 1248
 				break;
1121 1249
 
1122 1250
 			case 'document':
1123
-				if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
1251
+				if (!$settings)
1252
+				{
1253
+					$settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
1254
+				}
1124 1255
 				$document_merge = new timesheet_merge();
1125 1256
 				$msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir']);
1126 1257
 				$failed = count($checked);
@@ -1172,7 +1303,10 @@  discard block
 block discarded – undo
1172 1303
 						$this->load_statuses();
1173 1304
 						$msg .= lang('Status updated.');
1174 1305
 					}
1175
-					if ($button == 'apply') break;
1306
+					if ($button == 'apply')
1307
+					{
1308
+						break;
1309
+					}
1176 1310
 					// fall-through
1177 1311
 				case 'cancel':
1178 1312
 					$GLOBALS['egw']->redirect_link('/admin/index.php', null, 'admin');
Please login to merge, or discard this patch.
webdav.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
  * Create a session or if the user has no account return authenticate header and 401 Unauthorized
32 32
  *
33 33
  * @param array &$account
34
- * @return int session-id
34
+ * @return string session-id
35 35
  */
36 36
 function check_access(&$account)
37 37
 {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 {
35 35
 	if (isset($_GET['auth']))
36 36
 	{
37
-		list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = explode(':',base64_decode($_GET['auth']),2);
37
+		list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode($_GET['auth']), 2);
38 38
 	}
39 39
 	return egw_digest_auth::autocreate_session_callback($account);
40 40
 }
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 		'noheader'  => True,
46 46
 		'currentapp' => preg_match('|/webdav.php/apps/([A-Za-z0-9_-]+)/|', $_SERVER['REQUEST_URI'], $matches) ? $matches[1] : 'filemanager',
47 47
 		'autocreate_session_callback' => 'check_access',
48
-		'no_exception_handler' => 'basic_auth',	// we use a basic auth exception handler (sends exception message as basic auth realm)
49
-		'auth_realm' => 'EGroupware WebDAV server',	// cant use vfs_webdav_server::REALM as autoloading and include path not yet setup!
48
+		'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm)
49
+		'auth_realm' => 'EGroupware WebDAV server', // cant use vfs_webdav_server::REALM as autoloading and include path not yet setup!
50 50
 	)
51 51
 );
52 52
 require_once('phpgwapi/inc/class.egw_digest_auth.inc.php');
Please login to merge, or discard this patch.
filemanager/setup/setup.inc.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	'name'  => 'Ralf Becker',
21 21
 	'email' => '[email protected]'
22 22
 );
23
-$setup_info['filemanager']['license']  = 'GPL';
23
+$setup_info['filemanager']['license'] = 'GPL';
24 24
 
25 25
 /* The hooks this app includes, needed for hooks registration */
26 26
 $setup_info['filemanager']['hooks']['settings'] = 'filemanager_hooks::settings';
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_merge.inc.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
 		}
124 124
 		// Custom fields
125 125
 		if($content && strpos($content, '#') !== 0)
126
-                {
126
+				{
127 127
 			// Expand link-to custom fields
128 128
 			 $this->cf_link_to_expand($file, $content, $info);
129 129
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		}
124 124
 		// Custom fields
125 125
 		if($content && strpos($content, '#') !== 0)
126
-                {
126
+		{
127 127
 			// Expand link-to custom fields
128 128
 			 $this->cf_link_to_expand($file, $content, $info);
129 129
 
@@ -151,12 +151,14 @@  discard block
 block discarded – undo
151 151
 			// Try this first - a normal path /apps/appname/id/file
152 152
 			list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5));
153 153
 			// Symlink?
154
-			if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) {
154
+			if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps']))
155
+			{
155 156
 				// Try resolving just app + ID - /apps/App Name/Record Title/file
156 157
 				$resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4)));
157 158
 				list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5));
158 159
 
159
-				if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) {
160
+				if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps']))
161
+				{
160 162
 					// Get rid of any virtual folders (eg: All$) and symlinks
161 163
 					$resolved = Vfs::resolve_url_symlinks($file['path']);
162 164
 					list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5));
@@ -190,7 +192,10 @@  discard block
 block discarded – undo
190 192
 		if(is_array($link))
191 193
 		{
192 194
 			// Directories have their internal protocol in path here
193
-			if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path'];
195
+			if($link['path'] && strpos($link['path'], '://') !== false)
196
+			{
197
+				$link['path'] = $file['path'];
198
+			}
194 199
 			$link = Api\Session::link('/index.php', $link);
195 200
 		}
196 201
 		else
@@ -211,7 +216,10 @@  discard block
 block discarded – undo
211 216
 		// Add markers
212 217
 		foreach($file as $key => &$value)
213 218
 		{
214
-			if(!$value) $value = '';
219
+			if(!$value)
220
+			{
221
+				$value = '';
222
+			}
215 223
 			$info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value;
216 224
 		}
217 225
 		if($app_placeholders)
@@ -252,9 +260,15 @@  discard block
 block discarded – undo
252 260
 		);
253 261
 		foreach($fields as $name => $label)
254 262
 		{
255
-			if (!($n&1)) echo '<tr>';
263
+			if (!($n&1))
264
+			{
265
+				echo '<tr>';
266
+			}
256 267
 			echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>';
257
-			if ($n&1) echo "</tr>\n";
268
+			if ($n&1)
269
+			{
270
+				echo "</tr>\n";
271
+			}
258 272
 			$n++;
259 273
 		}
260 274
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	{
57 57
 		parent::__construct();
58 58
 
59
-		if($_dir)
59
+		if ($_dir)
60 60
 		{
61 61
 			$this->dir = $_dir;
62 62
 		}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param string &$content=null content to create some replacements only if they are use
73 73
 	 * @return array|boolean
74 74
 	 */
75
-	protected function get_replacements($id,&$content=null)
75
+	protected function get_replacements($id, &$content = null)
76 76
 	{
77 77
 		if (!($replacements = $this->filemanager_replacements($id, '', $content)))
78 78
 		{
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 * @param string $prefix='' prefix like eg. 'erole'
89 89
 	 * @return array|boolean
90 90
 	 */
91
-	public function filemanager_replacements($id,$prefix='', &$content = null)
91
+	public function filemanager_replacements($id, $prefix = '', &$content = null)
92 92
 	{
93 93
 		$info = array();
94
-		$file = egw_vfs::lstat($id,true);
94
+		$file = egw_vfs::lstat($id, true);
95 95
 
96 96
 		$file['mtime'] = egw_time::to($file['mtime']);
97 97
 		$file['ctime'] = egw_time::to($file['ctime']);
98 98
 
99 99
 		$file['name'] = egw_vfs::basename($id);
100 100
 		$file['dir'] = egw_vfs::decodePath(egw_vfs::dirname($id));
101
-		$dirlist = explode('/',$file['dir']);
101
+		$dirlist = explode('/', $file['dir']);
102 102
 		$file['folder'] = array_pop($dirlist);
103
-		$file['folder_file'] = $file['folder'] . '/'.$file['name'];
103
+		$file['folder_file'] = $file['folder'].'/'.$file['name'];
104 104
 		$file['path'] = $id;
105 105
 		$file['rel_path'] = str_replace($this->dir.'/', '', $id);
106 106
 		$file['hsize'] = egw_vfs::hsize($file['size']);
107 107
 		$file['mime'] = egw_vfs::mime_content_type($id);
108
-		$file['gid'] *= -1;  // our widgets use negative gid's
108
+		$file['gid'] *= -1; // our widgets use negative gid's
109 109
 		if (($props = egw_vfs::propfind($id)))
110 110
 		{
111
-			foreach($props as $prop)
111
+			foreach ($props as $prop)
112 112
 			{
113 113
 				$file[$prop['name']] = $prop['val'];
114 114
 			}
@@ -118,22 +118,22 @@  discard block
 block discarded – undo
118 118
 			$file['symlink'] = egw_vfs::readlink($id);
119 119
 		}
120 120
 		// Custom fields
121
-		if($content && strpos($content, '#') !== 0)
121
+		if ($content && strpos($content, '#') !== 0)
122 122
                 {
123 123
 			// Expand link-to custom fields
124 124
 			 $this->cf_link_to_expand($file, $content, $info);
125 125
 
126
-			foreach(config::get_customfields('filemanager') as $name => $field)
126
+			foreach (config::get_customfields('filemanager') as $name => $field)
127 127
 			{
128 128
 				// Set any missing custom fields, or the marker will stay
129
-				if(!$file['#'.$name])
129
+				if (!$file['#'.$name])
130 130
 				{
131 131
 					$file['#'.$name] = '';
132 132
 					continue;
133 133
 				}
134 134
 
135 135
 				// Format date cfs per user preferences
136
-				if($field['type'] == 'date' || $field['type'] == 'date-time')
136
+				if ($field['type'] == 'date' || $field['type'] == 'date-time')
137 137
 				{
138 138
 					$this->date_fields[] = '#'.$name;
139 139
 					$file['#'.$name] = egw_time::to($file['#'.$name], $field['type'] == 'date' ? true : '');
@@ -142,51 +142,51 @@  discard block
 block discarded – undo
142 142
 		}
143 143
 
144 144
 		// If in apps folder, try for app-specific placeholders
145
-		if($dirlist[1] == 'apps' && count($dirlist) > 1)
145
+		if ($dirlist[1] == 'apps' && count($dirlist) > 1)
146 146
 		{
147 147
 			// Try this first - a normal path /apps/appname/id/file
148
-			list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5));
148
+			list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/') + 5));
149 149
 			// Symlink?
150
-			if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) {
150
+			if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) {
151 151
 				// Try resolving just app + ID - /apps/App Name/Record Title/file
152
-				$resolved = egw_vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4)));
153
-				list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5));
152
+				$resolved = egw_vfs::resolve_url_symlinks(implode('/', array_slice(explode('/', $file['dir']), 0, 4)));
153
+				list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5));
154 154
 
155
-				if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) {
155
+				if (!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) {
156 156
 					// Get rid of any virtual folders (eg: All$) and symlinks
157 157
 					$resolved = egw_vfs::resolve_url_symlinks($file['path']);
158
-					list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5));
158
+					list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5));
159 159
 				}
160 160
 			}
161
-			if($app && $app_id)
161
+			if ($app && $app_id)
162 162
 			{
163
-				if($app && $GLOBALS['egw_info']['user']['apps'][$app])
163
+				if ($app && $GLOBALS['egw_info']['user']['apps'][$app])
164 164
 				{
165 165
 					$app_merge = null;
166 166
 					try
167 167
 					{
168
-						$classname = $app .'_merge';
169
-						if(class_exists($classname))
168
+						$classname = $app.'_merge';
169
+						if (class_exists($classname))
170 170
 						{
171 171
 							$app_merge = new $classname();
172
-							if($app_merge && method_exists($app_merge, 'get_replacements'))
172
+							if ($app_merge && method_exists($app_merge, 'get_replacements'))
173 173
 							{
174 174
 								$app_placeholders = $app_merge->get_replacements($app_id, $content);
175 175
 							}
176 176
 						}
177 177
 					}
178 178
 					// Silently discard & continue
179
-					catch(Exception $e) {
180
-						unset($e);	// not used
179
+					catch (Exception $e) {
180
+						unset($e); // not used
181 181
 					}
182 182
 				}
183 183
 			}
184 184
 		}
185 185
 		$link = egw_link::mime_open($file['url'], $file['mime']);
186
-		if(is_array($link))
186
+		if (is_array($link))
187 187
 		{
188 188
 			// Directories have their internal protocol in path here
189
-			if($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path'];
189
+			if ($link['path'] && strpos($link['path'], '://') !== false) $link['path'] = $file['path'];
190 190
 			$link = egw_session::link('/index.php', $link);
191 191
 		}
192 192
 		else
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 		$file['url'] = $link;
206 206
 
207 207
 		// Add markers
208
-		foreach($file as $key => &$value)
208
+		foreach ($file as $key => &$value)
209 209
 		{
210
-			if(!$value) $value = '';
211
-			$info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value;
210
+			if (!$value) $value = '';
211
+			$info['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value;
212 212
 		}
213
-		if($app_placeholders)
213
+		if ($app_placeholders)
214 214
 		{
215 215
 			$info = array_merge($app_placeholders, $info);
216 216
 		}
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			'hsize' => 'Size',
247 247
 			'size' => 'Size (in bytes)',
248 248
 		);
249
-		foreach($fields as $name => $label)
249
+		foreach ($fields as $name => $label)
250 250
 		{
251 251
 			if (!($n&1)) echo '<tr>';
252 252
 			echo '<td>{{'.$name.'}}</td><td>'.lang($label).'</td>';
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 		}
256 256
 
257 257
 		echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>";
258
-		foreach(config::get_customfields('filemanager') as $name => $field)
258
+		foreach (config::get_customfields('filemanager') as $name => $field)
259 259
 		{
260 260
 			echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n";
261 261
 		}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 		echo '<tr><td colspan="4">'.lang('For files linked to an application entry (inside /apps/appname/id/) the placeholders for that application are also available.  See the specific application for a list of available placeholders.').'</td></tr>';
265 265
 
266 266
 		echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
267
-		foreach(array(
267
+		foreach (array(
268 268
 			'date' => lang('Date'),
269 269
 			'user/n_fn' => lang('Name of current user, all other contact fields are valid too'),
270 270
 			'user/account_lid' => lang('Username'),
Please login to merge, or discard this patch.
calendar/sitemgr/class.module_calendar.inc.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@
 block discarded – undo
27 27
 		$this->description = lang('This module displays the current month');
28 28
  	}
29 29
 
30
-	function get_content(&$arguments,$properties)
30
+	function get_content(&$arguments, $properties)
31 31
 	{
32
-		$date = (int) (strtotime(get_var('date',array('POST','GET'))));
32
+		$date = (int)(strtotime(get_var('date', array('POST', 'GET'))));
33 33
 		$redirect = $arguments['redirect'] ? $arguments['redirect'] : '#';
34 34
 
35 35
 		return $GLOBALS['egw']->jscalendar->get_javascript().
36
-			$GLOBALS['egw']->jscalendar->flat($redirect,$date);
36
+			$GLOBALS['egw']->jscalendar->flat($redirect, $date);
37 37
 	}
38 38
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
 /**
13 13
  * Calendar day selection for sitemgr
14 14
  */
15
-class module_calendar extends Module 
15
+class module_calendar extends Module
16 16
 {
17
-	function module_calendar()  
17
+	function module_calendar()
18 18
 	{
19 19
 		$this->arguments = array(
20 20
 			'redirect' => array(
Please login to merge, or discard this patch.