@@ -19,9 +19,8 @@ |
||
19 | 19 | * Constructor |
20 | 20 | * |
21 | 21 | * @param string $domain string with domain-name or array with all arguments |
22 | - * @param string $config_user=null user to config the domain (or header_admin_user) |
|
23 | - * @param string $config_passwd=null pw of above user |
|
24 | - * @param boolean $verbose=false if true, echos out some status information during the run |
|
22 | + * @param string $config_user user to config the domain (or header_admin_user) |
|
23 | + * @param string $config_passwd pw of above user |
|
25 | 24 | */ |
26 | 25 | function __construct($domain,$config_user=null,$config_passwd=null) |
27 | 26 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string $config_passwd=null pw of above user |
24 | 24 | * @param boolean $verbose=false if true, echos out some status information during the run |
25 | 25 | */ |
26 | - function __construct($domain,$config_user=null,$config_passwd=null) |
|
26 | + function __construct($domain, $config_user = null, $config_passwd = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($domain)) |
29 | 29 | { |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
46 | 46 | * @throws Exception('header.inc.php not found!'); |
47 | 47 | */ |
48 | - protected function exec($check_only=false) |
|
48 | + protected function exec($check_only = false) |
|
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) return true; // nothing to check, no arguments ... |
|
51 | 51 | |
52 | 52 | // instanciate setup object and check authorisation |
53 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
53 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
54 | 54 | |
55 | - $this->check_installed($this->domain,15,$this->verbose); |
|
55 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
56 | 56 | |
57 | 57 | global $setup_info; |
58 | - foreach($setup_info as $appname => $info) |
|
58 | + foreach ($setup_info as $appname => $info) |
|
59 | 59 | { |
60 | 60 | if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
61 | 61 | } |
@@ -47,7 +47,11 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected function exec($check_only=false) |
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) |
|
51 | + { |
|
52 | + return true; |
|
53 | + } |
|
54 | + // nothing to check, no arguments ... |
|
51 | 55 | |
52 | 56 | // instanciate setup object and check authorisation |
53 | 57 | $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
@@ -57,7 +61,10 @@ discard block |
||
57 | 61 | global $setup_info; |
58 | 62 | foreach($setup_info as $appname => $info) |
59 | 63 | { |
60 | - if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
|
64 | + if ($info['currentver']) |
|
65 | + { |
|
66 | + self::$egw_setup->register_hooks($appname); |
|
67 | + } |
|
61 | 68 | } |
62 | 69 | $this->restore_db(); |
63 | 70 |
@@ -936,9 +936,6 @@ |
||
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 | */ |
@@ -203,7 +203,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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, |
@@ -84,9 +84,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -28,9 +28,6 @@ |
||
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 | { |
@@ -32,7 +32,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -56,11 +56,18 @@ discard block |
||
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 |
||
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 | { |
@@ -252,7 +252,7 @@ |
||
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 | { |
@@ -65,7 +65,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) |
@@ -464,7 +464,7 @@ |
||
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) |
@@ -27,12 +27,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -53,10 +53,7 @@ |
||
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()) |
@@ -59,11 +59,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -108,7 +108,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -261,7 +261,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -152,8 +152,8 @@ |
||
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 | /** |
@@ -16,7 +16,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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, " ",STR_PAD_LEFT).trim(str_replace(' ','',$status['name'])); |
|
273 | - if(count($status['substatus']) > 0) |
|
272 | + $labels[$status['id']] = str_pad('', $depth * 12, " ", STR_PAD_LEFT).trim(str_replace(' ', '', $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 | } |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | * @param int $required =EGW_ACL_READ |
284 | 284 | * @return array with uid => Username pairs |
285 | 285 | */ |
286 | - function grant_list($required=EGW_ACL_READ) |
|
286 | + function grant_list($required = EGW_ACL_READ) |
|
287 | 287 | { |
288 | 288 | $result = array(); |
289 | - foreach($this->grants as $uid => $grant) |
|
289 | + foreach ($this->grants as $uid => $grant) |
|
290 | 290 | { |
291 | - if ($grant & $required) |
|
291 | + if ($grant&$required) |
|
292 | 292 | { |
293 | 293 | $result[$uid] = Api\Accounts::username($uid); |
294 | 294 | } |
@@ -307,19 +307,19 @@ discard block |
||
307 | 307 | * @param int $user =null for which user to check, default current user |
308 | 308 | * @return boolean true if the rights are ok, false if no rights |
309 | 309 | */ |
310 | - function check_statusForEditRights($data=null,$user=null) |
|
310 | + function check_statusForEditRights($data = null, $user = null) |
|
311 | 311 | { |
312 | 312 | if (is_null($data) || (int)$data == $this->data['ts_id']) |
313 | 313 | { |
314 | - $data =& $this->data; |
|
314 | + $data = & $this->data; |
|
315 | 315 | } |
316 | 316 | if (!is_array($data)) |
317 | 317 | { |
318 | 318 | $save_data = $this->data; |
319 | - $data = $this->read($data,true); |
|
319 | + $data = $this->read($data, true); |
|
320 | 320 | $this->data = $save_data; |
321 | 321 | |
322 | - if (!$data) return null; // entry not found |
|
322 | + if (!$data) return null; // entry not found |
|
323 | 323 | } |
324 | 324 | if (!$user) $user = $this->user; |
325 | 325 | if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status']) |
@@ -342,19 +342,19 @@ discard block |
||
342 | 342 | * @param int $user =null for which user to check, default current user |
343 | 343 | * @return boolean true if the rights are ok, null if not found, false if no rights |
344 | 344 | */ |
345 | - function check_acl($required,$data=null,$user=null) |
|
345 | + function check_acl($required, $data = null, $user = null) |
|
346 | 346 | { |
347 | 347 | if (is_null($data) || (int)$data == $this->data['ts_id']) |
348 | 348 | { |
349 | - $data =& $this->data; |
|
349 | + $data = & $this->data; |
|
350 | 350 | } |
351 | 351 | if (!is_array($data)) |
352 | 352 | { |
353 | 353 | $save_data = $this->data; |
354 | - $data = $this->read($data,true); |
|
354 | + $data = $this->read($data, true); |
|
355 | 355 | $this->data = $save_data; |
356 | 356 | |
357 | - if (!$data) return null; // entry not found |
|
357 | + if (!$data) return null; // entry not found |
|
358 | 358 | } |
359 | 359 | if (!$user) $user = $this->user; |
360 | 360 | if ($user == $this->user) |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | } |
364 | 364 | else |
365 | 365 | { |
366 | - $grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP,true,$user); |
|
366 | + $grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP, true, $user); |
|
367 | 367 | } |
368 | - $ret = $data && !!($grants[$data['ts_owner']] & $required); |
|
368 | + $ret = $data && !!($grants[$data['ts_owner']]&$required); |
|
369 | 369 | |
370 | - if(($required & Acl::DELETE) && $this->config_data['history'] == 'history' && |
|
370 | + if (($required&Acl::DELETE) && $this->config_data['history'] == 'history' && |
|
371 | 371 | $data['ts_status'] == self::DELETED_STATUS) |
372 | 372 | { |
373 | 373 | $ret = !!($GLOBALS['egw_info']['user']['apps']['admin']); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param int &$end |
385 | 385 | * @return string |
386 | 386 | */ |
387 | - function date_filter($name,&$start,&$end) |
|
387 | + function date_filter($name, &$start, &$end) |
|
388 | 388 | { |
389 | 389 | return Api\DateTime::sql_filter($name, $start, $end, 'ts_start', $this->date_filters); |
390 | 390 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @param boolean $only_summary =false If true only return the sums as array with keys duration and price, default false |
410 | 410 | * @return array of matching rows (the row is an array of the cols) or False |
411 | 411 | */ |
412 | - 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) |
|
412 | + 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) |
|
413 | 413 | { |
414 | 414 | //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')"); |
415 | 415 | //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"; |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | |
419 | 419 | if (!is_array($extra_cols)) |
420 | 420 | { |
421 | - $extra_cols = $extra_cols ? explode(',',$extra_cols) : array(); |
|
421 | + $extra_cols = $extra_cols ? explode(',', $extra_cols) : array(); |
|
422 | 422 | } |
423 | - if ($only_keys === false || $this->show_sums && strpos($order_by,'ts_start') !== false) |
|
423 | + if ($only_keys === false || $this->show_sums && strpos($order_by, 'ts_start') !== false) |
|
424 | 424 | { |
425 | 425 | $extra_cols[] = $total_sql.' AS ts_total'; |
426 | 426 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | { |
433 | 433 | if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']); |
434 | 434 | |
435 | - foreach($filter['ts_owner'] as $key => $owner) |
|
435 | + foreach ($filter['ts_owner'] as $key => $owner) |
|
436 | 436 | { |
437 | 437 | if (!isset($this->grants[$owner])) |
438 | 438 | { |
@@ -446,8 +446,8 @@ discard block |
||
446 | 446 | } |
447 | 447 | else |
448 | 448 | { |
449 | - $filter[] = '(ts_status ' . ($filter['ts_status'] == self::DELETED_STATUS ? '=':'!= ') . self::DELETED_STATUS . |
|
450 | - ($filter['ts_status'] == self::DELETED_STATUS ? '':' OR ts_status IS NULL') . ')'; |
|
449 | + $filter[] = '(ts_status '.($filter['ts_status'] == self::DELETED_STATUS ? '=' : '!= ').self::DELETED_STATUS. |
|
450 | + ($filter['ts_status'] == self::DELETED_STATUS ? '' : ' OR ts_status IS NULL').')'; |
|
451 | 451 | } |
452 | 452 | if (!count($filter['ts_owner'])) |
453 | 453 | { |
@@ -455,15 +455,15 @@ discard block |
||
455 | 455 | $this->summary = array(); |
456 | 456 | return array(); |
457 | 457 | } |
458 | - if ($only_summary==false && $criteria && $this->show_sums) |
|
458 | + if ($only_summary == false && $criteria && $this->show_sums) |
|
459 | 459 | { |
460 | 460 | // if we have a criteria AND intend to show the sums we first query the affected ids, |
461 | 461 | // then we throw away criteria and filter, and replace the filter with the list of ids |
462 | - $ids = parent::search($criteria,'egw_timesheet.ts_id as id','','',$wildcard,$empty,$op,false,$filter,$join); |
|
462 | + $ids = parent::search($criteria, 'egw_timesheet.ts_id as id', '', '', $wildcard, $empty, $op, false, $filter, $join); |
|
463 | 463 | //_debug_array($ids); |
464 | 464 | if (empty($ids)) |
465 | 465 | { |
466 | - $this->summary = array('duration'=>0,'price'=>null,'quantity'=>0); |
|
466 | + $this->summary = array('duration'=>0, 'price'=>null, 'quantity'=>0); |
|
467 | 467 | return array(); |
468 | 468 | } |
469 | 469 | unset($criteria); |
@@ -487,45 +487,45 @@ discard block |
||
487 | 487 | |
488 | 488 | if ($only_summary) return $this->summary; |
489 | 489 | |
490 | - if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start |
|
490 | + if ($this->show_sums && strpos($order_by, 'ts_start') !== false && // sums only make sense if ordered by ts_start |
|
491 | 491 | $this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start'))) |
492 | 492 | { |
493 | 493 | $sum_sql = array( |
494 | - 'year' => $this->db->date_format($from_unixtime_ts_start,'%Y'), |
|
495 | - 'month' => $this->db->date_format($from_unixtime_ts_start,'%Y%m'), |
|
496 | - 'week' => $this->db->date_format($from_unixtime_ts_start,$GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'), |
|
497 | - 'day' => $this->db->date_format($from_unixtime_ts_start,'%Y-%m-%d'), |
|
494 | + 'year' => $this->db->date_format($from_unixtime_ts_start, '%Y'), |
|
495 | + 'month' => $this->db->date_format($from_unixtime_ts_start, '%Y%m'), |
|
496 | + 'week' => $this->db->date_format($from_unixtime_ts_start, $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'] == 'Sunday' ? '%X%V' : '%x%v'), |
|
497 | + 'day' => $this->db->date_format($from_unixtime_ts_start, '%Y-%m-%d'), |
|
498 | 498 | ); |
499 | - foreach($this->show_sums as $type) |
|
499 | + foreach ($this->show_sums as $type) |
|
500 | 500 | { |
501 | 501 | $extra_cols[] = $sum_sql[$type].' AS ts_'.$type; |
502 | 502 | $extra_cols[] = '0 AS is_sum_'.$type; |
503 | - $sum_extra_cols[] = str_replace('ts_start','MIN(ts_start)',$sum_sql[$type]); // as we dont group by ts_start |
|
503 | + $sum_extra_cols[] = str_replace('ts_start', 'MIN(ts_start)', $sum_sql[$type]); // as we dont group by ts_start |
|
504 | 504 | $sum_extra_cols[$type] = '0 AS is_sum_'.$type; |
505 | 505 | } |
506 | 506 | // regular entries |
507 | - parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); |
|
507 | + parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count); |
|
508 | 508 | |
509 | - $sort = substr($order_by,8); |
|
509 | + $sort = substr($order_by, 8); |
|
510 | 510 | $union_order = array(); |
511 | - $sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0); |
|
512 | - foreach($this->show_sums as $type) |
|
511 | + $sum_ts_id = array('year' => -3, 'month' => -2, 'week' => -1, 'day' => 0); |
|
512 | + foreach ($this->show_sums as $type) |
|
513 | 513 | { |
514 | - $union_order[] = 'ts_'.$type . ' ' . $sort; |
|
514 | + $union_order[] = 'ts_'.$type.' '.$sort; |
|
515 | 515 | $union_order[] = 'is_sum_'.$type; |
516 | 516 | $sum_extra_cols[$type]{0} = '1'; |
517 | 517 | // the $type sum |
518 | - parent::search($criteria,array( |
|
519 | - (string)$sum_ts_id[$type],"''","''","''",'MIN(ts_start)','SUM(ts_duration) AS ts_duration', |
|
518 | + parent::search($criteria, array( |
|
519 | + (string)$sum_ts_id[$type], "''", "''", "''", 'MIN(ts_start)', 'SUM(ts_duration) AS ts_duration', |
|
520 | 520 | ($this->quantity_sum ? "SUM(ts_quantity) AS ts_quantity" : '0'), |
521 | - '0','NULL','0','0','0','0','0',"SUM($total_sql) AS ts_total" |
|
522 | - ),'GROUP BY '.$sum_sql[$type],$sum_extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count); |
|
521 | + '0', 'NULL', '0', '0', '0', '0', '0', "SUM($total_sql) AS ts_total" |
|
522 | + ), 'GROUP BY '.$sum_sql[$type], $sum_extra_cols, $wildcard, $empty, $op, 'UNION', $filter, $join, $need_full_no_count); |
|
523 | 523 | $sum_extra_cols[$type]{0} = '0'; |
524 | 524 | } |
525 | 525 | $union_order[] = 'ts_start '.$sort; |
526 | - return parent::search('','',implode(',',$union_order),'','',false,'',$start); |
|
526 | + return parent::search('', '', implode(',', $union_order), '', '', false, '', $start); |
|
527 | 527 | } |
528 | - return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count); |
|
528 | + return parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -535,16 +535,16 @@ discard block |
||
535 | 535 | * @param boolean $ignore_acl =false should the Acl be checked |
536 | 536 | * @return array|boolean array with timesheet entry, null if timesheet not found or false if no rights |
537 | 537 | */ |
538 | - function read($ts_id,$ignore_acl=false) |
|
538 | + function read($ts_id, $ignore_acl = false) |
|
539 | 539 | { |
540 | 540 | //error_log(__METHOD__."($ts_id,$ignore_acl) ".function_backtrace()); |
541 | 541 | if (!(int)$ts_id || (int)$ts_id != $this->data['ts_id'] && !parent::read($ts_id)) |
542 | 542 | { |
543 | - return null; // entry not found |
|
543 | + return null; // entry not found |
|
544 | 544 | } |
545 | 545 | if (!$ignore_acl && !($ret = $this->check_acl(Acl::READ))) |
546 | 546 | { |
547 | - return false; // no read rights |
|
547 | + return false; // no read rights |
|
548 | 548 | } |
549 | 549 | return $this->data; |
550 | 550 | } |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | * @param boolean $ignore_acl =false should the Acl be checked, returns true if no edit-rigts |
560 | 560 | * @return int 0 on success and errno != 0 else |
561 | 561 | */ |
562 | - function save($keys=null,$touch_modified=true,$ignore_acl=false) |
|
562 | + function save($keys = null, $touch_modified = true, $ignore_acl = false) |
|
563 | 563 | { |
564 | 564 | if ($keys) $this->data_merge($keys); |
565 | 565 | |
@@ -577,13 +577,13 @@ discard block |
||
577 | 577 | // check if we have a real modification of an existing record |
578 | 578 | if ($this->data['ts_id']) |
579 | 579 | { |
580 | - $new =& $this->data; |
|
580 | + $new = & $this->data; |
|
581 | 581 | unset($this->data); |
582 | 582 | $this->read($new['ts_id']); |
583 | - $old =& $this->data; |
|
584 | - $this->data =& $new; |
|
583 | + $old = & $this->data; |
|
584 | + $this->data = & $new; |
|
585 | 585 | $changed = array(); |
586 | - if (isset($old)) foreach($old as $name => $value) |
|
586 | + if (isset($old)) foreach ($old as $name => $value) |
|
587 | 587 | { |
588 | 588 | if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; |
589 | 589 | } |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | } |
595 | 595 | |
596 | 596 | // Check for restore of deleted contact, restore held links |
597 | - if($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS) |
|
597 | + if ($old && $old['ts_status'] == self::DELETED_STATUS && $new['ts_status'] != self::DELETED_STATUS) |
|
598 | 598 | { |
599 | 599 | Link::restore(TIMESHEET_APP, $new['ts_id']); |
600 | 600 | } |
@@ -605,14 +605,14 @@ discard block |
||
605 | 605 | |
606 | 606 | $this->tracking->html_content_allow = true; |
607 | 607 | } |
608 | - if ($this->tracking->track($this->data,$old,$this->user) === false) |
|
608 | + if ($this->tracking->track($this->data, $old, $this->user) === false) |
|
609 | 609 | { |
610 | - return implode(', ',$this->tracking->errors); |
|
610 | + return implode(', ', $this->tracking->errors); |
|
611 | 611 | } |
612 | 612 | if (!($err = parent::save())) |
613 | 613 | { |
614 | 614 | // notify the link-class about the update, as other apps may be subscribt to it |
615 | - Link::notify_update(TIMESHEET_APP,$this->data['ts_id'],$this->data); |
|
615 | + Link::notify_update(TIMESHEET_APP, $this->data['ts_id'], $this->data); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | return $err; |
@@ -625,15 +625,15 @@ discard block |
||
625 | 625 | * @param boolean $ignore_acl =false should the Acl be checked, returns false if no delete-rigts |
626 | 626 | * @return int affected rows, should be 1 if ok, 0 if an error |
627 | 627 | */ |
628 | - function delete($keys=null,$ignore_acl=false) |
|
628 | + function delete($keys = null, $ignore_acl = false) |
|
629 | 629 | { |
630 | - if (!is_array($keys) && (int) $keys) |
|
630 | + if (!is_array($keys) && (int)$keys) |
|
631 | 631 | { |
632 | - $keys = array('ts_id' => (int) $keys); |
|
632 | + $keys = array('ts_id' => (int)$keys); |
|
633 | 633 | } |
634 | 634 | $ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id']; |
635 | 635 | |
636 | - if (!$ignore_acl && !$this->check_acl(Acl::DELETE,$ts_id) || !($old = $this->read($ts_id))) |
|
636 | + if (!$ignore_acl && !$this->check_acl(Acl::DELETE, $ts_id) || !($old = $this->read($ts_id))) |
|
637 | 637 | { |
638 | 638 | return false; |
639 | 639 | } |
@@ -644,12 +644,12 @@ discard block |
||
644 | 644 | $delete = $old; |
645 | 645 | $delete['ts_status'] = self::DELETED_STATUS; |
646 | 646 | $ret = !($this->save($delete)); |
647 | - Link::unlink(0,TIMESHEET_APP,$ts_id,'','','',true); |
|
647 | + Link::unlink(0, TIMESHEET_APP, $ts_id, '', '', '', true); |
|
648 | 648 | } |
649 | 649 | elseif (($ret = parent::delete($keys)) && $ts_id) |
650 | 650 | { |
651 | 651 | // delete all links to timesheet entry $ts_id |
652 | - Link::unlink(0,TIMESHEET_APP,$ts_id); |
|
652 | + Link::unlink(0, TIMESHEET_APP, $ts_id); |
|
653 | 653 | } |
654 | 654 | return $ret; |
655 | 655 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | function deleteaccount($data) |
665 | 665 | { |
666 | 666 | $account_id = $data['account_id']; |
667 | - $new_owner = $data['new_owner']; |
|
667 | + $new_owner = $data['new_owner']; |
|
668 | 668 | |
669 | 669 | if (!$new_owner) |
670 | 670 | { |
@@ -688,22 +688,22 @@ discard block |
||
688 | 688 | * @param int $status =0 |
689 | 689 | * @return int affected rows, should be 1 if ok, 0 if an error |
690 | 690 | */ |
691 | - function set_status($keys=null, $status=0) |
|
691 | + function set_status($keys = null, $status = 0) |
|
692 | 692 | { |
693 | 693 | $ret = true; |
694 | - if (!is_array($keys) && (int) $keys) |
|
694 | + if (!is_array($keys) && (int)$keys) |
|
695 | 695 | { |
696 | - $keys = array('ts_id' => (int) $keys); |
|
696 | + $keys = array('ts_id' => (int)$keys); |
|
697 | 697 | } |
698 | 698 | $ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id']; |
699 | 699 | |
700 | - if (!$this->check_acl(Acl::EDIT,$ts_id) || !$this->read($ts_id,true)) |
|
700 | + if (!$this->check_acl(Acl::EDIT, $ts_id) || !$this->read($ts_id, true)) |
|
701 | 701 | { |
702 | 702 | return false; |
703 | 703 | } |
704 | 704 | |
705 | 705 | $this->data['ts_status'] = $status; |
706 | - if ($this->save($ts_id)!=0) $ret = false; |
|
706 | + if ($this->save($ts_id) != 0) $ret = false; |
|
707 | 707 | |
708 | 708 | return $ret; |
709 | 709 | } |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | { |
721 | 721 | return array('duration' => 0, 'quantity' => 0, 'price' => 0, 'max_modified' => null); |
722 | 722 | } |
723 | - return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true); |
|
723 | + return $this->search(array('ts_id'=>$ids), true, '', '', '', false, 'AND', false, null, '', false, true); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
@@ -731,27 +731,27 @@ discard block |
||
731 | 731 | * @param int|array $entry int ts_id or array with timesheet entry |
732 | 732 | * @return string/boolean string with title, null if timesheet not found, false if no perms to view it |
733 | 733 | */ |
734 | - function link_title( $entry ) |
|
734 | + function link_title($entry) |
|
735 | 735 | { |
736 | 736 | if (!is_array($entry)) |
737 | 737 | { |
738 | 738 | // need to preserve the $this->data |
739 | - $backup =& $this->data; |
|
739 | + $backup = & $this->data; |
|
740 | 740 | unset($this->data); |
741 | - $entry = $this->read( $entry,false,false); |
|
741 | + $entry = $this->read($entry, false, false); |
|
742 | 742 | // restore the data again |
743 | - $this->data =& $backup; |
|
743 | + $this->data = & $backup; |
|
744 | 744 | } |
745 | 745 | if (!$entry) |
746 | 746 | { |
747 | 747 | return $entry; |
748 | 748 | } |
749 | 749 | $format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
750 | - if (date('H:i',$entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
750 | + if (date('H:i', $entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
751 | 751 | { |
752 | 752 | $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'); |
753 | 753 | } |
754 | - return date($format,$entry['ts_start']).': '.$entry['ts_title']; |
|
754 | + return date($format, $entry['ts_start']).': '.$entry['ts_title']; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -762,18 +762,18 @@ discard block |
||
762 | 762 | * @param array $ids array with ts_id's |
763 | 763 | * @return array with titles, see link_title |
764 | 764 | */ |
765 | - function link_titles( array $ids ) |
|
765 | + function link_titles(array $ids) |
|
766 | 766 | { |
767 | 767 | $titles = array(); |
768 | - if (($entries = $this->search(array('ts_id' => $ids),'ts_id,ts_title,ts_start'))) |
|
768 | + if (($entries = $this->search(array('ts_id' => $ids), 'ts_id,ts_title,ts_start'))) |
|
769 | 769 | { |
770 | - foreach($entries as $entry) |
|
770 | + foreach ($entries as $entry) |
|
771 | 771 | { |
772 | 772 | $titles[$entry['ts_id']] = $this->link_title($entry); |
773 | 773 | } |
774 | 774 | } |
775 | 775 | // we assume all not returned entries are not readable by the user, as we notify Link about all deletes |
776 | - foreach($ids as $id) |
|
776 | + foreach ($ids as $id) |
|
777 | 777 | { |
778 | 778 | if (!isset($titles[$id])) |
779 | 779 | { |
@@ -792,16 +792,16 @@ discard block |
||
792 | 792 | * @param array $options Array of options for the search |
793 | 793 | * @return array with ts_id - title pairs of the matching entries |
794 | 794 | */ |
795 | - function link_query( $pattern, Array &$options = array() ) |
|
795 | + function link_query($pattern, Array &$options = array()) |
|
796 | 796 | { |
797 | 797 | $limit = false; |
798 | 798 | $need_count = false; |
799 | - if($options['start'] || $options['num_rows']) { |
|
799 | + if ($options['start'] || $options['num_rows']) { |
|
800 | 800 | $limit = array($options['start'], $options['num_rows']); |
801 | 801 | $need_count = true; |
802 | 802 | } |
803 | 803 | $result = array(); |
804 | - foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts ) |
|
804 | + foreach ((array)$this->search($pattern, false, '', '', '%', false, 'OR', $limit, null, '', $need_count) as $ts) |
|
805 | 805 | { |
806 | 806 | if ($ts) $result[$ts['ts_id']] = $this->link_title($ts); |
807 | 807 | } |
@@ -818,11 +818,11 @@ discard block |
||
818 | 818 | * @param int $user =null for which user to check, default current user |
819 | 819 | * @return boolean true if access is granted or false otherwise |
820 | 820 | */ |
821 | - function file_access($id,$check,$rel_path=null,$user=null) |
|
821 | + function file_access($id, $check, $rel_path = null, $user = null) |
|
822 | 822 | { |
823 | - unset($rel_path); // not used, but required by function signature |
|
823 | + unset($rel_path); // not used, but required by function signature |
|
824 | 824 | |
825 | - return $this->check_acl($check,$id,$user); |
|
825 | + return $this->check_acl($check, $id, $user); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -834,16 +834,16 @@ discard block |
||
834 | 834 | * @param string $newtitle => the new title of the project |
835 | 835 | * @return boolean true for success, false for invalid parameters |
836 | 836 | */ |
837 | - function update_ts_project($oldtitle='', $newtitle='') |
|
837 | + function update_ts_project($oldtitle = '', $newtitle = '') |
|
838 | 838 | { |
839 | - if(strlen($oldtitle) > 0 && strlen($newtitle) > 0) |
|
839 | + if (strlen($oldtitle) > 0 && strlen($newtitle) > 0) |
|
840 | 840 | { |
841 | - $this->db->update('egw_timesheet',array( |
|
841 | + $this->db->update('egw_timesheet', array( |
|
842 | 842 | 'ts_project' => $newtitle, |
843 | 843 | 'ts_title' => $newtitle, |
844 | - ),array( |
|
844 | + ), array( |
|
845 | 845 | 'ts_project' => $oldtitle, |
846 | - ),__LINE__,__FILE__,TIMESHEET_APP); |
|
846 | + ), __LINE__, __FILE__, TIMESHEET_APP); |
|
847 | 847 | |
848 | 848 | return true; |
849 | 849 | } |
@@ -856,16 +856,16 @@ discard block |
||
856 | 856 | * @param int $pm_id ID of selected project |
857 | 857 | * @return array containing link_id and ts_id |
858 | 858 | */ |
859 | - function get_ts_links($pm_id=0) |
|
859 | + function get_ts_links($pm_id = 0) |
|
860 | 860 | { |
861 | - if($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
861 | + if ($pm_id && isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) |
|
862 | 862 | { |
863 | - $pm_ids = ExecMethod('projectmanager.projectmanager_bo.children',$pm_id); |
|
863 | + $pm_ids = ExecMethod('projectmanager.projectmanager_bo.children', $pm_id); |
|
864 | 864 | $pm_ids[] = $pm_id; |
865 | - $links = Link\Storage::get_links('projectmanager',$pm_ids,'timesheet'); // Link\Storage::get_links not egw_links::get_links! |
|
865 | + $links = Link\Storage::get_links('projectmanager', $pm_ids, 'timesheet'); // Link\Storage::get_links not egw_links::get_links! |
|
866 | 866 | if ($links) |
867 | 867 | { |
868 | - $links = array_unique(call_user_func_array('array_merge',$links)); |
|
868 | + $links = array_unique(call_user_func_array('array_merge', $links)); |
|
869 | 869 | } |
870 | 870 | return $links; |
871 | 871 | } |
@@ -883,17 +883,17 @@ discard block |
||
883 | 883 | function notify($data) |
884 | 884 | { |
885 | 885 | //error_log(__METHOD__.'('.array2string($data).')'); |
886 | - $backup =& $this->data; // backup internal data in case class got re-used by ExecMethod |
|
886 | + $backup = & $this->data; // backup internal data in case class got re-used by ExecMethod |
|
887 | 887 | unset($this->data); |
888 | 888 | |
889 | 889 | if ($data['target_app'] == 'projectmanager' && $this->read($data['id'])) |
890 | 890 | { |
891 | 891 | $old_title = isset($data['data']) ? $data['data'][Link::OLD_LINK_TITLE] : null; |
892 | - switch($data['type']) |
|
892 | + switch ($data['type']) |
|
893 | 893 | { |
894 | 894 | case 'link': |
895 | 895 | case 'update': |
896 | - if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one |
|
896 | + if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one |
|
897 | 897 | isset($old_title) && $this->data['ts_project'] === $old_title) |
898 | 898 | { |
899 | 899 | $pm_id = $data['target_id']; |
@@ -935,17 +935,17 @@ discard block |
||
935 | 935 | * @param array $data =null if given works on that array and returns result, else works on internal data-array |
936 | 936 | * @return array |
937 | 937 | */ |
938 | - function db2data($data=null) |
|
938 | + function db2data($data = null) |
|
939 | 939 | { |
940 | 940 | if (($intern = !is_array($data))) |
941 | 941 | { |
942 | - $data =& $this->data; |
|
942 | + $data = & $this->data; |
|
943 | 943 | } |
944 | 944 | // get pm_id from links and ts_project: either project matching ts_project or first found project |
945 | 945 | if (!isset($data['pm_id']) && $data['ts_id']) |
946 | 946 | { |
947 | 947 | $first_pm_id = null; |
948 | - foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
|
948 | + foreach (Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
|
949 | 949 | { |
950 | 950 | if (!isset($first_pm_id)) $first_pm_id = $pm_id; |
951 | 951 | if ($data['ts_project'] == Link::title('projectmanager', $pm_id)) |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | $data['ts_project_blur'] = $data['ts_project']; |
964 | 964 | $data['ts_project'] = ''; |
965 | 965 | } |
966 | - return parent::db2data($intern ? null : $data); // important to use null, if $intern! |
|
966 | + return parent::db2data($intern ? null : $data); // important to use null, if $intern! |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
@@ -975,17 +975,17 @@ discard block |
||
975 | 975 | * @param array $data =null if given works on that array and returns result, else works on internal data-array |
976 | 976 | * @return array |
977 | 977 | */ |
978 | - function data2db($data=null) |
|
978 | + function data2db($data = null) |
|
979 | 979 | { |
980 | 980 | if (($intern = !is_array($data))) |
981 | 981 | { |
982 | - $data =& $this->data; |
|
982 | + $data = & $this->data; |
|
983 | 983 | } |
984 | 984 | // allways store ts_project to be able to search for it, even if no custom project is set |
985 | 985 | if (empty($data['ts_project']) && !is_null($data['ts_project'])) |
986 | 986 | { |
987 | 987 | $data['ts_project'] = $data['pm_id'] ? Link::title('projectmanager', $data['pm_id']) : ''; |
988 | 988 | } |
989 | - return parent::data2db($intern ? null : $data); // important to use null, if $intern! |
|
989 | + return parent::data2db($intern ? null : $data); // important to use null, if $intern! |
|
990 | 990 | } |
991 | 991 | } |
@@ -167,12 +167,18 @@ discard block |
||
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 |
||
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 |
||
243 | 253 | */ |
244 | 254 | function get_sub_status($status) |
245 | 255 | { |
246 | - if (!isset($this->status_labels_config)) $this->load_statuses(); |
|
256 | + if (!isset($this->status_labels_config)) |
|
257 | + { |
|
258 | + $this->load_statuses(); |
|
259 | + } |
|
247 | 260 | $stati = array($status); |
248 | 261 | foreach($this->status_labels_config as $stat) |
249 | 262 | { |
@@ -319,9 +332,16 @@ discard block |
||
319 | 332 | $data = $this->read($data,true); |
320 | 333 | $this->data = $save_data; |
321 | 334 | |
322 | - if (!$data) return null; // entry not found |
|
335 | + if (!$data) |
|
336 | + { |
|
337 | + return null; |
|
338 | + } |
|
339 | + // entry not found |
|
340 | + } |
|
341 | + if (!$user) |
|
342 | + { |
|
343 | + $user = $this->user; |
|
323 | 344 | } |
324 | - if (!$user) $user = $this->user; |
|
325 | 345 | if (!isset($GLOBALS['egw_info']['user']['apps']['admin']) && $data['ts_status']) |
326 | 346 | { |
327 | 347 | if ($this->status_labels_config[$data['ts_status']]['admin']) |
@@ -354,9 +374,16 @@ discard block |
||
354 | 374 | $data = $this->read($data,true); |
355 | 375 | $this->data = $save_data; |
356 | 376 | |
357 | - if (!$data) return null; // entry not found |
|
377 | + if (!$data) |
|
378 | + { |
|
379 | + return null; |
|
380 | + } |
|
381 | + // entry not found |
|
382 | + } |
|
383 | + if (!$user) |
|
384 | + { |
|
385 | + $user = $this->user; |
|
358 | 386 | } |
359 | - if (!$user) $user = $this->user; |
|
360 | 387 | if ($user == $this->user) |
361 | 388 | { |
362 | 389 | $grants = $this->grants; |
@@ -430,7 +457,10 @@ discard block |
||
430 | 457 | } |
431 | 458 | else |
432 | 459 | { |
433 | - if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']); |
|
460 | + if (!is_array($filter['ts_owner'])) |
|
461 | + { |
|
462 | + $filter['ts_owner'] = array($filter['ts_owner']); |
|
463 | + } |
|
434 | 464 | |
435 | 465 | foreach($filter['ts_owner'] as $key => $owner) |
436 | 466 | { |
@@ -485,7 +515,10 @@ discard block |
||
485 | 515 | $this->summary = $this->summary[0]; |
486 | 516 | $this->summary['max_modified'] = Api\DateTime::server2user($this->summary['max_modified']); |
487 | 517 | |
488 | - if ($only_summary) return $this->summary; |
|
518 | + if ($only_summary) |
|
519 | + { |
|
520 | + return $this->summary; |
|
521 | + } |
|
489 | 522 | |
490 | 523 | if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start |
491 | 524 | $this->db->capabilities['union'] && ($from_unixtime_ts_start = $this->db->from_unixtime('ts_start'))) |
@@ -561,7 +594,10 @@ discard block |
||
561 | 594 | */ |
562 | 595 | function save($keys=null,$touch_modified=true,$ignore_acl=false) |
563 | 596 | { |
564 | - if ($keys) $this->data_merge($keys); |
|
597 | + if ($keys) |
|
598 | + { |
|
599 | + $this->data_merge($keys); |
|
600 | + } |
|
565 | 601 | |
566 | 602 | if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(Acl::EDIT)) |
567 | 603 | { |
@@ -583,10 +619,13 @@ discard block |
||
583 | 619 | $old =& $this->data; |
584 | 620 | $this->data =& $new; |
585 | 621 | $changed = array(); |
586 | - if (isset($old)) foreach($old as $name => $value) |
|
622 | + if (isset($old)) |
|
623 | + { |
|
624 | + foreach($old as $name => $value) |
|
587 | 625 | { |
588 | 626 | if (isset($new[$name]) && $new[$name] != $value) $changed[] = $name; |
589 | 627 | } |
628 | + } |
|
590 | 629 | } |
591 | 630 | if (isset($old) && !$changed) |
592 | 631 | { |
@@ -703,7 +742,10 @@ discard block |
||
703 | 742 | } |
704 | 743 | |
705 | 744 | $this->data['ts_status'] = $status; |
706 | - if ($this->save($ts_id)!=0) $ret = false; |
|
745 | + if ($this->save($ts_id)!=0) |
|
746 | + { |
|
747 | + $ret = false; |
|
748 | + } |
|
707 | 749 | |
708 | 750 | return $ret; |
709 | 751 | } |
@@ -747,10 +789,13 @@ discard block |
||
747 | 789 | return $entry; |
748 | 790 | } |
749 | 791 | $format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
750 | - if (date('H:i',$entry['ts_start']) != '00:00') // dont show 00:00 time, as it means date only |
|
792 | + if (date('H:i',$entry['ts_start']) != '00:00') |
|
793 | + { |
|
794 | + // dont show 00:00 time, as it means date only |
|
751 | 795 | { |
752 | 796 | $format .= ' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'); |
753 | 797 | } |
798 | + } |
|
754 | 799 | return date($format,$entry['ts_start']).': '.$entry['ts_title']; |
755 | 800 | } |
756 | 801 | |
@@ -796,14 +841,18 @@ discard block |
||
796 | 841 | { |
797 | 842 | $limit = false; |
798 | 843 | $need_count = false; |
799 | - if($options['start'] || $options['num_rows']) { |
|
844 | + if($options['start'] || $options['num_rows']) |
|
845 | + { |
|
800 | 846 | $limit = array($options['start'], $options['num_rows']); |
801 | 847 | $need_count = true; |
802 | 848 | } |
803 | 849 | $result = array(); |
804 | 850 | foreach((array) $this->search($pattern,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts ) |
805 | 851 | { |
806 | - if ($ts) $result[$ts['ts_id']] = $this->link_title($ts); |
|
852 | + if ($ts) |
|
853 | + { |
|
854 | + $result[$ts['ts_id']] = $this->link_title($ts); |
|
855 | + } |
|
807 | 856 | } |
808 | 857 | $options['total'] = $need_count ? $this->total : count($result); |
809 | 858 | return $result; |
@@ -922,7 +971,10 @@ discard block |
||
922 | 971 | //error_log(__METHOD__."() setting pm_id=$pm_id --> ".array2string($update)); |
923 | 972 | } |
924 | 973 | } |
925 | - if ($backup) $this->data = $backup; |
|
974 | + if ($backup) |
|
975 | + { |
|
976 | + $this->data = $backup; |
|
977 | + } |
|
926 | 978 | } |
927 | 979 | |
928 | 980 | |
@@ -947,7 +999,10 @@ discard block |
||
947 | 999 | $first_pm_id = null; |
948 | 1000 | foreach(Link::get_links('timesheet', $data['ts_id'], 'projectmanager') as $pm_id) |
949 | 1001 | { |
950 | - if (!isset($first_pm_id)) $first_pm_id = $pm_id; |
|
1002 | + if (!isset($first_pm_id)) |
|
1003 | + { |
|
1004 | + $first_pm_id = $pm_id; |
|
1005 | + } |
|
951 | 1006 | if ($data['ts_project'] == Link::title('projectmanager', $pm_id)) |
952 | 1007 | { |
953 | 1008 | $data['pm_id'] = $pm_id; |
@@ -956,7 +1011,10 @@ discard block |
||
956 | 1011 | break; |
957 | 1012 | } |
958 | 1013 | } |
959 | - if (!isset($data['pm_id']) && isset($first_pm_id)) $data['pm_id'] = $first_pm_id; |
|
1014 | + if (!isset($data['pm_id']) && isset($first_pm_id)) |
|
1015 | + { |
|
1016 | + $data['pm_id'] = $first_pm_id; |
|
1017 | + } |
|
960 | 1018 | } |
961 | 1019 | elseif ($data['ts_id'] && $data['pm_id'] && Link::title('projectmanager', $data['pm_id']) == $data['ts_project']) |
962 | 1020 | { |
@@ -572,7 +572,7 @@ |
||
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 | { |
@@ -83,7 +83,7 @@ |
||
83 | 83 | * @param array $element source project element representing an InfoLog entry, $element['pe_app_id'] = info_id |
84 | 84 | * @param int $target target project id |
85 | 85 | * @param array $extra =null data of target-project, atm not used by the infolog datasource |
86 | - * @return array|boolean array(info_id,link_id) on success, false otherwise |
|
86 | + * @return boolean array(info_id,link_id) on success, false otherwise |
|
87 | 87 | */ |
88 | 88 | function copy($element,$target,$extra=null) |
89 | 89 | { |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | } |
44 | 44 | if (!is_array($data_id)) |
45 | 45 | { |
46 | - if (!(int) $data_id || !($data = $GLOBALS['timesheet_bo']->read((int) $data_id))) |
|
46 | + if (!(int)$data_id || !($data = $GLOBALS['timesheet_bo']->read((int)$data_id))) |
|
47 | 47 | { |
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | else |
52 | 52 | { |
53 | - $data =& $data_id; |
|
53 | + $data = & $data_id; |
|
54 | 54 | } |
55 | 55 | $ds = array( |
56 | 56 | 'pe_title' => $GLOBALS['timesheet_bo']->link_title($data), |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ); |
67 | 67 | if ($data['ts_duration']) |
68 | 68 | { |
69 | - $ds['pe_real_end'] = $data['ts_start'] + 60*$data['ts_duration']; |
|
69 | + $ds['pe_real_end'] = $data['ts_start'] + 60 * $data['ts_duration']; |
|
70 | 70 | $ds['pe_used_time'] = $data['ts_duration']; |
71 | 71 | } |
72 | 72 | if ($this->debug) |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @param array $extra =null data of target-project, atm not used by the infolog datasource |
86 | 86 | * @return array|boolean array(info_id,link_id) on success, false otherwise |
87 | 87 | */ |
88 | - function copy($element,$target,$extra=null) |
|
88 | + function copy($element, $target, $extra = null) |
|
89 | 89 | { |
90 | - unset($element,$target,$extra); // not used, but required by function signature |
|
90 | + unset($element, $target, $extra); // not used, but required by function signature |
|
91 | 91 | |
92 | 92 | return false; |
93 | 93 | } |
@@ -25,7 +25,7 @@ discard block |
||
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 |
||
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; |
@@ -125,8 +125,8 @@ |
||
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. |
@@ -27,51 +27,51 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @param egw_record $_definition |
29 | 29 | */ |
30 | - public function export( $_stream, importexport_definition $_definition) { |
|
30 | + public function export($_stream, importexport_definition $_definition) { |
|
31 | 31 | $options = $_definition->plugin_options; |
32 | 32 | |
33 | 33 | $this->ui = new timesheet_ui(); |
34 | 34 | $selection = array(); |
35 | 35 | |
36 | - if($options['selection'] == 'search') { |
|
37 | - $query = $GLOBALS['egw']->session->appsession('index',TIMESHEET_APP); |
|
38 | - $query['num_rows'] = -1; // all records |
|
39 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
40 | - $this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
|
41 | - } elseif($options['selection'] == 'all') { |
|
36 | + if ($options['selection'] == 'search') { |
|
37 | + $query = $GLOBALS['egw']->session->appsession('index', TIMESHEET_APP); |
|
38 | + $query['num_rows'] = -1; // all records |
|
39 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
40 | + $this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's |
|
41 | + } elseif ($options['selection'] == 'all') { |
|
42 | 42 | $query = array( |
43 | 43 | 'num_rows' => -1, |
44 | - 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
44 | + 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
45 | 45 | ); |
46 | - $this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
|
46 | + $this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's |
|
47 | 47 | } |
48 | - else if($options['selection'] == 'filter') |
|
48 | + else if ($options['selection'] == 'filter') |
|
49 | 49 | { |
50 | 50 | $fields = importexport_helper_functions::get_filter_fields($_definition->application, $this); |
51 | 51 | $filter = $_definition->filter; |
52 | 52 | $query = array( |
53 | 53 | 'num_rows' => -1, |
54 | - 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
54 | + 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
55 | 55 | 'col_filter' => array() |
56 | 56 | ); |
57 | 57 | |
58 | 58 | // Handle ranges |
59 | - foreach($filter as $field => $value) |
|
59 | + foreach ($filter as $field => $value) |
|
60 | 60 | { |
61 | - if($field == 'cat_id') |
|
61 | + if ($field == 'cat_id') |
|
62 | 62 | { |
63 | 63 | $query['cat_id'] = $value; |
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | $query['col_filter'][$field] = $value; |
67 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
67 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
68 | 68 | |
69 | 69 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
70 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
71 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
70 | + if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from']; |
|
71 | + if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to']; |
|
72 | 72 | unset($query['col_filter'][$field]); |
73 | 73 | } |
74 | - $this->ui->get_rows($query,$selection,$readonlys,true); // true = only return the id's |
|
74 | + $this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | // support other selectors atm. |
84 | 84 | foreach ($selection as $identifier) { |
85 | 85 | $record = new timesheet_egw_record($identifier); |
86 | - if($options['convert']) { |
|
86 | + if ($options['convert']) { |
|
87 | 87 | importexport_export_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $this->selects); |
88 | 88 | } else { |
89 | 89 | // Implode arrays, so they don't say 'Array' |
90 | - foreach($record->get_record_array() as $key => $value) { |
|
91 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
90 | + foreach ($record->get_record_array() as $key => $value) { |
|
91 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | $export_object->export_record($record); |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | public function get_selects() |
152 | 152 | { |
153 | 153 | $this->selects = array( |
154 | - 'ts_status' => $this->ui->status_labels+array(lang('No status')) |
|
154 | + 'ts_status' => $this->ui->status_labels + array(lang('No status')) |
|
155 | 155 | ); |
156 | - foreach($this->selects['ts_status'] as &$status) { |
|
157 | - $status = str_replace(' ','',$status); // Remove |
|
156 | + foreach ($this->selects['ts_status'] as &$status) { |
|
157 | + $status = str_replace(' ', '', $status); // Remove |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function get_filter_fields(Array &$filters) |
165 | 165 | { |
166 | - foreach($filters as $field_name => &$settings) |
|
166 | + foreach ($filters as $field_name => &$settings) |
|
167 | 167 | { |
168 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
168 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |
@@ -14,7 +14,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(' ','',$status); // Remove |
158 | 187 | } |
159 | 188 | |
@@ -165,7 +194,10 @@ discard block |
||
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 |
@@ -247,7 +247,7 @@ |
||
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 | { |
@@ -86,8 +86,6 @@ |
||
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 | { |
@@ -28,7 +28,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -76,9 +76,12 @@ |
||
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 | } |
@@ -49,7 +49,7 @@ |
||
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 |