Completed
Push — 16.1 ( b39e15...d98aac )
by Klaus
18:52
created
setup/inc/class.setup_cmd_ldap.inc.php 3 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -936,9 +936,6 @@
 block discarded – undo
936 936
 	 *
937 937
 	 * Uses $this->ldap_host, $this->ldap_admin and $this->ldap_admin_pw to connect.
938 938
 	 *
939
-	 * @param string $this->object_class ='qmailUser'
940
-	 * @param string $this->mbox_attr ='mailmessagestore' lowercase!!!
941
-	 * @param string $this->mail_login_type ='email' 'email', 'vmailmgr', 'standard' or 'uidNumber'
942 939
 	 * @return string with success message N entries modified
943 940
 	 * @throws Api\Exception if dn not found, not listable or delete fails
944 941
 	 */
Please login to merge, or discard this patch.
Braces   +124 added lines, -30 removed lines patch added patch discarded remove patch
@@ -203,7 +203,10 @@  discard block
 block discarded – undo
203 203
 		$change_account_id = '';
204 204
 		foreach($entries as $key => $entry)
205 205
 		{
206
-			if ($key === 'count') continue;
206
+			if ($key === 'count')
207
+			{
208
+				continue;
209
+			}
207 210
 
208 211
 			$entry = Api\Ldap::result2array($entry);
209 212
 			$accounts[$entry['dn']] = $entry;
@@ -230,7 +233,10 @@  discard block
 block discarded – undo
230 233
 		//print_r($change); die('Stop');
231 234
 
232 235
 		// change account-ids inside EGroupware
233
-		if ($check_only) $msg[] = "You need to run now:\n$cmd_change_account_id $change_account_id";
236
+		if ($check_only)
237
+		{
238
+			$msg[] = "You need to run now:\n$cmd_change_account_id $change_account_id";
239
+		}
234 240
 		//$cmd = new admin_cmd_change_account_id($change);
235 241
 		//$msg[] = $cmd->run($time=null, $set_modifier=false, $skip_checks=false, $check_only);
236 242
 
@@ -252,7 +258,10 @@  discard block
 block discarded – undo
252 258
 				throw new Api\Exception("Failed to modify ldap: !ldap_modify({$this->test_ldap->ds}, '$dn', ".array2string($modify).") ".ldap_error($this->test_ldap->ds).
253 259
 					"\n- ".implode("\n- ", $msg));	// EGroupware change already run successful
254 260
 			}
255
-			if ($modify) ++$changed;
261
+			if ($modify)
262
+			{
263
+				++$changed;
264
+			}
256 265
 		}
257 266
 		$msg[] = "You need to run now on your samba share(s):\nsetup/doc/chown.php -R $change_account_id <share>";
258 267
 
@@ -279,7 +288,10 @@  discard block
 block discarded – undo
279 288
 			else
280 289
 			{
281 290
 				list($to, $from) = explode('=', $attr);
282
-				if ($from) $attrs[] = $from;
291
+				if ($from)
292
+				{
293
+					$attrs[] = $from;
294
+				}
283 295
 				$rename[strtolower($from)] = $to;
284 296
 			}
285 297
 		}
@@ -294,7 +306,10 @@  discard block
 block discarded – undo
294 306
 		{
295 307
 			$this->ads_context = 'CN=Users,DC='.implode(',DC=', explode('.', $this->ads_domain));
296 308
 		}
297
-		if (empty($this->ads_admin_user)) $this->ads_admin_user = 'Administrator';
309
+		if (empty($this->ads_admin_user))
310
+		{
311
+			$this->ads_admin_user = 'Administrator';
312
+		}
298 313
 		$admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user :
299 314
 			'CN='.$this->ads_admin_user.','.$this->ads_context;
300 315
 		switch($this->ads_connection)
@@ -338,7 +353,10 @@  discard block
 block discarded – undo
338 353
 		$utc_diff = null;
339 354
 		foreach($entries as $key => $entry)
340 355
 		{
341
-			if ($key === 'count') continue;
356
+			if ($key === 'count')
357
+			{
358
+				continue;
359
+			}
342 360
 
343 361
 			$entry_arr = Api\Ldap::result2array($entry);
344 362
 			$uid = $entry_arr['uid'];
@@ -352,7 +370,10 @@  discard block
 block discarded – undo
352 370
 				continue;
353 371
 			}
354 372
 			$dn = $dest[0]['dn'];
355
-			if (isset($rename[''])) $entry[''] = '';
373
+			if (isset($rename['']))
374
+			{
375
+				$entry[''] = '';
376
+			}
356 377
 			// special handling for copying shadowExpires to accountExpires
357 378
 			if (strtolower($rename['shadowexpire']) === 'accountexpires')
358 379
 			{
@@ -363,7 +384,10 @@  discard block
 block discarded – undo
363 384
 				}
364 385
 				else
365 386
 				{
366
-					if (is_null($utc_diff)) $utc_diff = date('Z');
387
+					if (is_null($utc_diff))
388
+					{
389
+						$utc_diff = date('Z');
390
+					}
367 391
 					$entry['shadowexpire'] = accounts_ads::convertUnixTimeToWindowsTime(
368 392
 						$entry['shadowexpire']*24*3600+$utc_diff);	// ldap time to unixTime
369 393
 				}
@@ -375,20 +399,29 @@  discard block
 block discarded – undo
375 399
 				{
376 400
 					$to = isset($rename[$attr]) ? $rename[$attr] : $attr;
377 401
 					$prefix = null;
378
-					if ($to[0] == '{')	// eg. {smtp:}proxyAddresses=forwardTo
402
+					if ($to[0] == '{')
403
+					{
404
+						// eg. {smtp:}proxyAddresses=forwardTo
379 405
 					{
380 406
 						list($prefix, $to) = explode('}', substr($to, 1));
381 407
 					}
408
+					}
382 409
 					foreach((array)$value as $val)
383 410
 					{
384 411
 						if (isset($update[$to]))
385 412
 						{
386
-							if (!is_array($update[$to])) $update[$to] = array($update[$to]);
413
+							if (!is_array($update[$to]))
414
+							{
415
+								$update[$to] = array($update[$to]);
416
+							}
387 417
 							// we need to check (caseinsensitive) if value already exists in set
388 418
 							// as AD chokes on doublicate values "Type or value exists"
389 419
 							foreach($update[$to] as $v)
390 420
 							{
391
-								if (!strcasecmp($v, $prefix.$val)) continue 2;
421
+								if (!strcasecmp($v, $prefix.$val))
422
+								{
423
+									continue 2;
424
+								}
392 425
 							}
393 426
 							$update[$to][] = $prefix.$val;
394 427
 						}
@@ -415,7 +448,10 @@  discard block
 block discarded – undo
415 448
 				$changed++;
416 449
 			}
417 450
 		}
418
-		if ($check_only) return lang("%1 accounts to copy found.", count($entries));
451
+		if ($check_only)
452
+		{
453
+			return lang("%1 accounts to copy found.", count($entries));
454
+		}
419 455
 
420 456
 		return "Copied data of $changed accounts from LDAP to AD ".
421 457
 			(count($msg) > $changed ? ' ('.(count($msg)-$changed).' errors!)' : '');
@@ -431,7 +467,10 @@  discard block
 block discarded – undo
431 467
 	private function migrate($mode)
432 468
 	{
433 469
 		// support old boolean mode
434
-		if (is_bool($mode)) $mode = $mode ? 'migrate_to_ldap' : 'migrate_to_sql';
470
+		if (is_bool($mode))
471
+		{
472
+			$mode = $mode ? 'migrate_to_ldap' : 'migrate_to_sql';
473
+		}
435 474
 
436 475
 		$passwords2sql = $mode === "passwords_to_sql";
437 476
 		list(,$to) = explode('_to_', $mode);
@@ -597,7 +636,10 @@  discard block
 block discarded – undo
597 636
 					{
598 637
 						foreach(array('ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter','ldap_encryptin_type','mail_suffix','mail_login_type') as $name)
599 638
 						{
600
-							 if (!empty($this->$name)) $GLOBALS['egw_info']['server'][$name] = $this->$name;
639
+							 if (!empty($this->$name))
640
+							 {
641
+							 	$GLOBALS['egw_info']['server'][$name] = $this->$name;
642
+							 }
601 643
 						}
602 644
 						//error_log(__METHOD__."() setup up egw_info[server]: ldap_host='{$GLOBALS['egw_info']['server']['ldap_host']}', ldap_root_dn='{$GLOBALS['egw_info']['server']['ldap_root_dn']}', ldap_root_pw='{$GLOBALS['egw_info']['server']['ldap_root_pw']}', ldap_context='{$GLOBALS['egw_info']['server']['ldap_context']}', mail_suffix='{$GLOBALS['egw_info']['server']['mail_suffix']}', mail_logig_type='{$GLOBALS['egw_info']['server']['mail_login-type']}'");
603 645
 					}
@@ -684,7 +726,10 @@  discard block
 block discarded – undo
684 726
 	 */
685 727
 	public static function hash_sql2ldap($hash)
686 728
 	{
687
-		if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) $type = 'md5';
729
+		if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type']))
730
+		{
731
+			$type = 'md5';
732
+		}
688 733
 
689 734
 		$matches = null;
690 735
 		if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches))
@@ -718,10 +763,13 @@  discard block
 block discarded – undo
718 763
 	 */
719 764
 	public static function hash_ldap2sql($hash)
720 765
 	{
721
-		if ($hash[0] != '{')	// plain has to be explicitly specified for sql, in ldap it's the default
766
+		if ($hash[0] != '{')
767
+		{
768
+			// plain has to be explicitly specified for sql, in ldap it's the default
722 769
 		{
723 770
 			$hash = '{PLAIN}'.$hash;
724 771
 		}
772
+		}
725 773
 		return $hash;
726 774
 	}
727 775
 
@@ -741,9 +789,12 @@  discard block
 block discarded – undo
741 789
 
742 790
 		foreach($accounts as $account_id => &$account)
743 791
 		{
744
-			if ($account_id != $account['account_id'])	// not all backends have as key the account_id
792
+			if ($account_id != $account['account_id'])
793
+			{
794
+				// not all backends have as key the account_id
745 795
 			{
746 796
 				unset($account);
797
+			}
747 798
 				$account_id = $account['account_id'];
748 799
 			}
749 800
 			$account += $accounts_obj->read($account_id);
@@ -776,7 +827,11 @@  discard block
 block discarded – undo
776 827
 			parent::_setup_enviroment($this->domain);
777 828
 			$enviroment_setup = true;
778 829
 		}
779
-		if ($type != 'sql') $this->connect();	// throws exception, if it can NOT connect
830
+		if ($type != 'sql')
831
+		{
832
+			$this->connect();
833
+		}
834
+		// throws exception, if it can NOT connect
780 835
 
781 836
 		// otherwise search does NOT work, as accounts_sql uses addressbook_bo for it
782 837
 		$GLOBALS['egw_info']['server']['account_repository'] = $type;
@@ -803,14 +858,26 @@  discard block
 block discarded – undo
803 858
 	 */
804 859
 	private function connect($dn=null,$pw=null,$host=null)
805 860
 	{
806
-		if (is_null($dn)) $dn = $this->ldap_root_dn;
807
-		if (is_null($pw)) $pw = $this->ldap_root_pw;
808
-		if (is_null($host)) $host = $this->ldap_host;
861
+		if (is_null($dn))
862
+		{
863
+			$dn = $this->ldap_root_dn;
864
+		}
865
+		if (is_null($pw))
866
+		{
867
+			$pw = $this->ldap_root_pw;
868
+		}
869
+		if (is_null($host))
870
+		{
871
+			$host = $this->ldap_host;
872
+		}
809 873
 
810
-		if (!$pw)	// Api\Ldap::ldapConnect use the current eGW's pw otherwise
874
+		if (!$pw)
875
+		{
876
+			// Api\Ldap::ldapConnect use the current eGW's pw otherwise
811 877
 		{
812 878
 			throw new Api\Exception\WrongUserinput(lang('You need to specify a password!'));
813 879
 		}
880
+		}
814 881
 
815 882
 		try {
816 883
 			$this->test_ldap = Api\Ldap::factory(false, $host, $dn, $pw);
@@ -841,8 +908,14 @@  discard block
 block discarded – undo
841 908
 		$num = 0;
842 909
 		foreach($entries as $n => $entry)
843 910
 		{
844
-			if ($n === 'count') continue;
845
-			if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) continue;
911
+			if ($n === 'count')
912
+			{
913
+				continue;
914
+			}
915
+			if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time())
916
+			{
917
+				continue;
918
+			}
846 919
 			++$num;
847 920
 		}
848 921
 		return $num;
@@ -921,7 +994,10 @@  discard block
 block discarded – undo
921 994
 		$deleted = 0;
922 995
 		foreach($entries as $n => $entry)
923 996
 		{
924
-			if ($n === 'count') continue;
997
+			if ($n === 'count')
998
+			{
999
+				continue;
1000
+			}
925 1001
 			$deleted += $this->rdelete($entry['dn']);
926 1002
 		}
927 1003
 		if (!ldap_delete($this->test_ldap->ds,$dn))
@@ -969,7 +1045,10 @@  discard block
 block discarded – undo
969 1045
 		$modified = 0;
970 1046
 		foreach($entries as $n => $entry)
971 1047
 		{
972
-			if ($n === 'count') continue;
1048
+			if ($n === 'count')
1049
+			{
1050
+				continue;
1051
+			}
973 1052
 
974 1053
 			$mbox = Api\Mail\Smtp\Ldap::mailbox_addr(array(
975 1054
 				'account_id' => $entry['uidnumber'][0],
@@ -977,7 +1056,11 @@  discard block
 block discarded – undo
977 1056
 				'account_email' => $entry['mail'][0],
978 1057
 			),$this->domain,$mail_login_type);
979 1058
 
980
-			if ($mbox === $entry[$mbox_attr][0]) continue;	// nothing to change
1059
+			if ($mbox === $entry[$mbox_attr][0])
1060
+			{
1061
+				continue;
1062
+			}
1063
+			// nothing to change
981 1064
 
982 1065
 			if (!$check_only && !ldap_modify($this->test_ldap->ds,$entry['dn'],array(
983 1066
 				$mbox_attr => $mbox,
@@ -986,7 +1069,10 @@  discard block
 block discarded – undo
986 1069
 				throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!",$entry['dn'],$mbox_attr,$mbox));
987 1070
 			}
988 1071
 			++$modified;
989
-			if ($check_only) echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n";
1072
+			if ($check_only)
1073
+			{
1074
+				echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n";
1075
+			}
990 1076
 		}
991 1077
 		return $check_only ? lang('%1 entries would have been modified.',$modified) :
992 1078
 			lang('%1 entries modified.',$modified);
@@ -1034,8 +1120,16 @@  discard block
 block discarded – undo
1034 1120
 			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn).' '.
1035 1121
 				lang('Supported node types:').implode(', ',array_keys(self::$requiredObjectclasses)));
1036 1122
 		}
1037
-		if ($name == 'dc') $extra['o'] = $value;	// required by organisation
1038
-		if ($name == 'uid') $extra['cn'] = $value;	// required by organizationalRole
1123
+		if ($name == 'dc')
1124
+		{
1125
+			$extra['o'] = $value;
1126
+		}
1127
+		// required by organisation
1128
+		if ($name == 'uid')
1129
+		{
1130
+			$extra['cn'] = $value;
1131
+		}
1132
+		// required by organizationalRole
1039 1133
 
1040 1134
 		if (!@ldap_add($this->test_ldap->ds,$dn,$attr = array(
1041 1135
 			$name => $value,
Please login to merge, or discard this patch.
Spacing   +139 added lines, -142 removed lines patch added patch discarded remove patch
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @param string $ldap_encryption_type ='des'
85 85
 	 * @param boolean $truncate_egw_accounts =false truncate accounts table before migration to SQL
86 86
 	 */
87
-	function __construct($domain,$ldap_host=null,$ldap_suffix=null,$ldap_admin=null,$ldap_admin_pw=null,
88
-		$ldap_base=null,$ldap_root_dn=null,$ldap_root_pw=null,$ldap_context=null,$ldap_search_filter=null,
89
-		$ldap_group_context=null,$sub_command='create_ldap',$ldap_encryption_type='des',$truncate_egw_accounts=false)
87
+	function __construct($domain, $ldap_host = null, $ldap_suffix = null, $ldap_admin = null, $ldap_admin_pw = null,
88
+		$ldap_base = null, $ldap_root_dn = null, $ldap_root_pw = null, $ldap_context = null, $ldap_search_filter = null,
89
+		$ldap_group_context = null, $sub_command = 'create_ldap', $ldap_encryption_type = 'des', $truncate_egw_accounts = false)
90 90
 	{
91 91
 		if (!is_array($domain))
92 92
 		{
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
120 120
 	 * @throws Exception('header.inc.php not found!');
121 121
 	 */
122
-	protected function exec($check_only=false)
122
+	protected function exec($check_only = false)
123 123
 	{
124
-		if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i',$this->domain))
124
+		if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i', $this->domain))
125 125
 		{
126
-			throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!",$this->domain));
126
+			throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!", $this->domain));
127 127
 		}
128 128
 		if ($this->remote_id && $check_only && !in_array($this->sub_command, array('set_mailbox', 'sid2uidnumber', 'copy2ad')))
129 129
 		{
130
-			return true;	// further checks can only done locally
130
+			return true; // further checks can only done locally
131 131
 		}
132 132
 		$this->_merge_defaults();
133 133
 		//_debug_array($this->as_array());
134 134
 
135
-		switch($this->sub_command)
135
+		switch ($this->sub_command)
136 136
 		{
137 137
 			case 'test_ldap_root':
138
-				$msg = $this->connect($this->ldap_admin,$this->ldap_admin_pw);
138
+				$msg = $this->connect($this->ldap_admin, $this->ldap_admin_pw);
139 139
 				break;
140 140
 			case 'test_ldap':
141 141
 				$msg = $this->connect();
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param boolean $check_only =false true: only connect and output necessary commands
182 182
 	 */
183
-	private function sid2uidnumber($check_only=false)
183
+	private function sid2uidnumber($check_only = false)
184 184
 	{
185 185
 		$msg = array();
186 186
 		$this->connect();
187 187
 
188 188
 		// check if base does exist
189
-		if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*'))
189
+		if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*'))
190 190
 		{
191
-			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base));
191
+			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base));
192 192
 		}
193 193
 
194
-		if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base,
195
-			$search='(&(|(objectClass=posixAccount)(objectClass=posixGroup))('.self::sambaSID.'=*)(!(uid=*$)))',
196
-			array('uidNumber','gidNumber','uid','cn', 'objectClass',self::sambaSID))) ||
194
+		if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base,
195
+			$search = '(&(|(objectClass=posixAccount)(objectClass=posixGroup))('.self::sambaSID.'=*)(!(uid=*$)))',
196
+			array('uidNumber', 'gidNumber', 'uid', 'cn', 'objectClass', self::sambaSID))) ||
197 197
 			!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
198 198
 		{
199
-			throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search));
199
+			throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!', $this->ldap_base, $search));
200 200
 		}
201 201
 		$change = $accounts = array();
202 202
 		$cmd_change_account_id = 'admin/admin-cli.php --change-account-id <admin>@<domain>,<adminpw>';
203 203
 		$change_account_id = '';
204
-		foreach($entries as $key => $entry)
204
+		foreach ($entries as $key => $entry)
205 205
 		{
206 206
 			if ($key === 'count') continue;
207 207
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 		// now change them in LDAP
238 238
 		$changed = 0;
239
-		foreach($accounts as $dn => $account)
239
+		foreach ($accounts as $dn => $account)
240 240
 		{
241 241
 			$modify = array();
242 242
 			if (!empty($account['uidnumber']) && isset($change[$account['uidnumber']]))
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			if (!$check_only && $modify && !ldap_modify($this->test_ldap->ds, $dn, $modify))
251 251
 			{
252 252
 				throw new Api\Exception("Failed to modify ldap: !ldap_modify({$this->test_ldap->ds}, '$dn', ".array2string($modify).") ".ldap_error($this->test_ldap->ds).
253
-					"\n- ".implode("\n- ", $msg));	// EGroupware change already run successful
253
+					"\n- ".implode("\n- ", $msg)); // EGroupware change already run successful
254 254
 			}
255 255
 			if ($modify) ++$changed;
256 256
 		}
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @param boolean $check_only =false true: only connect and output necessary commands
267 267
 	 */
268
-	private function copy2ad($check_only=false)
268
+	private function copy2ad($check_only = false)
269 269
 	{
270 270
 		$msg = array();
271 271
 		$attrs = $rename = array();
272
-		foreach(explode(',', $this->attributes) as $attr)
272
+		foreach (explode(',', $this->attributes) as $attr)
273 273
 		{
274
-			if ($attr[0] == '@' ||	// copy whole objectclass without renaming, eg. @inetOrgPerson
274
+			if ($attr[0] == '@' || // copy whole objectclass without renaming, eg. @inetOrgPerson
275 275
 				strpos($attr, '=') === false)
276 276
 			{
277 277
 				$attrs[] = $attr;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		$ignore_attr = array_flip(array('dn', 'objectclass', 'cn', 'userpassword'));
287 287
 		if (!in_array('uid', $attrs))
288 288
 		{
289
-			$attrs[] = 'uid';	// need to match account
289
+			$attrs[] = 'uid'; // need to match account
290 290
 			$ignore_attr['uid'] = true;
291 291
 		}
292 292
 		// connect to destination ads
@@ -295,9 +295,8 @@  discard block
 block discarded – undo
295 295
 			$this->ads_context = 'CN=Users,DC='.implode(',DC=', explode('.', $this->ads_domain));
296 296
 		}
297 297
 		if (empty($this->ads_admin_user)) $this->ads_admin_user = 'Administrator';
298
-		$admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user :
299
-			'CN='.$this->ads_admin_user.','.$this->ads_context;
300
-		switch($this->ads_connection)
298
+		$admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user : 'CN='.$this->ads_admin_user.','.$this->ads_context;
299
+		switch ($this->ads_connection)
301 300
 		{
302 301
 			case 'ssl':
303 302
 				$url = 'ldaps://'.$this->ads_host.'/';
@@ -315,28 +314,27 @@  discard block
 block discarded – undo
315 314
 		// check if ads base does exist
316 315
 		if (!@ldap_read($ads->ds, $this->ads_context, 'objectClass=*'))
317 316
 		{
318
-			throw new Api\Exception\WrongUserinput(lang('Ads dn "%1" NOT found!',$this->ads_context));
317
+			throw new Api\Exception\WrongUserinput(lang('Ads dn "%1" NOT found!', $this->ads_context));
319 318
 		}
320 319
 
321 320
 		// connect to source ldap
322 321
 		$this->connect();
323 322
 
324 323
 		// check if ldap base does exist
325
-		if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*'))
324
+		if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*'))
326 325
 		{
327
-			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base));
326
+			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base));
328 327
 		}
329 328
 
330
-		if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base,
331
-			$search = $this->no_sid_check ? '(objectClass=posixAccount)' :
332
-				'(&(objectClass=posixAccount)('.self::sambaSID.'=*)(!(uid=*$)))', $attrs)) ||
329
+		if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base,
330
+			$search = $this->no_sid_check ? '(objectClass=posixAccount)' : '(&(objectClass=posixAccount)('.self::sambaSID.'=*)(!(uid=*$)))', $attrs)) ||
333 331
 			!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
334 332
 		{
335
-			throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search));
333
+			throw new Api\Exception(lang('Error searching "dn=%1" for "%2"!', $this->ldap_base, $search));
336 334
 		}
337 335
 		$changed = 0;
338 336
 		$utc_diff = null;
339
-		foreach($entries as $key => $entry)
337
+		foreach ($entries as $key => $entry)
340 338
 		{
341 339
 			if ($key === 'count') continue;
342 340
 
@@ -345,7 +343,7 @@  discard block
 block discarded – undo
345 343
 			$entry = array_diff_key($entry_arr, $ignore_attr);
346 344
 
347 345
 			if (!($sr = ldap_search($ads->ds, $this->ads_context,
348
-				$search='(&(objectClass=user)(sAMAccountName='.Api\Ldap::quote($uid).'))', array('dn'))) ||
346
+				$search = '(&(objectClass=user)(sAMAccountName='.Api\Ldap::quote($uid).'))', array('dn'))) ||
349 347
 				!($dest = ldap_get_entries($ads->ds, $sr)))
350 348
 			{
351 349
 				$msg[] = lang('User "%1" not found!', $uid);
@@ -365,11 +363,11 @@  discard block
 block discarded – undo
365 363
 				{
366 364
 					if (is_null($utc_diff)) $utc_diff = date('Z');
367 365
 					$entry['shadowexpire'] = accounts_ads::convertUnixTimeToWindowsTime(
368
-						$entry['shadowexpire']*24*3600+$utc_diff);	// ldap time to unixTime
366
+						$entry['shadowexpire'] * 24 * 3600 + $utc_diff); // ldap time to unixTime
369 367
 				}
370 368
 			}
371 369
 			$update = array();
