@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param boolean $verbose =false if true, echos out some status information during the run |
31 | 31 | * @param string $app =null single application to update or install |
32 | 32 | */ |
33 | - function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$verbose=false,$app=null) |
|
33 | + function __construct($domain, $config_user = null, $config_passwd = null, $backup = null, $verbose = false, $app = null) |
|
34 | 34 | { |
35 | 35 | if (!is_array($domain)) |
36 | 36 | { |
@@ -55,32 +55,32 @@ discard block |
||
55 | 55 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
56 | 56 | * @throws Exception('header.inc.php not found!'); |
57 | 57 | */ |
58 | - protected function exec($check_only=false) |
|
58 | + protected function exec($check_only = false) |
|
59 | 59 | { |
60 | 60 | global $setup_info; |
61 | 61 | |
62 | 62 | // instanciate setup object and check authorisation |
63 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
63 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
64 | 64 | |
65 | - $this->check_installed($this->domain,array(14),$this->verbose); |
|
65 | + $this->check_installed($this->domain, array(14), $this->verbose); |
|
66 | 66 | |
67 | 67 | if ($GLOBALS['egw_info']['setup']['stage']['db'] != 4 && |
68 | 68 | (!$this->app || !in_array($this->app, self::$apps_to_install) && !in_array($this->app, self::$apps_to_upgrade)) && |
69 | 69 | !self::check_autoinstall()) |
70 | 70 | { |
71 | - return lang('No update necessary, domain %1(%2) is up to date.',$this->domain,$GLOBALS['egw_domain'][$this->domain]['db_type']); |
|
71 | + return lang('No update necessary, domain %1(%2) is up to date.', $this->domain, $GLOBALS['egw_domain'][$this->domain]['db_type']); |
|
72 | 72 | } |
73 | 73 | if ($check_only) return lang('Update necessary.'); |
74 | 74 | |
75 | 75 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
76 | 76 | |
77 | - self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain |
|
77 | + self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain |
|
78 | 78 | |
79 | 79 | // request to install a single app |
80 | 80 | if ($this->app && in_array($this->app, self::$apps_to_install)) |
81 | 81 | { |
82 | 82 | $app_title = $setup_info[$this->app]['title'] ? $setup_info[$this->app]['title'] : $setup_info[$this->app]['name']; |
83 | - self::_echo_message($this->verbose,lang('Start installing application %1 ...',$app_title)); |
|
83 | + self::_echo_message($this->verbose, lang('Start installing application %1 ...', $app_title)); |
|
84 | 84 | ob_start(); |
85 | 85 | $terror = array($this->app => $setup_info[$this->app]); |
86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | $errors = self::$egw_setup->process->current($terror, $this->verbose); |
90 | 90 | $terror = self::$egw_setup->process->default_records($errors, $this->verbose); |
91 | - echo $app_title . ' ' . lang('tables installed, unless there are errors printed above') . '.'; |
|
91 | + echo $app_title.' '.lang('tables installed, unless there are errors printed above').'.'; |
|
92 | 92 | } |
93 | 93 | else |
94 | 94 | { |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | { |
103 | 103 | self::$egw_setup->register_app($setup_info[$this->app]['name']); |
104 | 104 | } |
105 | - echo $app_title . ' ' . lang('registered') . '.'; |
|
105 | + echo $app_title.' '.lang('registered').'.'; |
|
106 | 106 | |
107 | 107 | if ($setup_info[$this->app]['hooks']) |
108 | 108 | { |
109 | 109 | self::$egw_setup->register_hooks($setup_info[$this->app]['name']); |
110 | - echo "\n".$app_title . ' ' . lang('hooks registered') . '.'; |
|
110 | + echo "\n".$app_title.' '.lang('hooks registered').'.'; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | 114 | else |
115 | 115 | { |
116 | - self::_echo_message($this->verbose,lang('Start updating the database ...')); |
|
116 | + self::_echo_message($this->verbose, lang('Start updating the database ...')); |
|
117 | 117 | ob_start(); |
118 | - self::$egw_setup->process->pass($setup_info,'upgrade',false); |
|
118 | + self::$egw_setup->process->pass($setup_info, 'upgrade', false); |
|
119 | 119 | } |
120 | 120 | $messages = ob_get_contents(); |
121 | 121 | ob_end_clean(); |
@@ -70,7 +70,10 @@ discard block |
||
70 | 70 | { |
71 | 71 | return lang('No update necessary, domain %1(%2) is up to date.',$this->domain,$GLOBALS['egw_domain'][$this->domain]['db_type']); |
72 | 72 | } |
73 | - if ($check_only) return lang('Update necessary.'); |
|
73 | + if ($check_only) |
|
74 | + { |
|
75 | + return lang('Update necessary.'); |
|
76 | + } |
|
74 | 77 | |
75 | 78 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
76 | 79 | |
@@ -119,7 +122,10 @@ discard block |
||
119 | 122 | } |
120 | 123 | $messages = ob_get_contents(); |
121 | 124 | ob_end_clean(); |
122 | - if ($messages && $this->verbose) echo strip_tags($messages)."\n"; |
|
125 | + if ($messages && $this->verbose) |
|
126 | + { |
|
127 | + echo strip_tags($messages)."\n"; |
|
128 | + } |
|
123 | 129 | |
124 | 130 | $this->restore_db(); |
125 | 131 |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @param string $domain ='default' domain to set |
65 | 65 | */ |
66 | - function defaults($domain='default') |
|
66 | + function defaults($domain = 'default') |
|
67 | 67 | { |
68 | 68 | $egw_root = realpath(__DIR__.'/../..'); |
69 | 69 | $GLOBALS['egw_info']['server']['server_root'] = $GLOBALS['egw_info']['server']['include_root'] = $egw_root; |
70 | - define('EGW_SERVER_ROOT',$egw_root); // this is usally already defined by setup and cant be changed |
|
71 | - define('EGW_INCLUDE_ROOT',$egw_root); |
|
70 | + define('EGW_SERVER_ROOT', $egw_root); // this is usally already defined by setup and cant be changed |
|
71 | + define('EGW_INCLUDE_ROOT', $egw_root); |
|
72 | 72 | |
73 | 73 | $GLOBALS['egw_info']['server']['header_admin_user'] = 'admin'; |
74 | 74 | $GLOBALS['egw_info']['server']['header_admin_password'] = ''; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $GLOBALS['egw_info']['server']['mcrypt_iv'] = $this->generate_mcyrpt_iv(); |
85 | 85 | } |
86 | 86 | |
87 | - function domain_defaults($user='admin',$passwd='',$supported_db=null) |
|
87 | + function domain_defaults($user = 'admin', $passwd = '', $supported_db = null) |
|
88 | 88 | { |
89 | 89 | $null = null; |
90 | 90 | if (is_null($supported_db)) $supported_db = $this->check_db_support($null); |
@@ -109,19 +109,19 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return array with errors or null if no errors |
111 | 111 | */ |
112 | - function validation_errors($path=EGW_SERVER_ROOT) |
|
112 | + function validation_errors($path = EGW_SERVER_ROOT) |
|
113 | 113 | { |
114 | 114 | $errors = null; |
115 | 115 | |
116 | 116 | if (!is_dir($path) || !is_readable($path) || !is_dir($path.'/api')) |
117 | 117 | { |
118 | - $errors[] = lang("%1 '%2' does NOT exist, is not readable by the webserver or contains no EGroupware installation!",lang('Server root'),$path); |
|
118 | + $errors[] = lang("%1 '%2' does NOT exist, is not readable by the webserver or contains no EGroupware installation!", lang('Server root'), $path); |
|
119 | 119 | } |
120 | - if(!$GLOBALS['egw_info']['server']['header_admin_password']) |
|
120 | + if (!$GLOBALS['egw_info']['server']['header_admin_password']) |
|
121 | 121 | { |
122 | 122 | $errors[] = lang("You didn't enter a header admin password"); |
123 | 123 | } |
124 | - if(!$GLOBALS['egw_info']['server']['header_admin_user']) |
|
124 | + if (!$GLOBALS['egw_info']['server']['header_admin_user']) |
|
125 | 125 | { |
126 | 126 | $errors[] = lang("You didn't enter a header admin username"); |
127 | 127 | } |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | } |
132 | 132 | else |
133 | 133 | { |
134 | - foreach($GLOBALS['egw_domain'] as $domain => $data) |
|
134 | + foreach ($GLOBALS['egw_domain'] as $domain => $data) |
|
135 | 135 | { |
136 | 136 | if (!$data['config_passwd']) |
137 | 137 | { |
138 | - $errors[] = lang("You didn't enter a config password for domain %1",$domain); |
|
138 | + $errors[] = lang("You didn't enter a config password for domain %1", $domain); |
|
139 | 139 | } |
140 | - if(!$data['config_user']) |
|
140 | + if (!$data['config_user']) |
|
141 | 141 | { |
142 | - $errors[] = lang("You didn't enter a config username for domain %1",$domain); |
|
142 | + $errors[] = lang("You didn't enter a config username for domain %1", $domain); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -156,19 +156,19 @@ discard block |
||
156 | 156 | * @param array $egw_domain info about the existing eGW domains / DB instances |
157 | 157 | * @return string content of header.inc.php |
158 | 158 | */ |
159 | - function generate($egw_info,$egw_domain) |
|
159 | + function generate($egw_info, $egw_domain) |
|
160 | 160 | { |
161 | - $tpl = new Framework\Template('../', 'keep'); // 'keep' to not loose '{hash}' prefix of password-hashes! |
|
161 | + $tpl = new Framework\Template('../', 'keep'); // 'keep' to not loose '{hash}' prefix of password-hashes! |
|
162 | 162 | $tpl->set_file(array('header' => 'header.inc.php.template')); |
163 | - $tpl->set_block('header','domain','domain'); |
|
163 | + $tpl->set_block('header', 'domain', 'domain'); |
|
164 | 164 | |
165 | 165 | $most_secure_pw_hash = null; |
166 | 166 | Api\Auth::passwdhashes($most_secure_pw_hash); |
167 | 167 | |
168 | - foreach($egw_domain as $domain => $data) |
|
168 | + foreach ($egw_domain as $domain => $data) |
|
169 | 169 | { |
170 | 170 | $var = array('DB_DOMAIN' => $domain); |
171 | - foreach($data as $name => $value) |
|
171 | + foreach ($data as $name => $value) |
|
172 | 172 | { |
173 | 173 | if ($name == 'db_port' && !$value) $value = $this->default_db_ports[$data['db_type']]; |
174 | 174 | if ($name == 'config_passwd') |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | $tpl->set_var($var); |
184 | - $tpl->parse('domains','domain',True); |
|
184 | + $tpl->parse('domains', 'domain', True); |
|
185 | 185 | } |
186 | - $tpl->set_var('domain',''); |
|
186 | + $tpl->set_var('domain', ''); |
|
187 | 187 | |
188 | 188 | $var = Array(); |
189 | - foreach($egw_info['server'] as $name => $value) |
|
189 | + foreach ($egw_info['server'] as $name => $value) |
|
190 | 190 | { |
191 | 191 | if ($name == 'header_admin_password' && $value && !self::is_hashed($value)) $value = Api\Auth::encrypt_sql($value, $most_secure_pw_hash); |
192 | 192 | if ($name == 'versions') |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | } |
209 | 209 | $tpl->set_var($var); |
210 | 210 | |
211 | - return $tpl->parse('out','header'); |
|
211 | + return $tpl->parse('out', 'header'); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -227,18 +227,18 @@ discard block |
||
227 | 227 | return $iv; |
228 | 228 | }*/ |
229 | 229 | $size = 30; |
230 | - srand((double)microtime()*1000000); |
|
230 | + srand((double)microtime() * 1000000); |
|
231 | 231 | $random_char = array( |
232 | - '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', |
|
233 | - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', |
|
234 | - 'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', |
|
235 | - 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' |
|
232 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
|
233 | + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
|
234 | + 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', |
|
235 | + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' |
|
236 | 236 | ); |
237 | 237 | |
238 | 238 | $iv = ''; |
239 | - for($i=0; $i < $size; $i++) |
|
239 | + for ($i = 0; $i < $size; $i++) |
|
240 | 240 | { |
241 | - $iv .= $random_char[rand(1,count($random_char))]; |
|
241 | + $iv .= $random_char[rand(1, count($random_char))]; |
|
242 | 242 | } |
243 | 243 | //error_log(__METHOD__."() size=$size returning ".array2string($iv)); |
244 | 244 | return $iv; |
@@ -247,15 +247,15 @@ discard block |
||
247 | 247 | function check_db_support(&$detected) |
248 | 248 | { |
249 | 249 | $supported_db = $detected = array(); |
250 | - foreach(array( |
|
250 | + foreach (array( |
|
251 | 251 | // short => array(extension,func_to_check,supported_db(s)) |
252 | - 'mysqli' => array('mysql','mysqli_connect','mysqli'), |
|
253 | - 'mysql' => array('mysql','mysql_connect','mysql'), |
|
254 | - 'mysqlt' => array('mysql','mysql_connect','mysqlt'), |
|
255 | - 'pgsql' => array('pgsql','pg_connect','pgsql'), |
|
256 | - 'mssql' => array('mssql','mssql_connect','mssql'), |
|
257 | - 'odbc' => array('odbc',false,'sapdb','odbc_mssql','odbc_oracle'), |
|
258 | - 'oracle' => array('oci8',false,'oracle'), |
|
252 | + 'mysqli' => array('mysql', 'mysqli_connect', 'mysqli'), |
|
253 | + 'mysql' => array('mysql', 'mysql_connect', 'mysql'), |
|
254 | + 'mysqlt' => array('mysql', 'mysql_connect', 'mysqlt'), |
|
255 | + 'pgsql' => array('pgsql', 'pg_connect', 'pgsql'), |
|
256 | + 'mssql' => array('mssql', 'mssql_connect', 'mssql'), |
|
257 | + 'odbc' => array('odbc', false, 'sapdb', 'odbc_mssql', 'odbc_oracle'), |
|
258 | + 'oracle' => array('oci8', false, 'oracle'), |
|
259 | 259 | ) as $db => $data) |
260 | 260 | { |
261 | 261 | $ext = array_shift($data); |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | $name = isset($this->db_fullnames[$db]) ? $this->db_fullnames[$db] : strtoupper($db); |
264 | 264 | if (check_load_extension($ext) || $func_to_check && function_exists($func_to_check)) |
265 | 265 | { |
266 | - $detected[] = lang('You appear to have %1 support.',$name); |
|
267 | - $supported_db = array_merge($supported_db,$data); |
|
266 | + $detected[] = lang('You appear to have %1 support.', $name); |
|
267 | + $supported_db = array_merge($supported_db, $data); |
|
268 | 268 | } |
269 | 269 | else |
270 | 270 | { |
271 | - $detected[] .= lang('No %1 support found. Disabling',$name); |
|
271 | + $detected[] .= lang('No %1 support found. Disabling', $name); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | return $supported_db; |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | // some constanst for pre php4.3 |
292 | 292 | if (!defined('PHP_SHLIB_SUFFIX')) |
293 | 293 | { |
294 | - define('PHP_SHLIB_SUFFIX',strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ? 'dll' : 'so'); |
|
294 | + define('PHP_SHLIB_SUFFIX', strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' ? 'dll' : 'so'); |
|
295 | 295 | } |
296 | 296 | if (!defined('PHP_SHLIB_PREFIX')) |
297 | 297 | { |
298 | - define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); |
|
298 | + define('PHP_SHLIB_PREFIX', PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); |
|
299 | 299 | } |
@@ -74,7 +74,10 @@ discard block |
||
74 | 74 | $GLOBALS['egw_info']['server']['header_admin_password'] = ''; |
75 | 75 | $GLOBALS['egw_info']['server']['setup_acl'] = ''; |
76 | 76 | |
77 | - if ($domain) $GLOBALS['egw_domain'][$domain] = $this->domain_defaults(); |
|
77 | + if ($domain) |
|
78 | + { |
|
79 | + $GLOBALS['egw_domain'][$domain] = $this->domain_defaults(); |
|
80 | + } |
|
78 | 81 | |
79 | 82 | $GLOBALS['egw_info']['server']['show_domain_selectbox'] = false; |
80 | 83 | $GLOBALS['egw_info']['server']['db_persistent'] = True; |
@@ -87,7 +90,10 @@ discard block |
||
87 | 90 | function domain_defaults($user='admin',$passwd='',$supported_db=null) |
88 | 91 | { |
89 | 92 | $null = null; |
90 | - if (is_null($supported_db)) $supported_db = $this->check_db_support($null); |
|
93 | + if (is_null($supported_db)) |
|
94 | + { |
|
95 | + $supported_db = $this->check_db_support($null); |
|
96 | + } |
|
91 | 97 | $default_db = count($supported_db) ? $supported_db[0] : 'mysqli'; |
92 | 98 | |
93 | 99 | return array( |
@@ -170,7 +176,10 @@ discard block |
||
170 | 176 | $var = array('DB_DOMAIN' => $domain); |
171 | 177 | foreach($data as $name => $value) |
172 | 178 | { |
173 | - if ($name == 'db_port' && !$value) $value = $this->default_db_ports[$data['db_type']]; |
|
179 | + if ($name == 'db_port' && !$value) |
|
180 | + { |
|
181 | + $value = $this->default_db_ports[$data['db_type']]; |
|
182 | + } |
|
174 | 183 | if ($name == 'config_passwd') |
175 | 184 | { |
176 | 185 | $var['CONFIG_PASS'] = self::is_hashed($value) ? $value : Api\Auth::encrypt_sql($value, $most_secure_pw_hash); |
@@ -188,7 +197,10 @@ discard block |
||
188 | 197 | $var = Array(); |
189 | 198 | foreach($egw_info['server'] as $name => $value) |
190 | 199 | { |
191 | - if ($name == 'header_admin_password' && $value && !self::is_hashed($value)) $value = Api\Auth::encrypt_sql($value, $most_secure_pw_hash); |
|
200 | + if ($name == 'header_admin_password' && $value && !self::is_hashed($value)) |
|
201 | + { |
|
202 | + $value = Api\Auth::encrypt_sql($value, $most_secure_pw_hash); |
|
203 | + } |
|
192 | 204 | if ($name == 'versions') |
193 | 205 | { |
194 | 206 | $name = 'mcrypt_version'; |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | $GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template')); |
31 | 31 | $GLOBALS['header_template']->set_block('header','domain','domain'); |
32 | - $var = Array(); |
|
32 | + $var = array(); |
|
33 | 33 | |
34 | 34 | $deletedomain = $_POST['deletedomain']; |
35 | 35 | $domains = $_POST['domains']; |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | * @param boolean $make_db_name_unique =false true: if create fails because db exists, |
54 | 54 | * try creating a unique name by shortening the name and adding a number to it |
55 | 55 | */ |
56 | - function __construct($domain,$db_type=null,$db_host=null,$db_port=null,$db_name=null,$db_user=null,$db_pass=null, |
|
57 | - $db_root=null,$db_root_pw=null,$sub_command='create_db',$db_grant_host='localhost',$make_db_name_unique=false) |
|
56 | + function __construct($domain, $db_type = null, $db_host = null, $db_port = null, $db_name = null, $db_user = null, $db_pass = null, |
|
57 | + $db_root = null, $db_root_pw = null, $sub_command = 'create_db', $db_grant_host = 'localhost', $make_db_name_unique = false) |
|
58 | 58 | { |
59 | 59 | if (!is_array($domain)) |
60 | 60 | { |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
86 | 86 | * @throws Exception('header.inc.php not found!'); |
87 | 87 | */ |
88 | - protected function exec($check_only=false) |
|
88 | + protected function exec($check_only = false) |
|
89 | 89 | { |
90 | - if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i',$this->domain)) |
|
90 | + if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i', $this->domain)) |
|
91 | 91 | { |
92 | - throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!",$this->domain)); |
|
92 | + throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!", $this->domain)); |
|
93 | 93 | } |
94 | - if ($this->remote_id && $check_only) return true; // further checks can only done locally |
|
94 | + if ($this->remote_id && $check_only) return true; // further checks can only done locally |
|
95 | 95 | |
96 | 96 | $this->_merge_defaults(); |
97 | 97 | //_debug_array($this->as_array()); |
98 | 98 | |
99 | 99 | try { |
100 | - switch($this->sub_command) |
|
100 | + switch ($this->sub_command) |
|
101 | 101 | { |
102 | 102 | case 'test_db_root': |
103 | - $msg = $this->connect($this->db_root,$this->db_root_pw,$this->db_meta); |
|
103 | + $msg = $this->connect($this->db_root, $this->db_root_pw, $this->db_meta); |
|
104 | 104 | break; |
105 | 105 | case 'test_db': |
106 | 106 | $msg = $this->connect(); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param string $name =null default $this->db_name |
135 | 135 | * @throws Api\Exception\WrongUserinput Can not connect to database ... |
136 | 136 | */ |
137 | - private function connect($user=null,$pass=null,$name=null) |
|
137 | + private function connect($user = null, $pass = null, $name = null) |
|
138 | 138 | { |
139 | 139 | if (is_null($user)) $user = $this->db_user; |
140 | 140 | if (is_null($pass)) $pass = $this->db_pass; |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | $this->test_db = new Api\Db(); |
144 | 144 | |
145 | 145 | $error_rep = error_reporting(); |
146 | - error_reporting($error_rep & ~E_WARNING); // switch warnings of, in case they are on |
|
146 | + error_reporting($error_rep&~E_WARNING); // switch warnings of, in case they are on |
|
147 | 147 | try { |
148 | - $this->test_db->connect($name,$this->db_host,$this->db_port,$user,$pass,$this->db_type); |
|
148 | + $this->test_db->connect($name, $this->db_host, $this->db_port, $user, $pass, $this->db_type); |
|
149 | 149 | } |
150 | 150 | catch (Exception $e) { |
151 | 151 | // just give a nicer error, after switching error_reporting on again |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | if ($e) |
156 | 156 | { |
157 | 157 | throw new Api\Exception\WrongUserinput(lang('Can not connect to %1 database %2 on host %3 using user %4!', |
158 | - $this->db_type,$name,$this->db_host.($this->db_port?':'.$this->db_port:''),$user).' ('.$e->getMessage().')'); |
|
158 | + $this->db_type, $name, $this->db_host.($this->db_port ? ':'.$this->db_port : ''), $user).' ('.$e->getMessage().')'); |
|
159 | 159 | } |
160 | 160 | return lang('Successful connected to %1 database %2 on %3 using user %4.', |
161 | - $this->db_type,$name,$this->db_host.($this->db_port?':'.$this->db_port:''),$user); |
|
161 | + $this->db_type, $name, $this->db_host.($this->db_port ? ':'.$this->db_port : ''), $user); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | */ |
175 | 175 | private function create() |
176 | 176 | { |
177 | - static $try_make_unique = 0; // to limit trials to create a unique name |
|
177 | + static $try_make_unique = 0; // to limit trials to create a unique name |
|
178 | 178 | |
179 | 179 | // shorten db-name/-user to self::MAX_DB_NAME_LEN chars |
180 | 180 | if ($this->make_db_name_unique && strlen($this->db_name) > self::MAX_DB_NAME_LEN) |
181 | 181 | { |
182 | 182 | $this->set_defaults['db_name'] = $this->db_name = |
183 | 183 | $this->set_defaults['db_user'] = $this->db_user = // change user too (otherwise existing user/db could not connect any more!) |
184 | - substr(str_replace(array('.', '-'), '_', $this->db_name),0,self::MAX_DB_NAME_LEN); |
|
184 | + substr(str_replace(array('.', '-'), '_', $this->db_name), 0, self::MAX_DB_NAME_LEN); |
|
185 | 185 | } |
186 | 186 | try { |
187 | 187 | $msg = $this->connect(); |
@@ -189,22 +189,22 @@ discard block |
||
189 | 189 | catch (Api\Exception\WrongUserinput $e) { |
190 | 190 | // db or user not working --> connect as root and create it |
191 | 191 | try { |
192 | - $this->test_db->create_database($this->db_root,$this->db_root_pw,$this->db_charset,$this->db_grant_host); |
|
192 | + $this->test_db->create_database($this->db_root, $this->db_root_pw, $this->db_charset, $this->db_grant_host); |
|
193 | 193 | $this->connect(); |
194 | 194 | } |
195 | - catch(Api\Db\Exception $e) { // catches failed to create database |
|
195 | + catch (Api\Db\Exception $e) { // catches failed to create database |
|
196 | 196 | // try connect as root to check if wrong root/root_pw is the problem |
197 | - $this->connect($this->db_root,$this->db_root_pw,$this->db_meta); |
|
197 | + $this->connect($this->db_root, $this->db_root_pw, $this->db_meta); |
|
198 | 198 | |
199 | 199 | // if we should create a db with a unique name (try it only N times, not endless!) |
200 | 200 | if ($this->make_db_name_unique && $try_make_unique++ < 20) |
201 | 201 | { |
202 | 202 | // check if we can connect as root to the db to create --> db exists already |
203 | 203 | try { |
204 | - $this->connect($this->db_root,$this->db_root_pw); |
|
204 | + $this->connect($this->db_root, $this->db_root_pw); |
|
205 | 205 | // create new db_name by incrementing an existing numeric postfix |
206 | 206 | $matches = null; |
207 | - if (preg_match('/([0-9]+)$/',$this->db_name,$matches)) |
|
207 | + if (preg_match('/([0-9]+)$/', $this->db_name, $matches)) |
|
208 | 208 | { |
209 | 209 | $num = (string)(++$matches[1]); |
210 | 210 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } |
215 | 215 | $this->set_defaults['db_name'] = $this->db_name = |
216 | 216 | $this->set_defaults['db_user'] = $this->db_user = // change user too (otherwise existing user/db could not connect any more!) |
217 | - substr($this->db_name,0,self::MAX_DB_NAME_LEN-strlen($num)).$num; |
|
217 | + substr($this->db_name, 0, self::MAX_DB_NAME_LEN - strlen($num)).$num; |
|
218 | 218 | |
219 | 219 | return $this->create(); |
220 | 220 | } |
@@ -225,21 +225,21 @@ discard block |
||
225 | 225 | } |
226 | 226 | // if not give general error |
227 | 227 | throw new Api\Exception\WrongUserinput(lang('Can not create %1 database %2 on %3 for user %4!', |
228 | - $this->db_type,$this->db_name,$this->db_host.($this->db_port?':'.$this->db_port:''),$this->db_user)); |
|
228 | + $this->db_type, $this->db_name, $this->db_host.($this->db_port ? ':'.$this->db_port : ''), $this->db_user)); |
|
229 | 229 | } |
230 | 230 | $msg = lang('Successful connected to %1 on %3 and created database %2 for user %4.', |
231 | - $this->db_type,$this->db_name,$this->db_host.($this->db_port?':'.$this->db_port:''),$this->db_user); |
|
231 | + $this->db_type, $this->db_name, $this->db_host.($this->db_port ? ':'.$this->db_port : ''), $this->db_user); |
|
232 | 232 | } |
233 | 233 | // check if it already contains tables |
234 | 234 | if (($tables = $this->test_db->table_names())) |
235 | 235 | { |
236 | - foreach($tables as &$table) |
|
236 | + foreach ($tables as &$table) |
|
237 | 237 | { |
238 | 238 | $table = $table['table_name']; |
239 | 239 | } |
240 | 240 | throw new Api\Exception\WrongUserinput(lang('%1 database %2 on %3 already contains the following tables:', |
241 | - $this->db_type,$this->db_name,$this->db_host.($this->db_port?':'.$this->db_port:'')).' '. |
|
242 | - implode(', ',$tables)); |
|
241 | + $this->db_type, $this->db_name, $this->db_host.($this->db_port ? ':'.$this->db_port : '')).' '. |
|
242 | + implode(', ', $tables)); |
|
243 | 243 | } |
244 | 244 | return $msg; |
245 | 245 | } |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | */ |
254 | 254 | private function drop() |
255 | 255 | { |
256 | - $this->connect($this->db_root,$this->db_root_pw,$this->db_meta); |
|
257 | - $this->test_db->query('DROP DATABASE '.$this->test_db->name_quote($this->db_name),__LINE__,__FILE__); |
|
258 | - $msg = lang('Datebase %1 droped.',$this->db_name); |
|
256 | + $this->connect($this->db_root, $this->db_root_pw, $this->db_meta); |
|
257 | + $this->test_db->query('DROP DATABASE '.$this->test_db->name_quote($this->db_name), __LINE__, __FILE__); |
|
258 | + $msg = lang('Datebase %1 droped.', $this->db_name); |
|
259 | 259 | try { |
260 | 260 | $this->test_db->query('DROP USER '.$this->test_db->quote($this->db_user).'@'. |
261 | - $this->test_db->quote($this->db_grant_host?$this->db_grant_host:'%'),__LINE__,__FILE__); |
|
261 | + $this->test_db->quote($this->db_grant_host ? $this->db_grant_host : '%'), __LINE__, __FILE__); |
|
262 | 262 | } |
263 | 263 | catch (Api\Db\Exception $e) { |
264 | 264 | unset($e); |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * @param string $db_type ='mysqli' |
275 | 275 | * @return array |
276 | 276 | */ |
277 | - static function defaults($db_type='mysqli') |
|
277 | + static function defaults($db_type = 'mysqli') |
|
278 | 278 | { |
279 | - switch($db_type) |
|
279 | + switch ($db_type) |
|
280 | 280 | { |
281 | 281 | case 'mysql': |
282 | 282 | default: |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | 'db_user' => 'egw_$domain', |
295 | 295 | 'db_pass' => self::randomstring(), |
296 | 296 | 'db_root' => 'root', |
297 | - 'db_root_pw' => '', // not really a default |
|
297 | + 'db_root_pw' => '', // not really a default |
|
298 | 298 | 'db_meta' => $meta_db, |
299 | 299 | 'db_charset' => 'utf-8', |
300 | 300 | 'db_grant_host' => 'localhost', |
@@ -306,19 +306,19 @@ discard block |
||
306 | 306 | */ |
307 | 307 | private function _merge_defaults() |
308 | 308 | { |
309 | - foreach(self::defaults() as $name => $default) |
|
309 | + foreach (self::defaults() as $name => $default) |
|
310 | 310 | { |
311 | 311 | if (!$this->$name) |
312 | 312 | { |
313 | 313 | //echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n"; |
314 | 314 | $this->set_defaults[$name] = $this->$name = $default; |
315 | 315 | } |
316 | - if (strpos($this->$name,'$domain') !== false) |
|
316 | + if (strpos($this->$name, '$domain') !== false) |
|
317 | 317 | { |
318 | 318 | // limit names to 16 chars (16 char is user-name limit in MySQL) |
319 | 319 | $this->set_defaults[$name] = $this->$name = |
320 | - substr(str_replace(array('$domain','.','-'),array($this->domain,'_','_'),$this->$name), |
|
321 | - 0,self::MAX_DB_NAME_LEN); |
|
320 | + substr(str_replace(array('$domain', '.', '-'), array($this->domain, '_', '_'), $this->$name), |
|
321 | + 0, self::MAX_DB_NAME_LEN); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | } |
@@ -91,7 +91,11 @@ discard block |
||
91 | 91 | { |
92 | 92 | throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!",$this->domain)); |
93 | 93 | } |
94 | - if ($this->remote_id && $check_only) return true; // further checks can only done locally |
|
94 | + if ($this->remote_id && $check_only) |
|
95 | + { |
|
96 | + return true; |
|
97 | + } |
|
98 | + // further checks can only done locally |
|
95 | 99 | |
96 | 100 | $this->_merge_defaults(); |
97 | 101 | //_debug_array($this->as_array()); |
@@ -136,9 +140,18 @@ discard block |
||
136 | 140 | */ |
137 | 141 | private function connect($user=null,$pass=null,$name=null) |
138 | 142 | { |
139 | - if (is_null($user)) $user = $this->db_user; |
|
140 | - if (is_null($pass)) $pass = $this->db_pass; |
|
141 | - if (is_null($name)) $name = $this->db_name; |
|
143 | + if (is_null($user)) |
|
144 | + { |
|
145 | + $user = $this->db_user; |
|
146 | + } |
|
147 | + if (is_null($pass)) |
|
148 | + { |
|
149 | + $pass = $this->db_pass; |
|
150 | + } |
|
151 | + if (is_null($name)) |
|
152 | + { |
|
153 | + $name = $this->db_name; |
|
154 | + } |
|
142 | 155 | |
143 | 156 | $this->test_db = new Api\Db(); |
144 | 157 |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @param array $config =array() extra config for the account object: account_repository, ldap_* |
39 | 39 | * @param string $lang ='en' |
40 | 40 | */ |
41 | - function __construct($domain,$config_user=null,$config_passwd=null,$admin_user=null,$admin_password=null, |
|
42 | - $admin_firstname=null,$admin_lastname=null,$admin_email=null,array $config=array(),$lang='en') |
|
41 | + function __construct($domain, $config_user = null, $config_passwd = null, $admin_user = null, $admin_password = null, |
|
42 | + $admin_firstname = null, $admin_lastname = null, $admin_email = null, array $config = array(), $lang = 'en') |
|
43 | 43 | { |
44 | 44 | if (!is_array($domain)) |
45 | 45 | { |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
69 | 69 | * @throws Exception('header.inc.php not found!'); |
70 | 70 | */ |
71 | - protected function exec($check_only=false) |
|
71 | + protected function exec($check_only = false) |
|
72 | 72 | { |
73 | 73 | if ($check_only && $this->remote_id) |
74 | 74 | { |
75 | - return true; // can only check locally |
|
75 | + return true; // can only check locally |
|
76 | 76 | } |
77 | - $this->check_installed($this->domain,15); |
|
77 | + $this->check_installed($this->domain, 15); |
|
78 | 78 | |
79 | 79 | if (!$this->admin_firstname) $this->set_defaults['admin_firstname'] = $this->admin_firstname = lang('Admin'); |
80 | 80 | if (!$this->admin_lastname) $this->set_defaults['admin_lastname'] = $this->admin_lastname = lang('User'); |
81 | - if (strpos($this->admin_email,'$') !== false) |
|
81 | + if (strpos($this->admin_email, '$') !== false) |
|
82 | 82 | { |
83 | 83 | $this->set_defaults['email'] = $this->admin_email = str_replace( |
84 | - array('$domain','$uid','$account_lid'), |
|
85 | - array($this->domain,$this->admin_user,$this->admin_user),$this->admin_email); |
|
84 | + array('$domain', '$uid', '$account_lid'), |
|
85 | + array($this->domain, $this->admin_user, $this->admin_user), $this->admin_email); |
|
86 | 86 | } |
87 | 87 | $_POST['username'] = $this->admin_user; |
88 | 88 | $_POST['passwd2'] = $_POST['passwd'] = $this->admin_password; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | switch ($error) |
100 | 100 | { |
101 | 101 | case 41: |
102 | - throw new Api\Exception\WrongUserinput(lang('Error in admin-creation !!!'),41); |
|
102 | + throw new Api\Exception\WrongUserinput(lang('Error in admin-creation !!!'), 41); |
|
103 | 103 | case 42: |
104 | - throw new Api\Exception\WrongUserinput(lang('Error in group-creation !!!'),42); |
|
104 | + throw new Api\Exception\WrongUserinput(lang('Error in group-creation !!!'), 42); |
|
105 | 105 | } |
106 | 106 | $this->restore_db(); |
107 | 107 | |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | if (php_sapi_name() !== 'cli' || !file_exists(EGW_SERVER_ROOT.'/stylite') || file_exists(EGW_SERVER_ROOT.'/managementserver')) |
113 | 113 | { |
114 | 114 | $output = $ret = null; |
115 | - exec($cmd,$output,$ret); |
|
115 | + exec($cmd, $output, $ret); |
|
116 | 116 | } |
117 | - $output = implode("\n",$output); |
|
117 | + $output = implode("\n", $output); |
|
118 | 118 | //echo "ret=$ret\n".$output; |
119 | 119 | if ($ret) |
120 | 120 | { |
121 | - throw new Api\Exception ($output,$ret); |
|
121 | + throw new Api\Exception($output, $ret); |
|
122 | 122 | } |
123 | 123 | return lang('Admin account successful created.'); |
124 | 124 | } |
@@ -76,8 +76,14 @@ |
||
76 | 76 | } |
77 | 77 | $this->check_installed($this->domain,15); |
78 | 78 | |
79 | - if (!$this->admin_firstname) $this->set_defaults['admin_firstname'] = $this->admin_firstname = lang('Admin'); |
|
80 | - if (!$this->admin_lastname) $this->set_defaults['admin_lastname'] = $this->admin_lastname = lang('User'); |
|
79 | + if (!$this->admin_firstname) |
|
80 | + { |
|
81 | + $this->set_defaults['admin_firstname'] = $this->admin_firstname = lang('Admin'); |
|
82 | + } |
|
83 | + if (!$this->admin_lastname) |
|
84 | + { |
|
85 | + $this->set_defaults['admin_lastname'] = $this->admin_lastname = lang('User'); |
|
86 | + } |
|
81 | 87 | if (strpos($this->admin_email,'$') !== false) |
82 | 88 | { |
83 | 89 | $this->set_defaults['email'] = $this->admin_email = str_replace( |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | if (!$this->header_secret && $this->header_admin_user) // no secret specified but header_admin_user/password |
36 | 36 | { |
37 | 37 | if (!$this->uid) $this->uid = true; |
38 | - $this->set_header_secret($this->header_admin_user,$this->header_admin_password); |
|
38 | + $this->set_header_secret($this->header_admin_user, $this->header_admin_password); |
|
39 | 39 | } |
40 | 40 | $secret = $this->_calc_header_secret($GLOBALS['egw_info']['server']['header_admin_user'], |
41 | 41 | $GLOBALS['egw_info']['server']['header_admin_password']); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | if ($this->header_secret != $secret) |
45 | 45 | { |
46 | 46 | //echo "_check_header_access: header_secret='$this->header_secret' != '$secret'=_calc_header_secret({$GLOBALS['egw_info']['server']['header_admin_user']},{$GLOBALS['egw_info']['server']['header_admin_password']})\n"; |
47 | - throw new Api\Exception\NoPermission(lang('Wrong credentials to access the header.inc.php file!'),5); |
|
47 | + throw new Api\Exception\NoPermission(lang('Wrong credentials to access the header.inc.php file!'), 5); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | * @param string $user |
56 | 56 | * @param string $pw password or md5 hash of it |
57 | 57 | */ |
58 | - public function set_header_secret($user,$pw) |
|
58 | + public function set_header_secret($user, $pw) |
|
59 | 59 | { |
60 | 60 | if ($this->uid || parent::save(false)) // we need to save first, to get the uid |
61 | 61 | { |
62 | - $this->header_secret = $this->_calc_header_secret($user,$pw); |
|
62 | + $this->header_secret = $this->_calc_header_secret($user, $pw); |
|
63 | 63 | } |
64 | 64 | else |
65 | 65 | { |
66 | - throw new Exception ('failed to set header_secret!'); |
|
66 | + throw new Exception('failed to set header_secret!'); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string $header_admin_password |
77 | 77 | * @return string |
78 | 78 | */ |
79 | - private function _calc_header_secret($header_admin_user=null,$header_admin_password=null) |
|
79 | + private function _calc_header_secret($header_admin_user = null, $header_admin_password = null) |
|
80 | 80 | { |
81 | 81 | if (!self::is_md5($header_admin_password)) $header_admin_password = md5($header_admin_password); |
82 | 82 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system) |
92 | 92 | * @return boolean true on success, false otherwise |
93 | 93 | */ |
94 | - function save($set_modifier=true) |
|
94 | + function save($set_modifier = true) |
|
95 | 95 | { |
96 | 96 | if (isset($GLOBALS['egw']->db) && is_object($GLOBALS['egw']->db) && $GLOBALS['egw']->db->Database) |
97 | 97 | { |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * Create the setup enviroment (for running within setup or eGW) |
114 | 114 | */ |
115 | - static protected function _setup_enviroment($domain=null) |
|
115 | + static protected function _setup_enviroment($domain = null) |
|
116 | 116 | { |
117 | 117 | if (!is_object($GLOBALS['egw_setup'])) |
118 | 118 | { |
119 | 119 | require_once(EGW_INCLUDE_ROOT.'/setup/inc/class.setup.inc.php'); |
120 | - $GLOBALS['egw_setup'] = new setup(true,true); |
|
120 | + $GLOBALS['egw_setup'] = new setup(true, true); |
|
121 | 121 | } |
122 | 122 | self::$egw_setup = $GLOBALS['egw_setup']; |
123 | 123 | self::$egw_setup->ConfigDomain = $domain; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | is_object($GLOBALS['egw']) && $GLOBALS['egw'] instanceof Egw) |
127 | 127 | { |
128 | 128 | // we run inside eGW, not setup --> read egw_domain array from the header via the showheader cmd |
129 | - $cmd = new setup_cmd_showheader(null); // null = only header, no db stuff, no hashes |
|
129 | + $cmd = new setup_cmd_showheader(null); // null = only header, no db stuff, no hashes |
|
130 | 130 | $header = $cmd->run(); |
131 | 131 | $GLOBALS['egw_domain'] = $header['egw_domain']; |
132 | 132 | |
@@ -179,26 +179,26 @@ discard block |
||
179 | 179 | * @throws Api\Exception\NoPermission(lang('Access denied: wrong username or password for manage-header !!!'),21); |
180 | 180 | * @throws Api\Exception\NoPermission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40); |
181 | 181 | */ |
182 | - static function check_setup_auth($user,$pw,$domain=null) |
|
182 | + static function check_setup_auth($user, $pw, $domain = null) |
|
183 | 183 | { |
184 | 184 | self::_setup_enviroment($domain); |
185 | 185 | |
186 | 186 | // check the authentication if a header_admin_password is set, if not we dont have a header yet and no authentication |
187 | 187 | if ($GLOBALS['egw_info']['server']['header_admin_password']) // if that's not given we dont have a header yet |
188 | 188 | { |
189 | - if (!self::$egw_setup->check_auth($user,$pw,$GLOBALS['egw_info']['server']['header_admin_user'], |
|
189 | + if (!self::$egw_setup->check_auth($user, $pw, $GLOBALS['egw_info']['server']['header_admin_user'], |
|
190 | 190 | $GLOBALS['egw_info']['server']['header_admin_password']) && |
191 | 191 | (is_null($domain) || !isset($GLOBALS['egw_domain'][$domain]) || // if valid domain given check it's config user/pw |
192 | - !self::$egw_setup->check_auth($user,$pw,$GLOBALS['egw_domain'][$domain]['config_user'], |
|
192 | + !self::$egw_setup->check_auth($user, $pw, $GLOBALS['egw_domain'][$domain]['config_user'], |
|
193 | 193 | $GLOBALS['egw_domain'][$domain]['config_passwd']))) |
194 | 194 | { |
195 | 195 | if (is_null($domain)) |
196 | 196 | { |
197 | - throw new Api\Exception\NoPermission(lang('Access denied: wrong username or password for manage-header !!!'),21); |
|
197 | + throw new Api\Exception\NoPermission(lang('Access denied: wrong username or password for manage-header !!!'), 21); |
|
198 | 198 | } |
199 | 199 | else |
200 | 200 | { |
201 | - throw new Api\Exception\NoPermission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40); |
|
201 | + throw new Api\Exception\NoPermission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!", $domain, $GLOBALS['egw_domain'][$domain]['db_type']), 40); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @var array |
211 | 211 | */ |
212 | - static public $apps_to_install=array(); |
|
212 | + static public $apps_to_install = array(); |
|
213 | 213 | /** |
214 | 214 | * Applications which are currently need update (set after call to check_installed, for the last/only domain only) |
215 | 215 | * |
216 | 216 | * @var array |
217 | 217 | */ |
218 | - static public $apps_to_upgrade=array(); |
|
218 | + static public $apps_to_upgrade = array(); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Check if eGW is installed, which versions and if an update is needed |
@@ -227,66 +227,66 @@ discard block |
||
227 | 227 | * @param boolean $verbose =false echo messages as they happen, instead returning them |
228 | 228 | * @return array with translated messages |
229 | 229 | */ |
230 | - static function check_installed($domain='',$stop=0,$verbose=false) |
|
230 | + static function check_installed($domain = '', $stop = 0, $verbose = false) |
|
231 | 231 | { |
232 | 232 | self::_setup_enviroment($domain); |
233 | 233 | |
234 | 234 | global $setup_info; |
235 | - static $header_checks=true; // output the header checks only once |
|
235 | + static $header_checks = true; // output the header checks only once |
|
236 | 236 | |
237 | 237 | $messages = array(); |
238 | 238 | |
239 | 239 | if ($stop && !is_array($stop)) $stop = array($stop); |
240 | 240 | |
241 | - $versions =& $GLOBALS['egw_info']['server']['versions']; |
|
241 | + $versions = & $GLOBALS['egw_info']['server']['versions']; |
|
242 | 242 | |
243 | 243 | if (!$versions['api']) |
244 | 244 | { |
245 | 245 | if (!include(EGW_INCLUDE_ROOT.'/api/setup/setup.inc.php')) |
246 | 246 | { |
247 | - throw new Api\Exception\WrongUserinput(lang("EGroupware sources in '%1' are not complete, file '%2' missing !!!",realpath('..'),'api/setup/setup.inc.php'),99); // should not happen ;-) |
|
247 | + throw new Api\Exception\WrongUserinput(lang("EGroupware sources in '%1' are not complete, file '%2' missing !!!", realpath('..'), 'api/setup/setup.inc.php'), 99); // should not happen ;-) |
|
248 | 248 | } |
249 | 249 | $versions['api'] = $setup_info['api']['version']; |
250 | 250 | unset($setup_info); |
251 | 251 | } |
252 | 252 | if ($header_checks) |
253 | 253 | { |
254 | - $messages[] = self::_echo_message($verbose,lang('EGroupware API version %1 found.',$versions['api'])); |
|
254 | + $messages[] = self::_echo_message($verbose, lang('EGroupware API version %1 found.', $versions['api'])); |
|
255 | 255 | } |
256 | 256 | $header_stage = self::$egw_setup->detection->check_header(); |
257 | - if ($stop && in_array($header_stage,$stop)) return true; |
|
257 | + if ($stop && in_array($header_stage, $stop)) return true; |
|
258 | 258 | |
259 | 259 | switch ($header_stage) |
260 | 260 | { |
261 | - case 1: throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1); |
|
261 | + case 1: throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'), 1); |
|
262 | 262 | |
263 | 263 | // case 2: throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('No header admin password set! Use --edit-header <password>[,<user>] to set one (--usage gives more options).'),2); |
264 | 264 | |
265 | - case 3: throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('No EGroupware domains / database instances exist! Use --edit-header --domain to add one (--usage gives more options).'),3); |
|
265 | + case 3: throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) version %1 exists%2', $versions['header'], '.')."\n".lang('No EGroupware domains / database instances exist! Use --edit-header --domain to add one (--usage gives more options).'), 3); |
|
266 | 266 | |
267 | - case 4: throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('It needs upgrading to version %1! Use --update-header <password>[,<user>] to do so (--usage gives more options).',$versions['current_header']),4); |
|
267 | + case 4: throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) version %1 exists%2', $versions['header'], '.')."\n".lang('It needs upgrading to version %1! Use --update-header <password>[,<user>] to do so (--usage gives more options).', $versions['current_header']), 4); |
|
268 | 268 | } |
269 | 269 | if ($header_checks) |
270 | 270 | { |
271 | - $messages[] = self::_echo_message($verbose,lang('EGroupware configuration file (header.inc.php) version %1 exists%2', |
|
272 | - $versions['header'],' '.lang('and is up to date'))); |
|
271 | + $messages[] = self::_echo_message($verbose, lang('EGroupware configuration file (header.inc.php) version %1 exists%2', |
|
272 | + $versions['header'], ' '.lang('and is up to date'))); |
|
273 | 273 | } |
274 | - unset($header_checks); // no further output of the header checks |
|
274 | + unset($header_checks); // no further output of the header checks |
|
275 | 275 | |
276 | 276 | $domains = $GLOBALS['egw_domain']; |
277 | 277 | if ($domain) // domain to check given |
278 | 278 | { |
279 | - if (!isset($GLOBALS['egw_domain'][$domain])) throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!",$domain), 92); |
|
279 | + if (!isset($GLOBALS['egw_domain'][$domain])) throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!", $domain), 92); |
|
280 | 280 | |
281 | 281 | $domains = array($domain => $GLOBALS['egw_domain'][$domain]); |
282 | 282 | } |
283 | - foreach($domains as $domain => $data) |
|
283 | + foreach ($domains as $domain => $data) |
|
284 | 284 | { |
285 | - self::$egw_setup->ConfigDomain = $domain; // set the domain the setup class operates on |
|
285 | + self::$egw_setup->ConfigDomain = $domain; // set the domain the setup class operates on |
|
286 | 286 | if (count($GLOBALS['egw_domain']) > 1) |
287 | 287 | { |
288 | 288 | self::_echo_message($verbose); |
289 | - $messages[] = self::_echo_message($verbose,lang('EGroupware domain/instance %1(%2):',$domain,$data['db_type'])); |
|
289 | + $messages[] = self::_echo_message($verbose, lang('EGroupware domain/instance %1(%2):', $domain, $data['db_type'])); |
|
290 | 290 | } |
291 | 291 | $setup_info = self::$egw_setup->detection->get_versions(); |
292 | 292 | // check if there's already a db-connection and close if, otherwise the db-connection of the previous domain will be used |
@@ -298,27 +298,27 @@ discard block |
||
298 | 298 | |
299 | 299 | $db = $data['db_type'].'://'.$data['db_user'].':'.$data['db_pass'].'@'.$data['db_host'].'/'.$data['db_name']; |
300 | 300 | |
301 | - $db_stage =& $GLOBALS['egw_info']['setup']['stage']['db']; |
|
301 | + $db_stage = & $GLOBALS['egw_info']['setup']['stage']['db']; |
|
302 | 302 | if (($db_stage = self::$egw_setup->detection->check_db($setup_info)) != 1) |
303 | 303 | { |
304 | 304 | $setup_info = self::$egw_setup->detection->get_db_versions($setup_info); |
305 | 305 | $db_stage = self::$egw_setup->detection->check_db($setup_info); |
306 | 306 | } |
307 | - if ($stop && in_array(10+$db_stage,$stop)) |
|
307 | + if ($stop && in_array(10 + $db_stage, $stop)) |
|
308 | 308 | { |
309 | 309 | return $messages; |
310 | 310 | } |
311 | - switch($db_stage) |
|
311 | + switch ($db_stage) |
|
312 | 312 | { |
313 | - case 1: throw new Api\Exception\WrongUserinput(lang('Your Database is not working!')." $db: ".self::$egw_setup->db->Error,11); |
|
313 | + case 1: throw new Api\Exception\WrongUserinput(lang('Your Database is not working!')." $db: ".self::$egw_setup->db->Error, 11); |
|
314 | 314 | |
315 | - case 3: throw new Api\Exception\WrongUserinput(lang('Your database is working, but you dont have any applications installed')." ($db). ".lang("Use --install to install EGroupware."),13); |
|
315 | + case 3: throw new Api\Exception\WrongUserinput(lang('Your database is working, but you dont have any applications installed')." ($db). ".lang("Use --install to install EGroupware."), 13); |
|
316 | 316 | |
317 | - case 4: throw new Api\Exception\WrongUserinput(lang('EGroupware API needs a database (schema) update from version %1 to %2!',$setup_info['phpgwapi']['currentver'],$versions['phpgwapi']).' '.lang('Use --update to do so.'),14); |
|
317 | + case 4: throw new Api\Exception\WrongUserinput(lang('EGroupware API needs a database (schema) update from version %1 to %2!', $setup_info['phpgwapi']['currentver'], $versions['phpgwapi']).' '.lang('Use --update to do so.'), 14); |
|
318 | 318 | |
319 | 319 | case 10: // also check apps of updates |
320 | 320 | self::$apps_to_upgrade = self::$apps_to_install = array(); |
321 | - foreach($setup_info as $app => $data) |
|
321 | + foreach ($setup_info as $app => $data) |
|
322 | 322 | { |
323 | 323 | if ($data['currentver'] && $data['version'] && $data['version'] != 'deleted' && $data['version'] != $data['currentver']) |
324 | 324 | { |
@@ -332,23 +332,23 @@ discard block |
||
332 | 332 | if (self::$apps_to_install) |
333 | 333 | { |
334 | 334 | self::_echo_message($verbose); |
335 | - $messages[] = self::_echo_message($verbose,lang('The following applications are NOT installed:').' '.implode(', ',self::$apps_to_install)); |
|
335 | + $messages[] = self::_echo_message($verbose, lang('The following applications are NOT installed:').' '.implode(', ', self::$apps_to_install)); |
|
336 | 336 | } |
337 | 337 | if (self::$apps_to_upgrade) |
338 | 338 | { |
339 | 339 | $db_stage = 4; |
340 | - if ($stop && in_array(10+$db_stage,$stop)) return $messages; |
|
340 | + if ($stop && in_array(10 + $db_stage, $stop)) return $messages; |
|
341 | 341 | |
342 | - throw new Api\Exception\WrongUserinput(lang('The following applications need to be upgraded:').' '.implode(', ',self::$apps_to_upgrade).'! '.lang('Use --update to do so.'),14); |
|
342 | + throw new Api\Exception\WrongUserinput(lang('The following applications need to be upgraded:').' '.implode(', ', self::$apps_to_upgrade).'! '.lang('Use --update to do so.'), 14); |
|
343 | 343 | } |
344 | 344 | break; |
345 | 345 | } |
346 | - $messages[] = self::_echo_message($verbose,lang("database is version %1 and up to date.",$setup_info['api']['currentver'])); |
|
346 | + $messages[] = self::_echo_message($verbose, lang("database is version %1 and up to date.", $setup_info['api']['currentver'])); |
|
347 | 347 | |
348 | 348 | self::$egw_setup->detection->check_config(); |
349 | - if ($GLOBALS['egw_info']['setup']['config_errors'] && $stop && !in_array(15,$stop)) |
|
349 | + if ($GLOBALS['egw_info']['setup']['config_errors'] && $stop && !in_array(15, $stop)) |
|
350 | 350 | { |
351 | - throw new Api\Exception\WrongUserinput(lang('You need to configure EGroupware:')."\n- ".@implode("\n- ",$GLOBALS['egw_info']['setup']['config_errors']),15); |
|
351 | + throw new Api\Exception\WrongUserinput(lang('You need to configure EGroupware:')."\n- ".@implode("\n- ", $GLOBALS['egw_info']['setup']['config_errors']), 15); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | return $messages; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @param string $msg |
378 | 378 | * @return string $msg |
379 | 379 | */ |
380 | - static function _echo_message($verbose,$msg='') |
|
380 | + static function _echo_message($verbose, $msg = '') |
|
381 | 381 | { |
382 | 382 | if ($verbose) echo $msg."\n"; |
383 | 383 |
@@ -32,14 +32,20 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function _check_header_access() |
34 | 34 | { |
35 | - if (!$this->header_secret && $this->header_admin_user) // no secret specified but header_admin_user/password |
|
35 | + if (!$this->header_secret && $this->header_admin_user) |
|
36 | + { |
|
37 | + // no secret specified but header_admin_user/password |
|
36 | 38 | { |
37 | 39 | if (!$this->uid) $this->uid = true; |
40 | + } |
|
38 | 41 | $this->set_header_secret($this->header_admin_user,$this->header_admin_password); |
39 | 42 | } |
40 | 43 | $secret = $this->_calc_header_secret($GLOBALS['egw_info']['server']['header_admin_user'], |
41 | 44 | $GLOBALS['egw_info']['server']['header_admin_password']); |
42 | - if ($this->uid === true) unset($this->uid); |
|
45 | + if ($this->uid === true) |
|
46 | + { |
|
47 | + unset($this->uid); |
|
48 | + } |
|
43 | 49 | |
44 | 50 | if ($this->header_secret != $secret) |
45 | 51 | { |
@@ -57,10 +63,13 @@ discard block |
||
57 | 63 | */ |
58 | 64 | public function set_header_secret($user,$pw) |
59 | 65 | { |
60 | - if ($this->uid || parent::save(false)) // we need to save first, to get the uid |
|
66 | + if ($this->uid || parent::save(false)) |
|
67 | + { |
|
68 | + // we need to save first, to get the uid |
|
61 | 69 | { |
62 | 70 | $this->header_secret = $this->_calc_header_secret($user,$pw); |
63 | 71 | } |
72 | + } |
|
64 | 73 | else |
65 | 74 | { |
66 | 75 | throw new Exception ('failed to set header_secret!'); |
@@ -78,7 +87,10 @@ discard block |
||
78 | 87 | */ |
79 | 88 | private function _calc_header_secret($header_admin_user=null,$header_admin_password=null) |
80 | 89 | { |
81 | - if (!self::is_md5($header_admin_password)) $header_admin_password = md5($header_admin_password); |
|
90 | + if (!self::is_md5($header_admin_password)) |
|
91 | + { |
|
92 | + $header_admin_password = md5($header_admin_password); |
|
93 | + } |
|
82 | 94 | |
83 | 95 | $secret = md5($this->uid.$header_admin_user.$header_admin_password); |
84 | 96 | //echo "header_secret='$secret' = md5('$this->uid'.'$header_admin_user'.'$header_admin_password')\n"; |
@@ -135,7 +147,10 @@ discard block |
||
135 | 147 | self::$egw_accounts_backup = $GLOBALS['egw']->accounts; |
136 | 148 | unset($GLOBALS['egw']->accounts); |
137 | 149 | } |
138 | - if ($this->config) self::$egw_setup->setup_account_object($this->config); |
|
150 | + if ($this->config) |
|
151 | + { |
|
152 | + self::$egw_setup->setup_account_object($this->config); |
|
153 | + } |
|
139 | 154 | } |
140 | 155 | if (is_object($GLOBALS['egw']->db) && $domain) |
141 | 156 | { |
@@ -184,7 +199,9 @@ discard block |
||
184 | 199 | self::_setup_enviroment($domain); |
185 | 200 | |
186 | 201 | // check the authentication if a header_admin_password is set, if not we dont have a header yet and no authentication |
187 | - if ($GLOBALS['egw_info']['server']['header_admin_password']) // if that's not given we dont have a header yet |
|
202 | + if ($GLOBALS['egw_info']['server']['header_admin_password']) |
|
203 | + { |
|
204 | + // if that's not given we dont have a header yet |
|
188 | 205 | { |
189 | 206 | if (!self::$egw_setup->check_auth($user,$pw,$GLOBALS['egw_info']['server']['header_admin_user'], |
190 | 207 | $GLOBALS['egw_info']['server']['header_admin_password']) && |
@@ -195,6 +212,7 @@ discard block |
||
195 | 212 | if (is_null($domain)) |
196 | 213 | { |
197 | 214 | throw new Api\Exception\NoPermission(lang('Access denied: wrong username or password for manage-header !!!'),21); |
215 | + } |
|
198 | 216 | } |
199 | 217 | else |
200 | 218 | { |
@@ -236,7 +254,10 @@ discard block |
||
236 | 254 | |
237 | 255 | $messages = array(); |
238 | 256 | |
239 | - if ($stop && !is_array($stop)) $stop = array($stop); |
|
257 | + if ($stop && !is_array($stop)) |
|
258 | + { |
|
259 | + $stop = array($stop); |
|
260 | + } |
|
240 | 261 | |
241 | 262 | $versions =& $GLOBALS['egw_info']['server']['versions']; |
242 | 263 | |
@@ -254,7 +275,10 @@ discard block |
||
254 | 275 | $messages[] = self::_echo_message($verbose,lang('EGroupware API version %1 found.',$versions['api'])); |
255 | 276 | } |
256 | 277 | $header_stage = self::$egw_setup->detection->check_header(); |
257 | - if ($stop && in_array($header_stage,$stop)) return true; |
|
278 | + if ($stop && in_array($header_stage,$stop)) |
|
279 | + { |
|
280 | + return true; |
|
281 | + } |
|
258 | 282 | |
259 | 283 | switch ($header_stage) |
260 | 284 | { |
@@ -274,9 +298,12 @@ discard block |
||
274 | 298 | unset($header_checks); // no further output of the header checks |
275 | 299 | |
276 | 300 | $domains = $GLOBALS['egw_domain']; |
277 | - if ($domain) // domain to check given |
|
301 | + if ($domain) |
|
302 | + { |
|
303 | + // domain to check given |
|
278 | 304 | { |
279 | 305 | if (!isset($GLOBALS['egw_domain'][$domain])) throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!",$domain), 92); |
306 | + } |
|
280 | 307 | |
281 | 308 | $domains = array($domain => $GLOBALS['egw_domain'][$domain]); |
282 | 309 | } |
@@ -324,10 +351,13 @@ discard block |
||
324 | 351 | { |
325 | 352 | self::$apps_to_upgrade[] = $app; |
326 | 353 | } |
327 | - if (!isset($data['enabled']) && isset($data['version'])) // jdots eg. is no app, but a template |
|
354 | + if (!isset($data['enabled']) && isset($data['version'])) |
|
355 | + { |
|
356 | + // jdots eg. is no app, but a template |
|
328 | 357 | { |
329 | 358 | self::$apps_to_install[] = $app; |
330 | 359 | } |
360 | + } |
|
331 | 361 | } |
332 | 362 | if (self::$apps_to_install) |
333 | 363 | { |
@@ -337,7 +367,10 @@ discard block |
||
337 | 367 | if (self::$apps_to_upgrade) |
338 | 368 | { |
339 | 369 | $db_stage = 4; |
340 | - if ($stop && in_array(10+$db_stage,$stop)) return $messages; |
|
370 | + if ($stop && in_array(10+$db_stage,$stop)) |
|
371 | + { |
|
372 | + return $messages; |
|
373 | + } |
|
341 | 374 | |
342 | 375 | throw new Api\Exception\WrongUserinput(lang('The following applications need to be upgraded:').' '.implode(', ',self::$apps_to_upgrade).'! '.lang('Use --update to do so.'),14); |
343 | 376 | } |
@@ -379,7 +412,10 @@ discard block |
||
379 | 412 | */ |
380 | 413 | static function _echo_message($verbose,$msg='') |
381 | 414 | { |
382 | - if ($verbose) echo $msg."\n"; |
|
415 | + if ($verbose) |
|
416 | + { |
|
417 | + echo $msg."\n"; |
|
418 | + } |
|
383 | 419 | |
384 | 420 | return $msg; |
385 | 421 | } |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | * @version $Id$ |
14 | 14 | */ |
15 | 15 | |
16 | -error_reporting(error_reporting() & ~E_NOTICE & ~E_STRICT); |
|
16 | +error_reporting(error_reporting()&~E_NOTICE&~E_STRICT); |
|
17 | 17 | |
18 | 18 | // for an old header, we need to setup the reference before including it |
19 | -$GLOBALS['phpgw_info'] =& $GLOBALS['egw_info']; |
|
19 | +$GLOBALS['phpgw_info'] = & $GLOBALS['egw_info']; |
|
20 | 20 | |
21 | 21 | $GLOBALS['egw_info'] = array( |
22 | 22 | 'flags' => array( |
@@ -25,48 +25,48 @@ discard block |
||
25 | 25 | 'currentapp' => 'setup', |
26 | 26 | 'noapi' => True |
27 | 27 | )); |
28 | -if(file_exists('../header.inc.php')) |
|
28 | +if (file_exists('../header.inc.php')) |
|
29 | 29 | { |
30 | 30 | include('../header.inc.php'); |
31 | 31 | } |
32 | 32 | // for an old header we need to setup a reference for the domains |
33 | -if (!is_array($GLOBALS['egw_domain'])) $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain']; |
|
33 | +if (!is_array($GLOBALS['egw_domain'])) $GLOBALS['egw_domain'] = & $GLOBALS['phpgw_domain']; |
|
34 | 34 | |
35 | 35 | /* If we included the header.inc.php, but it is somehow broken, cover ourselves... */ |
36 | -if(!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT')) |
|
36 | +if (!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT')) |
|
37 | 37 | { |
38 | 38 | if (defined('PHPGW_SERVER_ROOT') && defined('PHPGW_INCLUDE_ROOT')) // pre 1.2 install |
39 | 39 | { |
40 | - define('EGW_SERVER_ROOT',PHPGW_SERVER_ROOT); |
|
41 | - define('EGW_INCLUDE_ROOT',PHPGW_INCLUDE_ROOT); |
|
40 | + define('EGW_SERVER_ROOT', PHPGW_SERVER_ROOT); |
|
41 | + define('EGW_INCLUDE_ROOT', PHPGW_INCLUDE_ROOT); |
|
42 | 42 | } |
43 | 43 | else // no install |
44 | 44 | { |
45 | - define('EGW_SERVER_ROOT',realpath('..')); |
|
46 | - define('EGW_INCLUDE_ROOT',realpath('..')); |
|
47 | - define('PHPGW_SERVER_ROOT',realpath('..')); |
|
48 | - define('PHPGW_INCLUDE_ROOT',realpath('..')); |
|
45 | + define('EGW_SERVER_ROOT', realpath('..')); |
|
46 | + define('EGW_INCLUDE_ROOT', realpath('..')); |
|
47 | + define('PHPGW_SERVER_ROOT', realpath('..')); |
|
48 | + define('PHPGW_INCLUDE_ROOT', realpath('..')); |
|
49 | 49 | } |
50 | - define('EGW_API_INC',EGW_SERVER_ROOT.'/phpgwapi/inc'); |
|
50 | + define('EGW_API_INC', EGW_SERVER_ROOT.'/phpgwapi/inc'); |
|
51 | 51 | } |
52 | 52 | |
53 | -require_once(EGW_INCLUDE_ROOT . '/api/src/loader/common.php'); |
|
53 | +require_once(EGW_INCLUDE_ROOT.'/api/src/loader/common.php'); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * function to handle multilanguage support |
57 | 57 | * |
58 | 58 | */ |
59 | -function lang($key,$vars=null) |
|
59 | +function lang($key, $vars = null) |
|
60 | 60 | { |
61 | - if(!is_array($vars)) |
|
61 | + if (!is_array($vars)) |
|
62 | 62 | { |
63 | 63 | $vars = func_get_args(); |
64 | - array_shift($vars); // remove $key |
|
64 | + array_shift($vars); // remove $key |
|
65 | 65 | } |
66 | 66 | return $GLOBALS['egw_setup']->translation->translate("$key", $vars); |
67 | 67 | } |
68 | 68 | |
69 | -if(file_exists(EGW_SERVER_ROOT.'/api/setup/setup.inc.php')) |
|
69 | +if (file_exists(EGW_SERVER_ROOT.'/api/setup/setup.inc.php')) |
|
70 | 70 | { |
71 | 71 | include(EGW_SERVER_ROOT.'/api/setup/setup.inc.php'); /* To set the current core version */ |
72 | 72 | /* This will change to just use setup_info */ |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | |
80 | 80 | $GLOBALS['egw_info']['server']['app_images'] = 'templates/default/images'; |
81 | 81 | |
82 | -CreateObject('setup.setup',True,True); // setup constuctor assigns itself to $GLOBALS['egw_setup'], doing it twice fails on some php4 |
|
83 | -$GLOBALS['phpgw_setup'] =& $GLOBALS['egw_setup']; |
|
82 | +CreateObject('setup.setup', True, True); // setup constuctor assigns itself to $GLOBALS['egw_setup'], doing it twice fails on some php4 |
|
83 | +$GLOBALS['phpgw_setup'] = & $GLOBALS['egw_setup']; |
|
84 | 84 | |
85 | -if (!function_exists('version_compare') || version_compare(PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,'<')) |
|
85 | +if (!function_exists('version_compare') || version_compare(PHP_VERSION, $GLOBALS['egw_setup']->required_php_version, '<')) |
|
86 | 86 | { |
87 | 87 | if (isset($_SERVER['HTTP_HOST'])) echo "<pre>\n"; |
88 | 88 | echo "EGroupware now requires PHP {$GLOBALS['egw_setup']->required_php_version} or greater.\nYour PHP version is: ".PHP_VERSION."\n"; |
@@ -30,14 +30,20 @@ discard block |
||
30 | 30 | include('../header.inc.php'); |
31 | 31 | } |
32 | 32 | // for an old header we need to setup a reference for the domains |
33 | -if (!is_array($GLOBALS['egw_domain'])) $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain']; |
|
33 | +if (!is_array($GLOBALS['egw_domain'])) |
|
34 | +{ |
|
35 | + $GLOBALS['egw_domain'] =& $GLOBALS['phpgw_domain']; |
|
36 | +} |
|
34 | 37 | |
35 | 38 | /* If we included the header.inc.php, but it is somehow broken, cover ourselves... */ |
36 | 39 | if(!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT')) |
37 | 40 | { |
38 | - if (defined('PHPGW_SERVER_ROOT') && defined('PHPGW_INCLUDE_ROOT')) // pre 1.2 install |
|
41 | + if (defined('PHPGW_SERVER_ROOT') && defined('PHPGW_INCLUDE_ROOT')) |
|
42 | + { |
|
43 | + // pre 1.2 install |
|
39 | 44 | { |
40 | 45 | define('EGW_SERVER_ROOT',PHPGW_SERVER_ROOT); |
46 | + } |
|
41 | 47 | define('EGW_INCLUDE_ROOT',PHPGW_INCLUDE_ROOT); |
42 | 48 | } |
43 | 49 | else // no install |
@@ -84,7 +90,10 @@ discard block |
||
84 | 90 | |
85 | 91 | if (!function_exists('version_compare') || version_compare(PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,'<')) |
86 | 92 | { |
87 | - if (isset($_SERVER['HTTP_HOST'])) echo "<pre>\n"; |
|
93 | + if (isset($_SERVER['HTTP_HOST'])) |
|
94 | + { |
|
95 | + echo "<pre>\n"; |
|
96 | + } |
|
88 | 97 | echo "EGroupware now requires PHP {$GLOBALS['egw_setup']->required_php_version} or greater.\nYour PHP version is: ".PHP_VERSION."\n"; |
89 | 98 | echo 'Please contact your System Administrator.'; |
90 | 99 | exit; |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function auth_type($settings) |
34 | 34 | { |
35 | - switch($settings['auth_type']) |
|
35 | + switch ($settings['auth_type']) |
|
36 | 36 | { |
37 | 37 | case 'mail': |
38 | 38 | if (class_exists('Horde_Imap_Client_Socket') && !in_array($settings['mail_server_type'], array('pop', 'pops'))) |
39 | 39 | { |
40 | - return; // we use Horde code instead of imap extension |
|
40 | + return; // we use Horde code instead of imap extension |
|
41 | 41 | } |
42 | 42 | try { |
43 | 43 | check_load_extension('imap', true); |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function vfs_storage_mode($settings) |
59 | 59 | { |
60 | - switch($settings['vfs_storage_mode']) |
|
60 | + switch ($settings['vfs_storage_mode']) |
|
61 | 61 | { |
62 | 62 | case 'fs': |
63 | - Api\Config::save_value('vfs_fstab','','phpgwapi'); |
|
63 | + Api\Config::save_value('vfs_fstab', '', 'phpgwapi'); |
|
64 | 64 | break; |
65 | 65 | case 'db': |
66 | 66 | Api\Config::save_value('vfs_fstab', array( |
67 | 67 | '/' => 'sqlfs://$host/?storage=db', |
68 | 68 | '/apps' => 'links://$host/apps?storage=db', |
69 | - ),'phpgwapi'); |
|
69 | + ), 'phpgwapi'); |
|
70 | 70 | break; |
71 | 71 | } |
72 | 72 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | function temp_dir($settings) |
75 | 75 | { |
76 | 76 | $error_msg = null; |
77 | - if (!setup_detection::check_dir($settings['temp_dir'],$error_msg)) |
|
77 | + if (!setup_detection::check_dir($settings['temp_dir'], $error_msg)) |
|
78 | 78 | { |
79 | - $GLOBALS['config_error'] = lang("Your temporary directory '%1' %2",$settings['temp_dir'],$error_msg); |
|
79 | + $GLOBALS['config_error'] = lang("Your temporary directory '%1' %2", $settings['temp_dir'], $error_msg); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | { |
85 | 85 | $error_msg = null; |
86 | 86 | if ($settings['file_repository'] == 'sql' && $settings['file_store_contents'] == 'filesystem' && |
87 | - !setup_detection::check_dir($settings['files_dir'],$error_msg,true)) |
|
87 | + !setup_detection::check_dir($settings['files_dir'], $error_msg, true)) |
|
88 | 88 | { |
89 | - $GLOBALS['config_error'] = lang("Your files directory '%1' %2",$settings['files_dir'],$error_msg); |
|
89 | + $GLOBALS['config_error'] = lang("Your files directory '%1' %2", $settings['files_dir'], $error_msg); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -97,20 +97,20 @@ discard block |
||
97 | 97 | $settings['backup_dir'] = $settings['files_dir'].'/db_backup'; |
98 | 98 | } |
99 | 99 | $error_msg = null; |
100 | - if (!setup_detection::check_dir($settings['backup_dir'],$error_msg,true)) |
|
100 | + if (!setup_detection::check_dir($settings['backup_dir'], $error_msg, true)) |
|
101 | 101 | { |
102 | - $GLOBALS['config_error'] = lang("Your backup directory '%1' %2",$settings['backup_dir'],$error_msg); |
|
102 | + $GLOBALS['config_error'] = lang("Your backup directory '%1' %2", $settings['backup_dir'], $error_msg); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | -function _mcrypt_test_module_mode($module,$mode) |
|
106 | +function _mcrypt_test_module_mode($module, $mode) |
|
107 | 107 | { |
108 | 108 | /* Data */ |
109 | 109 | $key_in = 'this is a very long key, even too long for the cipher'; |
110 | 110 | $plain_text = 'very important data'; |
111 | 111 | |
112 | 112 | /* Open module, and create IV */ |
113 | - if(!$GLOBALS['td'] = @mcrypt_module_open($module, '',$mode, '')) |
|
113 | + if (!$GLOBALS['td'] = @mcrypt_module_open($module, '', $mode, '')) |
|
114 | 114 | { |
115 | 115 | @mcrypt_module_close($GLOBALS['td']); |
116 | 116 | return False; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $iv = @mcrypt_create_iv($iv_size, MCRYPT_RAND); |
121 | 121 | |
122 | 122 | /* Initialize encryption handle */ |
123 | - if(mcrypt_generic_init($GLOBALS['td'], $key, $iv) != -1) |
|
123 | + if (mcrypt_generic_init($GLOBALS['td'], $key, $iv) != -1) |
|
124 | 124 | { |
125 | 125 | /* Encrypt data */ |
126 | 126 | $c_t = mcrypt_generic($GLOBALS['td'], $plain_text); |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | $modes = mcrypt_list_modes(); |
155 | 155 | $algorithms = mcrypt_list_algorithms(); |
156 | 156 | |
157 | - foreach($algorithms as $cipher) |
|
157 | + foreach ($algorithms as $cipher) |
|
158 | 158 | { |
159 | - if(mcrypt_module_self_test($cipher)) |
|
159 | + if (mcrypt_module_self_test($cipher)) |
|
160 | 160 | { |
161 | 161 | $GLOBALS['ciphers'][$cipher] = array(); |
162 | - foreach($modes as $mode) |
|
162 | + foreach ($modes as $mode) |
|
163 | 163 | { |
164 | - if(_mcrypt_test_module_mode($cipher,$mode)) |
|
164 | + if (_mcrypt_test_module_mode($cipher, $mode)) |
|
165 | 165 | { |
166 | 166 | $result = True; |
167 | 167 | } |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | function mcrypt_algo($settings) |
181 | 181 | { |
182 | 182 | /* _debug_array($settings);exit; */ |
183 | - if(@function_exists('mcrypt_list_modes')) |
|
183 | + if (@function_exists('mcrypt_list_modes')) |
|
184 | 184 | { |
185 | 185 | mcrypt_check_sanity(); |
186 | - if(!@$GLOBALS['ciphers'][$settings['mcrypt_algo']][$settings['mcrypt_mode']]) |
|
186 | + if (!@$GLOBALS['ciphers'][$settings['mcrypt_algo']][$settings['mcrypt_mode']]) |
|
187 | 187 | { |
188 | 188 | $GLOBALS['config_error'] = lang('Invalid Mcrypt Algorithm/Mode combination'); |
189 | 189 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | function ldap_search_filter(&$settings) |
199 | 199 | { |
200 | - $filter =& $settings['ldap_search_filter']; |
|
200 | + $filter = & $settings['ldap_search_filter']; |
|
201 | 201 | |
202 | 202 | if ($filter && $filter{0} != '(') $filter = '('.$filter.')'; |
203 | 203 | } |
@@ -199,5 +199,8 @@ |
||
199 | 199 | { |
200 | 200 | $filter =& $settings['ldap_search_filter']; |
201 | 201 | |
202 | - if ($filter && $filter{0} != '(') $filter = '('.$filter.')'; |
|
203 | -} |
|
202 | + if ($filter && $filter{0} != '(') |
|
203 | + { |
|
204 | + $filter = '('.$filter.')'; |
|
205 | + } |
|
206 | + } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param array $config =array() configuration to preset the defaults during the install, eg. set the account_repository |
35 | 35 | * @param string $lang ='en' |
36 | 36 | */ |
37 | - function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$charset='utf-8',$verbose=false,array $config=array(),$lang='en') |
|
37 | + function __construct($domain, $config_user = null, $config_passwd = null, $backup = null, $charset = 'utf-8', $verbose = false, array $config = array(), $lang = 'en') |
|
38 | 38 | { |
39 | 39 | if (!is_array($domain)) |
40 | 40 | { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'lang' => $lang, |
50 | 50 | ); |
51 | 51 | } |
52 | - elseif(!$domain['charset']) |
|
52 | + elseif (!$domain['charset']) |
|
53 | 53 | { |
54 | 54 | $domain['charset'] = 'utf-8'; |
55 | 55 | } |
@@ -65,24 +65,24 @@ discard block |
||
65 | 65 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
66 | 66 | * @throws Exception('header.inc.php not found!'); |
67 | 67 | */ |
68 | - protected function exec($check_only=false) |
|
68 | + protected function exec($check_only = false) |
|
69 | 69 | { |
70 | - unset($check_only); // not used; |
|
70 | + unset($check_only); // not used; |
|
71 | 71 | global $setup_info; |
72 | 72 | |
73 | 73 | // instanciate setup object and check authorisation |
74 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
74 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
75 | 75 | |
76 | - $this->check_installed($this->domain,array(13,14,20),$this->verbose); |
|
76 | + $this->check_installed($this->domain, array(13, 14, 20), $this->verbose); |
|
77 | 77 | |
78 | 78 | // use uploaded backup, instead installing from scratch |
79 | 79 | if ($this->backup) |
80 | 80 | { |
81 | 81 | $db_backup = new db_backup(); |
82 | 82 | |
83 | - if (!is_resource($f = $db_backup->fopen_backup($this->backup,true))) |
|
83 | + if (!is_resource($f = $db_backup->fopen_backup($this->backup, true))) |
|
84 | 84 | { |
85 | - throw new Api\Exception\WrongUserinput(lang('Restore failed').' ('.$f.')',31); |
|
85 | + throw new Api\Exception\WrongUserinput(lang('Restore failed').' ('.$f.')', 31); |
|
86 | 86 | } |
87 | 87 | if ($this->verbose) |
88 | 88 | { |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | } |
91 | 91 | else |
92 | 92 | { |
93 | - ob_start(); // restore echos the table structure |
|
93 | + ob_start(); // restore echos the table structure |
|
94 | 94 | } |
95 | - $db_backup->restore($f,$this->charset,$this->backup); |
|
95 | + $db_backup->restore($f, $this->charset, $this->backup); |
|
96 | 96 | fclose($f); |
97 | 97 | |
98 | 98 | if (!$this->verbose) |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // regular (new) install |
105 | 105 | if ($GLOBALS['egw_info']['setup']['stage']['db'] != 3) |
106 | 106 | { |
107 | - throw new Api\Exception\WrongUserinput(lang('eGroupWare is already installed!'),30); |
|
107 | + throw new Api\Exception\WrongUserinput(lang('eGroupWare is already installed!'), 30); |
|
108 | 108 | } |
109 | 109 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
110 | 110 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $_POST['ConfigLang'] = $this->lang; |
115 | 115 | |
116 | 116 | if ($this->verbose) echo lang('Installation started, this might take a few minutes ...')."\n"; |
117 | - if (true) $setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config); |
|
117 | + if (true) $setup_info = self::$egw_setup->process->pass($setup_info, 'new', false, True, $this->config); |
|
118 | 118 | |
119 | 119 | $this->restore_db(); |
120 | 120 |
@@ -113,8 +113,14 @@ |
||
113 | 113 | self::$egw_setup->db->Link_ID->SetCharSet($this->charset); |
114 | 114 | $_POST['ConfigLang'] = $this->lang; |
115 | 115 | |
116 | - if ($this->verbose) echo lang('Installation started, this might take a few minutes ...')."\n"; |
|
117 | - if (true) $setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config); |
|
116 | + if ($this->verbose) |
|
117 | + { |
|
118 | + echo lang('Installation started, this might take a few minutes ...')."\n"; |
|
119 | + } |
|
120 | + if (true) |
|
121 | + { |
|
122 | + $setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config); |
|
123 | + } |
|
118 | 124 | |
119 | 125 | $this->restore_db(); |
120 | 126 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $arguments =null array with command line argruments |
32 | 32 | * @param boolean $verbose =false if true, echos out some status information during the run |
33 | 33 | */ |
34 | - function __construct($domain,$config_user=null,$config_passwd=null,$arguments=null,$verbose=false) |
|
34 | + function __construct($domain, $config_user = null, $config_passwd = null, $arguments = null, $verbose = false) |
|
35 | 35 | { |
36 | 36 | if (!is_array($domain)) |
37 | 37 | { |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
56 | 56 | * @throws Exception('header.inc.php not found!'); |
57 | 57 | */ |
58 | - protected function exec($check_only=false) |
|
58 | + protected function exec($check_only = false) |
|
59 | 59 | { |
60 | 60 | if ($check_only && $this->remote_id) |
61 | 61 | { |
62 | - return true; // can only check locally |
|
62 | + return true; // can only check locally |
|
63 | 63 | } |
64 | 64 | // instanciate setup object and check authorisation |
65 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
65 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
66 | 66 | |
67 | - $this->check_installed($this->domain,15,$this->verbose); |
|
67 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
68 | 68 | |
69 | 69 | // fixing authtypes in self::$options |
70 | 70 | self::auth_types(true); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | // store the config |
83 | - foreach($values as $name => $value) |
|
83 | + foreach ($values as $name => $value) |
|
84 | 84 | { |
85 | 85 | if (substr($name, 0, 4) == 'acc_') continue; |
86 | 86 | |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | { |
90 | 90 | list($app, $name) = explode('/', $name); |
91 | 91 | } |
92 | - self::$egw_setup->db->insert(self::$egw_setup->config_table,array( |
|
92 | + self::$egw_setup->db->insert(self::$egw_setup->config_table, array( |
|
93 | 93 | 'config_value' => $value, |
94 | - ),array( |
|
94 | + ), array( |
|
95 | 95 | 'config_app' => $app, |
96 | 96 | 'config_name' => $name, |
97 | - ),__LINE__,__FILE__); |
|
97 | + ), __LINE__, __FILE__); |
|
98 | 98 | } |
99 | 99 | if (count($values)) |
100 | 100 | { |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | * @param boolean $echoit =false if true the config is additionally echo'ed out |
119 | 119 | * @return array with name => value pairs |
120 | 120 | */ |
121 | - static function get_config($echoit=false) |
|
121 | + static function get_config($echoit = false) |
|
122 | 122 | { |
123 | - self::$egw_setup->db->select(self::$egw_setup->config_table,'config_name,config_value',array( |
|
123 | + self::$egw_setup->db->select(self::$egw_setup->config_table, 'config_name,config_value', array( |
|
124 | 124 | 'config_app' => 'phpgwapi', |
125 | 125 | "(config_name LIKE '%\\_dir' OR (config_name LIKE 'mail%' AND config_name != 'mail_footer') OR config_name LIKE 'smtp\\_%' OR config_name LIKE 'ldap%' OR config_name IN ('webserver_url','system_charset','auth_type','account_repository'))", |
126 | - ),__LINE__,__FILE__); |
|
126 | + ), __LINE__, __FILE__); |
|
127 | 127 | |
128 | 128 | $config = array(); |
129 | 129 | while (($row = self::$egw_setup->db->row(true))) |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | if ($echoit) |
134 | 134 | { |
135 | 135 | echo lang('Current configuration:')."\n"; |
136 | - foreach($config as $name => $value) |
|
136 | + foreach ($config as $name => $value) |
|
137 | 137 | { |
138 | - echo str_pad($name.':',22).$value."\n"; |
|
138 | + echo str_pad($name.':', 22).$value."\n"; |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | return $config; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @var array |
148 | 148 | */ |
149 | 149 | static $options = array( |
150 | - '--config' => array(), // name=value,... |
|
150 | + '--config' => array(), // name=value,... |
|
151 | 151 | '--files-dir' => 'files_dir', |
152 | 152 | '--vfs-root-user' => 'vfs_root_user', |
153 | 153 | '--backup-dir' => 'backup_dir', |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | 'acc_imap_host', |
159 | 159 | 'acc_imap_port', |
160 | 160 | 'acc_domain', |
161 | - array('name' => 'acc_imap_logintype','allowed' => array( |
|
161 | + array('name' => 'acc_imap_logintype', 'allowed' => array( |
|
162 | 162 | 'username (standard)' => 'standard', |
163 | 163 | 'username@domain (virtual mail manager)' => 'vmailmgr', |
164 | 164 | 'Username/Password defined by admin' => 'admin', |
165 | 165 | 'userId@domain eg. u123@domain' => 'uidNumber', |
166 | 166 | 'email (Standard Maildomain should be set)' => 'email', |
167 | 167 | )), |
168 | - array('name' => 'acc_imap_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
168 | + array('name' => 'acc_imap_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
169 | 169 | ), |
170 | 170 | '--imap' => array( |
171 | 171 | 'acc_imap_admin_username', |
@@ -173,28 +173,28 @@ discard block |
||
173 | 173 | 'acc_imap_type', |
174 | 174 | ), |
175 | 175 | '--folder' => array( |
176 | - 'acc_folder_sent','acc_folder_trash','acc_folder_draft','acc_folder_template','acc_folder_junk', |
|
176 | + 'acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk', |
|
177 | 177 | ), |
178 | 178 | '--sieve' => array( |
179 | 179 | array('name' => 'acc_sieve_host'), |
180 | 180 | 'acc_sieve_port', |
181 | 181 | 'acc_sieve_enabled', |
182 | - array('name' => 'acc_sieve_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
182 | + array('name' => 'acc_sieve_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
183 | 183 | ), |
184 | 184 | '--smtp' => array( |
185 | - array('name' => 'editforwardingaddress','allowed' => array('yes',null)), |
|
185 | + array('name' => 'editforwardingaddress', 'allowed' => array('yes', null)), |
|
186 | 186 | 'acc_smtp_type', |
187 | 187 | ), |
188 | 188 | '--smtpserver' => array( //smtp server,[smtp port],[smtp user],[smtp password],[auth session user/pw],[no|starttls|ssl|tls],[user editable],[further identities] |
189 | - 'acc_smtp_host','acc_smtp_port','acc_smtp_username','acc_smtp_passwd','acc_smtp_auth_session', |
|
190 | - array('name' => 'acc_smtp_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')), |
|
191 | - 'acc_user_editable','acc_further_identities', |
|
189 | + 'acc_smtp_host', 'acc_smtp_port', 'acc_smtp_username', 'acc_smtp_passwd', 'acc_smtp_auth_session', |
|
190 | + array('name' => 'acc_smtp_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')), |
|
191 | + 'acc_user_editable', 'acc_further_identities', |
|
192 | 192 | ), |
193 | 193 | '--account-auth' => array( |
194 | - array('name' => 'account_repository','allowed' => array('sql','ldap','ads'),'default'=>'sql'), |
|
195 | - array('name' => 'auth_type','allowed' => array('sql','ldap','mail','ads','http','sqlssl','nis','pam'),'default'=>'sql'), |
|
196 | - array('name' => 'sql_encryption','allowed' => array('blowfish_crypt','sha512_crypt','sha256_crypt','md5_crypt','crypt','ssha','smd5','md5'),'default'=>'blowfish_crypt'), |
|
197 | - 'check_save_password','allow_cookie_auth'), |
|
194 | + array('name' => 'account_repository', 'allowed' => array('sql', 'ldap', 'ads'), 'default'=>'sql'), |
|
195 | + array('name' => 'auth_type', 'allowed' => array('sql', 'ldap', 'mail', 'ads', 'http', 'sqlssl', 'nis', 'pam'), 'default'=>'sql'), |
|
196 | + array('name' => 'sql_encryption', 'allowed' => array('blowfish_crypt', 'sha512_crypt', 'sha256_crypt', 'md5_crypt', 'crypt', 'ssha', 'smd5', 'md5'), 'default'=>'blowfish_crypt'), |
|
197 | + 'check_save_password', 'allow_cookie_auth'), |
|
198 | 198 | '--ldap-host' => 'ldap_host', |
199 | 199 | '--ldap-root-dn' => 'ldap_root_dn', |
200 | 200 | '--ldap-root-pw' => 'ldap_root_pw', |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | '--install-id' => 'install_id', |
207 | 207 | '--ads-host' => 'ads_host', |
208 | 208 | '--ads-domain' => 'ads_domain', |
209 | - '--ads-admin-user' => 'ads_domain_admin', // eg. Administrator |
|
209 | + '--ads-admin-user' => 'ads_domain_admin', // eg. Administrator |
|
210 | 210 | '--ads-admin-pw' => 'ads_admin_pw', |
211 | 211 | '--ads-connection' => array( |
212 | 212 | array('name' => 'ads_connection', 'allowed' => array('ssl', 'tls')) |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | |
253 | 253 | $save_mail_account = false; |
254 | 254 | $values = array(); |
255 | - foreach(self::$options as $arg => $option) |
|
255 | + foreach (self::$options as $arg => $option) |
|
256 | 256 | { |
257 | - foreach(is_array($option) ? $option : array($option) as $n => $data) |
|
257 | + foreach (is_array($option) ? $option : array($option) as $n => $data) |
|
258 | 258 | { |
259 | 259 | $name = is_array($data) ? $data['name'] : $data; |
260 | 260 | $oldname = array_key_exists($name, $this->old2new); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | if (isset($this->$name)) |
268 | 268 | { |
269 | - $save_mail_account = $this->_parse_value($arg,$n,$option,$this->$name,$values) || $save_mail_account; |
|
269 | + $save_mail_account = $this->_parse_value($arg, $n, $option, $this->$name, $values) || $save_mail_account; |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | } |
@@ -284,27 +284,27 @@ discard block |
||
284 | 284 | $values = array(); |
285 | 285 | $save_mail_account = false; |
286 | 286 | $args = $this->arguments; |
287 | - while(($arg = array_shift($args))) |
|
287 | + while (($arg = array_shift($args))) |
|
288 | 288 | { |
289 | 289 | if (!isset(self::$options[$arg])) |
290 | 290 | { |
291 | - throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$arg),90); |
|
291 | + throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!", $arg), 90); |
|
292 | 292 | } |
293 | - $options = is_array(self::$options[$arg]) ? explode(',',array_shift($args)) : array(array_shift($args)); |
|
293 | + $options = is_array(self::$options[$arg]) ? explode(',', array_shift($args)) : array(array_shift($args)); |
|
294 | 294 | |
295 | 295 | if ($arg == '--config' || $arg == '--setup_cmd_config') |
296 | 296 | { |
297 | - foreach($options as $option) |
|
297 | + foreach ($options as $option) |
|
298 | 298 | { |
299 | - list($name,$value) = explode('=',$option,2); |
|
299 | + list($name, $value) = explode('=', $option, 2); |
|
300 | 300 | $values[$name] = $value; |
301 | 301 | } |
302 | 302 | continue; |
303 | 303 | } |
304 | 304 | $options[] = ''; $options[] = ''; |
305 | - foreach($options as $n => $value) |
|
305 | + foreach ($options as $n => $value) |
|
306 | 306 | { |
307 | - $save_mail_account = $this->_parse_value($arg,$n,self::$options[$arg],$value,$values) || $save_mail_account; |
|
307 | + $save_mail_account = $this->_parse_value($arg, $n, self::$options[$arg], $value, $values) || $save_mail_account; |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | return $save_mail_account; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param array &$values where the values get set |
321 | 321 | * @return boolean true if mail-accounts needs to be saved, false if not |
322 | 322 | */ |
323 | - private function _parse_value($arg,$n,$data,$value,array &$values) |
|
323 | + private function _parse_value($arg, $n, $data, $value, array &$values) |
|
324 | 324 | { |
325 | 325 | if ($value === '' && is_array($data) && !isset($data[$n]['default'])) return false; |
326 | 326 | |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | { |
331 | 331 | if (!$value && isset($name['default'])) $value = $name['default']; |
332 | 332 | |
333 | - if (isset($name['allowed']) && !in_array($value,$name['allowed'])) |
|
333 | + if (isset($name['allowed']) && !in_array($value, $name['allowed'])) |
|
334 | 334 | { |
335 | - throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1+$n,$arg)." ($name[name])",91); |
|
335 | + throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!", $value, 1 + $n, $arg)." ($name[name])", 91); |
|
336 | 336 | } |
337 | 337 | $name = $name['name']; |
338 | 338 | } |
339 | 339 | $values[$name] = $value; |
340 | 340 | |
341 | - return in_array($arg,array('--mailserver','--smtpserver','--imap','--smtp','--sieve','--folder')); |
|
341 | + return in_array($arg, array('--mailserver', '--smtpserver', '--imap', '--smtp', '--sieve', '--folder')); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | function _save_mail_account(array $data) |
350 | 350 | { |
351 | 351 | // convert ssl textual values to nummerical ones used in Api\Mail\Account |
352 | - foreach(array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name) |
|
352 | + foreach (array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name) |
|
353 | 353 | { |
354 | - switch(strtolower($data[$name])) |
|
354 | + switch (strtolower($data[$name])) |
|
355 | 355 | { |
356 | 356 | case 'no': $data[$name] = Api\Mail\Account::SSL_NONE; break; |
357 | 357 | case 'starttls': $data[$name] = Api\Mail\Account::SSL_STARTTLS; break; |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | } |
361 | 361 | } |
362 | 362 | // convert 'yes', 'no' to boolean |
363 | - foreach(array('acc_sieve_enabled','acc_user_editable','acc_further_identities','acc_smtp_auth_session') as $name) |
|
363 | + foreach (array('acc_sieve_enabled', 'acc_user_editable', 'acc_further_identities', 'acc_smtp_auth_session') as $name) |
|
364 | 364 | { |
365 | 365 | $data[$name] = $data[$name] && strtolower($data[$name]) != 'no'; |
366 | 366 | } |
367 | 367 | // do NOT write empty usernames |
368 | - foreach(array('acc_imap_username', 'acc_smtp_username') as $name) |
|
368 | + foreach (array('acc_imap_username', 'acc_smtp_username') as $name) |
|
369 | 369 | { |
370 | 370 | if (empty($data[$name])) |
371 | 371 | { |
@@ -375,16 +375,16 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | $data['acc_name'] = 'Created by setup'; |
378 | - $data['account_id'] = 0; // 0 = valid for all users |
|
378 | + $data['account_id'] = 0; // 0 = valid for all users |
|
379 | 379 | |
380 | 380 | Api\Mail\Account::write($data); |
381 | 381 | |
382 | 382 | if ($this->verbose) |
383 | 383 | { |
384 | 384 | echo "\n".lang('EMailAdmin mail account saved:')."\n"; |
385 | - foreach($data as $name => $value) |
|
385 | + foreach ($data as $name => $value) |
|
386 | 386 | { |
387 | - echo str_pad($name.':',22).$value."\n"; |
|
387 | + echo str_pad($name.':', 22).$value."\n"; |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | static function options() |
398 | 398 | { |
399 | 399 | $options = array(); |
400 | - foreach(self::$options as $option) |
|
400 | + foreach (self::$options as $option) |
|
401 | 401 | { |
402 | 402 | if (is_array($option)) |
403 | 403 | { |
404 | - foreach($option as $data) |
|
404 | + foreach ($option as $data) |
|
405 | 405 | { |
406 | 406 | if (is_array($data) && isset($data['allowed'])) |
407 | 407 | { |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | $options[$data['name']] = self::account_repositories(); |
415 | 415 | continue 2; |
416 | 416 | } |
417 | - foreach($data['allowed'] as $label => $value) |
|
417 | + foreach ($data['allowed'] as $label => $value) |
|
418 | 418 | { |
419 | 419 | if (is_int($label)) |
420 | 420 | { |
421 | - $label = (string) $value === '' ? 'No' : strtoupper($value); |
|
421 | + $label = (string)$value === '' ? 'No' : strtoupper($value); |
|
422 | 422 | } |
423 | 423 | $options[$data['name']][$value] = lang($label); |
424 | 424 | } |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | if (!$scan_done++) |
452 | 452 | { |
453 | 453 | // now add auth backends found in filesystem |
454 | - foreach(scandir(EGW_INCLUDE_ROOT.'/api/src/Auth') as $file) |
|
454 | + foreach (scandir(EGW_INCLUDE_ROOT.'/api/src/Auth') as $file) |
|
455 | 455 | { |
456 | 456 | $matches = null; |
457 | 457 | if (preg_match('/^([a-z0-9]+)\.php$/', $file, $matches) && |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | $auth_types[strtolower($matches[1])] = $matches[1]; |
461 | 461 | } |
462 | 462 | } |
463 | - foreach(self::$options['--account-auth'] as &$param) |
|
463 | + foreach (self::$options['--account-auth'] as &$param) |
|
464 | 464 | { |
465 | 465 | if ($param['name'] == 'auth_type') |
466 | 466 | { |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @param string $current =null current value, to allways return it |
479 | 479 | * @return array |
480 | 480 | */ |
481 | - static function account_repositories($current=null) |
|
481 | + static function account_repositories($current = null) |
|
482 | 482 | { |
483 | 483 | static $account_repositories = array( |
484 | 484 | 'sql' => 'SQL', |
@@ -489,13 +489,13 @@ discard block |
||
489 | 489 | if (!$scan_done++) |
490 | 490 | { |
491 | 491 | // now add auth backends found in filesystem |
492 | - foreach(scandir(EGW_INCLUDE_ROOT.'/api/src/Accounts') as $file) |
|
492 | + foreach (scandir(EGW_INCLUDE_ROOT.'/api/src/Accounts') as $file) |
|
493 | 493 | { |
494 | 494 | $matches = null; |
495 | 495 | if (preg_match('/^([a-z0-9]+)\.php$/', $file, $matches) && |
496 | 496 | !isset($account_repositories[strtolower($matches[1])]) && |
497 | - class_exists($class='EGroupware\\Api\\Accounts\\'.$matches[1]) && |
|
498 | - (strtolower($matches[1]) == $current || !is_callable($callable=$class.'::available') || call_user_func($callable))) |
|
497 | + class_exists($class = 'EGroupware\\Api\\Accounts\\'.$matches[1]) && |
|
498 | + (strtolower($matches[1]) == $current || !is_callable($callable = $class.'::available') || call_user_func($callable))) |
|
499 | 499 | { |
500 | 500 | $account_repositories[strtolower($matches[1])] = $matches[1]; |
501 | 501 | } |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | { |
514 | 514 | $defaults = array(); |
515 | 515 | // fetch the default from the cli options |
516 | - foreach(self::$options as $option) |
|
516 | + foreach (self::$options as $option) |
|
517 | 517 | { |
518 | 518 | if (is_array($option)) |
519 | 519 | { |
520 | - foreach($option as $data) |
|
520 | + foreach ($option as $data) |
|
521 | 521 | { |
522 | 522 | if (is_array($data) && isset($data['default'])) |
523 | 523 | { |
@@ -545,20 +545,20 @@ discard block |
||
545 | 545 | */ |
546 | 546 | private function _merge_defaults() |
547 | 547 | { |
548 | - foreach(self::defaults() as $name => $default) |
|
548 | + foreach (self::defaults() as $name => $default) |
|
549 | 549 | { |
550 | 550 | if (!$this->$name) |
551 | 551 | { |
552 | 552 | //echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n"; |
553 | 553 | $this->set_defaults[$name] = $this->$name = $default; |
554 | 554 | } |
555 | - if (strpos($this->$name,'$') !== false) |
|
555 | + if (strpos($this->$name, '$') !== false) |
|
556 | 556 | { |
557 | 557 | $this->set_defaults[$name] = $this->$name = str_replace(array( |
558 | 558 | '$domain', |
559 | - ),array( |
|
559 | + ), array( |
|
560 | 560 | $this->domain, |
561 | - ),$this->$name); |
|
561 | + ), $this->$name); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | } |
@@ -70,10 +70,13 @@ discard block |
||
70 | 70 | self::auth_types(true); |
71 | 71 | |
72 | 72 | $values = array(); |
73 | - if ($this->arguments) // we have command line arguments |
|
73 | + if ($this->arguments) |
|
74 | + { |
|
75 | + // we have command line arguments |
|
74 | 76 | { |
75 | 77 | $save_mail_account = $this->_parse_cli_arguments($values); |
76 | 78 | } |
79 | + } |
|
77 | 80 | else |
78 | 81 | { |
79 | 82 | $save_mail_account = $this->_parse_properties($values); |
@@ -82,7 +85,10 @@ discard block |
||
82 | 85 | // store the config |
83 | 86 | foreach($values as $name => $value) |
84 | 87 | { |
85 | - if (substr($name, 0, 4) == 'acc_') continue; |
|
88 | + if (substr($name, 0, 4) == 'acc_') |
|
89 | + { |
|
90 | + continue; |
|
91 | + } |
|
86 | 92 | |
87 | 93 | $app = 'phpgwapi'; |
88 | 94 | if (strpos($name, '/') !== false) |
@@ -98,7 +104,10 @@ discard block |
||
98 | 104 | } |
99 | 105 | if (count($values)) |
100 | 106 | { |
101 | - if ($save_mail_account) $this->_save_mail_account($values); |
|
107 | + if ($save_mail_account) |
|
108 | + { |
|
109 | + $this->_save_mail_account($values); |
|
110 | + } |
|
102 | 111 | |
103 | 112 | // flush instance cache, so above config get read from database not cache |
104 | 113 | Api\Cache::flush(); |
@@ -322,13 +331,19 @@ discard block |
||
322 | 331 | */ |
323 | 332 | private function _parse_value($arg,$n,$data,$value,array &$values) |
324 | 333 | { |
325 | - if ($value === '' && is_array($data) && !isset($data[$n]['default'])) return false; |
|
334 | + if ($value === '' && is_array($data) && !isset($data[$n]['default'])) |
|
335 | + { |
|
336 | + return false; |
|
337 | + } |
|
326 | 338 | |
327 | 339 | $name = is_array($data) || $n ? $data[$n] : $data; |
328 | 340 | |
329 | 341 | if (is_array($name)) |
330 | 342 | { |
331 | - if (!$value && isset($name['default'])) $value = $name['default']; |
|
343 | + if (!$value && isset($name['default'])) |
|
344 | + { |
|
345 | + $value = $name['default']; |
|
346 | + } |
|
332 | 347 | |
333 | 348 | if (isset($name['allowed']) && !in_array($value,$name['allowed'])) |
334 | 349 | { |