Completed
Push — 14.2 ( e07840...cec2da )
by Ralf
83:18 queued 52:04
created
setup/inc/class.setup_cmd_database.inc.php 3 patches
Braces   +17 added lines, -4 removed lines patch added patch discarded remove patch
@@ -91,7 +91,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Doc Comments   +9 added lines, -15 removed lines patch added patch discarded remove patch
@@ -39,16 +39,14 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @param string/array $domain domain-name to customize the defaults or array with all parameters
41 41
 	 * @param string $db_type db-type (mysql, pgsql, ...)
42
-	 * @param string $db_host=null
43
-	 * @param string $db_port=null
44
-	 * @param string $db_name=null
45
-	 * @param string $db_user=null
46
-	 * @param string $db_pass=null
47
-	 * @param string $db_root=null
48
-	 * @param string $db_root_pw=null
49
-	 * @param string $sub_command='create_db' 'create_db', 'test_db', 'test_db_root'
50
-	 * @param string $db_grant_host='localhost' host/ip of webserver for grant
51
-	 * @param boolean $make_db_name_unique=false true: if create fails because db exists,
42
+	 * @param string $db_host
43
+	 * @param string $db_port
44
+	 * @param string $db_name
45
+	 * @param string $db_user
46
+	 * @param string $db_pass
47
+	 * @param string $db_root
48
+	 * @param string $db_root_pw
49
+	 * @param boolean $make_db_name_unique true: if create fails because db exists,
52 50
 	 * 	try creating a unique name by shortening the name and adding a number to it
53 51
 	 */