372
-			foreach($entry as $attr => $value)
370
+			foreach ($entry as $attr => $value)
373 371
 			{
374 372
 				if ($value || $attr === '')
375 373
 				{
@@ -379,14 +377,14 @@  discard block
 block discarded – undo
379 377
 					{
380 378
 						list($prefix, $to) = explode('}', substr($to, 1));
381 379
 					}
382
-					foreach((array)$value as $val)
380
+					foreach ((array)$value as $val)
383 381
 					{
384 382
 						if (isset($update[$to]))
385 383
 						{
386 384
 							if (!is_array($update[$to])) $update[$to] = array($update[$to]);
387 385
 							// we need to check (caseinsensitive) if value already exists in set
388 386
 							// as AD chokes on doublicate values "Type or value exists"
389
-							foreach($update[$to] as $v)
387
+							foreach ($update[$to] as $v)
390 388
 							{
391 389
 								if (!strcasecmp($v, $prefix.$val)) continue 2;
392 390
 							}
@@ -418,7 +416,7 @@  discard block
 block discarded – undo
418 416
 		if ($check_only) return lang("%1 accounts to copy found.", count($entries));
419 417
 
420 418
 		return "Copied data of $changed accounts from LDAP to AD ".
421
-			(count($msg) > $changed ? ' ('.(count($msg)-$changed).' errors!)' : '');
419
+			(count($msg) > $changed ? ' ('.(count($msg) - $changed).' errors!)' : '');
422 420
 	}
423 421
 
424 422
 	/**
@@ -461,9 +459,9 @@  discard block
 block discarded – undo
461 459
 		$accounts_created = $groups_created = $errors = $egw_info_set = 0;
462 460
 		$emailadmin_src = $ldap_class = null;
463 461
 		$target = strtoupper($to);
464
-		foreach($accounts as $account_id => $account)
462
+		foreach ($accounts as $account_id => $account)
465 463
 		{
466
-			if (isset($this->only) && !in_array($account_id,$this->only))
464
+			if (isset($this->only) && !in_array($account_id, $this->only))
467 465
 			{
468 466
 				continue;
469 467
 			}
@@ -483,12 +481,12 @@  discard block
 block discarded – undo
483 481
 			{
484 482
 				if (!($sql_account = $accounts_obj->read($account_id)))
485 483
 				{
486
-					$msg[] = lang('%1 does NOT exist in %2.',$what,$target);
484
+					$msg[] = lang('%1 does NOT exist in %2.', $what, $target);
487 485
 					$errors++;
488 486
 				}
489
-				elseif(empty($account['account_pwd']))
487
+				elseif (empty($account['account_pwd']))
490 488
 				{
491
-					$msg[] = lang('%1 does NOT have a password (userPassword attribute) or we are not allowed to read it!',$what);
489
+					$msg[] = lang('%1 does NOT have a password (userPassword attribute) or we are not allowed to read it!', $what);
492 490
 					$errors++;
493 491
 				}
494 492
 				else
@@ -497,12 +495,12 @@  discard block
 block discarded – undo
497 495
 
498 496
 					if (!$accounts_obj->save($sql_account))
499 497
 					{
500
-						$msg[] = lang('Update of %1 in %2 failed !!!',$what,$target);
498
+						$msg[] = lang('Update of %1 in %2 failed !!!', $what, $target);
501 499
 						$errors++;
502 500
 					}
503 501
 					else
504 502
 					{
505
-						$msg[] = lang('%1 password set in %2.',$what,$target);
503
+						$msg[] = lang('%1 password set in %2.', $what, $target);
506 504
 						$accounts_created++;
507 505
 					}
508 506
 				}
@@ -513,7 +511,7 @@  discard block
 block discarded – undo
513 511
 			{
514 512
 				if ($accounts_obj->exists($account_id))
515 513
 				{
516
-					$msg[] = lang('%1 already exists in %2.',$what,$target);
514
+					$msg[] = lang('%1 already exists in %2.', $what, $target);
517 515
 					$errors++;
518 516
 					continue;
519 517
 				}
@@ -521,7 +519,7 @@  discard block
 block discarded – undo
521 519
 				{
522 520
 					if ($GLOBALS['egw_info']['server']['ldap_extra_attributes'])
523 521
 					{
524
-						$account['homedirectory'] = $GLOBALS['egw_info']['server']['ldap_account_home'] . '/' . $account['account_lid'];
522
+						$account['homedirectory'] = $GLOBALS['egw_info']['server']['ldap_account_home'].'/'.$account['account_lid'];
525 523
 						$account['loginshell'] = $GLOBALS['egw_info']['server']['ldap_account_shell'];
526 524
 					}
527 525
 					$account['account_passwd'] = self::hash_sql2ldap($account['account_pwd']);
@@ -534,12 +532,12 @@  discard block
 block discarded – undo
534 532
 
535 533
 				if (!$accounts_obj->save($account))
536 534
 				{
537
-					$msg[] = lang('Creation of %1 in %2 failed !!!',$what,$target);
535
+					$msg[] = lang('Creation of %1 in %2 failed !!!', $what, $target);
538 536
 					$errors++;
539 537
 					continue;
540 538
 				}
541
-				$accounts_obj->set_memberships($account['memberships'],$account_id);
542
-				$msg[] = lang('%1 created in %2.',$what,$target);
539
+				$accounts_obj->set_memberships($account['memberships'], $account_id);
540
+				$msg[] = lang('%1 created in %2.', $what, $target);
543 541
 				$accounts_created++;
544 542
 
545 543
 				// check if we need to migrate mail-account
@@ -548,7 +546,7 @@  discard block
 block discarded – undo
548 546
 					$ldap_class = false;
549 547
 					$ldap = new ldap();
550 548
 					$ldap->ldapConnect();
551
-					foreach(array(	// todo: have these enumerated by emailadmin ...
549
+					foreach (array(	// todo: have these enumerated by emailadmin ...
552 550
 						'qmailUser' => 'EGroupware\\Api\\Mail\\Smtp\\Oldqmailuser',
553 551
 						'dbMailUser' => 'EGroupware\\Api\\Mail\\Smtp\\Dbmailuser',
554 552
 						// nothing to migrate for inetOrgPerson ...
@@ -595,7 +593,7 @@  discard block
 block discarded – undo
595 593
 					// setting up egw_info array with new ldap information, so hook can use Api\Ldap::ldapConnect()
596 594
 					if (!$egw_info_set++)
597 595
 					{
598
-						foreach(array('ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter','ldap_encryptin_type','mail_suffix','mail_login_type') as $name)
596
+						foreach (array('ldap_host', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_group_context', 'ldap_search_filter', 'ldap_encryptin_type', 'mail_suffix', 'mail_login_type') as $name)
599 597
 						{
600 598
 							 if (!empty($this->$name)) $GLOBALS['egw_info']['server'][$name] = $this->$name;
601 599
 						}
@@ -609,12 +607,12 @@  discard block
 block discarded – undo
609 607
 						{
610 608
 							Api\Hooks::process($account, array(), true);
611 609
 						}
612
-						elseif(is_callable($this->add_account_hook))
610
+						elseif (is_callable($this->add_account_hook))
613 611
 						{
614
-							call_user_func($this->add_account_hook,$account);
612
+							call_user_func($this->add_account_hook, $account);
615 613
 						}
616 614
 					}
617
-					catch(Exception $e)
615
+					catch (Exception $e)
618 616
 					{
619 617
 						$msg[] = $e->getMessage();
620 618
 						$errors++;
@@ -628,38 +626,38 @@  discard block
 block discarded – undo
628 626
 				{
629 627
 					if (!$accounts_obj->save($account))
630 628
 					{
631
-						$msg[] = lang('Creation of %1 in %2 failed !!!',$what,$target);
629
+						$msg[] = lang('Creation of %1 in %2 failed !!!', $what, $target);
632 630
 						++$errors;
633 631
 						continue;
634 632
 					}
635
-					$msg[] = lang('%1 created in %2.',$what,$target);
633
+					$msg[] = lang('%1 created in %2.', $what, $target);
636 634
 					$groups_created++;
637 635
 				}
638 636
 				else
639 637
 				{
640
-					$msg[] = lang('%1 already exists in %2.',$what,$target);
638
+					$msg[] = lang('%1 already exists in %2.', $what, $target);
641 639
 					$errors++;
642 640
 
643 641
 					if ($accounts_obj->id2name($account_id) != $account['account_lid'])
644 642
 					{
645
-						$msg[] = lang("==> different group '%1' under that gidNumber %2, NOT setting memberships!",$account['account_lid'],$account_id);
643
+						$msg[] = lang("==> different group '%1' under that gidNumber %2, NOT setting memberships!", $account['account_lid'], $account_id);
646 644
 						++$errors;
647
-						continue;	// different group under that gidnumber!
645
+						continue; // different group under that gidnumber!
648 646
 					}
649 647
 				}
650 648
 				// now saving / updating the memberships
651
-				$accounts_obj->set_members($account['members'],$account_id);
649
+				$accounts_obj->set_members($account['members'], $account_id);
652 650
 			}
653 651
 		}
654 652
 		if ($passwords2sql)
655 653
 		{
656
-			return lang('%1 passwords updated, %3 errors',$accounts_created,$groups_created,$errors).
657
-				($errors || $this->verbose ? "\n- ".implode("\n- ",$msg) : '');
654
+			return lang('%1 passwords updated, %3 errors', $accounts_created, $groups_created, $errors).
655
+				($errors || $this->verbose ? "\n- ".implode("\n- ", $msg) : '');
658 656
 		}
659 657
 		// migrate addressbook data
660
-		$GLOBALS['egw_info']['user']['apps']['admin'] = true;	// otherwise migration will not run in setup!
658
+		$GLOBALS['egw_info']['user']['apps']['admin'] = true; // otherwise migration will not run in setup!
661 659
 		$addressbook = new Api\Contacts\Storage();
662
-		foreach($this->as_array() as $name => $value)
660
+		foreach ($this->as_array() as $name => $value)
663 661
 		{
664 662
 			if (substr($name, 5) == 'ldap_')
665 663
 			{
@@ -672,8 +670,8 @@  discard block
 block discarded – undo
672 670
 
673 671
 		$this->restore_db();
674 672
 
675
-		return lang('%1 users and %2 groups created, %3 errors',$accounts_created,$groups_created,$errors).
676
-			($errors || $this->verbose ? "\n- ".implode("\n- ",$msgs) : '');
673
+		return lang('%1 users and %2 groups created, %3 errors', $accounts_created, $groups_created, $errors).
674
+			($errors || $this->verbose ? "\n- ".implode("\n- ", $msgs) : '');
677 675
 	}
678 676
 
679 677
 	/**
@@ -687,22 +685,22 @@  discard block
 block discarded – undo
687 685
 		if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) $type = 'md5';
688 686
 
689 687
 		$matches = null;
690
-		if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches))
688
+		if (preg_match('/^\\{(.*)\\}(.*)$/', $hash, $matches))
691 689
 		{
692
-			list(,$type,$hash) = $matches;
690
+			list(,$type, $hash) = $matches;
693 691
 		}
694
-		elseif (preg_match('/^[0-9a-f]{32}$/',$hash))
692
+		elseif (preg_match('/^[0-9a-f]{32}$/', $hash))
695 693
 		{
696 694
 			$type = 'md5';
697 695
 		}
698
-		switch(strtolower($type))
696
+		switch (strtolower($type))
699 697
 		{
700 698
 			case 'plain':
701 699
 				// ldap stores plaintext passwords without {plain} prefix
702 700
 				break;
703 701
 
704 702
 			case 'md5':
705
-				$hash = base64_encode(pack("H*",$hash));
703
+				$hash = base64_encode(pack("H*", $hash));
706 704
 				// fall through
707 705
 			default:
708 706
 				$hash = '{'.strtoupper($type).'}'.$hash;
@@ -732,14 +730,14 @@  discard block
 block discarded – undo
732 730
 	 * @param string $type ='both'
733 731
 	 * @return array
734 732
 	 */
735
-	public function accounts($from='ldap', $type='both')
733
+	public function accounts($from = 'ldap', $type = 'both')
736 734
 	{
737 735
 		$accounts_obj = $this->accounts_obj($from);
738 736
 		//error_log(__METHOD__."(from_ldap=".array2string($from_ldap).') get_class(accounts_obj->backend)='.get_class($accounts_obj->backend));
739 737
 
740 738
 		$accounts = $accounts_obj->search(array('type' => $type, 'objectclass' => true, 'active' => false));
741 739
 
742
-		foreach($accounts as $account_id => &$account)
740
+		foreach ($accounts as $account_id => &$account)
743 741
 		{
744 742
 			if ($account_id != $account['account_id'])	// not all backends have as key the account_id
745 743
 			{
@@ -750,11 +748,11 @@  discard block
 block discarded – undo
750 748
 
751 749
 			if ($account['account_type'] == 'g')
752 750
 			{
753
-				$account['members'] = $accounts_obj->members($account_id,true);
751
+				$account['members'] = $accounts_obj->members($account_id, true);
754 752
 			}
755 753
 			else
756 754
 			{
757
-				$account['memberships'] = $accounts_obj->memberships($account_id,true);
755
+				$account['memberships'] = $accounts_obj->memberships($account_id, true);
758 756
 			}
759 757
 		}
760 758
 		Api\Accounts::cache_invalidate();
@@ -770,13 +768,13 @@  discard block
 block discarded – undo
770 768
 	 */
771 769
 	private function accounts_obj($type)
772 770
 	{
773
-		static $enviroment_setup=null;
771
+		static $enviroment_setup = null;
774 772
 		if (!$enviroment_setup)
775 773
 		{
776 774
 			parent::_setup_enviroment($this->domain);
777 775
 			$enviroment_setup = true;
778 776
 		}
779
-		if ($type != 'sql') $this->connect();	// throws exception, if it can NOT connect
777
+		if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect
780 778
 
781 779
 		// otherwise search does NOT work, as accounts_sql uses addressbook_bo for it
782 780
 		$GLOBALS['egw_info']['server']['account_repository'] = $type;
@@ -801,7 +799,7 @@  discard block
 block discarded – undo
801 799
 	 * @param string $host =null default $this->ldap_host, hostname, ip or ldap-url
802 800
 	 * @throws Api\Exception\WrongUserinput Can not connect to ldap ...
803 801
 	 */
804
-	private function connect($dn=null,$pw=null,$host=null)
802
+	private function connect($dn = null, $pw = null, $host = null)
805 803
 	{
806 804
 		if (is_null($dn)) $dn = $this->ldap_root_dn;
807 805
 		if (is_null($pw)) $pw = $this->ldap_root_pw;
@@ -818,9 +816,9 @@  discard block
 block discarded – undo
818 816
 		catch (Api\Exception\NoPermission $e) {
819 817
 			_egw_log_exception($e);
820 818
 			throw new Api\Exception\WrongUserinput(lang('Can not connect to LDAP server on host %1 using DN %2!',
821
-				$host,$dn).($this->test_ldap->ds ? ' ('.ldap_error($this->test_ldap->ds).')' : ''));
819
+				$host, $dn).($this->test_ldap->ds ? ' ('.ldap_error($this->test_ldap->ds).')' : ''));
822 820
 		}
823
-		return lang('Successful connected to LDAP server on %1 using DN %2.',$this->ldap_host,$dn);
821
+		return lang('Successful connected to LDAP server on %1 using DN %2.', $this->ldap_host, $dn);
824 822
 	}
825 823
 
826 824
 	/**
@@ -833,16 +831,16 @@  discard block
 block discarded – undo
833 831
 	{
834 832
 		$this->connect();
835 833
 
836
-		$sr = ldap_list($this->test_ldap->ds,$this->ldap_context,'ObjectClass=posixAccount',array('dn','shadowExpire'));
834
+		$sr = ldap_list($this->test_ldap->ds, $this->ldap_context, 'ObjectClass=posixAccount', array('dn', 'shadowExpire'));
837 835
 		if (!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
838 836
 		{
839
-			throw new Api\Exception('Error listing "dn=%1"!',$this->ldap_context);
837
+			throw new Api\Exception('Error listing "dn=%1"!', $this->ldap_context);
840 838
 		}
841 839
 		$num = 0;
842
-		foreach($entries as $n => $entry)
840
+		foreach ($entries as $n => $entry)
843 841
 		{
844 842
 			if ($n === 'count') continue;
845
-			if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) continue;
843
+			if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0] * 24 * 3600 < time()) continue;
846 844
 			++$num;
847 845
 		}
848 846
 		return $num;
@@ -856,23 +854,23 @@  discard block
 block discarded – undo
856 854
 	 */
857 855
 	private function create()
858 856
 	{
859
-		$this->connect($this->ldap_admin,$this->ldap_admin_pw);
857
+		$this->connect($this->ldap_admin, $this->ldap_admin_pw);
860 858
 
861
-		foreach(array(
859
+		foreach (array(
862 860
 			$this->ldap_base => array(),
863 861
 			$this->ldap_context => array(),
864 862
 			$this->ldap_group_context => array(),
865
-			$this->ldap_root_dn => array('userPassword' => Api\Auth::encrypt_ldap($this->ldap_root_pw,'ssha')),
863
+			$this->ldap_root_dn => array('userPassword' => Api\Auth::encrypt_ldap($this->ldap_root_pw, 'ssha')),
866 864
 		) as $dn => $extra)
867 865
 		{
868
-			if (!$this->_create_node($dn,$extra,$this->check_only) && $dn == $this->ldap_root_dn)
866
+			if (!$this->_create_node($dn, $extra, $this->check_only) && $dn == $this->ldap_root_dn)
869 867
 			{
870 868
 				// ldap_root already existed, lets check the pw is correct
871 869
 				$this->connect();
872 870
 			}
873 871
 		}
874 872
 		return lang('Successful connected to LDAP server on %1 and created/checked required structur %2.',
875
-			$this->ldap_host,$this->ldap_base);
873
+			$this->ldap_host, $this->ldap_base);
876 874
 	}
877 875
 
878 876
 	/**
@@ -883,25 +881,25 @@  discard block
 block discarded – undo
883 881
 	 */
884 882
 	private function delete_base()
885 883
 	{
886
-		$this->connect($this->ldap_admin,$this->ldap_admin_pw);
884
+		$this->connect($this->ldap_admin, $this->ldap_admin_pw);
887 885
 
888 886
 		// if base not set, use context minus one hierarchy, eg. ou=accounts,(o=domain,dc=local)
889 887
 		if (empty($this->ldap_base) && $this->ldap_context)
890 888
 		{
891
-			list(,$this->ldap_base) = explode(',',$this->ldap_context,2);
889
+			list(,$this->ldap_base) = explode(',', $this->ldap_context, 2);
892 890
 		}
893 891
 		// some precausion to not delete whole ldap tree!
894
-		if (count(explode(',',$this->ldap_base)) < 2)
892
+		if (count(explode(',', $this->ldap_base)) < 2)
895 893
 		{
896
-			throw new Api\Exception\AssertionFailed(lang('Refusing to delete dn "%1"!',$this->ldap_base));
894
+			throw new Api\Exception\AssertionFailed(lang('Refusing to delete dn "%1"!', $this->ldap_base));
897 895
 		}
898 896
 		// check if base does exist
899
-		if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*'))
897
+		if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*'))
900 898
 		{
901
-			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base));
899
+			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base));
902 900
 		}
903 901
 		return lang('LDAP dn="%1" with %2 entries deleted.',
904
-			$this->ldap_base,$this->rdelete($this->ldap_base));
902
+			$this->ldap_base, $this->rdelete($this->ldap_base));
905 903
 	}
906 904
 
907 905
 	/**
@@ -913,20 +911,20 @@  discard block
 block discarded – undo
913 911
 	 */
914 912
 	private function rdelete($dn)
915 913
 	{
916
-		if (!($sr = ldap_list($this->test_ldap->ds,$dn,'ObjectClass=*',array(''))) ||
914
+		if (!($sr = ldap_list($this->test_ldap->ds, $dn, 'ObjectClass=*', array(''))) ||
917 915
 			!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
918 916
 		{
919
-			throw new Api\Exception(lang('Error listing "dn=%1"!',$dn));
917
+			throw new Api\Exception(lang('Error listing "dn=%1"!', $dn));
920 918
 		}
921 919
 		$deleted = 0;
922
-		foreach($entries as $n => $entry)
920
+		foreach ($entries as $n => $entry)
923 921
 		{
924 922
 			if ($n === 'count') continue;
925 923
 			$deleted += $this->rdelete($entry['dn']);
926 924
 		}
927
-		if (!ldap_delete($this->test_ldap->ds,$dn))
925
+		if (!ldap_delete($this->test_ldap->ds, $dn))
928 926
 		{
929
-			throw new Api\Exception(lang('Error deleting "dn=%1"!',$dn));
927
+			throw new Api\Exception(lang('Error deleting "dn=%1"!', $dn));
930 928
 		}
931 929
 		return ++$deleted;
932 930
 	}
@@ -942,32 +940,32 @@  discard block
 block discarded – undo
942 940
 	 * @return string with success message N entries modified
943 941
 	 * @throws Api\Exception if dn not found, not listable or delete fails
944 942
 	 */
945
-	private function set_mailbox($check_only=false)
943
+	private function set_mailbox($check_only = false)
946 944
 	{
947
-		$this->connect($this->ldap_admin,$this->ldap_admin_pw);
945
+		$this->connect($this->ldap_admin, $this->ldap_admin_pw);
948 946
 
949 947
 		// if base not set, use context minus one hierarchy, eg. ou=accounts,(o=domain,dc=local)
950 948
 		if (empty($this->ldap_base) && $this->ldap_context)
951 949
 		{
952
-			list(,$this->ldap_base) = explode(',',$this->ldap_context,2);
950
+			list(,$this->ldap_base) = explode(',', $this->ldap_context, 2);
953 951
 		}
954 952
 		// check if base does exist
955
-		if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*'))
953
+		if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*'))
956 954
 		{
957
-			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!',$this->ldap_base));
955
+			throw new Api\Exception\WrongUserinput(lang('Base dn "%1" NOT found!', $this->ldap_base));
958 956
 		}
959 957
 		$object_class = $this->object_class ? $this->object_class : 'qmailUser';
960 958
 		$mbox_attr = $this->mbox_attr ? $this->mbox_attr : 'mailmessagestore';
961 959
 		$mail_login_type = $this->mail_login_type ? $this->mail_login_type : 'email';
962 960
 
963
-		if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base,
964
-				'objectClass='.$object_class,array('mail','uidNumber','uid',$mbox_attr))) ||
961
+		if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base,
962
+				'objectClass='.$object_class, array('mail', 'uidNumber', 'uid', $mbox_attr))) ||
965 963
 			!($entries = ldap_get_entries($this->test_ldap->ds, $sr)))
966 964
 		{
967
-			throw new Api\Exception(lang('Error listing "dn=%1"!',$this->ldap_base));
965
+			throw new Api\Exception(lang('Error listing "dn=%1"!', $this->ldap_base));
968 966
 		}
969 967
 		$modified = 0;
970
-		foreach($entries as $n => $entry)
968
+		foreach ($entries as $n => $entry)
971 969
 		{
972 970
 			if ($n === 'count') continue;
973 971
 
@@ -975,21 +973,20 @@  discard block
 block discarded – undo
975 973
 				'account_id' => $entry['uidnumber'][0],
976 974
 				'account_lid' => $entry['uid'][0],
977 975
 				'account_email' => $entry['mail'][0],
978
-			),$this->domain,$mail_login_type);
976
+			), $this->domain, $mail_login_type);
979 977
 
980
-			if ($mbox === $entry[$mbox_attr][0]) continue;	// nothing to change
978
+			if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change
981 979
 
982
-			if (!$check_only && !ldap_modify($this->test_ldap->ds,$entry['dn'],array(
980
+			if (!$check_only && !ldap_modify($this->test_ldap->ds, $entry['dn'], array(
983 981
 				$mbox_attr => $mbox,
984 982
 			)))
985 983
 			{
986
-				throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!",$entry['dn'],$mbox_attr,$mbox));
984
+				throw new Api\Exception(lang("Error modifying dn=%1: %2='%3'!", $entry['dn'], $mbox_attr, $mbox));
987 985
 			}
988 986
 			++$modified;
989 987
 			if ($check_only) echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n";
990 988
 		}
991
-		return $check_only ? lang('%1 entries would have been modified.',$modified) :
992
-			lang('%1 entries modified.',$modified);
989
+		return $check_only ? lang('%1 entries would have been modified.', $modified) : lang('%1 entries modified.', $modified);
993 990
 	}
994 991
 
995 992
 	/**
@@ -1000,9 +997,9 @@  discard block
 block discarded – undo
1000 997
 	static $requiredObjectclasses = array(
1001 998
 		'o' => 'organization',
1002 999
 		'ou' => 'organizationalUnit',
1003
-		'cn' => array('organizationalRole','simpleSecurityObject'),
1004
-		'uid' => array('uidObject','organizationalRole','simpleSecurityObject'),
1005
-		'dc' => array('organization','dcObject'),
1000
+		'cn' => array('organizationalRole', 'simpleSecurityObject'),
1001
+		'uid' => array('uidObject', 'organizationalRole', 'simpleSecurityObject'),
1002
+		'dc' => array('organization', 'dcObject'),
1006 1003
 	);
1007 1004
 
1008 1005
 	/**
@@ -1013,37 +1010,37 @@  discard block
 block discarded – undo
1013 1010
 	 * @return boolean true if the node was create, false if it was already there
1014 1011
 	 * @throws Api\Exception\WrongUserinput
1015 1012
 	 */
1016
-	private function _create_node($dn,$extra=array())
1013
+	private function _create_node($dn, $extra = array())
1017 1014
 	{
1018 1015
 		// check if the node already exists and return if it does
1019
-		if (@ldap_read($this->test_ldap->ds,$dn,'objectClass=*'))
1016
+		if (@ldap_read($this->test_ldap->ds, $dn, 'objectClass=*'))
1020 1017
 		{
1021 1018
 			return false;
1022 1019
 		}
1023
-		list($node,$base) = explode(',',$dn,2);
1020
+		list($node, $base) = explode(',', $dn, 2);
1024 1021
 
1025
-		if (!@ldap_read($this->test_ldap->ds,$base,'objectClass=*'))
1022
+		if (!@ldap_read($this->test_ldap->ds, $base, 'objectClass=*'))
1026 1023
 		{
1027
-			$this->_create_node($base);		// create the base if it's not already there
1024
+			$this->_create_node($base); // create the base if it's not already there
1028 1025
 		}
1029 1026
 		// now we need to create the node itself
1030
-		list($name,$value) = explode('=',$node);
1027
+		list($name, $value) = explode('=', $node);
1031 1028
 
1032 1029
 		if (!isset(self::$requiredObjectclasses[$name]))
1033 1030
 		{
1034
-			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn).' '.
1035
-				lang('Supported node types:').implode(', ',array_keys(self::$requiredObjectclasses)));
1031
+			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!', $dn).' '.
1032
+				lang('Supported node types:').implode(', ', array_keys(self::$requiredObjectclasses)));
1036 1033
 		}
1037
-		if ($name == 'dc') $extra['o'] = $value;	// required by organisation
1038
-		if ($name == 'uid') $extra['cn'] = $value;	// required by organizationalRole
1034
+		if ($name == 'dc') $extra['o'] = $value; // required by organisation
1035
+		if ($name == 'uid') $extra['cn'] = $value; // required by organizationalRole
1039 1036
 
1040
-		if (!@ldap_add($this->test_ldap->ds,$dn,$attr = array(
1037
+		if (!@ldap_add($this->test_ldap->ds, $dn, $attr = array(
1041 1038
 			$name => $value,
1042 1039
 			'objectClass' => self::$requiredObjectclasses[$name],
1043
-		)+$extra))
1040
+		) + $extra))
1044 1041
 		{
1045
-			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!',$dn).
1046
-				' ('.ldap_error($this->test_ldap->ds).', attributes='.print_r($attr,true).')');
1042
+			throw new Api\Exception\WrongUserinput(lang('Can not create DN %1!', $dn).
1043
+				' ('.ldap_error($this->test_ldap->ds).', attributes='.print_r($attr, true).')');
1047 1044
 		}
1048 1045
 		return true;
1049 1046
 	}
@@ -1074,30 +1071,30 @@  discard block
 block discarded – undo
1074 1071
 	 */
1075 1072
 	private function _merge_defaults()
1076 1073
 	{
1077
-		foreach(self::defaults() as $name => $default)
1074
+		foreach (self::defaults() as $name => $default)
1078 1075
 		{
1079
-			if ($this->sub_command == 'delete_ldap' && in_array($name,array('ldap_base','ldap_context')))
1076
+			if ($this->sub_command == 'delete_ldap' && in_array($name, array('ldap_base', 'ldap_context')))
1080 1077
 			{
1081
-				continue;	// no default on what to delete!
1078
+				continue; // no default on what to delete!
1082 1079
 			}
1083 1080
 			if (!$this->$name)
1084 1081
 			{
1085 1082
 				//echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n";
1086 1083
 				$this->set_defaults[$name] = $this->$name = $default;
1087 1084
 			}
1088
-			if (strpos($this->$name,'$') !== false)
1085
+			if (strpos($this->$name, '$') !== false)
1089 1086
 			{
1090 1087
 				$this->set_defaults[$name] = $this->$name = str_replace(array(
1091 1088
 					'$domain',
1092 1089
 					'$suffix',
1093 1090
 					'$base',
1094 1091
 					'$admin_pw',
1095
-				),array(
1092
+				), array(
1096 1093
 					$this->domain,
1097 1094
 					$this->ldap_suffix,
1098 1095
 					$this->ldap_base,
1099 1096
 					$this->ldap_admin_pw,
1100
-				),$this->$name);
1097
+				), $this->$name);
1101 1098
 			}
1102 1099
 		}
1103 1100
 	}
Please login to merge, or discard this patch.
setup/inc/class.setup_cmd_showheader.inc.php 3 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -28,9 +28,6 @@
 block discarded – undo
28 28
 	/**
29 29
 	 * Constructor
30 30
 	 *
31
-	 * @param boolean $data=true true: send only the remote_hash, domain and webserver_url,
32
-	 *                           false: the complete header vars, plus install_id and webserver_url from the config table,
33
-	 *                           null:  only the header vars
34 31
 	 */
35 32
 	function __construct($data=true,$header_admin_user=null,$header_admin_password=null)
