@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | 'php' => '/usr/bin/php', |
19 | 19 | 'source_dir' => '/usr/share/egroupware', |
20 | 20 | 'data_dir' => '/var/lib/egroupware', |
21 | - 'header' => '$data_dir/header.inc.php', // symlinked to source_dir by rpm |
|
21 | + 'header' => '$data_dir/header.inc.php', // symlinked to source_dir by rpm |
|
22 | 22 | 'setup-cli' => '$source_dir/setup/setup-cli.php', |
23 | 23 | 'domain' => 'default', |
24 | 24 | 'config_user' => 'admin', |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | 'db_user' => 'egroupware', |
31 | 31 | 'db_pass' => randomstring(), |
32 | 32 | 'db_grant_host' => 'localhost', |
33 | - 'db_root' => 'root', // mysql root user/pw to create database |
|
33 | + 'db_root' => 'root', // mysql root user/pw to create database |
|
34 | 34 | 'db_root_pw' => '', |
35 | 35 | 'backup' => '', |
36 | 36 | 'admin_user' => 'sysop', |
37 | 37 | 'admin_passwd'=> randomstring(), |
38 | 38 | 'admin_email' => '', |
39 | - 'lang' => 'en', // languages for admin user and extra lang to install |
|
39 | + 'lang' => 'en', // languages for admin user and extra lang to install |
|
40 | 40 | 'charset' => 'utf-8', |
41 | 41 | 'start_db' => '/sbin/service mysqld', |
42 | 42 | 'autostart_db' => '/sbin/chkconfig --level 345 mysqld on', |
@@ -56,23 +56,23 @@ discard block |
||
56 | 56 | 'ldap_search_filter' => '(uid=%user)', |
57 | 57 | 'ldap_group_context' => 'ou=groups,$base', |
58 | 58 | 'ldap_encryption_type' => '', |
59 | - 'sambaadmin/sambasid'=> '', // SID for sambaadmin |
|
59 | + 'sambaadmin/sambasid'=> '', // SID for sambaadmin |
|
60 | 60 | 'mailserver' => '', |
61 | 61 | 'smtpserver' => 'localhost,25', |
62 | - 'smtp' => '', // see setup-cli.php --help config |
|
62 | + 'smtp' => '', // see setup-cli.php --help config |
|
63 | 63 | 'imap' => '', |
64 | 64 | 'sieve' => '', |
65 | 65 | 'folder' => '', |
66 | - 'install-update-app' => '', // install or update a single (non-default) app |
|
67 | - 'webserver_user'=> 'apache', // required to fix permissions |
|
66 | + 'install-update-app' => '', // install or update a single (non-default) app |
|
67 | + 'webserver_user'=> 'apache', // required to fix permissions |
|
68 | 68 | 'php5enmod' => '', |
69 | 69 | ); |
70 | 70 | |
71 | 71 | // read language from LANG enviroment variable |
72 | 72 | if (($lang = isset($_ENV['LANG']) ? $_ENV['LANG'] : (isset($_SERVER['LANG']) ? $_SERVER['LANG'] : null))) |
73 | 73 | { |
74 | - @list($lang,$nat) = preg_split('/[_.]/',$lang); |
|
75 | - if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw'))) |
|
74 | + @list($lang, $nat) = preg_split('/[_.]/', $lang); |
|
75 | + if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw'))) |
|
76 | 76 | { |
77 | 77 | $lang .= '-'.strtolower($nat); |
78 | 78 | } |
@@ -85,16 +85,13 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param string $distro =null default autodetect |
87 | 87 | */ |
88 | -function set_distro_defaults($distro=null) |
|
88 | +function set_distro_defaults($distro = null) |
|
89 | 89 | { |
90 | 90 | global $config; |
91 | 91 | if (is_null($distro)) |
92 | 92 | { |
93 | - $distro = file_exists('/etc/SuSE-release') ? 'suse' : |
|
94 | - (file_exists('/etc/mandriva-release') ? 'mandriva' : |
|
95 | - (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi', |
|
96 | - file_get_contents('/etc/lsb-release')) ? 'univention' : |
|
97 | - (file_exists('/etc/debian_version') ? 'debian' : 'rh'))); |
|
93 | + $distro = file_exists('/etc/SuSE-release') ? 'suse' : (file_exists('/etc/mandriva-release') ? 'mandriva' : (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi', |
|
94 | + file_get_contents('/etc/lsb-release')) ? 'univention' : (file_exists('/etc/debian_version') ? 'debian' : 'rh'))); |
|
98 | 95 | } |
99 | 96 | switch (($config['distro'] = $distro)) |
100 | 97 | { |
@@ -162,9 +159,9 @@ discard block |
||
162 | 159 | } |
163 | 160 | elseif (!file_exists('/etc/init.d/mysqld') && file_exists('/etc/init.d/mysql')) |
164 | 161 | { |
165 | - foreach(array('start_db','autostart_db') as $name) |
|
162 | + foreach (array('start_db', 'autostart_db') as $name) |
|
166 | 163 | { |
167 | - $config[$name] = str_replace('mysqld','mysql',$config[$name]); |
|
164 | + $config[$name] = str_replace('mysqld', 'mysql', $config[$name]); |
|
168 | 165 | } |
169 | 166 | } |
170 | 167 | break; |
@@ -180,48 +177,48 @@ discard block |
||
180 | 177 | if (($config_set = isset($_ENV['EGW_POST_INSTALL']) ? $_ENV['EGW_POST_INSTALL'] : @$_SERVER['EGW_POST_INSTALL'])) |
181 | 178 | { |
182 | 179 | $conf = array(); |
183 | - $config_set = preg_split('/[ \t]+/',trim($config_set)); |
|
184 | - while($config_set) |
|
180 | + $config_set = preg_split('/[ \t]+/', trim($config_set)); |
|
181 | + while ($config_set) |
|
185 | 182 | { |
186 | 183 | $val = array_shift($config_set); |
187 | 184 | if (($quote = $val[0]) == "'" || $quote == '"') // arguments might be quoted with ' or " |
188 | 185 | { |
189 | - while (substr($val,-1) != $quote) |
|
186 | + while (substr($val, -1) != $quote) |
|
190 | 187 | { |
191 | 188 | if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!'); |
192 | 189 | $val .= ' '.array_shift($config_set); |
193 | 190 | } |
194 | - $val = substr($val,1,-1); |
|
191 | + $val = substr($val, 1, -1); |
|
195 | 192 | } |
196 | 193 | $conf[] = $val; |
197 | 194 | } |
198 | - $argv = array_merge($conf,$argv); |
|
195 | + $argv = array_merge($conf, $argv); |
|
199 | 196 | } |
200 | 197 | |
201 | 198 | $auth_type_given = false; |
202 | -while(($arg = array_shift($argv))) |
|
199 | +while (($arg = array_shift($argv))) |
|
203 | 200 | { |
204 | 201 | if ($arg == '-v' || $arg == '--verbose') |
205 | 202 | { |
206 | 203 | $verbose = true; |
207 | 204 | } |
208 | - elseif($arg == '-h' || $arg == '--help') |
|
205 | + elseif ($arg == '-h' || $arg == '--help') |
|
209 | 206 | { |
210 | 207 | usage(); |
211 | 208 | } |
212 | - elseif($arg == '--suse') |
|
209 | + elseif ($arg == '--suse') |
|
213 | 210 | { |
214 | 211 | set_distro_defaults('suse'); |
215 | 212 | } |
216 | - elseif($arg == '--distro') |
|
213 | + elseif ($arg == '--distro') |
|
217 | 214 | { |
218 | 215 | set_distro_defaults(array_shift($argv)); |
219 | 216 | } |
220 | - elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)])) |
|
217 | + elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)])) |
|
221 | 218 | { |
222 | 219 | $config[$name] = array_shift($argv); |
223 | 220 | |
224 | - switch($name) |
|
221 | + switch ($name) |
|
225 | 222 | { |
226 | 223 | case 'auth_type': |
227 | 224 | $auth_type_given = true; |
@@ -242,18 +239,18 @@ discard block |
||
242 | 239 | } |
243 | 240 | |
244 | 241 | $replace = array(); |
245 | -foreach($config as $name => $value) |
|
242 | +foreach ($config as $name => $value) |
|
246 | 243 | { |
247 | 244 | $replace['$'.$name] = $value; |
248 | - if (strpos($value,'$') !== false) |
|
245 | + if (strpos($value, '$') !== false) |
|
249 | 246 | { |
250 | - $config[$name] = strtr($value,$replace); |
|
247 | + $config[$name] = strtr($value, $replace); |
|
251 | 248 | } |
252 | 249 | } |
253 | 250 | // basic config checks |
254 | -foreach(array('php','source_dir','data_dir','setup-cli') as $name) |
|
251 | +foreach (array('php', 'source_dir', 'data_dir', 'setup-cli') as $name) |
|
255 | 252 | { |
256 | - if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!'); |
|
253 | + if (!file_exists($config[$name])) bail_out(1, $config[$name].' not found!'); |
|
257 | 254 | } |
258 | 255 | |
259 | 256 | // fix important php.ini and conf.d/*.ini settings |
@@ -278,7 +275,7 @@ discard block |
||
278 | 275 | } |
279 | 276 | // create database |
280 | 277 | $setup_db = $setup_cli.' --setup-cmd-database sub_command=create_db'; |
281 | - foreach(array('domain','db_type','db_host','db_port','db_name','db_user','db_pass','db_root','db_root_pw','db_grant_host') as $name) |
|
278 | + foreach (array('domain', 'db_type', 'db_host', 'db_port', 'db_name', 'db_user', 'db_pass', 'db_root', 'db_root_pw', 'db_grant_host') as $name) |
|
282 | 279 | { |
283 | 280 | $setup_db .= ' '.escapeshellarg($name.'='.$config[$name]); |
284 | 281 | } |
@@ -286,7 +283,7 @@ discard block |
||
286 | 283 | |
287 | 284 | // check if ldap is required and initialise it |
288 | 285 | // we need to specify account_repository and auth_type to --install as extra config, otherwise install happens for sql! |
289 | - @list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3); |
|
286 | + @list($config['account_repository'], $config['auth_type'], $rest) = explode(',', $config['account-auth'], 3); |
|
290 | 287 | $extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']); |
291 | 288 | $extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type'])); |
292 | 289 | if (empty($rest)) unset($config['account-auth']); |
@@ -297,15 +294,15 @@ discard block |
||
297 | 294 | |
298 | 295 | $setup_ldap = $setup_cli.' --setup-cmd-ldap sub_command='. |
299 | 296 | ($config['account_repository'] == 'ldap' ? 'create_ldap' : 'test_ldap'); |
300 | - foreach(array( |
|
301 | - 'domain','ldap_suffix','ldap_host','ldap_admin','ldap_admin_pw', // non-egw params: only used for create |
|
302 | - 'ldap_base','ldap_root_dn','ldap_root_pw','ldap_context','ldap_search_filter','ldap_group_context', // egw params |
|
297 | + foreach (array( |
|
298 | + 'domain', 'ldap_suffix', 'ldap_host', 'ldap_admin', 'ldap_admin_pw', // non-egw params: only used for create |
|
299 | + 'ldap_base', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_search_filter', 'ldap_group_context', // egw params |
|
303 | 300 | 'ldap_encryption_type', 'sambaadmin/sambasid', |
304 | 301 | ) as $name) |
305 | 302 | { |
306 | - if (strpos($value=$config[$name],'$') !== false) |
|
303 | + if (strpos($value = $config[$name], '$') !== false) |
|
307 | 304 | { |
308 | - $config[$name] = $value = strtr($value,array( |
|
305 | + $config[$name] = $value = strtr($value, array( |
|
309 | 306 | '$suffix' => $config['ldap_suffix'], |
310 | 307 | '$base' => $config['ldap_base'], |
311 | 308 | '$admin_pw' => $config['ldap_admin_pw'], |
@@ -313,7 +310,7 @@ discard block |
||
313 | 310 | } |
314 | 311 | $setup_ldap .= ' '.escapeshellarg($name.'='.$value); |
315 | 312 | |
316 | - if (!in_array($name,array('domain','ldap_suffix','ldap_admin','ldap_admin_pw'))) |
|
313 | + if (!in_array($name, array('domain', 'ldap_suffix', 'ldap_admin', 'ldap_admin_pw'))) |
|
317 | 314 | { |
318 | 315 | $extra_config .= ' '.escapeshellarg($name.'='.$value); |
319 | 316 | } |
@@ -346,7 +343,7 @@ discard block |
||
346 | 343 | } |
347 | 344 | // create mailserver config (fmail requires at least minimal config given as default, otherwise fatal error) |
348 | 345 | $setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']); |
349 | - foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name) |
|
346 | + foreach (array('account-auth', 'smtpserver', 'smtp', 'postfix', 'mailserver', 'imap', 'cyrus', 'sieve', 'folder') as $name) |
|
350 | 347 | { |
351 | 348 | if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
352 | 349 | } |
@@ -360,7 +357,7 @@ discard block |
||
360 | 357 | // check if webserver is started and start it (permanent) if not |
361 | 358 | if ($config['start_webserver']) |
362 | 359 | { |
363 | - exec(build_cmd('start_webserver', 'status'),$dummy,$ret); |
|
360 | + exec(build_cmd('start_webserver', 'status'), $dummy, $ret); |
|
364 | 361 | if ($ret) |
365 | 362 | { |
366 | 363 | system(build_cmd('start_webserver', 'start')); |
@@ -399,7 +396,7 @@ discard block |
||
399 | 396 | // --> existing install --> update |
400 | 397 | |
401 | 398 | // get user from header and replace password, as we dont know it |
402 | - $old_password = patch_header($config['header'],$config['config_user'],$config['config_passwd']); |
|
399 | + $old_password = patch_header($config['header'], $config['config_user'], $config['config_passwd']); |
|
403 | 400 | // register a shutdown function to put old password back in any case |
404 | 401 | register_shutdown_function(function() use (&$config, $old_password) |
405 | 402 | { |
@@ -408,18 +405,18 @@ discard block |
||
408 | 405 | |
409 | 406 | // update egroupware |
410 | 407 | $setup_update = $setup_cli.' --update '.escapeshellarg('all,'.$config['config_user'].','.$config['config_passwd'].',,'.$config['install-update-app']); |
411 | - $ret = run_cmd($setup_update,$output,array(4,15)); |
|
408 | + $ret = run_cmd($setup_update, $output, array(4, 15)); |
|
412 | 409 | |
413 | - switch($ret) |
|
410 | + switch ($ret) |
|
414 | 411 | { |
415 | 412 | case 4: // header needs an update |
416 | 413 | $header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']); |
417 | 414 | run_cmd($header_update); |
418 | - $ret = run_cmd($setup_update,$output,15); |
|
415 | + $ret = run_cmd($setup_update, $output, 15); |
|
419 | 416 | if ($ret != 15) break; |
420 | 417 | // fall through |
421 | 418 | case 15: // missing configuration (eg. mailserver) |
422 | - if (!$verbose) echo implode("\n",(array)$output)."\n"; |
|
419 | + if (!$verbose) echo implode("\n", (array)$output)."\n"; |
|
423 | 420 | break; |
424 | 421 | |
425 | 422 | case 0: |
@@ -462,18 +459,18 @@ discard block |
||
462 | 459 | * @param string $password new password |
463 | 460 | * @return string old password |
464 | 461 | */ |
465 | -function patch_header($filename,&$user,$password) |
|
462 | +function patch_header($filename, &$user, $password) |
|
466 | 463 | { |
467 | 464 | $header = file_get_contents($filename); |
468 | 465 | |
469 | 466 | $umatches = $pmatches = null; |
470 | - if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m",$header,$umatches) || |
|
471 | - !preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",$header,$pmatches)) |
|
467 | + if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m", $header, $umatches) || |
|
468 | + !preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", $header, $pmatches)) |
|
472 | 469 | { |
473 | - bail_out(99,"$filename is no regular EGroupware header.inc.php!"); |
|
470 | + bail_out(99, "$filename is no regular EGroupware header.inc.php!"); |
|
474 | 471 | } |
475 | - file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", |
|
476 | - "\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header)); |
|
472 | + file_put_contents($filename, preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", |
|
473 | + "\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';", $header)); |
|
477 | 474 | |
478 | 475 | $user = $umatches[1]; |
479 | 476 | |
@@ -488,7 +485,7 @@ discard block |
||
488 | 485 | * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out |
489 | 486 | * @return int exit code of $cmd |
490 | 487 | */ |
491 | -function run_cmd($cmd,array &$output=null,$no_bailout=null) |
|
488 | +function run_cmd($cmd, array &$output = null, $no_bailout = null) |
|
492 | 489 | { |
493 | 490 | global $verbose; |
494 | 491 | |
@@ -496,16 +493,16 @@ discard block |
||
496 | 493 | { |
497 | 494 | echo $cmd."\n"; |
498 | 495 | $ret = null; |
499 | - system($cmd,$ret); |
|
496 | + system($cmd, $ret); |
|
500 | 497 | } |
501 | 498 | else |
502 | 499 | { |
503 | 500 | $output[] = $cmd; |
504 | - exec($cmd,$output,$ret); |
|
501 | + exec($cmd, $output, $ret); |
|
505 | 502 | } |
506 | - if ($ret && $no_bailout !== true && !in_array($ret,(array)$no_bailout)) |
|
503 | + if ($ret && $no_bailout !== true && !in_array($ret, (array)$no_bailout)) |
|
507 | 504 | { |
508 | - bail_out($ret,$verbose?null:$output); |
|
505 | + bail_out($ret, $verbose ? null : $output); |
|
509 | 506 | } |
510 | 507 | return $ret; |
511 | 508 | } |
@@ -516,9 +513,9 @@ discard block |
||
516 | 513 | * @param int $ret =1 |
517 | 514 | * @param array|string $output line(s) to output before temination notice |
518 | 515 | */ |
519 | -function bail_out($ret=1,$output=null) |
|
516 | +function bail_out($ret = 1, $output = null) |
|
520 | 517 | { |
521 | - if ($output) echo implode("\n",(array)$output); |
|
518 | + if ($output) echo implode("\n", (array)$output); |
|
522 | 519 | echo "\n\nInstallation failed --> exiting!\n\n"; |
523 | 520 | exit($ret); |
524 | 521 | } |
@@ -529,21 +526,21 @@ discard block |
||
529 | 526 | * @param int $len =16 |
530 | 527 | * @return string |
531 | 528 | */ |
532 | -function randomstring($len=16) |
|
529 | +function randomstring($len = 16) |
|
533 | 530 | { |
534 | 531 | static $usedchars = array( |
535 | - '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', |
|
536 | - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', |
|
537 | - 'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', |
|
538 | - 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', |
|
539 | - '@','!','%','&','(',')','=','?',';',':','#','_','-','<', |
|
540 | - '>','|','[',']','}', // dont add /\,'"{ as we have problems dealing with them |
|
532 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
|
533 | + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
|
534 | + 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', |
|
535 | + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
536 | + '@', '!', '%', '&', '(', ')', '=', '?', ';', ':', '#', '_', '-', '<', |
|
537 | + '>', '|', '[', ']', '}', // dont add /\,'"{ as we have problems dealing with them |
|
541 | 538 | ); |
542 | 539 | |
543 | 540 | $str = ''; |
544 | - for($i=0; $i < $len; $i++) |
|
541 | + for ($i = 0; $i < $len; $i++) |
|
545 | 542 | { |
546 | - $str .= $usedchars[mt_rand(0,count($usedchars)-1)]; |
|
543 | + $str .= $usedchars[mt_rand(0, count($usedchars) - 1)]; |
|
547 | 544 | } |
548 | 545 | return $str; |
549 | 546 | } |
@@ -553,20 +550,20 @@ discard block |
||
553 | 550 | * |
554 | 551 | * @param string $error =null optional error-message |
555 | 552 | */ |
556 | -function usage($error=null) |
|
553 | +function usage($error = null) |
|
557 | 554 | { |
558 | - global $prog,$config; |
|
555 | + global $prog, $config; |
|
559 | 556 | |
560 | 557 | echo "Usage: $prog [-h|--help] [-v|--verbose] [--distro=(suse|rh|debian)] [options, ...]\n\n"; |
561 | 558 | echo "options and their defaults:\n"; |
562 | - foreach($config as $name => $default) |
|
559 | + foreach ($config as $name => $default) |
|
563 | 560 | { |
564 | - if (in_array($name, array('postfix','cyrus'))) continue; // do NOT report deprecated options |
|
565 | - if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16) |
|
561 | + if (in_array($name, array('postfix', 'cyrus'))) continue; // do NOT report deprecated options |
|
562 | + if (in_array($name, array('config_passwd', 'db_pass', 'admin_passwd', 'ldap_root_pw')) && strlen($config[$name]) == 16) |
|
566 | 563 | { |
567 | 564 | $default = '<16 char random string>'; |
568 | 565 | } |
569 | - echo '--'.str_pad($name,20).$default."\n"; |
|
566 | + echo '--'.str_pad($name, 20).$default."\n"; |
|
570 | 567 | } |
571 | 568 | if ($error) |
572 | 569 | { |
@@ -616,8 +613,8 @@ discard block |
||
616 | 613 | $config['distro'] = 'univention'; |
617 | 614 | |
618 | 615 | // set lang from ucr locale, as cloud-config at least never has anything but EN set in enviroment |
619 | - @list($lang,$nat) = preg_split('/[_.]/', _ucr_get('locale/default')); |
|
620 | - if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw'))) |
|
616 | + @list($lang, $nat) = preg_split('/[_.]/', _ucr_get('locale/default')); |
|
617 | + if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw'))) |
|
621 | 618 | { |
622 | 619 | $lang .= '-'.strtolower($nat); |
623 | 620 | } |
@@ -642,7 +639,7 @@ discard block |
||
642 | 639 | // ldap password hash (our default blowfish_crypt seems not to work) |
643 | 640 | $config['ldap_encryption_type'] = 'sha512_crypt'; |
644 | 641 | |
645 | - $config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups |
|
642 | + $config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups |
|
646 | 643 | |
647 | 644 | $config['account-auth'] = 'univention,ldap'; |
648 | 645 | |
@@ -652,7 +649,7 @@ discard block |
||
652 | 649 | // mailserver, see setup-cli.php --help config |
653 | 650 | if (($mailserver = exec('/usr/bin/univention-ldapsearch -x "(univentionAppID=mailserver_*)" univentionAppInstalledOnServer|sed -n "s/univentionAppInstalledOnServer: \(.*\)/\1/p"')) && |
654 | 651 | // only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' && |
655 | - ($domains=_ucr_get('mail/hosteddomains'))) |
|
652 | + ($domains = _ucr_get('mail/hosteddomains'))) |
|
656 | 653 | { |
657 | 654 | if (!is_array($domains)) $domains = explode("\n", $domains); |
658 | 655 | $domain = array_shift($domains); |
@@ -692,12 +689,12 @@ discard block |
||
692 | 689 | */ |
693 | 690 | function _ucr_get($name) |
694 | 691 | { |
695 | - static $values=null; |
|
692 | + static $values = null; |
|
696 | 693 | if (!isset($values)) |
697 | 694 | { |
698 | 695 | $output = $matches = null; |
699 | 696 | exec('/usr/sbin/ucr dump', $output); |
700 | - foreach($output as $line) |
|
697 | + foreach ($output as $line) |
|
701 | 698 | { |
702 | 699 | if (preg_match("/^([^:]+): (.*)\n?$/", $line, $matches)) |
703 | 700 | { |
@@ -773,7 +770,7 @@ discard block |
||
773 | 770 | */ |
774 | 771 | function _size_with_unit($size) |
775 | 772 | { |
776 | - switch(strtoupper(substr($size, -1))) |
|
773 | + switch (strtoupper(substr($size, -1))) |
|
777 | 774 | { |
778 | 775 | case 'G': |
779 | 776 | $size *= 1024; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | - foreach($custom as $name => $data) { |
|
50 | + foreach ($custom as $name => $data) { |
|
51 | 51 | $this->mapping_fields['#'.$name] = $data['label']; |
52 | 52 | } |
53 | 53 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | - foreach($custom as $name => $data) { |
|
50 | + foreach ($custom as $name => $data) { |
|
51 | 51 | $this->mapping_fields['#'.$name] = $data['label']; |
52 | 52 | } |
53 | 53 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | - foreach($custom as $name => $data) { |
|
50 | + foreach ($custom as $name => $data) { |
|
51 | 51 | $this->mapping_fields['#'.$name] = $data['label']; |
52 | 52 | } |
53 | 53 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | - foreach($custom as $name => $data) { |
|
50 | + foreach ($custom as $name => $data) { |
|
51 | 51 | $this->mapping_fields['#'.$name] = $data['label']; |
52 | 52 | } |
53 | 53 |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
40 | 40 | } |
41 | 41 | // fix for SOGo connector, which does not decode the = in our f/b url |
42 | -if (strpos($_SERVER['QUERY_STRING'],'=3D') !== false && substr($_GET['user'],0,2) == '3D') |
|
42 | +if (strpos($_SERVER['QUERY_STRING'], '=3D') !== false && substr($_GET['user'], 0, 2) == '3D') |
|
43 | 43 | { |
44 | - $_GET['user'] = substr($_GET['user'],2); |
|
45 | - if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'],2); |
|
46 | - if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'],2); |
|
44 | + $_GET['user'] = substr($_GET['user'], 2); |
|
45 | + if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'], 2); |
|
46 | + if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'], 2); |
|
47 | 47 | } |
48 | 48 | if (!is_numeric($user = $_GET['user'])) |
49 | 49 | { |
50 | 50 | // check if user contains the current domain --> remove it |
51 | - list(,$domain) = explode('@',$user); |
|
51 | + list(,$domain) = explode('@', $user); |
|
52 | 52 | if ($domain === $GLOBALS['egw_info']['user']['domain']) |
53 | - list($user) = explode('@',$user); |
|
54 | - $user = $GLOBALS['egw']->accounts->name2id($user,'account_lid','u'); |
|
53 | + list($user) = explode('@', $user); |
|
54 | + $user = $GLOBALS['egw']->accounts->name2id($user, 'account_lid', 'u'); |
|
55 | 55 | } |
56 | 56 | if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user))) |
57 | 57 | { |
58 | - fail_exit(lang("freebusy: Unknow user '%1', wrong password or not availible to not loged in users !!!"." $username($user)",$_GET['user'])); |
|
58 | + fail_exit(lang("freebusy: Unknow user '%1', wrong password or not availible to not loged in users !!!"." $username($user)", $_GET['user'])); |
|
59 | 59 | } |
60 | 60 | if (!$loged_in) |
61 | 61 | { |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | if (strpos($authuser, '@') === false) |
77 | 77 | { |
78 | 78 | $domain = $GLOBALS['egw_info']['server']['default_domain']; |
79 | - $authuser .= '@' . $domain; |
|
79 | + $authuser .= '@'.$domain; |
|
80 | 80 | } |
81 | 81 | else |
82 | 82 | { |
83 | - list(, $domain) = explode('@',$authuser, 2); |
|
83 | + list(, $domain) = explode('@', $authuser, 2); |
|
84 | 84 | } |
85 | 85 | if (array_key_exists($domain, $GLOBALS['egw_domain'])) |
86 | 86 | { |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | $GLOBALS['egw_info']['user']['domain'] = $domain; |
91 | 91 | $GLOBALS['egw_info']['flags']['currentapp'] = 'login'; |
92 | 92 | $GLOBALS['egw_info']['flags']['noapi'] = false; |
93 | - require_once(EGW_API_INC . '/functions.inc.php'); |
|
94 | - $loged_in = $GLOBALS['egw']->session->create($authuser, $password, 'text'); |
|
93 | + require_once(EGW_API_INC.'/functions.inc.php'); |
|
94 | + $loged_in = $GLOBALS['egw']->session->create($authuser, $password, 'text'); |
|
95 | 95 | session_unset(); |
96 | 96 | session_destroy(); |
97 | 97 | } |
@@ -107,6 +107,6 @@ discard block |
||
107 | 107 | } |
108 | 108 | else |
109 | 109 | { |
110 | - html::content_header('freebusy.ifb','text/calendar'); |
|
110 | + html::content_header('freebusy.ifb', 'text/calendar'); |
|
111 | 111 | } |
112 | -echo ExecMethod2('calendar.calendar_ical.freebusy',$user,$_GET['end']); |
|
112 | +echo ExecMethod2('calendar.calendar_ical.freebusy', $user, $_GET['end']); |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | |
12 | 12 | die('This file is only used on http://www.egroupware.org/ and therefore disabled on local installations!'); |
13 | 13 | |
14 | -if(empty($_POST['locale']) || !preg_match('/^[A-Z]{2}$/',$_POST['locale'])) |
|
14 | +if (empty($_POST['locale']) || !preg_match('/^[A-Z]{2}$/', $_POST['locale'])) |
|
15 | 15 | { |
16 | 16 | die('Missing or wrong value for required _POST[local]!'); |
17 | 17 | } |
18 | -$send_back_to = str_replace('submit','admin',$_SERVER['HTTP_REFERER']); |
|
18 | +$send_back_to = str_replace('submit', 'admin', $_SERVER['HTTP_REFERER']); |
|
19 | 19 | |
20 | -function _holiday_cmp($a,$b) |
|
20 | +function _holiday_cmp($a, $b) |
|
21 | 21 | { |
22 | 22 | if (($year_diff = ($a['occurence'] <= 0 ? 0 : $a['occurence']) - ($b['occurence'] <= 0 ? 0 : $b['occurence']))) |
23 | 23 | { |
@@ -26,21 +26,21 @@ discard block |
||
26 | 26 | return $a['month'] - $b['month'] ? $a['month'] - $b['month'] : $a['day'] - $b['day']; |
27 | 27 | } |
28 | 28 | |
29 | -$send_back_to = str_replace('&locale='.$_POST['locale'],'',$send_back_to); |
|
29 | +$send_back_to = str_replace('&locale='.$_POST['locale'], '', $send_back_to); |
|
30 | 30 | $file = './holidays.'.$_POST['locale'].'.csv'; |
31 | -if(!file_exists($file) || filesize($file) < 300) // treat very small files as not existent |
|
31 | +if (!file_exists($file) || filesize($file) < 300) // treat very small files as not existent |
|
32 | 32 | { |
33 | 33 | if (count($_POST['name'])) |
34 | 34 | { |
35 | - $fp = fopen($file,'w'); |
|
36 | - if ($_POST['charset']) fwrite($fp,"charset\t".$_POST['charset']."\n"); |
|
35 | + $fp = fopen($file, 'w'); |
|
36 | + if ($_POST['charset']) fwrite($fp, "charset\t".$_POST['charset']."\n"); |
|
37 | 37 | |
38 | 38 | $holidays = array(); |
39 | - foreach($_POST['name'] as $i => $name) |
|
39 | + foreach ($_POST['name'] as $i => $name) |
|
40 | 40 | { |
41 | 41 | $holidays[] = array( |
42 | 42 | 'locale' => $_POST['locale'], |
43 | - 'name' => str_replace('\\','',$name), |
|
43 | + 'name' => str_replace('\\', '', $name), |
|
44 | 44 | 'day' => $_POST['day'][$i], |
45 | 45 | 'month' => $_POST['month'][$i], |
46 | 46 | 'occurence' => $_POST['occurence'][$i], |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | ); |
50 | 50 | } |
51 | 51 | // sort holidays by year / occurence: |
52 | - usort($holidays,'_holiday_cmp'); |
|
52 | + usort($holidays, '_holiday_cmp'); |
|
53 | 53 | |
54 | 54 | $last_year = -1; |
55 | - foreach($holidays as $holiday) |
|
55 | + foreach ($holidays as $holiday) |
|
56 | 56 | { |
57 | 57 | $year = $holiday['occurence'] <= 0 ? 0 : $holiday['occurence']; |
58 | 58 | if ($year != $last_year) |
59 | 59 | { |
60 | - fwrite($fp,"\n".($year ? $year : 'regular (year=0)').":\n"); |
|
60 | + fwrite($fp, "\n".($year ? $year : 'regular (year=0)').":\n"); |
|
61 | 61 | $last_year = $year; |
62 | 62 | } |
63 | - fwrite($fp,"$holiday[locale]\t$holiday[name]\t$holiday[day]\t$holiday[month]\t$holiday[occurence]\t$holiday[dow]\t$holiday[observance_rule]\n"); |
|
63 | + fwrite($fp, "$holiday[locale]\t$holiday[name]\t$holiday[day]\t$holiday[month]\t$holiday[occurence]\t$holiday[dow]\t$holiday[observance_rule]\n"); |
|
64 | 64 | } |
65 | 65 | fclose($fp); |
66 | 66 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | 'category' => array( |
52 | 52 | 'type' => 'select', |
53 | 53 | 'label' => lang('Choose a category'), |
54 | - 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
54 | + 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
55 | 55 | 'multiple' => true, |
56 | 56 | ), |
57 | 57 | 'numWeeks' => array( |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | function get_user_interface() |
104 | 104 | { |
105 | 105 | // copied from bookmarks module. |
106 | - $cat = createobject('phpgwapi.categories','','calendar'); |
|
107 | - $cats = $cat->return_array('all',0,False,'','cat_name','',True); |
|
106 | + $cat = createobject('phpgwapi.categories', '', 'calendar'); |
|
107 | + $cats = $cat->return_array('all', 0, False, '', 'cat_name', '', True); |
|
108 | 108 | $cat_ids = array(); |
109 | 109 | while (list(,$category) = @each($cats)) |
110 | 110 | { |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | $this->arguments['category']['multiple'] = 5; |
116 | 116 | } |
117 | 117 | |
118 | - if (! isset($GLOBALS['egw']->accounts)) |
|
118 | + if (!isset($GLOBALS['egw']->accounts)) |
|
119 | 119 | { |
120 | 120 | $GLOBALS['egw']->accounts = new accounts(); |
121 | 121 | } |
122 | - $this->accounts =& $GLOBALS['egw']->accounts; |
|
123 | - $search_params=array( |
|
122 | + $this->accounts = & $GLOBALS['egw']->accounts; |
|
123 | + $search_params = array( |
|
124 | 124 | 'type' => 'both', |
125 | 125 | 'app' => 'calendar', |
126 | 126 | ); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | // sort users and groups separately. |
131 | 131 | if (isset($GLOBALS['sitemgr_info']['anonymous_user'])) |
132 | 132 | { |
133 | - $anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'],'account_lid','u'); |
|
133 | + $anon_user = $this->accounts->name2id($GLOBALS['sitemgr_info']['anonymous_user'], 'account_lid', 'u'); |
|
134 | 134 | } |
135 | 135 | else |
136 | 136 | { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * Get possible sitemgr paths from the HTTP_REFERRER in order to unreveal the |
140 | 140 | * anonymous user for the correct site. |
141 | 141 | */ |
142 | - $sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/',"/\${1}",$_SERVER['HTTP_REFERER']); |
|
142 | + $sitemgr_path = preg_replace('/^[^\/]+:\/\/[^\/]+\/([^\?]*)(\?.*)*$/', "/\${1}", $_SERVER['HTTP_REFERER']); |
|
143 | 143 | // Remove the trailing file- / pathname if any |
144 | 144 | $sitemgr_path = preg_replace('/[^\/]*$/', '', $sitemgr_path); |
145 | 145 | // Add leading slash if it has been lost. |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | // Code adapted from sitemgr-site/index.php |
152 | 152 | $site_urls = array(); |
153 | 153 | $site_urls[] = $sitemgr_path; |
154 | - $site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $sitemgr_path; |
|
155 | - $site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $sitemgr_path; |
|
154 | + $site_urls[] = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_ADDR'].$sitemgr_path; |
|
155 | + $site_urls[] = $site_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$sitemgr_path; |
|
156 | 156 | |
157 | - $GLOBALS['egw']->db->select('egw_sitemgr_sites','anonymous_user,anonymous_passwd,site_id', |
|
158 | - array('site_url' => $site_urls),__LINE__,__FILE__,false,'','sitemgr'); |
|
157 | + $GLOBALS['egw']->db->select('egw_sitemgr_sites', 'anonymous_user,anonymous_passwd,site_id', |
|
158 | + array('site_url' => $site_urls), __LINE__, __FILE__, false, '', 'sitemgr'); |
|
159 | 159 | |
160 | 160 | $GLOBALS['egw']->db->next_record(); |
161 | - $anon_user = $this->accounts->name2id($GLOBALS['egw']->db->f('anonymous_user'),'account_lid','u'); |
|
161 | + $anon_user = $this->accounts->name2id($GLOBALS['egw']->db->f('anonymous_user'), 'account_lid', 'u'); |
|
162 | 162 | } |
163 | 163 | |
164 | - $anon_groups = $this->accounts->memberships($anon_user,true); |
|
164 | + $anon_groups = $this->accounts->memberships($anon_user, true); |
|
165 | 165 | foreach ($accounts as $entry) |
166 | 166 | { |
167 | 167 | $is_group = false; |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | $acl = new acl($entry['account_id']); |
170 | 170 | $acl->read_repository(); |
171 | 171 | // get the rights for each account to check whether the anon user has read permissions. |
172 | - $rights = $acl->get_rights($anon_user,'calendar'); |
|
172 | + $rights = $acl->get_rights($anon_user, 'calendar'); |
|
173 | 173 | // also add the anon user if it's his own calendar. |
174 | - if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $anon_user)) |
|
174 | + if (($rights&EGW_ACL_READ) || ($entry['account_id'] == $anon_user)) |
|
175 | 175 | { |
176 | 176 | $has_read_permissions = true; |
177 | 177 | } |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | // or ass permissions if this is the anon group's calendar. |
182 | 182 | foreach ($anon_groups as $parent_group) |
183 | 183 | { |
184 | - $rights = $acl->get_rights($parent_group,'calendar'); |
|
185 | - if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $parent_group)) |
|
184 | + $rights = $acl->get_rights($parent_group, 'calendar'); |
|
185 | + if (($rights&EGW_ACL_READ) || ($entry['account_id'] == $parent_group)) |
|
186 | 186 | { |
187 | 187 | $has_read_permissions = true; |
188 | 188 | break; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | else |
200 | 200 | { |
201 | - $users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']); |
|
201 | + $users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'], $entry['account_firstname'], $entry['account_lastname']); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | return parent::get_user_interface(); |
219 | 219 | } |
220 | 220 | |
221 | - function get_content(&$arguments,$properties) |
|
221 | + function get_content(&$arguments, $properties) |
|
222 | 222 | { |
223 | 223 | $html = ""; |
224 | 224 | $GLOBALS['egw']->translation->add_app('calendar'); |
@@ -226,34 +226,33 @@ discard block |
||
226 | 226 | $this->ui->allowEdit = false; |
227 | 227 | $this->ui->use_time_grid = isset($arguments['grid']) ? $arguments['grid'] : false; |
228 | 228 | |
229 | - $weeks = $arguments['numWeeks'] ? (int) $arguments['numWeeks'] : 2; |
|
229 | + $weeks = $arguments['numWeeks'] ? (int)$arguments['numWeeks'] : 2; |
|
230 | 230 | |
231 | - if (($arguments['acceptDateParam']) && (get_var('date',array('POST','GET')))) |
|
231 | + if (($arguments['acceptDateParam']) && (get_var('date', array('POST', 'GET')))) |
|
232 | 232 | { |
233 | - $start = (int) (strtotime(get_var('date',array('POST','GET'))) + |
|
233 | + $start = (int)(strtotime(get_var('date', array('POST', 'GET'))) + |
|
234 | 234 | (60 * 60 * 24 * 7 * $dateOffset)); |
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | - $start = (int) ($this->bo->now_su + |
|
238 | + $start = (int)($this->bo->now_su + |
|
239 | 239 | (60 * 60 * 24 * 7 * $dateOffset)); |
240 | 240 | } |
241 | 241 | $first = $this->ui->datetime->get_weekday_start( |
242 | - adodb_date('Y',$start), |
|
243 | - adodb_date('m',$start), |
|
244 | - adodb_date('d',$start)); |
|
245 | - $last = strtotime("+$weeks weeks",$first) - 1; |
|
242 | + adodb_date('Y', $start), |
|
243 | + adodb_date('m', $start), |
|
244 | + adodb_date('d', $start)); |
|
245 | + $last = strtotime("+$weeks weeks", $first) - 1; |
|
246 | 246 | |
247 | 247 | if ($arguments['showTitle']) |
248 | 248 | { |
249 | 249 | $html .= '<div id="divAppboxHeader">'.$GLOBALS['egw_info']['apps']['calendar']['title'].' - '.lang('Weekview').": "; |
250 | - $html .= lang('After %1',$this->bo->long_date($first)); |
|
250 | + $html .= lang('After %1', $this->bo->long_date($first)); |
|
251 | 251 | $html .= "</div>"; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // set the search parameters |
255 | - $search_params = Array |
|
256 | - ( |
|
255 | + $search_params = Array( |
|
257 | 256 | 'offset' => false, |
258 | 257 | 'order' => 'cal_start ASC', |
259 | 258 | 'start' => $first, |
@@ -288,24 +287,24 @@ discard block |
||
288 | 287 | $html .= '<!-- END Calendar info -->'."\n"; |
289 | 288 | unset($css_file); |
290 | 289 | // we add DAY_s/2 to $this->first (using 12h), to deal with daylight saving changes |
291 | - for ($week_start = $first; $week_start < $last; $week_start = strtotime("+1 week",$week_start)) |
|
290 | + for ($week_start = $first; $week_start < $last; $week_start = strtotime("+1 week", $week_start)) |
|
292 | 291 | { |
293 | 292 | $week = array(); |
294 | 293 | for ($i = 0; $i < 7; ++$i) |
295 | 294 | { |
296 | - $day_ymd = $this->bo->date2string($i ? strtotime("+$i days",$week_start) : $week_start); |
|
295 | + $day_ymd = $this->bo->date2string($i ? strtotime("+$i days", $week_start) : $week_start); |
|
297 | 296 | $week[$day_ymd] = array_shift($rows); |
298 | 297 | } |
299 | 298 | $week_view = array( |
300 | 299 | 'menuaction' => false, |
301 | 300 | 'date' => $this->bo->date2string($week_start), |
302 | 301 | ); |
303 | - $title = lang('Wk').' '.adodb_date('W',$week_start); |
|
302 | + $title = lang('Wk').' '.adodb_date('W', $week_start); |
|
304 | 303 | if (!isset($GLOBALS['egw']->template)) |
305 | 304 | { |
306 | 305 | $GLOBALS['egw']->template = new Template; |
307 | 306 | } |
308 | - $html .= $this->ui->timeGridWidget($this->ui->tagWholeDayOnTop($week),$weeks == 2 ? 30 : 60,200,'',$title,0,$week_start+WEEK_s >= $last); |
|
307 | + $html .= $this->ui->timeGridWidget($this->ui->tagWholeDayOnTop($week), $weeks == 2 ? 30 : 60, 200, '', $title, 0, $week_start + WEEK_s >= $last); |
|
309 | 308 | } |
310 | 309 | // Initialize Tooltips |
311 | 310 | $html .= '<script language="JavaScript" type="text/javascript" src="'.$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/wz_tooltip/wz_tooltip.js"></script>'."\n"; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | 'category' => array( |
89 | 89 | 'type' => 'select', |
90 | 90 | 'label' => lang('Choose a category'), |
91 | - 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
91 | + 'options' => array(), // specification of options is postponed into the get_user_interface function |
|
92 | 92 | 'multiple' => true, |
93 | 93 | ), |
94 | 94 | 'numWeeks' => array( |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | { |
155 | 155 | //_debug_array($GLOBALS['Common_BO']->sites->current_site); |
156 | 156 | // copied from bookmarks module. |
157 | - $cat = createobject('phpgwapi.categories','','calendar'); |
|
158 | - $cats = $cat->return_array('all',0,False,'','cat_name','',True); |
|
157 | + $cat = createobject('phpgwapi.categories', '', 'calendar'); |
|
158 | + $cats = $cat->return_array('all', 0, False, '', 'cat_name', '', True); |
|
159 | 159 | $cat_ids = array(); |
160 | 160 | while (list(,$category) = @each($cats)) |
161 | 161 | { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $GLOBALS['egw']->accounts = new accounts(); |
172 | 172 | } |
173 | - $this->accounts =& $GLOBALS['egw']->accounts; |
|
173 | + $this->accounts = & $GLOBALS['egw']->accounts; |
|
174 | 174 | $search_params = array( |
175 | 175 | 'type' => 'both', |
176 | 176 | 'app' => 'calendar', |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | $users = array(); |
180 | 180 | $groups = array(); |
181 | 181 | // sort users and groups separately. |
182 | - $anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'],'account_lid','u'); |
|
183 | - $anon_groups = $this->accounts->memberships($anon_user,true); |
|
182 | + $anon_user = $this->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'], 'account_lid', 'u'); |
|
183 | + $anon_groups = $this->accounts->memberships($anon_user, true); |
|
184 | 184 | foreach ($accounts as $entry) |
185 | 185 | { |
186 | 186 | $is_group = false; |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | $acl = new acl($entry['account_id']); |
189 | 189 | $acl->read_repository(); |
190 | 190 | // get the rights for each account to check whether the anon user has read permissions. |
191 | - $rights = $acl->get_rights($anon_user,'calendar'); |
|
191 | + $rights = $acl->get_rights($anon_user, 'calendar'); |
|
192 | 192 | // also add the anon user if it's his own calendar. |
193 | - if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $anon_user)) |
|
193 | + if (($rights&EGW_ACL_READ) || ($entry['account_id'] == $anon_user)) |
|
194 | 194 | { |
195 | 195 | $has_read_permissions = true; |
196 | 196 | } |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | // or ass permissions if this is the anon group's calendar. |
201 | 201 | foreach ($anon_groups as $parent_group) |
202 | 202 | { |
203 | - $rights = $acl->get_rights($parent_group,'calendar'); |
|
204 | - if (($rights & EGW_ACL_READ) || ($entry['account_id'] == $parent_group)) |
|
203 | + $rights = $acl->get_rights($parent_group, 'calendar'); |
|
204 | + if (($rights&EGW_ACL_READ) || ($entry['account_id'] == $parent_group)) |
|
205 | 205 | { |
206 | 206 | $has_read_permissions = true; |
207 | 207 | break; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | else |
219 | 219 | { |
220 | - $users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'],$entry['account_firstname'],$entry['account_lastname']); |
|
220 | + $users[$entry['account_id']] = $GLOBALS['egw']->common->display_fullname($entry['account_lid'], $entry['account_firstname'], $entry['account_lastname']); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | return parent::get_user_interface(); |
238 | 238 | } |
239 | 239 | |
240 | - function get_content(&$arguments,$properties) |
|
240 | + function get_content(&$arguments, $properties) |
|
241 | 241 | { |
242 | 242 | $html = ""; |
243 | 243 | $GLOBALS['egw']->translation->add_app('calendar'); |
@@ -246,41 +246,40 @@ discard block |
||
246 | 246 | $this->ui->allowEdit = false; |
247 | 247 | $this->ui->use_time_grid = isset($arguments['grid']) ? $arguments['grid'] : false; |
248 | 248 | |
249 | - $weeks = $arguments['numWeeks'] ? (int) $arguments['numWeeks'] : 4; |
|
250 | - $dateOffset = $arguments['offset'] ? (int) $arguments['offset'] : 0; |
|
249 | + $weeks = $arguments['numWeeks'] ? (int)$arguments['numWeeks'] : 4; |
|
250 | + $dateOffset = $arguments['offset'] ? (int)$arguments['offset'] : 0; |
|
251 | 251 | |
252 | - if (($arguments['acceptDateParam']) && (get_var('date',array('POST','GET')))) |
|
252 | + if (($arguments['acceptDateParam']) && (get_var('date', array('POST', 'GET')))) |
|
253 | 253 | { |
254 | - $first = $start = (int) (strtotime(get_var('date',array('POST','GET'))) + |
|
254 | + $first = $start = (int)(strtotime(get_var('date', array('POST', 'GET'))) + |
|
255 | 255 | (60 * 60 * 24 * 7 * $dateOffset)); |
256 | 256 | } |
257 | 257 | else |
258 | 258 | { |
259 | - $first = $start = (int) ($this->bo->now_su + |
|
259 | + $first = $start = (int)($this->bo->now_su + |
|
260 | 260 | (60 * 60 * 24 * 7 * $dateOffset)); |
261 | 261 | } |
262 | 262 | if ($arguments['useWeekStart']) |
263 | 263 | { |
264 | 264 | $first = $this->ui->datetime->get_weekday_start( |
265 | - adodb_date('Y',$start), |
|
266 | - adodb_date('m',$start), |
|
267 | - adodb_date('d',$start)); |
|
265 | + adodb_date('Y', $start), |
|
266 | + adodb_date('m', $start), |
|
267 | + adodb_date('d', $start)); |
|
268 | 268 | } |
269 | 269 | |
270 | - $last = (int) ($first + |
|
270 | + $last = (int)($first + |
|
271 | 271 | (60 * 60 * 24 * 7 * $weeks)); |
272 | 272 | |
273 | 273 | if ($arguments['showTitle']) |
274 | 274 | { |
275 | 275 | $html .= '<div id="divAppboxHeader">'.$GLOBALS['egw_info']['apps']['calendar']['title'].' - '; |
276 | - $html .= lang('After %1',$this->bo->long_date($first)); |
|
276 | + $html .= lang('After %1', $this->bo->long_date($first)); |
|
277 | 277 | $html .= "</div>"; |
278 | 278 | } |
279 | 279 | |
280 | 280 | // set the search parameters |
281 | - $search_params = Array |
|
282 | - ( |
|
283 | - 'offset' => $arguments['entryOffset'] ? (int) $arguments['entryOffset'] : false, |
|
281 | + $search_params = Array( |
|
282 | + 'offset' => $arguments['entryOffset'] ? (int)$arguments['entryOffset'] : false, |
|
284 | 283 | 'order' => 'cal_start ASC', |
285 | 284 | 'start' => $first, |
286 | 285 | 'end' => $last, |
@@ -300,23 +299,23 @@ discard block |
||
300 | 299 | } |
301 | 300 | if ($arguments['numEntries']) |
302 | 301 | { |
303 | - $search_params['num_rows'] = (int) $arguments['numEntries']; |
|
304 | - $search_params['offset'] = $arguments['entryOffset'] ? (int) $arguments['entryOffset'] :0; |
|
302 | + $search_params['num_rows'] = (int)$arguments['numEntries']; |
|
303 | + $search_params['offset'] = $arguments['entryOffset'] ? (int)$arguments['entryOffset'] : 0; |
|
305 | 304 | } |
306 | 305 | $rows = array(); |
307 | 306 | |
308 | - foreach((array) $this->bo->search($search_params) as $event) |
|
307 | + foreach ((array)$this->bo->search($search_params) as $event) |
|
309 | 308 | { |
310 | 309 | $event['date'] = $this->bo->date2string($event['start']); |
311 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
312 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
310 | + if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
311 | + if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
313 | 312 | $rows[] = $event; |
314 | 313 | } |
315 | 314 | if (($arguments['showWeeks']) && ((int)$arguments['offset'] == 0)) |
316 | 315 | { |
317 | 316 | $html .= "<div>".lang('Next')." ".lang('%1 weeks', $weeks).":</div>\n"; |
318 | 317 | } |
319 | - if (($search_params['offset'] && $this->bo->total == 0) || count($rows)==0) |
|
318 | + if (($search_params['offset'] && $this->bo->total == 0) || count($rows) == 0) |
|
320 | 319 | { |
321 | 320 | $html .= "<div>".lang("no events found")."</div>"; |
322 | 321 | } |
@@ -329,11 +328,11 @@ discard block |
||
329 | 328 | $html .= ' <div class="cal_list_weektop"></div>'."\n"; |
330 | 329 | foreach ($rows as $event) |
331 | 330 | { |
332 | - if (($last_week != 0) && (adodb_date('W-Y',$event['start']) != $last_week)) |
|
331 | + if (($last_week != 0) && (adodb_date('W-Y', $event['start']) != $last_week)) |
|
333 | 332 | { |
334 | 333 | $html .= ' <div class="cal_list_weeksplit"></div>'."\n"; |
335 | 334 | } |
336 | - $last_week = adodb_date('W-Y',$event['start']); |
|
335 | + $last_week = adodb_date('W-Y', $event['start']); |
|
337 | 336 | $html .= " <!-- Event -->\n"; |
338 | 337 | if ($event_count % 2 == 0) { |
339 | 338 | $html .= ' <div class="cal_list_event cal_event_even">'."\n"; |
@@ -345,17 +344,17 @@ discard block |
||
345 | 344 | $html .= ' <div class="cal_list_title">'.$event['title']."</div>\n"; |
346 | 345 | $html .= ' <div class="cal_list_date">'; |
347 | 346 | $html .= '<span class="cal_list_start">'; |
348 | - $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D',$event['start'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
|
347 | + $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D', $event['start'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
|
349 | 348 | $html .= $this->bo->format_date($event['start'])."</span>"; |
350 | 349 | $html .= '<span class="cal_list_end"> - '; |
351 | - $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D',$event['end'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
|
350 | + $html .= '<span class="cal_list_weekday">'.lang(adodb_date('D', $event['end'])).".".($this->bo->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ')."</span>"; |
|
352 | 351 | $html .= $this->bo->format_date($event['end'])."</span></div>\n"; |
353 | 352 | $descr = trim($event['description']); |
354 | - if (! empty($descr)) { |
|
355 | - $html .= " <div class=\"cal_list_descr\">\n".preg_replace('/\\n/',"<br>\n",$event['description'])."</div>\n"; |
|
353 | + if (!empty($descr)) { |
|
354 | + $html .= " <div class=\"cal_list_descr\">\n".preg_replace('/\\n/', "<br>\n", $event['description'])."</div>\n"; |
|
356 | 355 | } |
357 | 356 | $html .= " </div><!-- cal_list_event -->\n"; |
358 | - $event_count ++; |
|
357 | + $event_count++; |
|
359 | 358 | } |
360 | 359 | $html .= ' <div class="cal_list_weekbottom"></div>'."\n"; |
361 | 360 | $html .= "<!-- End module -->\n"; |