54 52
 	function __construct($domain,$db_type=null,$db_host=null,$db_port=null,$db_name=null,$db_user=null,$db_pass=null,
@@ -78,7 +76,7 @@  discard block
 block discarded – undo
78 76
 	/**
79 77
 	 * run the command: test or create database
80 78
 	 *
81
-	 * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
79
+	 * @param boolean $check_only only run the checks (and throw the exceptions), but not the command itself
82 80
 	 * @return string success message
83 81
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
84 82
 	 * @throws Exception('header.inc.php not found!');
@@ -127,9 +125,6 @@  discard block
 block discarded – undo
127 125
 	/**
128 126
 	 * Connect to database
129 127
 	 *
130
-	 * @param string $user=null default $this->db_user
131
-	 * @param string $pass=null default $this->db_pass
132
-	 * @param string $name=null default $this->db_name
133 128
 	 * @throws egw_exception_wrong_userinput Can not connect to database ...
134 129
 	 */
135 130
 	private function connect($user=null,$pass=null,$name=null)
@@ -267,7 +262,6 @@  discard block
 block discarded – undo
267 262
 	/**
268 263
 	 * Return default database settings for a given domain
269 264
 	 *
270
-	 * @param string $db_type='mysql'
271 265
 	 * @return array
272 266
 	 */
273 267
 	static function defaults($db_type='mysqli')
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 * @param boolean $make_db_name_unique=false true: if create fails because db exists,
52 52
 	 * 	try creating a unique name by shortening the name and adding a number to it
53 53
 	 */
54
-	function __construct($domain,$db_type=null,$db_host=null,$db_port=null,$db_name=null,$db_user=null,$db_pass=null,
55
-		$db_root=null,$db_root_pw=null,$sub_command='create_db',$db_grant_host='localhost',$make_db_name_unique=false)
54
+	function __construct($domain, $db_type = null, $db_host = null, $db_port = null, $db_name = null, $db_user = null, $db_pass = null,
55
+		$db_root = null, $db_root_pw = null, $sub_command = 'create_db', $db_grant_host = 'localhost', $make_db_name_unique = false)
56 56
 	{
57 57
 		if (!is_array($domain))
58 58
 		{
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
84 84
 	 * @throws Exception('header.inc.php not found!');
85 85
 	 */
86
-	protected function exec($check_only=false)
86
+	protected function exec($check_only = false)
87 87
 	{
88
-		if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i',$this->domain))
88
+		if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i', $this->domain))
89 89
 		{
90
-			throw new egw_exception_wrong_userinput(lang("'%1' is no valid domain name!",$this->domain));
90
+			throw new egw_exception_wrong_userinput(lang("'%1' is no valid domain name!", $this->domain));
91 91
 		}
92
-		if ($this->remote_id && $check_only) return true;	// further checks can only done locally
92
+		if ($this->remote_id && $check_only) return true; // further checks can only done locally
93 93
 
94 94
 		$this->_merge_defaults();
95 95
 		//_debug_array($this->as_array());
96 96
 
97 97
 		try {
98
-			switch($this->sub_command)
98
+			switch ($this->sub_command)
99 99
 			{
100 100
 				case 'test_db_root':
101
-					$msg = $this->connect($this->db_root,$this->db_root_pw,$this->db_meta);
101
+					$msg = $this->connect($this->db_root, $this->db_root_pw, $this->db_meta);
102 102
 					break;
103 103
 				case 'test_db':
104 104
 					$msg = $this->connect();
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param string $name=null default $this->db_name
133 133
 	 * @throws egw_exception_wrong_userinput Can not connect to database ...
134 134
 	 */
135
-	private function connect($user=null,$pass=null,$name=null)
135
+	private function connect($user = null, $pass = null, $name = null)
136 136
 	{
137 137
 		if (is_null($user)) $user = $this->db_user;
138 138
 		if (is_null($pass)) $pass = $this->db_pass;
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 		$this->test_db = new egw_db();
142 142
 
143 143
 		$error_rep = error_reporting();
144
-		error_reporting($error_rep & ~E_WARNING);	// switch warnings of, in case they are on
144
+		error_reporting($error_rep&~E_WARNING); // switch warnings of, in case they are on
145 145
 		try {
146
-			$this->test_db->connect($name,$this->db_host,$this->db_port,$user,$pass,$this->db_type);
146
+			$this->test_db->connect($name, $this->db_host, $this->db_port, $user, $pass, $this->db_type);
147 147
 		}
148 148
 		catch (Exception $e) {
149 149
 			// just give a nicer error, after switching error_reporting on again
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 		if ($e)
154 154
 		{
155 155
 			throw new egw_exception_wrong_userinput(lang('Can not connect to %1 database %2 on host %3 using user %4!',
156
-				$this->db_type,$name,$this->db_host.($this->db_port?':'.$this->db_port:''),$user).' ('.$e->getMessage().')');
156
+				$this->db_type, $name, $this->db_host.($this->db_port ? ':'.$this->db_port : ''), $user).' ('.$e->getMessage().')');
157 157
 		}
158 158
 		return lang('Successful connected to %1 database %2 on %3 using user %4.',
159
-				$this->db_type,$name,$this->db_host.($this->db_port?':'.$this->db_port:''),$user);
159
+				$this->db_type, $name, $this->db_host.($this->db_port ? ':'.$this->db_port : ''), $user);
160 160
 	}
161 161
 
162 162
 	/**
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	private function create()
174 174
 	{
175
-		static $try_make_unique = 0;	// to limit trials to create a unique name
175
+		static $try_make_unique = 0; // to limit trials to create a unique name
176 176
 
177 177
 		// shorten db-name/-user to self::MAX_DB_NAME_LEN chars
178 178
 		if ($this->make_db_name_unique && strlen($this->db_name) > self::MAX_DB_NAME_LEN)
179 179
 		{
180 180
 			$this->set_defaults['db_name'] = $this->db_name =
181 181
 			$this->set_defaults['db_user'] = $this->db_user = // change user too (otherwise existing user/db could not connect any more!)
182
-				substr(str_replace(array('.', '-'), '_', $this->db_name),0,self::MAX_DB_NAME_LEN);
182
+				substr(str_replace(array('.', '-'), '_', $this->db_name), 0, self::MAX_DB_NAME_LEN);
183 183
 		}
184 184
 		try {
185 185
 			$msg = $this->connect();
@@ -187,21 +187,21 @@  discard block
 block discarded – undo
187 187
 		catch (egw_exception_wrong_userinput $e) {
188 188
 			// db or user not working --> connect as root and create it
189 189
 			try {
190
-				$this->test_db->create_database($this->db_root,$this->db_root_pw,$this->db_charset,$this->db_grant_host);
190
+				$this->test_db->create_database($this->db_root, $this->db_root_pw, $this->db_charset, $this->db_grant_host);
191 191
 				$this->connect();
192 192
 			}
193
-			catch(egw_exception_db $e) {	// catches failed to create database
193
+			catch (egw_exception_db $e) {	// catches failed to create database
194 194
 				// try connect as root to check if wrong root/root_pw is the problem
195
-				$this->connect($this->db_root,$this->db_root_pw,$this->db_meta);
195
+				$this->connect($this->db_root, $this->db_root_pw, $this->db_meta);
196 196
 
197 197
 				// if we should create a db with a unique name (try it only N times, not endless!)
198 198
 				if ($this->make_db_name_unique && $try_make_unique++ < 20)
199 199
 				{
200 200
 					// check if we can connect as root to the db to create --> db exists already
201 201
 					try {
202
-						$this->connect($this->db_root,$this->db_root_pw);
202
+						$this->connect($this->db_root, $this->db_root_pw);
203 203
 						// create new db_name by incrementing an existing numeric postfix
204
-						if (preg_match('/([0-9]+)$/',$this->db_name,$matches))
204
+						if (preg_match('/([0-9]+)$/', $this->db_name, $matches))
205 205
 						{
206 206
 							$num = (string)(++$matches[1]);
207 207
 						}
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 						}
212 212
 						$this->set_defaults['db_name'] = $this->db_name =
213 213
 						$this->set_defaults['db_user'] = $this->db_user = // change user too (otherwise existing user/db could not connect any more!)
214
-							substr($this->db_name,0,self::MAX_DB_NAME_LEN-strlen($num)).$num;
214
+							substr($this->db_name, 0, self::MAX_DB_NAME_LEN - strlen($num)).$num;
215 215
 
216 216
 						return $this->create();
217 217
 					}
@@ -222,21 +222,21 @@  discard block
 block discarded – undo
222 222
 				}
223 223
 				// if not give general error
224 224
 				throw new egw_exception_wrong_userinput(lang('Can not create %1 database %2 on %3 for user %4!',
225
-					$this->db_type,$this->db_name,$this->db_host.($this->db_port?':'.$this->db_port:''),$this->db_user));
225
+					$this->db_type, $this->db_name, $this->db_host.($this->db_port ? ':'.$this->db_port : ''), $this->db_user));
226 226
 			}
227 227
 			$msg = lang('Successful connected to %1 on %3 and created database %2 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
 		// check if it already contains tables
231 231
 		if (($tables = $this->test_db->table_names()))
232 232
 		{
233
-			foreach($tables as &$table)
233
+			foreach ($tables as &$table)
234 234
 			{
235 235
 				$table = $table['table_name'];
236 236
 			}
237 237
 			throw new egw_exception_wrong_userinput(lang('%1 database %2 on %3 already contains the following tables:',
238
-				$this->db_type,$this->db_name,$this->db_host.($this->db_port?':'.$this->db_port:'')).' '.
239
-				implode(', ',$tables));
238
+				$this->db_type, $this->db_name, $this->db_host.($this->db_port ? ':'.$this->db_port : '')).' '.
239
+				implode(', ', $tables));
240 240
 		}
241 241
 		return $msg;
242 242
 	}
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	private function drop()
252 252
 	{
253
-		$this->connect($this->db_root,$this->db_root_pw,$this->db_meta);
254
-		$this->test_db->query('DROP DATABASE '.$this->test_db->name_quote($this->db_name),__LINE__,__FILE__);
255
-		$msg = lang('Datebase %1 droped.',$this->db_name);
253
+		$this->connect($this->db_root, $this->db_root_pw, $this->db_meta);
254
+		$this->test_db->query('DROP DATABASE '.$this->test_db->name_quote($this->db_name), __LINE__, __FILE__);
255
+		$msg = lang('Datebase %1 droped.', $this->db_name);
256 256
 		try {
257 257
 			$this->test_db->query('DROP USER '.$this->test_db->quote($this->db_user).'@'.
258
-				$this->test_db->quote($this->db_grant_host?$this->db_grant_host:'%'),__LINE__,__FILE__);
258
+				$this->test_db->quote($this->db_grant_host ? $this->db_grant_host : '%'), __LINE__, __FILE__);
259 259
 		}
260 260
 		catch (egw_db_exception $e) {
261 261
 			// we make this no fatal error, as the granthost might be something else ...
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 	 * @param string $db_type='mysql'
271 271
 	 * @return array
272 272
 	 */
273
-	static function defaults($db_type='mysqli')
273
+	static function defaults($db_type = 'mysqli')
274 274
 	{
275
-		switch($db_type)
275
+		switch ($db_type)
276 276
 		{
277 277
 			case 'mysql':
278 278
 			default:
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			'db_user' => 'egw_$domain',
291 291
 			'db_pass' => self::randomstring(),
292 292
 			'db_root' => 'root',
293
-			'db_root_pw' => '',	// not really a default
293
+			'db_root_pw' => '', // not really a default
294 294
 			'db_meta' => $meta_db,
295 295
 			'db_charset' => 'utf-8',
296 296
 			'db_grant_host' => 'localhost',
@@ -302,19 +302,19 @@  discard block
 block discarded – undo
302 302
 	 */
303 303
 	private function _merge_defaults()
304 304
 	{
305
-		foreach(self::defaults() as $name => $default)
305
+		foreach (self::defaults() as $name => $default)
306 306
 		{
307 307
 			if (!$this->$name)
308 308
 			{
309 309
 				//echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n";
310 310
 				$this->set_defaults[$name] = $this->$name = $default;
311 311
 			}
312
-			if (strpos($this->$name,'$domain') !== false)
312
+			if (strpos($this->$name, '$domain') !== false)
313 313
 			{
314 314
 				// limit names to 16 chars (16 char is user-name limit in MySQL)
315 315
 				$this->set_defaults[$name] = $this->$name =
316
-					substr(str_replace(array('$domain','.','-'),array($this->domain,'_','_'),$this->$name),
317
-					0,self::MAX_DB_NAME_LEN);
316
+					substr(str_replace(array('$domain', '.', '-'), array($this->domain, '_', '_'), $this->$name),
317
+					0, self::MAX_DB_NAME_LEN);
318 318
 			}
319 319
 		}
320 320
 	}
Please login to merge, or discard this patch.
setup/inc/class.setup_cmd_admin.inc.php 3 patches
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,8 +76,14 @@
 block discarded – undo
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(
Please login to merge, or discard this patch.
Doc Comments   +8 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,15 +26,13 @@  discard block
 block discarded – undo
26 26
 	 * Constructor
27 27
 	 *
28 28
 	 * @param string|array $domain domain-name or array with all parameters
29
-	 * @param string $config_user=null user to config the domain (or header_admin_user)
30
-	 * @param string $config_passwd=null pw of above user
31
-	 * @param string $admin_user=null
32
-	 * @param string $admin_password=null
33
-	 * @param string $admin_firstname=null
34
-	 * @param string $admin_lastname=null
35
-	 * @param string $admin_email=null
36
-	 * @param array $config=array() extra config for the account object: account_repository, ldap_*
37
-	 * @param string $lang='en'
29
+	 * @param string $config_user user to config the domain (or header_admin_user)
30
+	 * @param string $config_passwd pw of above user
31
+	 * @param string $admin_user
32
+	 * @param string $admin_password
33
+	 * @param string $admin_firstname
34
+	 * @param string $admin_lastname
35
+	 * @param string $admin_email
38 36
 	 */
39 37
 	function __construct($domain,$config_user=null,$config_passwd=null,$admin_user=null,$admin_password=null,
40 38
 		$admin_firstname=null,$admin_lastname=null,$admin_email=null,array $config=array(),$lang='en')
@@ -61,7 +59,7 @@  discard block
 block discarded – undo
61 59
 	/**
62 60
 	 * run the command: create eGW admin and standard groups
63 61
 	 *
64
-	 * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
62
+	 * @param boolean $check_only only run the checks (and throw the exceptions), but not the command itself
65 63
 	 * @return string success message
66 64
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
67 65
 	 * @throws Exception('header.inc.php not found!');
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 	 * @param array $config=array() extra config for the account object: account_repository, ldap_*
37 37
 	 * @param string $lang='en'
38 38
 	 */
39
-	function __construct($domain,$config_user=null,$config_passwd=null,$admin_user=null,$admin_password=null,
40
-		$admin_firstname=null,$admin_lastname=null,$admin_email=null,array $config=array(),$lang='en')
39
+	function __construct($domain, $config_user = null, $config_passwd = null, $admin_user = null, $admin_password = null,
40
+		$admin_firstname = null, $admin_lastname = null, $admin_email = null, array $config = array(), $lang = 'en')
41 41
 	{
42 42
 		if (!is_array($domain))
43 43
 		{
@@ -66,21 +66,21 @@  discard block
 block discarded – undo
66 66
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
67 67
 	 * @throws Exception('header.inc.php not found!');
68 68
 	 */
69
-	protected function exec($check_only=false)
69
+	protected function exec($check_only = false)
70 70
 	{
71 71
 		if ($check_only && $this->remote_id)
72 72
 		{
73
-			return true;	// can only check locally
73
+			return true; // can only check locally
74 74
 		}
75
-		$this->check_installed($this->domain,15);
75
+		$this->check_installed($this->domain, 15);
76 76
 
77 77
 		if (!$this->admin_firstname) $this->set_defaults['admin_firstname'] = $this->admin_firstname = lang('Admin');
78 78
 		if (!$this->admin_lastname) $this->set_defaults['admin_lastname'] = $this->admin_lastname = lang('User');
79
-		if (strpos($this->admin_email,'$') !== false)
79
+		if (strpos($this->admin_email, '$') !== false)
80 80
 		{
81 81
 			$this->set_defaults['email'] = $this->admin_email = str_replace(
82
-				array('$domain','$uid','$account_lid'),
83
-				array($this->domain,$this->admin_user,$this->admin_user),$this->admin_email);
82
+				array('$domain', '$uid', '$account_lid'),
83
+				array($this->domain, $this->admin_user, $this->admin_user), $this->admin_email);
84 84
 		}
85 85
 		$_POST['username'] = $this->admin_user;
86 86
 		$_POST['passwd2']  = $_POST['passwd'] = $this->admin_password;
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 		switch ($error)
98 98
 		{
99 99
 			case 41:
100
-				throw new egw_exception_wrong_userinput(lang('Error in admin-creation !!!'),41);
100
+				throw new egw_exception_wrong_userinput(lang('Error in admin-creation !!!'), 41);
101 101
 			case 42:
102
-				throw new egw_exception_wrong_userinput(lang('Error in group-creation !!!'),42);
102
+				throw new egw_exception_wrong_userinput(lang('Error in group-creation !!!'), 42);
103 103
 		}
104 104
 		$this->restore_db();
105 105
 
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 			escapeshellarg($this->admin_user.'@'.$this->domain.','.$this->admin_password.','.$this->admin_user);
110 110
 		if (php_sapi_name() !== 'cli' || !file_exists(EGW_SERVER_ROOT.'/stylite') || file_exists(EGW_SERVER_ROOT.'/managementserver'))
111 111
 		{
112
-			exec($cmd,$output,$ret);
112
+			exec($cmd, $output, $ret);
113 113
 		}
114
-		$output = implode("\n",$output);
114
+		$output = implode("\n", $output);
115 115
 		//echo "ret=$ret\n".$output;
116 116
 		if ($ret)
117 117
 		{
118
-			throw new egw_exception ($output,$ret);
118
+			throw new egw_exception($output, $ret);
119 119
 		}
120 120
 		return lang('Admin account successful created.');
121 121
 	}
Please login to merge, or discard this patch.
setup/inc/class.setup_cmd.inc.php 3 patches
Braces   +48 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,14 +32,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	/**
86 86
 	 * Saving the object to the database, reimplemented to not do it in setup context
87 87
 	 *
88
-	 * @param boolean $set_modifier=true set the current user as modifier or 0 (= run by the system)
88
+	 * @param boolean $set_modifier set the current user as modifier or 0 (= run by the system)
89 89
 	 * @return boolean true on success, false otherwise
90 90
 	 */
91 91
 	function save($set_modifier=true)
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @param string $user
174 174
 	 * @param string $pw
175
-	 * @param string $domain=null if given we also check agains config user/pw
175
+	 * @param string $domain if given we also check agains config user/pw
176 176
 	 * @throws egw_exception_no_permission(lang('Access denied: wrong username or password for manage-header !!!'),21);
177 177
 	 * @throws egw_exception_no_permission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40);
178 178
 	 */
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 * Sets self::$apps_to_update and self::$apps_to_install for the last/only domain only!
221 221
 	 *
222 222
 	 * @param string $domain='' domain to check, default '' = all
223
-	 * @param int/array $stop=0 stop checks before given exit-code(s), default 0 = all checks
224
-	 * @param boolean $verbose=false echo messages as they happen, instead returning them
223
+	 * @param int/array $stop stop checks before given exit-code(s), default 0 = all checks
224
+	 * @param boolean $verbose echo messages as they happen, instead returning them
225 225
 	 * @return array with translated messages
226 226
 	 */
227 227
 	static function check_installed($domain='',$stop=0,$verbose=false)
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		if (!$this->header_secret && $this->header_admin_user)	// no secret specified but header_admin_user/password
33 33
 		{
34 34
 			if (!$this->uid) $this->uid = true;
35
-			$this->set_header_secret($this->header_admin_user,$this->header_admin_password);
35
+			$this->set_header_secret($this->header_admin_user, $this->header_admin_password);
36 36
 		}
37 37
 		$secret = $this->_calc_header_secret($GLOBALS['egw_info']['server']['header_admin_user'],
38 38
 				$GLOBALS['egw_info']['server']['header_admin_password']);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		if ($this->header_secret != $secret)
42 42
 		{
43 43
 			//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";
44
-			throw new egw_exception_no_permission(lang('Wrong credentials to access the header.inc.php file!'),5);
44
+			throw new egw_exception_no_permission(lang('Wrong credentials to access the header.inc.php file!'), 5);
45 45
 		}
46 46
 
47 47
 	}
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 	 * @param string $user
53 53
 	 * @param string $pw password or md5 hash of it
54 54
 	 */
55
-	public function set_header_secret($user,$pw)
55
+	public function set_header_secret($user, $pw)
56 56
 	{
57 57
 		if ($this->uid || parent::save(false))	// we need to save first, to get the uid
58 58
 		{
59
-			$this->header_secret = $this->_calc_header_secret($user,$pw);
59
+			$this->header_secret = $this->_calc_header_secret($user, $pw);
60 60
 		}
61 61
 		else
62 62
 		{
63
-			throw new Exception ('failed to set header_secret!');
63
+			throw new Exception('failed to set header_secret!');
64 64
 		}
65 65
 	}
66 66
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param string $header_admin_password
74 74
 	 * @return string
75 75
 	 */
76
-	private function _calc_header_secret($header_admin_user=null,$header_admin_password=null)
76
+	private function _calc_header_secret($header_admin_user = null, $header_admin_password = null)
77 77
 	{
78 78
 		if (!self::is_md5($header_admin_password)) $header_admin_password = md5($header_admin_password);
79 79
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @param boolean $set_modifier=true set the current user as modifier or 0 (= run by the system)
89 89
 	 * @return boolean true on success, false otherwise
90 90
 	 */
91
-	function save($set_modifier=true)
91
+	function save($set_modifier = true)
92 92
 	{
93 93
 		if (isset($GLOBALS['egw']->db) && is_object($GLOBALS['egw']->db) && $GLOBALS['egw']->db->Database)
94 94
 		{
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * Create the setup enviroment (for running within setup or eGW)
111 111
 	 */
112
-	static protected function _setup_enviroment($domain=null)
112
+	static protected function _setup_enviroment($domain = null)
113 113
 	{
114 114
 		if (!is_object($GLOBALS['egw_setup']))
115 115
 		{
116 116
 			require_once(EGW_INCLUDE_ROOT.'/setup/inc/class.setup.inc.php');
117
-			$GLOBALS['egw_setup'] = new setup(true,true);
117
+			$GLOBALS['egw_setup'] = new setup(true, true);
118 118
 		}
119 119
 		self::$egw_setup = $GLOBALS['egw_setup'];
120 120
 		self::$egw_setup->ConfigDomain = $domain;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 			is_object($GLOBALS['egw']) && $GLOBALS['egw'] instanceof egw)
124 124
 		{
125 125
 			// we run inside eGW, not setup --> read egw_domain array from the header via the showheader cmd
126
-			$cmd = new setup_cmd_showheader(null);	// null = only header, no db stuff, no hashes
126
+			$cmd = new setup_cmd_showheader(null); // null = only header, no db stuff, no hashes
127 127
 			$header = $cmd->run();
128 128
 			$GLOBALS['egw_domain'] = $header['egw_domain'];
129 129
 
@@ -176,26 +176,26 @@  discard block
 block discarded – undo
176 176
 	 * @throws egw_exception_no_permission(lang('Access denied: wrong username or password for manage-header !!!'),21);
177 177
 	 * @throws egw_exception_no_permission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40);
178 178
 	 */
179
-	static function check_setup_auth($user,$pw,$domain=null)
179
+	static function check_setup_auth($user, $pw, $domain = null)
180 180
 	{
181 181
 		self::_setup_enviroment($domain);
182 182
 
183 183
 		// check the authentication if a header_admin_password is set, if not we dont have a header yet and no authentication
184 184
 		if ($GLOBALS['egw_info']['server']['header_admin_password'])	// if that's not given we dont have a header yet
185 185
 		{
186
-			if (!self::$egw_setup->check_auth($user,$pw,$GLOBALS['egw_info']['server']['header_admin_user'],
186
+			if (!self::$egw_setup->check_auth($user, $pw, $GLOBALS['egw_info']['server']['header_admin_user'],
187 187
 					$GLOBALS['egw_info']['server']['header_admin_password']) &&
188 188
 				(is_null($domain) || !isset($GLOBALS['egw_domain'][$domain]) || // if valid domain given check it's config user/pw
189
-					!self::$egw_setup->check_auth($user,$pw,$GLOBALS['egw_domain'][$domain]['config_user'],
189
+					!self::$egw_setup->check_auth($user, $pw, $GLOBALS['egw_domain'][$domain]['config_user'],
190 190
 						$GLOBALS['egw_domain'][$domain]['config_passwd'])))
191 191
 			{
192 192
 				if (is_null($domain))
193 193
 				{
194
-					throw new egw_exception_no_permission(lang('Access denied: wrong username or password for manage-header !!!'),21);
194
+					throw new egw_exception_no_permission(lang('Access denied: wrong username or password for manage-header !!!'), 21);
195 195
 				}
196 196
 				else
197 197
 				{
198
-					throw new egw_exception_no_permission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40);
198
+					throw new egw_exception_no_permission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!", $domain, $GLOBALS['egw_domain'][$domain]['db_type']), 40);
199 199
 				}
200 200
 			}
201 201
 		}
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @var array
208 208
 	 */
209
-	static public $apps_to_install=array();
209
+	static public $apps_to_install = array();
210 210
 	/**
211 211
 	 * Applications which are currently need update (set after call to check_installed, for the last/only domain only)
212 212
 	 *
213 213
 	 * @var array
214 214
 	 */
215
-	static public $apps_to_upgrade=array();
215
+	static public $apps_to_upgrade = array();
216 216
 
217 217
 	/**
218 218
 	 * Check if eGW is installed, which versions and if an update is needed
@@ -224,66 +224,66 @@  discard block
 block discarded – undo
224 224
 	 * @param boolean $verbose=false echo messages as they happen, instead returning them
225 225
 	 * @return array with translated messages
226 226
 	 */
227
-	static function check_installed($domain='',$stop=0,$verbose=false)
227
+	static function check_installed($domain = '', $stop = 0, $verbose = false)
228 228
 	{
229 229
 		self::_setup_enviroment($domain);
230 230
 
231 231
 		global $setup_info;
232
-		static $header_checks=true;	// output the header checks only once
232
+		static $header_checks = true; // output the header checks only once
233 233
 
234 234
 		$messages = array();
235 235
 
236 236
 		if ($stop && !is_array($stop)) $stop = array($stop);
237 237
 
238
-		$versions =& $GLOBALS['egw_info']['server']['versions'];
238
+		$versions = & $GLOBALS['egw_info']['server']['versions'];
239 239
 
240 240
 		if (!$versions['phpgwapi'])
241 241
 		{
242 242
 			if (!include(EGW_INCLUDE_ROOT.'/phpgwapi/setup/setup.inc.php'))
243 243
 			{
244
-				throw new egw_exception_wrong_userinput(lang("eGroupWare sources in '%1' are not complete, file '%2' missing !!!",realpath('..'),'phpgwapi/setup/setup.inc.php'),99);	// should not happen ;-)
244
+				throw new egw_exception_wrong_userinput(lang("eGroupWare sources in '%1' are not complete, file '%2' missing !!!", realpath('..'), 'phpgwapi/setup/setup.inc.php'), 99); // should not happen ;-)
245 245
 			}
246 246
 			$versions['phpgwapi'] = $setup_info['phpgwapi']['version'];
247 247
 			unset($setup_info);
248 248
 		}
249 249
 		if ($header_checks)
250 250
 		{
251
-			$messages[] = self::_echo_message($verbose,lang('eGroupWare API version %1 found.',$versions['phpgwapi']));
251
+			$messages[] = self::_echo_message($verbose, lang('eGroupWare API version %1 found.', $versions['phpgwapi']));
252 252
 		}
253 253
 		$header_stage = self::$egw_setup->detection->check_header();
254
-		if ($stop && in_array($header_stage,$stop)) return true;
254
+		if ($stop && in_array($header_stage, $stop)) return true;
255 255
 
256 256
 		switch ($header_stage)
257 257
 		{
258
-			case 1: throw new egw_exception_wrong_userinput(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);
258
+			case 1: throw new egw_exception_wrong_userinput(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);
259 259
 
260 260
 //			case 2: throw new egw_exception_wrong_userinput(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);
261 261
 
262
-			case 3: throw new egw_exception_wrong_userinput(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);
262
+			case 3: throw new egw_exception_wrong_userinput(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);
263 263
 
264
-			case 4: throw new egw_exception_wrong_userinput(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);
264
+			case 4: throw new egw_exception_wrong_userinput(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);
265 265
 		}
266 266
 		if ($header_checks)
267 267
 		{
268
-			$messages[] = self::_echo_message($verbose,lang('eGroupWare configuration file (header.inc.php) version %1 exists%2',
269
-				$versions['header'],' '.lang('and is up to date')));
268
+			$messages[] = self::_echo_message($verbose, lang('eGroupWare configuration file (header.inc.php) version %1 exists%2',
269
+				$versions['header'], ' '.lang('and is up to date')));
270 270
 		}
271
-		unset($header_checks);	// no further output of the header checks
271
+		unset($header_checks); // no further output of the header checks
272 272
 
273 273
 		$domains = $GLOBALS['egw_domain'];
274 274
 		if ($domain)	// domain to check given
275 275
 		{
276
-			if (!isset($GLOBALS['egw_domain'][$domain])) throw new egw_exception_wrong_userinput(lang("Domain '%1' does NOT exist !!!",$domain), 92);
276
+			if (!isset($GLOBALS['egw_domain'][$domain])) throw new egw_exception_wrong_userinput(lang("Domain '%1' does NOT exist !!!", $domain), 92);
277 277
 
278 278
 			$domains = array($domain => $GLOBALS['egw_domain'][$domain]);
279 279
 		}
280
-		foreach($domains as $domain => $data)
280
+		foreach ($domains as $domain => $data)
281 281
 		{
282
-			self::$egw_setup->ConfigDomain = $domain;	// set the domain the setup class operates on
282
+			self::$egw_setup->ConfigDomain = $domain; // set the domain the setup class operates on
283 283
 			if (count($GLOBALS['egw_domain']) > 1)
284 284
 			{
285 285
 				self::_echo_message($verbose);
286
-				$messages[] = self::_echo_message($verbose,lang('eGroupWare domain/instance %1(%2):',$domain,$data['db_type']));
286
+				$messages[] = self::_echo_message($verbose, lang('eGroupWare domain/instance %1(%2):', $domain, $data['db_type']));
287 287
 			}
288 288
 			$setup_info = self::$egw_setup->detection->get_versions();
289 289
 			// check if there's already a db-connection and close if, otherwise the db-connection of the previous domain will be used
@@ -295,27 +295,27 @@  discard block
 block discarded – undo
295 295
 
296 296
 			$db = $data['db_type'].'://'.$data['db_user'].':'.$data['db_pass'].'@'.$data['db_host'].'/'.$data['db_name'];
297 297
 
298
-			$db_stage =& $GLOBALS['egw_info']['setup']['stage']['db'];
298
+			$db_stage = & $GLOBALS['egw_info']['setup']['stage']['db'];
299 299
 			if (($db_stage = self::$egw_setup->detection->check_db($setup_info)) != 1)
300 300
 			{
301 301
 				$setup_info = self::$egw_setup->detection->get_db_versions($setup_info);
302 302
 				$db_stage = self::$egw_setup->detection->check_db($setup_info);
303 303
 			}
304
-			if ($stop && in_array(10+$db_stage,$stop))
304
+			if ($stop && in_array(10 + $db_stage, $stop))
305 305
 			{
306 306
 				return $messages;
307 307
 			}
308
-			switch($db_stage)
308
+			switch ($db_stage)
309 309
 			{
310
-				case 1: throw new egw_exception_wrong_userinput(lang('Your Database is not working!')." $db: ".self::$egw_setup->db->Error,11);
310
+				case 1: throw new egw_exception_wrong_userinput(lang('Your Database is not working!')." $db: ".self::$egw_setup->db->Error, 11);
311 311
 
312
-				case 3: throw new egw_exception_wrong_userinput(lang('Your database is working, but you dont have any applications installed')." ($db). ".lang("Use --install to install eGroupWare."),13);
312
+				case 3: throw new egw_exception_wrong_userinput(lang('Your database is working, but you dont have any applications installed')." ($db). ".lang("Use --install to install eGroupWare."), 13);
313 313
 
314
-				case 4: throw new egw_exception_wrong_userinput(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);
314
+				case 4: throw new egw_exception_wrong_userinput(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);
315 315
 
316 316
 				case 10:	// also check apps of updates
317 317
 					self::$apps_to_upgrade = self::$apps_to_install = array();
318
-					foreach($setup_info as $app => $data)
318
+					foreach ($setup_info as $app => $data)
319 319
 					{
320 320
 						if ($data['currentver'] && $data['version'] && $data['version'] != 'deleted' && $data['version'] != $data['currentver'])
321 321
 						{
@@ -329,23 +329,23 @@  discard block
 block discarded – undo
329 329
 					if (self::$apps_to_install)
330 330
 					{
331 331
 						self::_echo_message($verbose);
332
-						$messages[] = self::_echo_message($verbose,lang('The following applications are NOT installed:').' '.implode(', ',self::$apps_to_install));
332
+						$messages[] = self::_echo_message($verbose, lang('The following applications are NOT installed:').' '.implode(', ', self::$apps_to_install));
333 333
 					}
334 334
 					if (self::$apps_to_upgrade)
335 335
 					{
336 336
 						$db_stage = 4;
337
-						if ($stop && in_array(10+$db_stage,$stop)) return $messages;
337
+						if ($stop && in_array(10 + $db_stage, $stop)) return $messages;
338 338
 
339
-						throw new egw_exception_wrong_userinput(lang('The following applications need to be upgraded:').' '.implode(', ',self::$apps_to_upgrade).'! '.lang('Use --update to do so.'),14);
339
+						throw new egw_exception_wrong_userinput(lang('The following applications need to be upgraded:').' '.implode(', ', self::$apps_to_upgrade).'! '.lang('Use --update to do so.'), 14);
340 340
 					}
341 341
 					break;
342 342
 			}
343
-			$messages[] = self::_echo_message($verbose,lang("database is version %1 and up to date.",$setup_info['phpgwapi']['currentver']));
343
+			$messages[] = self::_echo_message($verbose, lang("database is version %1 and up to date.", $setup_info['phpgwapi']['currentver']));
344 344
 
345 345
 			self::$egw_setup->detection->check_config();
346
-			if ($GLOBALS['egw_info']['setup']['config_errors'] && $stop && !in_array(15,$stop))
346
+			if ($GLOBALS['egw_info']['setup']['config_errors'] && $stop && !in_array(15, $stop))
347 347
 			{
348
-				throw new egw_exception_wrong_userinput(lang('You need to configure eGroupWare:')."\n- ".@implode("\n- ",$GLOBALS['egw_info']['setup']['config_errors']),15);
348
+				throw new egw_exception_wrong_userinput(lang('You need to configure eGroupWare:')."\n- ".@implode("\n- ", $GLOBALS['egw_info']['setup']['config_errors']), 15);
349 349
 			}
350 350
 		}
351 351
 		return $messages;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 * @param string $msg
375 375
 	 * @return string $msg
376 376
 	 */
377
-	static function _echo_message($verbose,$msg='')
377
+	static function _echo_message($verbose, $msg = '')
378 378
 	{
379 379
 		if ($verbose) echo $msg."\n";
380 380
 
Please login to merge, or discard this patch.
setup/inc/functions.inc.php 2 patches
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,14 +30,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
  * @version $Id$
14 14
  */
15 15
 
16
-error_reporting(error_reporting() & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
16
+error_reporting(error_reporting()&~E_NOTICE&~E_STRICT&~E_DEPRECATED);
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
 block discarded – undo
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 . '/phpgwapi/inc/common_functions.inc.php');
53
+require_once(EGW_INCLUDE_ROOT.'/phpgwapi/inc/common_functions.inc.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.'/phpgwapi/setup/setup.inc.php'))
69
+if (file_exists(EGW_SERVER_ROOT.'/phpgwapi/setup/setup.inc.php'))
70 70
 {
71 71
 	include(EGW_SERVER_ROOT.'/phpgwapi/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
 block discarded – undo
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";
Please login to merge, or discard this patch.
setup/inc/hook_config_validate.inc.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -199,5 +199,8 @@
 block discarded – undo
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
+	}
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
  */
31 31
 function auth_type($settings)
32 32
 {
33
-	switch($settings['auth_type'])
33
+	switch ($settings['auth_type'])
34 34
 	{
35 35
 		case 'mail':
36 36
 			if (class_exists('Horde_Imap_Client_Socket') && !in_array($settings['mail_server_type'], array('pop', 'pops')))
37 37
 			{
38
-				return;	// we use Horde code instead of imap extension
38
+				return; // we use Horde code instead of imap extension
39 39
 			}
40 40
 			try {
41 41
 				check_load_extension('imap', true);
@@ -55,33 +55,33 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function vfs_storage_mode($settings)
57 57
 {
58
-	switch($settings['vfs_storage_mode'])
58
+	switch ($settings['vfs_storage_mode'])
59 59
 	{
60 60
 		case 'fs':
61
-			config::save_value('vfs_fstab','','phpgwapi');
61
+			config::save_value('vfs_fstab', '', 'phpgwapi');
62 62
 			break;
63 63
 		case 'db':
64 64
 			config::save_value('vfs_fstab', array(
65 65
 				'/' => 'sqlfs://$host/?storage=db',
66 66
 				'/apps' => 'links://$host/apps?storage=db',
67
-			),'phpgwapi');
67
+			), 'phpgwapi');
68 68
 			break;
69 69
 	}
70 70
 }
71 71
 
72 72
 function temp_dir($settings)
73 73
 {
74
-	if (!setup_detection::check_dir($settings['temp_dir'],$error_msg))
74
+	if (!setup_detection::check_dir($settings['temp_dir'], $error_msg))
75 75
 	{
76
-		$GLOBALS['config_error'] = lang("Your temporary directory '%1' %2",$settings['temp_dir'],$error_msg);
76
+		$GLOBALS['config_error'] = lang("Your temporary directory '%1' %2", $settings['temp_dir'], $error_msg);
77 77
 	}
78 78
 }
79 79
 
80 80
 function files_dir($settings)
81 81
 {
82
-	if (!setup_detection::check_dir($settings['files_dir'],$error_msg,true))
82
+	if (!setup_detection::check_dir($settings['files_dir'], $error_msg, true))
83 83
 	{
84
-		$GLOBALS['config_error'] = lang("Your files directory '%1' %2",$settings['files_dir'],$error_msg);
84
+		$GLOBALS['config_error'] = lang("Your files directory '%1' %2", $settings['files_dir'], $error_msg);
85 85
 	}
86 86
 }
87 87
 
@@ -91,20 +91,20 @@  discard block
 block discarded – undo
91 91
 	{
92 92
 		$settings['backup_dir'] = $settings['files_dir'].'/db_backup';
93 93
 	}
94
-	if (!setup_detection::check_dir($settings['backup_dir'],$error_msg,true))
94
+	if (!setup_detection::check_dir($settings['backup_dir'], $error_msg, true))
95 95
 	{
96
-		$GLOBALS['config_error'] = lang("Your backup directory '%1' %2",$settings['backup_dir'],$error_msg);
96
+		$GLOBALS['config_error'] = lang("Your backup directory '%1' %2", $settings['backup_dir'], $error_msg);
97 97
 	}
98 98
 }
99 99
 
100
-function _mcrypt_test_module_mode($module,$mode)
100
+function _mcrypt_test_module_mode($module, $mode)
101 101
 {
102 102
 	/* Data */
103 103
 	$key = 'this is a very long key, even too long for the cipher';
104 104
 	$plain_text = 'very important data';
105 105
 
106 106
 	/* Open module, and create IV */
107
-	if(!$GLOBALS['td'] = @mcrypt_module_open($module, '',$mode, ''))
107
+	if (!$GLOBALS['td'] = @mcrypt_module_open($module, '', $mode, ''))
108 108
 	{
109 109
 		@mcrypt_module_close($GLOBALS['td']);
110 110
 		return False;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	$iv = @mcrypt_create_iv($iv_size, MCRYPT_RAND);
115 115
 
116 116
 	/* Initialize encryption handle */
117
-	if(mcrypt_generic_init($GLOBALS['td'], $key, $iv) != -1)
117
+	if (mcrypt_generic_init($GLOBALS['td'], $key, $iv) != -1)
118 118
 	{
119 119
 		/* Encrypt data */
120 120
 		$c_t = mcrypt_generic($GLOBALS['td'], $plain_text);
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	$modes = mcrypt_list_modes();
149 149
 	$algorithms = mcrypt_list_algorithms();
150 150
 
151
-	foreach($algorithms as $cipher)
151
+	foreach ($algorithms as $cipher)
152 152
 	{
153
-		if(mcrypt_module_self_test($cipher))
153
+		if (mcrypt_module_self_test($cipher))
154 154
 		{
155 155
 			$GLOBALS['ciphers'][$cipher] = array();
156
-			foreach($modes as $mode)
156
+			foreach ($modes as $mode)
157 157
 			{
158
-				if(_mcrypt_test_module_mode($cipher,$mode))
158
+				if (_mcrypt_test_module_mode($cipher, $mode))
159 159
 				{
160 160
 					$result = True;
161 161
 				}
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 function mcrypt_algo($settings)
175 175
 {
176 176
 	/* _debug_array($settings);exit; */
177
-	if(@function_exists('mcrypt_list_modes'))
177
+	if (@function_exists('mcrypt_list_modes'))
178 178
 	{
179 179
 		mcrypt_check_sanity();
180
-		if(!@$GLOBALS['ciphers'][$settings['mcrypt_algo']][$settings['mcrypt_mode']])
180
+		if (!@$GLOBALS['ciphers'][$settings['mcrypt_algo']][$settings['mcrypt_mode']])
181 181
 		{
182 182
 			$GLOBALS['config_error'] = lang('Invalid Mcrypt Algorithm/Mode combination');
183 183
 		}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
  */
192 192
 function ldap_search_filter(&$settings)
193 193
 {
194
-	$filter =& $settings['ldap_search_filter'];
194
+	$filter = & $settings['ldap_search_filter'];
195 195
 
196 196
 	if ($filter && $filter{0} != '(') $filter = '('.$filter.')';
197 197
 }
Please login to merge, or discard this patch.
setup/inc/class.setup_cmd_config.inc.php 2 patches
Braces   +20 added lines, -5 removed lines patch added patch discarded remove patch
@@ -70,10 +70,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 			{
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param string $arguments =null array with command line argruments
30 30
 	 * @param boolean $verbose =false if true, echos out some status information during the run
31 31
 	 */
32
-	function __construct($domain,$config_user=null,$config_passwd=null,$arguments=null,$verbose=false)
32
+	function __construct($domain, $config_user = null, $config_passwd = null, $arguments = null, $verbose = false)
33 33
 	{
34 34
 		if (!is_array($domain))
35 35
 		{
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
 	 * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
54 54
 	 * @throws Exception('header.inc.php not found!');
55 55
 	 */
56
-	protected function exec($check_only=false)
56
+	protected function exec($check_only = false)
57 57
 	{
58 58
 		if ($check_only && $this->remote_id)
59 59
 		{
60
-			return true;	// can only check locally
60
+			return true; // can only check locally
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,15,$this->verbose);
65
+		$this->check_installed($this->domain, 15, $this->verbose);
66 66
 
67 67
 		// fixing authtypes in self::$options
68 68
 		self::auth_types(true);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		}
79 79
 
80 80
 		// store the config
81
-		foreach($values as $name => $value)
81
+		foreach ($values as $name => $value)
82 82
 		{
83 83
 			if (substr($name, 0, 4) == 'acc_') continue;
84 84
 
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 			{
88 88
 				list($app, $name) = explode('/', $name);
89 89
 			}
90
-			self::$egw_setup->db->insert(self::$egw_setup->config_table,array(
90
+			self::$egw_setup->db->insert(self::$egw_setup->config_table, array(
91 91
 				'config_value' => $value,
92
-			),array(
92
+			), array(
93 93
 				'config_app'  => $app,
94 94
 				'config_name' => $name,
95
-			),__LINE__,__FILE__);
95
+			), __LINE__, __FILE__);
96 96
 		}
97 97
 		if (count($values))
98 98
 		{
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
 	 * @param boolean $echoit =false if true the config is additionally echo'ed out
117 117
 	 * @return array with name => value pairs
118 118
 	 */
119
-	static function get_config($echoit=false)
119
+	static function get_config($echoit = false)
120 120
 	{
121
-		self::$egw_setup->db->select(self::$egw_setup->config_table,'config_name,config_value',array(
121
+		self::$egw_setup->db->select(self::$egw_setup->config_table, 'config_name,config_value', array(
122 122
 			'config_app'  => 'phpgwapi',
123 123
 			"(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'))",
124
-		),__LINE__,__FILE__);
124
+		), __LINE__, __FILE__);
125 125
 
126 126
 		$config = array();
127 127
 		while (($row = self::$egw_setup->db->row(true)))
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 		if ($echoit)
132 132
 		{
133 133
 			echo lang('Current configuration:')."\n";
134
-			foreach($config as $name => $value)
134
+			foreach ($config as $name => $value)
135 135
 			{
136
-				echo str_pad($name.':',22).$value."\n";
136
+				echo str_pad($name.':', 22).$value."\n";
137 137
 			}
138 138
 		}
139 139
 		return $config;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @var array
146 146
 	 */
147 147
 	static $options = array(
148
-		'--config'     => array(),	// name=value,...
148
+		'--config'     => array(), // name=value,...
149 149
 		'--files-dir'  => 'files_dir',
150 150
 		'--vfs-root-user' => 'vfs_root_user',
151 151
 		'--backup-dir' => 'backup_dir',
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 			'acc_imap_host',
157 157
 			'acc_imap_port',
158 158
 			'acc_domain',
159
-			array('name' => 'acc_imap_logintype','allowed'  => array(
159
+			array('name' => 'acc_imap_logintype', 'allowed'  => array(
160 160
 				'username (standard)' => 'standard',
161 161
 				'username@domain (virtual mail manager)' => 'vmailmgr',
162 162
 				'Username/Password defined by admin' => 'admin',
163 163
 				'userId@domain eg. u123@domain' => 'uidNumber',
164 164
 				'email (Standard Maildomain should be set)' => 'email',
165 165
 			)),
166
-			array('name' => 'acc_imap_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')),
166
+			array('name' => 'acc_imap_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')),
167 167
 		),
168 168
 		'--imap' => array(
169 169
 			'acc_imap_admin_username',
@@ -171,28 +171,28 @@  discard block
 block discarded – undo
171 171
 			'acc_imap_type',
172 172
 		),
173 173
 		'--folder' => array(
174
-			'acc_folder_sent','acc_folder_trash','acc_folder_draft','acc_folder_template','acc_folder_junk',
174
+			'acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk',
175 175
 		),
176 176
 		'--sieve' => array(
177 177
 			array('name' => 'acc_sieve_host'),
178 178
 			'acc_sieve_port',
179 179
 			'acc_sieve_enabled',
180
-			array('name' => 'acc_sieve_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')),
180
+			array('name' => 'acc_sieve_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')),
181 181
 		),
182 182
 		'--smtp' => array(
183
-			array('name' => 'editforwardingaddress','allowed' => array('yes',null)),
183
+			array('name' => 'editforwardingaddress', 'allowed' => array('yes', null)),
184 184
 			'acc_smtp_type',
185 185
 		),
186 186
 		'--smtpserver' => array(	//smtp server,[smtp port],[smtp user],[smtp password],[auth session user/pw],[no|starttls|ssl|tls],[user editable],[further identities]
187
-			'acc_smtp_host','acc_smtp_port','acc_smtp_username','acc_smtp_passwd','acc_smtp_auth_session',
188
-			array('name' => 'acc_smtp_ssl','allowed' => array(0,'no',1,'starttls',3,'ssl',2,'tls')),
189
-			'acc_user_editable','acc_further_identities',
187
+			'acc_smtp_host', 'acc_smtp_port', 'acc_smtp_username', 'acc_smtp_passwd', 'acc_smtp_auth_session',
188
+			array('name' => 'acc_smtp_ssl', 'allowed' => array(0, 'no', 1, 'starttls', 3, 'ssl', 2, 'tls')),
189
+			'acc_user_editable', 'acc_further_identities',
190 190
 		),
191 191
 		'--account-auth' => array(
192
-			array('name' => 'account_repository','allowed' => array('sql','ldap','ads'),'default'=>'sql'),
193
-			array('name' => 'auth_type','allowed' => array('sql','ldap','mail','ads','http','sqlssl','nis','pam'),'default'=>'sql'),
194
-			array('name' => 'sql_encryption','allowed' => array('blowfish_crypt','sha512_crypt','sha256_crypt','md5_crypt','crypt','ssha','smd5','md5'),'default'=>'blowfish_crypt'),
195
-			'check_save_password','allow_cookie_auth'),
192
+			array('name' => 'account_repository', 'allowed' => array('sql', 'ldap', 'ads'), 'default'=>'sql'),
193
+			array('name' => 'auth_type', 'allowed' => array('sql', 'ldap', 'mail', 'ads', 'http', 'sqlssl', 'nis', 'pam'), 'default'=>'sql'),
194
+			array('name' => 'sql_encryption', 'allowed' => array('blowfish_crypt', 'sha512_crypt', 'sha256_crypt', 'md5_crypt', 'crypt', 'ssha', 'smd5', 'md5'), 'default'=>'blowfish_crypt'),
195
+			'check_save_password', 'allow_cookie_auth'),
196 196
 		'--ldap-host' => 'ldap_host',
197 197
 		'--ldap-root-dn' => 'ldap_root_dn',
198 198
 		'--ldap-root-pw' => 'ldap_root_pw',
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		'--install-id' => 'install_id',
205 205
 		'--ads-host' => 'ads_host',
206 206
 		'--ads-domain' => 'ads_domain',
207
-		'--ads-admin-user' => 'ads_domain_admin',	// eg. Administrator
207
+		'--ads-admin-user' => 'ads_domain_admin', // eg. Administrator
208 208
 		'--ads-admin-pw' => 'ads_admin_pw',
209 209
 		'--ads-connection' => array(
210 210
 			array('name' => 'ads_connection', 'allowed' => array('ssl', 'tls'))
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 
251 251
 		$save_mail_account = false;
252 252
 		$values = array();
253
-		foreach(self::$options as $arg => $option)
253
+		foreach (self::$options as $arg => $option)
254 254
 		{
255
-			foreach(is_array($option) ? $option : array($option) as $n => $data)
255
+			foreach (is_array($option) ? $option : array($option) as $n => $data)
256 256
 			{
257 257
 				$name = is_array($data) ? $data['name'] : $data;
258 258
 				$oldname = array_key_exists($name, $this->old2new);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 				}
265 265
 				if (isset($this->$name))
266 266
 				{
267
-					$save_mail_account = $this->_parse_value($arg,$n,$option,$this->$name,$values) || $save_mail_account;
267
+					$save_mail_account = $this->_parse_value($arg, $n, $option, $this->$name, $values) || $save_mail_account;
268 268
 				}
269 269
 			}
270 270
 		}
@@ -282,27 +282,27 @@  discard block
 block discarded – undo
282 282
 		$values = array();
283 283
 		$save_mail_account = false;
284 284
 		$args = $this->arguments;
285
-		while(($arg = array_shift($args)))
285
+		while (($arg = array_shift($args)))
286 286
 		{
287 287
 			if (!isset(self::$options[$arg]))
288 288
 			{
289
-				throw new egw_exception_wrong_userinput(lang("Unknown option '%1' !!!",$arg),90);
289
+				throw new egw_exception_wrong_userinput(lang("Unknown option '%1' !!!", $arg), 90);
290 290
 			}
291
-			$options = is_array(self::$options[$arg]) ? explode(',',array_shift($args)) : array(array_shift($args));
291
+			$options = is_array(self::$options[$arg]) ? explode(',', array_shift($args)) : array(array_shift($args));
292 292
 
293 293
 			if ($arg == '--config' || $arg == '--setup_cmd_config')
294 294
 			{
295
-				foreach($options as $option)
295
+				foreach ($options as $option)
296 296
 				{
297
-					list($name,$value) = explode('=',$option,2);
297
+					list($name, $value) = explode('=', $option, 2);
298 298
 					$values[$name] = $value;
299 299
 				}
300 300
 				continue;
301 301
 			}
302 302
 			$options[] = ''; $options[] = '';
303
-			foreach($options as $n => $value)
303
+			foreach ($options as $n => $value)
304 304
 			{
305
-				$save_mail_account = $this->_parse_value($arg,$n,self::$options[$arg],$value,$values) || $save_mail_account;
305
+				$save_mail_account = $this->_parse_value($arg, $n, self::$options[$arg], $value, $values) || $save_mail_account;
306 306
 			}
307 307
 		}
308 308
 		return $save_mail_account;
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 * @param array &$values where the values get set
319 319
 	 * @return boolean true if mail-accounts needs to be saved, false if not
320 320
 	 */
321
-	private function _parse_value($arg,$n,$data,$value,array &$values)
321
+	private function _parse_value($arg, $n, $data, $value, array &$values)
322 322
 	{
323 323
 		if ($value === '' && is_array($data) && !isset($data[$n]['default'])) return false;
324 324
 
@@ -328,15 +328,15 @@  discard block
 block discarded – undo
328 328
 		{
329 329
 			if (!$value && isset($name['default'])) $value = $name['default'];
330 330
 
331
-			if (isset($name['allowed']) && !in_array($value,$name['allowed']))
331
+			if (isset($name['allowed']) && !in_array($value, $name['allowed']))
332 332
 			{
333
-				throw new egw_exception_wrong_userinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1+$n,$arg)." ($name[name])",91);
333
+				throw new egw_exception_wrong_userinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!", $value, 1 + $n, $arg)." ($name[name])", 91);
334 334
 			}
335 335
 			$name = $name['name'];
336 336
 		}
337 337
 		$values[$name] = $value;
338 338
 
339
-		return in_array($arg,array('--mailserver','--smtpserver','--imap','--smtp','--sieve','--folder'));
339
+		return in_array($arg, array('--mailserver', '--smtpserver', '--imap', '--smtp', '--sieve', '--folder'));
340 340
 	}
341 341
 
342 342
 	/**
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 	function _save_mail_account(array $data)
348 348
 	{
349 349
 		// convert ssl textual values to nummerical ones used in emailadmin_account
350
-		foreach(array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name)
350
+		foreach (array('acc_imap_ssl', 'acc_sieve_ssl', 'acc_smtp_ssl') as $name)
351 351
 		{
352
-			switch(strtolower($data[$name]))
352
+			switch (strtolower($data[$name]))
353 353
 			{
354 354
 				case 'no':       $data[$name] = emailadmin_account::SSL_NONE; break;
355 355
 				case 'starttls': $data[$name] = emailadmin_account::SSL_STARTTLS; break;
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
 			}
359 359
 		}
360 360
 		// convert 'yes', 'no' to boolean
361
-		foreach(array('acc_sieve_enabled','acc_user_editable','acc_further_identities','acc_smtp_auth_session') as $name)
361
+		foreach (array('acc_sieve_enabled', 'acc_user_editable', 'acc_further_identities', 'acc_smtp_auth_session') as $name)
362 362
 		{
363 363
 			$data[$name] = $data[$name] && strtolower($data[$name]) != 'no';
364 364
 		}
365 365
 		// do NOT write empty usernames
366
-		foreach(array('acc_imap_username', 'acc_smtp_username') as $name)
366
+		foreach (array('acc_imap_username', 'acc_smtp_username') as $name)
367 367
 		{
368 368
 			if (empty($data[$name]))
369 369
 			{
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
 		}
374 374
 
375 375
 		$data['acc_name'] = 'Created by setup';
376
-		$data['account_id'] = 0;	// 0 = valid for all users
376
+		$data['account_id'] = 0; // 0 = valid for all users
377 377
 
378 378
 		emailadmin_account::write($data);
379 379
 
380 380
 		if ($this->verbose)
381 381
 		{
382 382
 			echo "\n".lang('EMailAdmin mail account saved:')."\n";
383
-			foreach($data as $name => $value)
383
+			foreach ($data as $name => $value)
384 384
 			{
385
-				echo str_pad($name.':',22).$value."\n";
385
+				echo str_pad($name.':', 22).$value."\n";
386 386
 			}
387 387
 		}
388 388
 	}
@@ -395,11 +395,11 @@  discard block
 block discarded – undo
395 395
 	static function options()
396 396
 	{
397 397
 		$options = array();
398
-		foreach(self::$options as $option)
398
+		foreach (self::$options as $option)
399 399
 		{
400 400
 			if (is_array($option))
401 401
 			{
402
-				foreach($option as $data)
402
+				foreach ($option as $data)
403 403
 				{
404 404
 					if (is_array($data) && isset($data['allowed']))
405 405
 					{
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 								$options[$data['name']] = self::account_repositories();
413 413
 								continue 2;
414 414
 						}
415
-						foreach($data['allowed'] as $label => $value)
415
+						foreach ($data['allowed'] as $label => $value)
416 416
 						{
417 417
 							if (is_int($label))
418 418
 							{
419
-								$label = (string) $value === '' ? 'No' : strtoupper($value);
419
+								$label = (string)$value === '' ? 'No' : strtoupper($value);
420 420
 							}
421 421
 							$options[$data['name']][$value] = lang($label);
422 422
 						}
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		if (!$scan_done++)
450 450
 		{
451 451
 			// now add auth backends found in filesystem
452
-			foreach(scandir(EGW_INCLUDE_ROOT.'/phpgwapi/inc') as $class)
452
+			foreach (scandir(EGW_INCLUDE_ROOT.'/phpgwapi/inc') as $class)
453 453
 			{
454 454
 				$matches = null;
455 455
 				if (preg_match('/^class\.auth_([a-z]+)\.inc\.php$/', $class, $matches) &&
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 					$auth_types[$matches[1]] = ucfirst($matches[1]);
459 459
 				}
460 460
 			}
461
-			foreach(self::$options['--account-auth'] as &$param)
461
+			foreach (self::$options['--account-auth'] as &$param)
462 462
 			{
463 463
 				if ($param['name'] == 'auth_type')
464 464
 				{
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 * @param string $current =null current value, to allways return it
477 477
 	 * @return array
478 478
 	 */
479
-	static function account_repositories($current=null)
479
+	static function account_repositories($current = null)
480 480
 	{
481 481
 		static $account_repositories = array(
482 482
 			'sql' => 'SQL',
@@ -487,13 +487,13 @@  discard block
 block discarded – undo
487 487
 		if (!$scan_done++)
488 488
 		{
489 489
 			// now add auth backends found in filesystem
490
-			foreach(scandir(EGW_INCLUDE_ROOT.'/phpgwapi/inc') as $file)
490
+			foreach (scandir(EGW_INCLUDE_ROOT.'/phpgwapi/inc') as $file)
491 491
 			{
492 492
 				$matches = null;
493 493
 				if (preg_match('/^class\.accounts_([a-z]+)\.inc\.php$/', $file, $matches) &&
494 494
 					!isset($account_repositories[$matches[1]]) &&
495
-					class_exists($class='accounts_'.$matches[1]) &&
496
-					($matches[1] == $current || !is_callable($callable=$class.'::available') || call_user_func($callable)))
495
+					class_exists($class = 'accounts_'.$matches[1]) &&
496
+					($matches[1] == $current || !is_callable($callable = $class.'::available') || call_user_func($callable)))
497 497
 				{
498 498
 					$account_repositories[$matches[1]] = ucfirst($matches[1]);
499 499
 				}
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	{
512 512
 		$defaults = array();
513 513
 		// fetch the default from the cli options
514
-		foreach(self::$options as $option)
514
+		foreach (self::$options as $option)
515 515
 		{
516 516
 			if (is_array($option))
517 517
 			{
518
-				foreach($option as $data)
518
+				foreach ($option as $data)
519 519
 				{
520 520
 					if (is_array($data) && isset($data['default']))
521 521
 					{
@@ -543,20 +543,20 @@  discard block
 block discarded – undo
543 543
 	 */
544 544
 	private function _merge_defaults()
545 545
 	{
546
-		foreach(self::defaults() as $name => $default)
546
+		foreach (self::defaults() as $name => $default)
547 547
 		{
548 548
 			if (!$this->$name)
549 549
 			{
550 550
 				//echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n";
551 551
 				$this->set_defaults[$name] = $this->$name = $default;
552 552
 			}
553
-			if (strpos($this->$name,'$') !== false)
553
+			if (strpos($this->$name, '$') !== false)
554 554
 			{
555 555
 				$this->set_defaults[$name] = $this->$name = str_replace(array(
556 556
 					'$domain',
557
-				),array(
557
+				), array(
558 558
 					$this->domain,
559
-				),$this->$name);
559
+				), $this->$name);
560 560
 			}
561 561
 		}
562 562
 	}
Please login to merge, or discard this patch.
setup/inc/class.setup_html.inc.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -295,7 +295,10 @@
 block discarded – undo
295 295
 		if (empty($ConfigLang))
296 296
 		{
297 297
 			$ConfigLang = setup::get_lang();
298
-			if (empty($ConfigLang)) $ConfigLang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
298
+			if (empty($ConfigLang))
299
+			{
300
+				$ConfigLang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
301
+			}
299 302
 		}
300 303
 		return Api\Html::select('ConfigLang', $ConfigLang, Api\Translation::get_available_langs(false), true,
301 304
 			$onChange ? ' onchange="this.form.submit();"' : '');
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -26,54 +26,54 @@  discard block
 block discarded – undo
26 26
 		// variable names with underscores.
27 27
 
28 28
 		$GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template'));
29
-		$GLOBALS['header_template']->set_block('header','domain','domain');
29
+		$GLOBALS['header_template']->set_block('header', 'domain', 'domain');
30 30
 		$var = Array();
31 31
 
32
-		$deletedomain = get_var('deletedomain',Array('POST'));
33
-		$domains = get_var('domains',Array('POST'));
32
+		$deletedomain = get_var('deletedomain', Array('POST'));
33
+		$domains = get_var('domains', Array('POST'));
34 34
 
35
-		foreach($domains as $k => $v)
35
+		foreach ($domains as $k => $v)
36 36
 		{
37
-			if(is_array($deletedomain) && isset($deletedomain[$k]))
37
+			if (is_array($deletedomain) && isset($deletedomain[$k]))
38 38
 			{
39 39
 				continue;
40 40
 			}
41
-			$variableName = str_replace('.','_',$k);
42
-			$dom = get_var('setting_'.$variableName,Array('POST'));
43
-			$GLOBALS['header_template']->set_var('DB_DOMAIN',$v);
44
-			foreach($dom as $x => $y)
41
+			$variableName = str_replace('.', '_', $k);
42
+			$dom = get_var('setting_'.$variableName, Array('POST'));
43
+			$GLOBALS['header_template']->set_var('DB_DOMAIN', $v);
44
+			foreach ($dom as $x => $y)
45 45
 			{
46
-				if(strtoupper($x) == 'CONFIG_PASS')
46
+				if (strtoupper($x) == 'CONFIG_PASS')
47 47
 				{
48
-					$GLOBALS['header_template']->set_var(strtoupper($x),md5($y));
48
+					$GLOBALS['header_template']->set_var(strtoupper($x), md5($y));
49 49
 				}
50 50
 				else
51 51
 				{
52
-					$GLOBALS['header_template']->set_var(strtoupper($x),$y);
52
+					$GLOBALS['header_template']->set_var(strtoupper($x), $y);
53 53
 				}
54 54
 			}
55 55
 			/* Admin did not type a new password, so use the old one from the hidden field,
56 56
 			 * which is already md5 encoded.
57 57
 			 */
58
-			if($dom['config_password'] && !$dom['config_pass'])
58
+			if ($dom['config_password'] && !$dom['config_pass'])
59 59
 			{
60 60
 				/* Real == hidden */
61
-				$GLOBALS['header_template']->set_var('CONFIG_PASS',$dom['config_password']);
61
+				$GLOBALS['header_template']->set_var('CONFIG_PASS', $dom['config_password']);
62 62
 			}
63 63
 			/* If the admin didn't select a db_port, set to the default */
64
-			if(!$dom['db_port'])
64
+			if (!$dom['db_port'])
65 65
 			{
66
-				$GLOBALS['header_template']->set_var('DB_PORT',$GLOBALS['default_db_ports'][$dom['db_type']]);
66
+				$GLOBALS['header_template']->set_var('DB_PORT', $GLOBALS['default_db_ports'][$dom['db_type']]);
67 67
 			}
68
-			$GLOBALS['header_template']->parse('domains','domain',True);
68
+			$GLOBALS['header_template']->parse('domains', 'domain', True);
69 69
 		}
70 70
 
71
-		$GLOBALS['header_template']->set_var('domain','');
71
+		$GLOBALS['header_template']->set_var('domain', '');
72 72
 
73
-		$setting = get_var('setting',Array('POST'));
74
-		while($setting && list($k,$v) = @each($setting))
73
+		$setting = get_var('setting', Array('POST'));
74
+		while ($setting && list($k, $v) = @each($setting))
75 75
 		{
76
-			if(strtoupper($k) == 'HEADER_ADMIN_PASSWORD')
76
+			if (strtoupper($k) == 'HEADER_ADMIN_PASSWORD')
77 77
 			{
78 78
 				$var[strtoupper($k)] = md5($v);
79 79
 			}
@@ -85,38 +85,38 @@  discard block
 block discarded – undo
85 85
 		/* Admin did not type a new header password, so use the old one from the hidden field,
86 86
 		 * which is already md5 encoded.
87 87
 		 */
88
-		if($var['HEADER_ADMIN_PASS'] && empty($setting['HEADER_ADMIN_PASSWORD']))
88
+		if ($var['HEADER_ADMIN_PASS'] && empty($setting['HEADER_ADMIN_PASSWORD']))
89 89
 		{
90 90
 			/* Real == hidden */
91 91
 			$var['HEADER_ADMIN_PASSWORD'] = $var['HEADER_ADMIN_PASS'];
92 92
 		}
93 93
 		$GLOBALS['header_template']->set_var($var);
94
-		return $GLOBALS['header_template']->parse('out','header');
94
+		return $GLOBALS['header_template']->parse('out', 'header');
95 95
 	}
96 96
 
97
-	static function setup_tpl_dir($app_name='setup')
97
+	static function setup_tpl_dir($app_name = 'setup')
98 98
 	{
99 99
 		/* hack to get tpl dir */
100 100
 		if (is_dir(EGW_SERVER_ROOT))
101 101
 		{
102
-			$srv_root = EGW_SERVER_ROOT . SEP . "$app_name" . SEP;
102
+			$srv_root = EGW_SERVER_ROOT.SEP."$app_name".SEP;
103 103
 		}
104 104
 		else
105 105
 		{
106 106
 			$srv_root = '';
107 107
 		}
108 108
 
109
-		$tpl_typical = 'templates' . SEP . 'default';
110
-		$tpl_root = "$srv_root" ."$tpl_typical";
109
+		$tpl_typical = 'templates'.SEP.'default';
110
+		$tpl_root = "$srv_root"."$tpl_typical";
111 111
 		return $tpl_root;
112 112
 	}
113 113
 
114
-	static function show_header($title='',$nologoutbutton=False, $logoutfrom='config', $configdomain='')
114
+	static function show_header($title = '', $nologoutbutton = False, $logoutfrom = 'config', $configdomain = '')
115 115
 	{
116 116
 		// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
117 117
 		header('Content-type: text/html; charset='.$GLOBALS['egw_setup']->system_charset);
118 118
 
119
-		$GLOBALS['setup_tpl']->set_var('charset',$GLOBALS['egw_setup']->system_charset);
119
+		$GLOBALS['setup_tpl']->set_var('charset', $GLOBALS['egw_setup']->system_charset);
120 120
 		$style = array(
121 121
 			'th_bg'		=> '#486591',
122 122
 			'th_text'	=> '#FFFFFF',
@@ -128,35 +128,35 @@  discard block
 block discarded – undo
128 128
 		$GLOBALS['setup_tpl']->set_var($style);
129 129
 		if ($nologoutbutton)
130 130
 		{
131
-			$GLOBALS['setup_tpl']->set_block('T_head','loged_in');
132
-			$GLOBALS['setup_tpl']->set_var('loged_in','');
131
+			$GLOBALS['setup_tpl']->set_block('T_head', 'loged_in');
132
+			$GLOBALS['setup_tpl']->set_var('loged_in', '');
133 133
 		}
134 134
 		else
135 135
 		{
136
-			$btn_logout = '<a href="index.php?FormLogout=' . $logoutfrom . '" class="link">' . lang('Logout').'</a>';
136
+			$btn_logout = '<a href="index.php?FormLogout='.$logoutfrom.'" class="link">'.lang('Logout').'</a>';
137 137
 			$check_install = '<a class="textsidebox" href="check_install.php">'.lang('Check installation').'</a>';
138 138
 			$register_hooks = '<a class="textsidebox" href="applications.php?hooks=1">'.lang('Clear cache and register hooks').'</a>';
139 139
 		}
140 140
 
141 141
 		$GLOBALS['setup_tpl']->set_var('lang_setup', lang('setup'));
142
-		$GLOBALS['setup_tpl']->set_var('page_title',$title);
142
+		$GLOBALS['setup_tpl']->set_var('page_title', $title);
143 143
 		if ($configdomain == '')
144 144
 		{
145
-			$GLOBALS['setup_tpl']->set_var('configdomain','');
145
+			$GLOBALS['setup_tpl']->set_var('configdomain', '');
146 146
 		}
147 147
 		else
148 148
 		{
149
-			$GLOBALS['setup_tpl']->set_var('configdomain',' - ' . lang('Domain') . ': ' . $configdomain);
149
+			$GLOBALS['setup_tpl']->set_var('configdomain', ' - '.lang('Domain').': '.$configdomain);
150 150
 		}
151 151
 
152
-		if(basename($_SERVER['SCRIPT_FILENAME']) != 'index.php')
152
+		if (basename($_SERVER['SCRIPT_FILENAME']) != 'index.php')
153 153
 		{
154
-			$index_btn = '<a href="index.php" class="link">' . lang('Setup Main Menu') . '</a>';
154
+			$index_btn = '<a href="index.php" class="link">'.lang('Setup Main Menu').'</a>';
155 155
 			$index_img = '<img src="../phpgwapi/templates/default/images/bullet.png" />';
156 156
 		}
157 157
 
158
-		$GLOBALS['setup_tpl']->set_var('lang_version',lang('version'));
159
-		$GLOBALS['setup_tpl']->set_var('pgw_ver',@$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
158
+		$GLOBALS['setup_tpl']->set_var('lang_version', lang('version'));
159
+		$GLOBALS['setup_tpl']->set_var('pgw_ver', @$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
160 160
 		$GLOBALS['setup_tpl']->set_var(array(
161 161
 			'logoutbutton'  => $btn_logout,
162 162
 			'indexbutton'   => $index_btn,
@@ -169,66 +169,66 @@  discard block
 block discarded – undo
169 169
 
170 170
 		// manual / help link to the install manual on egroupware.org
171 171
 		$manual_remote_egw_url = 'http://manual.egroupware.org/egroupware';
172
-		$url_parts = explode('/',$_SERVER['PHP_SELF']);
172
+		$url_parts = explode('/', $_SERVER['PHP_SELF']);
173 173
 		$script = array_pop($url_parts);
174 174
 		$lang = setup::get_lang();
175 175
 		$url = $manual_remote_egw_url.'/manual/index.php?referer='.urlencode($manual_remote_egw_url.'/setup/'.$script).
176 176
 			($lang ? '&lang='.urlencode($lang) : '');
177
-		$GLOBALS['setup_tpl']->set_var('manual','<a href="'.$url.'" target="manual" onclick="'.
177
+		$GLOBALS['setup_tpl']->set_var('manual', '<a href="'.$url.'" target="manual" onclick="'.
178 178
 			"window.open('$url','manual','width=800,height=600,scrollbars=yes,resizable=yes'); return false;".'">'.
179 179
 			htmlspecialchars(lang('Manual / help')).'</a>');
180 180
 
181
-		$GLOBALS['setup_tpl']->pparse('out','T_head');
181
+		$GLOBALS['setup_tpl']->pparse('out', 'T_head');
182 182
 		/* $setup_tpl->set_var('T_head',''); */
183 183
 	}
184 184
 
185 185
 	static function show_footer()
186 186
 	{
187
-		$GLOBALS['setup_tpl']->pparse('out','T_footer');
187
+		$GLOBALS['setup_tpl']->pparse('out', 'T_footer');
188 188
 		unset($GLOBALS['setup_tpl']);
189 189
 	}
190 190
 
191
-	static function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)')
191
+	static function show_alert_msg($alert_word = 'Setup alert', $alert_msg = 'setup alert (generic)')
192 192
 	{
193
-		$GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word);
194
-		$GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg);
195
-		$GLOBALS['setup_tpl']->pparse('out','T_alert_msg');
193
+		$GLOBALS['setup_tpl']->set_var('V_alert_word', $alert_word);
194
+		$GLOBALS['setup_tpl']->set_var('V_alert_msg', $alert_msg);
195
+		$GLOBALS['setup_tpl']->pparse('out', 'T_alert_msg');
196 196
 	}
197 197
 
198
-	static function make_frm_btn_simple($pre_frm_blurb='',$frm_method='post',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='')
198
+	static function make_frm_btn_simple($pre_frm_blurb = '', $frm_method = 'post', $frm_action = '', $input_type = 'submit', $input_value = '', $post_frm_blurb = '')
199 199
 	{
200 200
 		/* a simple form has simple components */
201
-		$simple_form = $pre_frm_blurb  ."\n"
202
-			. '<form method="' . $frm_method . '" action="' . $frm_action  . '">' . "\n"
203
-			. '<input type="'  . $input_type . '" value="'  . $input_value . '" />' . "\n"
204
-			. '</form>' . "\n"
205
-			. $post_frm_blurb . "\n";
201
+		$simple_form = $pre_frm_blurb."\n"
202
+			. '<form method="'.$frm_method.'" action="'.$frm_action.'">'."\n"
203
+			. '<input type="'.$input_type.'" value="'.$input_value.'" />'."\n"
204
+			. '</form>'."\n"
205
+			. $post_frm_blurb."\n";
206 206
 		return $simple_form;
207 207
 	}
208 208
 
209
-	static function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='')
209
+	static function make_href_link_simple($pre_link_blurb = '', $href_link = '', $href_text = 'default text', $post_link_blurb = '')
210 210
 	{
211 211
 		/* a simple href link has simple components */
212 212
 		$simple_link = $pre_link_blurb
213
-			. '<a href="' . $href_link . '">' . $href_text . '</a> '
214
-			. $post_link_blurb . "\n";
213
+			. '<a href="'.$href_link.'">'.$href_text.'</a> '
214
+			. $post_link_blurb."\n";
215 215
 		return $simple_link;
216 216
 	}
217 217
 
218 218
 	static function login_form()
219 219
 	{
220 220
 		/* begin use TEMPLATE login_main.tpl */
221
-		$GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',@$GLOBALS['egw_info']['setup']['ConfigLoginMSG']);
222
-		$GLOBALS['setup_tpl']->set_var('HeaderLoginMSG',@$GLOBALS['egw_info']['setup']['HeaderLoginMSG']);
223
-		$GLOBALS['setup_tpl']->set_var('lang_header_username',lang('Header Username'));
224
-		$GLOBALS['setup_tpl']->set_var('lang_header_password',lang('Header Password'));
225
-		$GLOBALS['setup_tpl']->set_var('lang_header_login',lang('Header Admin Login'));
226
-		$GLOBALS['setup_tpl']->set_var('lang_config_login',lang('Setup/Config Admin Login'));
227
-		$GLOBALS['setup_tpl']->set_var('lang_config_username',lang('Config Username'));
228
-		$GLOBALS['setup_tpl']->set_var('lang_config_password',lang('Config Password'));
229
-		$GLOBALS['setup_tpl']->set_var('lang_domain',lang('Domain'));
221
+		$GLOBALS['setup_tpl']->set_var('ConfigLoginMSG', @$GLOBALS['egw_info']['setup']['ConfigLoginMSG']);
222
+		$GLOBALS['setup_tpl']->set_var('HeaderLoginMSG', @$GLOBALS['egw_info']['setup']['HeaderLoginMSG']);
223
+		$GLOBALS['setup_tpl']->set_var('lang_header_username', lang('Header Username'));
224
+		$GLOBALS['setup_tpl']->set_var('lang_header_password', lang('Header Password'));
225
+		$GLOBALS['setup_tpl']->set_var('lang_header_login', lang('Header Admin Login'));
226
+		$GLOBALS['setup_tpl']->set_var('lang_config_login', lang('Setup/Config Admin Login'));
227
+		$GLOBALS['setup_tpl']->set_var('lang_config_username', lang('Config Username'));
228
+		$GLOBALS['setup_tpl']->set_var('lang_config_password', lang('Config Password'));
229
+		$GLOBALS['setup_tpl']->set_var('lang_domain', lang('Domain'));
230 230
 
231
-		$GLOBALS['setup_tpl']->set_var('lang_select',self::lang_select());
231
+		$GLOBALS['setup_tpl']->set_var('lang_select', self::lang_select());
232 232
 
233 233
 		if ($GLOBALS['egw_info']['setup']['stage']['header'] == '10')
234 234
 		{
@@ -238,54 +238,54 @@  discard block
 block discarded – undo
238 238
 			*/
239 239
 			if (count($GLOBALS['egw_domain']) > 1)
240 240
 			{
241
-				foreach($GLOBALS['egw_domain'] as $domain => $data)
241
+				foreach ($GLOBALS['egw_domain'] as $domain => $data)
242 242
 				{
243 243
 					$domains .= "<option value=\"$domain\" ".($domain == @$GLOBALS['egw_info']['setup']['LastDomain'] ? ' selected="selected"' : '').">$domain</option>\n";
244 244
 				}
245
-				$GLOBALS['setup_tpl']->set_var('domains',$domains);
245
+				$GLOBALS['setup_tpl']->set_var('domains', $domains);
246 246
 
247 247
 				// use BLOCK B_multi_domain inside of login_stage_header
248
-				$GLOBALS['setup_tpl']->parse('V_multi_domain','B_multi_domain');
248
+				$GLOBALS['setup_tpl']->parse('V_multi_domain', 'B_multi_domain');
249 249
 				// in this case, the single domain block needs to be nothing
250
-				$GLOBALS['setup_tpl']->set_var('V_single_domain','');
250
+				$GLOBALS['setup_tpl']->set_var('V_single_domain', '');
251 251
 			}
252 252
 			else
253 253
 			{
254 254
 				reset($GLOBALS['egw_domain']);
255 255
 				$default_domain = each($GLOBALS['egw_domain']);
256
-				$GLOBALS['setup_tpl']->set_var('default_domain_zero',$default_domain[0]);
256
+				$GLOBALS['setup_tpl']->set_var('default_domain_zero', $default_domain[0]);
257 257
 
258 258
 				/* Use BLOCK B_single_domain inside of login_stage_header */
259
-				$GLOBALS['setup_tpl']->parse('V_single_domain','B_single_domain');
259
+				$GLOBALS['setup_tpl']->parse('V_single_domain', 'B_single_domain');
260 260
 				/* in this case, the multi domain block needs to be nothing */
261
-				$GLOBALS['setup_tpl']->set_var('V_multi_domain','');
261
+				$GLOBALS['setup_tpl']->set_var('V_multi_domain', '');
262 262
 			}
263 263
 			/*
264 264
 			 End use SUB-TEMPLATE login_stage_header
265 265
 			 put all this into V_login_stage_header for use inside login_main
266 266
 			*/
267
-			$GLOBALS['setup_tpl']->parse('V_login_stage_header','T_login_stage_header');
267
+			$GLOBALS['setup_tpl']->parse('V_login_stage_header', 'T_login_stage_header');
268 268
 		}
269 269
 		else
270 270
 		{
271 271
 			/* begin SKIP SUB-TEMPLATE login_stage_header */
272
-			$GLOBALS['setup_tpl']->set_var('V_multi_domain','');
273
-			$GLOBALS['setup_tpl']->set_var('V_single_domain','');
274
-			$GLOBALS['setup_tpl']->set_var('V_login_stage_header','');
272
+			$GLOBALS['setup_tpl']->set_var('V_multi_domain', '');
273
+			$GLOBALS['setup_tpl']->set_var('V_single_domain', '');
274
+			$GLOBALS['setup_tpl']->set_var('V_login_stage_header', '');
275 275
 		}
276 276
 		/*
277 277
 		 end use TEMPLATE login_main.tpl
278 278
 		 now out the login_main template
279 279
 		*/
280
-		$GLOBALS['setup_tpl']->pparse('out','T_login_main');
280
+		$GLOBALS['setup_tpl']->pparse('out', 'T_login_main');
281 281
 	}
282 282
 
283
-	static function lang_select($onChange=False,$ConfigLang='')
283
+	static function lang_select($onChange = False, $ConfigLang = '')
284 284
 	{
285 285
 		if (empty($ConfigLang))
286 286
 		{
287 287
 			$ConfigLang = setup::get_lang();
288
-			if (empty($ConfigLang)) $ConfigLang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
288
+			if (empty($ConfigLang)) $ConfigLang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
289 289
 		}
290 290
 		return html::select('ConfigLang', $ConfigLang, translation::get_available_langs(false), true,
291 291
 			$onChange ? ' onchange="this.form.submit();"' : '');
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
 
294 294
 	static function get_template_list()
295 295
 	{
296
-		$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates');
296
+		$d = dir(EGW_SERVER_ROOT.'/phpgwapi/templates');
297 297
 
298
-		while($entry = $d->read())
298
+		while ($entry = $d->read())
299 299
 		{
300 300
 			if ($entry != 'CVS' && $entry != '.' && $entry != '..')
301 301
 			{
302 302
 				$list[$entry]['name'] = $entry;
303
-				$f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php';
304
-				if (file_exists ($f))
303
+				$f = EGW_SERVER_ROOT.'/phpgwapi/templates/'.$entry.'/details.inc.php';
304
+				if (file_exists($f))
305 305
 				{
306 306
 					include($f);
307
-					$list[$entry]['title'] = 'Use ' . $GLOBALS['egw_info']['template'][$entry]['title'] . 'interface';
307
+					$list[$entry]['title'] = 'Use '.$GLOBALS['egw_info']['template'][$entry]['title'].'interface';
308 308
 				}
309 309
 				else
310 310
 				{
@@ -313,22 +313,22 @@  discard block
 block discarded – undo
313 313
 			}
314 314
 		}
315 315
 		$d->close();
316
-		reset ($list);
316
+		reset($list);
317 317
 		return $list;
318 318
 	}
319 319
 
320 320
 	static function list_themes()
321 321
 	{
322
-		$dh = dir(EGW_SERVER_ROOT . '/phpgwapi/themes');
322
+		$dh = dir(EGW_SERVER_ROOT.'/phpgwapi/themes');
323 323
 		while ($file = $dh->read())
324 324
 		{
325 325
 			if (preg_match('/'."\.theme$".'/i', $file))
326 326
 			{
327
-				$list[] = substr($file,0,strpos($file,'.'));
327
+				$list[] = substr($file, 0, strpos($file, '.'));
328 328
 			}
329 329
 		}
330 330
 		$dh->close();
331
-		reset ($list);
331
+		reset($list);
332 332
 		return $list;
333 333
 	}
334 334
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 
28 28
 		$GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template'));
29 29
 		$GLOBALS['header_template']->set_block('header','domain','domain');
30
-		$var = Array();
30
+		$var = array();
31 31
 
32
-		$deletedomain = get_var('deletedomain',Array('POST'));
33
-		$domains = get_var('domains',Array('POST'));
32
+		$deletedomain = get_var('deletedomain',array('POST'));
33
+		$domains = get_var('domains',array('POST'));
34 34
 
35 35
 		foreach($domains as $k => $v)
36 36
 		{
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 				continue;
40 40
 			}
41 41
 			$variableName = str_replace('.','_',$k);
42
-			$dom = get_var('setting_'.$variableName,Array('POST'));
42
+			$dom = get_var('setting_'.$variableName,array('POST'));
43 43
 			$GLOBALS['header_template']->set_var('DB_DOMAIN',$v);
44 44
 			foreach($dom as $x => $y)
45 45
 			{
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 		$GLOBALS['header_template']->set_var('domain','');
72 72
 
73
-		$setting = get_var('setting',Array('POST'));
73
+		$setting = get_var('setting',array('POST'));
74 74
 		while($setting && list($k,$v) = @each($setting))
75 75
 		{
76 76
 			if(strtoupper($k) == 'HEADER_ADMIN_PASSWORD')
Please login to merge, or discard this patch.
setup/setup-cli.php 4 patches
Braces   +69 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,10 +15,13 @@  discard block
 block discarded – undo
15 15
 
16 16
 chdir(dirname(__FILE__));	// to enable our relative pathes to work
17 17
 
18
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
18
+if (php_sapi_name() !== 'cli')
19
+{
20
+	// security precaution: forbit calling setup-cli as web-page
19 21
 {
20 22
 	die('<h1>setup-cli.php must NOT be called as web-page --> exiting !!!</h1>');
21 23
 }
24
+}
22 25
 error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
23 26
 
24 27
 $dry_run = false;
@@ -33,7 +36,11 @@  discard block
 block discarded – undo
33 36
 	}
34 37
 	$arguments = $_SERVER['argv'];
35 38
 	$action = array_shift($arguments);
36
-	if (isset($arguments[0])) list($_POST['FormDomain']) = explode(',',$arguments[0]);	// header include needs that to detects the right domain
39
+	if (isset($arguments[0]))
40
+	{
41
+		list($_POST['FormDomain']) = explode(',',$arguments[0]);
42
+	}
43
+	// header include needs that to detects the right domain
37 44
 }
38 45
 else
39 46
 {
@@ -51,7 +58,10 @@  discard block
 block discarded – undo
51 58
 // check if date.timezone is set, report it and set something if not, as it gives tons of errors in install log
52 59
 if (!ini_get('date.timezone'))
53 60
 {
54
-	if (!($tz = date_default_timezone_get())) $tz = 'UTC';
61
+	if (!($tz = date_default_timezone_get()))
62
+	{
63
+		$tz = 'UTC';
64
+	}
55 65
 	echo "No default timezone (php.ini date.timezone) set, we temporary set '$tz'. You should fix that permanent!\n";
56 66
 	ini_set('date.timezone',$tz);
57 67
 }
@@ -132,13 +142,19 @@  discard block
 block discarded – undo
132 142
 			foreach($arguments as $arg)
133 143
 			{
134 144
 				list($name,$value) = explode('=',$arg,2);
135
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
145
+				if(property_exists('admin_cmd',$name))
146
+				{
147
+					// dont allow to overwrite admin_cmd properties
136 148
 				{
137 149
 					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
138 150
 				}
139
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
151
+				}
152
+				if (substr($name,-1) == ']')
153
+				{
154
+					// allow 1-dim. arrays
140 155
 				{
141 156
 					list($name,$sub) = explode('[',substr($name,0,-1),2);
157
+				}
142 158
 					$args[$name][$sub] = $value;
143 159
 				}
144 160
 				else
@@ -148,7 +164,10 @@  discard block
 block discarded – undo
148 164
 			}
149 165
 			$cmd = new $class($args);
150 166
 			$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
151
-			if (is_array($msg)) $msg = print_r($msg,true);
167
+			if (is_array($msg))
168
+			{
169
+				$msg = print_r($msg,true);
170
+			}
152 171
 			echo "$msg\n";
153 172
 			break;
154 173
 		}
@@ -164,14 +183,20 @@  discard block
 block discarded – undo
164 183
 function do_config($args)
165 184
 {
166 185
 	$arg0 = explode(',',array_shift($args));
167
-	if (!($domain = @array_shift($arg0))) $domain = 'default';
186
+	if (!($domain = @array_shift($arg0)))
187
+	{
188
+		$domain = 'default';
189
+	}
168 190
 	$user = @array_shift($arg0);
169 191
 	$password = @array_shift($arg0);
170 192
 	_fetch_user_password($user,$password);
171 193
 
172
-	if ($arg0)	// direct assignments (name=value,...) left
194
+	if ($arg0)
195
+	{
196
+		// direct assignments (name=value,...) left
173 197
 	{
174 198
 		array_unshift($args,implode(',',$arg0));
199
+	}
175 200
 		array_unshift($args,'--config');
176 201
 	}
177 202
 
@@ -238,9 +263,15 @@  discard block
 block discarded – undo
238 263
 	{
239 264
 		$options[0] = $domain;
240 265
 
241
-		if ($quite_check) ob_start();
266
+		if ($quite_check)
267
+		{
268
+			ob_start();
269
+		}
242 270
 		_check_auth_config(implode(',',$options),14);
243
-		if ($quite_check) ob_end_clean();
271
+		if ($quite_check)
272
+		{
273
+			ob_end_clean();
274
+		}
244 275
 
245 276
 		if ($backup == 'no')
246 277
 		{
@@ -316,7 +347,10 @@  discard block
 block discarded – undo
316 347
 function _check_auth_config($arg,$stop,$set_lang=true)
317 348
 {
318 349
 	$options = explode(',',$arg);
319
-	if (!($domain = array_shift($options))) $domain = 'default';
350
+	if (!($domain = array_shift($options)))
351
+	{
352
+		$domain = 'default';
353
+	}
320 354
 	$user = array_shift($options);
321 355
 	$password = array_shift($options);
322 356
 	_fetch_user_password($user,$password);
@@ -324,7 +358,10 @@  discard block
 block discarded – undo
324 358
 	setup_cmd::check_installed($domain,$stop,true);
325 359
 
326 360
 	// reset charset for the output to the charset used by the OS
327
-	if ($set_lang) $GLOBALS['egw_setup']->system_charset = $GLOBALS['charset'];
361
+	if ($set_lang)
362
+	{
363
+		$GLOBALS['egw_setup']->system_charset = $GLOBALS['charset'];
364
+	}
328 365
 
329 366
 	setup_cmd::check_setup_auth($user,$password,$domain);
330 367
 
@@ -360,7 +397,10 @@  discard block
 block discarded – undo
360 397
 function _fetch_user_password(&$user,&$password)
361 398
 {
362 399
 	// read password from enviroment or query it from user, if not given
363
-	if (!$user) $user = 'admin';
400
+	if (!$user)
401
+	{
402
+		$user = 'admin';
403
+	}
364 404
 	if (!$password && !($password = $_SERVER['EGW_CLI_PASSWORD']))
365 405
 	{
366 406
 		echo lang('Admin password to header manager').' ';
@@ -406,9 +446,15 @@  discard block
 block discarded – undo
406 446
 		list($code,$language) = explode("\t",$line);
407 447
 		$languages[$code] = $language;
408 448
 	}
409
-	if (isset($languages[$lang.'-'.$nation])) return $lang.'-'.$nation;
449
+	if (isset($languages[$lang.'-'.$nation]))
450
+	{
451
+		return $lang.'-'.$nation;
452
+	}
410 453
 
411
-	if (isset($languages[$lang])) return $lang;
454
+	if (isset($languages[$lang]))
455
+	{
456
+		return $lang;
457
+	}
412 458
 
413 459
 	return 'en';
414 460
 }
@@ -448,7 +494,10 @@  discard block
 block discarded – undo
448 494
 	if (!$what || $what == 'config')
449 495
 	{
450 496
 		echo '--config '.lang('domain(default),[config user(admin)],password,[name=value,...] sets config values beside:')."\n";
451
-		if (!$what) echo '	--help config '.lang('gives further options')."\n";
497
+		if (!$what)
498
+		{
499
+			echo '	--help config '.lang('gives further options')."\n";
500
+		}
452 501
 	}
453 502
 	if ($what == 'config')
454 503
 	{
@@ -477,7 +526,10 @@  discard block
 block discarded – undo
477 526
 		echo lang('Create or edit the EGroupware configuration file: header.inc.php:')."\n";
478 527
 		echo '--create-header '.lang('header-password[,header-user(admin)]')."\n";
479 528
 		echo '--edit-header '.lang('[header-password],[header-user],[new-password],[new-user]')."\n";
480
-		if (!$what) echo '	--help header '.lang('gives further options')."\n";
529
+		if (!$what)
530
+		{
531
+			echo '	--help header '.lang('gives further options')."\n";
532
+		}
481 533
 	}
482 534
 	if ($what == 'header')
483 535
 	{
Please login to merge, or discard this patch.
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -206,7 +206,6 @@
 block discarded – undo
206 206
 /**
207 207
  * Updates the default EMailAdmin profile
208 208
  *
209
- * @param array $values
210 209
  */
211 210
 function do_emailadmin()
212 211
 {
Please login to merge, or discard this patch.
Switch Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -66,91 +66,91 @@
 block discarded – undo
66 66
 
67 67
 switch($action)
68 68
 {
69
-	case '--version':
70
-	case '--check':
71
-		setup_cmd::check_installed($arguments[0],0,true);
72
-		break;
73
-
74
-	case '--create-header':
75
-	case '--edit-header':
76
-	case '--upgrade-header':
77
-	case '--update-header':
78
-		do_header($action == '--create-header',$arguments);
79
-		break;
80
-
81
-	case '--install':
82
-		do_install($arguments);
83
-		break;
84
-
85
-	case '--config':
86
-		do_config($arguments);
87
-		break;
88
-
89
-	case '--admin':
90
-		do_admin($arguments[0]);
91
-		break;
92
-
93
-	case '--update':
94
-		do_update($arguments[0]);
95
-		break;
96
-
97
-	case '--register-hooks':
98
-	case '--register-all-hooks':
99
-		do_hooks($arguments[0]);
100
-		break;
101
-
102
-	case '--backup':
103
-		do_backup($arguments[0]);
104
-		break;
105
-
106
-	case '--languages':
107
-		echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8');
108
-		break;
109
-
110
-	case '--charsets':
111
-		echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n";
112
-		break;
113
-
114
-	case '--exit-codes':
115
-		list_exit_codes();
116
-		break;
117
-
118
-	case '--help':
119
-	case '--usage':
120
-		do_usage($arguments[0]);
121
-		break;
122
-
123
-	default:
124
-		// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
125
-		if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
126
-			is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
127
-		{
128
-			$args = array();
129
-			list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include
130
-			foreach($arguments as $arg)
69
+		case '--version':
70
+		case '--check':
71
+			setup_cmd::check_installed($arguments[0],0,true);
72
+			break;
73
+
74
+		case '--create-header':
75
+		case '--edit-header':
76
+		case '--upgrade-header':
77
+		case '--update-header':
78
+			do_header($action == '--create-header',$arguments);
79
+			break;
80
+
81
+		case '--install':
82
+			do_install($arguments);
83
+			break;
84
+
85
+		case '--config':
86
+			do_config($arguments);
87
+			break;
88
+
89
+		case '--admin':
90
+			do_admin($arguments[0]);
91
+			break;
92
+
93
+		case '--update':
94
+			do_update($arguments[0]);
95
+			break;
96
+
97
+		case '--register-hooks':
98
+		case '--register-all-hooks':
99
+			do_hooks($arguments[0]);
100
+			break;
101
+
102
+		case '--backup':
103
+			do_backup($arguments[0]);
104
+			break;
105
+
106
+		case '--languages':
107
+			echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8');
108
+			break;
109
+
110
+		case '--charsets':
111
+			echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n";
112
+			break;
113
+
114
+		case '--exit-codes':
115
+			list_exit_codes();
116
+			break;
117
+
118
+		case '--help':
119
+		case '--usage':
120
+			do_usage($arguments[0]);
121
+			break;
122
+
123
+		default:
124
+			// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
125
+			if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
126
+				is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
131 127
 			{
132
-				list($name,$value) = explode('=',$arg,2);
133
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
134
-				{
135
-					throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!",$arg),90);
136
-				}
137
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
128
+				$args = array();
129
+				list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include
130
+				foreach($arguments as $arg)
138 131
 				{
139
-					list($name,$sub) = explode('[',substr($name,0,-1),2);
140
-					$args[$name][$sub] = $value;
141
-				}
142
-				else
143
-				{
144
-					$args[$name] = $value;
132
+					list($name,$value) = explode('=',$arg,2);
133
+					if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
134
+					{
135
+						throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!",$arg),90);
136
+					}
137
+					if (substr($name,-1) == ']')	// allow 1-dim. arrays
138
+					{
139
+						list($name,$sub) = explode('[',substr($name,0,-1),2);
140
+						$args[$name][$sub] = $value;
141
+					}
142
+					else
143
+					{
144
+						$args[$name] = $value;
145
+					}
145 146
 				}
147
+				$cmd = new $class($args);
148
+				$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
149
+				if (is_array($msg)) $msg = print_r($msg,true);
150
+				echo "$msg\n";
151
+				break;
146 152
 			}
147
-			$cmd = new $class($args);
148
-			$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
149
-			if (is_array($msg)) $msg = print_r($msg,true);
150
-			echo "$msg\n";
151
-			break;
152
-		}
153
-		throw new egw_exception_wrong_userinput(lang("Unknown option '%1' !!!",$action),90);
153
+			throw new egw_exception_wrong_userinput(lang("Unknown option '%1' !!!",$action),90);
154 154
 }
155 155
 exit(0);
156 156
 
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
  * @version $Id$
12 12
  */
13 13
 
14
-chdir(dirname(__FILE__));	// to enable our relative pathes to work
14
+chdir(dirname(__FILE__)); // to enable our relative pathes to work
15 15
 
16 16
 if (php_sapi_name() !== 'cli')	// security precaution: forbit calling setup-cli as web-page
17 17
 {
18 18
 	die('<h1>setup-cli.php must NOT be called as web-page --> exiting !!!</h1>');
19 19
 }
20
-error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
20
+error_reporting(E_ALL&~E_NOTICE&~E_STRICT&~E_DEPRECATED);
21 21
 
22 22
 $dry_run = false;
23 23
 array_shift($_SERVER['argv']);
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 	$arguments = $_SERVER['argv'];
33 33
 	$action = array_shift($arguments);
34
-	if (isset($arguments[0])) list($_POST['FormDomain']) = explode(',',$arguments[0]);	// header include needs that to detects the right domain
34
+	if (isset($arguments[0])) list($_POST['FormDomain']) = explode(',', $arguments[0]); // header include needs that to detects the right domain
35 35
 }
36 36
 else
37 37
 {
@@ -40,42 +40,42 @@  discard block
 block discarded – undo
40 40
 
41 41
 // setting the language from the enviroment
42 42
 $_POST['ConfigLang'] = get_lang($charset);
43
-create_http_enviroment();	// guessing the docroot etc.
43
+create_http_enviroment(); // guessing the docroot etc.
44 44
 
45 45
 if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp'))
46 46
 {
47
-	ini_set('session.save_path','/tmp');	// regular users may have no rights to apache's session dir
47
+	ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir
48 48
 }
49 49
 // check if date.timezone is set, report it and set something if not, as it gives tons of errors in install log
50 50
 if (!ini_get('date.timezone'))
51 51
 {
52 52
 	if (!($tz = date_default_timezone_get())) $tz = 'UTC';
53 53
 	echo "No default timezone (php.ini date.timezone) set, we temporary set '$tz'. You should fix that permanent!\n";
54
-	ini_set('date.timezone',$tz);
54
+	ini_set('date.timezone', $tz);
55 55
 }
56 56
 
57 57
 // setting up the $GLOBALS['egw_setup'] object AND including the header.inc.php if it exists
58 58
 include('inc/functions.inc.php');
59
-$GLOBALS['egw_info']['flags']['no_exception_handler'] = 'cli';	// inc/functions.inc.php does NOT set it
59
+$GLOBALS['egw_info']['flags']['no_exception_handler'] = 'cli'; // inc/functions.inc.php does NOT set it
60 60
 $GLOBALS['egw_setup']->system_charset = $charset;
61 61
 
62
-if ((float) PHP_VERSION < $GLOBALS['egw_setup']->required_php_version)
62
+if ((float)PHP_VERSION < $GLOBALS['egw_setup']->required_php_version)
63 63
 {
64
-	throw new egw_exception_wrong_userinput(lang('You are using PHP version %1. EGroupware now requires %2 or later, recommended is PHP %3.',PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,$GLOBALS['egw_setup']->recommended_php_version),98);
64
+	throw new egw_exception_wrong_userinput(lang('You are using PHP version %1. EGroupware now requires %2 or later, recommended is PHP %3.', PHP_VERSION, $GLOBALS['egw_setup']->required_php_version, $GLOBALS['egw_setup']->recommended_php_version), 98);
65 65
 }
66 66
 
67
-switch($action)
67
+switch ($action)
68 68
 {
69 69
 	case '--version':
70 70
 	case '--check':
71
-		setup_cmd::check_installed($arguments[0],0,true);
71
+		setup_cmd::check_installed($arguments[0], 0, true);
72 72
 		break;
73 73
 
74 74
 	case '--create-header':
75 75
 	case '--edit-header':
76 76
 	case '--upgrade-header':
77 77
 	case '--update-header':
78
-		do_header($action == '--create-header',$arguments);
78
+		do_header($action == '--create-header', $arguments);
79 79
 		break;
80 80
 
81 81
 	case '--install':
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 		break;
105 105
 
106 106
 	case '--languages':
107
-		echo html_entity_decode(file_get_contents('lang/languages'),ENT_COMPAT,'utf-8');
107
+		echo html_entity_decode(file_get_contents('lang/languages'), ENT_COMPAT, 'utf-8');
108 108
 		break;
109 109
 
110 110
 	case '--charsets':
111
-		echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n";
111
+		echo html_entity_decode(implode("\n", $GLOBALS['egw_setup']->translation->get_charsets(false)), ENT_COMPAT, 'utf-8')."\n";
112 112
 		break;
113 113
 
114 114
 	case '--exit-codes':
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
 
123 123
 	default:
124 124
 		// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
125
-		if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
126
-			is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
125
+		if (substr($action, 0, 2) == '--' && class_exists($class = str_replace('-', '_', substr($action, 2))) &&
126
+			is_subclass_of($class, 'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
127 127
 		{
128 128
 			$args = array();
129
-			list($args['domain']) = explode(',', array_shift($arguments));	// domain must be first argument, to ensure right domain get's selected in header-include
130
-			foreach($arguments as $arg)
129
+			list($args['domain']) = explode(',', array_shift($arguments)); // domain must be first argument, to ensure right domain get's selected in header-include
130
+			foreach ($arguments as $arg)
131 131
 			{
132
-				list($name,$value) = explode('=',$arg,2);
133
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
132
+				list($name, $value) = explode('=', $arg, 2);
133
+				if (property_exists('admin_cmd', $name))		// dont allow to overwrite admin_cmd properties
134 134
 				{
135
-					throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!",$arg),90);
135
+					throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!", $arg), 90);
136 136
 				}
137
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
137
+				if (substr($name, -1) == ']')	// allow 1-dim. arrays
138 138
 				{
139
-					list($name,$sub) = explode('[',substr($name,0,-1),2);
139
+					list($name, $sub) = explode('[', substr($name, 0, -1), 2);
140 140
 					$args[$name][$sub] = $value;
141 141
 				}
142 142
 				else
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
 				}
146 146
 			}
147 147
 			$cmd = new $class($args);
148
-			$msg = $cmd->run($time=null, $set_modifier=true, $skip_checks=false, $check_only=$dry_run);
149
-			if (is_array($msg)) $msg = print_r($msg,true);
148
+			$msg = $cmd->run($time = null, $set_modifier = true, $skip_checks = false, $check_only = $dry_run);
149
+			if (is_array($msg)) $msg = print_r($msg, true);
150 150
 			echo "$msg\n";
151 151
 			break;
152 152
 		}
153
-		throw new egw_exception_wrong_userinput(lang("Unknown option '%1' !!!",$action),90);
153
+		throw new egw_exception_wrong_userinput(lang("Unknown option '%1' !!!", $action), 90);
154 154
 }
155 155
 exit(0);
156 156
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
  */
162 162
 function do_config($args)
163 163
 {
164
-	$arg0 = explode(',',array_shift($args));
164
+	$arg0 = explode(',', array_shift($args));
165 165
 	if (!($domain = @array_shift($arg0))) $domain = 'default';
166 166
 	$user = @array_shift($arg0);
167 167
 	$password = @array_shift($arg0);
168
-	_fetch_user_password($user,$password);
168
+	_fetch_user_password($user, $password);
169 169
 
170 170
 	if ($arg0)	// direct assignments (name=value,...) left
171 171
 	{
172
-		array_unshift($args,implode(',',$arg0));
173
-		array_unshift($args,'--config');
172
+		array_unshift($args, implode(',', $arg0));
173
+		array_unshift($args, '--config');
174 174
 	}
175 175
 
176
-	$cmd = new setup_cmd_config($domain,$user,$password,$args,true);
176
+	$cmd = new setup_cmd_config($domain, $user, $password, $args, true);
177 177
 	echo $cmd->run()."\n\n";
178 178
 
179 179
 	$cmd->get_config(true);
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
  */
187 187
 function do_hooks($arg)
188 188
 {
189
-	list($domain,$user,$password) = explode(',',$arg);
190
-	_fetch_user_password($user,$password);
189
+	list($domain, $user, $password) = explode(',', $arg);
190
+	_fetch_user_password($user, $password);
191 191
 
192 192
 	$domains = $GLOBALS['egw_domain'];
193 193
 	if ($domain && $domain != 'all')
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 		$domains = array($domain => $GLOBALS['egw_domain'][$domain]);
196 196
 	}
197 197
 
198
-	foreach(array_keys($domains) as $domain)
198
+	foreach (array_keys($domains) as $domain)
199 199
 	{
200
-		$cmd = new setup_cmd_hooks($domain,$user,$password);
200
+		$cmd = new setup_cmd_hooks($domain, $user, $password);
201 201
 		echo "$domain: ".$cmd->run()."\n";
202 202
 	}
203 203
 	echo "\n";
@@ -210,23 +210,23 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function do_emailadmin()
212 212
 {
213
-	$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array(
213
+	$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table, 'config_name,config_value', array(
214 214
 		'config_app'  => 'phpgwapi',
215 215
 		"((config_name LIKE 'mail%' AND config_name != 'mail_footer') OR config_name LIKE 'smtp%' OR config_name LIKE 'imap%' OR config_name='editforwardingaddress')",
216
-	),__LINE__,__FILE__);
216
+	), __LINE__, __FILE__);
217 217
 	while (($row = $GLOBALS['egw_setup']->db->row(true)))
218 218
 	{
219 219
 		$config[$row['config_name']] = $row['config_value'];
220 220
 	}
221 221
 	$config['smtpAuth'] = $config['smtp_auth_user'] ? 'yes' : null;
222 222
 
223
-	$emailadmin = new emailadmin_bo(false,false);	// false=no session stuff
223
+	$emailadmin = new emailadmin_bo(false, false); // false=no session stuff
224 224
 	$emailadmin->setDefaultProfile($config);
225 225
 
226 226
 	echo "\n".lang('EMailAdmin profile updated:')."\n";
227
-	foreach($config as $name => $value)
227
+	foreach ($config as $name => $value)
228 228
 	{
229
-		echo str_pad($name.':',22).$value."\n";
229
+		echo str_pad($name.':', 22).$value."\n";
230 230
 	}
231 231
 }
232 232
 
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
  */
238 238
 function do_admin($arg)
239 239
 {
240
-	list($domain,$user,$password,$admin,$pw,$first,$last,$email,$lang) = explode(',',$arg);
241
-	_fetch_user_password($user,$password);
240
+	list($domain, $user, $password, $admin, $pw, $first, $last, $email, $lang) = explode(',', $arg);
241
+	_fetch_user_password($user, $password);
242 242
 
243
-	$cmd = new setup_cmd_admin($domain,$user,$password,$admin,$pw,$first,$last,$email,array(),$lang);
243
+	$cmd = new setup_cmd_admin($domain, $user, $password, $admin, $pw, $first, $last, $email, array(), $lang);
244 244
 	echo $cmd->run()."\n";
245 245
 }
246 246
 
@@ -250,21 +250,21 @@  discard block
 block discarded – undo
250 250
  * @param string $arg domain(all),[config user(admin)],password,[backup-file, 'no' for no backup or empty for default name]
251 251
  * @param boolean $quite_check quiten the call to _check_auth_config
252 252
  */
253
-function do_backup($arg,$quite_check=false)
253
+function do_backup($arg, $quite_check = false)
254 254
 {
255
-	list($domain,,,$backup) = $options = explode(',',$arg);
255
+	list($domain,,, $backup) = $options = explode(',', $arg);
256 256
 
257 257
 	$domains = $GLOBALS['egw_domain'];
258 258
 	if ($domain && $domain != 'all')
259 259
 	{
260 260
 		$domains = array($domain => $GLOBALS['egw_domain'][$domain]);
261 261
 	}
262
-	foreach(array_keys($domains) as $domain)
262
+	foreach (array_keys($domains) as $domain)
263 263
 	{
264 264
 		$options[0] = $domain;
265 265
 
266 266
 		if ($quite_check) ob_start();
267
-		_check_auth_config(implode(',',$options),14);
267
+		_check_auth_config(implode(',', $options), 14);
268 268
 		if ($quite_check) ob_end_clean();
269 269
 
270 270
 		if ($backup == 'no')
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 			}
283 283
 			else	// backup failed ==> dont start the upgrade
284 284
 			{
285
-				throw new egw_exception_wrong_userinput(lang('Backup failed').': '.$f,50);
285
+				throw new egw_exception_wrong_userinput(lang('Backup failed').': '.$f, 50);
286 286
 			}
287 287
 		}
288 288
 	}
@@ -295,31 +295,31 @@  discard block
 block discarded – undo
295 295
  */
296 296
 function do_update($arg)
297 297
 {
298
-	list($domain,$user,$password,$backup,$app) = explode(',',$arg);
299
-	_fetch_user_password($user,$password);
298
+	list($domain, $user, $password, $backup, $app) = explode(',', $arg);
299
+	_fetch_user_password($user, $password);
300 300
 
301 301
 	$domains = $GLOBALS['egw_domain'];
302 302
 	if ($domain && $domain != 'all')
303 303
 	{
304 304
 		$domains = array($domain => $GLOBALS['egw_domain'][$domain]);
305 305
 	}
306
-	foreach($domains as $domain => $data)
306
+	foreach ($domains as $domain => $data)
307 307
 	{
308 308
 		$arg = "$domain,$user,$password,$backup";
309 309
 
310
-		_check_auth_config($arg,14);
310
+		_check_auth_config($arg, 14);
311 311
 
312 312
 		if ($GLOBALS['egw_info']['setup']['stage']['db'] != 4 &&
313 313
 			(!$app || !in_array($app, setup_cmd::$apps_to_install) && !in_array($app, setup_cmd::$apps_to_upgrade)) &&
314 314
 			!setup_cmd::check_autoinstall())
315 315
 		{
316
-			echo lang('No update necessary, domain %1(%2) is up to date.',$domain,$data['db_type'])."\n";
316
+			echo lang('No update necessary, domain %1(%2) is up to date.', $domain, $data['db_type'])."\n";
317 317
 		}
318 318
 		else
319 319
 		{
320
-			do_backup($arg,true);
320
+			do_backup($arg, true);
321 321
 
322
-			$cmd = new setup_cmd_update($domain,$user,$password,$backup,true,$app);
322
+			$cmd = new setup_cmd_update($domain, $user, $password, $backup, true, $app);
323 323
 			echo $cmd->run()."\n";
324 324
 		}
325 325
 	}
@@ -338,20 +338,20 @@  discard block
 block discarded – undo
338 338
  * @param boolean $set_lang =true set our charset, overwriting the charset of the eGW installation, default true
339 339
  * @return array with unprocessed arguments from $arg
340 340
  */
341
-function _check_auth_config($arg,$stop,$set_lang=true)
341
+function _check_auth_config($arg, $stop, $set_lang = true)
342 342
 {
343
-	$options = explode(',',$arg);
343
+	$options = explode(',', $arg);
344 344
 	if (!($domain = array_shift($options))) $domain = 'default';
345 345
 	$user = array_shift($options);
346 346
 	$password = array_shift($options);
347
-	_fetch_user_password($user,$password);
347
+	_fetch_user_password($user, $password);
348 348
 
349
-	setup_cmd::check_installed($domain,$stop,true);
349
+	setup_cmd::check_installed($domain, $stop, true);
350 350
 
351 351
 	// reset charset for the output to the charset used by the OS
352 352
 	if ($set_lang) $GLOBALS['egw_setup']->system_charset = $GLOBALS['charset'];
353 353
 
354
-	setup_cmd::check_setup_auth($user,$password,$domain);
354
+	setup_cmd::check_setup_auth($user, $password, $domain);
355 355
 
356 356
 	return $options;
357 357
 }
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
  */
364 364
 function do_install($args)
365 365
 {
366
-	list($domain,$user,$password,$backup,$charset,$lang) = explode(',',array_shift($args));
367
-	_fetch_user_password($user,$password);
366
+	list($domain, $user, $password, $backup, $charset, $lang) = explode(',', array_shift($args));
367
+	_fetch_user_password($user, $password);
368 368
 
369 369
 	$config = array();
370
-	foreach($args as $arg)
370
+	foreach ($args as $arg)
371 371
 	{
372
-		list($name,$value) = explode('=',$arg,2);
372
+		list($name, $value) = explode('=', $arg, 2);
373 373
 		$config[$name] = $value;
374 374
 	}
375
-	$cmd = new setup_cmd_install($domain,$user,$password,$backup,$charset,true,$config,$lang);
375
+	$cmd = new setup_cmd_install($domain, $user, $password, $backup, $charset, true, $config, $lang);
376 376
 	echo $cmd->run()."\n";
377 377
 }
378 378
 
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
  * @param string &$user
383 383
  * @param string &$password
384 384
  */
385
-function _fetch_user_password(&$user,&$password)
385
+function _fetch_user_password(&$user, &$password)
386 386
 {
387 387
 	// read password from enviroment or query it from user, if not given
388 388
 	if (!$user) $user = 'admin';
389 389
 	if (!$password && !($password = $_SERVER['EGW_CLI_PASSWORD']))
390 390
 	{
391 391
 		echo lang('Admin password to header manager').' ';
392
-		$password = trim(fgets($f = fopen('php://stdin','rb')));
392
+		$password = trim(fgets($f = fopen('php://stdin', 'rb')));
393 393
 		fclose($f);
394 394
 	}
395 395
 }
@@ -401,18 +401,18 @@  discard block
 block discarded – undo
401 401
  * @param array $arguments
402 402
  * @return int
403 403
  */
404
-function do_header($create,&$arguments)
404
+function do_header($create, &$arguments)
405 405
 {
406 406
 	if (!$create)
407 407
 	{
408 408
 		// read password from enviroment or query it from user, if not given
409
-		$options = explode(',',@$arguments[0]);
410
-		_fetch_user_password($options[1],$options[0]);
411
-		$arguments[0] = implode(',',$options);
409
+		$options = explode(',', @$arguments[0]);
410
+		_fetch_user_password($options[1], $options[0]);
411
+		$arguments[0] = implode(',', $options);
412 412
 	}
413
-	array_unshift($arguments,$create ? '--create-header' : '--edit-header');
413
+	array_unshift($arguments, $create ? '--create-header' : '--edit-header');
414 414
 
415
-	$cmd = new setup_cmd_header($create?'create':'edit',$arguments);
415
+	$cmd = new setup_cmd_header($create ? 'create' : 'edit', $arguments);
416 416
 	echo $cmd->run()."\n";
417 417
 }
418 418
 
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
  */
425 425
 function get_lang(&$charset)
426 426
 {
427
-	@list($lang,$nation,$charset) = preg_split("/[_.]/",strtolower($_SERVER['LANG']));
427
+	@list($lang, $nation, $charset) = preg_split("/[_.]/", strtolower($_SERVER['LANG']));
428 428
 
429
-	foreach(file('lang/languages') as $line)
429
+	foreach (file('lang/languages') as $line)
430 430
 	{
431
-		list($code,$language) = explode("\t",$line);
431
+		list($code, $language) = explode("\t", $line);
432 432
 		$languages[$code] = $language;
433 433
 	}
434 434
 	if (isset($languages[$lang.'-'.$nation])) return $lang.'-'.$nation;
@@ -445,13 +445,13 @@  discard block
 block discarded – undo
445 445
 {
446 446
 	$_SERVER['SCRIPT_FILENAME'] = __FILE__;
447 447
 
448
-	foreach(array('httpsdocs','httpdocs','htdocs','html','www') as $docroottop)
448
+	foreach (array('httpsdocs', 'httpdocs', 'htdocs', 'html', 'www') as $docroottop)
449 449
 	{
450
-		$parts = explode($docroottop,__FILE__);
450
+		$parts = explode($docroottop, __FILE__);
451 451
 		if (count($parts) == 2)
452 452
 		{
453 453
 			$_SERVER['DOCUMENT_ROOT'] = $parts[0].$docroottop;
454
-			$_SERVER['PHP_SELF'] = str_replace('\\','/',$parts[1]);
454
+			$_SERVER['PHP_SELF'] = str_replace('\\', '/', $parts[1]);
455 455
 			break;
456 456
 		}
457 457
 	}
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
 /**
462 462
  * Echos usage message
463 463
  */
464
-function do_usage($what='')
464
+function do_usage($what = '')
465 465
 {
466
-	echo lang('Usage: %1 command [additional options]',basename($_SERVER['argv'][0]))."\n\n";
466
+	echo lang('Usage: %1 command [additional options]', basename($_SERVER['argv'][0]))."\n\n";
467 467
 
468 468
 	if (!$what)
469 469
 	{
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	if ($what == 'config')
479 479
 	{
480 480
 		echo '	--files-dir, --backup-dir, --temp-dir '.lang('path to various directories: have to exist and be writeable by the webserver')."\n";
481
-		echo '	--webserver-url '.lang('eg. /egroupware or http://domain.com/egroupware, default: %1',str_replace('/setup/setup-cli.php','',$_SERVER['PHP_SELF']))."\n";
481
+		echo '	--webserver-url '.lang('eg. /egroupware or http://domain.com/egroupware, default: %1', str_replace('/setup/setup-cli.php', '', $_SERVER['PHP_SELF']))."\n";
482 482
 		echo '	--mailserver '.lang('host,port(143),[domain],[{standard(default)|vmailmgr = add domain for mailserver login}]').',[starttls|ssl|tls]'."\n";
483 483
 		echo '	--smtpserver '.lang('host,[smtp port],[smtp user],[smtp password],[auth session user/pw=yes|no],[starttls|ssl|tls],[account user editable=yes|no],[further identities=yes|no]')."\n";
484 484
 		echo '	--smtp '.lang('MTA (with LDAP): [yes(user edit forwarding)],emailadmin_smtp(|_sql|_ldap|_ads|_qmail|_mandriva|_dbmailuser|_suse)')."\n";
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
 		echo '--charsets '.lang('charsets used by the different languages')."\n";
530 530
 		echo '--exit-codes '.lang('all exit codes of the command line interface')."\n";
531 531
 	}
532
-	if (!$what || !in_array($what,array('config','header','list')))
532
+	if (!$what || !in_array($what, array('config', 'header', 'list')))
533 533
 	{
534 534
 		echo '--help [config|header|list] '.lang('gives further options')."\n";
535 535
 	}
536 536
 }
537 537
 
538
-function fail($exit_code,$message)
538
+function fail($exit_code, $message)
539 539
 {
540 540
 	echo $message."\n";
541 541
 	exit($exit_code);
@@ -551,40 +551,40 @@  discard block
 block discarded – undo
551 551
  */
552 552
 function list_exit_codes()
553 553
 {
554
-	error_reporting(error_reporting() & ~E_NOTICE);
554
+	error_reporting(error_reporting()&~E_NOTICE);
555 555
 
556 556
 	$codes = array('Ok');
557 557
 	$setup_dir = EGW_SERVER_ROOT.'/setup/';
558 558
 	//$files = array('setup-cli.php');
559
-	foreach(scandir($setup_dir.'/inc') as $file)
559
+	foreach (scandir($setup_dir.'/inc') as $file)
560 560
 	{
561
-		if (substr($file,0,strlen('class.setup_cmd')) == 'class.setup_cmd')
561
+		if (substr($file, 0, strlen('class.setup_cmd')) == 'class.setup_cmd')
562 562
 		{
563 563
 			$files[] = 'inc/'.$file;
564 564
 		}
565 565
 	}
566
-	foreach($files as $file)
566
+	foreach ($files as $file)
567 567
 	{
568 568
 		$content = file_get_contents($setup_dir.'/'.$file);
569 569
 
570 570
 		$matches = null;
571
-		if (preg_match_all('/throw new (egw_exception[a-z_]*)\((.*),([0-9]+)\);/m',$content,$matches))
571
+		if (preg_match_all('/throw new (egw_exception[a-z_]*)\((.*),([0-9]+)\);/m', $content, $matches))
572 572
 		{
573 573
 			//echo $file.":\n"; print_r($matches);
574
-			foreach($matches[3] as $key => $code)
574
+			foreach ($matches[3] as $key => $code)
575 575
 			{
576 576
 				//if (isset($codes[$code])) echo "$file redifines #$code: {$codes[$code]}\n";
577 577
 
578
-				$src = preg_replace('/self::\$[a-z_>-]+/i', "''", $matches[2][$key]);	// gives fatal error otherwise
579
-				@eval($src='$codes['.$code.'] = '.$src.';');
578
+				$src = preg_replace('/self::\$[a-z_>-]+/i', "''", $matches[2][$key]); // gives fatal error otherwise
579
+				@eval($src = '$codes['.$code.'] = '.$src.';');
580 580
 				//echo "- codes[$code] => '{$codes[$code]}'\n";
581 581
 			}
582 582
 			//echo $file.":\n"; print_r($codes);
583 583
 		}
584 584
 	}
585
-	ksort($codes,SORT_NUMERIC);
586
-	foreach($codes as $num => $msg)
585
+	ksort($codes, SORT_NUMERIC);
586
+	foreach ($codes as $num => $msg)
587 587
 	{
588
-		echo $num."\t".str_replace("\n","\n\t",$msg)."\n";
588
+		echo $num."\t".str_replace("\n", "\n\t", $msg)."\n";
589 589
 	}
590 590
 }
Please login to merge, or discard this patch.
setup/account_migration.php 2 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -156,7 +156,10 @@
 block discarded – undo
156 156
 else	// do the migration
157 157
 {
158 158
 	$cmd->only = (array)$_POST['users'];
159
-	if (empty($_POST['passwords2sql'])) $cmd->only = array_merge($cmd->only, (array)$_POST['groups']);
159
+	if (empty($_POST['passwords2sql']))
160
+	{
161
+		$cmd->only = array_merge($cmd->only, (array)$_POST['groups']);
162
+	}
160 163
 	$cmd->verbose = true;
161 164
 	echo '<p align="center">'.str_replace("\n","</p>\n<p align='center'>",$cmd->run())."</p>\n";
162 165
 
Please login to merge, or discard this patch.
Spacing   +43 added lines, -44 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 // Does not return unless user is authorized
23 23
 
24 24
 $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
25
-$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
25
+$setup_tpl = CreateObject('phpgwapi.Template', $tpl_root);
26 26
 $setup_tpl->set_file(array(
27 27
 	'migration' => 'account_migration.tpl',
28 28
 	'T_head' => 'head.tpl',
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	$GLOBALS['egw_setup']->loaddb();
44 44
 }
45 45
 // Load configuration values account_repository and auth_type, as setup has not yet done so
46
-foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',
46
+foreach ($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table, 'config_name,config_value',
47 47
 	"config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type' OR config_name='mail_suffix'",
48
-	__LINE__,__FILE__) as $row)
48
+	__LINE__, __FILE__) as $row)
49 49
 {
50 50
 	$GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value'];
51 51
 }
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 }
64 64
 $direction = strtoupper($from).' --> '.strtoupper($to);
65 65
 
66
-$GLOBALS['egw_setup']->html->show_header($direction,False,'config',$GLOBALS['egw_setup']->ConfigDomain .
67
-	'(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
66
+$GLOBALS['egw_setup']->html->show_header($direction, False, 'config', $GLOBALS['egw_setup']->ConfigDomain.
67
+	'('.$GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'].')');
68 68
 
69 69
 // create base one level off ldap_context
70
-$base_parts = explode(',',$GLOBALS['egw_info']['server']['ldap_context']);
70
+$base_parts = explode(',', $GLOBALS['egw_info']['server']['ldap_context']);
71 71
 array_shift($base_parts);
72 72
 
73 73
 $cmd = new setup_cmd_ldap(array(
@@ -76,24 +76,24 @@  discard block
 block discarded – undo
76 76
 	// allow to set ldap root DN (ldap_admin) to create instance specific admin DN and structure
77 77
 	'ldap_admin' => !empty($_POST['ldap_admin']) ? $_POST['ldap_admin'] : $GLOBALS['egw_info']['server']['ldap_root_dn'],
78 78
 	'ldap_admin_pw' => !empty($_POST['ldap_admin']) ? $_POST['ldap_admin_pw'] : $GLOBALS['egw_info']['server']['ldap_root_pw'],
79
-	'ldap_base' => implode(',',$base_parts),
79
+	'ldap_base' => implode(',', $base_parts),
80 80
 	'truncate_egw_accounts' => !empty($_POST['truncate_egw_accounts']),
81
-)+$GLOBALS['egw_info']['server']);
81
+) + $GLOBALS['egw_info']['server']);
82 82
 
83 83
 if (!$_POST['migrate'] && !$_POST['passwords2sql'])
84 84
 {
85 85
 	$accounts = $cmd->accounts($from);
86 86
 
87 87
 	// now outputting the account selection
88
-	$setup_tpl->set_block('migration','header','header');
89
-	$setup_tpl->set_block('migration','user_list','user_list');
90
-	$setup_tpl->set_block('migration','group_list','group_list');
91
-	$setup_tpl->set_block('migration','ldap_admin','ldap_admin');
92
-	$setup_tpl->set_block('migration','submit','submit');
93
-	$setup_tpl->set_block('migration','footer','footer');
94
-	$setup_tpl->set_block('migration','truncate_egw_accounts','truncate_egw_accounts');
95
-
96
-	foreach($accounts as $account_id => $account)
88
+	$setup_tpl->set_block('migration', 'header', 'header');
89
+	$setup_tpl->set_block('migration', 'user_list', 'user_list');
90
+	$setup_tpl->set_block('migration', 'group_list', 'group_list');
91
+	$setup_tpl->set_block('migration', 'ldap_admin', 'ldap_admin');
92
+	$setup_tpl->set_block('migration', 'submit', 'submit');
93
+	$setup_tpl->set_block('migration', 'footer', 'footer');
94
+	$setup_tpl->set_block('migration', 'truncate_egw_accounts', 'truncate_egw_accounts');
95
+
96
+	foreach ($accounts as $account_id => $account)
97 97
 	{
98 98
 		if ($account['account_type'] == 'g')
99 99
 		{
@@ -101,70 +101,69 @@  discard block
 block discarded – undo
101 101
 			{
102 102
 				$identical_account_id_warning .= lang('Group %1 uses identical ID %2 as user %3!', $account['account_lid'], abs($account_id), $accounts[abs($account_id)]['account_lid']);
103 103
 			}
104
-			$group_list .= '<option value="' . $account_id . '" selected="1">'. $account['account_lid'] . "</option>\n";
104
+			$group_list .= '<option value="'.$account_id.'" selected="1">'.$account['account_lid']."</option>\n";
105 105
 		}
106 106
 		else
107 107
 		{
108
-			$user_list .= '<option value="' . $account_id . '" selected="1">'.
108
+			$user_list .= '<option value="'.$account_id.'" selected="1">'.
109 109
 				common::display_fullname($account['account_lid'],
110
-				$account['account_firstname'],$account['account_lastname'])	. "</option>\n";
110
+				$account['account_firstname'], $account['account_lastname'])."</option>\n";
111 111
 		}
112 112
 	}
113
-	$setup_tpl->set_var('action_url','account_migration.php');
114
-	$setup_tpl->set_var('users',$user_list);
115
-	$setup_tpl->set_var('groups',$group_list);
116
-
117
-	$setup_tpl->set_var('description',lang('Migration between EGroupware account repositories').': '.$direction);
118
-	$setup_tpl->set_var('select_users',lang('Select which user(s) will be exported'));
119
-	$setup_tpl->set_var('select_groups',lang('Select which group(s) will be exported'));
120
-	$setup_tpl->set_var('memberships',$identical_account_id_warning ?
121
-		'<p style="color: red">'.$identical_account_id_warning.'<br/>'.lang('Migration of group will fail, as SQL does NOT allow identical IDs.').'</p>' :
122
-		lang('Group memberships will be migrated too.'));
113
+	$setup_tpl->set_var('action_url', 'account_migration.php');
114
+	$setup_tpl->set_var('users', $user_list);
115
+	$setup_tpl->set_var('groups', $group_list);
116
+
117
+	$setup_tpl->set_var('description', lang('Migration between EGroupware account repositories').': '.$direction);
118
+	$setup_tpl->set_var('select_users', lang('Select which user(s) will be exported'));
119
+	$setup_tpl->set_var('select_groups', lang('Select which group(s) will be exported'));
120
+	$setup_tpl->set_var('memberships', $identical_account_id_warning ?
121
+		'<p style="color: red">'.$identical_account_id_warning.'<br/>'.lang('Migration of group will fail, as SQL does NOT allow identical IDs.').'</p>' : lang('Group memberships will be migrated too.'));
123 122
 	$setup_tpl->set_var('ldap_admin_message', lang('Give LDAP root DN and password, if you need to create an instance specific admin user, user- or group-context'));
124 123
 	$setup_tpl->set_var('ldap_admin_label', lang('Root DN'));
125 124
 	$setup_tpl->set_var('ldap_admin_pw_label', lang('Root DN password'));
126
-	$setup_tpl->set_var('migrate',$direction);
127
-	$setup_tpl->set_var('cancel',lang('Cancel'));
125
+	$setup_tpl->set_var('migrate', $direction);
126
+	$setup_tpl->set_var('cancel', lang('Cancel'));
128 127
 	if ($from == 'sql' && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap')
129 128
 	{
130 129
 		$setup_tpl->set_var('extra_button', html::submit_button('passwords2sql', lang('Passwords --> SQL')));
131 130
 	}
132 131
 
133
-	$setup_tpl->pfp('out','header');
134
-	if($user_list)
132
+	$setup_tpl->pfp('out', 'header');
133
+	if ($user_list)
135 134
 	{
136
-		$setup_tpl->pfp('out','user_list');
135
+		$setup_tpl->pfp('out', 'user_list');
137 136
 	}
138
-	if($group_list)
137
+	if ($group_list)
139 138
 	{
140
-		$setup_tpl->pfp('out','group_list');
139
+		$setup_tpl->pfp('out', 'group_list');
141 140
 	}
142 141
 	if ($to == 'ldap')
143 142
 	{
144
-		$setup_tpl->pfp('out','ldap_admin');
143
+		$setup_tpl->pfp('out', 'ldap_admin');
145 144
 	}
146 145
 	if ($to == 'sql')
147 146
 	{
148 147
 		$setup_tpl->set_var('truncate_egw_accounts_message', lang('Delete all existing accounts from SQL database'));
149
-		$setup_tpl->pfp('out','truncate_egw_accounts');
148
+		$setup_tpl->pfp('out', 'truncate_egw_accounts');
150 149
 	}
151
-	$setup_tpl->pfp('out','submit');
152
-	$setup_tpl->pfp('out','footer');
150
+	$setup_tpl->pfp('out', 'submit');
151
+	$setup_tpl->pfp('out', 'footer');
153 152
 }
154 153
 else	// do the migration
155 154
 {
156 155
 	$cmd->only = (array)$_POST['users'];
157 156
 	if (empty($_POST['passwords2sql'])) $cmd->only = array_merge($cmd->only, (array)$_POST['groups']);
158 157
 	$cmd->verbose = true;
159
-	echo '<p align="center">'.str_replace("\n","</p>\n<p align='center'>",$cmd->run())."</p>\n";
158
+	echo '<p align="center">'.str_replace("\n", "</p>\n<p align='center'>", $cmd->run())."</p>\n";
160 159
 
161 160
 	// store new repostory (and auth_type), as we are migrated now
162 161
 	if ($_POST['migrate'])
163 162
 	{
164
-		config::save_value('account_repository', $GLOBALS['egw_info']['server']['account_repository']=$to, 'phpgwapi');
163
+		config::save_value('account_repository', $GLOBALS['egw_info']['server']['account_repository'] = $to, 'phpgwapi');
165 164
 		if (empty($GLOBALS['egw_info']['server']['auth_type']) || $GLOBALS['egw_info']['server']['auth_type'] == $from)
166 165
 		{
167
-			config::save_value('auth_type', $GLOBALS['egw_info']['server']['auth_type']=$to, 'phpgwapi');
166
+			config::save_value('auth_type', $GLOBALS['egw_info']['server']['auth_type'] = $to, 'phpgwapi');
168 167
 		}
169 168
 	}
170 169
 	echo '<p align="center">'.lang('Click <a href="index.php">here</a> to return to setup.')."</p>\n";
Please login to merge, or discard this patch.