36 33
 	{
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *                           false: the complete header vars, plus install_id and webserver_url from the config table,
33 33
 	 *                           null:  only the header vars
34 34
 	 */
35
-	function __construct($data=true,$header_admin_user=null,$header_admin_password=null)
35
+	function __construct($data = true, $header_admin_user = null, $header_admin_password = null)
36 36
 	{
37 37
 		if (!is_array($data))
38 38
 		{
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
55 55
 	 * @throws Exception('header.inc.php not found!');
56 56
 	 */
57
-	function exec($check_only=false)
57
+	function exec($check_only = false)
58 58
 	{
59
-		if ($this->remote_id && $check_only) return true;	// cant check for the remote site locally!
59
+		if ($this->remote_id && $check_only) return true; // cant check for the remote site locally!
60 60
 
61 61
 		$this->_check_header_access();
62 62
 
63 63
 		if ($check_only) return true;
64 64
 
65 65
 		$egw_info_backup = $GLOBALS['egw_info'];
66
-		$GLOBALS['egw_info'] = array (
66
+		$GLOBALS['egw_info'] = array(
67 67
 			'flags' => array(
68 68
 				'noapi' => true,
69 69
 			),
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		{
73 73
 			throw new Exception('header.inc.php not found!');
74 74
 		}
75
-		eval(str_replace(array('<?php','perfgetmicrotime'),array('','perfgetmicrotime2'),$header));
75
+		eval(str_replace(array('<?php', 'perfgetmicrotime'), array('', 'perfgetmicrotime2'), $header));
76 76
 
77 77
 		// unset the flags, they are not part of  the header
78 78
 		unset($GLOBALS['egw_info']['flags']);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$GLOBALS['egw_info']['server']['versions']['phpgwapi'] = $egw_info_backup['server']['versions']['phpgwapi'];
82 82
 
83 83
 		// fetching the install id's stored in the database
84
-		foreach($GLOBALS['egw_domain'] as &$data)
84
+		foreach ($GLOBALS['egw_domain'] as &$data)
85 85
 		{
86 86
 			if (!is_null($this->hash_only))
87 87
 			{
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 			}
90 90
 			try {
91 91
 				// it's saver to only send the remote_hash and not install_id and config_pw
92
-				$data['remote_hash'] = admin_cmd::remote_hash($data['install_id'],$data['config_passwd']);
92
+				$data['remote_hash'] = admin_cmd::remote_hash($data['install_id'], $data['config_passwd']);
93 93
 			}
94
-			catch(Exception $e) {
94
+			catch (Exception $e) {
95 95
 				if ($data['install_id']) $data['error'] .= $e->getMessage();
96 96
 			}
97 97
 			if ($this->hash_only)
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 					'remote_hash'   => $data['remote_hash'],
101 101
 					'webserver_url' => $data['webserver_url'],
102 102
 					'install_id'     => $data['install_id'],
103
-				)+($data['error'] ? array(
103
+				) + ($data['error'] ? array(
104 104
 					'error' => $data['error'],
105 105
 				) : array());
106 106
 			}
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
 	{
134 134
 		$db = new Api\Db();
135 135
 
136
-		ob_start();		// not available db connection echos a lot grab ;-)
136
+		ob_start(); // not available db connection echos a lot grab ;-)
137 137
 		$err_rep = error_reporting(0);
138 138
 
139 139
 		$config = array();
140 140
 		try {
141
-			$db->connect($data['db_name'],$data['db_host'],$data['db_port'],$data['db_user'],$data['db_pass'],$data['db_type']);
141
+			$db->connect($data['db_name'], $data['db_host'], $data['db_port'], $data['db_user'], $data['db_pass'], $data['db_type']);
142 142
 			$db->set_app('phpgwapi');
143
-			$db->select('egw_config','config_name,config_value',array(
144
-				'config_name'=>array('install_id','webserver_url','account_repository','allow_remote_admin','mail_suffix'),
143
+			$db->select('egw_config', 'config_name,config_value', array(
144
+				'config_name'=>array('install_id', 'webserver_url', 'account_repository', 'allow_remote_admin', 'mail_suffix'),
145 145
 				'config_app'=>'phpgwapi',
146
-			),__LINE__,__FILE__);
146
+			), __LINE__, __FILE__);
147 147
 			while (($row = $db->row(true)))
148 148
 			{
149 149
 				$config[$row['config_name']] = $row['config_value'];
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system)
168 168
 	 * @return boolean true on success, false otherwise
169 169
 	 */
170
-	function save($set_modifier=true)
170
+	function save($set_modifier = true)
171 171
 	{
172 172
 		if ($this->remote_id)
173 173
 		{
Please login to merge, or discard this patch.
Braces   +13 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,11 +56,18 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	function exec($check_only=false)
58 58
 	{
59
-		if ($this->remote_id && $check_only) return true;	// cant check for the remote site locally!
59
+		if ($this->remote_id && $check_only)
60
+		{
61
+			return true;
62
+		}
63
+		// cant check for the remote site locally!
60 64
 
61 65
 		$this->_check_header_access();
62 66
 
63
-		if ($check_only) return true;
67
+		if ($check_only)
68
+		{
69
+			return true;
70
+		}
64 71
 
65 72
 		$egw_info_backup = $GLOBALS['egw_info'];
66 73
 		$GLOBALS['egw_info'] = array (
@@ -92,7 +99,10 @@  discard block
 block discarded – undo
92 99
 				$data['remote_hash'] = admin_cmd::remote_hash($data['install_id'],$data['config_passwd']);
93 100
 			}
94 101
 			catch(Exception $e) {
95
-				if ($data['install_id']) $data['error'] .= $e->getMessage();
102
+				if ($data['install_id'])
103
+				{
104
+					$data['error'] .= $e->getMessage();
105
+				}
96 106
 			}
97 107
 			if ($this->hash_only)
98 108
 			{
Please login to merge, or discard this patch.
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   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
 	{
28 28
 		$setup_info = array();
29 29
 		$d = dir(EGW_SERVER_ROOT);
30
-		while($entry=$d->read())
30
+		while ($entry = $d->read())
31 31
 		{
32
-			if($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT . '/' . $entry))
32
+			if ($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT.'/'.$entry))
33 33
 			{
34
-				$f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php';
35
-				if (@file_exists ($f))
34
+				$f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php';
35
+				if (@file_exists($f))
36 36
 				{
37 37
 					include($f);
38 38
 					$setup_info[$entry]['filename'] = $f;
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
 	 * @param array $setup_info
53 53
 	 * @return array $setup_info
54 54
 	 */
55
-	function get_db_versions($setup_info=null)
55
+	function get_db_versions($setup_info = null)
56 56
 	{
57 57
 		try {	// catch DB errors
58 58
 			$GLOBALS['egw_setup']->set_table_names();
59 59
 
60
-			if($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table),true))
60
+			if ($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table), true))
61 61
 			{
62 62
 				/* one of these tables exists. checking for post/pre beta version */
63
-				if($GLOBALS['egw_setup']->applications_table != 'applications')
63
+				if ($GLOBALS['egw_setup']->applications_table != 'applications')
64 64
 				{
65
-					foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row)
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 68
 						if (!isset($setup_info[$app]))	// app source no longer there
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 					{
83 83
 						// new api, dont care about old pre egroupware stuff
84 84
 					}
85
-					elseif(!@$setup_info['phpgwapi']['currentver'])
85
+					elseif (!@$setup_info['phpgwapi']['currentver'])
86 86
 					{
87 87
 						$setup_info['phpgwapi']['currentver'] = $setup_info['admin']['currentver'];
88 88
 						$setup_info['phpgwapi']['version'] = $setup_info['admin']['currentver'];
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 				}
102 102
 				else
103 103
 				{
104
-					foreach($GLOBALS['egw_setup']->db->query('select * from applications') as $row)
104
+					foreach ($GLOBALS['egw_setup']->db->query('select * from applications') as $row)
105 105
 					{
106
-						if($row['app_name'] == 'admin')
106
+						if ($row['app_name'] == 'admin')
107 107
 						{
108 108
 							$setup_info['phpgwapi']['currentver'] = $row['app_version'];
109 109
 						}
@@ -136,25 +136,25 @@  discard block
 block discarded – undo
136 136
 	 * 	V	Version mismatch at end of upgrade (Not used, proposed only)
137 137
 	 * 	M	Missing files at start of upgrade (Not used, proposed only)
138 138
 	 */
139
-	function compare_versions($setup_info,$try_downgrade=false)
139
+	function compare_versions($setup_info, $try_downgrade = false)
140 140
 	{
141
-		foreach($setup_info as $key => $value)
141
+		foreach ($setup_info as $key => $value)
142 142
 		{
143 143
 			//echo '<br>'.$value['name'].'STATUS: '.$value['status'];
144 144
 			/* Only set this if it has not already failed to upgrade - Milosch */
145
-			if(!( (@$value['status'] == 'F') || (@$value['status'] == 'C') ))
145
+			if (!((@$value['status'] == 'F') || (@$value['status'] == 'C')))
146 146
 			{
147 147
 				//if ($setup_info[$key]['currentver'] > $setup_info[$key]['version'])
148
-				if(!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'],@$value['version']) ||
148
+				if (!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'], @$value['version']) ||
149 149
 					$value['version'] == 'deleted')
150 150
 				{
151 151
 					$setup_info[$key]['status'] = 'V';
152 152
 				}
153
-				elseif(@$value['currentver'] == @$value['version'])
153
+				elseif (@$value['currentver'] == @$value['version'])
154 154
 				{
155 155
 					$setup_info[$key]['status'] = 'C';
156 156
 				}
157
-				elseif($GLOBALS['egw_setup']->alessthanb(@$value['currentver'],@$value['version']))
157
+				elseif ($GLOBALS['egw_setup']->alessthanb(@$value['currentver'], @$value['version']))
158 158
 				{
159 159
 					$setup_info[$key]['status'] = 'U';
160 160
 				}
@@ -171,35 +171,35 @@  discard block
 block discarded – undo
171 171
 	function check_depends($setup_info)
172 172
 	{
173 173
 		/* Run the list of apps */
174
-		foreach($setup_info as $key => $value)
174
+		foreach ($setup_info as $key => $value)
175 175
 		{
176 176
 			/* Does this app have any depends */
177
-			if(isset($value['depends']))
177
+			if (isset($value['depends']))
178 178
 			{
179 179
 				/* If so find out which apps it depends on */
180
-				foreach($value['depends'] as $depkey => $depvalue)
180
+				foreach ($value['depends'] as $depkey => $depvalue)
181 181
 				{
182 182
 					/* I set this to False until we find a compatible version of this app */
183 183
 					$setup_info['depends'][$depkey]['status'] = False;
184 184
 					/* Now we loop thru the versions looking for a compatible version */
185 185
 
186
-					foreach($depvalue['versions'] as $depsvalue)
186
+					foreach ($depvalue['versions'] as $depsvalue)
187 187
 					{
188 188
 						$currentver = $setup_info[$depvalue['appname']]['currentver'];
189
-						if ($depvalue['appname'] == 'phpgwapi' && substr($currentver,0,6) == '0.9.99')
189
+						if ($depvalue['appname'] == 'phpgwapi' && substr($currentver, 0, 6) == '0.9.99')
190 190
 						{
191 191
 							$currentver = '0.9.14.508';
192 192
 						}
193 193
 						$major = $GLOBALS['egw_setup']->get_major($currentver);
194
-						if ($major >= $depsvalue || $major == $depsvalue && substr($major,0,strlen($depsvalue)+1) == $depsvalue.'.')
194
+						if ($major >= $depsvalue || $major == $depsvalue && substr($major, 0, strlen($depsvalue) + 1) == $depsvalue.'.')
195 195
 						{
196 196
 							$setup_info['depends'][$depkey]['status'] = True;
197 197
 						}
198 198
 						else	// check if majors are equal and minors greater or equal
199 199
 						{
200 200
 							$major_depsvalue = $GLOBALS['egw_setup']->get_major($depsvalue);
201
-							$tmp = explode('.',$depsvalue); $minor_depsvalue = array_pop($tmp);
202
-							$tmp2 = explode('.',$currentver); $minor = array_pop($tmp2);
201
+							$tmp = explode('.', $depsvalue); $minor_depsvalue = array_pop($tmp);
202
+							$tmp2 = explode('.', $currentver); $minor = array_pop($tmp2);
203 203
 							if ($major == $major_depsvalue && $minor <= $minor_depsvalue)
204 204
 							{
205 205
 								$setup_info['depends'][$depkey]['status'] = True;
@@ -212,17 +212,17 @@  discard block
 block discarded – undo
212 212
 				 Finally, we loop through the dependencies again to look for apps that still have a failure status
213 213
 				 If we find one, we set the apps overall status as a dependency failure.
214 214
 				*/
215
-				foreach($value['depends'] as $depkey => $depvalue)
215
+				foreach ($value['depends'] as $depkey => $depvalue)
216 216
 				{
217 217
 					if ($setup_info['depends'][$depkey]['status'] == False)
218 218
 					{
219 219
 						/* Only set this if it has not already failed to upgrade - Milosch */
220
-						if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
220
+						if ($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C')
221 221
 						{
222 222
 							/* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install).
223 223
 							 * This should fix apps showing post-install dep failure when they are not yet installed.
224 224
 							 */
225
-							if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
225
+							if ($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U')
226 226
 							{
227 227
 								$setup_info[$key]['status'] = 'D';
228 228
 							}
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	function upgrade_exclude($setup_info)
246 246
 	{
247
-		foreach($setup_info as $key => $value)
247
+		foreach ($setup_info as $key => $value)
248 248
 		{
249
-			if(isset($value['no_mass_update']))
249
+			if (isset($value['no_mass_update']))
250 250
 			{
251 251
 				unset($setup_info[$key]);
252 252
 			}
@@ -261,24 +261,24 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	function check_header()
263 263
 	{
264
-		if(!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200)
264
+		if (!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200)
265 265
 		{
266 266
 			$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One';
267 267
 			return '1';
268 268
 		}
269 269
 		else
270 270
 		{
271
-			if(!@isset($GLOBALS['egw_info']['server']['header_admin_password']))
271
+			if (!@isset($GLOBALS['egw_info']['server']['header_admin_password']))
272 272
 			{
273 273
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (No header admin password set)';
274 274
 				return '2';
275 275
 			}
276
-			elseif(!@isset($GLOBALS['egw_domain']))
276
+			elseif (!@isset($GLOBALS['egw_domain']))
277 277
 			{
278 278
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Add domains to your header.inc.php)';
279 279
 				return '3';
280 280
 			}
281
-			elseif(@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header'])
281
+			elseif (@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header'])
282 282
 			{
283 283
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)';
284 284
 				return '4';
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 * @param array $setup_info =null default use $GLOBALS['setup_info']
296 296
 	 * @return int 1=no database, 3=empty, 4=need upgrade, 10=complete
297 297
 	 */
298
-	function check_db($setup_info=null)
298
+	function check_db($setup_info = null)
299 299
 	{
300 300
 		if (!$setup_info) $setup_info = $GLOBALS['setup_info'];
301 301
 
@@ -303,14 +303,14 @@  discard block
 block discarded – undo
303 303
 			if (!$GLOBALS['egw_setup']->db->Link_ID)
304 304
 			{
305 305
 				$old = error_reporting();
306
-				error_reporting($old & ~E_WARNING);	// no warnings
306
+				error_reporting($old&~E_WARNING); // no warnings
307 307
 				$GLOBALS['egw_setup']->db->connect();
308 308
 				error_reporting($old);
309 309
 
310 310
 				$GLOBALS['egw_setup']->set_table_names();
311 311
 			}
312 312
 		}
313
-		catch(Api\Db\Exception $e) {
313
+		catch (Api\Db\Exception $e) {
314 314
 			// ignore error
315 315
 		}
316 316
 
@@ -319,14 +319,14 @@  discard block
 block discarded – undo
319 319
 			$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)';
320 320
 			return 1;
321 321
 		}
322
-		if(!isset($setup_info['api']['currentver']))
322
+		if (!isset($setup_info['api']['currentver']))
323 323
 		{
324 324
 			$setup_info = $this->get_db_versions($setup_info);
325 325
 		}
326 326
 		// first check new api installed and up to date
327 327
 		if (isset($setup_info['api']['currentver']))
328 328
 		{
329
-			if($setup_info['api']['currentver'] == $setup_info['api']['version'])
329
+			if ($setup_info['api']['currentver'] == $setup_info['api']['version'])
330 330
 			{
331 331
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)';
332 332
 				return 10;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		// then check old phpgwapi
341 341
 		elseif (isset($setup_info['phpgwapi']['currentver']))
342 342
 		{
343
-			if($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version'])
343
+			if ($setup_info['phpgwapi']['currentver'] == $setup_info['phpgwapi']['version'])
344 344
 			{
345 345
 				$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)';
346 346
 				return 10;
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 	 */
376 376
 	function check_config()
377 377
 	{
378
-		if(@$GLOBALS['egw_info']['setup']['stage']['db'] != 10)
378
+		if (@$GLOBALS['egw_info']['setup']['stage']['db'] != 10)
379 379
 		{
380 380
 			return '';
381 381
 		}
382 382
 
383 383
 		try {	// catch db errors
384
-			foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,
385
-				'config_name,config_value',array('config_app' => 'phpgwapi'),__LINE__,__FILE__) as $row)
384
+			foreach ($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,
385
+				'config_name,config_value', array('config_app' => 'phpgwapi'), __LINE__, __FILE__) as $row)
386 386
 			{
387 387
 				$config[$row['config_name']] = $row['config_value'];
388 388
 			}
@@ -392,21 +392,21 @@  discard block
 block discarded – undo
392 392
 			// ignore db errors
393 393
 		}
394 394
 		$GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 2 (Needs Configuration)';
395
-		if(!count($config))
395
+		if (!count($config))
396 396
 		{
397 397
 			return 1;
398 398
 		}
399
-		$config_errors =& $GLOBALS['egw_info']['setup']['config_errors'];
399
+		$config_errors = & $GLOBALS['egw_info']['setup']['config_errors'];
400 400
 		$GLOBALS['egw_info']['setup']['config_errors'] = array();
401 401
 		$error_msg = null;
402
-		if (!$this->check_dir($config['temp_dir'],$error_msg))
402
+		if (!$this->check_dir($config['temp_dir'], $error_msg))
403 403
 		{
404
-			$config_errors[] = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg);
404
+			$config_errors[] = lang("Your temporary directory '%1' %2", $config['temp_dir'], $error_msg);
405 405
 		}
406 406
 
407
-		if (!$this->check_dir($config['files_dir'],$error_msg,true))
407
+		if (!$this->check_dir($config['files_dir'], $error_msg, true))
408 408
 		{
409
-			$config_errors[] = lang("Your files directory '%1' %2",$config['files_dir'],$error_msg);
409
+			$config_errors[] = lang("Your files directory '%1' %2", $config['files_dir'], $error_msg);
410 410
 		}
411 411
 		// set and create the default backup_dir
412 412
 		if (@is_writeable($config['files_dir']) && empty($config['backup_dir']))
@@ -414,35 +414,35 @@  discard block
 block discarded – undo
414 414
 			$config['backup_dir'] = $config['files_dir'].'/db_backup';
415 415
 			if (!is_dir($config['backup_dir']) && mkdir($config['backup_dir']))
416 416
 			{
417
-				$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
417
+				$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
418 418
 					'config_value' => $config['backup_dir'],
419
-				),array(
419
+				), array(
420 420
 					'config_app'  => 'phpgwapi',
421 421
 					'config_name' => 'backup_dir',
422
-				),__LINE__,__FILE__);
422
+				), __LINE__, __FILE__);
423 423
 			}
424 424
 		}
425 425
 		if (isset($config['backup_mincount']))
426 426
 		{
427
-			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
427
+			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
428 428
 				'config_value' => $config['backup_mincount'],
429
-				),array(
429
+				), array(
430 430
 				'config_app'  => 'phpgwapi',
431 431
 				'config_name' => 'backup_mincount',
432
-			),__LINE__,__FILE__);
432
+			), __LINE__, __FILE__);
433 433
 		}
434 434
 		if (isset($config['backup_files']))
435 435
 		{
436
-			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
436
+			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
437 437
 				'config_value' => (int)$config['backup_files'],
438
-				),array(
438
+				), array(
439 439
 				'config_app'  => 'phpgwapi',
440 440
 				'config_name' => 'backup_files',
441
-			),__LINE__,__FILE__);
441
+			), __LINE__, __FILE__);
442 442
 		}
443
-		if (!$this->check_dir($config['backup_dir'],$error_msg,true))
443
+		if (!$this->check_dir($config['backup_dir'], $error_msg, true))
444 444
 		{
445
-			$config_errors[] = lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg);
445
+			$config_errors[] = lang("Your backup directory '%1' %2", $config['backup_dir'], $error_msg);
446 446
 		}
447 447
 		if ($config_errors)
448 448
 		{
@@ -458,19 +458,19 @@  discard block
 block discarded – undo
458 458
 	 * @param $appname
459 459
 	 * @param $any		optional, set to True to see if any of the apps tables are installed
460 460
 	 */
461
-	function check_app_tables($appname,$any=False)
461
+	function check_app_tables($appname, $any = False)
462 462
 	{
463 463
 		$none = 0;
464 464
 		$setup_info = $GLOBALS['setup_info'];
465 465
 
466
-		if(@$setup_info[$appname]['tables'])
466
+		if (@$setup_info[$appname]['tables'])
467 467
 		{
468 468
 			/* Make a copy, else we send some callers into an infinite loop */
469 469
 			$copy = $setup_info;
470 470
 			$tables = Array();
471 471
 			try {
472 472
 				$table_names = $GLOBALS['egw_setup']->db->table_names();
473
-				foreach($table_names as $key => $val)
473
+				foreach ($table_names as $key => $val)
474 474
 				{
475 475
 					$tables[] = $val['table_name'];
476 476
 				}
@@ -479,19 +479,19 @@  discard block
 block discarded – undo
479 479
 				unset($e);
480 480
 				// ignore db error
481 481
 			}
482
-			foreach($copy[$appname]['tables'] as $key => $val)
482
+			foreach ($copy[$appname]['tables'] as $key => $val)
483 483
 			{
484
-				if($GLOBALS['DEBUG'])
484
+				if ($GLOBALS['DEBUG'])
485 485
 				{
486
-					echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val;
486
+					echo '<br>check_app_tables(): Checking: '.$appname.',table: '.$val;
487 487
 				}
488
-				if(!in_array($val,$tables) && !in_array(strtolower($val),$tables))	// names in tables might be lowercase
488
+				if (!in_array($val, $tables) && !in_array(strtolower($val), $tables))	// names in tables might be lowercase
489 489
 				{
490
-					if($GLOBALS['DEBUG'])
490
+					if ($GLOBALS['DEBUG'])
491 491
 					{
492
-						echo '<br>check_app_tables(): ' . $val . ' missing!';
492
+						echo '<br>check_app_tables(): '.$val.' missing!';
493 493
 					}
494
-					if(!$any)
494
+					if (!$any)
495 495
 					{
496 496
 						return False;
497 497
 					}
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 				}
503 503
 				else
504 504
 				{
505
-					if($any)
505
+					if ($any)
506 506
 					{
507
-						if($GLOBALS['DEBUG'])
507
+						if ($GLOBALS['DEBUG'])
508 508
 						{
509 509
 							echo '<br>check_app_tables(): Some tables installed';
510 510
 						}
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 				}
514 514
 			}
515 515
 		}
516
-		if($none && $any)
516
+		if ($none && $any)
517 517
 		{
518
-			if($GLOBALS['DEBUG'])
518
+			if ($GLOBALS['DEBUG'])
519 519
 			{
520 520
 				echo '<br>check_app_tables(): No tables installed';
521 521
 			}
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 		}
524 524
 		else
525 525
 		{
526
-			if($GLOBALS['DEBUG'])
526
+			if ($GLOBALS['DEBUG'])
527 527
 			{
528 528
 				echo '<br>check_app_tables(): All tables installed';
529 529
 			}
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
 	 * @param boolean $check_in_docroot =false run an optional in docroot check
540 540
 	 * @return boolean
541 541
 	 */
542
-	static function check_dir($dir,&$msg,$check_in_docroot=false)
542
+	static function check_dir($dir, &$msg, $check_in_docroot = false)
543 543
 	{
544
-		if (!@is_dir($dir) && !@mkdir($dir,0700,true))
544
+		if (!@is_dir($dir) && !@mkdir($dir, 0700, true))
545 545
 		{
546 546
 			$msg = lang('does not exist');
547 547
 			return false;
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
 		}
554 554
 		if ($check_in_docroot)
555 555
 		{
556
-			$docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT']));
556
+			$docroots = array(realpath(EGW_SERVER_ROOT), realpath($_SERVER['DOCUMENT_ROOT']));
557 557
 			$dir = realpath($dir);
558 558
 
559 559
 			foreach ($docroots as $docroot)
560 560
 			{
561 561
 				$len = strlen($docroot);
562 562
 
563
-				if ($docroot == substr($dir,0,$len) && $len>0)
563
+				if ($docroot == substr($dir, 0, $len) && $len > 0)
564 564
 				{
565
-					$rest = substr($dir,$len);
565
+					$rest = substr($dir, $len);
566 566
 
567 567
 					if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR)
568 568
 					{
Please login to merge, or discard this patch.
setup/inc/class.setup_process.inc.php 3 patches
Doc Comments   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,10 +53,7 @@
 block discarded – undo
53 53
 	 * the mother of all multipass upgrade parental loop functions
54 54
 	 *
55 55
 	 * @param array $setup_info array of application info from setup.inc.php files
56
-	 * @param string $type='new' defaults to new(install), could also be 'upgrade'
57
-	 * @param boolean $DEBUG=false print debugging info
58
-	 * @param boolean $force_en=false install english language files, not used anymore
59
-	 * @param string $system_charset=null charset to use
56
+	 * @param boolean $force_en install english language files, not used anymore
60 57
 	 * @param array $preset_config=array()
61 58
 	 */
62 59
 	function pass(array $setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array())
Please login to merge, or discard this patch.
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 	 * @param string $system_charset=null charset to use
60 60
 	 * @param array $preset_config=array()
61 61
 	 */
62
-	function pass(array $setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array())
62
+	function pass(array $setup_info, $method = 'new', $DEBUG = False, $force_en = False, $preset_config = array())
63 63
 	{
64
-		unset($force_en);	// no longer used
64
+		unset($force_en); // no longer used
65 65
 
66
-		if(!$method)
66
+		if (!$method)
67 67
 		{
68 68
 			return False;
69 69
 		}
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
 				$pass['phpgwapi'] = $setup_info['phpgwapi'];
93 93
 			}
94 94
 		}
95
-		$pass['admin']    = $setup_info['admin'];
95
+		$pass['admin'] = $setup_info['admin'];
96 96
 		$pass['preferences'] = $setup_info['preferences'];
97 97
 		if (file_exists(EGW_SERVER_ROOT.'/etemplate'))
98 98
 		{
99
-			$pass['etemplate'] = $setup_info['etemplate'];	// helps to minimize passes, as many apps depend on it
99
+			$pass['etemplate'] = $setup_info['etemplate']; // helps to minimize passes, as many apps depend on it
100 100
 		}
101 101
 		$this->api_version_target = $setup_info['api']['version'];
102 102
 
103 103
 		$i = 1;
104 104
 		$passed = array();
105 105
 		$passing = array();
106
-		$pass_string = implode (':', $pass);
107
-		$passing_string = implode (':', $passing);
108
-		while($pass_string != $passing_string)
106
+		$pass_string = implode(':', $pass);
107
+		$passing_string = implode(':', $passing);
108
+		while ($pass_string != $passing_string)
109 109
 		{
110 110
 			$passing = array();
111
-			if($DEBUG) { echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; }
111
+			if ($DEBUG) { echo '<br>process->pass(): #'.$i.' for '.$method.' processing'."\n"; }
112 112
 
113 113
 			// Check current versions and dependencies
114 114
 			$setup_info = $GLOBALS['egw_setup']->detection->check_depends(
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
 					$GLOBALS['egw_setup']->detection->get_db_versions($setup_info), true));
117 117
 
118 118
 			// stuff the rest of the apps, but only those with available upgrades
119
-			foreach($setup_info as $key => $value)
119
+			foreach ($setup_info as $key => $value)
120 120
 			{
121 121
 				// check if app is either installed or supports the used database
122 122
 				if (!isset($value['currentver']) && isset($value['only_db']) && (
123
-					is_array($value['only_db']) && !in_array($GLOBALS['egw_setup']->db->Type,$value['only_db']) ||
123
+					is_array($value['only_db']) && !in_array($GLOBALS['egw_setup']->db->Type, $value['only_db']) ||
124 124
 					!is_array($value['only_db']) && $GLOBALS['egw_setup']->db->Type != $value['only_db']))
125 125
 				{
126
-					continue;	// app does not support this db-type, dont try installing it
126
+					continue; // app does not support this db-type, dont try installing it
127 127
 				}
128
-				if(/*$value['name'] != 'phpgwapi' &&*/ $value['status'] == 'U')
128
+				if (/*$value['name'] != 'phpgwapi' &&*/ $value['status'] == 'U')
129 129
 				{
130
-					if($passed[$value['name']]['status'] != 'F' && $passed[$value['name']]['status'] != 'C')
130
+					if ($passed[$value['name']]['status'] != 'F' && $passed[$value['name']]['status'] != 'C')
131 131
 					{
132 132
 						$pass[$value['name']] = $setup_info[$value['name']];
133 133
 					}
134 134
 				}
135 135
 			}
136 136
 
137
-			switch($method)
137
+			switch ($method)
138 138
 			{
139 139
 				case 'new':
140 140
 					if (empty($GLOBALS['egw_info']['server']['temp_dir']))
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 						$GLOBALS['egw_info']['server']['temp_dir'] = sys_get_temp_dir();
143 143
 					}
144 144
 					/* Create tables and insert new records for each app in this list */
145
-					$passing_c = $this->current($pass,$DEBUG);
145
+					$passing_c = $this->current($pass, $DEBUG);
146 146
 					if (isset($pass['api'])) $this->save_minimal_config($preset_config);
147
-					$passing = $this->default_records($passing_c,$DEBUG);
147
+					$passing = $this->default_records($passing_c, $DEBUG);
148 148
 					break;
149 149
 				case 'upgrade':
150 150
 					/* Run upgrade scripts on each app in the list */
151
-					$passing = $this->upgrade($pass,$DEBUG);
151
+					$passing = $this->upgrade($pass, $DEBUG);
152 152
 					//_debug_array($pass);exit;
153 153
 					break;
154 154
 				default:
@@ -157,32 +157,32 @@  discard block
 block discarded – undo
157 157
 			}
158 158
 
159 159
 			$pass = array();
160
-			foreach($passing as $key => $value)
160
+			foreach ($passing as $key => $value)
161 161
 			{
162
-				if($value['status'] == 'C')
162
+				if ($value['status'] == 'C')
163 163
 				{
164 164
 					$passed[$value['name']] = $passing[$value['name']];
165
-					if($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; }
165
+					if ($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'].' install completed'."\n"; }
166 166
 				}
167
-				elseif($value['status'] == 'F')
167
+				elseif ($value['status'] == 'F')
168 168
 				{
169 169
 					$setup_info[$value['name']] = $passing[$value['name']];
170
-					if($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; }
170
+					if ($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'].' install failed'."\n"; }
171 171
 				}
172
-				elseif($value['status'] == 'D')
172
+				elseif ($value['status'] == 'D')
173 173
 				{
174 174
 					$pass[$value['name']] = $setup_info[$value['name']];
175
-					if($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; }
175
+					if ($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'].' fails dependency check on this pass'."\n"; }
176 176
 				}
177 177
 				else
178 178
 				{
179 179
 					$tmp = $passing[$value['name']]['name'];
180
-					if($DEBUG) { echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; }
180
+					if ($DEBUG) { echo '<br>process->pass(): '.$tmp.' skipped on this pass'."\n"; }
181 181
 				}
182 182
 			}
183 183
 
184 184
 			$i++;
185
-			if($i == 20) /* Then oops it broke */
185
+			if ($i == 20) /* Then oops it broke */
186 186
 			{
187 187
 				echo '<br>Setup failure: excess looping in process->pass():'."\n";
188 188
 				echo '<br>Pass:<br>'."\n";
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
 				_debug_array($passed);
192 192
 				exit;
193 193
 			}
194
-			$pass_string = implode (':', $pass);
195
-			$passing_string = implode (':', $passing);
194
+			$pass_string = implode(':', $pass);
195
+			$passing_string = implode(':', $passing);
196 196
 		}
197 197
 		try {
198 198
 			// flush instance cache: also registers hooks and flushes image cache
199 199
 			Api\Cache::flush(Api\Cache::INSTANCE);
200 200
 		}
201
-		catch(Exception $e) {
201
+		catch (Exception $e) {
202 202
 			unset($e);
203 203
 			// ignore exception, as during a new install, there's no cache configured and therefore no need to unset
204 204
 		}
205 205
 		/* now return the list */
206
-		return array_merge($setup_info,$passed);
206
+		return array_merge($setup_info, $passed);
207 207
 	}
208 208
 
209 209
 	/**
@@ -211,20 +211,20 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @param array $preset_config =array()
213 213
 	 */
214
-	function save_minimal_config(array $preset_config=array())
214
+	function save_minimal_config(array $preset_config = array())
215 215
 	{
216
-		$is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN';
216
+		$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
217 217
 
218 218
 		$current_config['site_title'] = 'EGroupware';
219
-		$current_config['hostname']  = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
219
+		$current_config['hostname'] = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
220 220
 
221 221
 		// guessing the eGW url
222 222
 		if (isset($_SERVER['HTTP_HOST']))
223 223
 		{
224
-			$parts = explode('/',$_SERVER['PHP_SELF']);
225
-			array_pop($parts);	// remove config.php
226
-			array_pop($parts);	// remove setup
227
-			$current_config['webserver_url'] = implode('/',$parts);
224
+			$parts = explode('/', $_SERVER['PHP_SELF']);
225
+			array_pop($parts); // remove config.php
226
+			array_pop($parts); // remove setup
227
+			$current_config['webserver_url'] = implode('/', $parts);
228 228
 			$egroupwareDirName = end($parts);
229 229
 		}
230 230
 		else	// eg. cli install --> use defaults
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 			$current_config['webserver_url'] = '/egroupware';
233 233
 			$egroupwareDirName = 'egroupware';
234 234
 		}
235
-		if(!$is_windows)
235
+		if (!$is_windows)
236 236
 		{
237
-			if(@is_dir('/tmp'))
237
+			if (@is_dir('/tmp'))
238 238
 			{
239 239
 				$current_config['temp_dir'] = '/tmp';
240 240
 			}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		}
249 249
 		else
250 250
 		{
251
-			if(@is_dir('c:\\windows\\temp'))
251
+			if (@is_dir('c:\\windows\\temp'))
252 252
 			{
253 253
 				$current_config['temp_dir'] = 'c:\\windows\\temp';
254 254
 			}
@@ -269,15 +269,15 @@  discard block
 block discarded – undo
269 269
 		$current_config['enabled_spellcheck'] = 'YesBrowserBased';
270 270
 
271 271
 		// always enable history logging for calendar, addressbook and infolog
272
-		$current_config['history'] = 'history';	// addressbook: only admin
273
-		$current_config['calendar_delete_history'] = 'history';	// only admins
272
+		$current_config['history'] = 'history'; // addressbook: only admin
273
+		$current_config['calendar_delete_history'] = 'history'; // only admins
274 274
 		// infolog does NOT use config_app='phpgwapi', but 'infolog'
275
-		$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
276
-			'config_value' => 'history_admin_delete',	// only admins
277
-		),array(
275
+		$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
276
+			'config_value' => 'history_admin_delete', // only admins
277
+		), array(
278 278
 			'config_app' => 'infolog',
279 279
 			'config_name' => 'history',
280
-		),__FILE__,__LINE__);
280
+		), __FILE__, __LINE__);
281 281
 
282 282
 
283 283
 		// RalfBecker: php.net recommend this for security reasons, it should be our default too
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 			$tz = new DateTimeZone(date_default_timezone_get());
294 294
 			$current_config['server_timezone'] = $tz->getName();
295 295
 		}
296
-		catch(Exception $e)
296
+		catch (Exception $e)
297 297
 		{
298 298
 			unset($e);
299 299
 			// do nothing if new DateTimeZone fails (eg. 'System/Localtime' returned), specially do NOT store it!
@@ -301,42 +301,42 @@  discard block
 block discarded – undo
301 301
 		}
302 302
 		$current_config['install_id'] = md5($_SERVER['HTTP_HOST'].microtime(true).$GLOBALS['egw_setup']->ConfigDomain);
303 303
 
304
-		$current_config['postpone_statistics_submit'] = time() + 2 * 30 * 86400;	// ask user in 2 month from now, when he has something to report
304
+		$current_config['postpone_statistics_submit'] = time() + 2 * 30 * 86400; // ask user in 2 month from now, when he has something to report
305 305
 
306 306
 		// use securest password hash by default
307
-		require_once EGW_SERVER_ROOT.'/setup/inc/hook_config.inc.php';	// for sql_passwdhashes, to get securest available password hash
307
+		require_once EGW_SERVER_ROOT.'/setup/inc/hook_config.inc.php'; // for sql_passwdhashes, to get securest available password hash
308 308
 		$securest = null;
309 309
 		sql_passwdhashes(array(), true, $securest);
310 310
 		$current_config['sql_encryption_type'] = $current_config['ldap_encryption_type'] = $securest;
311 311
 
312 312
 		if ($preset_config)
313 313
 		{
314
-			$current_config = array_merge($current_config,$preset_config);
314
+			$current_config = array_merge($current_config, $preset_config);
315 315
 		}
316 316
 
317
-		foreach($current_config as $name => $value)
317
+		foreach ($current_config as $name => $value)
318 318
 		{
319 319
 			$app = 'phpgwapi';
320 320
 			if ($name == 'postpone_statistics_submit')
321 321
 			{
322 322
 				$app = 'admin';
323 323
 			}
324
-			elseif(strpos($name, '/') !== false)
324
+			elseif (strpos($name, '/') !== false)
325 325
 			{
326 326
 				list($app, $name) = explode('/', $name);
327 327
 			}
328
-			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
328
+			$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array(
329 329
 				'config_value' => $value,
330
-			),array(
330
+			), array(
331 331
 				'config_app' => $app,
332 332
 				'config_name' => $name,
333
-			),__FILE__,__LINE__);
333
+			), __FILE__, __LINE__);
334 334
 		}
335 335
 
336 336
 		// so the default_records use the current data
337 337
 		$GLOBALS['egw_info']['server'] = array_merge((array)$GLOBALS['egw_info']['server'], $current_config);
338
-		Api\Cache::flush();	// flush whole instance cache
339
-		Api\Config::init_static();	// flush internal cache of Api\Config class
338
+		Api\Cache::flush(); // flush whole instance cache
339
+		Api\Config::init_static(); // flush internal cache of Api\Config class
340 340
 		$GLOBALS['egw_setup']->setup_account_object($current_config);
341 341
 	}
342 342
 
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @param $setup_info	array of application info from setup.inc.php files, etc.
347 347
 	 */
348
-	function droptables(array $setup_info,$DEBUG=False)
348
+	function droptables(array $setup_info, $DEBUG = False)
349 349
 	{
350
-		if(!@$GLOBALS['egw_setup']->oProc)
350
+		if (!@$GLOBALS['egw_setup']->oProc)
351 351
 		{
352 352
 			$this->init_process();
353 353
 		}
@@ -355,10 +355,10 @@  discard block
 block discarded – undo
355 355
 		$tablenames = $GLOBALS['egw_setup']->db->table_names();
356 356
 		if (!is_array($setup_info) || !is_array($tablenames))
357 357
 		{
358
-			return $setup_info;	// nothing to do
358
+			return $setup_info; // nothing to do
359 359
 		}
360 360
 		$tables = array();
361
-		foreach($tablenames as $data)
361
+		foreach ($tablenames as $data)
362 362
 		{
363 363
 			$tables[] = $data['table_name'];
364 364
 		}
@@ -367,16 +367,16 @@  discard block
 block discarded – undo
367 367
 		{
368 368
 			return $setup_info;
369 369
 		}
370
-		foreach($setup_info as $app_name => $data)
370
+		foreach ($setup_info as $app_name => $data)
371 371
 		{
372
-			if(is_array($data['tables']))
372
+			if (is_array($data['tables']))
373 373
 			{
374
-				foreach($data['tables'] as $table)
374
+				foreach ($data['tables'] as $table)
375 375
 				{
376 376
 					//echo $table;
377
-					if(in_array($table,$tables))
377
+					if (in_array($table, $tables))
378 378
 					{
379
-						if($DEBUG){ echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; }
379
+						if ($DEBUG) { echo '<br>process->droptables(): Dropping :'.$app_name.' table: '.$table; }
380 380
 						$GLOBALS['egw_setup']->oProc->DropTable($table);
381 381
 						// Update the array values for return below
382 382
 						$setup_info[$app_name]['status'] = 'U';
@@ -396,31 +396,31 @@  discard block
 block discarded – undo
396 396
 	 * @param boolean $DEBUG =false output further diagnostics
397 397
 	 * @return array $setup_info
398 398
 	 */
399
-	function current(array $setup_info,$DEBUG=False)
399
+	function current(array $setup_info, $DEBUG = False)
400 400
 	{
401 401
 		//echo __METHOD__; _debug_array($setup_info);
402
-		if(!isset($GLOBALS['egw_setup']->oProc))
402
+		if (!isset($GLOBALS['egw_setup']->oProc))
403 403
 		{
404 404
 			$this->init_process();
405 405
 		}
406
-		foreach($setup_info as $appname => &$appdata)
406
+		foreach ($setup_info as $appname => &$appdata)
407 407
 		{
408 408
 			$enabled = False;
409 409
 			$apptitle = $appdata['title'];
410 410
 
411
-			if($DEBUG) { echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; }
411
+			if ($DEBUG) { echo '<br>process->current(): Incoming status: '.$appname.',status: '.$appdata['status']; }
412 412
 
413
-			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
413
+			$appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
414 414
 
415
-			if($appdata['tables'] && file_exists($appdir.'tables_current.inc.php'))
415
+			if ($appdata['tables'] && file_exists($appdir.'tables_current.inc.php'))
416 416
 			{
417
-				if($DEBUG) { echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; }
417
+				if ($DEBUG) { echo '<br>process->current(): Including: '.$appdir.'tables_current.inc.php'; }
418 418
 				$phpgw_baseline = null;
419 419
 				include ($appdir.'tables_current.inc.php');
420
-				$ret = $this->post_process($phpgw_baseline,$DEBUG);
421
-				if($ret)
420
+				$ret = $this->post_process($phpgw_baseline, $DEBUG);
421
+				if ($ret)
422 422
 				{
423
-					if($GLOBALS['egw_setup']->app_registered($appname))
423
+					if ($GLOBALS['egw_setup']->app_registered($appname))
424 424
 					{
425 425
 						$GLOBALS['egw_setup']->update_app($appname);
426 426
 					}
@@ -435,34 +435,34 @@  discard block
 block discarded – undo
435 435
 				else
436 436
 				{
437 437
 					/* script processing failed */
438
-					if($DEBUG) { echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; }
438
+					if ($DEBUG) { echo '<br>process->current(): Failed for '.$appname.',status: '.$appdata['status']; }
439 439
 					$appdata['status'] = 'F';
440 440
 				}
441 441
 			}
442 442
 			else
443 443
 			{
444
-				if($DEBUG) { echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; }
444
+				if ($DEBUG) { echo '<br>process->current(): No current tables for '.$apptitle."\n"; }
445 445
 				/*
446 446
 				 Add the app, but disable it if it has tables defined.
447 447
 				 A manual sql script install is needed, but we do add the hooks
448 448
 				*/
449 449
 				$enabled = 99;
450
-				if($appdata['tables'][0] != '')
450
+				if ($appdata['tables'][0] != '')
451 451
 				{
452 452
 					$enabled = False;
453 453
 				}
454
-				if($GLOBALS['egw_setup']->app_registered($appname))
454
+				if ($GLOBALS['egw_setup']->app_registered($appname))
455 455
 				{
456 456
 					$GLOBALS['egw_setup']->update_app($appname);
457 457
 				}
458 458
 				else
459 459
 				{
460
-					$GLOBALS['egw_setup']->register_app($appname,$enabled);
460
+					$GLOBALS['egw_setup']->register_app($appname, $enabled);
461 461
 					$GLOBALS['egw_setup']->set_default_preferences($appname);
462 462
 				}
463 463
 				$appdata['status'] = 'C';
464 464
 			}
465
-			if($DEBUG) { echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; }
465
+			if ($DEBUG) { echo '<br>process->current(): Outgoing status: '.$appname.',status: '.$appdata['status']; }
466 466
 		}
467 467
 
468 468
 		// update hooks
@@ -479,25 +479,25 @@  discard block
 block discarded – undo
479 479
 	 * @param boolean $DEBUG =false output further diagnostics
480 480
 	 * @return array $setup_info
481 481
 	 */
482
-	function default_records(array $setup_info,$DEBUG=False)
482
+	function default_records(array $setup_info, $DEBUG = False)
483 483
 	{
484 484
 		//echo __METHOD__; _debug_array($setup_info);
485
-		if(!@$GLOBALS['egw_setup']->oProc)
485
+		if (!@$GLOBALS['egw_setup']->oProc)
486 486
 		{
487 487
 			$this->init_process();
488 488
 		}
489
-		foreach($setup_info as $appname => &$appdata)
489
+		foreach ($setup_info as $appname => &$appdata)
490 490
 		{
491
-			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
491
+			$appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
492 492
 
493
-			if(file_exists($appdir.'default_records.inc.php'))
493
+			if (file_exists($appdir.'default_records.inc.php'))
494 494
 			{
495
-				if($DEBUG)
495
+				if ($DEBUG)
496 496
 				{
497
-					echo '<br>process->default_records(): Including default records for ' . $appname . "\n";
497
+					echo '<br>process->default_records(): Including default records for '.$appname."\n";
498 498
 				}
499 499
 				$GLOBALS['egw_setup']->oProc->m_odb->transaction_begin();
500
-				$oProc = &$GLOBALS['egw_setup']->oProc;	// to be compatible with old apps
500
+				$oProc = &$GLOBALS['egw_setup']->oProc; // to be compatible with old apps
501 501
 				include ($appdir.'default_records.inc.php');
502 502
 				$GLOBALS['egw_setup']->oProc->m_odb->transaction_commit();
503 503
 			}
@@ -521,21 +521,21 @@  discard block
 block discarded – undo
521 521
 	 * @param boolean $DEBUG =false output further diagnostics
522 522
 	 * @return array $setup_info
523 523
 	 */
524
-	function test_data(array $setup_info,$DEBUG=False)
524
+	function test_data(array $setup_info, $DEBUG = False)
525 525
 	{
526
-		if(!@$GLOBALS['egw_setup']->oProc)
526
+		if (!@$GLOBALS['egw_setup']->oProc)
527 527
 		{
528 528
 			$this->init_process();
529 529
 		}
530
-		foreach($setup_info as $appname => &$appdata)
530
+		foreach ($setup_info as $appname => &$appdata)
531 531
 		{
532
-			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
532
+			$appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
533 533
 
534
-			if(file_exists($appdir.'test_data.inc.php'))
534
+			if (file_exists($appdir.'test_data.inc.php'))
535 535
 			{
536
-				if($DEBUG)
536
+				if ($DEBUG)
537 537
 				{
538
-					echo '<br>process->test_data(): Including baseline test data for ' . $appname . "\n";
538
+					echo '<br>process->test_data(): Including baseline test data for '.$appname."\n";
539 539
 				}
540 540
 				$GLOBALS['egw_setup']->oProc->m_odb->transaction_begin();
541 541
 				include ($appdir.'test_data.inc.php');
@@ -555,35 +555,35 @@  discard block
 block discarded – undo
555 555
 	 * @param boolean $DEBUG =false output further diagnostics
556 556
 	 * @return array $setup_info
557 557
 	 */
558
-	function baseline(array $setup_info,$DEBUG=False)
558
+	function baseline(array $setup_info, $DEBUG = False)
559 559
 	{
560
-		if(!@$GLOBALS['egw_setup']->oProc)
560
+		if (!@$GLOBALS['egw_setup']->oProc)
561 561
 		{
562 562
 			$this->init_process();
563 563
 		}
564
-		foreach($setup_info as $appname => &$appdata)
564
+		foreach ($setup_info as $appname => &$appdata)
565 565
 		{
566
-			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
566
+			$appdir = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
567 567
 
568
-			if(file_exists($appdir.'tables_baseline.inc.php'))
568
+			if (file_exists($appdir.'tables_baseline.inc.php'))
569 569
 			{
570
-				if($DEBUG)
570
+				if ($DEBUG)
571 571
 				{
572
-					echo '<br>process->baseline(): Including baseline tables for ' . $appname . "\n";
572
+					echo '<br>process->baseline(): Including baseline tables for '.$appname."\n";
573 573
 				}
574 574
 				$phpgw_baseline = null;
575 575
 				include ($appdir.'tables_baseline.inc.php');
576 576
 				$GLOBALS['egw_setup']->oProc->GenerateScripts($phpgw_baseline, $DEBUG);
577
-				$this->post_process($phpgw_baseline,$DEBUG);
577
+				$this->post_process($phpgw_baseline, $DEBUG);
578 578
 
579 579
 				/* Update the array values for return below */
580 580
 				/* $setup_info[$key]['status'] = 'R'; */
581 581
 			}
582 582
 			else
583 583
 			{
584
-				if($DEBUG)
584
+				if ($DEBUG)
585 585
 				{
586
-					echo '<br>process->baseline(): No baseline tables for ' . $appname . "\n";
586
+					echo '<br>process->baseline(): No baseline tables for '.$appname."\n";
587 587
 				}
588 588
 				//$setup_info[$key]['status'] = 'C';
589 589
 			}
@@ -601,19 +601,19 @@  discard block
 block discarded – undo
601 601
 	 * @param boolean $DEBUG =false output further diagnostics
602 602
 	 * @return array $setup_info
603 603
 	 */
604
-	function upgrade($setup_info,$DEBUG=False)
604
+	function upgrade($setup_info, $DEBUG = False)
605 605
 	{
606 606
 		//echo __METHOD__; _debug_array($setup_info);
607
-		if(!@$GLOBALS['egw_setup']->oProc)
607
+		if (!@$GLOBALS['egw_setup']->oProc)
608 608
 		{
609 609
 			$this->init_process();
610 610
 		}
611 611
 		$GLOBALS['egw_setup']->oProc->m_odb->HaltOnError = 'yes';
612 612
 
613
-		foreach($setup_info as $appname => &$appdata)
613
+		foreach ($setup_info as $appname => &$appdata)
614 614
 		{
615 615
 			// check if app is NOT installed
616
-			if(!$GLOBALS['egw_setup']->app_registered($appname))
616
+			if (!$GLOBALS['egw_setup']->app_registered($appname))
617 617
 			{
618 618
 				// check if app wants to be automatically installed on update to version x or allways
619 619
 				if (isset($appdata['autoinstall']) && ($appdata['autoinstall'] === true ||
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 					continue;
626 626
 				}
627 627
 				/* Don't try to upgrade an app that is not installed */
628
-				if($DEBUG)
628
+				if ($DEBUG)
629 629
 				{
630 630
 					echo "<p>process->upgrade(): Application not installed: $appname</p>\n";
631 631
 				}
@@ -634,41 +634,41 @@  discard block
 block discarded – undo
634 634
 			}
635 635
 
636 636
 			/* if upgrade required, or if we are running again after an upgrade or dependency failure */
637
-			if($DEBUG)
637
+			if ($DEBUG)
638 638
 			{
639 639
 				echo '<div style="text-align: left; border: thin dashed black; margin-top: 5px;">'."process->upgrade(): Incoming : appname: $appname, version: $appdata[currentver], status: $appdata[status]\n";
640 640
 			}
641
-			if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ???
641
+			if ($appdata['status'] == 'U' || $appdata['status'] == 'D' || $appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ???
642 642
 			{
643 643
 				$currentver = $appdata['currentver'];
644
-				$targetver  = $appdata['version'];	// The version we need to match when done
645
-				$appdir     = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
644
+				$targetver  = $appdata['version']; // The version we need to match when done
645
+				$appdir     = EGW_SERVER_ROOT.'/'.$appname.'/setup/';
646 646
 
647
-				if(file_exists($appdir . 'tables_update.inc.php'))
647
+				if (file_exists($appdir.'tables_update.inc.php'))
648 648
 				{
649 649
 					if (!@$this->updateincluded[$appname])
650 650
 					{
651
-						include ($appdir . 'tables_update.inc.php');
651
+						include ($appdir.'tables_update.inc.php');
652 652
 						$this->updateincluded[$appname] = True;
653 653
 					}
654 654
 					while ($currentver && $currentver != $targetver &&
655
-						function_exists($function = $appname . '_upgrade' . str_replace('.','_',$currentver)))
655
+						function_exists($function = $appname.'_upgrade'.str_replace('.', '_', $currentver)))
656 656
 					{
657
-						if($DEBUG)
657
+						if ($DEBUG)
658 658
 						{
659 659
 							echo "<br>process->upgrade(): $appname($currentver --> $targetver): running $function()\n";
660 660
 						}
661 661
 						if (!($currentver = $function()))
662 662
 						{
663
-							if($DEBUG)
663
+							if ($DEBUG)
664 664
 							{
665 665
 								echo "<b>failed!!!</b>\n";
666 666
 							}
667
-							$appstatus  = 'F';
667
+							$appstatus = 'F';
668 668
 						}
669 669
 						else
670 670
 						{
671
-							if($DEBUG)
671
+							if ($DEBUG)
672 672
 							{
673 673
 								echo "--> $currentver\n";
674 674
 							}
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 					}
677 677
 					if ($currentver == $targetver)	// upgrades succesful
678 678
 					{
679
-						if($DEBUG)
679
+						if ($DEBUG)
680 680
 						{
681 681
 							echo "<br>process->upgrade(): Upgrade of $appname to $targetver is completed.\n";
682 682
 						}
@@ -684,27 +684,27 @@  discard block
 block discarded – undo
684 684
 					}
685 685
 					elseif ($currentver)
686 686
 					{
687
-						if($DEBUG)
687
+						if ($DEBUG)
688 688
 						{
689 689
 							echo "<br><b>process->upgrade(): No table upgrade available for appname: $appname, version: $currentver</b>\n";
690 690
 						}
691 691
 						$appdate['currentver'] = $targetver;
692
-						$appstatus  = 'F';
692
+						$appstatus = 'F';
693 693
 					}
694 694
 				}
695 695
 				else
696 696
 				{
697
-					if($DEBUG)
697
+					if ($DEBUG)
698 698
 					{
699 699
 						echo "<br>process->upgrade(): No table upgrade required/availible for $appname\n";
700 700
 					}
701
-					$appstatus  = 'C';
701
+					$appstatus = 'C';
702 702
 				}
703 703
 				if ($appstatus == 'C')	// update successful completed
704 704
 				{
705 705
 					$appdata['currentver'] = $targetver;
706 706
 
707
-					if($GLOBALS['egw_setup']->app_registered($appname))
707
+					if ($GLOBALS['egw_setup']->app_registered($appname))
708 708
 					{
709 709
 						$GLOBALS['egw_setup']->update_app($appname);
710 710
 					}
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
 			}
718 718
 			else
719 719
 			{
720
-				if($DEBUG)
720
+				if ($DEBUG)
721 721
 				{
722 722
 					echo "<br>process->upgrade(): No upgrade required for $appname\n";
723 723
 				}
724
-				$appstatus  = 'C';
724
+				$appstatus = 'C';
725 725
 			}
726 726
 			/* Done with this app, update status */
727
-			if($DEBUG)
727
+			if ($DEBUG)
728 728
 			{
729 729
 				echo "<br>process->upgrade(): Outgoing : appname: $appname, status: $appstatus</div>\n";
730 730
 			}
@@ -742,13 +742,13 @@  discard block
 block discarded – undo
742 742
 	 * commit above processing to the db
743 743
 	 *
744 744
 	 */
745
-	function post_process($tables,$DEBUG=False)
745
+	function post_process($tables, $DEBUG = False)
746 746
 	{
747
-		if(!$tables)
747
+		if (!$tables)
748 748
 		{
749 749
 			return False;
750 750
 		}
751
-		return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables,$DEBUG);
751
+		return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables, $DEBUG);
752 752
 	}
753 753
 
754 754
 	/**
@@ -756,14 +756,14 @@  discard block
 block discarded – undo
756 756
 	 *
757 757
 	 * @param	$tablename	table whose array you want to see
758 758
 	 */
759
-	function sql_to_array($tablename='')
759
+	function sql_to_array($tablename = '')
760 760
 	{
761
-		if(!$tablename)
761
+		if (!$tablename)
762 762
 		{
763 763
 			return False;
764 764
 		}
765 765
 
766
-		if(!$GLOBALS['egw_setup']->oProc)
766
+		if (!$GLOBALS['egw_setup']->oProc)
767 767
 		{
768 768
 			$this->init_process();
769 769
 		}
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		$sColumns = null;
772 772
 		$GLOBALS['egw_setup']->oProc->m_oTranslator->_GetColumns($GLOBALS['egw_setup']->oProc, $tablename, $sColumns);
773 773
 
774
-		while(list($key,$tbldata) = each($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol))
774
+		while (list($key, $tbldata) = each($GLOBALS['egw_setup']->oProc->m_oTranslator->sCol))
775 775
 		{
776 776
 			$arr .= $tbldata;
777 777
 		}
@@ -780,6 +780,6 @@  discard block
 block discarded – undo
780 780
 		$ix = $GLOBALS['egw_setup']->oProc->m_oTranslator->ix;
781 781
 		$uc = $GLOBALS['egw_setup']->oProc->m_oTranslator->uc;
782 782
 
783
-		return array($arr,$pk,$fk,$ix,$uc);
783
+		return array($arr, $pk, $fk, $ix, $uc);
784 784
 	}
785 785
 }
Please login to merge, or discard this patch.
Braces   +53 added lines, -16 removed lines patch added patch discarded remove patch
@@ -108,7 +108,9 @@  discard block
 block discarded – undo
108 108
 		while($pass_string != $passing_string)
109 109
 		{
110 110
 			$passing = array();
111
-			if($DEBUG) { echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; }
111
+			if($DEBUG)
112
+			{
113
+echo '<br>process->pass(): #' . $i . ' for ' . $method . ' processing' . "\n"; }
112 114
 
113 115
 			// Check current versions and dependencies
114 116
 			$setup_info = $GLOBALS['egw_setup']->detection->check_depends(
@@ -143,7 +145,10 @@  discard block
 block discarded – undo
143 145
 					}
144 146
 					/* Create tables and insert new records for each app in this list */
145 147
 					$passing_c = $this->current($pass,$DEBUG);
146
-					if (isset($pass['api'])) $this->save_minimal_config($preset_config);
148
+					if (isset($pass['api']))
149
+					{
150
+						$this->save_minimal_config($preset_config);
151
+					}
147 152
 					$passing = $this->default_records($passing_c,$DEBUG);
148 153
 					break;
149 154
 				case 'upgrade':
@@ -162,29 +167,40 @@  discard block
 block discarded – undo
162 167
 				if($value['status'] == 'C')
163 168
 				{
164 169
 					$passed[$value['name']] = $passing[$value['name']];
165
-					if($DEBUG) { echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; }
170
+					if($DEBUG)
171
+					{
172
+echo '<br>process->pass(): '.$passed[$value['name']]['name'] . ' install completed'."\n"; }
166 173
 				}
167 174
 				elseif($value['status'] == 'F')
168 175
 				{
169 176
 					$setup_info[$value['name']] = $passing[$value['name']];
170
-					if($DEBUG) { echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; }
177
+					if($DEBUG)
178
+					{
179
+echo '<br>process->pass(): '.$setup_info[$value['name']]['name'] . ' install failed'."\n"; }
171 180
 				}
172 181
 				elseif($value['status'] == 'D')
173 182
 				{
174 183
 					$pass[$value['name']] = $setup_info[$value['name']];
175
-					if($DEBUG) { echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; }
184
+					if($DEBUG)
185
+					{
186
+echo '<br>process->pass(): '.$pass[$value['name']]['name'] . ' fails dependency check on this pass'."\n"; }
176 187
 				}
177 188
 				else
178 189
 				{
179 190
 					$tmp = $passing[$value['name']]['name'];
180
-					if($DEBUG) { echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; }
191
+					if($DEBUG)
192
+					{
193
+echo '<br>process->pass(): '.$tmp . ' skipped on this pass'."\n"; }
181 194
 				}
182 195
 			}
183 196
 
184 197
 			$i++;
185
-			if($i == 20) /* Then oops it broke */
198
+			if($i == 20)
199
+			{
200
+				/* Then oops it broke */
186 201
 			{
187 202
 				echo '<br>Setup failure: excess looping in process->pass():'."\n";
203
+			}
188 204
 				echo '<br>Pass:<br>'."\n";
189 205
 				_debug_array($pass);
190 206
 				echo '<br>Passed:<br>'."\n";
@@ -376,7 +392,9 @@  discard block
 block discarded – undo
376 392
 					//echo $table;
377 393
 					if(in_array($table,$tables))
378 394
 					{
379
-						if($DEBUG){ echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; }
395
+						if($DEBUG)
396
+						{
397
+echo '<br>process->droptables(): Dropping :'. $app_name . ' table: ' . $table; }
380 398
 						$GLOBALS['egw_setup']->oProc->DropTable($table);
381 399
 						// Update the array values for return below
382 400
 						$setup_info[$app_name]['status'] = 'U';
@@ -408,13 +426,17 @@  discard block
 block discarded – undo
408 426
 			$enabled = False;
409 427
 			$apptitle = $appdata['title'];
410 428
 
411
-			if($DEBUG) { echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; }
429
+			if($DEBUG)
430
+			{
431
+echo '<br>process->current(): Incoming status: ' . $appname . ',status: '. $appdata['status']; }
412 432
 
413 433
 			$appdir  = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
414 434
 
415 435
 			if($appdata['tables'] && file_exists($appdir.'tables_current.inc.php'))
416 436
 			{
417
-				if($DEBUG) { echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; }
437
+				if($DEBUG)
438
+				{
439
+echo '<br>process->current(): Including: ' . $appdir.'tables_current.inc.php'; }
418 440
 				$phpgw_baseline = null;
419 441
 				include ($appdir.'tables_current.inc.php');
420 442
 				$ret = $this->post_process($phpgw_baseline,$DEBUG);
@@ -435,13 +457,17 @@  discard block
 block discarded – undo
435 457
 				else
436 458
 				{
437 459
 					/* script processing failed */
438
-					if($DEBUG) { echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; }
460
+					if($DEBUG)
461
+					{
462
+echo '<br>process->current(): Failed for ' . $appname . ',status: '. $appdata['status']; }
439 463
 					$appdata['status'] = 'F';
440 464
 				}
441 465
 			}
442 466
 			else
443 467
 			{
444
-				if($DEBUG) { echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; }
468
+				if($DEBUG)
469
+				{
470
+echo '<br>process->current(): No current tables for ' . $apptitle . "\n"; }
445 471
 				/*
446 472
 				 Add the app, but disable it if it has tables defined.
447 473
 				 A manual sql script install is needed, but we do add the hooks
@@ -462,7 +488,9 @@  discard block
 block discarded – undo
462 488
 				}
463 489
 				$appdata['status'] = 'C';
464 490
 			}
465
-			if($DEBUG) { echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; }
491
+			if($DEBUG)
492
+			{
493
+echo '<br>process->current(): Outgoing status: ' . $appname . ',status: '. $appdata['status']; }
466 494
 		}
467 495
 
468 496
 		// update hooks
@@ -638,9 +666,12 @@  discard block
 block discarded – undo
638 666
 			{
639 667
 				echo '<div style="text-align: left; border: thin dashed black; margin-top: 5px;">'."process->upgrade(): Incoming : appname: $appname, version: $appdata[currentver], status: $appdata[status]\n";
640 668
 			}
641
-			if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '') // TODO this is not getting set for api upgrade, sometimes ???
669
+			if($appdata['status'] == 'U' || $appdata['status'] == 'D' ||$appdata['status'] == 'V' || $appdata['status'] == '')
670
+			{
671
+				// TODO this is not getting set for api upgrade, sometimes ???
642 672
 			{
643 673
 				$currentver = $appdata['currentver'];
674
+			}
644 675
 				$targetver  = $appdata['version'];	// The version we need to match when done
645 676
 				$appdir     = EGW_SERVER_ROOT . '/' . $appname . '/setup/';
646 677
 
@@ -674,11 +705,14 @@  discard block
 block discarded – undo
674 705
 							}
675 706
 						}
676 707
 					}
677
-					if ($currentver == $targetver)	// upgrades succesful
708
+					if ($currentver == $targetver)
709
+					{
710
+						// upgrades succesful
678 711
 					{
679 712
 						if($DEBUG)
680 713
 						{
681 714
 							echo "<br>process->upgrade(): Upgrade of $appname to $targetver is completed.\n";
715
+					}
682 716
 						}
683 717
 						$appstatus = 'C';
684 718
 					}
@@ -700,9 +734,12 @@  discard block
 block discarded – undo
700 734
 					}
701 735
 					$appstatus  = 'C';
702 736
 				}
703
-				if ($appstatus == 'C')	// update successful completed
737
+				if ($appstatus == 'C')
738
+				{
739
+					// update successful completed
704 740
 				{
705 741
 					$appdata['currentver'] = $targetver;
742
+				}
706 743
 
707 744
 					if($GLOBALS['egw_setup']->app_registered($appname))
708 745
 					{
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.
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.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 if (!defined('TIMESHEET_APP'))
18 18
 {
19
-	define('TIMESHEET_APP','timesheet');
19
+	define('TIMESHEET_APP', 'timesheet');
20 20
 }
21 21
 
22 22
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @var boolean
45 45
 	 */
46
-	var $quantity_sum=false;
46
+	var $quantity_sum = false;
47 47
 	/**
48 48
 	 * current user
49 49
 	 *
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @var array
57 57
 	 */
58 58
 	var $timestamps = array(
59
-		'ts_start','ts_modified'
59
+		'ts_start', 'ts_modified'
60 60
 	);
61 61
 	/**
62 62
 	 * Start of today in user-time
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 * @var array
71 71
 	 */
72 72
 	var $date_filters = array(	// Start: year,month,day,week, End: year,month,day,week
73
-		'Today'       => array(0,0,0,0,  0,0,1,0),
74
-		'Yesterday'   => array(0,0,-1,0, 0,0,0,0),
75
-		'This week'   => array(0,0,0,0,  0,0,0,1),
76
-		'Last week'   => array(0,0,0,-1, 0,0,0,0),
77
-		'This month'  => array(0,0,0,0,  0,1,0,0),
78
-		'Last month'  => array(0,-1,0,0, 0,0,0,0),
79
-		'2 month ago' => array(0,-2,0,0, 0,-1,0,0),
80
-		'This year'   => array(0,0,0,0,  1,0,0,0),
81
-		'Last year'   => array(-1,0,0,0, 0,0,0,0),
82
-		'2 years ago' => array(-2,0,0,0, -1,0,0,0),
83
-		'3 years ago' => array(-3,0,0,0, -2,0,0,0),
73
+		'Today'       => array(0, 0, 0, 0, 0, 0, 1, 0),
74
+		'Yesterday'   => array(0, 0, -1, 0, 0, 0, 0, 0),
75
+		'This week'   => array(0, 0, 0, 0, 0, 0, 0, 1),
76
+		'Last week'   => array(0, 0, 0, -1, 0, 0, 0, 0),
77
+		'This month'  => array(0, 0, 0, 0, 0, 1, 0, 0),
78
+		'Last month'  => array(0, -1, 0, 0, 0, 0, 0, 0),
79
+		'2 month ago' => array(0, -2, 0, 0, 0, -1, 0, 0),
80
+		'This year'   => array(0, 0, 0, 0, 1, 0, 0, 0),
81
+		'Last year'   => array(-1, 0, 0, 0, 0, 0, 0, 0),
82
+		'2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0),
83
+		'3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0),
84 84
 	);
85 85
 	/**
86 86
 	 * Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @var array
107 107
 	 */
108
-	var $customfields=array();
108
+	var $customfields = array();
109 109
 	/**
110 110
 	 * Array with status label
111 111
 	 *
@@ -165,21 +165,21 @@  discard block
 block discarded – undo
165 165
 
166 166
 	function __construct()
167 167
 	{
168
-		parent::__construct(TIMESHEET_APP,'egw_timesheet',self::EXTRA_TABLE,'','ts_extra_name','ts_extra_value','ts_id');
168
+		parent::__construct(TIMESHEET_APP, 'egw_timesheet', self::EXTRA_TABLE, '', 'ts_extra_name', 'ts_extra_value', 'ts_id');
169 169
 
170 170
 		if ($this->customfields) $this->columns_to_search[] = self::EXTRA_TABLE.'.ts_extra_value';
171 171
 		$this->config_data = Api\Config::read(TIMESHEET_APP);
172 172
 		$this->quantity_sum = $this->config_data['quantity_sum'] == 'true';
173 173
 
174 174
 		// Load & process statuses
175
-		if($this->config_data['status_labels']) $this->load_statuses();
175
+		if ($this->config_data['status_labels']) $this->load_statuses();
176 176
 
177
-		$this->today = mktime(0,0,0,date('m',$this->now),date('d',$this->now),date('Y',$this->now));
177
+		$this->today = mktime(0, 0, 0, date('m', $this->now), date('d', $this->now), date('Y', $this->now));
178 178
 
179 179
 		// save us in $GLOBALS['timesheet_bo'] for ExecMethod used in hooks
180 180
 		if (!is_object($GLOBALS['timesheet_bo']))
181 181
 		{
182
-			$GLOBALS['timesheet_bo'] =& $this;
182
+			$GLOBALS['timesheet_bo'] = & $this;
183 183
 		}
184 184
 		$this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
185 185
 	}
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	protected function load_statuses()
191 191
 	{
192
-		$this->status_labels =&  $this->config_data['status_labels'];
193
-		if (!is_array($this->status_labels)) $this->status_labels= array($this->status_labels);
192
+		$this->status_labels = &  $this->config_data['status_labels'];
193
+		if (!is_array($this->status_labels)) $this->status_labels = array($this->status_labels);
194 194
 
195 195
 		foreach ($this->status_labels as $status_id => $label)
196 196
 		{
197 197
 			if (!is_array($label))
198 198
 			{	//old values, before parent status
199 199
 				$name = $label;
200
-				$label=array();
200
+				$label = array();
201 201
 				$label['name'] = $name;
202 202
 				$label['parent'] = '';
203 203
 			}
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 		$map = array(
210 210
 			'' => array('substatus' => array())
211 211
 		);
212
-		foreach($this->status_labels_config as $id => &$status)
212
+		foreach ($this->status_labels_config as $id => &$status)
213 213
 		{
214 214
 			$status['substatus'] = array();
215 215
 			$map[$id] = &$status;
216 216
 		}
217
-		foreach($this->status_labels_config as &$status)
217
+		foreach ($this->status_labels_config as &$status)
218 218
 		{
219 219
 			$map[$status['parent']]['substatus'][] = &$status;
220 220
 		}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
 		// Sort Api\Config based on tree
228 228
 		$sorted = array();
229
-		foreach($this->status_labels as $status_id => $label)
229
+		foreach ($this->status_labels as $status_id => $label)
230 230
 		{
231 231
 			$sorted[$status_id] = $this->status_labels_config[$status_id];
232 232
 			//$sorted[$status_id]['name'] = $label;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	{
246 246
 		if (!isset($this->status_labels_config)) $this->load_statuses();
247 247
 		$stati = array($status);
248
-		foreach($this->status_labels_config as $stat)
248
+		foreach ($this->status_labels_config as $stat)
249 249
 		{
250 250
 			if ($stat['parent'] && in_array($stat['parent'], $stati))
251 251
 			{
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @return None, labels are built in labels parameter
267 267
 	 */
268
-	protected function make_status_labels($statuses, &$labels, $depth=0)
268
+	protected function make_status_labels($statuses, &$labels, $depth = 0)
269 269
 	{
270
-		foreach($statuses as $status)
270
+		foreach ($statuses as $status)
271 271
 		{
272
-			$labels[$status['id']] = str_pad('',$depth*12, "&nbsp;",STR_PAD_LEFT).trim(str_replace('&nbsp;','',$status['name']));
273
-			if(count($status['substatus']) > 0)
272
+			$labels[$status['id']] = str_pad('', $depth * 12, "&nbsp;", STR_PAD_LEFT).trim(str_replace('&nbsp;', '', $status['name']));
273
+			if (count($status['substatus']) > 0)
274 274
 			{
275
-				$this->make_status_labels($status['substatus'], $labels, $depth+1);
275
+				$this->make_status_labels($status['substatus'], $labels, $depth + 1);
276 276
 			}
277 277
 		}
278 278
 	}
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
 	 * @param boolean $hide_deactive =null default only Acl::EDIT hides deactivates users
285 285
 	 * @return array with uid => Username pairs
286 286
 	 */
287
-	function grant_list($required=Acl::READ, $hide_deactive=null)
287
+	function grant_list($required = Acl::READ, $hide_deactive = null)
288 288
 	{
289 289
 		if (!isset($hide_deactive)) $hide_deactive = $required == Acl::EDIT;
290 290
 
291 291
 		$result = array();
292
-		foreach($this->grants as $uid => $grant)
292
+		foreach ($this->grants as $uid => $grant)
293 293
 		{
294
-			if ($grant & $required && (!$hide_deactive || Api\Accounts::getInstance()->is_active($uid)))
294
+			if ($grant&$required && (!$hide_deactive || Api\Accounts::getInstance()->is_active($uid)))
295 295
 			{
296 296
 				$result[$uid] = Api\Accounts::username($uid);
297 297
 			}
@@ -310,19 +310,19 @@  discard block
 block discarded – undo
310 310
 	 * @param int $user =null for which user to check, default current user
311 311
 	 * @return boolean true if the rights are ok, false if no rights
312 312
 	 */
313
-	function check_statusForEditRights($data=null,$user=null)
313
+	function check_statusForEditRights($data = null, $user = null)
314 314
 	{
315 315
 		if (is_null($data) || (int)$data == $this->data['ts_id'])
316 316
 		{
317
-			$data =& $this->data;
317
+			$data = & $this->data;
318 318
 		}
319 319
 		if (!is_array($data))
320 320
 		{
321 321
 			$save_data = $this->data;
322
-			$data = $this->read($data,true);
322
+			$data = $this->read($data, true);
323 323
 			$this->data = $save_data;
324 324
 
325
-			if (!$data) return null; 	// entry not found
325
+			if (!$data) return null; // entry not found
326 326
 		}
327 327
 		if (!$user) $user = $this->user;
328 328
 		if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status'])
@@ -345,19 +345,19 @@  discard block
 block discarded – undo
345 345
 	 * @param int $user =null for which user to check, default current user
346 346
 	 * @return boolean true if the rights are ok, null if not found, false if no rights
347 347
 	 */
348
-	function check_acl($required,$data=null,$user=null)
348
+	function check_acl($required, $data = null, $user = null)
349 349
 	{
350 350
 		if (is_null($data) || (int)$data == $this->data['ts_id'])
351 351
 		{
352
-			$data =& $this->data;
352
+			$data = & $this->data;
353 353
 		}
354 354
 		if (!is_array($data))
355 355
 		{
356 356
 			$save_data = $this->data;
357
-			$data = $this->read($data,true);
357
+			$data = $this->read($data, true);
358 358
 			$this->data = $save_data;
359 359
 
360
-			if (!$data) return null; 	// entry not found
360
+			if (!$data) return null; // entry not found
361 361
 		}
362 362
 		if (!$user) $user = $this->user;
363 363
 		if ($user == $this->user)
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
 		}
367 367
 		else
368 368
 		{
369
-			$grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP,true,$user);
369
+			$grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP, true, $user);
370 370
 		}
371
-		$ret = $data && !!($grants[$data['ts_owner']] & $required);
371
+		$ret = $data && !!($grants[$data['ts_owner']]&$required);
372 372
 
373
-		if(($required & Acl::DELETE) && $this->config_data['history'] == 'history' &&
373
+		if (($required&Acl::DELETE) && $this->config_data['history'] == 'history' &&
374 374
 			$data['ts_status'] == self::DELETED_STATUS)
375 375
 		{
376 376
 			$ret = !!($GLOBALS['egw_info']['user']['apps']['admin']);
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * @param int &$end
388 388
 	 * @return string
389 389
 	 */
390
-	function date_filter($name,&$start,&$end)
390
+	function date_filter($name, &$start, &$end)
391 391
 	{
392 392
 		return Api\DateTime::sql_filter($name, $start, $end, 'ts_start', $this->date_filters);
393 393
 	}
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * @param boolean $only_summary =false If true only return the sums as array with keys duration and price, default false
413 413
 	 * @return array of matching rows (the row is an array of the cols) or False
414 414
 	 */
415
-	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)
415
+	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)
416 416
 	{
417 417
 		//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')");
418 418
 		//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";
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
 
422 422
 		if (!is_array($extra_cols))
423 423
 		{
424
-			$extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
424
+			$extra_cols = $extra_cols ? explode(',', $extra_cols) : array();
425 425
 		}
426
-		if ($only_keys === false || $this->show_sums && strpos($order_by,'ts_start') !== false)
426
+		if ($only_keys === false || $this->show_sums && strpos($order_by, 'ts_start') !== false)
427 427
 		{
428 428
 			$extra_cols[] = $total_sql.' AS ts_total';
429 429
 		}
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		{
436 436
 			if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
437 437
 
438
-			foreach($filter['ts_owner'] as $key => $owner)
438
+			foreach ($filter['ts_owner'] as $key => $owner)
439 439
 			{
440 440
 				if (!isset($this->grants[$owner]))
441 441
 				{
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 		}
450 450
 		else
451 451
 		{
452
-			$filter[] = '(ts_status ' . ($filter['ts_status'] == self::DELETED_STATUS ? '=':'!= ') . self::DELETED_STATUS .
453
-				($filter['ts_status'] == self::DELETED_STATUS ? '':' OR ts_status IS NULL') . ')';
452
+			$filter[] = '(ts_status '.($filter['ts_status'] == self::DELETED_STATUS ? '=' : '!= ').self::DELETED_STATUS.
453
+				($filter['ts_status'] == self::DELETED_STATUS ? '' : ' OR ts_status IS NULL').')';
454 454
 		}
455 455
 		if (!count($filter['ts_owner']))
456 456
 		{
@@ -458,15 +458,15 @@  discard block
 block discarded – undo
458 458
 			$this->summary = array();
459 459
 			return array();
460 460
 		}
461
-		if ($only_summary==false && $criteria && $this->show_sums)
461
+		if ($only_summary == false && $criteria && $this->show_sums)
462 462
 		{
463 463
 			// if we have a criteria AND intend to show the sums we first query the affected ids,
464 464
 			// then we throw away criteria and filter, and replace the filter with the list of ids
465
-			$ids = parent::search($criteria,'egw_timesheet.ts_id as id','','',$wildcard,$empty,$op,false,$filter,$join);
465
+			$ids = parent::search($criteria, 'egw_timesheet.ts_id as id', '', '', $wildcard, $empty, $op, false, $filter, $join);
466 466
 			//_debug_array($ids);
467 467
 			if (empty($ids))
468 468
 			{
469
-				$this->summary = array('duration'=>0,'price'=>null,'quantity'=>0);
469
+				$this->summary = array('duration'=>0, 'price'=>null, 'quantity'=>0);
470 470
 				return array();
471 471
 			}
472 472
 			unset($criteria);
@@ -490,45 +490,45 @@  discard block
 block discarded – undo
490 490
 
491 491
 		if ($only_summary) return $this->summary;
492 492
 
493
-		if ($this->show_sums && strpos($order_by,'ts_start') !== false && 	// sums only make sense if ordered by ts_start
493
+		if ($this->show_sums && strpos($order_by, 'ts_start') !== false && // sums only make sense if ordered by ts_start
494 494
 			$this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start')))
495 495
 		{
496 496
 			$sum_sql = array(
497
-				'year'  => $this->db->date_format($from_unixtime_ts_start,'%Y'),
498
-				'month' => $this->db->date_format($from_unixtime_ts_start,'%Y%m'),
499
-				'week'  => $this->db->date_format($from_unixtime_ts_start,$GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'),
500
-				'day'   => $this->db->date_format($from_unixtime_ts_start,'%Y-%m-%d'),
497
+				'year'  => $this->db->date_format($from_unixtime_ts_start, '%Y'),
498
+				'month' => $this->db->date_format($from_unixtime_ts_start, '%Y%m'),
499
+				'week'  => $this->db->date_format($from_unixtime_ts_start, $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'),
500
+				'day'   => $this->db->date_format($from_unixtime_ts_start, '%Y-%m-%d'),
501 501
 			);
502
-			foreach($this->show_sums as $type)
502
+			foreach ($this->show_sums as $type)
503 503
 			{
504 504
 				$extra_cols[] = $sum_sql[$type].' AS ts_'.$type;
505 505
 				$extra_cols[] = '0 AS is_sum_'.$type;
506
-				$sum_extra_cols[] = str_replace('ts_start','MIN(ts_start)',$sum_sql[$type]);	// as we dont group by ts_start
506
+				$sum_extra_cols[] = str_replace('ts_start', 'MIN(ts_start)', $sum_sql[$type]); // as we dont group by ts_start
507 507
 				$sum_extra_cols[$type] = '0 AS is_sum_'.$type;
508 508
 			}
509 509
 			// regular entries
510
-			parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
510
+			parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count);
511 511
 
512
-			$sort = substr($order_by,8);
512
+			$sort = substr($order_by, 8);
513 513
 			$union_order = array();
514
-			$sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0);
515
-			foreach($this->show_sums as $type)
514
+			$sum_ts_id = array('year' => -3, 'month' => -2, 'week' => -1, 'day' => 0);
515
+			foreach ($this->show_sums as $type)
516 516
 			{
517
-				$union_order[] = 'ts_'.$type . ' ' . $sort;
517
+				$union_order[] = 'ts_'.$type.' '.$sort;
518 518
 				$union_order[] = 'is_sum_'.$type;
519 519
 				$sum_extra_cols[$type]{0} = '1';
520 520
 				// the $type sum
521
-				parent::search($criteria,array(
522
-					(string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration',
521
+				parent::search($criteria, array(
522
+					(string)$sum_ts_id[$type], "''", "''", "''", 'MIN(ts_start)', 'SUM(ts_duration) AS ts_duration',
523 523
 					($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'),
524
-					'0','NULL','0','0','0','0','0',"SUM($total_sql) AS ts_total"
525
-				),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
524
+					'0', 'NULL', '0', '0', '0', '0', '0', "SUM($total_sql) AS ts_total"
525
+				), 'GROUP BY '.$sum_sql[$type], $sum_extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count);
526 526
 				$sum_extra_cols[$type]{0} = '0';
527 527
 			}
528 528
 			$union_order[] = 'ts_start '.$sort;
529
-			return parent::search('','',implode(',',$union_order),'','',false,'',$start);
529
+			return parent::search('', '', implode(',', $union_order), '', '', false, '', $start);
530 530
 		}
531
-		return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
531
+		return parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count);
532 532
 	}
533 533
 
534 534
 	/**
@@ -538,16 +538,16 @@  discard block
 block discarded – undo
538 538
 	 * @param boolean $ignore_acl =false should the Acl be checked
539 539
 	 * @return array|boolean array with timesheet entry, null if timesheet not found or false if no rights
540 540
 	 */
541
-	function read($ts_id,$ignore_acl=false)
541
+	function read($ts_id, $ignore_acl = false)
542 542
 	{
543 543
 		//error_log(__METHOD__."($ts_id,$ignore_acl) ".function_backtrace());
544 544
 		if (!(int)$ts_id || (int)$ts_id != $this->data['ts_id'] && !parent::read($ts_id))
545 545
 		{
546
-			return null;	// entry not found
546
+			return null; // entry not found
547 547
 		}
548 548
 		if (!$ignore_acl && !($ret = $this->check_acl(Acl::READ)))
549 549
 		{
550
-			return false;	// no read rights
550
+			return false; // no read rights
551 551
 		}
552 552
 		return $this->data;
553 553
 	}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	 * @param boolean $ignore_acl =false should the Acl be checked, returns true if no edit-rigts
563 563
 	 * @return int 0 on success and errno != 0 else
564 564
 	 */
565
-	function save($keys=null,$touch_modified=true,$ignore_acl=false)
565
+	function save($keys = null, $touch_modified = true, $ignore_acl = false)
566 566
 	{
567 567
 		if ($keys) $this->data_merge($keys);
568 568
 
@@ -580,13 +580,13 @@  discard block
 block discarded – undo
580 580
 		// check if we have a real modification of an existing record
581 581
 		if ($this->data['ts_id'])
582 582
 		{
583
-			$new =& $this->data;
583
+			$new = & $this->data;
584 584
 			unset($this->data);
585 585
 			$this->read($new['ts_id']);
586
-			$old =& $this->data;
587
-			$this->data =& $new;
586
+			$old = & $this->data;
587
+			$this->data = & $new;
588 588
 			$changed = array();
589
-			if (isset($old)) foreach($old as $name => $value)
589
+			if (isset($old)) foreach ($old as $name => $value)
590 590
 			{
591 591
 				if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name;
592 592
 			}
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 		}
598 598
 
599 599
 		// Check for restore of deleted contact, restore held links
600
-		if($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS)
600
+		if ($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS)
601 601
 		{
602 602
 			Link::restore(TIMESHEET_APP, $new['ts_id']);
603 603
 		}
@@ -608,14 +608,14 @@  discard block
 block discarded – undo
608 608
 
609 609
 			$this->tracking->html_content_allow = true;
610 610
 		}
611
-		if ($this->tracking->track($this->data,$old,$this->user) === false)
611
+		if ($this->tracking->track($this->data, $old, $this->user) === false)
612 612
 		{
613
-			return implode(', ',$this->tracking->errors);
613
+			return implode(', ', $this->tracking->errors);
614 614
 		}
615 615
 		if (!($err = parent::save()))
616 616
 		{
617 617
 			// notify the link-class about the update, as other apps may be subscribt to it
618
-			Link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
618
+			Link::notify_update(TIMESHEET_APP, $this->data['ts_id'], $this->data);
619 619
 		}
620 620
 
621 621
 		return $err;
@@ -628,15 +628,15 @@  discard block
 block discarded – undo
628 628
 	 * @param boolean $ignore_acl =false should the Acl be checked, returns false if no delete-rigts
629 629
 	 * @return int affected rows, should be 1 if ok, 0 if an error
630 630
 	 */
631
-	function delete($keys=null,$ignore_acl=false)
631
+	function delete($keys = null, $ignore_acl = false)
632 632
 	{
633
-		if (!is_array($keys) && (int) $keys)
633
+		if (!is_array($keys) && (int)$keys)
634 634
 		{
635
-			$keys = array('ts_id' => (int) $keys);
635
+			$keys = array('ts_id' => (int)$keys);
636 636
 		}
637 637
 		$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
638 638
 
639
-		if (!$ignore_acl && !$this->check_acl(Acl::DELETE,$ts_id) || !($old = $this->read($ts_id)))
639
+		if (!$ignore_acl && !$this->check_acl(Acl::DELETE, $ts_id) || !($old = $this->read($ts_id)))
640 640
 		{
641 641
 			return false;
642 642
 		}
@@ -647,12 +647,12 @@  discard block
 block discarded – undo
647 647
 			$delete = $old;
648 648
 			$delete['ts_status'] = self::DELETED_STATUS;
649 649
 			$ret = !($this->save($delete));
650
-			Link::unlink(0,TIMESHEET_APP,$ts_id,'','','',true);
650
+			Link::unlink(0, TIMESHEET_APP, $ts_id, '', '', '', true);
651 651
 		}
652 652
 		elseif (($ret = parent::delete($keys)) && $ts_id)
653 653
 		{
654 654
 			// delete all links to timesheet entry $ts_id
655
-			Link::unlink(0,TIMESHEET_APP,$ts_id);
655
+			Link::unlink(0, TIMESHEET_APP, $ts_id);
656 656
 		}
657 657
 		return $ret;
658 658
 	}
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	function deleteaccount($data)
668 668
 	{
669 669
 		$account_id = $data['account_id'];
670
-		$new_owner =  $data['new_owner'];
670
+		$new_owner = $data['new_owner'];
671 671
 
672 672
 		if (!$new_owner)
673 673
 		{
@@ -691,22 +691,22 @@  discard block
 block discarded – undo
691 691
 	 * @param int $status =0
692 692
 	 * @return int affected rows, should be 1 if ok, 0 if an error
693 693
 	 */
694
-	function set_status($keys=null, $status=0)
694
+	function set_status($keys = null, $status = 0)
695 695
 	{
696 696
 		$ret = true;
697
-		if (!is_array($keys) && (int) $keys)
697
+		if (!is_array($keys) && (int)$keys)
698 698
 		{
699
-			$keys = array('ts_id' => (int) $keys);
699
+			$keys = array('ts_id' => (int)$keys);
700 700
 		}
701 701
 		$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
702 702
 
703
-		if (!$this->check_acl(Acl::EDIT,$ts_id) || !$this->read($ts_id,true))
703
+		if (!$this->check_acl(Acl::EDIT, $ts_id) || !$this->read($ts_id, true))
704 704
 		{
705 705
 			return false;
706 706
 		}
707 707
 
708 708
 		$this->data['ts_status'] = $status;
709
-		if ($this->save($ts_id)!=0) $ret = false;
709
+		if ($this->save($ts_id) != 0) $ret = false;
710 710
 
711 711
 		return $ret;
712 712
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 		{
724 724
 			return array('duration' => 0, 'quantity' => 0, 'price' => 0, 'max_modified' => null);
725 725
 		}
726
-		return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true);
726
+		return $this->search(array('ts_id'=>$ids), true, '', '', '', false, 'AND', false, null, '', false, true);
727 727
 	}
728 728
 
729 729
 	/**
@@ -734,27 +734,27 @@  discard block
 block discarded – undo
734 734
 	 * @param int|array $entry int ts_id or array with timesheet entry
735 735
 	 * @return string/boolean string with title, null if timesheet not found, false if no perms to view it
736 736
 	 */
737
-	function link_title( $entry )
737
+	function link_title($entry)
738 738
 	{
739 739
 		if (!is_array($entry))
740 740
 		{
741 741
 			// need to preserve the $this->data
742
-			$backup =& $this->data;
742
+			$backup = & $this->data;
743 743
 			unset($this->data);
744
-			$entry = $this->read( $entry,false,false);
744
+			$entry = $this->read($entry, false, false);
745 745
 			// restore the data again
746
-			$this->data =& $backup;
746
+			$this->data = & $backup;
747 747
 		}
748 748
 		if (!$entry)
749 749
 		{
750 750
 			return $entry;
751 751
 		}
752 752
 		$format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
753
-		if (date('H:i',$entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
753
+		if (date('H:i', $entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
754 754
 		{
755 755
 			$format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i');
756 756
 		}
757
-		return date($format,$entry['ts_start']).': '.$entry['ts_title'];
757
+		return date($format, $entry['ts_start']).': '.$entry['ts_title'];
758 758
 	}
759 759
 
760 760
 	/**
@@ -765,18 +765,18 @@  discard block
 block discarded – undo
765 765
 	 * @param array $ids array with ts_id's
766 766
 	 * @return array with titles, see link_title
767 767
 	 */
768
-	function link_titles( array $ids )
768
+	function link_titles(array $ids)
769 769
 	{
770 770
 		$titles = array();
771
-		if (($entries = $this->search(array('ts_id' => $ids),'ts_id,ts_title,ts_start')))
771
+		if (($entries = $this->search(array('ts_id' => $ids), 'ts_id,ts_title,ts_start')))
772 772
 		{
773
-			foreach($entries as $entry)
773
+			foreach ($entries as $entry)
774 774
 			{
775 775
 				$titles[$entry['ts_id']] = $this->link_title($entry);
776 776
 			}
777 777
 		}
778 778
 		// we assume all not returned entries are not readable by the user, as we notify Link about all deletes
779
-		foreach($ids as $id)
779
+		foreach ($ids as $id)
780 780
 		{
781 781
 			if (!isset($titles[$id]))
782 782
 			{
@@ -795,16 +795,16 @@  discard block
 block discarded – undo
795 795
 	 * @param array $options Array of options for the search
796 796
 	 * @return array with ts_id - title pairs of the matching entries
797 797
 	 */
798
-	function link_query( $pattern, Array &$options = array() )
798
+	function link_query($pattern, Array &$options = array())
799 799
 	{
800 800
 		$limit = false;
801 801
 		$need_count = false;
802
-		if($options['start'] || $options['num_rows']) {
802
+		if ($options['start'] || $options['num_rows']) {
803 803
 			$limit = array($options['start'], $options['num_rows']);
804 804
 			$need_count = true;
805 805
 		}
806 806
 		$result = array();
807
-		foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts )
807
+		foreach ((array)$this->search($pattern, false, '', '', '%', false, 'OR', $limit, null, '', $need_count) as $ts)
808 808
 		{
809 809
 			if ($ts) $result[$ts['ts_id']] = $this->link_title($ts);
810 810
 		}
@@ -821,11 +821,11 @@  discard block
 block discarded – undo
821 821
 	 * @param int $user =null for which user to check, default current user
822 822
 	 * @return boolean true if access is granted or false otherwise
823 823
 	 */
824
-	function file_access($id,$check,$rel_path=null,$user=null)
824
+	function file_access($id, $check, $rel_path = null, $user = null)
825 825
 	{
826
-		unset($rel_path);	// not used, but required by function signature
826
+		unset($rel_path); // not used, but required by function signature
827 827
 
828
-		return $this->check_acl($check,$id,$user);
828
+		return $this->check_acl($check, $id, $user);
829 829
 	}
830 830
 
831 831
 	/**
@@ -837,16 +837,16 @@  discard block
 block discarded – undo
837 837
 	 * @param string $newtitle => the new title of the project
838 838
 	 * @return boolean true for success, false for invalid parameters
839 839
 	 */
840
-	 function update_ts_project($oldtitle='', $newtitle='')
840
+	 function update_ts_project($oldtitle = '', $newtitle = '')
841 841
 	 {
842
-		if(strlen($oldtitle) > 0 && strlen($newtitle) > 0)
842
+		if (strlen($oldtitle) > 0 && strlen($newtitle) > 0)
843 843
 		{
844
-			$this->db->update('egw_timesheet',array(
844
+			$this->db->update('egw_timesheet', array(
845 845
 				'ts_project' => $newtitle,
846 846
 				'ts_title' => $newtitle,
847
-			),array(
847
+			), array(
848 848
 				'ts_project' => $oldtitle,
849
-			),__LINE__,__FILE__,TIMESHEET_APP);
849
+			), __LINE__, __FILE__, TIMESHEET_APP);
850 850
 
851 851
 			return true;
852 852
 		}
@@ -859,16 +859,16 @@  discard block
 block discarded – undo
859 859
 	 * @param int $pm_id ID of selected project
860 860
 	 * @return array containing link_id and ts_id
861 861
 	 */
862
-	function get_ts_links($pm_id=0)
862
+	function get_ts_links($pm_id = 0)
863 863
 	{
864
-		if($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
864
+		if ($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
865 865
 		{
866
-			$pm_ids = ExecMethod('projectmanager.projectmanager_bo.children',$pm_id);
866
+			$pm_ids = ExecMethod('projectmanager.projectmanager_bo.children', $pm_id);
867 867
 			$pm_ids[] = $pm_id;
868
-			$links = Link\Storage::get_links('projectmanager',$pm_ids,'timesheet');	// Link\Storage::get_links not egw_links::get_links!
868
+			$links = Link\Storage::get_links('projectmanager', $pm_ids, 'timesheet'); // Link\Storage::get_links not egw_links::get_links!
869 869
 			if ($links)
870 870
 			{
871
-				$links = array_unique(call_user_func_array('array_merge',$links));
871
+				$links = array_unique(call_user_func_array('array_merge', $links));
872 872
 			}
873 873
 			return $links;
874 874
 		}
@@ -886,17 +886,17 @@  discard block
 block discarded – undo
886 886
 	function notify($data)
887 887
 	{
888 888
 		//error_log(__METHOD__.'('.array2string($data).')');
889
-		$backup =& $this->data;	// backup internal data in case class got re-used by ExecMethod
889
+		$backup = & $this->data; // backup internal data in case class got re-used by ExecMethod
890 890
 		unset($this->data);
891 891
 
892 892
 		if ($data['target_app'] == 'projectmanager' && $this->read($data['id']))
893 893
 		{
894 894
 			$old_title = isset($data['data']) ? $data['data'][Link::OLD_LINK_TITLE] : null;
895
-			switch($data['type'])
895
+			switch ($data['type'])
896 896
 			{
897 897
 				case 'link':
898 898
 				case 'update':
899
-					if (empty($this->data['ts_project']) ||	// timesheet has not yet project set --> set just linked one
899
+					if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one
900 900
 						isset($old_title) && $this->data['ts_project'] === $old_title)
901 901
 					{
902 902
 						$pm_id = $data['target_id'];
@@ -938,17 +938,17 @@  discard block
 block discarded – undo
938 938
 	 * @param array $data =null if given works on that array and returns result, else works on internal data-array
939 939
 	 * @return array
940 940
 	 */
941
-	function db2data($data=null)
941
+	function db2data($data = null)
942 942
 	{
943 943
 		if (($intern = !is_array($data)))
944 944
 		{
945
-			$data =& $this->data;
945
+			$data = & $this->data;
946 946
 		}
947 947
 		// get pm_id from links and ts_project: either project matching ts_project or first found project
948 948
 		if (!isset($data['pm_id']) && $data['ts_id'])
949 949
 		{
950 950
 			$first_pm_id = null;
951
-			foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
951
+			foreach (Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
952 952
 			{
953 953
 				if (!isset($first_pm_id)) $first_pm_id = $pm_id;
954 954
 				if ($data['ts_project'] == Link::title('projectmanager', $pm_id))
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 			$data['ts_project_blur'] = $data['ts_project'];
967 967
 			$data['ts_project'] = '';
968 968
 		}
969
-		return parent::db2data($intern ? null : $data);	// important to use null, if $intern!
969
+		return parent::db2data($intern ? null : $data); // important to use null, if $intern!
970 970
 	}
971 971
 
972 972
 	/**
@@ -978,17 +978,17 @@  discard block
 block discarded – undo
978 978
 	 * @param array $data =null if given works on that array and returns result, else works on internal data-array
979 979
 	 * @return array
980 980
 	 */
981
-	function data2db($data=null)
981
+	function data2db($data = null)
982 982
 	{
983 983
 		if (($intern = !is_array($data)))
984 984
 		{
985
-			$data =& $this->data;
985
+			$data = & $this->data;
986 986
 		}
987 987
 		// allways store ts_project to be able to search for it, even if no custom project is set
988 988
 		if (empty($data['ts_project']) && !is_null($data['ts_project']))
989 989
 		{
990 990
 			$data['ts_project'] = $data['pm_id'] ? Link::title('projectmanager', $data['pm_id']) : '';
991 991
 		}
992
-		return parent::data2db($intern ? null : $data);	// important to use null, if $intern!
992
+		return parent::data2db($intern ? null : $data); // important to use null, if $intern!
993 993
 	}
994 994
 }
Please login to merge, or discard this patch.
Braces   +82 added lines, -21 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
 		{
@@ -286,7 +299,10 @@  discard block
 block discarded – undo
286 299
 	 */
287 300
 	function grant_list($required=Acl::READ, $hide_deactive=null)
288 301
 	{
289
-		if (!isset($hide_deactive)) $hide_deactive = $required == Acl::EDIT;
302
+		if (!isset($hide_deactive))
303
+		{
304
+			$hide_deactive = $required == Acl::EDIT;
305
+		}
290 306
 
291 307
 		$result = array();
292 308
 		foreach($this->grants as $uid => $grant)
@@ -322,9 +338,16 @@  discard block
 block discarded – undo
322 338
 			$data = $this->read($data,true);
323 339
 			$this->data = $save_data;
324 340
 
325
-			if (!$data) return null; 	// entry not found
341
+			if (!$data)
342
+			{
343
+				return null;
344
+			}
345
+			// entry not found
346
+		}
347
+		if (!$user)
348
+		{
349
+			$user = $this->user;
326 350
 		}
327
-		if (!$user) $user = $this->user;
328 351
 		if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status'])
329 352
 		{
330 353
 			if ($this->status_labels_config[$data['ts_status']]['admin'])
@@ -357,9 +380,16 @@  discard block
 block discarded – undo
357 380
 			$data = $this->read($data,true);
358 381
 			$this->data = $save_data;
359 382
 
360
-			if (!$data) return null; 	// entry not found
383
+			if (!$data)
384
+			{
385
+				return null;
386
+			}
387
+			// entry not found
388
+		}
389
+		if (!$user)
390
+		{
391
+			$user = $this->user;
361 392
 		}
362
-		if (!$user) $user = $this->user;
363 393
 		if ($user == $this->user)
364 394
 		{
365 395
 			$grants = $this->grants;
@@ -433,7 +463,10 @@  discard block
 block discarded – undo
433 463
 		}
434 464
 		else
435 465
 		{
436
-			if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
466
+			if (!is_array($filter['ts_owner']))
467
+			{
468
+				$filter['ts_owner'] = array($filter['ts_owner']);
469
+			}
437 470
 
438 471
 			foreach($filter['ts_owner'] as $key => $owner)
439 472
 			{
@@ -488,7 +521,10 @@  discard block
 block discarded – undo
488 521
 		$this->summary = $this->summary[0];
489 522
 		$this->summary['max_modified'] = Api\DateTime::server2user($this->summary['max_modified']);
490 523
 
491
-		if ($only_summary) return $this->summary;
524
+		if ($only_summary)
525
+		{
526
+			return $this->summary;
527
+		}
492 528
 
493 529
 		if ($this->show_sums && strpos($order_by,'ts_start') !== false && 	// sums only make sense if ordered by ts_start
494 530
 			$this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start')))
@@ -564,7 +600,10 @@  discard block
 block discarded – undo
564 600
 	 */
565 601
 	function save($keys=null,$touch_modified=true,$ignore_acl=false)
566 602
 	{
567
-		if ($keys) $this->data_merge($keys);
603
+		if ($keys)
604
+		{
605
+			$this->data_merge($keys);
606
+		}
568 607
 
569 608
 		if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(Acl::EDIT))
570 609
 		{
@@ -586,10 +625,13 @@  discard block
 block discarded – undo
586 625
 			$old =& $this->data;
587 626
 			$this->data =& $new;
588 627
 			$changed = array();
589
-			if (isset($old)) foreach($old as $name => $value)
628
+			if (isset($old))
629
+			{
630
+				foreach($old as $name => $value)
590 631
 			{
591 632
 				if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name;
592 633
 			}
634
+			}
593 635
 		}
594 636
 		if (isset($old) && !$changed)
595 637
 		{
@@ -706,7 +748,10 @@  discard block
 block discarded – undo
706 748
 		}
707 749
 
708 750
 		$this->data['ts_status'] = $status;
709
-		if ($this->save($ts_id)!=0) $ret = false;
751
+		if ($this->save($ts_id)!=0)
752
+		{
753
+			$ret = false;
754
+		}
710 755
 
711 756
 		return $ret;
712 757
 	}
@@ -750,10 +795,13 @@  discard block
 block discarded – undo
750 795
 			return $entry;
751 796
 		}
752 797
 		$format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
753
-		if (date('H:i',$entry['ts_start']) != '00:00')	// dont show 00:00 time, as it means date only
798
+		if (date('H:i',$entry['ts_start']) != '00:00')
799
+		{
800
+			// dont show 00:00 time, as it means date only
754 801
 		{
755 802
 			$format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i');
756 803
 		}
804
+		}
757 805
 		return date($format,$entry['ts_start']).': '.$entry['ts_title'];
758 806
 	}
759 807
 
@@ -799,14 +847,18 @@  discard block
 block discarded – undo
799 847
 	{
800 848
 		$limit = false;
801 849
 		$need_count = false;
802
-		if($options['start'] || $options['num_rows']) {
850
+		if($options['start'] || $options['num_rows'])
851
+		{
803 852
 			$limit = array($options['start'], $options['num_rows']);
804 853
 			$need_count = true;
805 854
 		}
806 855
 		$result = array();
807 856
 		foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts )
808 857
 		{
809
-			if ($ts) $result[$ts['ts_id']] = $this->link_title($ts);
858
+			if ($ts)
859
+			{
860
+				$result[$ts['ts_id']] = $this->link_title($ts);
861
+			}
810 862
 		}
811 863
 		$options['total'] = $need_count ? $this->total : count($result);
812 864
 		return $result;
@@ -925,7 +977,10 @@  discard block
 block discarded – undo
925 977
 				//error_log(__METHOD__."() setting pm_id=$pm_id --> ".array2string($update));
926 978
 			}
927 979
 		}
928
-		if ($backup) $this->data = $backup;
980
+		if ($backup)
981
+		{
982
+			$this->data = $backup;
983
+		}
929 984
 	}
930 985
 
931 986
 
@@ -950,7 +1005,10 @@  discard block
 block discarded – undo
950 1005
 			$first_pm_id = null;
951 1006
 			foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id)
952 1007
 			{
953
-				if (!isset($first_pm_id)) $first_pm_id = $pm_id;
1008
+				if (!isset($first_pm_id))
1009
+				{
1010
+					$first_pm_id = $pm_id;
1011
+				}
954 1012
 				if ($data['ts_project'] == Link::title('projectmanager', $pm_id))
955 1013
 				{
956 1014
 					$data['pm_id'] = $pm_id;
@@ -959,7 +1017,10 @@  discard block
 block discarded – undo
959 1017
 					break;
960 1018
 				}
961 1019
 			}
962
-			if (!isset($data['pm_id']) && isset($first_pm_id)) $data['pm_id'] = $first_pm_id;
1020
+			if (!isset($data['pm_id']) && isset($first_pm_id))
1021
+			{
1022
+				$data['pm_id'] = $first_pm_id;
1023
+			}
963 1024
 		}
964 1025
 		elseif ($data['ts_id'] && $data['pm_id'] && Link::title('projectmanager', $data['pm_id']) == $data['ts_project'])
965 1026
 		{
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.
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.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,51 +29,51 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param egw_record $_definition
31 31
 	 */
32
-	public function export( $_stream, importexport_definition $_definition) {
32
+	public function export($_stream, importexport_definition $_definition) {
33 33
 		$options = $_definition->plugin_options;
34 34
 
35 35
 		$this->ui = new timesheet_ui();
36 36
 		$selection = array();
37 37
 
38
-		if($options['selection'] == 'search') {
38
+		if ($options['selection'] == 'search') {
39 39
 			$query = Api\Cache::getSession(TIMESHEET_APP, 'index');
40
-			$query['num_rows'] = -1;	// all records
41
-			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
42
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
43
-		} elseif($options['selection'] == 'all') {
40
+			$query['num_rows'] = -1; // all records
41
+			$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
42
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
43
+		} elseif ($options['selection'] == 'all') {
44 44
 			$query = array(
45 45
 				'num_rows' => -1,
46
-				'csv_export' => true,	// so get_rows method _can_ produce different content or not store state in the session
46
+				'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session
47 47
 			);
48
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
48
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
49 49
 		}
50
-		else if($options['selection'] == 'filter')
50
+		else if ($options['selection'] == 'filter')
51 51
 		{
52 52
 			$fields = importexport_helper_functions::get_filter_fields($_definition->application, $this);
53 53
 			$filter = $_definition->filter;
54 54
 			$query = array(
55 55
 				'num_rows' => -1,
56
-				'csv_export' => true,	// so get_rows method _can_ produce different content or not store state in the session
56
+				'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session
57 57
 				'col_filter' => array()
58 58
 			);
59 59
 
60 60
 			// Handle ranges
61
-			foreach($filter as $field => $value)
61
+			foreach ($filter as $field => $value)
62 62
 			{
63
-				if($field == 'cat_id')
63
+				if ($field == 'cat_id')
64 64
 				{
65 65
 					$query['cat_id'] = $value;
66 66
 					continue;
67 67
 				}
68 68
 				$query['col_filter'][$field] = $value;
69
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
69
+				if (!is_array($value) || (!$value['from'] && !$value['to'])) continue;
70 70
 
71 71
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
72
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
73
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
72
+				if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from'];
73
+				if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to'];
74 74
 				unset($query['col_filter'][$field]);
75 75
 			}
76
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
76
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
77 77
 		}
78 78
 
79 79
 
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 		// support other selectors atm.
86 86
 		foreach ($selection as $identifier) {
87 87
 			$record = new timesheet_egw_record($identifier);
88
-			if($options['convert']) {
88
+			if ($options['convert']) {
89 89
 				importexport_export_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $this->selects);
90 90
 			} else {
91 91
 				// Implode arrays, so they don't say 'Array'
92
-				foreach($record->get_record_array() as $key => $value) {
93
-					if(is_array($value)) $record->$key = implode(',', $value);
92
+				foreach ($record->get_record_array() as $key => $value) {
93
+					if (is_array($value)) $record->$key = implode(',', $value);
94 94
 				}
95 95
  			}
96 96
 			$export_object->export_record($record);
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 	public function get_selects()
154 154
 	{
155 155
 		$this->selects = array(
156
-			'ts_status'	=>	$this->ui->status_labels+array(lang('No status'))
156
+			'ts_status'	=>	$this->ui->status_labels + array(lang('No status'))
157 157
 		);
158
-		foreach($this->selects['ts_status'] as &$status) {
159
-			$status = str_replace('&nbsp;','',$status); // Remove &nbsp;
158
+		foreach ($this->selects['ts_status'] as &$status) {
159
+			$status = str_replace('&nbsp;', '', $status); // Remove &nbsp;
160 160
 		}
161 161
 
162 162
 	}
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function get_filter_fields(Array &$filters)
167 167
 	{
168
-		foreach($filters as $field_name => &$settings)
168
+		foreach ($filters as $field_name => &$settings)
169 169
 		{
170
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
170
+			if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
171 171
 		}
172 172
 	}
173 173
 
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_favorite_portlet.inc.php 4 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -86,8 +86,6 @@
 block discarded – undo
86 86
 	 * Here we need to handle any incoming data.  Setup is done in the constructor,
87 87
 	 * output is handled by parent.
88 88
 	 *
89
-	 * @param type $id
90
-	 * @param Etemplate $etemplate
91 89
 	 */
92 90
 	public static function process($content = array())
93 91
 	{
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		$context['appname'] = 'timesheet';
29 29
 
30 30
 		// Let parent handle the basic stuff
31
-		parent::__construct($context,$need_reload);
31
+		parent::__construct($context, $need_reload);
32 32
 
33 33
 		$this->context['template'] = 'timesheet.index.rows';
34 34
 		$this->nm_settings += array(
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
 		);
43 43
 	}
44 44
 
45
-	public function exec($id = null, Etemplate &$etemplate = null)
45
+	public function exec($id = null, Etemplate&$etemplate = null)
46 46
 	{
47 47
 		$ui = new timesheet_ui();
48 48
 
49 49
 		$date_filters = array('All');
50
-		foreach(array_keys($ui->date_filters) as $name)
50
+		foreach (array_keys($ui->date_filters) as $name)
51 51
 		{
52 52
 			$date_filters[$name] = $name;
53 53
 		}
54 54
 		$date_filters['custom'] = 'custom';
55 55
 		$this->context['sel_options']['filter'] = $date_filters;
56
-		$this->context['sel_options']['filter2'] = array('No details','Details');
56
+		$this->context['sel_options']['filter2'] = array('No details', 'Details');
57 57
 		$read_grants = $ui->grant_list(Acl::READ);
58 58
 		$this->context['sel_options'] += array(
59 59
 			'ts_owner'   => $read_grants,
60 60
 			'pm_id'      => array(lang('No project')),
61 61
 			'cat_id'     => array(array('value' => '', 'label' => lang('all')), array('value' => 0, 'label'=>lang('None'))),
62
-			'ts_status'  => $ui->status_labels+array(lang('No status')),
62
+			'ts_status'  => $ui->status_labels + array(lang('No status')),
63 63
 		);
64 64
 		$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings);
65 65
 
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
 			if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
113 113
 			{
114 114
 				$msg = lang('You need to select some entries first!');
115
-				Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
115
+				Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
116 116
 			}
117 117
 			else
118 118
 			{
119 119
 				$success = $failed = $action_msg = null;
120
-				if ($ui->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
121
-					$success,$failed,$action_msg,'index',$msg))
120
+				if ($ui->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
121
+					$success, $failed, $action_msg, 'index', $msg))
122 122
 				{
123
-					$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
123
+					$msg .= lang('%1 timesheets(s) %2', $success, $action_msg);
124 124
 
125
-					Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
126
-					foreach($content['nm']['selected'] as &$id)
125
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'success'));
126
+					foreach ($content['nm']['selected'] as &$id)
127 127
 					{
128 128
 						$id = 'timesheet::'.$id;
129 129
 					}
130 130
 					// Directly request an update - this will get timesheet tab too
131
-					Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
131
+					Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($content['nm']['selected']));
132 132
 				}
133
-				elseif(empty($msg))
133
+				elseif (empty($msg))
134 134
 				{
135
-					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
135
+					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
136 136
 				}
137
-				Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
137
+				Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
138 138
 			}
139 139
 		}
140 140
 	}
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,9 +76,12 @@
 block discarded – undo
76 76
 
77 77
 		// This is just copy+pasted from resources_ui line 816, but we don't want
78 78
 		// the etemplate exec to fire again.
79
-		if (is_array($content) && isset($content['nm']['rows']['document']))  // handle insert in default document button like an action
79
+		if (is_array($content) && isset($content['nm']['rows']['document']))
80
+		{
81
+			// handle insert in default document button like an action
80 82
 		{
81 83
 			list($id) = @each($content['nm']['rows']['document']);
84
+		}
82 85
 			$content['nm']['action'] = 'document';
83 86
 			$content['nm']['selected'] = array($id);
84 87
 		}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 	 *
50 50
 	 * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
51 51
 	 */
52
-	public function __construct(Array &$context = array(), &$need_reload = false)
52
+	public function __construct(array &$context = array(), &$need_reload = false)
53 53
 	{
54 54
 		if (false) parent::__construct();
55 55
 
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   +25 added lines, -25 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,8 +97,8 @@  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
-	*/
100
+	 * List of actions, and how many times that action was taken
101
+	 */
102 102
 	protected $results = array();
103 103
 
104 104
 	/**
@@ -526,39 +526,39 @@  discard block
 block discarded – undo
526 526
 	}
527 527
 
528 528
 	/**
529
-	* Returns warnings that were encountered during importing
530
-	* Maximum of one warning message per record, but you can append if you need to
531
-	*
532
-	* @return Array (
533
-	*       record_# => warning message
534
-	*       )
535
-	*/
529
+	 * Returns warnings that were encountered during importing
530
+	 * Maximum of one warning message per record, but you can append if you need to
531
+	 *
532
+	 * @return Array (
533
+	 *       record_# => warning message
534
+	 *       )
535
+	 */
536 536
 	public function get_warnings()
537 537
 	{
538 538
 		return $this->warnings;
539 539
 	}
540 540
 
541 541
 	/**
542
-	* Returns errors that were encountered during importing
543
-	* Maximum of one error message per record, but you can append if you need to
544
-	*
545
-	* @return Array (
546
-	*       record_# => error message
547
-	*       )
548
-	*/
542
+	 * Returns errors that were encountered during importing
543
+	 * Maximum of one error message per record, but you can append if you need to
544
+	 *
545
+	 * @return Array (
546
+	 *       record_# => error message
547
+	 *       )
548
+	 */
549 549
 	public function get_errors()
550 550
 	{
551 551
 		return $this->errors;
552 552
 	}
553 553
 
554 554
 	/**
555
-	* Returns a list of actions taken, and the number of records for that action.
556
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
557
-	*
558
-	* @return Array (
559
-	*       action => record count
560
-	* )
561
-	*/
555
+	 * Returns a list of actions taken, and the number of records for that action.
556
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
557
+	 *
558
+	 * @return Array (
559
+	 *       action => record count
560
+	 * )
561
+	 */
562 562
 	public function get_results()
563 563
 	{
564 564
 			return $this->results;
Please login to merge, or discard this patch.
Braces   +53 added lines, -14 removed lines patch added patch discarded remove patch
@@ -137,9 +137,12 @@  discard block
 block discarded – undo
137 137
 		$import_csv->conversion_class = $this;
138 138
 
139 139
 		//check if file has a header lines
140
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
140
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
141
+		{
141 142
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
142
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
143
+		}
144
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
145
+		{
143 146
 			// First method is preferred
144 147
 			$import_csv->skip_records(1);
145 148
 		}
@@ -163,7 +166,10 @@  discard block
 block discarded – undo
163 166
 		foreach($lookups['ts_status'] as $id => &$label)
164 167
 		{
165 168
 			$label = str_replace('&nbsp;', '',trim($label));
166
-			if($label == '') unset($lookups['ts_status'][$id]);
169
+			if($label == '')
170
+			{
171
+				unset($lookups['ts_status'][$id]);
172
+			}
167 173
 		}
168 174
 
169 175
 		// Start counting successes
@@ -178,10 +184,16 @@  discard block
 block discarded – undo
178 184
 			$success = false;
179 185
 
180 186
 			// don't import empty records
181
-			if( count( array_unique( $record ) ) < 2 ) continue;
187
+			if( count( array_unique( $record ) ) < 2 )
188
+			{
189
+				continue;
190
+			}
182 191
 
183 192
 			$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']);
184
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
193
+			if($result)
194
+			{
195
+				$this->warnings[$import_csv->get_current_position()] = $result;
196
+			}
185 197
 
186 198
 			// Automatically handle text Api\Categories without explicit Api\Translation
187 199
 			foreach(array('ts_status','cat_id') as $field)
@@ -329,8 +341,14 @@  discard block
 block discarded – undo
329 341
 									$record['ts_id'] = $result['ts_id'];
330 342
 									if ( $_definition->plugin_options['update_cats'] == 'add' )
331 343
 									{
332
-										if ( !is_array( $result['cat_id'] ) ) $result['cat_id'] = explode( ',', $result['cat_id'] );
333
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
344
+										if ( !is_array( $result['cat_id'] ) )
345
+										{
346
+											$result['cat_id'] = explode( ',', $result['cat_id'] );
347
+										}
348
+										if ( !is_array( $record['cat_id'] ) )
349
+										{
350
+											$record['cat_id'] = explode( ',', $record['cat_id'] );
351
+										}
334 352
 										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $result['cat_id'] ) ) );
335 353
 									}
336 354
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
@@ -348,7 +366,10 @@  discard block
 block discarded – undo
348 366
 							die('condition / action not supported!!!');
349 367
 							break;
350 368
 					}
351
-					if ($action['last']) break;
369
+					if ($action['last'])
370
+					{
371
+						break;
372
+					}
352 373
 				}
353 374
 			}
354 375
 			else
@@ -356,7 +377,10 @@  discard block
 block discarded – undo
356 377
 				// unconditional insert
357 378
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
358 379
 			}
359
-			if($success) $count++;
380
+			if($success)
381
+			{
382
+				$count++;
383
+			}
360 384
 		}
361 385
 		return $count;
362 386
 	}
@@ -448,7 +472,10 @@  discard block
 block discarded – undo
448 472
 		$_link_id = false;
449 473
 		foreach(self::$special_fields as $field => $desc)
450 474
 		{
451
-			if(!$_data[$field]) continue;
475
+			if(!$_data[$field])
476
+			{
477
+				continue;
478
+			}
452 479
 
453 480
 			// Links
454 481
 			if(strpos($field, 'link') === 0)
@@ -577,28 +604,40 @@  discard block
 block discarded – undo
577 604
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
578 605
 		}
579 606
 		$n_family = trim($n_family);
580
-		if(!is_null($n_given)) $n_given = trim($n_given);
607
+		if(!is_null($n_given))
608
+		{
609
+			$n_given = trim($n_given);
610
+		}
581 611
 		if (!is_object($contacts))
582 612
 		{
583 613
 			$contacts =& CreateObject('phpgwapi.contacts');
584 614
 		}
585
-		if (!is_null($org_name))        // org_name given?
615
+		if (!is_null($org_name))
616
+		{
617
+			// org_name given?
586 618
 		{
587 619
 			$org_name = trim($org_name);
620
+		}
588 621
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
589 622
 			if (!count($addrs))
590 623
 			{
591 624
 				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
592 625
 			}
593 626
 		}
594
-		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
627
+		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))
628
+		{
629
+			// first name given and no result so far
595 630
 		{
596 631
 			$addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given));
597 632
 		}
598
-		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
633
+		}
634
+		if (is_null($n_given) && is_null($org_name))
635
+		{
636
+			// just one name given, check against fn (= full name)
599 637
 		{
600 638
 			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
601 639
 		}
640
+		}
602 641
 		if (count($addrs))
603 642
 		{
604 643
 			return $addrs[0]['id'];
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 class timesheet_import_csv implements importexport_iface_import_plugin
21 21
 {
22 22
 	private static $plugin_options = array(
23
-		'fieldsep', 		// char
24
-		'charset', 			// string
25
-		'update_cats', 			// string {override|add} overides record
23
+		'fieldsep', // char
24
+		'charset', // string
25
+		'update_cats', // string {override|add} overides record
26 26
 								// with cat(s) from csv OR add the cat from
27 27
 								// csv file to exeisting cat(s) of record
28 28
 		'num_header_lines', // int number of header lines
29 29
 		'field_conversion', // array( $csv_col_num => conversion)
30
-		'field_mapping',	// array( $csv_col_num => adb_filed)
31
-		'conditions',		/* => array containing condition arrays:
30
+		'field_mapping', // array( $csv_col_num => adb_filed)
31
+		'conditions', /* => array containing condition arrays:
32 32
 				'type' => exists, // exists
33 33
 				'string' => '#kundennummer',
34 34
 				'true' => array(
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * actions wich could be done to data entries
54 54
 	 */
55
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
55
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
56 56
 
57 57
 	/**
58 58
 	 * conditions for actions
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	protected static $conditions = array( 'exists' );
62
+	protected static $conditions = array('exists');
63 63
 
64 64
 	/**
65 65
 	 * @var definition
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 	 * @param string $_charset
108 108
 	 * @param definition $_definition
109 109
 	 */
110
-	public function import( $_stream, importexport_definition $_definition )
110
+	public function import($_stream, importexport_definition $_definition)
111 111
 	{
112
-		$import_csv = new importexport_import_csv( $_stream, array(
112
+		$import_csv = new importexport_import_csv($_stream, array(
113 113
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
114 114
 			'charset' => $_definition->plugin_options['charset'],
115 115
 		));
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
120 120
 
121 121
 		// dry run?
122
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
122
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
123 123
 
124 124
 		// fetch the bo
125 125
 		$this->bo = new timesheet_bo();
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 		$import_csv->conversion_class = $this;
138 138
 
139 139
 		//check if file has a header lines
140
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
140
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
141 141
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
142
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
142
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
143 143
 			// First method is preferred
144 144
 			$import_csv->skip_records(1);
145 145
 		}
146 146
 
147 147
 		// set Owner
148 148
 		$plugin_options = $_definition->plugin_options;
149
-		$plugin_options['record_owner'] = isset( $_definition->plugin_options['record_owner'] ) ?
149
+		$plugin_options['record_owner'] = isset($_definition->plugin_options['record_owner']) ?
150 150
 			$_definition->plugin_options['record_owner'] : $this->user;
151 151
 		$_definition->plugin_options = $plugin_options;
152 152
 
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 		);
161 161
 
162 162
 		// Status need leading spaces removed
163
-		foreach($lookups['ts_status'] as $id => &$label)
163
+		foreach ($lookups['ts_status'] as $id => &$label)
164 164
 		{
165
-			$label = str_replace('&nbsp;', '',trim($label));
166
-			if($label == '') unset($lookups['ts_status'][$id]);
165
+			$label = str_replace('&nbsp;', '', trim($label));
166
+			if ($label == '') unset($lookups['ts_status'][$id]);
167 167
 		}
168 168
 
169 169
 		// Start counting successes
@@ -173,27 +173,27 @@  discard block
 block discarded – undo
173 173
 		// Failures
174 174
 		$this->errors = array();
175 175
 
176
-		while ( $record = $import_csv->get_record() )
176
+		while ($record = $import_csv->get_record())
177 177
 		{
178 178
 			$success = false;
179 179
 
180 180
 			// don't import empty records
181
-			if( count( array_unique( $record ) ) < 2 ) continue;
181
+			if (count(array_unique($record)) < 2) continue;
182 182
 
183 183
 			$result = importexport_import_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $lookups, $_definition->plugin_options['convert']);
184
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
184
+			if ($result) $this->warnings[$import_csv->get_current_position()] = $result;
185 185
 
186 186
 			// Automatically handle text Api\Categories without explicit Api\Translation
187
-			foreach(array('ts_status','cat_id') as $field)
187
+			foreach (array('ts_status', 'cat_id') as $field)
188 188
 			{
189
-				if(!is_numeric($record[$field]))
189
+				if (!is_numeric($record[$field]))
190 190
 				{
191
-					$translate_key = 'translate'.(substr($field,0,2) == 'ts' ? substr($field,2) : '_cat_id');
192
-					if(!is_null($lookups[$field]) && ($key = array_search($record[$field], $lookups[$field])))
191
+					$translate_key = 'translate'.(substr($field, 0, 2) == 'ts' ? substr($field, 2) : '_cat_id');
192
+					if (!is_null($lookups[$field]) && ($key = array_search($record[$field], $lookups[$field])))
193 193
 					{
194 194
 						$record[$field] = $key;
195 195
 					}
196
-					elseif(array_key_exists($translate_key, $_definition->plugin_options))
196
+					elseif (array_key_exists($translate_key, $_definition->plugin_options))
197 197
 					{
198 198
 						$t_field = $_definition->plugin_options[$translate_key];
199 199
 						switch ($t_field)
@@ -206,35 +206,35 @@  discard block
 block discarded – undo
206 206
 							case '~skip~':
207 207
 								continue 2;
208 208
 							default:
209
-								if(strpos($t_field, 'add') === 0)
209
+								if (strpos($t_field, 'add') === 0)
210 210
 								{
211 211
 									// Check for a parent
212
-									list($name, $parent_name) = explode('~',$t_field);
213
-									if($parent_name)
212
+									list($name, $parent_name) = explode('~', $t_field);
213
+									if ($parent_name)
214 214
 									{
215 215
 										$parent = importexport_helper_functions::cat_name2id($parent_name);
216 216
 									}
217 217
 
218
-									if($field == 'cat_id')
218
+									if ($field == 'cat_id')
219 219
 									{
220 220
 										$record[$field] = importexport_helper_functions::cat_name2id($record[$field], $parent);
221 221
 									}
222 222
 									elseif ($field == 'ts_status')
223 223
 									{
224 224
 										end($this->bo->status_labels);
225
-										$id = key($this->bo->status_labels)+1;
225
+										$id = key($this->bo->status_labels) + 1;
226 226
 										$this->bo->status_labels[$id] = $record[$field];
227 227
 										$this->bo->status_labels_config[$id] = array(
228 228
 											'name'   => $record[$field],
229 229
 											'parent' => $parent,
230 230
 											'admin'  => false
231 231
 										);
232
-										Api\Config::save_value('status_labels',$this->bo->status_labels_config,TIMESHEET_APP);
232
+										Api\Config::save_value('status_labels', $this->bo->status_labels_config, TIMESHEET_APP);
233 233
 										$lookups[$field][$id] = $name;
234 234
 										$record[$field] = $id;
235 235
 									}
236 236
 								}
237
-								elseif(!is_null($lookups[$field]) && ($key = array_search($t_field, $lookups[$field])))
237
+								elseif (!is_null($lookups[$field]) && ($key = array_search($t_field, $lookups[$field])))
238 238
 								{
239 239
 									$record[$field] = $key;
240 240
 								}
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
 			}
250 250
 
251 251
 			// Set creator, unless it's supposed to come from CSV file
252
-			if($_definition->plugin_options['owner_from_csv'] && $record['ts_owner'])
252
+			if ($_definition->plugin_options['owner_from_csv'] && $record['ts_owner'])
253 253
 			{
254
-				if(!is_numeric($record['ts_owner']))
254
+				if (!is_numeric($record['ts_owner']))
255 255
 				{
256 256
 					// Automatically handle text owner without explicit Api\Translation
257 257
 					$new_owner = importexport_helper_functions::account_name2id($record['ts_owner']);
258
-					if($new_owner == '')
258
+					if ($new_owner == '')
259 259
 					{
260 260
 						$this->errors[$import_csv->get_current_position()] = lang(
261 261
 							'Unable to convert "%1" to account ID.  Using plugin setting (%2) for %3.',
@@ -277,13 +277,13 @@  discard block
 block discarded – undo
277 277
 			}
278 278
 
279 279
 			// Check account IDs
280
-			foreach(array('ts_modifier') as $field)
280
+			foreach (array('ts_modifier') as $field)
281 281
 			{
282
-				if($record[$field] && !is_numeric($record[$field]))
282
+				if ($record[$field] && !is_numeric($record[$field]))
283 283
 				{
284 284
 					// Try an automatic conversion
285 285
 					$account_id = importexport_helper_functions::account_name2id($record[$field]);
286
-					if($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field]))
286
+					if ($account_id && strtoupper(Api\Accounts::username($account_id)) == strtoupper($record[$field]))
287 287
 					{
288 288
 						$record[$field] = $account_id;
289 289
 					}
@@ -302,49 +302,49 @@  discard block
 block discarded – undo
302 302
 			// Special values
303 303
 			if ($record['addressbook'] && !is_numeric($record['addressbook']))
304 304
 			{
305
-				list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
306
-				$record['addressbook'] = self::addr_id($lastname,$firstname,$org_name);
305
+				list($lastname, $firstname, $org_name) = explode(',', $record['addressbook']);
306
+				$record['addressbook'] = self::addr_id($lastname, $firstname, $org_name);
307 307
 			}
308 308
 			if ($record['pm_id'] && !is_numeric($record['pm_id']))
309 309
 			{
310
-				$pms = Link::query('projectmanager',$record['pm_id']);
310
+				$pms = Link::query('projectmanager', $record['pm_id']);
311 311
 				$record['pm_id'] = key($pms);
312 312
 			}
313 313
 
314
-			if ( $_definition->plugin_options['conditions'] )
314
+			if ($_definition->plugin_options['conditions'])
315 315
 			{
316
-				foreach ( $_definition->plugin_options['conditions'] as $condition )
316
+				foreach ($_definition->plugin_options['conditions'] as $condition)
317 317
 				{
318 318
 					$results = array();
319
-					switch ( $condition['type'] )
319
+					switch ($condition['type'])
320 320
 					{
321 321
 						// exists
322 322
 						case 'exists' :
323
-							if($record[$condition['string']])
323
+							if ($record[$condition['string']])
324 324
 							{
325 325
 								$results = $this->bo->search(array($condition['string'] => $record[$condition['string']]));
326 326
 							}
327 327
 
328
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1 )
328
+							if (is_array($results) && count(array_keys($results)) >= 1)
329 329
 							{
330 330
 								// apply action to all records matching this exists condition
331 331
 								$action = $condition['true'];
332
-								foreach ( (array)$results as $result )
332
+								foreach ((array)$results as $result)
333 333
 								{
334 334
 									$record['ts_id'] = $result['ts_id'];
335
-									if ( $_definition->plugin_options['update_cats'] == 'add' )
335
+									if ($_definition->plugin_options['update_cats'] == 'add')
336 336
 									{
337
-										if ( !is_array( $result['cat_id'] ) ) $result['cat_id'] = explode( ',', $result['cat_id'] );
338
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
339
-										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $result['cat_id'] ) ) );
337
+										if (!is_array($result['cat_id'])) $result['cat_id'] = explode(',', $result['cat_id']);
338
+										if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
339
+										$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $result['cat_id'])));
340 340
 									}
341
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
341
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
342 342
 								}
343 343
 							}
344 344
 							else
345 345
 							{
346 346
 								$action = $condition['false'];
347
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
347
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
348 348
 							}
349 349
 							break;
350 350
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 			else
360 360
 			{
361 361
 				// unconditional insert
362
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
362
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
363 363
 			}
364
-			if($success) $count++;
364
+			if ($success) $count++;
365 365
 		}
366 366
 		return $count;
367 367
 	}
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @param array $_data tracker data for the action
374 374
 	 * @return bool success or not
375 375
 	 */
376
-	private function action ( $_action, $_data, $record_num = 0 )
376
+	private function action($_action, $_data, $record_num = 0)
377 377
 	{
378 378
 		$result = true;
379 379
 		switch ($_action)
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 				$old_record = new timesheet_egw_record($_data['ts_id']);
386 386
 				$old = $old_record->get_record_array();
387 387
 
388
-				if(!$this->definition->plugin_options['change_owner'])
388
+				if (!$this->definition->plugin_options['change_owner'])
389 389
 				{
390 390
 					// Don't change creator of an existing ticket
391 391
 					unset($_data['ts_owner']);
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 				// Merge to deal with fields not in import record
395 395
 				$_data = array_merge($old, $_data);
396 396
 				$changed = $this->tracking->changed_fields($_data, $old);
397
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
397
+				if (count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
398 398
 				{
399 399
 					break;
400 400
 				}
@@ -402,12 +402,12 @@  discard block
 block discarded – undo
402 402
 				// Clear old link, if different
403 403
 				if ($_data['ts_id'] && array_key_exists('pm_id', $_data) && $_data['pm_id'] != $old['pm_id'])
404 404
 				{
405
-					Link::unlink2(0,TIMESHEET_APP,$_data['ts_id'],0,'projectmanager',$old['pm_id']);
405
+					Link::unlink2(0, TIMESHEET_APP, $_data['ts_id'], 0, 'projectmanager', $old['pm_id']);
406 406
 				}
407 407
 
408 408
 				// Fall through
409 409
 			case 'insert' :
410
-				if ( $this->dry_run )
410
+				if ($this->dry_run)
411 411
 				{
412 412
 					//print_r($_data);
413 413
 					$this->results[$_action]++;
@@ -415,24 +415,24 @@  discard block
 block discarded – undo
415 415
 				}
416 416
 				else
417 417
 				{
418
-					$result = $this->bo->save( $_data);
418
+					$result = $this->bo->save($_data);
419 419
 					$_data['ts_id'] = $this->bo->data['ts_id'];
420 420
 
421 421
 					// Set projectmanager link
422 422
 					if ($_data['pm_id'])
423 423
 					{
424
-						Link::link(TIMESHEET_APP,$_data['ts_id'],'projectmanager',$_data['pm_id']);
424
+						Link::link(TIMESHEET_APP, $_data['ts_id'], 'projectmanager', $_data['pm_id']);
425 425
 						
426 426
 						// notify the link-class about the update, as other apps may be subscribed to it
427
-						Link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data);
427
+						Link::notify_update(TIMESHEET_APP, $this->data['ts_id'], $this->data);
428 428
 					}
429 429
 
430
-					if($result)
430
+					if ($result)
431 431
 					{
432 432
 						$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
433 433
 							$GLOBALS['egw']->accounts->id2name($_data['owner']),
434 434
 							lang($_action)
435
-						) . ' ' . $result;
435
+						).' '.$result;
436 436
 					}
437 437
 					else
438 438
 					{
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
 		}
447 447
 
448 448
 		// Process some additional fields
449
-		if(!is_numeric($result))
449
+		if (!is_numeric($result))
450 450
 		{
451 451
 			return $result;
452 452
 		}
453 453
 		$_link_id = false;
454
-		foreach(self::$special_fields as $field => $desc)
454
+		foreach (self::$special_fields as $field => $desc)
455 455
 		{
456
-			if(!$_data[$field]) continue;
456
+			if (!$_data[$field]) continue;
457 457
 
458 458
 			// Links
459
-			if(strpos($field, 'link') === 0)
459
+			if (strpos($field, 'link') === 0)
460 460
 			{
461 461
 				list($app, $app_id) = explode(':', $_data[$field]);
462 462
 			}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 			}
468 468
 			if ($app && $app_id)
469 469
 			{
470
-				$link_id = Link::link('timesheet',$_data['ts_id'],$app,$app_id);
470
+				$link_id = Link::link('timesheet', $_data['ts_id'], $app, $app_id);
471 471
 			}
472 472
 		}
473 473
 		return true;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	// end of iface_export_plugin
572 572
 
573 573
 	// Extra conversion functions - must be static
574
-	public static function addr_id( $n_family,$n_given=null,$org_name=null )
574
+	public static function addr_id($n_family, $n_given = null, $org_name = null)
575 575
 	{
576 576
 
577 577
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
@@ -582,18 +582,18 @@  discard block
 block discarded – undo
582 582
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
583 583
 		}
584 584
 		$n_family = trim($n_family);
585
-		if(!is_null($n_given)) $n_given = trim($n_given);
585
+		if (!is_null($n_given)) $n_given = trim($n_given);
586 586
 		if (!is_object($contacts))
587 587
 		{
588
-			$contacts =& CreateObject('phpgwapi.contacts');
588
+			$contacts = & CreateObject('phpgwapi.contacts');
589 589
 		}
590 590
 		if (!is_null($org_name))        // org_name given?
591 591
 		{
592 592
 			$org_name = trim($org_name);
593
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
593
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name");
594 594
 			if (!count($addrs))
595 595
 			{
596
-				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
596
+				$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name');
597 597
 			}
598 598
 		}
599 599
 		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		}
603 603
 		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
604 604
 		{
605
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
605
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn');
606 606
 		}
607 607
 		if (count($addrs))
608 608
 		{
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.
Braces   +177 added lines, -45 removed lines patch added patch discarded remove patch
@@ -63,7 +63,10 @@  discard block
 block discarded – undo
63 63
 		$etpl = new Etemplate('timesheet.edit');
64 64
 		if (!is_array($content))
65 65
 		{
66
-			if ($_GET['msg']) $msg = strip_tags($_GET['msg']);
66
+			if ($_GET['msg'])
67
+			{
68
+				$msg = strip_tags($_GET['msg']);
69
+			}
67 70
 
68 71
 			if ($view || (int)$_GET['ts_id'])
69 72
 			{
@@ -116,23 +119,32 @@  discard block
 block discarded – undo
116 119
 				$content['ts_description'] = $content['ts_description_short'];
117 120
 			}
118 121
 			// we only need 2 out of 3 values from start-, end-time or duration (the date in ts_start is always required!)
119
-			if (isset($content['start_time']))		// start-time specified
122
+			if (isset($content['start_time']))
123
+			{
124
+				// start-time specified
120 125
 			{
121 126
 				//$content['ts_start'] += $content['start_time'];
122 127
 				$start = new Api\DateTime($content['ts_start']);
128
+			}
123 129
 				$start_time = explode(':',$content['start_time']);
124 130
 				$start->setTime($start_time[0],$start_time[1]);
125 131
 				$content['ts_start'] = $start->format('ts');
126 132
 			}
127
-			if (isset($content['end_time']))		// end-time specified
133
+			if (isset($content['end_time']))
134
+			{
135
+				// end-time specified
128 136
 			{
129 137
 				$end = new Api\DateTime($content['ts_start']);
138
+			}
130 139
 				$end_time = explode(':',$content['end_time']);
131 140
 				$end->setTime($end_time[0],$end_time[1]);
132 141
 			}
133
-			if ($end && $start)	// start- & end-time --> calculate the duration
142
+			if ($end && $start)
143
+			{
144
+				// start- & end-time --> calculate the duration
134 145
 			{
135 146
 				$content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60;
147
+			}
136 148
 				// check if negative duration is caused by wrap over midnight
137 149
 				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60)
138 150
 				{
@@ -140,12 +152,18 @@  discard block
 block discarded – undo
140 152
 				}
141 153
 				//echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n";
142 154
 			}
143
-			elseif ($content['ts_duration'] && $end)	// no start, calculate from end and duration
155
+			elseif ($content['ts_duration'] && $end)
156
+			{
157
+				// no start, calculate from end and duration
144 158
 			{
145 159
 				$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
160
+			}
146 161
 				//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n";
147 162
 			}
148
-			if ($content['ts_duration'] > 0) unset($content['end_time']);
163
+			if ($content['ts_duration'] > 0)
164
+			{
165
+				unset($content['end_time']);
166
+			}
149 167
 			// now we only deal with start (date+time) and duration
150 168
 			list($button) = @each($content['button']);
151 169
 			$view = $content['view'];
@@ -159,7 +177,10 @@  discard block
 block discarded – undo
159 177
 			switch($button)
160 178
 			{
161 179
 				case 'edit':
162
-					if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false;
180
+					if ($this->check_acl(Acl::EDIT) && !$only_admin_edit)
181
+					{
182
+						$view = false;
183
+					}
163 184
 					break;
164 185
 
165 186
 				case 'undelete':
@@ -173,12 +194,15 @@  discard block
 block discarded – undo
173 194
 				case 'save':
174 195
 				case 'save_new':
175 196
 				case 'apply':
176
-					if ((!$this->data['ts_quantity'] || $this->ts_viewtype == 'short') && $this->data['ts_duration'])	// set the quantity (in h) from the duration (in min)
197
+					if ((!$this->data['ts_quantity'] || $this->ts_viewtype == 'short') && $this->data['ts_duration'])
198
+					{
199
+						// set the quantity (in h) from the duration (in min)
177 200
 					{
178 201
 						// We need to keep the actual value of ts_quantity when we are storing it, as it is used in price calculation
179 202
 						// and rounding it causes miscalculation on prices
180 203
 						$this->data['ts_quantity'] = $this->data['ts_duration'] / 60.0;
181 204
 					}
205
+					}
182 206
 					if (!$this->data['ts_quantity'])
183 207
 					{
184 208
 						$etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!'));
@@ -210,7 +234,11 @@  discard block
 block discarded – undo
210 234
 							unset($content['ts_project_blur']);
211 235
 						}
212 236
 					}
213
-					if ($etpl->validation_errors()) break;	// the user need to fix the error, before we can save the entry
237
+					if ($etpl->validation_errors())
238
+					{
239
+						break;
240
+					}
241
+					// the user need to fix the error, before we can save the entry
214 242
 
215 243
 					// account for changed project --> remove old one from links and add new one
216 244
 					if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id'])
@@ -254,14 +282,20 @@  discard block
 block discarded – undo
254 282
 						}
255 283
 					}
256 284
 					Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
257
-					if ($button == 'apply') break;
285
+					if ($button == 'apply')
286
+					{
287
+						break;
288
+					}
258 289
 					if ($button == 'save_new')
259 290
 					{
260 291
 						$msg .= ', '.lang('creating new entry');		// giving some feedback to the user
261 292
 
262
-						if (!is_array($content['link_to']['to_id']))	// set links again, so new entry gets the same links as the existing one
293
+						if (!is_array($content['link_to']['to_id']))
294
+						{
295
+							// set links again, so new entry gets the same links as the existing one
263 296
 						{
264 297
 							$content['link_to']['to_id'] = 0;
298
+						}
265 299
 							foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link)
266 300
 							{
267 301
 								Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
@@ -324,12 +358,15 @@  discard block
 block discarded – undo
324 358
 			foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
325 359
 			{
326 360
 				$link_id = $link_ids[$n];
327
-				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
361
+				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
362
+				{
363
+					// gard against XSS
328 364
 				{
329 365
 					switch ($link_app)
330 366
 					{
331 367
 						case 'projectmanager':
332 368
 							$links[] = $link_id;
369
+				}
333 370
 							// fall-through;
334 371
 						default:
335 372
 							if(!$n)
@@ -341,8 +378,14 @@  discard block
 block discarded – undo
341 378
 								{
342 379
 									foreach((array)$set['link_app'] as $i => $l_app)
343 380
 									{
344
-										if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
345
-										if ($l_app == 'projectmanager') $links[] = $l_id;
381
+										if (($l_id=$set['link_id'][$i]))
382
+										{
383
+											Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
384
+										}
385
+										if ($l_app == 'projectmanager')
386
+										{
387
+											$links[] = $l_id;
388
+										}
346 389
 									}
347 390
 									unset($set['link_app']);
348 391
 									unset($set['link_id']);
@@ -438,8 +481,16 @@  discard block
 block discarded – undo
438 481
 			$content['ts_viewtype'] = $readonlys['tabs']['notes'] = true;
439 482
 			$content['ts_description_short'] = $content['ts_description'];
440 483
 		}
441
-		if (!$this->customfields) $readonlys['tabs']['customfields'] = true;	// suppress tab if there are not customfields
442
-		if (!$this->data['ts_id']) $readonlys['tabs']['history']    = true;   //suppress history for the first loading without ID
484
+		if (!$this->customfields)
485
+		{
486
+			$readonlys['tabs']['customfields'] = true;
487
+		}
488
+		// suppress tab if there are not customfields
489
+		if (!$this->data['ts_id'])
490
+		{
491
+			$readonlys['tabs']['history']    = true;
492
+		}
493
+		//suppress history for the first loading without ID
443 494
 
444 495
 		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2);
445 496
 	}
@@ -452,7 +503,10 @@  discard block
 block discarded – undo
452 503
 	 */
453 504
 	function datetime2time($datetime)
454 505
 	{
455
-		if (!$datetime) return 0;
506
+		if (!$datetime)
507
+		{
508
+			return 0;
509
+		}
456 510
 
457 511
 		return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime));
458 512
 	}
@@ -497,7 +551,10 @@  discard block
 block discarded – undo
497 551
 			}
498 552
 			// show week-sums, if we are week-aligned (show full weeks)?
499 553
 			$week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'];
500
-			if (!$week_start_day) $week_start_day = 'Sunday';
554
+			if (!$week_start_day)
555
+			{
556
+				$week_start_day = 'Sunday';
557
+			}
501 558
 			switch($week_start_day)
502 559
 			{
503 560
 				case 'Sunday': $week_end_day = 'Saturday'; break;
@@ -518,7 +575,10 @@  discard block
 block discarded – undo
518 575
 			}
519 576
 		}
520 577
 		//echo "<p align=right>show_sums=".print_r($this->show_sums,true)."</p>\n";
521
-		if (!$id_only && !$query_in['csv_export']) Api\Cache::setSession(TIMESHEET_APP, 'index', $query_in);
578
+		if (!$id_only && !$query_in['csv_export'])
579
+		{
580
+			Api\Cache::setSession(TIMESHEET_APP, 'index', $query_in);
581
+		}
522 582
 
523 583
 		// Refresh actions (undelete needs this)
524 584
 		$query_in['actions'] = $this->get_actions($query_in);
@@ -526,8 +586,14 @@  discard block
 block discarded – undo
526 586
 		$query = $query_in;	// keep the original query
527 587
 		$query['enddate'] = $end_date;
528 588
 
529
-		if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
530
-		if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false;
589
+		if($this->ts_viewtype == 'short')
590
+		{
591
+			$query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
592
+		}
593
+		if ($query['no_status'])
594
+		{
595
+			$query_in['options-selectcols']['ts_status'] = false;
596
+		}
531 597
 
532 598
 		//_debug_array($query['col_filter']);
533 599
 		//echo "PM Integration:".$this->pm_integration.'<br>';
@@ -540,8 +606,14 @@  discard block
 block discarded – undo
540 606
 		{
541 607
 			//$query['col_filter']['ts_id'] = Link::get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet');
542 608
 			$query['col_filter']['ts_id'] = $this->get_ts_links($query['col_filter']['pm_id']);
543
-			if (empty($query['col_filter']['ts_id'])) $query['col_filter']['ts_id'] = -1;
544
-			if (!$query['col_filter']['ts_id']) $query['col_filter']['ts_id'] = 0;
609
+			if (empty($query['col_filter']['ts_id']))
610
+			{
611
+				$query['col_filter']['ts_id'] = -1;
612
+			}
613
+			if (!$query['col_filter']['ts_id'])
614
+			{
615
+				$query['col_filter']['ts_id'] = 0;
616
+			}
545 617
 		}
546 618
 		if ((string)$query['col_filter']['pm_id'] != '' && (string)$query['col_filter']['pm_id'] == '0')
547 619
 		{
@@ -605,10 +677,13 @@  discard block
 block discarded – undo
605 677
 			$cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']);
606 678
 			$query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id'];
607 679
 		}
608
-		elseif ((string)$query['cat_id'] == '0')	// no category
680
+		elseif ((string)$query['cat_id'] == '0')
681
+		{
682
+			// no category
609 683
 		{
610 684
 			$query['col_filter']['cat_id'] = null;
611 685
 		}
686
+		}
612 687
 		else	// all cats --> no filter
613 688
 		{
614 689
 			unset($query['col_filter']['cat_id']);
@@ -619,7 +694,10 @@  discard block
 block discarded – undo
619 694
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']);
620 695
 			#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
621 696
 			#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
622
-			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));
697
+			if ($query['col_filter']['ts_owner']<0)
698
+			{
699
+				$query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
700
+			}
623 701
 		}
624 702
 		else
625 703
 		{
@@ -632,10 +710,13 @@  discard block
 block discarded – undo
632 710
 			// generate a meaningful app-header / report title
633 711
 			if ($this->show_sums['month'])
634 712
 			{
635
-				if ((int)$start[1] == 1 && (int) $end[1] == 12)		// whole year(s)
713
+				if ((int)$start[1] == 1 && (int) $end[1] == 12)
714
+				{
715
+					// whole year(s)
636 716
 				{
637 717
 					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : '');
638 718
 				}
719
+				}
639 720
 				else
640 721
 				{
641 722
 					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0];
@@ -677,7 +758,10 @@  discard block
 block discarded – undo
677 758
 		$ids = array();
678 759
 		foreach($rows as &$row)
679 760
 		{
680
-			if ($row['ts_id'] > 0) $ids[] = $row['ts_id'];
761
+			if ($row['ts_id'] > 0)
762
+			{
763
+				$ids[] = $row['ts_id'];
764
+			}
681 765
 		}
682 766
 		if ($id_only)
683 767
 		{
@@ -707,12 +791,19 @@  discard block
 block discarded – undo
707 791
 		$have_cats = false;
708 792
 		foreach($rows as &$row)
709 793
 		{
710
-			if ($row['cat_id']) $have_cats = true;
794
+			if ($row['cat_id'])
795
+			{
796
+				$have_cats = true;
797
+			}
711 798
 
712 799
 			$row['class'] = 'row';
713
-			if ($row['ts_id'] <= 0)	// sums
800
+			if ($row['ts_id'] <= 0)
714 801
 			{
715
-				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;	// fix for DSL change
802
+				// sums
803
+			{
804
+				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;
805
+			}
806
+			// fix for DSL change
716 807
 
717 808
 				// Remove fake modified date, it breaks nextmatch checks
718 809
 				unset($row['ts_modified']);
@@ -740,7 +831,10 @@  discard block
 block discarded – undo
740 831
 						break;
741 832
 				}
742 833
 				$row['ts_start'] = $row['ts_unitprice'] = '';
743
-				if (!$this->quantity_sum) $row['ts_quantity'] = '';
834
+				if (!$this->quantity_sum)
835
+				{
836
+					$row['ts_quantity'] = '';
837
+				}
744 838
 				$row['class'] = 'th rowNoEdit rowNoDelete rowNoUndelete';
745 839
 				$row['titleClass'] = 'timesheet_titleSum';
746 840
 				continue;
@@ -782,13 +876,22 @@  discard block
 block discarded – undo
782 876
 				}
783 877
 			}
784 878
 
785
-			if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
879
+			if(!$row['titleClass'])
880
+			{
881
+				$row['titleClass'] = 'timesheet_titleDetails';
882
+			}
786 883
 
787 884
 		}
788 885
 		$rows['no_cat_id'] = (!$have_cats || $query['cat_id']);
789
-		if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint';
886
+		if ($query['col_filter']['ts_owner'])
887
+		{
888
+			$rows['ownerClass'] = 'noPrint';
889
+		}
790 890
 		$rows['no_owner_col'] = $query['no_owner_col'];
791
-		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner')) $rows['no_owner_col'] = 1;
891
+		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner'))
892
+		{
893
+			$rows['no_owner_col'] = 1;
894
+		}
792 895
 
793 896
 		$rows += $this->summary;
794 897
 
@@ -797,13 +900,23 @@  discard block
 block discarded – undo
797 900
 		if (!$rows['ts_viewtype'])
798 901
 		{
799 902
 			#_debug_array($query['selectcols']);
800
-			if(!is_array($query['selectcols'])){
903
+			if(!is_array($query['selectcols']))
904
+			{
801 905
 				$query['selectcols'] = explode(',',$query['selectcols']);
802 906
 			}
803 907
 			#ts_quantity,ts_unitprice,ts_total
804
-			if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) $rows['no_ts_quantity'] = 1;
805
-			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) $rows['no_ts_unitprice'] = 1;
806
-			if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) $rows['no_ts_total'] = 1;
908
+			if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false)
909
+			{
910
+				$rows['no_ts_quantity'] = 1;
911
+			}
912
+			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false)
913
+			{
914
+				$rows['no_ts_unitprice'] = 1;
915
+			}
916
+			if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false)
917
+			{
918
+				$rows['no_ts_total'] = 1;
919
+			}
807 920
 		}
808 921
 		$rows['no_ts_status'] = in_array('ts_status', $query['selectcols']) === false && !$this->config_data['history'] ||
809 922
 			$query['no_status'];
@@ -826,7 +939,10 @@  discard block
 block discarded – undo
826 939
 	{
827 940
 		$etpl = new Etemplate('timesheet.index');
828 941
 
829
-		if ($_GET['msg']) $msg = $_GET['msg'];
942
+		if ($_GET['msg'])
943
+		{
944
+			$msg = $_GET['msg'];
945
+		}
830 946
 		if ($content['nm']['rows']['delete'])
831 947
 		{
832 948
 			list($ts_id) = each($content['nm']['rows']['delete']);
@@ -839,9 +955,12 @@  discard block
 block discarded – undo
839 955
 				$msg = lang('Error deleting the entry!!!');
840 956
 			}
841 957
 		}
842
-		if (is_array($content) && isset($content['nm']['rows']['document']))  // handle insert in default document button like an action
958
+		if (is_array($content) && isset($content['nm']['rows']['document']))
959
+		{
960
+			// handle insert in default document button like an action
843 961
 		{
844 962
 			list($id) = @each($content['nm']['rows']['document']);
963
+		}
845 964
 			$content['nm']['action'] = 'document';
846 965
 			$content['nm']['selected'] = array($id);
847 966
 		}
@@ -909,7 +1028,10 @@  discard block
 block discarded – undo
909 1028
 		}
910 1029
 		$read_grants = $this->grant_list(Acl::READ);
911 1030
 		$content['nm']['no_owner_col'] = count($read_grants) == 1;
912
-		if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']) $content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'];
1031
+		if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'])
1032
+		{
1033
+			$content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'];
1034
+		}
913 1035
 		$sel_options = array(
914 1036
 			'ts_owner'   => $read_grants,
915 1037
 			'pm_id'      => array(lang('No project')),
@@ -926,7 +1048,10 @@  discard block
 block discarded – undo
926 1048
 		if ($this->pm_integration != 'full')
927 1049
 		{
928 1050
 			$projects =& $this->query_list('ts_project');
929
-			if (!is_array($projects)) $projects = array();
1051
+			if (!is_array($projects))
1052
+			{
1053
+				$projects = array();
1054
+			}
930 1055
 			$sel_options['ts_project'] = $projects + array(lang('No project'));
931 1056
 		}
932 1057
 
@@ -1132,7 +1257,8 @@  discard block
 block discarded – undo
1132 1257
 			case 'cat':
1133 1258
 				$cat_name = Api\Categories::id2name($settings);
1134 1259
 				$action_msg = lang('changed category to %1', $cat_name);
1135
-				foreach((array)$checked as $n => $id) {
1260
+				foreach((array)$checked as $n => $id)
1261
+				{
1136 1262
 					$entry = $this->read($id);
1137 1263
 					$entry['cat_id'] = $settings;
1138 1264
 					if($this->save($entry) == 0)
@@ -1147,7 +1273,10 @@  discard block
 block discarded – undo
1147 1273
 				break;
1148 1274
 
1149 1275
 			case 'document':
1150
-				if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
1276
+				if (!$settings)
1277
+				{
1278
+					$settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
1279
+				}
1151 1280
 				$document_merge = new timesheet_merge();
1152 1281
 				$msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir']);
1153 1282
 				$failed = count($checked);
@@ -1199,7 +1328,10 @@  discard block
 block discarded – undo
1199 1328
 						$this->load_statuses();
1200 1329
 						$msg .= lang('Status updated.');
1201 1330
 					}
1202
-					if ($button == 'apply') break;
1331
+					if ($button == 'apply')
1332
+					{
1333
+						break;
1334
+					}
1203 1335
 					// fall-through
1204 1336
 				case 'cancel':
1205 1337
 					$GLOBALS['egw']->redirect_link('/admin/index.php', null, 'admin');
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   +172 added lines, -174 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 	function view()
57 57
 	{
58
-		$this->edit(null,true);
58
+		$this->edit(null, true);
59 59
 	}
60 60
 
61
-	function edit($content = null,$view = false)
61
+	function edit($content = null, $view = false)
62 62
 	{
63 63
 		$etpl = new Etemplate('timesheet.edit');
64 64
 		if (!is_array($content))
@@ -80,30 +80,29 @@  discard block
 block discarded – undo
80 80
 			{
81 81
 				$this->data = array(
82 82
 					'ts_start' => $this->today,
83
-					'start_time' => '',	// force empty start-time
84
-					'end_time' => Api\DateTime::to($this->now,'H:i'),
83
+					'start_time' => '', // force empty start-time
84
+					'end_time' => Api\DateTime::to($this->now, 'H:i'),
85 85
 					'ts_owner' => $GLOBALS['egw_info']['user']['account_id'],
86
-					'cat_id'   => (int) $_REQUEST['cat_id'],
86
+					'cat_id'   => (int)$_REQUEST['cat_id'],
87 87
 					'ts_status'=> $GLOBALS['egw_info']['user']['preferences']['timesheet']['predefined_status'],
88 88
 					'ts_project' => $_REQUEST['ts_project'],
89 89
 					'ts_title_blur' => $_REQUEST['ts_project'],
90 90
 				);
91
-				if(!is_numeric($_REQUEST['ts_project']))
91
+				if (!is_numeric($_REQUEST['ts_project']))
92 92
 				{
93 93
 					$this->data['pm_id'] = $this->find_pm_id($_REQUEST['ts_project']);
94 94
 				}
95 95
 			}
96 96
 			$matches = null;
97
-			$referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] :
98
-				(strpos($_SERVER['HTTP_REFERER'],'/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
97
+			$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');
99 98
 
100 99
 			if (!$this->check_statusForEditRights($this->data))
101 100
 			{
102
-				$view = true;  //only admin can edit with this status
101
+				$view = true; //only admin can edit with this status
103 102
 				$only_admin_edit = true;
104 103
 				$msg = lang('only Admin can edit this status');
105 104
 			}
106
-			if(!$this->data['ts_project_blur'])
105
+			if (!$this->data['ts_project_blur'])
107 106
 			{
108 107
 				$this->data['ts_project_blur'] = $this->data['pm_id'] ? Link::title('projectmanager', $this->data['pm_id']) : '';
109 108
 			}
@@ -115,7 +114,7 @@  discard block
 block discarded – undo
115 114
 			{
116 115
 				if ($this->status_labels_config[$content['ts_status']]['admin'])
117 116
 				{
118
-					$view = true;  //only admin can edit with this status
117
+					$view = true; //only admin can edit with this status
119 118
 					$only_admin_edit = true;
120 119
 					$msg = lang('only Admin can edit this status');
121 120
 				}
@@ -129,29 +128,29 @@  discard block
 block discarded – undo
129 128
 			{
130 129
 				//$content['ts_start'] += $content['start_time'];
131 130
 				$start = new Api\DateTime($content['ts_start']);
132
-				$start_time = explode(':',$content['start_time']);
133
-				$start->setTime($start_time[0],$start_time[1]);
131
+				$start_time = explode(':', $content['start_time']);
132
+				$start->setTime($start_time[0], $start_time[1]);
134 133
 				$content['ts_start'] = $start->format('ts');
135 134
 			}
136 135
 			if (isset($content['end_time']))		// end-time specified
137 136
 			{
138 137
 				$end = new Api\DateTime($content['ts_start']);
139
-				$end_time = explode(':',$content['end_time']);
140
-				$end->setTime($end_time[0],$end_time[1]);
138
+				$end_time = explode(':', $content['end_time']);
139
+				$end->setTime($end_time[0], $end_time[1]);
141 140
 			}
142 141
 			if ($end && $start)	// start- & end-time --> calculate the duration
143 142
 			{
144 143
 				$content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60;
145 144
 				// check if negative duration is caused by wrap over midnight
146
-				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60)
145
+				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24 * 60)
147 146
 				{
148
-					$content['ts_duration'] += 24*60;
147
+					$content['ts_duration'] += 24 * 60;
149 148
 				}
150 149
 				//echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n";
151 150
 			}
152 151
 			elseif ($content['ts_duration'] && $end)	// no start, calculate from end and duration
153 152
 			{
154
-				$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
153
+				$content['ts_start'] = $end->format('ts') - 60 * $content['ts_duration'];
155 154
 				//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n";
156 155
 			}
157 156
 			if ($content['ts_duration'] > 0) unset($content['end_time']);
@@ -161,18 +160,18 @@  discard block
 block discarded – undo
161 160
 			$referer = $content['referer'];
162 161
 			$content['ts_project_blur'] = $content['pm_id'] ? Link::title('projectmanager', $content['pm_id']) : '';
163 162
 			$this->data = $content;
164
-			foreach(array('button','view','referer','tabs','start_time') as $key)
163
+			foreach (array('button', 'view', 'referer', 'tabs', 'start_time') as $key)
165 164
 			{
166 165
 				unset($this->data[$key]);
167 166
 			}
168
-			switch($button)
167
+			switch ($button)
169 168
 			{
170 169
 				case 'edit':
171 170
 					if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false;
172 171
 					break;
173 172
 
174 173
 				case 'undelete':
175
-					if($content['ts_status'] == self::DELETED_STATUS)
174
+					if ($content['ts_status'] == self::DELETED_STATUS)
176 175
 					{
177 176
 						unset($content['ts_status']);
178 177
 						$this->data['ts_status'] = '';
@@ -190,18 +189,17 @@  discard block
 block discarded – undo
190 189
 					}
191 190
 					if (!$this->data['ts_quantity'])
192 191
 					{
193
-						$etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!'));
192
+						$etpl->set_validation_error('ts_quantity', lang('Field must not be empty !!!'));
194 193
 					}
195 194
 					if ($this->data['ts_duration'] < 0)
196 195
 					{
197
-						$etpl->set_validation_error('start_time',lang('Starttime has to be before endtime !!!'));
196
+						$etpl->set_validation_error('start_time', lang('Starttime has to be before endtime !!!'));
198 197
 					}
199 198
 					// set ts_title to ts_project if short viewtype (title is not editable)
200
-					if($this->ts_viewtype == 'short')
199
+					if ($this->ts_viewtype == 'short')
201 200
 					{
202 201
 						$this->data['ts_title'] = $this->data['ts_project'] = $this->data['pm_id'] ?
203
-								Link::title('projectmanager', $this->data['pm_id']) :
204
-								$this->data['ts_project'];
202
+								Link::title('projectmanager', $this->data['pm_id']) : $this->data['ts_project'];
205 203
 					}
206 204
 					if (!$this->data['ts_title'])
207 205
 					{
@@ -210,9 +208,9 @@  discard block
 block discarded – undo
210 208
 
211 209
 						if (!$this->data['ts_title'])
212 210
 						{
213
-							$etpl->set_validation_error('ts_title',lang('Field must not be empty !!!'));
211
+							$etpl->set_validation_error('ts_title', lang('Field must not be empty !!!'));
214 212
 						}
215
-						elseif($button != 'save_new')
213
+						elseif ($button != 'save_new')
216 214
 						{
217 215
 							// remove title-blur for same behavior after apply, as for opening the saved entry again
218 216
 							unset($this->data['ts_title_blur']);
@@ -221,26 +219,26 @@  discard block
 block discarded – undo
221 219
 							unset($content['ts_project_blur']);
222 220
 						}
223 221
 					}
224
-					if ($etpl->validation_errors()) break;	// the user need to fix the error, before we can save the entry
222
+					if ($etpl->validation_errors()) break; // the user need to fix the error, before we can save the entry
225 223
 
226 224
 					// account for changed project --> remove old one from links and add new one
227
-					if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id'])
225
+					if ((int)$this->data['pm_id'] != (int)$this->data['old_pm_id'])
228 226
 					{
229 227
 						// update links accordingly
230 228
 						if ($this->data['pm_id'])
231 229
 						{
232
-							Link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
230
+							Link::link(TIMESHEET_APP, $content['link_to']['to_id'], 'projectmanager', $this->data['pm_id']);
233 231
 						}
234 232
 						if ($this->data['old_pm_id'])
235 233
 						{
236
-							Link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
234
+							Link::unlink2(0, TIMESHEET_APP, $content['link_to']['to_id'], 0, 'projectmanager', $this->data['old_pm_id']);
237 235
 							unset($this->data['old_pm_id']);
238 236
 						}
239 237
 					}
240 238
 					// check if we are linked to a project, but that is NOT set as project
241 239
 					if (!$this->data['pm_id'] && is_array($content['link_to']['to_id']))
242 240
 					{
243
-						foreach($content['link_to']['to_id'] as $data)
241
+						foreach ($content['link_to']['to_id'] as $data)
244 242
 						{
245 243
 							if ($data['app'] == 'projectmanager')
246 244
 							{
@@ -261,26 +259,26 @@  discard block
 block discarded – undo
261 259
 						$msg = lang('Entry saved');
262 260
 						if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
263 261
 						{
264
-							Link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
262
+							Link::link(TIMESHEET_APP, $this->data['ts_id'], $content['link_to']['to_id']);
265 263
 						}
266 264
 					}
267 265
 					Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
268 266
 					if ($button == 'apply') break;
269 267
 					if ($button == 'save_new')
270 268
 					{
271
-						$msg .= ', '.lang('creating new entry');		// giving some feedback to the user
269
+						$msg .= ', '.lang('creating new entry'); // giving some feedback to the user
272 270
 
273 271
 						if (!is_array($content['link_to']['to_id']))	// set links again, so new entry gets the same links as the existing one
274 272
 						{
275 273
 							$content['link_to']['to_id'] = 0;
276
-							foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link)
274
+							foreach (Link::get_links(TIMESHEET_APP, $this->data['ts_id'], '!'.Link::VFS_APPNAME) as $link)
277 275
 							{
278
-								Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
276
+								Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
279 277
 							}
280 278
 						}
281 279
 						// create a new entry
282 280
 						$this->data['ts_start'] += 60 * $this->data['ts_duration'];
283
-						foreach(array('ts_id','ts_title','ts_description','ts_duration','ts_quantity','ts_modified','ts_modifier') as $name)
281
+						foreach (array('ts_id', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_modified', 'ts_modifier') as $name)
284 282
 						{
285 283
 							unset($this->data[$name]);
286 284
 						}
@@ -300,7 +298,7 @@  discard block
 block discarded – undo
300 298
 						else
301 299
 						{
302 300
 							$msg = lang('Error deleting the entry!!!');
303
-							break;	// dont close window
301
+							break; // dont close window
304 302
 						}
305 303
 					}
306 304
 					// fall-through for save
@@ -313,7 +311,7 @@  discard block
 block discarded – undo
313 311
 			'referer' => $referer,
314 312
 			'ts_title_blur' => $content['ts_title_blur'],
315 313
 		);
316
-		$content = array_merge($this->data,array(
314
+		$content = array_merge($this->data, array(
317 315
 			'msg'  => $msg,
318 316
 			'view' => $view,
319 317
 			'tabs'  => $content['tabs'],
@@ -321,8 +319,8 @@  discard block
 block discarded – undo
321 319
 				'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] : $content['link_to']['to_id'],
322 320
 				'to_app' => TIMESHEET_APP,
323 321
 			),
324
-			'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0,3) : '',
325
-			'ts_quantity' => $this->data['ts_duration']/60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
322
+			'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0, 3) : '',
323
+			'ts_quantity' => $this->data['ts_duration'] / 60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
326 324
 			'start_time' => isset($this->data['start_time']) ? $this->data['start_time'] : $this->data['ts_start'],
327 325
 			'pm_integration' => $this->pm_integration,
328 326
 			'no_ts_status' => !$this->status_labels && ($this->data['ts_status'] != self::DELETED_STATUS),
@@ -332,10 +330,10 @@  discard block
 block discarded – undo
332 330
 		if (!$this->data['ts_id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
333 331
 		{
334 332
 			$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
335
-			foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
333
+			foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
336 334
 			{
337 335
 				$link_id = $link_ids[$n];
338
-				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
336
+				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// gard against XSS
339 337
 				{
340 338
 					switch ($link_app)
341 339
 					{
@@ -343,33 +341,33 @@  discard block
 block discarded – undo
343 341
 							$links[] = $link_id;
344 342
 							// fall-through;
345 343
 						default:
346
-							if(!$n)
344
+							if (!$n)
347 345
 							{
348 346
 								// get title from first linked app
349
-								$preserv['ts_title_blur'] = Link::title($link_app,$link_id);
347
+								$preserv['ts_title_blur'] = Link::title($link_app, $link_id);
350 348
 								// ask first linked app via "timesheet_set" hook, for further data to set, incl. links
351
-								if (($set = Api\Hooks::single(array('location'=>'timesheet_set','id'=>$link_id),$link_app)))
349
+								if (($set = Api\Hooks::single(array('location'=>'timesheet_set', 'id'=>$link_id), $link_app)))
352 350
 								{
353
-									foreach((array)$set['link_app'] as $i => $l_app)
351
+									foreach ((array)$set['link_app'] as $i => $l_app)
354 352
 									{
355
-										if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
353
+										if (($l_id = $set['link_id'][$i])) Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $l_app, $l_id);
356 354
 										if ($l_app == 'projectmanager') $links[] = $l_id;
357 355
 									}
358 356
 									unset($set['link_app']);
359 357
 									unset($set['link_id']);
360 358
 
361
-									$content = array_merge($content,$set);
359
+									$content = array_merge($content, $set);
362 360
 								}
363 361
 							}
364 362
 							break;
365 363
 					}
366
-					Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
364
+					Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link_app, $link_id);
367 365
 				}
368 366
 			}
369 367
 		}
370 368
 		elseif ($this->data['ts_id'])
371 369
 		{
372
-			$links = Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
370
+			$links = Link::get_links(TIMESHEET_APP, $this->data['ts_id'], 'projectmanager');
373 371
 		}
374 372
 		// make all linked projects availible for the pm-pricelist widget, to be able to choose prices from all
375 373
 		$content['all_pm_ids'] = array_values($links);
@@ -412,7 +410,7 @@  discard block
 block discarded – undo
412 410
 
413 411
 		if ($view)
414 412
 		{
415
-			foreach(array_merge(array_keys($this->data),array('pm_id','pl_id','link_to')) as $key)
413
+			foreach (array_merge(array_keys($this->data), array('pm_id', 'pl_id', 'link_to')) as $key)
416 414
 			{
417 415
 				$readonlys[$key] = true;
418 416
 			}
@@ -428,9 +426,9 @@  discard block
 block discarded – undo
428 426
 		{
429 427
 			$edit_grants[$content['ts_owner']] = Api\Accounts::username($content['ts_owner']);
430 428
 		}
431
-		$sel_options['ts_owner']  = $edit_grants;
432
-		$sel_options['ts_status']  = $this->status_labels;
433
-		if($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
429
+		$sel_options['ts_owner'] = $edit_grants;
430
+		$sel_options['ts_status'] = $this->status_labels;
431
+		if ($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
434 432
 		{
435 433
 			$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
436 434
 		}
@@ -440,23 +438,23 @@  discard block
 block discarded – undo
440 438
 		// supress unknow widget 'projectmanager-*', if projectmanager is not installed or old
441 439
 		if (!@file_exists(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.projectmanager_widget.inc.php'))
442 440
 		{
443
-			$etpl->set_cell_attribute('pm_id','disabled',true);
444
-			$etpl->set_cell_attribute('pl_id','disabled',true);
441
+			$etpl->set_cell_attribute('pm_id', 'disabled', true);
442
+			$etpl->set_cell_attribute('pl_id', 'disabled', true);
445 443
 		}
446 444
 
447
-		if($this->ts_viewtype == 'short')
445
+		if ($this->ts_viewtype == 'short')
448 446
 		{
449 447
 			$content['ts_viewtype'] = $readonlys['tabs']['notes'] = true;
450 448
 			$content['ts_description_short'] = $content['ts_description'];
451
-			if(!$content['pm_id'] && $this->pm_integration != 'full' && $content['ts_project'])
449
+			if (!$content['pm_id'] && $this->pm_integration != 'full' && $content['ts_project'])
452 450
 			{
453
-				$etpl->setElementAttribute('pm_id','blur',$content['ts_project']);
451
+				$etpl->setElementAttribute('pm_id', 'blur', $content['ts_project']);
454 452
 			}
455 453
 		}
456
-		if (!$this->customfields) $readonlys['tabs']['customfields'] = true;	// suppress tab if there are not customfields
457
-		if (!$this->data['ts_id']) $readonlys['tabs']['history']    = true;   //suppress history for the first loading without ID
454
+		if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields
455
+		if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID
458 456
 
459
-		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2);
457
+		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit', $content, $sel_options, $readonlys, $preserv, 2);
460 458
 	}
461 459
 
462 460
 	/**
@@ -469,7 +467,7 @@  discard block
 block discarded – undo
469 467
 	{
470 468
 		if (!$datetime) return 0;
471 469
 
472
-		return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime));
470
+		return $datetime - mktime(0, 0, 0, date('m', $datetime), date('d', $datetime), date('Y', $datetime));
473 471
 	}
474 472
 
475 473
 	/**
@@ -483,22 +481,22 @@  discard block
 block discarded – undo
483 481
 	 * @param boolean $id_only if true only return (via $rows) an array of contact-ids, dont save state to session
484 482
 	 * @return int total number of contacts matching the selection
485 483
 	 */
486
-	function get_rows(&$query_in,&$rows,&$readonlys,$id_only=false)
484
+	function get_rows(&$query_in, &$rows, &$readonlys, $id_only = false)
487 485
 	{
488 486
 		$this->show_sums = false;
489 487
 
490 488
 		// Date filter
491 489
 		$end_date = $query_in['enddate'] ? $query_in['enddate'] : false;
492
-		if($end_date || $query_in['filter'] === 'custom')
490
+		if ($end_date || $query_in['filter'] === 'custom')
493 491
 		{
494 492
 			$query_in['startdate'] = $query_in['startdate'] ? $query_in['startdate'] : 1;
495 493
 		}
496
-		$date_filter = $this->date_filter($query_in['filter'],$query_in['startdate'],$end_date);
494
+		$date_filter = $this->date_filter($query_in['filter'], $query_in['startdate'], $end_date);
497 495
 
498 496
 		if ($query_in['startdate'])
499 497
 		{
500
-			$start = explode('-',date('Y-m-d',$query_in['startdate']+12*60*60));
501
-			$end   = explode('-',date('Y-m-d',$end_date ? $end_date : $query_in['startdate']+7.5*24*60*60));
498
+			$start = explode('-', date('Y-m-d', $query_in['startdate'] + 12 * 60 * 60));
499
+			$end   = explode('-', date('Y-m-d', $end_date ? $end_date : $query_in['startdate'] + 7.5 * 24 * 60 * 60));
502 500
 
503 501
 			// show year-sums, if we are year-aligned (show full years)?
504 502
 			if ((int)$start[2] == 1 && (int)$start[1] == 1 && (int)$end[2] == 31 && (int)$end[1] == 12)
@@ -506,28 +504,28 @@  discard block
 block discarded – undo
506 504
 				$this->show_sums[] = 'year';
507 505
 			}
508 506
 			// show month-sums, if we are month-aligned (show full monthes)?
509
-			if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d',mktime(12,0,0,$end[1]+1,0,$end[0])))
507
+			if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d', mktime(12, 0, 0, $end[1] + 1, 0, $end[0])))
510 508
 			{
511 509
 				$this->show_sums[] = 'month';
512 510
 			}
513 511
 			// show week-sums, if we are week-aligned (show full weeks)?
514 512
 			$week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'];
515 513
 			if (!$week_start_day) $week_start_day = 'Sunday';
516
-			switch($week_start_day)
514
+			switch ($week_start_day)
517 515
 			{
518 516
 				case 'Sunday': $week_end_day = 'Saturday'; break;
519 517
 				case 'Monday': $week_end_day = 'Sunday'; break;
520 518
 				case 'Saturday': $week_end_day = 'Friday'; break;
521 519
 			}
522
-			$filter_start_day = date('l',$query_in['startdate']+12*60*60);
523
-			$filter_end_day   = $query_in['enddate'] ? date('l',$query_in['enddate']+12*60*60) : false;
520
+			$filter_start_day = date('l', $query_in['startdate'] + 12 * 60 * 60);
521
+			$filter_end_day   = $query_in['enddate'] ? date('l', $query_in['enddate'] + 12 * 60 * 60) : false;
524 522
 			//echo "<p align=right>prefs: $week_start_day - $week_end_day, filter: $filter_start_day - $filter_end_day</p>\n";
525 523
 			if ($filter_start_day == $week_start_day && (!$filter_end_day || $filter_end_day == $week_end_day))
526 524
 			{
527 525
 				$this->show_sums[] = 'week';
528 526
 			}
529 527
 			// show day-sums, if range <= 5 weeks
530
-			if (!$query_in['enddate'] || $query_in['enddate'] - $query_in['startdate'] < 36*24*60*60)
528
+			if (!$query_in['enddate'] || $query_in['enddate'] - $query_in['startdate'] < 36 * 24 * 60 * 60)
531 529
 			{
532 530
 				$this->show_sums[] = 'day';
533 531
 			}
@@ -538,10 +536,10 @@  discard block
 block discarded – undo
538 536
 		// Refresh actions (undelete needs this)
539 537
 		$query_in['actions'] = $this->get_actions($query_in);
540 538
 
541
-		$query = $query_in;	// keep the original query
539
+		$query = $query_in; // keep the original query
542 540
 		$query['enddate'] = $end_date;
543 541
 
544
-		if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
542
+		if ($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false, 'ts_unitprice'=>false, 'ts_total'=>false);
545 543
 		if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false;
546 544
 
547 545
 		//_debug_array($query['col_filter']);
@@ -568,18 +566,18 @@  discard block
 block discarded – undo
568 566
 		// handle linked filter (show only entries linked to a certain other entry)
569 567
 		if ($query['col_filter']['linked'])
570 568
 		{
571
-			if(!is_array($query['col_filter']['linked']))
569
+			if (!is_array($query['col_filter']['linked']))
572 570
 			{
573
-				list($app,$id) = explode(':',$query['col_filter']['linked']);
571
+				list($app, $id) = explode(':', $query['col_filter']['linked']);
574 572
 			}
575 573
 			else
576 574
 			{
577 575
 				$app = $query['col_filter']['linked']['app'];
578 576
 				$id = $query['col_filter']['linked']['id'];
579 577
 			}
580
-			if (!($links = Link::get_links($app,$id,'timesheet')))
578
+			if (!($links = Link::get_links($app, $id, 'timesheet')))
581 579
 			{
582
-				$rows = array();	// no infologs linked to project --> no rows to return
580
+				$rows = array(); // no infologs linked to project --> no rows to return
583 581
 				return 0;
584 582
 			}
585 583
 			if (!$query['col_filter']['ts_id'])
@@ -587,9 +585,9 @@  discard block
 block discarded – undo
587 585
 				$query['col_filter']['ts_id'] = array_values(array_unique($links));
588 586
 			}
589 587
 			// allow to combine with other filters using ts_id --> intersect ids
590
-			elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'],array_values(array_unique($links)))))
588
+			elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'], array_values(array_unique($links)))))
591 589
 			{
592
-				$rows = array();	// no infologs linked to project --> no rows to return
590
+				$rows = array(); // no infologs linked to project --> no rows to return
593 591
 				return 0;
594 592
 			}
595 593
 		}
@@ -613,13 +611,13 @@  discard block
 block discarded – undo
613 611
 			{
614 612
 				if (isset($this->status_labels_substatus['2level'][$status_id]))
615 613
 				{
616
-					$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'],$this->status_labels_substatus[$status_id]);
614
+					$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'], $this->status_labels_substatus[$status_id]);
617 615
 				}
618 616
 			}
619 617
 		}
620 618
 		if ((int)$query['filter2'] != (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'])
621 619
 		{
622
-			$GLOBALS['egw']->preferences->add(TIMESHEET_APP,'show_details',(int)$query['filter2']);
620
+			$GLOBALS['egw']->preferences->add(TIMESHEET_APP, 'show_details', (int)$query['filter2']);
623 621
 			$GLOBALS['egw']->preferences->save_repository(true);
624 622
 		}
625 623
 		// category filter: cat_id or ''=All cats or 0=No cat
@@ -642,7 +640,7 @@  discard block
 block discarded – undo
642 640
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']);
643 641
 			#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
644 642
 			#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
645
-			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));
643
+			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));
646 644
 		}
647 645
 		else
648 646
 		{
@@ -655,60 +653,60 @@  discard block
 block discarded – undo
655 653
 			// generate a meaningful app-header / report title
656 654
 			if ($this->show_sums['month'])
657 655
 			{
658
-				if ((int)$start[1] == 1 && (int) $end[1] == 12)		// whole year(s)
656
+				if ((int)$start[1] == 1 && (int)$end[1] == 12)		// whole year(s)
659 657
 				{
660
-					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : '');
658
+					$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$start[0].($start[0] != $end[0] ? ' - '.$end[0] : '');
661 659
 				}
662 660
 				else
663 661
 				{
664
-					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0];
662
+					$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(date('F', $query['startdate'] + 12 * 60 * 60)).' '.$start[0];
665 663
 					if ($start[0] != $end[0] || $start[1] != $end[1])
666 664
 					{
667
-						$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . lang(date('F',$query['enddate']+12*60*60)) . ' ' . $end[0];
665
+						$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang(date('F', $query['enddate'] + 12 * 60 * 60)).' '.$end[0];
668 666
 					}
669 667
 				}
670 668
 			}
671 669
 			elseif ($this->show_sums['week'])
672 670
 			{
673
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang('week') . ' ' . date('W',$query['startdate']+36*60*60) . '/' . $start[0];
674
-				if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10*24*60*60)
671
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('week').' '.date('W', $query['startdate'] + 36 * 60 * 60).'/'.$start[0];
672
+				if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10 * 24 * 60 * 60)
675 673
 				{
676
-					$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . date('W',$query['enddate']-36*60*60) . '/' . $end[0];
674
+					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.date('W', $query['enddate'] - 36 * 60 * 60).'/'.$end[0];
677 675
 				}
678 676
 			}
679 677
 			elseif ($query['startdate'])
680 678
 			{
681 679
 				$df = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
682
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . Api\DateTime::to($query['startdate']+12*60*60, $df);
680
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\DateTime::to($query['startdate'] + 12 * 60 * 60, $df);
683 681
 				if ($start != $end)
684 682
 				{
685
-					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate']+12*60*60:'now', $df);
683
+					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate'] + 12 * 60 * 60 : 'now', $df);
686 684
 				}
687 685
 			}
688 686
 		}
689 687
 		// Update start / end dates for custom
690
-		if($query_in['filter'] != 'custom')
688
+		if ($query_in['filter'] != 'custom')
691 689
 		{
692 690
 			Api\Json\Response::get()->call(
693 691
 				'app.timesheet.update_timespan',
694
-				Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now' , Api\DateTime::ET2),
692
+				Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now', Api\DateTime::ET2),
695 693
 				$query['filter'] ? Api\DateTime::to($query['enddate'], Api\DateTime::ET2) : null
696 694
 			);
697 695
 		}
698
-		$total = parent::get_rows($query,$rows,$readonlys);
696
+		$total = parent::get_rows($query, $rows, $readonlys);
699 697
 
700 698
 		$ids = array();
701
-		foreach($rows as &$row)
699
+		foreach ($rows as &$row)
702 700
 		{
703 701
 			if ($row['ts_id'] > 0) $ids[] = $row['ts_id'];
704 702
 		}
705 703
 		if ($id_only)
706 704
 		{
707 705
 			$rows = $ids;
708
-			return $this->total;	// no need to set other fields or $readonlys
706
+			return $this->total; // no need to set other fields or $readonlys
709 707
 		}
710 708
 		$links = array();
711
-		$links3 = Link::get_links_multiple(TIMESHEET_APP,$ids,true,'projectmanager');	// only check for pm links!
709
+		$links3 = Link::get_links_multiple(TIMESHEET_APP, $ids, true, 'projectmanager'); // only check for pm links!
712 710
 		//as the full array is expected, we must supply the missing but needed (since expected further down) information
713 711
 		if (is_array($links3))
714 712
 		{
@@ -728,14 +726,14 @@  discard block
 block discarded – undo
728 726
 
729 727
 		$readonlys = array();
730 728
 		$have_cats = false;
731
-		foreach($rows as &$row)
729
+		foreach ($rows as &$row)
732 730
 		{
733 731
 			if ($row['cat_id']) $have_cats = true;
734 732
 
735 733
 			$row['class'] = 'row';
736 734
 			if ($row['ts_id'] <= 0)	// sums
737 735
 			{
738
-				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;	// fix for DSL change
736
+				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; // fix for DSL change
739 737
 
740 738
 				// Remove fake modified date, it breaks nextmatch checks
741 739
 				unset($row['ts_modified']);
@@ -743,22 +741,22 @@  discard block
 block discarded – undo
743 741
 				// Set flag to avoid actions on these rows
744 742
 				$row['no_actions'] = true;
745 743
 
746
-				switch($row['ts_id'])
744
+				switch ($row['ts_id'])
747 745
 				{
748 746
 					case 0:	// day-sum
749
-						$row['ts_title'] = lang('Sum %1:',lang(date('l',$row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
747
+						$row['ts_title'] = lang('Sum %1:', lang(date('l', $row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
750 748
 						$row['ts_id'] = 'sum-day-'.$row['ts_start'];
751 749
 						break;
752 750
 					case -1:	// week-sum
753
-						$row['ts_title'] = lang('Sum %1:',lang('week').' '.substr($row['ts_week'],4).'/'.substr($row['ts_week'],0,4));
751
+						$row['ts_title'] = lang('Sum %1:', lang('week').' '.substr($row['ts_week'], 4).'/'.substr($row['ts_week'], 0, 4));
754 752
 						$row['ts_id'] = 'sum-week-'.$row['ts_week'];
755 753
 						break;
756 754
 					case -2:	// month-sum
757
-						$row['ts_title'] = lang('Sum %1:',lang(date('F',$row['ts_start'])).' '.substr($row['ts_month'],0,4));
755
+						$row['ts_title'] = lang('Sum %1:', lang(date('F', $row['ts_start'])).' '.substr($row['ts_month'], 0, 4));
758 756
 						$row['ts_id'] = 'sum-month-'.$row['ts_month'];
759 757
 						break;
760 758
 					case -3:	// year-sum
761
-						$row['ts_title'] = lang('Sum %1:',$row['ts_year']);
759
+						$row['ts_title'] = lang('Sum %1:', $row['ts_year']);
762 760
 						$row['ts_id'] = 'sum-year-'.$row['ts_year'];
763 761
 						break;
764 762
 				}
@@ -768,11 +766,11 @@  discard block
 block discarded – undo
768 766
 				$row['titleClass'] = 'timesheet_titleSum';
769 767
 				continue;
770 768
 			}
771
-			if($row['ts_quantity'])
769
+			if ($row['ts_quantity'])
772 770
 			{
773 771
 				$row['ts_quantity'] = round($row['ts_quantity'], 2);
774 772
 			}
775
-			if (!$this->check_acl(Acl::EDIT,$row))
773
+			if (!$this->check_acl(Acl::EDIT, $row))
776 774
 			{
777 775
 				$row['class'] .= ' rowNoEdit ';
778 776
 			}
@@ -780,21 +778,21 @@  discard block
 block discarded – undo
780 778
 			{
781 779
 				$row['class'] .= ' rowNoEdit ';
782 780
 			}
783
-			if (!$this->check_acl(Acl::DELETE,$row))
781
+			if (!$this->check_acl(Acl::DELETE, $row))
784 782
 			{
785 783
 				$row['class'] .= ' rowNoDelete ';
786 784
 			}
787
-			if($row['ts_status'] != self::DELETED_STATUS)
785
+			if ($row['ts_status'] != self::DELETED_STATUS)
788 786
 			{
789 787
 				$row['class'] .= ' rowNoUndelete ';
790 788
 			}
791 789
 			if ($query['col_filter']['ts_project'])
792 790
 			{
793
-				unset($row['ts_project']);	// dont need or want to show it
791
+				unset($row['ts_project']); // dont need or want to show it
794 792
 			}
795 793
 			elseif ($links[$row['ts_id']])
796 794
 			{
797
-				foreach($links[$row['ts_id']] as $link)
795
+				foreach ($links[$row['ts_id']] as $link)
798 796
 				{
799 797
 					if ($link['app'] == 'projectmanager')
800 798
 					{
@@ -805,28 +803,28 @@  discard block
 block discarded – undo
805 803
 				}
806 804
 			}
807 805
 
808
-			if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
806
+			if (!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
809 807
 
810 808
 		}
811 809
 		$rows['no_cat_id'] = (!$have_cats || $query['cat_id']);
812 810
 		if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint';
813 811
 		$rows['no_owner_col'] = $query['no_owner_col'];
814
-		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'],'ts_owner')) $rows['no_owner_col'] = 1;
812
+		if (!$rows['no_owner_col'] && $query['selectcols'] && !strpos($query['selectcols'], 'ts_owner')) $rows['no_owner_col'] = 1;
815 813
 
816 814
 		$rows += $this->summary;
817 815
 
818 816
 		$rows['pm_integration'] = $this->pm_integration;
819
-		$rows['ts_viewtype'] =  $rows['no_ts_quantity'] =  $rows['no_ts_unitprice'] =  $rows['no_ts_total'] = $this->ts_viewtype == 'short';
817
+		$rows['ts_viewtype'] = $rows['no_ts_quantity'] = $rows['no_ts_unitprice'] = $rows['no_ts_total'] = $this->ts_viewtype == 'short';
820 818
 		if (!$rows['ts_viewtype'])
821 819
 		{
822 820
 			#_debug_array($query['selectcols']);
823
-			if(!is_array($query['selectcols'])){
824
-				$query['selectcols'] = explode(',',$query['selectcols']);
821
+			if (!is_array($query['selectcols'])) {
822
+				$query['selectcols'] = explode(',', $query['selectcols']);
825 823
 			}
826 824
 			#ts_quantity,ts_unitprice,ts_total
827
-			if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) $rows['no_ts_quantity'] = 1;
828
-			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) $rows['no_ts_unitprice'] = 1;
829
-			if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) $rows['no_ts_total'] = 1;
825
+			if ($query['selectcols'] && in_array('ts_quantity_quantity', $query['selectcols']) === false) $rows['no_ts_quantity'] = 1;
826
+			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols']) === false) $rows['no_ts_unitprice'] = 1;
827
+			if ($query['selectcols'] && in_array('ts_total_price', $query['selectcols']) === false) $rows['no_ts_total'] = 1;
830 828
 		}
831 829
 		$rows['no_ts_status'] = in_array('ts_status', $query['selectcols']) === false && !$this->config_data['history'] ||
832 830
 			$query['no_status'];
@@ -845,7 +843,7 @@  discard block
 block discarded – undo
845 843
 	 * @param array $content
846 844
 	 * @param string $msg
847 845
 	 */
848
-	function index($content = null,$msg='')
846
+	function index($content = null, $msg = '')
849 847
 	{
850 848
 		$etpl = new Etemplate('timesheet.index');
851 849
 
@@ -882,14 +880,14 @@  discard block
 block discarded – undo
882 880
 			else
883 881
 			{
884 882
 				$success = $failed = $action_msg = null;
885
-				if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
886
-					$success,$failed,$action_msg,'index',$msg))
883
+				if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
884
+					$success, $failed, $action_msg, 'index', $msg))
887 885
 				{
888
-					$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
886
+					$msg .= lang('%1 timesheets(s) %2', $success, $action_msg);
889 887
 				}
890
-				elseif(empty($msg))
888
+				elseif (empty($msg))
891 889
 				{
892
-					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
890
+					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
893 891
 				}
894 892
 			}
895 893
 		}
@@ -901,7 +899,7 @@  discard block
 block discarded – undo
901 899
 		if (!is_array($content['nm']))
902 900
 		{
903 901
 			$date_filters = array('All');
904
-			foreach(array_keys($this->date_filters) as $name)
902
+			foreach (array_keys($this->date_filters) as $name)
905 903
 			{
906 904
 				$date_filters[$name] = $name;
907 905
 			}
@@ -910,27 +908,27 @@  discard block
 block discarded – undo
910 908
 			$content['nm'] = array(
911 909
 				'get_rows'       =>	TIMESHEET_APP.'.timesheet_ui.get_rows',
912 910
 				'options-filter' => $date_filters,
913
-				'options-filter2' => array('No details','Details'),
914
-				'order'          =>	'ts_start',// IO name of the column to sort after (optional for the sortheaders)
915
-				'sort'           =>	'DESC',// IO direction of the sort: 'ASC' or 'DESC'
911
+				'options-filter2' => array('No details', 'Details'),
912
+				'order'          =>	'ts_start', // IO name of the column to sort after (optional for the sortheaders)
913
+				'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
916 914
 				'filter_onchange' => "app.timesheet.filter_change();",
917 915
 				'filter2_onchange' => "app.timesheet.filter2_change();",
918 916
 				'filter2'        => (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'],
919 917
 				'row_id'         => 'ts_id',
920 918
 				'row_modified'   => 'ts_modified',
921 919
 				//'actions'        => $this->get_actions(),
922
-				'default_cols'   => '!legacy_actions',	// switch legacy actions column and row off by default
920
+				'default_cols'   => '!legacy_actions', // switch legacy actions column and row off by default
923 921
 				'pm_integration' => $this->pm_integration,
924 922
 				'placeholder_actions' => array('add')
925 923
 			);
926 924
 		}
927 925
 		$content['nm']['actions'] = $this->get_actions($content['nm']);
928 926
 
929
-		if($_GET['search'])
927
+		if ($_GET['search'])
930 928
 		{
931 929
 			$content['nm']['search'] = $_GET['search'];
932 930
 		}
933
-		if($_GET['link_app'] && Link::get_registry($_GET['link_app'], 'query') && $_GET['link_id'])
931
+		if ($_GET['link_app'] && Link::get_registry($_GET['link_app'], 'query') && $_GET['link_id'])
934 932
 		{
935 933
 			$content['nm']['col_filter']['linked'] = array(
936 934
 				'app' => $_GET['link_app'],
@@ -944,25 +942,25 @@  discard block
 block discarded – undo
944 942
 			'ts_owner'   => $read_grants,
945 943
 			'pm_id'      => array(lang('No project')),
946 944
 			'cat_id'     => array(array('value' => '', 'label' => lang('all categories')), array('value' => 0, 'label'=>lang('None'))),
947
-			'ts_status'  => $this->status_labels+array(lang('No status')),
945
+			'ts_status'  => $this->status_labels + array(lang('No status')),
948 946
 		);
949
-		if($this->config_data['history'])
947
+		if ($this->config_data['history'])
950 948
 		{
951 949
 			$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
952 950
 		}
953
-		$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1;	// 1 because of 'No status'
954
-		$content['nm']['favorites'] = true;		//Enable favorite
951
+		$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1; // 1 because of 'No status'
952
+		$content['nm']['favorites'] = true; //Enable favorite
955 953
 
956 954
 		if ($this->pm_integration != 'full')
957 955
 		{
958
-			$projects =& $this->query_list('ts_project');
956
+			$projects = & $this->query_list('ts_project');
959 957
 			if (!is_array($projects)) $projects = array();
960 958
 			$sel_options['ts_project'] = $projects + array(lang('No project'));
961 959
 		}
962 960
 
963 961
 		// dont show [Export] button if app is not availible to the user or we are on php4
964
-		$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int) phpversion() < 5;
965
-		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index',$content,$sel_options,$readonlys);
962
+		$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int)phpversion() < 5;
963
+		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index', $content, $sel_options, $readonlys);
966 964
 	}
967 965
 
968 966
 	/**
@@ -981,9 +979,9 @@  discard block
 block discarded – undo
981 979
 				'allowOnMultiple' => false,
982 980
 				'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
983 981
 				'popup' => Link::get_registry('timesheet', 'add_popup'),
984
-				'group' => $group=1,
982
+				'group' => $group = 1,
985 983
 				'disableClass' => 'th',
986
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.timesheet.viewEntry':'',
984
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.timesheet.viewEntry' : '',
987 985
 				'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/timesheet/templates/mobile/view.xet'))
988 986
 			),
989 987
 /*
@@ -1010,7 +1008,7 @@  discard block
 block discarded – undo
1010 1008
 				'group' => $group,
1011 1009
 			),
1012 1010
 			'cat' => Etemplate\Widget\Nextmatch::category_action(
1013
-				'timesheet',++$group,'Change category','cat_'
1011
+				'timesheet', ++$group, 'Change category', 'cat_'
1014 1012
 			),
1015 1013
 			'status' => array(
1016 1014
 				'icon' => 'apply',
@@ -1062,7 +1060,7 @@  discard block
 block discarded – undo
1062 1060
 			);
1063 1061
 		}
1064 1062
 		// enable additonal edit check for following actions, if they are generally available
1065
-		foreach(array('cat','status') as $action)
1063
+		foreach (array('cat', 'status') as $action)
1066 1064
 		{
1067 1065
 			if ($actions[$action]['enabled'])
1068 1066
 			{
@@ -1085,7 +1083,7 @@  discard block
 block discarded – undo
1085 1083
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1086 1084
 	 * @return boolean true if all actions succeded, false otherwise
1087 1085
 	 */
1088
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
1086
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg)
1089 1087
 	{
1090 1088
 		$success = $failed = 0;
1091 1089
 		if ($use_all)
@@ -1095,17 +1093,17 @@  discard block
 block discarded – undo
1095 1093
 
1096 1094
 			if ($use_all)
1097 1095
 			{
1098
-				@set_time_limit(0);			// switch off the execution time limit, as it's for big selections to small
1099
-				$query['num_rows'] = -1;	// all
1096
+				@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
1097
+				$query['num_rows'] = -1; // all
1100 1098
 				$readonlys = null;
1101
-				$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
1099
+				$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
1102 1100
 			}
1103 1101
 		}
1104 1102
 		//error_log(__METHOD__."('$action', ".array2string($checked).', '.array2string($use_all).",,, '$session_name')");
1105 1103
 
1106
-		if (substr($action,0,9) == 'to_status')
1104
+		if (substr($action, 0, 9) == 'to_status')
1107 1105
 		{
1108
-			$to_status = (int)substr($action,10);
1106
+			$to_status = (int)substr($action, 10);
1109 1107
 			$action = 'to_status';
1110 1108
 		}
1111 1109
 		else
@@ -1114,11 +1112,11 @@  discard block
 block discarded – undo
1114 1112
 			list($action, $settings) = explode('_', $action, 2);
1115 1113
 		}
1116 1114
 
1117
-		switch($action)
1115
+		switch ($action)
1118 1116
 		{
1119 1117
 			case 'delete':
1120 1118
 				$action_msg = lang('deleted');
1121
-				foreach((array)$checked as $n => $id)
1119
+				foreach ((array)$checked as $n => $id)
1122 1120
 				{
1123 1121
 					if ($this->delete($id))
1124 1122
 					{
@@ -1131,10 +1129,10 @@  discard block
 block discarded – undo
1131 1129
 				}
1132 1130
 				break;
1133 1131
 			case 'undelete':
1134
-				$action_msg =lang('recovered');
1135
-				foreach((array)$checked as $n => $id)
1132
+				$action_msg = lang('recovered');
1133
+				foreach ((array)$checked as $n => $id)
1136 1134
 				{
1137
-					if ($this->set_status($id,''))
1135
+					if ($this->set_status($id, ''))
1138 1136
 					{
1139 1137
 						$success++;
1140 1138
 					}
@@ -1145,10 +1143,10 @@  discard block
 block discarded – undo
1145 1143
 				}
1146 1144
 				break;
1147 1145
 			case 'to_status':
1148
-				$action_msg =lang('changed status');
1149
-				foreach((array)$checked as $n => $id)
1146
+				$action_msg = lang('changed status');
1147
+				foreach ((array)$checked as $n => $id)
1150 1148
 				{
1151
-					if ($this->set_status($id,$to_status))
1149
+					if ($this->set_status($id, $to_status))
1152 1150
 					{
1153 1151
 						$success++;
1154 1152
 					}
@@ -1161,7 +1159,7 @@  discard block
 block discarded – undo
1161 1159
 			case 'cat':
1162 1160
 				$cat_name = Api\Categories::id2name($settings);
1163 1161
 				$action_msg = lang('changed category to %1', $cat_name);
1164
-				foreach((array)$checked as $n => $id) {
1162
+				foreach ((array)$checked as $n => $id) {
1165 1163
 					if (($entry = $this->read($id)) &&
1166 1164
 						($entry['cat_id'] = $settings) &&
1167 1165
 						$this->save($entry) == 0)
@@ -1192,7 +1190,7 @@  discard block
 block discarded – undo
1192 1190
 	 * @param conetnt
1193 1191
 	 * @param view
1194 1192
 	 */
1195
-	function editstatus($content = null,$msg='')
1193
+	function editstatus($content = null, $msg = '')
1196 1194
 	{
1197 1195
 		// this function requires admin rights
1198 1196
 		$GLOBALS['egw_info']['flags']['admin_only'] = true;
@@ -1203,13 +1201,13 @@  discard block
 block discarded – undo
1203 1201
 			list($button) = @each($content['button']);
1204 1202
 			unset ($content['button']);
1205 1203
 
1206
-			switch($button)
1204
+			switch ($button)
1207 1205
 			{
1208 1206
 				case 'delete':
1209 1207
 					break;
1210 1208
 				case 'apply':
1211 1209
 				case 'save':
1212
-					foreach($content['statis'] as &$cat)
1210
+					foreach ($content['statis'] as &$cat)
1213 1211
 					{
1214 1212
 						$id = $cat['id'];
1215 1213
 						if (($cat ['name'] !== $this->status_labels_config[$id]) && ($cat ['name'] !== '') || ($cat ['parent'] !== $this->status_labels_config[$id]['parent']) && ($cat ['parent'] !== ''))
@@ -1223,7 +1221,7 @@  discard block
 block discarded – undo
1223 1221
 					}
1224 1222
 					if ($need_update)
1225 1223
 					{
1226
-						Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
1224
+						Api\Config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP);
1227 1225
 						$this->config_data = Api\Config::read(TIMESHEET_APP);
1228 1226
 						$this->load_statuses();
1229 1227
 						$msg .= lang('Status updated.');
@@ -1240,7 +1238,7 @@  discard block
 block discarded – undo
1240 1238
 			if (isset($this->status_labels_config[$id]))
1241 1239
 			{
1242 1240
 				unset($this->status_labels_config[$id]);
1243
-				Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
1241
+				Api\Config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP);
1244 1242
 				unset($this->status_labels[$id]);
1245 1243
 				$msg .= lang('Status deleted.');
1246 1244
 			}
@@ -1249,12 +1247,12 @@  discard block
 block discarded – undo
1249 1247
 		$i = 1;
1250 1248
 		$max_id = 0;
1251 1249
 		unset($content['statis']);
1252
-		foreach($this->status_labels_config as $id => $label)
1250
+		foreach ($this->status_labels_config as $id => $label)
1253 1251
 		{
1254
-			$content['statis'][$i]['name']= $label['name'];
1255
-			$content['statis'][$i]['id']= $id;
1256
-			$content['statis'][$i]['parent']= $label['parent'];
1257
-			$content['statis'][$i]['admin']= $label['admin'];
1252
+			$content['statis'][$i]['name'] = $label['name'];
1253
+			$content['statis'][$i]['id'] = $id;
1254
+			$content['statis'][$i]['parent'] = $label['parent'];
1255
+			$content['statis'][$i]['admin'] = $label['admin'];
1258 1256
 			$i++;
1259 1257
 			$max_id = max($id, $max_id);
1260 1258
 		}
@@ -1266,7 +1264,7 @@  discard block
 block discarded – undo
1266 1264
 		$preserv = $content;
1267 1265
 		$sel_options['parent'] = $this->status_labels;
1268 1266
 		$etpl = new Etemplate('timesheet.editstatus');
1269
-		$etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,array(),$preserv);
1267
+		$etpl->exec('timesheet.timesheet_ui.editstatus', $content, $sel_options, array(), $preserv);
1270 1268
 	}
1271 1269
 
1272 1270
 	/**
@@ -1277,14 +1275,14 @@  discard block
 block discarded – undo
1277 1275
 	protected function find_pm_id($project)
1278 1276
 	{
1279 1277
 		list($pm_number, $pm_title) = explode(': ', $project, 2);
1280
-		if(!$pm_number || !$pm_title)
1278
+		if (!$pm_number || !$pm_title)
1281 1279
 		{
1282 1280
 			return false;
1283 1281
 		}
1284 1282
 
1285 1283
 		$pm = new projectmanager_bo();
1286 1284
 		$pm_ids = $pm->search(array('pm_number' => $pm_number, 'pm_title' => $pm_title));
1287
-		if($pm_ids && count($pm_ids) >= 1)
1285
+		if ($pm_ids && count($pm_ids) >= 1)
1288 1286
 		{
1289 1287
 			return $pm_ids[0]['pm_id'];
1290 1288
 		}
Please login to merge, or discard this patch.