@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | var $recommended_php_version = '5.5'; |
| 77 | 77 | |
| 78 | - function __construct($html=False, $translation=False) |
|
| 78 | + function __construct($html = False, $translation = False) |
|
| 79 | 79 | { |
| 80 | 80 | // setup us as $GLOBALS['egw_setup'], as this gets used in our sub-objects |
| 81 | - $GLOBALS['egw_setup'] =& $this; |
|
| 81 | + $GLOBALS['egw_setup'] = & $this; |
|
| 82 | 82 | |
| 83 | 83 | if (!is_object($GLOBALS['egw'])) |
| 84 | 84 | { |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * include api db class for the ConfigDomain and connect to the db |
| 100 | 100 | */ |
| 101 | - function loaddb($connect_and_setcharset=true) |
|
| 101 | + function loaddb($connect_and_setcharset = true) |
|
| 102 | 102 | { |
| 103 | - if(!isset($this->ConfigDomain) || empty($this->ConfigDomain)) |
|
| 103 | + if (!isset($this->ConfigDomain) || empty($this->ConfigDomain)) |
|
| 104 | 104 | { |
| 105 | - $this->ConfigDomain = get_var('ConfigDomain',array('COOKIE','POST'),$_POST['FormDomain']); |
|
| 105 | + $this->ConfigDomain = get_var('ConfigDomain', array('COOKIE', 'POST'), $_POST['FormDomain']); |
|
| 106 | 106 | } |
| 107 | 107 | $GLOBALS['egw_info']['server']['db_type'] = $GLOBALS['egw_domain'][$this->ConfigDomain]['db_type']; |
| 108 | 108 | |
@@ -123,27 +123,27 @@ discard block |
||
| 123 | 123 | if ($connect_and_setcharset) |
| 124 | 124 | { |
| 125 | 125 | try { |
| 126 | - $this->set_table_names(); // sets/checks config- and applications-table-name |
|
| 126 | + $this->set_table_names(); // sets/checks config- and applications-table-name |
|
| 127 | 127 | |
| 128 | 128 | // Set the DB's client charset if a system-charset is set |
| 129 | - $this->db->select($this->config_table,'config_value',array( |
|
| 129 | + $this->db->select($this->config_table, 'config_value', array( |
|
| 130 | 130 | 'config_app' => 'phpgwapi', |
| 131 | 131 | 'config_name' => 'system_charset', |
| 132 | - ),__LINE__,__FILE__); |
|
| 132 | + ), __LINE__, __FILE__); |
|
| 133 | 133 | if ($this->db->next_record() && $this->db->f(0)) |
| 134 | 134 | { |
| 135 | 135 | $this->system_charset = $this->db->f(0); |
| 136 | - $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
|
| 136 | + $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
|
| 137 | 137 | |
| 138 | 138 | // we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!! |
| 139 | - if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version |
|
| 139 | + if (substr($this->db->Type, 0, 5) == 'mysql') // we need to check the api version |
|
| 140 | 140 | { |
| 141 | - $this->db->select($this->applications_table,'app_version',array( |
|
| 141 | + $this->db->select($this->applications_table, 'app_version', array( |
|
| 142 | 142 | 'app_name' => 'phpgwapi', |
| 143 | - ),__LINE__,__FILE__); |
|
| 143 | + ), __LINE__, __FILE__); |
|
| 144 | 144 | $api_version = $this->db->next_record() ? $this->db->f(0) : false; |
| 145 | 145 | } |
| 146 | - if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019')) |
|
| 146 | + if (!$api_version || !$this->alessthanb($api_version, '1.0.1.019')) |
|
| 147 | 147 | { |
| 148 | 148 | $this->db->Link_ID->SetCharSet($this->system_charset); |
| 149 | 149 | } |
@@ -163,15 +163,15 @@ discard block |
||
| 163 | 163 | static function cookiedomain() |
| 164 | 164 | { |
| 165 | 165 | // Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy |
| 166 | - $cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
| 166 | + $cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
| 167 | 167 | |
| 168 | 168 | // remove port from HTTP_HOST |
| 169 | 169 | $arr = null; |
| 170 | - if (preg_match("/^(.*):(.*)$/",$cookie_domain,$arr)) |
|
| 170 | + if (preg_match("/^(.*):(.*)$/", $cookie_domain, $arr)) |
|
| 171 | 171 | { |
| 172 | 172 | $cookie_domain = $arr[1]; |
| 173 | 173 | } |
| 174 | - if (count(explode('.',$cookie_domain)) <= 1) |
|
| 174 | + if (count(explode('.', $cookie_domain)) <= 1) |
|
| 175 | 175 | { |
| 176 | 176 | // setcookie dont likes domains without dots, leaving it empty, gets setcookie to fill the domain in |
| 177 | 177 | $cookie_domain = ''; |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
| 187 | 187 | * @param int $cookietime when cookie should expire, 0 for session only (optional) |
| 188 | 188 | */ |
| 189 | - function set_cookie($cookiename,$cookievalue='',$cookietime=0) |
|
| 189 | + function set_cookie($cookiename, $cookievalue = '', $cookietime = 0) |
|
| 190 | 190 | { |
| 191 | - if(!isset($this->cookie_domain)) |
|
| 191 | + if (!isset($this->cookie_domain)) |
|
| 192 | 192 | { |
| 193 | 193 | $this->cookie_domain = self::cookiedomain(); |
| 194 | 194 | } |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | if (!isset($_SESSION)) self::session_start(); |
| 214 | 214 | $ConfigLang = $_SESSION['ConfigLang']; |
| 215 | 215 | } |
| 216 | - if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang)) |
|
| 216 | + if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $ConfigLang)) |
|
| 217 | 217 | { |
| 218 | - $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader |
|
| 218 | + $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader |
|
| 219 | 219 | } |
| 220 | 220 | //error_log(__METHOD__."() \$_POST['ConfigLang']=".array2string($_POST['ConfigLang']).", \$_SESSION['ConfigLang']=".array2string($_SESSION['ConfigLang'])." returning ".array2string($ConfigLang)); |
| 221 | 221 | return $ConfigLang; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); |
| 249 | 249 | |
| 250 | - $ok = @session_start(); // suppress notice if session already started or warning in CLI |
|
| 250 | + $ok = @session_start(); // suppress notice if session already started or warning in CLI |
|
| 251 | 251 | // need to decrypt session, in case session encryption is switched on in header.inc.php |
| 252 | 252 | egw_session::decrypt(); |
| 253 | 253 | //error_log(__METHOD__."() returning ".array2string($ok).' _SESSION='.array2string($_SESSION)); |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * @param string $_auth_type ='config' 'config' or 'header' (caseinsensitiv) |
| 261 | 261 | */ |
| 262 | - function auth($_auth_type='config') |
|
| 262 | + function auth($_auth_type = 'config') |
|
| 263 | 263 | { |
| 264 | 264 | $auth_type = strtolower($_auth_type); |
| 265 | 265 | $GLOBALS['egw_info']['setup']['HeaderLoginMSG'] = $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = ''; |
| 266 | 266 | |
| 267 | - if(!$this->checkip(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? |
|
| 267 | + if (!$this->checkip(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? |
|
| 268 | 268 | $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'])) |
| 269 | 269 | { |
| 270 | 270 | //error_log(__METHOD__."('$auth_type') invalid IP"); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION).", \$_POST=".array2string($_POST)); |
| 278 | 278 | if (isset($_REQUEST['FormLogout'])) |
| 279 | 279 | { |
| 280 | - $this->set_cookie(self::SESSIONID, '', time()-86400); |
|
| 280 | + $this->set_cookie(self::SESSIONID, '', time() - 86400); |
|
| 281 | 281 | session_destroy(); |
| 282 | 282 | if ($_REQUEST['FormLogout'] == 'config') |
| 283 | 283 | { |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | { |
| 294 | 294 | return false; |
| 295 | 295 | } |
| 296 | - switch($auth_type) |
|
| 296 | + switch ($auth_type) |
|
| 297 | 297 | { |
| 298 | 298 | case 'config': |
| 299 | 299 | if (!isset($GLOBALS['egw_domain'][$_POST['FormDomain']]) || |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION)); |
| 334 | 334 | if ($_SESSION['egw_last_action_time'] < time() - self::TIMEOUT) |
| 335 | 335 | { |
| 336 | - $this->set_cookie(self::SESSIONID, '', time()-86400); |
|
| 336 | + $this->set_cookie(self::SESSIONID, '', time() - 86400); |
|
| 337 | 337 | session_destroy(); |
| 338 | 338 | $GLOBALS['egw_info']['setup'][$_SESSION['egw_setup_auth_type'] == 'config' ? 'ConfigLoginMSG' : 'HeaderLoginMSG'] = |
| 339 | 339 | lang('Session expired'); |
@@ -388,37 +388,37 @@ discard block |
||
| 388 | 388 | * @param string $remoteip |
| 389 | 389 | * @return boolean |
| 390 | 390 | */ |
| 391 | - function checkip($remoteip='') |
|
| 391 | + function checkip($remoteip = '') |
|
| 392 | 392 | { |
| 393 | 393 | //echo "<p>setup::checkip($remoteip) against setup_acl='".$GLOBALS['egw_info']['server']['setup_acl']."'</p>\n"; |
| 394 | - $allowed_ips = explode(',',@$GLOBALS['egw_info']['server']['setup_acl']); |
|
| 395 | - if(empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips)) |
|
| 394 | + $allowed_ips = explode(',', @$GLOBALS['egw_info']['server']['setup_acl']); |
|
| 395 | + if (empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips)) |
|
| 396 | 396 | { |
| 397 | - return True; // no test |
|
| 397 | + return True; // no test |
|
| 398 | 398 | } |
| 399 | - $remotes = explode('.',$remoteip); |
|
| 400 | - foreach($allowed_ips as $value) |
|
| 399 | + $remotes = explode('.', $remoteip); |
|
| 400 | + foreach ($allowed_ips as $value) |
|
| 401 | 401 | { |
| 402 | - if (!preg_match('/^[0-9.]+$/',$value)) |
|
| 402 | + if (!preg_match('/^[0-9.]+$/', $value)) |
|
| 403 | 403 | { |
| 404 | - $value = gethostbyname($was=$value); // resolve domain-name, eg. a dyndns account |
|
| 404 | + $value = gethostbyname($was = $value); // resolve domain-name, eg. a dyndns account |
|
| 405 | 405 | //echo "resolving '$was' to '$value'<br>\n"; |
| 406 | 406 | } |
| 407 | - $values = explode('.',$value); |
|
| 408 | - for($i = 0; $i < count($values); ++$i) |
|
| 407 | + $values = explode('.', $value); |
|
| 408 | + for ($i = 0; $i < count($values); ++$i) |
|
| 409 | 409 | { |
| 410 | - if ((int) $values[$i] != (int) $remotes[$i]) |
|
| 410 | + if ((int)$values[$i] != (int)$remotes[$i]) |
|
| 411 | 411 | { |
| 412 | 412 | break; |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | if ($i == count($values)) |
| 416 | 416 | { |
| 417 | - return True; // match |
|
| 417 | + return True; // match |
|
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = lang('Invalid IP address').' '.$remoteip; |
| 421 | - error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip,true)); |
|
| 421 | + error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip, true)); |
|
| 422 | 422 | return False; |
| 423 | 423 | } |
| 424 | 424 | |
@@ -429,14 +429,14 @@ discard block |
||
| 429 | 429 | */ |
| 430 | 430 | function get_major($versionstring) |
| 431 | 431 | { |
| 432 | - if(!$versionstring) |
|
| 432 | + if (!$versionstring) |
|
| 433 | 433 | { |
| 434 | 434 | return False; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - $version = str_replace('pre','.',$versionstring); |
|
| 438 | - $varray = explode('.',$version); |
|
| 439 | - $major = implode('.',array($varray[0],$varray[1],$varray[2])); |
|
| 437 | + $version = str_replace('pre', '.', $versionstring); |
|
| 438 | + $varray = explode('.', $version); |
|
| 439 | + $major = implode('.', array($varray[0], $varray[1], $varray[2])); |
|
| 440 | 440 | |
| 441 | 441 | return $major; |
| 442 | 442 | } |
@@ -456,55 +456,55 @@ discard block |
||
| 456 | 456 | * @param $appname Application 'name' with a matching $setup_info[$appname] array slice |
| 457 | 457 | * @param $_enable =99 set to True/False to override setup.inc.php setting |
| 458 | 458 | */ |
| 459 | - function register_app($appname, $_enable=99) |
|
| 459 | + function register_app($appname, $_enable = 99) |
|
| 460 | 460 | { |
| 461 | 461 | $setup_info = $GLOBALS['setup_info']; |
| 462 | 462 | |
| 463 | - if(!$appname) |
|
| 463 | + if (!$appname) |
|
| 464 | 464 | { |
| 465 | 465 | return False; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if($_enable == 99) |
|
| 468 | + if ($_enable == 99) |
|
| 469 | 469 | { |
| 470 | 470 | $_enable = $setup_info[$appname]['enable']; |
| 471 | 471 | } |
| 472 | 472 | $enable = (int)$_enable; |
| 473 | 473 | |
| 474 | - if($GLOBALS['DEBUG']) |
|
| 474 | + if ($GLOBALS['DEBUG']) |
|
| 475 | 475 | { |
| 476 | - echo '<br>register_app(): ' . $appname . ', version: ' . $setup_info[$appname]['version'] . ', tables: ' . implode(', ',$setup_info[$appname]['tables']) . '<br>'; |
|
| 476 | + echo '<br>register_app(): '.$appname.', version: '.$setup_info[$appname]['version'].', tables: '.implode(', ', $setup_info[$appname]['tables']).'<br>'; |
|
| 477 | 477 | // _debug_array($setup_info[$appname]); |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - if($setup_info[$appname]['version']) |
|
| 480 | + if ($setup_info[$appname]['version']) |
|
| 481 | 481 | { |
| 482 | - if($setup_info[$appname]['tables']) |
|
| 482 | + if ($setup_info[$appname]['tables']) |
|
| 483 | 483 | { |
| 484 | - $tables = implode(',',$setup_info[$appname]['tables']); |
|
| 484 | + $tables = implode(',', $setup_info[$appname]['tables']); |
|
| 485 | 485 | } |
| 486 | 486 | if ($setup_info[$appname]['tables_use_prefix'] == True) |
| 487 | 487 | { |
| 488 | - if($GLOBALS['DEBUG']) |
|
| 488 | + if ($GLOBALS['DEBUG']) |
|
| 489 | 489 | { |
| 490 | - echo "<br>$appname uses tables_use_prefix, storing ". $setup_info[$appname]['tables_prefix']." as prefix for tables\n"; |
|
| 490 | + echo "<br>$appname uses tables_use_prefix, storing ".$setup_info[$appname]['tables_prefix']." as prefix for tables\n"; |
|
| 491 | 491 | } |
| 492 | - $this->db->insert($this->config_table,array( |
|
| 492 | + $this->db->insert($this->config_table, array( |
|
| 493 | 493 | 'config_app' => $appname, |
| 494 | 494 | 'config_name' => $appname.'_tables_prefix', |
| 495 | 495 | 'config_value' => $setup_info[$appname]['tables_prefix'], |
| 496 | - ),False,__LINE__,__FILE__); |
|
| 496 | + ), False, __LINE__, __FILE__); |
|
| 497 | 497 | } |
| 498 | - $this->db->insert($this->applications_table,array( |
|
| 498 | + $this->db->insert($this->applications_table, array( |
|
| 499 | 499 | 'app_name' => $appname, |
| 500 | 500 | 'app_enabled' => $enable, |
| 501 | 501 | 'app_order' => $setup_info[$appname]['app_order'], |
| 502 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
| 502 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
| 503 | 503 | 'app_version' => $setup_info[$appname]['version'], |
| 504 | 504 | 'app_index' => $setup_info[$appname]['index'], |
| 505 | 505 | 'app_icon' => $setup_info[$appname]['icon'], |
| 506 | 506 | 'app_icon_app' => $setup_info[$appname]['icon_app'], |
| 507 | - ),False,__LINE__,__FILE__); |
|
| 507 | + ), False, __LINE__, __FILE__); |
|
| 508 | 508 | |
| 509 | 509 | $this->clear_session_cache(); |
| 510 | 510 | } |
@@ -518,27 +518,27 @@ discard block |
||
| 518 | 518 | */ |
| 519 | 519 | function app_registered($appname) |
| 520 | 520 | { |
| 521 | - if(!$appname) |
|
| 521 | + if (!$appname) |
|
| 522 | 522 | { |
| 523 | 523 | return False; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - if(@$GLOBALS['DEBUG']) |
|
| 526 | + if (@$GLOBALS['DEBUG']) |
|
| 527 | 527 | { |
| 528 | - echo '<br>app_registered(): checking ' . $appname . ', table: ' . $this->applications_table; |
|
| 528 | + echo '<br>app_registered(): checking '.$appname.', table: '.$this->applications_table; |
|
| 529 | 529 | // _debug_array($setup_info[$appname]); |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - $this->db->select($this->applications_table,'COUNT(*)',array('app_name' => $appname),__LINE__,__FILE__); |
|
| 533 | - if($this->db->next_record() && $this->db->f(0)) |
|
| 532 | + $this->db->select($this->applications_table, 'COUNT(*)', array('app_name' => $appname), __LINE__, __FILE__); |
|
| 533 | + if ($this->db->next_record() && $this->db->f(0)) |
|
| 534 | 534 | { |
| 535 | - if(@$GLOBALS['DEBUG']) |
|
| 535 | + if (@$GLOBALS['DEBUG']) |
|
| 536 | 536 | { |
| 537 | 537 | echo '... app previously registered.'; |
| 538 | 538 | } |
| 539 | 539 | return True; |
| 540 | 540 | } |
| 541 | - if(@$GLOBALS['DEBUG']) |
|
| 541 | + if (@$GLOBALS['DEBUG']) |
|
| 542 | 542 | { |
| 543 | 543 | echo '... app not registered'; |
| 544 | 544 | } |
@@ -555,38 +555,38 @@ discard block |
||
| 555 | 555 | { |
| 556 | 556 | $setup_info = $GLOBALS['setup_info']; |
| 557 | 557 | |
| 558 | - if(!$appname) |
|
| 558 | + if (!$appname) |
|
| 559 | 559 | { |
| 560 | 560 | return False; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - if($GLOBALS['DEBUG']) |
|
| 563 | + if ($GLOBALS['DEBUG']) |
|
| 564 | 564 | { |
| 565 | - echo '<br>update_app(): ' . $appname . ', version: ' . $setup_info[$appname]['currentver'] . ', table: ' . $this->applications_table . '<br>'; |
|
| 565 | + echo '<br>update_app(): '.$appname.', version: '.$setup_info[$appname]['currentver'].', table: '.$this->applications_table.'<br>'; |
|
| 566 | 566 | // _debug_array($setup_info[$appname]); |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - if(!$this->app_registered($appname)) |
|
| 569 | + if (!$this->app_registered($appname)) |
|
| 570 | 570 | { |
| 571 | 571 | return False; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if($setup_info[$appname]['version']) |
|
| 574 | + if ($setup_info[$appname]['version']) |
|
| 575 | 575 | { |
| 576 | 576 | //echo '<br>' . $setup_info[$appname]['version']; |
| 577 | - if($setup_info[$appname]['tables']) |
|
| 577 | + if ($setup_info[$appname]['tables']) |
|
| 578 | 578 | { |
| 579 | - $tables = implode(',',$setup_info[$appname]['tables']); |
|
| 579 | + $tables = implode(',', $setup_info[$appname]['tables']); |
|
| 580 | 580 | } |
| 581 | - $this->db->update($this->applications_table,array( |
|
| 581 | + $this->db->update($this->applications_table, array( |
|
| 582 | 582 | 'app_enabled' => $setup_info[$appname]['enable'], |
| 583 | 583 | 'app_order' => $setup_info[$appname]['app_order'], |
| 584 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
| 584 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
| 585 | 585 | 'app_version' => $setup_info[$appname]['version'], |
| 586 | 586 | 'app_index' => $setup_info[$appname]['index'], |
| 587 | 587 | 'app_icon' => $setup_info[$appname]['icon'], |
| 588 | 588 | 'app_icon_app' => $setup_info[$appname]['icon_app'], |
| 589 | - ),array('app_name'=>$appname),__LINE__,__FILE__); |
|
| 589 | + ), array('app_name'=>$appname), __LINE__, __FILE__); |
|
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | |
@@ -599,20 +599,20 @@ discard block |
||
| 599 | 599 | */ |
| 600 | 600 | function update_app_version($setup_info, $appname, $tableschanged = True) |
| 601 | 601 | { |
| 602 | - if(!$appname) |
|
| 602 | + if (!$appname) |
|
| 603 | 603 | { |
| 604 | 604 | return False; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - if($tableschanged == True) |
|
| 607 | + if ($tableschanged == True) |
|
| 608 | 608 | { |
| 609 | 609 | $GLOBALS['egw_info']['setup']['tableschanged'] = True; |
| 610 | 610 | } |
| 611 | - if($setup_info[$appname]['currentver']) |
|
| 611 | + if ($setup_info[$appname]['currentver']) |
|
| 612 | 612 | { |
| 613 | - $this->db->update($this->applications_table,array( |
|
| 613 | + $this->db->update($this->applications_table, array( |
|
| 614 | 614 | 'app_version' => $setup_info[$appname]['currentver'], |
| 615 | - ),array('app_name'=>$appname),__LINE__,__FILE__); |
|
| 615 | + ), array('app_name'=>$appname), __LINE__, __FILE__); |
|
| 616 | 616 | } |
| 617 | 617 | return $setup_info; |
| 618 | 618 | } |
@@ -624,19 +624,19 @@ discard block |
||
| 624 | 624 | */ |
| 625 | 625 | function deregister_app($appname) |
| 626 | 626 | { |
| 627 | - if(!$appname) |
|
| 627 | + if (!$appname) |
|
| 628 | 628 | { |
| 629 | 629 | return False; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Remove categories |
| 633 | - $this->db->delete(categories::TABLE, array('cat_appname'=>$appname),__LINE__,__FILE__); |
|
| 633 | + $this->db->delete(categories::TABLE, array('cat_appname'=>$appname), __LINE__, __FILE__); |
|
| 634 | 634 | categories::invalidate_cache($appname); |
| 635 | 635 | |
| 636 | 636 | // Remove config |
| 637 | - $this->db->delete(config::TABLE, array('config_app'=>$appname),__LINE__,__FILE__); |
|
| 637 | + $this->db->delete(config::TABLE, array('config_app'=>$appname), __LINE__, __FILE__); |
|
| 638 | 638 | //echo 'DELETING application: ' . $appname; |
| 639 | - $this->db->delete($this->applications_table,array('app_name'=>$appname),__LINE__,__FILE__); |
|
| 639 | + $this->db->delete($this->applications_table, array('app_name'=>$appname), __LINE__, __FILE__); |
|
| 640 | 640 | |
| 641 | 641 | // Remove links to the app |
| 642 | 642 | egw_link::unlink(0, $appname); |
@@ -653,21 +653,21 @@ discard block |
||
| 653 | 653 | { |
| 654 | 654 | $setup_info = $GLOBALS['setup_info']; |
| 655 | 655 | |
| 656 | - if(!$appname) |
|
| 656 | + if (!$appname) |
|
| 657 | 657 | { |
| 658 | 658 | return False; |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - if(!$this->hooks_table) // No hooks table yet |
|
| 661 | + if (!$this->hooks_table) // No hooks table yet |
|
| 662 | 662 | { |
| 663 | 663 | return False; |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | if (!is_object($this->hooks)) |
| 667 | 667 | { |
| 668 | - $this->hooks =& CreateObject('phpgwapi.hooks',$this->db,$this->hooks_table); |
|
| 668 | + $this->hooks = & CreateObject('phpgwapi.hooks', $this->db, $this->hooks_table); |
|
| 669 | 669 | } |
| 670 | - $this->hooks->register_hooks($appname,$setup_info[$appname]['hooks']); |
|
| 670 | + $this->hooks->register_hooks($appname, $setup_info[$appname]['hooks']); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | /** |
@@ -682,20 +682,20 @@ discard block |
||
| 682 | 682 | |
| 683 | 683 | if (!isset($setup_info) || !isset($setup_info['hooks'])) |
| 684 | 684 | { |
| 685 | - return false; // app not found or no hook |
|
| 685 | + return false; // app not found or no hook |
|
| 686 | 686 | } |
| 687 | 687 | $GLOBALS['settings'] = array(); |
| 688 | 688 | if (isset($setup_info['hooks']['settings'])) |
| 689 | 689 | { |
| 690 | - $settings = ExecMethod($setup_info['hooks']['settings'],array('location' => 'settings','setup' => true)); |
|
| 690 | + $settings = ExecMethod($setup_info['hooks']['settings'], array('location' => 'settings', 'setup' => true)); |
|
| 691 | 691 | } |
| 692 | - elseif(in_array('settings',$setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php')) |
|
| 692 | + elseif (in_array('settings', $setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php')) |
|
| 693 | 693 | { |
| 694 | 694 | include_once($file); |
| 695 | 695 | } |
| 696 | 696 | if (!isset($settings) || !is_array($settings)) |
| 697 | 697 | { |
| 698 | - $settings = $GLOBALS['settings']; // old file hook or not updated new hook |
|
| 698 | + $settings = $GLOBALS['settings']; // old file hook or not updated new hook |
|
| 699 | 699 | } |
| 700 | 700 | if (!is_array($settings) || !count($settings)) |
| 701 | 701 | { |
@@ -706,10 +706,10 @@ discard block |
||
| 706 | 706 | { |
| 707 | 707 | $GLOBALS['settings'] = array(); |
| 708 | 708 | include_once($file); |
| 709 | - if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']); |
|
| 709 | + if ($GLOBALS['settings']) $settings = array_merge($settings, $GLOBALS['settings']); |
|
| 710 | 710 | } |
| 711 | 711 | $default = $forced = array(); |
| 712 | - foreach($settings as $name => $setting) |
|
| 712 | + foreach ($settings as $name => $setting) |
|
| 713 | 713 | { |
| 714 | 714 | if (isset($setting['default'])) |
| 715 | 715 | { |
@@ -723,14 +723,14 @@ discard block |
||
| 723 | 723 | // store default/forced preferences, if any found |
| 724 | 724 | $preferences = new preferences(); |
| 725 | 725 | $preferences->read_repository(false); |
| 726 | - foreach(array( |
|
| 726 | + foreach (array( |
|
| 727 | 727 | 'default' => $default, |
| 728 | 728 | 'forced' => $forced, |
| 729 | 729 | ) as $type => $prefs) |
| 730 | 730 | { |
| 731 | 731 | if ($prefs) |
| 732 | 732 | { |
| 733 | - foreach($prefs as $name => $value) |
|
| 733 | + foreach ($prefs as $name => $value) |
|
| 734 | 734 | { |
| 735 | 735 | $preferences->add($appname == 'preferences' ? 'common' : $appname, $name, $value, $type); |
| 736 | 736 | } |
@@ -759,12 +759,12 @@ discard block |
||
| 759 | 759 | */ |
| 760 | 760 | function deregister_hooks($appname) |
| 761 | 761 | { |
| 762 | - if(!$this->hooks_table) // No hooks table yet |
|
| 762 | + if (!$this->hooks_table) // No hooks table yet |
|
| 763 | 763 | { |
| 764 | 764 | return False; |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | - if(!$appname) |
|
| 767 | + if (!$appname) |
|
| 768 | 768 | { |
| 769 | 769 | return False; |
| 770 | 770 | } |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | //echo "DELETING hooks for: " . $setup_info[$appname]['name']; |
| 773 | 773 | if (!is_object($this->hooks)) |
| 774 | 774 | { |
| 775 | - $this->hooks =& CreateObject('phpgwapi.hooks',$this->db,$this->hooks_table); |
|
| 775 | + $this->hooks = & CreateObject('phpgwapi.hooks', $this->db, $this->hooks_table); |
|
| 776 | 776 | } |
| 777 | 777 | return $this->hooks->register_hooks($appname); |
| 778 | 778 | } |
@@ -783,13 +783,13 @@ discard block |
||
| 783 | 783 | * @param $location hook location - required |
| 784 | 784 | * @param $appname application name - optional |
| 785 | 785 | */ |
| 786 | - function hook($location, $appname='') |
|
| 786 | + function hook($location, $appname = '') |
|
| 787 | 787 | { |
| 788 | 788 | if (!is_object($this->hooks)) |
| 789 | 789 | { |
| 790 | - $this->hooks =& CreateObject('phpgwapi.hooks',$this->db,$this->hooks_table); |
|
| 790 | + $this->hooks = & CreateObject('phpgwapi.hooks', $this->db, $this->hooks_table); |
|
| 791 | 791 | } |
| 792 | - return $this->hooks->single($location,$appname,True,True); |
|
| 792 | + return $this->hooks->single($location, $appname, True, True); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
@@ -798,82 +798,82 @@ discard block |
||
| 798 | 798 | * @param $b phpgw version number to check $a against |
| 799 | 799 | * @return True if $a < $b |
| 800 | 800 | */ |
| 801 | - function alessthanb($a,$b,$DEBUG=False) |
|
| 801 | + function alessthanb($a, $b, $DEBUG = False) |
|
| 802 | 802 | { |
| 803 | - $num = array('1st','2nd','3rd','4th'); |
|
| 803 | + $num = array('1st', '2nd', '3rd', '4th'); |
|
| 804 | 804 | |
| 805 | - if($DEBUG) |
|
| 805 | + if ($DEBUG) |
|
| 806 | 806 | { |
| 807 | 807 | echo'<br>Input values: ' |
| 808 | 808 | . 'A="'.$a.'", B="'.$b.'"'; |
| 809 | 809 | } |
| 810 | - $newa = str_replace('pre','.',$a); |
|
| 811 | - $newb = str_replace('pre','.',$b); |
|
| 812 | - $testa = explode('.',$newa); |
|
| 813 | - if(@$testa[1] == '') |
|
| 810 | + $newa = str_replace('pre', '.', $a); |
|
| 811 | + $newb = str_replace('pre', '.', $b); |
|
| 812 | + $testa = explode('.', $newa); |
|
| 813 | + if (@$testa[1] == '') |
|
| 814 | 814 | { |
| 815 | 815 | $testa[1] = 0; |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | - $testb = explode('.',$newb); |
|
| 819 | - if(@$testb[1] == '') |
|
| 818 | + $testb = explode('.', $newb); |
|
| 819 | + if (@$testb[1] == '') |
|
| 820 | 820 | { |
| 821 | 821 | $testb[1] = 0; |
| 822 | 822 | } |
| 823 | - if(@$testb[3] == '') |
|
| 823 | + if (@$testb[3] == '') |
|
| 824 | 824 | { |
| 825 | 825 | $testb[3] = 0; |
| 826 | 826 | } |
| 827 | 827 | $less = 0; |
| 828 | 828 | |
| 829 | - for($i=0;$i<count($testa);$i++) |
|
| 829 | + for ($i = 0; $i < count($testa); $i++) |
|
| 830 | 830 | { |
| 831 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
| 832 | - if((int)$testa[$i] < (int)$testb[$i]) |
|
| 831 | + if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is less than '.(int)$testb[$i].' ...'; } |
|
| 832 | + if ((int)$testa[$i] < (int)$testb[$i]) |
|
| 833 | 833 | { |
| 834 | 834 | if ($DEBUG) { echo ' yes.'; } |
| 835 | 835 | $less++; |
| 836 | - if($i<3) |
|
| 836 | + if ($i < 3) |
|
| 837 | 837 | { |
| 838 | 838 | /* Ensure that this is definitely smaller */ |
| 839 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
| 839 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
| 840 | 840 | $less = 5; |
| 841 | 841 | break; |
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | - elseif((int)$testa[$i] > (int)$testb[$i]) |
|
| 844 | + elseif ((int)$testa[$i] > (int)$testb[$i]) |
|
| 845 | 845 | { |
| 846 | - if($DEBUG) { echo ' no.'; } |
|
| 846 | + if ($DEBUG) { echo ' no.'; } |
|
| 847 | 847 | $less--; |
| 848 | - if($i<2) |
|
| 848 | + if ($i < 2) |
|
| 849 | 849 | { |
| 850 | 850 | /* Ensure that this is definitely greater */ |
| 851 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
| 851 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
| 852 | 852 | $less = -5; |
| 853 | 853 | break; |
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | else |
| 857 | 857 | { |
| 858 | - if($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
| 858 | + if ($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
| 859 | 859 | // makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' ! |
| 860 | 860 | $less = count($testa) < count($testb) ? 1 : 0; |
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
| 864 | - if($less>0) |
|
| 863 | + if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
| 864 | + if ($less > 0) |
|
| 865 | 865 | { |
| 866 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
| 866 | + if ($DEBUG) { echo '<br>A is less than B'; } |
|
| 867 | 867 | return True; |
| 868 | 868 | } |
| 869 | - elseif($less<0) |
|
| 869 | + elseif ($less < 0) |
|
| 870 | 870 | { |
| 871 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
| 871 | + if ($DEBUG) { echo '<br>A is greater than B'; } |
|
| 872 | 872 | return False; |
| 873 | 873 | } |
| 874 | 874 | else |
| 875 | 875 | { |
| 876 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
| 876 | + if ($DEBUG) { echo '<br>A is equal to B'; } |
|
| 877 | 877 | return False; |
| 878 | 878 | } |
| 879 | 879 | } |
@@ -885,76 +885,76 @@ discard block |
||
| 885 | 885 | * @param $b phpgw version number to check $a against |
| 886 | 886 | * @return True if $a < $b |
| 887 | 887 | */ |
| 888 | - function amorethanb($a,$b,$DEBUG=False) |
|
| 888 | + function amorethanb($a, $b, $DEBUG = False) |
|
| 889 | 889 | { |
| 890 | - $num = array('1st','2nd','3rd','4th'); |
|
| 890 | + $num = array('1st', '2nd', '3rd', '4th'); |
|
| 891 | 891 | |
| 892 | - if($DEBUG) |
|
| 892 | + if ($DEBUG) |
|
| 893 | 893 | { |
| 894 | 894 | echo'<br>Input values: ' |
| 895 | 895 | . 'A="'.$a.'", B="'.$b.'"'; |
| 896 | 896 | } |
| 897 | - $newa = str_replace('pre','.',$a); |
|
| 898 | - $newb = str_replace('pre','.',$b); |
|
| 899 | - $testa = explode('.',$newa); |
|
| 900 | - if($testa[3] == '') |
|
| 897 | + $newa = str_replace('pre', '.', $a); |
|
| 898 | + $newb = str_replace('pre', '.', $b); |
|
| 899 | + $testa = explode('.', $newa); |
|
| 900 | + if ($testa[3] == '') |
|
| 901 | 901 | { |
| 902 | 902 | $testa[3] = 0; |
| 903 | 903 | } |
| 904 | - $testb = explode('.',$newb); |
|
| 905 | - if($testb[3] == '') |
|
| 904 | + $testb = explode('.', $newb); |
|
| 905 | + if ($testb[3] == '') |
|
| 906 | 906 | { |
| 907 | 907 | $testb[3] = 0; |
| 908 | 908 | } |
| 909 | 909 | $less = 0; |
| 910 | 910 | |
| 911 | - for($i=0;$i<count($testa);$i++) |
|
| 911 | + for ($i = 0; $i < count($testa); $i++) |
|
| 912 | 912 | { |
| 913 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
| 914 | - if((int)$testa[$i] > (int)$testb[$i]) |
|
| 913 | + if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is more than '.(int)$testb[$i].' ...'; } |
|
| 914 | + if ((int)$testa[$i] > (int)$testb[$i]) |
|
| 915 | 915 | { |
| 916 | - if($DEBUG) { echo ' yes.'; } |
|
| 916 | + if ($DEBUG) { echo ' yes.'; } |
|
| 917 | 917 | $less++; |
| 918 | - if($i<3) |
|
| 918 | + if ($i < 3) |
|
| 919 | 919 | { |
| 920 | 920 | /* Ensure that this is definitely greater */ |
| 921 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
| 921 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
| 922 | 922 | $less = 5; |
| 923 | 923 | break; |
| 924 | 924 | } |
| 925 | 925 | } |
| 926 | - elseif((int)$testa[$i] < (int)$testb[$i]) |
|
| 926 | + elseif ((int)$testa[$i] < (int)$testb[$i]) |
|
| 927 | 927 | { |
| 928 | - if($DEBUG) { echo ' no.'; } |
|
| 928 | + if ($DEBUG) { echo ' no.'; } |
|
| 929 | 929 | $less--; |
| 930 | - if($i<2) |
|
| 930 | + if ($i < 2) |
|
| 931 | 931 | { |
| 932 | 932 | /* Ensure that this is definitely smaller */ |
| 933 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
| 933 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
| 934 | 934 | $less = -5; |
| 935 | 935 | break; |
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | else |
| 939 | 939 | { |
| 940 | - if($DEBUG) { echo ' no, they are equal.'; } |
|
| 940 | + if ($DEBUG) { echo ' no, they are equal.'; } |
|
| 941 | 941 | $less = 0; |
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
| 945 | - if($less>0) |
|
| 944 | + if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
| 945 | + if ($less > 0) |
|
| 946 | 946 | { |
| 947 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
| 947 | + if ($DEBUG) { echo '<br>A is greater than B'; } |
|
| 948 | 948 | return True; |
| 949 | 949 | } |
| 950 | - elseif($less<0) |
|
| 950 | + elseif ($less < 0) |
|
| 951 | 951 | { |
| 952 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
| 952 | + if ($DEBUG) { echo '<br>A is less than B'; } |
|
| 953 | 953 | return False; |
| 954 | 954 | } |
| 955 | 955 | else |
| 956 | 956 | { |
| 957 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
| 957 | + if ($DEBUG) { echo '<br>A is equal to B'; } |
|
| 958 | 958 | return False; |
| 959 | 959 | } |
| 960 | 960 | } |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | */ |
| 967 | 967 | var $accounts; |
| 968 | 968 | |
| 969 | - function setup_account_object(array $config=array()) |
|
| 969 | + function setup_account_object(array $config = array()) |
|
| 970 | 970 | { |
| 971 | 971 | if (!isset($this->accounts) || $this->accounts->config || $config) |
| 972 | 972 | { |
@@ -977,9 +977,9 @@ discard block |
||
| 977 | 977 | if (!$config) |
| 978 | 978 | { |
| 979 | 979 | // load the configuration from the database |
| 980 | - foreach($this->db->select($this->config_table,'config_name,config_value', |
|
| 980 | + foreach ($this->db->select($this->config_table, 'config_name,config_value', |
|
| 981 | 981 | "config_name LIKE 'ads%' OR config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type'", |
| 982 | - __LINE__,__FILE__) as $row) |
|
| 982 | + __LINE__, __FILE__) as $row) |
|
| 983 | 983 | { |
| 984 | 984 | $GLOBALS['egw_info']['server'][$row['config_name']] = $config[$row['config_name']] = $row['config_value']; |
| 985 | 985 | } |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | return false; |
| 993 | 993 | } |
| 994 | 994 | if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts; |
| 995 | - accounts::cache_invalidate(); // the cache is shared for all instances of the class |
|
| 995 | + accounts::cache_invalidate(); // the cache is shared for all instances of the class |
|
| 996 | 996 | } |
| 997 | 997 | return true; |
| 998 | 998 | } |
@@ -1018,7 +1018,7 @@ discard block |
||
| 1018 | 1018 | * @param string &$anonpw=null on return password for anonymous user |
| 1019 | 1019 | * @return int the numerical user-id |
| 1020 | 1020 | */ |
| 1021 | - function add_account($username,$first,$last,$passwd,$primary_group='Default',$changepw=False,$email='',&$anonpw=null) |
|
| 1021 | + function add_account($username, $first, $last, $passwd, $primary_group = 'Default', $changepw = False, $email = '', &$anonpw = null) |
|
| 1022 | 1022 | { |
| 1023 | 1023 | $this->setup_account_object(); |
| 1024 | 1024 | |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | $passwd = $anonpw = $this->anonpw; |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - if(!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g'))) |
|
| 1033 | + if (!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g'))) |
|
| 1034 | 1034 | { |
| 1035 | 1035 | $account = array( |
| 1036 | 1036 | 'account_type' => $primary_group ? 'u' : 'g', |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | } |
| 1052 | 1052 | } |
| 1053 | 1053 | // set password for existing account, if given and not '*unchanged*' |
| 1054 | - elseif($passwd && $passwd != '*unchanged*') |
|
| 1054 | + elseif ($passwd && $passwd != '*unchanged*') |
|
| 1055 | 1055 | { |
| 1056 | 1056 | try { |
| 1057 | 1057 | $auth = new auth; |
@@ -1089,7 +1089,7 @@ discard block |
||
| 1089 | 1089 | { |
| 1090 | 1090 | $this->set_memberships(array($primary_group_id), $accountid); |
| 1091 | 1091 | |
| 1092 | - if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid); |
|
| 1092 | + if (!$changepw) $this->add_acl('preferences', 'nopasswordchange', $accountid); |
|
| 1093 | 1093 | } |
| 1094 | 1094 | //error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid"); |
| 1095 | 1095 | return $accountid; |
@@ -1137,7 +1137,7 @@ discard block |
||
| 1137 | 1137 | { |
| 1138 | 1138 | return false; |
| 1139 | 1139 | } |
| 1140 | - foreach($accounts as $account) |
|
| 1140 | + foreach ($accounts as $account) |
|
| 1141 | 1141 | { |
| 1142 | 1142 | if ($account['account_lid'] != 'anonymous') |
| 1143 | 1143 | { |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | * @param int|string $account accountid or account_lid |
| 1159 | 1159 | * @param int $rights rights to set, default 1 |
| 1160 | 1160 | */ |
| 1161 | - function add_acl($apps,$location,$account,$rights=1) |
|
| 1161 | + function add_acl($apps, $location, $account, $rights = 1) |
|
| 1162 | 1162 | { |
| 1163 | 1163 | //error_log("setup::add_acl(".(is_array($apps) ? "array('".implode("','",$apps)."')" : "'$apps'").",'$location',$account,$rights)"); |
| 1164 | 1164 | if (!is_numeric($account)) |
@@ -1166,32 +1166,32 @@ discard block |
||
| 1166 | 1166 | $this->setup_account_object(); |
| 1167 | 1167 | $account = $this->accounts->name2id($account); |
| 1168 | 1168 | } |
| 1169 | - if(!is_object($this->db)) |
|
| 1169 | + if (!is_object($this->db)) |
|
| 1170 | 1170 | { |
| 1171 | 1171 | $this->loaddb(); |
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | - if(!is_array($apps)) |
|
| 1174 | + if (!is_array($apps)) |
|
| 1175 | 1175 | { |
| 1176 | 1176 | $apps = array($apps); |
| 1177 | 1177 | } |
| 1178 | - foreach($apps as $app) |
|
| 1178 | + foreach ($apps as $app) |
|
| 1179 | 1179 | { |
| 1180 | - $this->db->delete($this->acl_table,array( |
|
| 1180 | + $this->db->delete($this->acl_table, array( |
|
| 1181 | 1181 | 'acl_appname' => $app, |
| 1182 | 1182 | 'acl_location' => $location, |
| 1183 | 1183 | 'acl_account' => $account |
| 1184 | - ),__LINE__,__FILE__); |
|
| 1184 | + ), __LINE__, __FILE__); |
|
| 1185 | 1185 | |
| 1186 | - if ((int) $rights) |
|
| 1186 | + if ((int)$rights) |
|
| 1187 | 1187 | { |
| 1188 | - $this->db->insert($this->acl_table,array( |
|
| 1188 | + $this->db->insert($this->acl_table, array( |
|
| 1189 | 1189 | 'acl_rights' => $rights |
| 1190 | - ),array( |
|
| 1190 | + ), array( |
|
| 1191 | 1191 | 'acl_appname' => $app, |
| 1192 | 1192 | 'acl_location' => $location, |
| 1193 | 1193 | 'acl_account' => $account, |
| 1194 | - ),__LINE__,__FILE__); |
|
| 1194 | + ), __LINE__, __FILE__); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | } |
| 1197 | 1197 | } |
@@ -1202,7 +1202,7 @@ discard block |
||
| 1202 | 1202 | * @param array $tables array with possible table-names |
| 1203 | 1203 | * @return string/boolean tablename or false |
| 1204 | 1204 | */ |
| 1205 | - function table_exist($tables,$force_refresh=False) |
|
| 1205 | + function table_exist($tables, $force_refresh = False) |
|
| 1206 | 1206 | { |
| 1207 | 1207 | static $table_names = False; |
| 1208 | 1208 | |
@@ -1210,9 +1210,9 @@ discard block |
||
| 1210 | 1210 | |
| 1211 | 1211 | if (!$table_names) return false; |
| 1212 | 1212 | |
| 1213 | - foreach($table_names as $data) |
|
| 1213 | + foreach ($table_names as $data) |
|
| 1214 | 1214 | { |
| 1215 | - if (($key = array_search($data['table_name'],$tables)) !== false) |
|
| 1215 | + if (($key = array_search($data['table_name'], $tables)) !== false) |
|
| 1216 | 1216 | { |
| 1217 | 1217 | return $tables[$key]; |
| 1218 | 1218 | } |
@@ -1225,18 +1225,18 @@ discard block |
||
| 1225 | 1225 | * |
| 1226 | 1226 | * Other tables can always use the most up to date name |
| 1227 | 1227 | */ |
| 1228 | - function set_table_names($force_refresh=False) |
|
| 1228 | + function set_table_names($force_refresh = False) |
|
| 1229 | 1229 | { |
| 1230 | - foreach(array( |
|
| 1231 | - 'config_table' => array('egw_config','phpgw_config','config'), |
|
| 1232 | - 'applications_table' => array('egw_applications','phpgw_applications','applications'), |
|
| 1233 | - 'accounts_table' => array('egw_accounts','phpgw_accounts'), |
|
| 1234 | - 'acl_table' => array('egw_acl','phpgw_acl'), |
|
| 1235 | - 'lang_table' => array('egw_lang','phpgw_lang','lang'), |
|
| 1236 | - 'languages_table' => array('egw_languages','phpgw_languages','languages'), |
|
| 1230 | + foreach (array( |
|
| 1231 | + 'config_table' => array('egw_config', 'phpgw_config', 'config'), |
|
| 1232 | + 'applications_table' => array('egw_applications', 'phpgw_applications', 'applications'), |
|
| 1233 | + 'accounts_table' => array('egw_accounts', 'phpgw_accounts'), |
|
| 1234 | + 'acl_table' => array('egw_acl', 'phpgw_acl'), |
|
| 1235 | + 'lang_table' => array('egw_lang', 'phpgw_lang', 'lang'), |
|
| 1236 | + 'languages_table' => array('egw_languages', 'phpgw_languages', 'languages'), |
|
| 1237 | 1237 | ) as $name => $tables) |
| 1238 | 1238 | { |
| 1239 | - $table = $this->table_exist($tables,$force_refresh); |
|
| 1239 | + $table = $this->table_exist($tables, $force_refresh); |
|
| 1240 | 1240 | |
| 1241 | 1241 | if ($table && $table != $this->$name) // only overwrite the default name, if we realy got one (important for new installs) |
| 1242 | 1242 | { |