@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $setup_info['admin']['name'] = 'admin'; |
13 | 13 | $setup_info['admin']['version'] = '16.1'; |
14 | 14 | $setup_info['admin']['app_order'] = 1; |
15 | -$setup_info['admin']['tables'] = array('egw_admin_queue','egw_admin_remote'); |
|
15 | +$setup_info['admin']['tables'] = array('egw_admin_queue', 'egw_admin_remote'); |
|
16 | 16 | $setup_info['admin']['enable'] = 1; |
17 | -$setup_info['admin']['index'] = 'admin.admin_ui.index&ajax=true'; |
|
17 | +$setup_info['admin']['index'] = 'admin.admin_ui.index&ajax=true'; |
|
18 | 18 | |
19 | 19 | $setup_info['admin']['author'][] = array( |
20 | 20 | 'name' => 'eGroupWare coreteam', |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'url' => 'www.egroupware.org' |
28 | 28 | ); |
29 | 29 | |
30 | -$setup_info['admin']['license'] = 'GPL'; |
|
30 | +$setup_info['admin']['license'] = 'GPL'; |
|
31 | 31 | $setup_info['admin']['description'] = 'EGroupware administration application'; |
32 | 32 | |
33 | 33 | /* The hooks this app includes, needed for hooks registration */ |
@@ -27,5 +27,5 @@ |
||
27 | 27 | /* Dependencies for this app to work */ |
28 | 28 | $setup_info['home']['depends'][] = array( |
29 | 29 | 'appname' => 'api', |
30 | - 'versions' => Array('16.1') |
|
30 | + 'versions' => array('16.1') |
|
31 | 31 | ); |
@@ -15,37 +15,37 @@ |
||
15 | 15 | $phpgw_baseline = array( |
16 | 16 | 'egw_admin_queue' => array( |
17 | 17 | 'fd' => array( |
18 | - 'cmd_id' => array('type' => 'auto','nullable' => False), |
|
19 | - 'cmd_uid' => array('type' => 'ascii','precision' => '64','nullable' => False), |
|
20 | - 'cmd_creator' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False), |
|
21 | - 'cmd_creator_email' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
22 | - 'cmd_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False), |
|
23 | - 'cmd_type' => array('type' => 'ascii','precision' => '32','nullable' => False,'default' => 'admin_cmd'), |
|
24 | - 'cmd_status' => array('type' => 'int','precision' => '1'), |
|
25 | - 'cmd_scheduled' => array('type' => 'int','meta' => 'timestamp','precision' => '8'), |
|
26 | - 'cmd_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8'), |
|
27 | - 'cmd_modifier' => array('type' => 'int','meta' => 'user','precision' => '4'), |
|
28 | - 'cmd_modifier_email' => array('type' => 'varchar','precision' => '128'), |
|
29 | - 'cmd_error' => array('type' => 'varchar','precision' => '255'), |
|
30 | - 'cmd_errno' => array('type' => 'int','precision' => '4'), |
|
31 | - 'cmd_requested' => array('type' => 'int','precision' => '4'), |
|
32 | - 'cmd_requested_email' => array('type' => 'varchar','precision' => '128'), |
|
33 | - 'cmd_comment' => array('type' => 'varchar','precision' => '255'), |
|
34 | - 'cmd_data' => array('type' => 'ascii','precision' => '16384'), |
|
35 | - 'remote_id' => array('type' => 'int','precision' => '4') |
|
18 | + 'cmd_id' => array('type' => 'auto', 'nullable' => False), |
|
19 | + 'cmd_uid' => array('type' => 'ascii', 'precision' => '64', 'nullable' => False), |
|
20 | + 'cmd_creator' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False), |
|
21 | + 'cmd_creator_email' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
22 | + 'cmd_created' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False), |
|
23 | + 'cmd_type' => array('type' => 'ascii', 'precision' => '32', 'nullable' => False, 'default' => 'admin_cmd'), |
|
24 | + 'cmd_status' => array('type' => 'int', 'precision' => '1'), |
|
25 | + 'cmd_scheduled' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8'), |
|
26 | + 'cmd_modified' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8'), |
|
27 | + 'cmd_modifier' => array('type' => 'int', 'meta' => 'user', 'precision' => '4'), |
|
28 | + 'cmd_modifier_email' => array('type' => 'varchar', 'precision' => '128'), |
|
29 | + 'cmd_error' => array('type' => 'varchar', 'precision' => '255'), |
|
30 | + 'cmd_errno' => array('type' => 'int', 'precision' => '4'), |
|
31 | + 'cmd_requested' => array('type' => 'int', 'precision' => '4'), |
|
32 | + 'cmd_requested_email' => array('type' => 'varchar', 'precision' => '128'), |
|
33 | + 'cmd_comment' => array('type' => 'varchar', 'precision' => '255'), |
|
34 | + 'cmd_data' => array('type' => 'ascii', 'precision' => '16384'), |
|
35 | + 'remote_id' => array('type' => 'int', 'precision' => '4') |
|
36 | 36 | ), |
37 | 37 | 'pk' => array('cmd_id'), |
38 | 38 | 'fk' => array(), |
39 | - 'ix' => array('cmd_status','cmd_scheduled'), |
|
39 | + 'ix' => array('cmd_status', 'cmd_scheduled'), |
|
40 | 40 | 'uc' => array('cmd_uid') |
41 | 41 | ), |
42 | 42 | 'egw_admin_remote' => array( |
43 | 43 | 'fd' => array( |
44 | - 'remote_id' => array('type' => 'auto','nullable' => False), |
|
45 | - 'remote_name' => array('type' => 'varchar','precision' => '64','nullable' => False), |
|
46 | - 'remote_hash' => array('type' => 'ascii','precision' => '32','nullable' => False), |
|
47 | - 'remote_url' => array('type' => 'ascii','precision' => '128','nullable' => False), |
|
48 | - 'remote_domain' => array('type' => 'ascii','precision' => '64','nullable' => False) |
|
44 | + 'remote_id' => array('type' => 'auto', 'nullable' => False), |
|
45 | + 'remote_name' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False), |
|
46 | + 'remote_hash' => array('type' => 'ascii', 'precision' => '32', 'nullable' => False), |
|
47 | + 'remote_url' => array('type' => 'ascii', 'precision' => '128', 'nullable' => False), |
|
48 | + 'remote_domain' => array('type' => 'ascii', 'precision' => '64', 'nullable' => False) |
|
49 | 49 | ), |
50 | 50 | 'pk' => array('remote_id'), |
51 | 51 | 'fk' => array(), |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | |
21 | 21 | function admin_upgrade1_4() |
22 | 22 | { |
23 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_queue',array( |
|
23 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_queue', array( |
|
24 | 24 | 'fd' => array( |
25 | 25 | 'cmd_id' => array('type' => 'auto'), |
26 | - 'cmd_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
27 | - 'cmd_creator' => array('type' => 'int','precision' => '4','nullable' => False), |
|
28 | - 'cmd_creator_email' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
29 | - 'cmd_created' => array('type' => 'int','precision' => '8','nullable' => False), |
|
30 | - 'cmd_type' => array('type' => 'varchar','precision' => '32','nullable' => False,'default' => 'admin_cmd'), |
|
31 | - 'cmd_status' => array('type' => 'int','precision' => '1'), |
|
32 | - 'cmd_scheduled' => array('type' => 'int','precision' => '8'), |
|
33 | - 'cmd_modified' => array('type' => 'int','precision' => '8'), |
|
34 | - 'cmd_modifier' => array('type' => 'int','precision' => '4'), |
|
35 | - 'cmd_modifier_email' => array('type' => 'varchar','precision' => '128'), |
|
36 | - 'cmd_error' => array('type' => 'varchar','precision' => '255'), |
|
37 | - 'cmd_errno' => array('type' => 'int','precision' => '4'), |
|
38 | - 'cmd_requested' => array('type' => 'int','precision' => '4'), |
|
39 | - 'cmd_requested_email' => array('type' => 'varchar','precision' => '128'), |
|
40 | - 'cmd_comment' => array('type' => 'varchar','precision' => '255'), |
|
26 | + 'cmd_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
27 | + 'cmd_creator' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
28 | + 'cmd_creator_email' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
29 | + 'cmd_created' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
30 | + 'cmd_type' => array('type' => 'varchar', 'precision' => '32', 'nullable' => False, 'default' => 'admin_cmd'), |
|
31 | + 'cmd_status' => array('type' => 'int', 'precision' => '1'), |
|
32 | + 'cmd_scheduled' => array('type' => 'int', 'precision' => '8'), |
|
33 | + 'cmd_modified' => array('type' => 'int', 'precision' => '8'), |
|
34 | + 'cmd_modifier' => array('type' => 'int', 'precision' => '4'), |
|
35 | + 'cmd_modifier_email' => array('type' => 'varchar', 'precision' => '128'), |
|
36 | + 'cmd_error' => array('type' => 'varchar', 'precision' => '255'), |
|
37 | + 'cmd_errno' => array('type' => 'int', 'precision' => '4'), |
|
38 | + 'cmd_requested' => array('type' => 'int', 'precision' => '4'), |
|
39 | + 'cmd_requested_email' => array('type' => 'varchar', 'precision' => '128'), |
|
40 | + 'cmd_comment' => array('type' => 'varchar', 'precision' => '255'), |
|
41 | 41 | 'cmd_data' => array('type' => 'blob') |
42 | 42 | ), |
43 | 43 | 'pk' => array('cmd_id'), |
44 | 44 | 'fk' => array(), |
45 | - 'ix' => array('cmd_status','cmd_scheduled'), |
|
45 | + 'ix' => array('cmd_status', 'cmd_scheduled'), |
|
46 | 46 | 'uc' => array('cmd_uid') |
47 | 47 | )); |
48 | 48 | return $GLOBALS['setup_info']['admin']['currentver'] = '1.5.001'; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | |
52 | 52 | function admin_upgrade1_5_001() |
53 | 53 | { |
54 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_remote',array( |
|
54 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_remote', array( |
|
55 | 55 | 'fd' => array( |
56 | 56 | 'remote_id' => array('type' => 'auto'), |
57 | - 'remote_name' => array('type' => 'varchar','precision' => '64','nullable' => False), |
|
58 | - 'remote_hash' => array('type' => 'varchar','precision' => '32','nullable' => False), |
|
59 | - 'remote_url' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
60 | - 'remote_domain' => array('type' => 'varchar','precision' => '64','nullable' => False) |
|
57 | + 'remote_name' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False), |
|
58 | + 'remote_hash' => array('type' => 'varchar', 'precision' => '32', 'nullable' => False), |
|
59 | + 'remote_url' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
60 | + 'remote_domain' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False) |
|
61 | 61 | ), |
62 | 62 | 'pk' => array('remote_id'), |
63 | 63 | 'fk' => array(), |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | function admin_upgrade1_5_002() |
73 | 73 | { |
74 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue','remote_id',array( |
|
74 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue', 'remote_id', array( |
|
75 | 75 | 'type' => 'int', |
76 | 76 | 'precision' => '4' |
77 | 77 | )); |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | |
111 | 111 | function admin_upgrade14_1() |
112 | 112 | { |
113 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_uid',array( |
|
113 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_uid', array( |
|
114 | 114 | 'type' => 'ascii', |
115 | 115 | 'precision' => '64', |
116 | 116 | 'nullable' => False |
117 | 117 | )); |
118 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_type',array( |
|
118 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_type', array( |
|
119 | 119 | 'type' => 'ascii', |
120 | 120 | 'precision' => '32', |
121 | 121 | 'nullable' => False, |
122 | 122 | 'default' => 'admin_cmd' |
123 | 123 | )); |
124 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_data',array( |
|
124 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_data', array( |
|
125 | 125 | 'type' => 'ascii', |
126 | 126 | 'precision' => '16384' |
127 | 127 | )); |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | |
133 | 133 | function admin_upgrade14_2_001() |
134 | 134 | { |
135 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_hash',array( |
|
135 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_hash', array( |
|
136 | 136 | 'type' => 'ascii', |
137 | 137 | 'precision' => '32', |
138 | 138 | 'nullable' => False |
139 | 139 | )); |
140 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_url',array( |
|
140 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_url', array( |
|
141 | 141 | 'type' => 'ascii', |
142 | 142 | 'precision' => '128', |
143 | 143 | 'nullable' => False |
144 | 144 | )); |
145 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_domain',array( |
|
145 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_domain', array( |
|
146 | 146 | 'type' => 'ascii', |
147 | 147 | 'precision' => '64', |
148 | 148 | 'nullable' => False |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | // asuming everythings not MySQL uses PostgreSQL regular expression syntax |
162 | 162 | $regexp = substr($GLOBALS['egw_setup']->db->Type, 0, 5) == 'mysql' ? 'REGEXP' : '~*'; |
163 | 163 | |
164 | - foreach($GLOBALS['egw_setup']->db->select('egw_admin_queue', 'cmd_id,cmd_data', |
|
164 | + foreach ($GLOBALS['egw_setup']->db->select('egw_admin_queue', 'cmd_id,cmd_data', |
|
165 | 165 | 'cmd_status NOT IN ('.implode(',', admin_cmd::$require_pw_stati).") AND cmd_data $regexp '(pw|passwd\\_?\\d*|password|db\\_pass)\\?\"'", |
166 | 166 | __LINE__, __FILE__, false, '', 'admin') as $row) |
167 | 167 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @var array |
90 | 90 | */ |
91 | 91 | public static $ssl_types = array( |
92 | - self::SSL_TLS => 'TLS', // SSL with minimum TLS (no SSL v.2 or v.3), requires Horde_Imap_Client-2.16.0/Horde_Socket_Client-1.1.0 |
|
92 | + self::SSL_TLS => 'TLS', // SSL with minimum TLS (no SSL v.2 or v.3), requires Horde_Imap_Client-2.16.0/Horde_Socket_Client-1.1.0 |
|
93 | 93 | self::SSL_SSL => 'SSL', |
94 | 94 | self::SSL_STARTTLS => 'STARTTLS', |
95 | 95 | 'no' => 'no', |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public static $ssl2secure = array( |
103 | 103 | 'SSL' => 'ssl', |
104 | 104 | 'STARTTLS' => 'tls', |
105 | - 'TLS' => 'tlsv1', // SSL with minimum TLS (no SSL v.2 or v.3), requires Horde_Imap_Client-2.16.0/Horde_Socket_Client-1.1.0 |
|
105 | + 'TLS' => 'tlsv1', // SSL with minimum TLS (no SSL v.2 or v.3), requires Horde_Imap_Client-2.16.0/Horde_Socket_Client-1.1.0 |
|
106 | 106 | ); |
107 | 107 | /** |
108 | 108 | * Convert ssl-type to eMailAdmin acc_(imap|sieve|smtp)_ssl integer value |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param array $content |
169 | 169 | * @param type $msg |
170 | 170 | */ |
171 | - public function add(array $content=array(), $msg='', $msg_type='success') |
|
171 | + public function add(array $content = array(), $msg = '', $msg_type = 'success') |
|
172 | 172 | { |
173 | 173 | // otherwise we cant switch to ckeditor in edit |
174 | 174 | Api\Html\CkEditorConfig::set_csp_script_src_attrs(); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | if ($content['button'] && key($content['button']) == 'skip_imap') |
209 | 209 | { |
210 | 210 | unset($content['button']); |
211 | - if (!isset($content['acc_smtp_host'])) $content['acc_smtp_host'] = ''; // do manual mode right away |
|
211 | + if (!isset($content['acc_smtp_host'])) $content['acc_smtp_host'] = ''; // do manual mode right away |
|
212 | 212 | return $this->smtp($content, lang('Skipping IMAP configuration!')); |
213 | 213 | } |
214 | 214 | $content['output'] = ''; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | if (!empty($content['acc_imap_host'])) |
223 | 223 | { |
224 | 224 | $hosts = array($content['acc_imap_host'] => true); |
225 | - if ($content['acc_imap_port'] > 0 && !in_array($content['acc_imap_port'], array(143,993))) |
|
225 | + if ($content['acc_imap_port'] > 0 && !in_array($content['acc_imap_port'], array(143, 993))) |
|
226 | 226 | { |
227 | 227 | $ssl_type = (string)array_search($content['acc_imap_ssl'], self::$ssl2type); |
228 | 228 | if ($ssl_type === '') $ssl_type = 'insecure'; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $content['ispdb'] = $ispdb; |
237 | 237 | $content['output'] .= lang('Using data from Mozilla ISPDB for provider %1', $ispdb['displayName'])."\n"; |
238 | 238 | $hosts = array(); |
239 | - foreach($ispdb['imap'] as $server) |
|
239 | + foreach ($ispdb['imap'] as $server) |
|
240 | 240 | { |
241 | 241 | if (!isset($hosts[$server['hostname']])) |
242 | 242 | { |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | // iterate over all hosts and try to connect |
263 | - foreach($hosts as $host => $data) |
|
263 | + foreach ($hosts as $host => $data) |
|
264 | 264 | { |
265 | 265 | $content['acc_imap_host'] = $host; |
266 | 266 | // by default we check SSL, STARTTLS and at last an insecure connection |
267 | 267 | if (!is_array($data)) $data = array('TLS' => 993, 'SSL' => 993, 'STARTTLS' => 143, 'insecure' => 143); |
268 | 268 | |
269 | - foreach($data as $ssl => $port) |
|
269 | + foreach ($data as $ssl => $port) |
|
270 | 270 | { |
271 | 271 | if ($ssl === 'username') continue; |
272 | 272 | |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | $content['connected'] = $connected = true; |
292 | 292 | break 2; |
293 | 293 | } |
294 | - catch(Horde_Imap_Client_Exception $e) |
|
294 | + catch (Horde_Imap_Client_Exception $e) |
|
295 | 295 | { |
296 | - switch($e->getCode()) |
|
296 | + switch ($e->getCode()) |
|
297 | 297 | { |
298 | 298 | case Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED: |
299 | 299 | $content['output'] .= "\n".$e->getMessage()."\n"; |
300 | - break 3; // no need to try other SSL or non-SSL connections, if auth failed |
|
300 | + break 3; // no need to try other SSL or non-SSL connections, if auth failed |
|
301 | 301 | |
302 | 302 | case Horde_Imap_Client_Exception::SERVER_CONNECT: |
303 | 303 | $content['output'] .= "\n".$e->getMessage()."\n"; |
304 | - if ($ssl == 'STARTTLS') break 2; // no need to try insecure connection on same port |
|
304 | + if ($ssl == 'STARTTLS') break 2; // no need to try insecure connection on same port |
|
305 | 305 | break; |
306 | 306 | |
307 | 307 | default: |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | } |
311 | 311 | if (self::$debug) _egw_log_exception($e); |
312 | 312 | } |
313 | - catch(Exception $e) { |
|
313 | + catch (Exception $e) { |
|
314 | 314 | $content['output'] .= "\n".get_class($e).': '.$e->getMessage().' ('.$e->getCode().')'."\n"; |
315 | 315 | //$content['output'] .= $e->getTraceAsString()."\n"; |
316 | 316 | if (self::$debug) _egw_log_exception($e); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | // add validation error, if we can identify a field |
327 | 327 | if (!$connected && $e instanceof Horde_Imap_Client_Exception) |
328 | 328 | { |
329 | - switch($e->getCode()) |
|
329 | + switch ($e->getCode()) |
|
330 | 330 | { |
331 | 331 | case Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED: |
332 | 332 | Etemplate::set_validation_error('acc_imap_username', lang($e->getMessage())); |
@@ -352,13 +352,13 @@ discard block |
||
352 | 352 | * @param string $msg ='' |
353 | 353 | * @param Horde_Imap_Client_Socket $imap =null |
354 | 354 | */ |
355 | - public function folder(array $content, $msg='', Horde_Imap_Client_Socket $imap=null) |
|
355 | + public function folder(array $content, $msg = '', Horde_Imap_Client_Socket $imap = null) |
|
356 | 356 | { |
357 | 357 | if (isset($content['button'])) |
358 | 358 | { |
359 | 359 | list($button) = each($content['button']); |
360 | 360 | unset($content['button']); |
361 | - switch($button) |
|
361 | + switch ($button) |
|
362 | 362 | { |
363 | 363 | case 'back': |
364 | 364 | return $this->add($content); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | } |
369 | 369 | } |
370 | 370 | $content['msg'] = $msg; |
371 | - if (!isset($imap)) $imap = self::imap_client ($content); |
|
371 | + if (!isset($imap)) $imap = self::imap_client($content); |
|
372 | 372 | |
373 | 373 | try { |
374 | 374 | //_debug_array($content); |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $sel_options['acc_folder_draft'] = $sel_options['acc_folder_template'] = |
377 | 377 | $sel_options['acc_folder_junk'] = $sel_options['acc_folder_archive'] = self::mailboxes($imap, $content); |
378 | 378 | } |
379 | - catch(Exception $e) { |
|
379 | + catch (Exception $e) { |
|
380 | 380 | $content['msg'] = $e->getMessage(); |
381 | 381 | if (self::$debug) _egw_log_exception($e); |
382 | 382 | } |
@@ -393,27 +393,27 @@ discard block |
||
393 | 393 | * @return array with folders as key AND value |
394 | 394 | * @throws Horde_Imap_Client_Exception |
395 | 395 | */ |
396 | - public static function mailboxes(Horde_Imap_Client_Socket $imap, array &$content=null) |
|
396 | + public static function mailboxes(Horde_Imap_Client_Socket $imap, array &$content = null) |
|
397 | 397 | { |
398 | 398 | // query all subscribed mailboxes |
399 | 399 | $mailboxes = $imap->listMailboxes('*', Horde_Imap_Client::MBOX_SUBSCRIBED, array( |
400 | 400 | 'special_use' => true, |
401 | - 'attributes' => true, // otherwise special_use is only queried, but not returned ;-) |
|
401 | + 'attributes' => true, // otherwise special_use is only queried, but not returned ;-) |
|
402 | 402 | 'delimiter' => true, |
403 | 403 | )); |
404 | 404 | //_debug_array($mailboxes); |
405 | 405 | // list mailboxes by special-use attributes |
406 | 406 | $folders = $attributes = $all = array(); |
407 | - foreach($mailboxes as $mailbox => $data) |
|
407 | + foreach ($mailboxes as $mailbox => $data) |
|
408 | 408 | { |
409 | - foreach($data['attributes'] as $attribute) |
|
409 | + foreach ($data['attributes'] as $attribute) |
|
410 | 410 | { |
411 | 411 | $attributes[$attribute][] = $mailbox; |
412 | 412 | } |
413 | 413 | $folders[$mailbox] = $mailbox.': '.implode(', ', $data['attributes']); |
414 | 414 | } |
415 | 415 | // pre-select send, trash, ... folder for user, by checking special-use attributes or common name(s) |
416 | - foreach(array( |
|
416 | + foreach (array( |
|
417 | 417 | 'acc_folder_sent' => array('\\sent', 'sent'), |
418 | 418 | 'acc_folder_trash' => array('\\trash', 'trash'), |
419 | 419 | 'acc_folder_draft' => array('\\drafts', 'drafts'), |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | // first check special-use attributes |
426 | 426 | if (($special_use = array_shift($common_names))) |
427 | 427 | { |
428 | - foreach((array)$attributes[$special_use] as $mailbox) |
|
428 | + foreach ((array)$attributes[$special_use] as $mailbox) |
|
429 | 429 | { |
430 | 430 | if (empty($content[$name]) || strlen($mailbox) < strlen($content[$name])) |
431 | 431 | { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | // no special use folder found, try common names |
437 | 437 | if (empty($content[$name])) |
438 | 438 | { |
439 | - foreach($mailboxes as $mailbox => $data) |
|
439 | + foreach ($mailboxes as $mailbox => $data) |
|
440 | 440 | { |
441 | 441 | $delimiter = !empty($data['delimiter']) ? $data['delimiter'] : '.'; |
442 | 442 | $name_parts = explode($delimiter, strtolower($mailbox)); |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param array $content |
464 | 464 | * @param string $msg ='' |
465 | 465 | */ |
466 | - public function sieve(array $content, $msg='') |
|
466 | + public function sieve(array $content, $msg = '') |
|
467 | 467 | { |
468 | 468 | static $sieve_ssl2port = array( |
469 | 469 | self::SSL_TLS => 5190, |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | { |
478 | 478 | list($button) = each($content['button']); |
479 | 479 | unset($content['button']); |
480 | - switch($button) |
|
480 | + switch ($button) |
|
481 | 481 | { |
482 | 482 | case 'back': |
483 | 483 | return $this->folder($content); |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | { |
527 | 527 | $data = $sieve_ssl2port; |
528 | 528 | } |
529 | - foreach($data as $ssl => $ports) |
|
529 | + foreach ($data as $ssl => $ports) |
|
530 | 530 | { |
531 | - foreach((array)$ports as $port) |
|
531 | + foreach ((array)$ports as $port) |
|
532 | 532 | { |
533 | 533 | $content['acc_sieve_ssl'] = $ssl; |
534 | 534 | $ssl_label = self::$ssl_types[$ssl]; |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | )); |
547 | 547 | // connect to sieve server |
548 | 548 | $sieve->connect(); |
549 | - $content['sieve_output'] .= "\n".lang('Successful connected to %1 server%2.', 'Sieve',''); |
|
549 | + $content['sieve_output'] .= "\n".lang('Successful connected to %1 server%2.', 'Sieve', ''); |
|
550 | 550 | // and log in |
551 | 551 | $sieve->login($content['acc_imap_username'], $content['acc_imap_password']); |
552 | 552 | $content['sieve_output'] .= ' '.lang('and logged in')."\n"; |
@@ -556,10 +556,10 @@ discard block |
||
556 | 556 | return $this->smtp($content, lang('Successful connected to %1 server%2.', 'Sieve', |
557 | 557 | ' '.lang('and logged in'))); |
558 | 558 | } |
559 | - catch(Horde\ManageSieve\Exception\ConnectionFailed $e) { |
|
559 | + catch (Horde\ManageSieve\Exception\ConnectionFailed $e) { |
|
560 | 560 | $content['sieve_output'] .= "\n".$e->getMessage().' '.$e->details."\n"; |
561 | 561 | } |
562 | - catch(Exception $e) { |
|
562 | + catch (Exception $e) { |
|
563 | 563 | $content['sieve_output'] .= "\n".get_class($e).': '.$e->getMessage(). |
564 | 564 | ($e->details ? ' '.$e->details : '').' ('.$e->getCode().')'."\n"; |
565 | 565 | $content['sieve_output'] .= $e->getTraceAsString()."\n"; |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | // add validation error, if we can identify a field |
578 | 578 | if (!$content['sieve_connected'] && $e instanceof Exception) |
579 | 579 | { |
580 | - switch($e->getCode()) |
|
580 | + switch ($e->getCode()) |
|
581 | 581 | { |
582 | 582 | case 61: // connection refused |
583 | 583 | case 60: // connection timed out (imap.googlemail.com returns that for none-ssl/4190/2000) |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @param array $content |
601 | 601 | * @param string $msg ='' |
602 | 602 | */ |
603 | - public function smtp(array $content, $msg='') |
|
603 | + public function smtp(array $content, $msg = '') |
|
604 | 604 | { |
605 | 605 | static $smtp_ssl2port = array( |
606 | 606 | self::SSL_NONE => 25, |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | { |
615 | 615 | list($button) = each($content['button']); |
616 | 616 | unset($content['button']); |
617 | - switch($button) |
|
617 | + switch ($button) |
|
618 | 618 | { |
619 | 619 | case 'back': |
620 | 620 | return $this->sieve($content); |
@@ -655,11 +655,11 @@ discard block |
||
655 | 655 | ); |
656 | 656 | } |
657 | 657 | } |
658 | - elseif($content['ispdb'] && !empty($content['ispdb']['smtp'])) |
|
658 | + elseif ($content['ispdb'] && !empty($content['ispdb']['smtp'])) |
|
659 | 659 | { |
660 | 660 | $content['smtp_output'] .= lang('Using data from Mozilla ISPDB for provider %1', $content['ispdb']['displayName'])."\n"; |
661 | 661 | $hosts = array(); |
662 | - foreach($content['ispdb']['smtp'] as $server) |
|
662 | + foreach ($content['ispdb']['smtp'] as $server) |
|
663 | 663 | { |
664 | 664 | if (!isset($hosts[$server['hostname']])) |
665 | 665 | { |
@@ -681,14 +681,14 @@ discard block |
||
681 | 681 | { |
682 | 682 | $hosts = $this->guess_hosts($content['ident_email'], 'smtp'); |
683 | 683 | } |
684 | - foreach($hosts as $host => $data) |
|
684 | + foreach ($hosts as $host => $data) |
|
685 | 685 | { |
686 | 686 | $content['acc_smtp_host'] = $host; |
687 | 687 | if (!is_array($data)) |
688 | 688 | { |
689 | 689 | $data = array('TLS' => 465, 'SSL' => 465, 'STARTTLS' => 587, '' => 25); |
690 | 690 | } |
691 | - foreach($data as $ssl => $port) |
|
691 | + foreach ($data as $ssl => $port) |
|
692 | 692 | { |
693 | 693 | if ($ssl === 'username') continue; |
694 | 694 | |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | $content['smtp_output'] .= "\n".Api\DateTime::to('now', 'H:i:s').": Trying $ssl connection to $host:$port ...\n"; |
700 | 700 | $content['acc_smtp_port'] = $port; |
701 | 701 | |
702 | - $mail = new Horde_Mail_Transport_Smtphorde($params=array( |
|
702 | + $mail = new Horde_Mail_Transport_Smtphorde($params = array( |
|
703 | 703 | 'username' => $content['acc_smtp_username'], |
704 | 704 | 'password' => $content['acc_smtp_password'], |
705 | 705 | 'host' => $content['acc_smtp_host'], |
@@ -739,9 +739,9 @@ discard block |
||
739 | 739 | } |
740 | 740 | // unfortunately LOGIN_AUTHENTICATIONFAILED and SERVER_CONNECT are thrown as Horde_Mail_Exception |
741 | 741 | // while others are thrown as Horde_Smtp_Exception --> using common base Horde_Exception_Wrapped |
742 | - catch(Horde_Exception_Wrapped $e) |
|
742 | + catch (Horde_Exception_Wrapped $e) |
|
743 | 743 | { |
744 | - switch($e->getCode()) |
|
744 | + switch ($e->getCode()) |
|
745 | 745 | { |
746 | 746 | case Horde_Smtp_Exception::LOGIN_AUTHENTICATIONFAILED: |
747 | 747 | case Horde_Smtp_Exception::LOGIN_REQUIREAUTHENTICATION: |
@@ -757,14 +757,14 @@ discard block |
||
757 | 757 | } |
758 | 758 | if (self::$debug) _egw_log_exception($e); |
759 | 759 | } |
760 | - catch(Horde_Smtp_Exception $e) |
|
760 | + catch (Horde_Smtp_Exception $e) |
|
761 | 761 | { |
762 | 762 | // prever $e->details over $e->getMessage() as it contains original message from SMTP server (eg. relay access denied) |
763 | 763 | $content['smtp_output'] .= "\n".(empty($e->details) ? $e->getMessage().' ('.$e->getCode().')' : $e->details)."\n"; |
764 | 764 | //$content['smtp_output'] .= $e->getTraceAsString()."\n"; |
765 | 765 | if (self::$debug) _egw_log_exception($e); |
766 | 766 | } |
767 | - catch(Exception $e) { |
|
767 | + catch (Exception $e) { |
|
768 | 768 | $content['smtp_output'] .= "\n".get_class($e).': '.$e->getMessage().' ('.$e->getCode().')'."\n"; |
769 | 769 | //$content['smtp_output'] .= $e->getTraceAsString()."\n"; |
770 | 770 | if (self::$debug) _egw_log_exception($e); |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | // add validation error, if we can identify a field |
776 | 776 | if (!$content['smtp_connected'] && $e instanceof Horde_Exception_Wrapped) |
777 | 777 | { |
778 | - switch($e->getCode()) |
|
778 | + switch ($e->getCode()) |
|
779 | 779 | { |
780 | 780 | case Horde_Smtp_Exception::LOGIN_AUTHENTICATIONFAILED: |
781 | 781 | case Horde_Smtp_Exception::LOGIN_REQUIREAUTHENTICATION: |
@@ -809,14 +809,14 @@ discard block |
||
809 | 809 | * @param string $msg ='' |
810 | 810 | * @param string $msg_type ='success' |
811 | 811 | */ |
812 | - public function edit(array $content=null, $msg='', $msg_type='success') |
|
812 | + public function edit(array $content = null, $msg = '', $msg_type = 'success') |
|
813 | 813 | { |
814 | 814 | // app is trying to tell something, while redirecting to wizard |
815 | - if (empty($content) && $_GET['acc_id'] && empty($msg) && !empty( $_GET['msg'])) |
|
815 | + if (empty($content) && $_GET['acc_id'] && empty($msg) && !empty($_GET['msg'])) |
|
816 | 816 | { |
817 | - if (stripos($_GET['msg'],'fatal error:')!==false || $_GET['msg_type'] == 'error') $msg_type = 'error'; |
|
817 | + if (stripos($_GET['msg'], 'fatal error:') !== false || $_GET['msg_type'] == 'error') $msg_type = 'error'; |
|
818 | 818 | } |
819 | - if ($content['acc_id'] || (isset($_GET['acc_id']) && (int)$_GET['acc_id'] > 0) ) Mail::unsetCachedObjects($content['acc_id']?$content['acc_id']:$_GET['acc_id']); |
|
819 | + if ($content['acc_id'] || (isset($_GET['acc_id']) && (int)$_GET['acc_id'] > 0)) Mail::unsetCachedObjects($content['acc_id'] ? $content['acc_id'] : $_GET['acc_id']); |
|
820 | 820 | $tpl = new Etemplate('admin.mailaccount'); |
821 | 821 | |
822 | 822 | if (!is_array($content) || !empty($content['acc_id']) && isset($content['old_acc_id']) && $content['acc_id'] != $content['old_acc_id']) |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | list($content['acc_id']) = each($content['accounts']); |
832 | 832 | //error_log(__METHOD__.__LINE__.'.'.array2string($content['acc_id'])); |
833 | 833 | // test if the "to be selected" acccount is imap or not |
834 | - if (count($content['accounts'])>1 && Mail\Account::is_multiple($content['acc_id'])) |
|
834 | + if (count($content['accounts']) > 1 && Mail\Account::is_multiple($content['acc_id'])) |
|
835 | 835 | { |
836 | 836 | try { |
837 | 837 | $account = Mail\Account::read($content['acc_id'], $content['called_for']); |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | //error_log(__METHOD__.__LINE__.'.'.array2string($content['acc_id'])); |
843 | 843 | } |
844 | 844 | } |
845 | - catch(Api\Exception\NotFound $e) { |
|
845 | + catch (Api\Exception\NotFound $e) { |
|
846 | 846 | if (self::$debug) _egw_log_exception($e); |
847 | 847 | } |
848 | 848 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | try { |
866 | 866 | $account = Mail\Account::read($content['acc_id'], $this->is_admin && $content['called_for'] ? |
867 | 867 | $content['called_for'] : $GLOBALS['egw_info']['user']['account_id']); |
868 | - $account->getUserData(); // quota, aliases, forwards etc. |
|
868 | + $account->getUserData(); // quota, aliases, forwards etc. |
|
869 | 869 | $content += $account->params; |
870 | 870 | $content['acc_sieve_enabled'] = (string)($content['acc_sieve_enabled']); |
871 | 871 | $content['notify_use_default'] = !$content['notify_account_id']; |
@@ -876,16 +876,16 @@ discard block |
||
876 | 876 | $content['std_ident_id'] = $content['ident_id']; |
877 | 877 | $content['identities'][$content['std_ident_id']] = lang('Standard identity'); |
878 | 878 | // change self::SSL_NONE (=0) to "no" used in sel_options |
879 | - foreach(array('imap','smtp','sieve') as $type) |
|
879 | + foreach (array('imap', 'smtp', 'sieve') as $type) |
|
880 | 880 | { |
881 | 881 | if (!$content['acc_'.$type.'_ssl']) $content['acc_'.$type.'_ssl'] = 'no'; |
882 | 882 | } |
883 | 883 | } |
884 | - catch(Api\Exception\NotFound $e) { |
|
884 | + catch (Api\Exception\NotFound $e) { |
|
885 | 885 | if (self::$debug) _egw_log_exception($e); |
886 | 886 | Framework::window_close(lang('Account not found!')); |
887 | 887 | } |
888 | - catch(Exception $e) { |
|
888 | + catch (Exception $e) { |
|
889 | 889 | if (self::$debug) _egw_log_exception($e); |
890 | 890 | Framework::window_close($e->getMessage().' ('.get_class($e).': '.$e->getCode().')'); |
891 | 891 | } |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | elseif ($content['acc_id'] === 'new') |
894 | 894 | { |
895 | 895 | $content['account_id'] = $content['called_for']; |
896 | - $content['old_acc_id'] = $content['acc_id']; // to not call add/wizard, if we return from to |
|
896 | + $content['old_acc_id'] = $content['acc_id']; // to not call add/wizard, if we return from to |
|
897 | 897 | unset($content['tabs']); |
898 | 898 | return $this->add($content); |
899 | 899 | } |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | { |
904 | 904 | if (!isset($content['account_id'])) $content['account_id'] = array($GLOBALS['egw_info']['user']['account_id']); |
905 | 905 | $content['acc_user_editable'] = $content['acc_further_identities'] = true; |
906 | - $readonlys['ident_id'] = true; // need to create standard identity first |
|
906 | + $readonlys['ident_id'] = true; // need to create standard identity first |
|
907 | 907 | } |
908 | 908 | if (empty($content['acc_name'])) |
909 | 909 | { |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | { |
940 | 940 | list($button) = each($content['button']); |
941 | 941 | unset($content['button']); |
942 | - switch($button) |
|
942 | + switch ($button) |
|
943 | 943 | { |
944 | 944 | case 'wizard': |
945 | 945 | // if we just came from wizard, go back to last page/step |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | { |
973 | 973 | $content['ident_id'] = Mail\Account::save_identity(array( |
974 | 974 | 'account_id' => $content['called_for'] ? $content['called_for'] : $GLOBALS['egw_info']['user']['account_id'], |
975 | - )+$content); |
|
975 | + ) + $content); |
|
976 | 976 | $content['identities'][$content['ident_id']] = Mail\Account::identity_name($content); |
977 | 977 | $msg = lang('Identity saved.'); |
978 | 978 | if ($edit_access) $msg .= ' '.lang('Switch back to standard identity to save account.'); |
@@ -1076,17 +1076,17 @@ discard block |
||
1076 | 1076 | catch (Horde_Imap_Client_Exception $e) |
1077 | 1077 | { |
1078 | 1078 | _egw_log_exception($e); |
1079 | - $tpl->set_validation_error('acc_imap_admin_username', $msg=lang($e->getMessage())); |
|
1079 | + $tpl->set_validation_error('acc_imap_admin_username', $msg = lang($e->getMessage())); |
|
1080 | 1080 | $msg_type = 'error'; |
1081 | - $content['tabs'] = 'admin.mailaccount.imap'; // should happen automatic |
|
1081 | + $content['tabs'] = 'admin.mailaccount.imap'; // should happen automatic |
|
1082 | 1082 | break; |
1083 | 1083 | } |
1084 | 1084 | catch (Horde\ManageSieve\Exception\ConnectionFailed $e) |
1085 | 1085 | { |
1086 | 1086 | _egw_log_exception($e); |
1087 | - $tpl->set_validation_error('acc_sieve_port', $msg=lang($e->getMessage())); |
|
1087 | + $tpl->set_validation_error('acc_sieve_port', $msg = lang($e->getMessage())); |
|
1088 | 1088 | $msg_type = 'error'; |
1089 | - $content['tabs'] = 'admin.mailaccount.sieve'; // should happen automatic |
|
1089 | + $content['tabs'] = 'admin.mailaccount.sieve'; // should happen automatic |
|
1090 | 1090 | break; |
1091 | 1091 | } |
1092 | 1092 | catch (Exception $e) { |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | $msg_type = 'error'; |
1096 | 1096 | } |
1097 | 1097 | if ($content['acc_id']) Mail::unsetCachedObjects($content['acc_id']); |
1098 | - if (stripos($msg,'fatal error:')!==false) $msg_type = 'error'; |
|
1098 | + if (stripos($msg, 'fatal error:') !== false) $msg_type = 'error'; |
|
1099 | 1099 | Framework::refresh_opener($msg, 'emailadmin', $content['acc_id'], $new_account ? 'add' : 'update', null, null, null, $msg_type); |
1100 | 1100 | if ($button == 'save') Framework::window_close(); |
1101 | 1101 | break; |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | if ($this->is_admin && (empty($content['acc_imap_username']) || empty($content['acc_imap_host']) || $content['called_for'])) |
1149 | 1149 | { |
1150 | 1150 | // cant connection to imap --> allow free entries in taglists |
1151 | - foreach(array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder) |
|
1151 | + foreach (array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder) |
|
1152 | 1152 | { |
1153 | 1153 | $tpl->setElementAttribute($folder, 'allowFreeEntries', true); |
1154 | 1154 | } |
@@ -1159,15 +1159,15 @@ discard block |
||
1159 | 1159 | $sel_options['acc_folder_sent'] = $sel_options['acc_folder_trash'] = |
1160 | 1160 | $sel_options['acc_folder_draft'] = $sel_options['acc_folder_template'] = |
1161 | 1161 | $sel_options['acc_folder_junk'] = $sel_options['acc_folder_archive'] = $sel_options['notify_folders'] = |
1162 | - self::mailboxes(self::imap_client ($content)); |
|
1162 | + self::mailboxes(self::imap_client($content)); |
|
1163 | 1163 | } |
1164 | - catch(Exception $e) { |
|
1164 | + catch (Exception $e) { |
|
1165 | 1165 | if (self::$debug) _egw_log_exception($e); |
1166 | 1166 | // let user know what the problem is and that he can fix it using wizard or deleting |
1167 | 1167 | $msg = lang($e->getMessage())."\n\n".lang('You can use wizard to fix account settings or delete account.'); |
1168 | 1168 | $msg_type = 'error'; |
1169 | 1169 | // cant connection to imap --> allow free entries in taglists |
1170 | - foreach(array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder) |
|
1170 | + foreach (array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder) |
|
1171 | 1171 | { |
1172 | 1172 | $tpl->setElementAttribute($folder, 'allowFreeEntries', true); |
1173 | 1173 | } |
@@ -1264,7 +1264,7 @@ discard block |
||
1264 | 1264 | if ($content['called_for'] && $content['acc_id'] > 0) |
1265 | 1265 | { |
1266 | 1266 | $admin_actions = array(); |
1267 | - foreach(Api\Hooks::process(array( |
|
1267 | + foreach (Api\Hooks::process(array( |
|
1268 | 1268 | 'location' => 'emailadmin_edit', |
1269 | 1269 | 'account_id' => $content['called_for'], |
1270 | 1270 | 'acc_id' => $content['acc_id'], |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | * @param string|array &$account_id on return always array |
1286 | 1286 | * @param boolean $back =false |
1287 | 1287 | */ |
1288 | - private static function fix_account_id_0(&$account_id=null, $back=false) |
|
1288 | + private static function fix_account_id_0(&$account_id = null, $back = false) |
|
1289 | 1289 | { |
1290 | 1290 | if (!isset($account_id)) return; |
1291 | 1291 | |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | { |
1294 | 1294 | $account_id = explode(',', $account_id); |
1295 | 1295 | } |
1296 | - if (($k = array_search($back?'':'0', $account_id)) !== false) |
|
1296 | + if (($k = array_search($back ? '' : '0', $account_id)) !== false) |
|
1297 | 1297 | { |
1298 | 1298 | $account_id[$k] = $back ? '0' : ''; |
1299 | 1299 | } |
@@ -1306,7 +1306,7 @@ discard block |
||
1306 | 1306 | * @param int $timeout =null default use value returned by Mail\Imap::getTimeOut() |
1307 | 1307 | * @return Horde_Imap_Client_Socket |
1308 | 1308 | */ |
1309 | - protected static function imap_client(array $content, $timeout=null) |
|
1309 | + protected static function imap_client(array $content, $timeout = null) |
|
1310 | 1310 | { |
1311 | 1311 | return new Horde_Imap_Client_Socket(array( |
1312 | 1312 | 'username' => $content['acc_imap_username'], |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | protected static function fix_ssl_order($data) |
1329 | 1329 | { |
1330 | 1330 | $ordered = array(); |
1331 | - foreach(array_merge(array('TLS', 'SSL', 'STARTTLS'), array_keys($data)) as $key) |
|
1331 | + foreach (array_merge(array('TLS', 'SSL', 'STARTTLS'), array_keys($data)) as $key) |
|
1332 | 1332 | { |
1333 | 1333 | if (array_key_exists($key, $data)) $ordered[$key] = $data[$key]; |
1334 | 1334 | } |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | * @return array with values for keys 'displayName', 'imap', 'smtp', 'pop3', which each contain |
1347 | 1347 | * array of arrays with values for keys 'hostname', 'port', 'socketType'=(SSL|STARTTLS), 'username'=%EMAILADDRESS% |
1348 | 1348 | */ |
1349 | - protected static function mozilla_ispdb($domain, $try_mx=true) |
|
1349 | + protected static function mozilla_ispdb($domain, $try_mx = true) |
|
1350 | 1350 | { |
1351 | 1351 | if (strpos($domain, '@') !== false) list(,$domain) = explode('@', $domain); |
1352 | 1352 | |
@@ -1357,17 +1357,17 @@ discard block |
||
1357 | 1357 | $provider = array( |
1358 | 1358 | 'displayName' => (string)$xml->emailProvider->displayName, |
1359 | 1359 | ); |
1360 | - foreach($xml->emailProvider->children() as $tag => $server) |
|
1360 | + foreach ($xml->emailProvider->children() as $tag => $server) |
|
1361 | 1361 | { |
1362 | 1362 | if (!in_array($tag, array('incomingServer', 'outgoingServer'))) continue; |
1363 | - foreach($server->attributes() as $name => $value) |
|
1363 | + foreach ($server->attributes() as $name => $value) |
|
1364 | 1364 | { |
1365 | 1365 | if ($name == 'type') $type = (string)$value; |
1366 | 1366 | } |
1367 | 1367 | $data = array(); |
1368 | - foreach($server as $name => $value) |
|
1368 | + foreach ($server as $name => $value) |
|
1369 | 1369 | { |
1370 | - foreach($value->children() as $tag => $val) |
|
1370 | + foreach ($value->children() as $tag => $val) |
|
1371 | 1371 | { |
1372 | 1372 | $data[$name][$tag] = (string)$val; |
1373 | 1373 | } |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | $provider[$type][] = $data; |
1377 | 1377 | } |
1378 | 1378 | } |
1379 | - catch(Exception $e) { |
|
1379 | + catch (Exception $e) { |
|
1380 | 1380 | // ignore own not-found exception or xml parsing execptions |
1381 | 1381 | unset($e); |
1382 | 1382 | |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | * @param string $type ='imap' 'imap' or 'smtp', used as hostname beside 'mail' |
1409 | 1409 | * @return array of hostname => true pairs |
1410 | 1410 | */ |
1411 | - protected function guess_hosts($email, $type='imap') |
|
1411 | + protected function guess_hosts($email, $type = 'imap') |
|
1412 | 1412 | { |
1413 | 1413 | list(,$domain) = explode('@', $email); |
1414 | 1414 | |
@@ -1434,7 +1434,7 @@ discard block |
||
1434 | 1434 | } |
1435 | 1435 | |
1436 | 1436 | // verify hosts in dns |
1437 | - foreach(array_keys($hosts) as $host) |
|
1437 | + foreach (array_keys($hosts) as $host) |
|
1438 | 1438 | { |
1439 | 1439 | if (!dns_get_record($host, DNS_A)) unset($hosts[$host]); |
1440 | 1440 | } |
@@ -1471,12 +1471,12 @@ discard block |
||
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | $ea_account = Mail\Account::read($emailadmin->acc_id, $_data['id']); |
1474 | - if (($userData = $ea_account->getUserData ())) |
|
1474 | + if (($userData = $ea_account->getUserData())) |
|
1475 | 1475 | { |
1476 | 1476 | $userData = array( |
1477 | 1477 | 'acc_smtp_type' => $ea_account->acc_smtp_type, |
1478 | 1478 | 'accountStatus' => $_data['status'], |
1479 | - 'quotaLimit' => $_data['qouta']? $_data['qouta']: $userData['qoutaLimit'], |
|
1479 | + 'quotaLimit' => $_data['qouta'] ? $_data['qouta'] : $userData['qoutaLimit'], |
|
1480 | 1480 | 'mailLocalAddress' => $userData['mailLocalAddress'] |
1481 | 1481 | ); |
1482 | 1482 | |
@@ -1484,7 +1484,7 @@ discard block |
||
1484 | 1484 | { |
1485 | 1485 | $userData['mailLocalAddress'] = preg_replace('/@'.preg_quote($ea_account->acc_domain).'$/', '@'.$_data['domain'], $userData['mailLocalAddress']); |
1486 | 1486 | |
1487 | - foreach($userData['mailAlternateAddress'] as &$alias) |
|
1487 | + foreach ($userData['mailAlternateAddress'] as &$alias) |
|
1488 | 1488 | { |
1489 | 1489 | $alias = preg_replace('/@'.preg_quote($ea_account->acc_domain).'$/', '@'.$_data['domain'], $alias); |
1490 | 1490 | } |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | // fullfill the saveUserData requirements |
1493 | 1493 | $userData += $ea_account->params; |
1494 | 1494 | $ea_account->saveUserData($_data['id'], $userData); |
1495 | - $msg = '#'.$_data['id'].' '.$account['account_fullname']. ' '.($userData['accountStatus'] == 'active'? lang('activated'):lang('deactivated')); |
|
1495 | + $msg = '#'.$_data['id'].' '.$account['account_fullname'].' '.($userData['accountStatus'] == 'active' ? lang('activated') : lang('deactivated')); |
|
1496 | 1496 | } |
1497 | 1497 | else |
1498 | 1498 | { |
@@ -208,7 +208,11 @@ discard block |
||
208 | 208 | if ($content['button'] && key($content['button']) == 'skip_imap') |
209 | 209 | { |
210 | 210 | unset($content['button']); |
211 | - if (!isset($content['acc_smtp_host'])) $content['acc_smtp_host'] = ''; // do manual mode right away |
|
211 | + if (!isset($content['acc_smtp_host'])) |
|
212 | + { |
|
213 | + $content['acc_smtp_host'] = ''; |
|
214 | + } |
|
215 | + // do manual mode right away |
|
212 | 216 | return $this->smtp($content, lang('Skipping IMAP configuration!')); |
213 | 217 | } |
214 | 218 | $content['output'] = ''; |
@@ -225,7 +229,10 @@ discard block |
||
225 | 229 | if ($content['acc_imap_port'] > 0 && !in_array($content['acc_imap_port'], array(143,993))) |
226 | 230 | { |
227 | 231 | $ssl_type = (string)array_search($content['acc_imap_ssl'], self::$ssl2type); |
228 | - if ($ssl_type === '') $ssl_type = 'insecure'; |
|
232 | + if ($ssl_type === '') |
|
233 | + { |
|
234 | + $ssl_type = 'insecure'; |
|
235 | + } |
|
229 | 236 | $hosts[$content['acc_imap_host']] = array( |
230 | 237 | $ssl_type => $content['acc_imap_port'], |
231 | 238 | ); |
@@ -242,10 +249,13 @@ discard block |
||
242 | 249 | { |
243 | 250 | $hosts[$server['hostname']] = array('username' => $server['username']); |
244 | 251 | } |
245 | - if (strtoupper($server['socketType']) == 'SSL') // try TLS first |
|
252 | + if (strtoupper($server['socketType']) == 'SSL') |
|
253 | + { |
|
254 | + // try TLS first |
|
246 | 255 | { |
247 | 256 | $hosts[$server['hostname']]['TLS'] = $server['port']; |
248 | 257 | } |
258 | + } |
|
249 | 259 | $hosts[$server['hostname']][strtoupper($server['socketType'])] = $server['port']; |
250 | 260 | // make sure we prefer SSL over STARTTLS over insecure |
251 | 261 | if (count($hosts[$server['hostname']]) > 2) |
@@ -264,11 +274,17 @@ discard block |
||
264 | 274 | { |
265 | 275 | $content['acc_imap_host'] = $host; |
266 | 276 | // by default we check SSL, STARTTLS and at last an insecure connection |
267 | - if (!is_array($data)) $data = array('TLS' => 993, 'SSL' => 993, 'STARTTLS' => 143, 'insecure' => 143); |
|
277 | + if (!is_array($data)) |
|
278 | + { |
|
279 | + $data = array('TLS' => 993, 'SSL' => 993, 'STARTTLS' => 143, 'insecure' => 143); |
|
280 | + } |
|
268 | 281 | |
269 | 282 | foreach($data as $ssl => $port) |
270 | 283 | { |
271 | - if ($ssl === 'username') continue; |
|
284 | + if ($ssl === 'username') |
|
285 | + { |
|
286 | + continue; |
|
287 | + } |
|
272 | 288 | |
273 | 289 | $content['acc_imap_ssl'] = (int)self::$ssl2type[$ssl]; |
274 | 290 | |
@@ -301,25 +317,38 @@ discard block |
||
301 | 317 | |
302 | 318 | case Horde_Imap_Client_Exception::SERVER_CONNECT: |
303 | 319 | $content['output'] .= "\n".$e->getMessage()."\n"; |
304 | - if ($ssl == 'STARTTLS') break 2; // no need to try insecure connection on same port |
|
320 | + if ($ssl == 'STARTTLS') |
|
321 | + { |
|
322 | + break 2; |
|
323 | + } |
|
324 | + // no need to try insecure connection on same port |
|
305 | 325 | break; |
306 | 326 | |
307 | 327 | default: |
308 | 328 | $content['output'] .= "\n".get_class($e).': '.$e->getMessage().' ('.$e->getCode().')'."\n"; |
309 | 329 | //$content['output'] .= $e->getTraceAsString()."\n"; |
310 | 330 | } |
311 | - if (self::$debug) _egw_log_exception($e); |
|
331 | + if (self::$debug) |
|
332 | + { |
|
333 | + _egw_log_exception($e); |
|
334 | + } |
|
312 | 335 | } |
313 | 336 | catch(Exception $e) { |
314 | 337 | $content['output'] .= "\n".get_class($e).': '.$e->getMessage().' ('.$e->getCode().')'."\n"; |
315 | 338 | //$content['output'] .= $e->getTraceAsString()."\n"; |
316 | - if (self::$debug) _egw_log_exception($e); |
|
339 | + if (self::$debug) |
|
340 | + { |
|
341 | + _egw_log_exception($e); |
|
342 | + } |
|
317 | 343 | } |
318 | 344 | } |
319 | 345 | } |
320 | - if ($connected) // continue with next wizard step: define folders |
|
346 | + if ($connected) |
|
347 | + { |
|
348 | + // continue with next wizard step: define folders |
|
321 | 349 | { |
322 | 350 | unset($content['button']); |
351 | + } |
|
323 | 352 | return $this->folder($content, lang('Successful connected to %1 server%2.', 'IMAP', ' '.lang('and logged in')). |
324 | 353 | ($imap->isSecureConnection() ? '' : "\n".lang('Connection is NOT secure! Everyone can read eg. your credentials.'))); |
325 | 354 | } |
@@ -368,7 +397,10 @@ discard block |
||
368 | 397 | } |
369 | 398 | } |
370 | 399 | $content['msg'] = $msg; |
371 | - if (!isset($imap)) $imap = self::imap_client ($content); |
|
400 | + if (!isset($imap)) |
|
401 | + { |
|
402 | + $imap = self::imap_client ($content); |
|
403 | + } |
|
372 | 404 | |
373 | 405 | try { |
374 | 406 | //_debug_array($content); |
@@ -378,7 +410,10 @@ discard block |
||
378 | 410 | } |
379 | 411 | catch(Exception $e) { |
380 | 412 | $content['msg'] = $e->getMessage(); |
381 | - if (self::$debug) _egw_log_exception($e); |
|
413 | + if (self::$debug) |
|
414 | + { |
|
415 | + _egw_log_exception($e); |
|
416 | + } |
|
382 | 417 | } |
383 | 418 | |
384 | 419 | $tpl = new Etemplate('admin.mailwizard.folder'); |
@@ -503,8 +538,14 @@ discard block |
||
503 | 538 | $readonlys['button[manual]'] = true; |
504 | 539 | } |
505 | 540 | // set default ssl and port |
506 | - if (!isset($content['acc_sieve_ssl'])) list($content['acc_sieve_ssl']) = each(self::$ssl_types); |
|
507 | - if (empty($content['acc_sieve_port'])) $content['acc_sieve_port'] = $sieve_ssl2port[$content['acc_sieve_ssl']]; |
|
541 | + if (!isset($content['acc_sieve_ssl'])) |
|
542 | + { |
|
543 | + list($content['acc_sieve_ssl']) = each(self::$ssl_types); |
|
544 | + } |
|
545 | + if (empty($content['acc_sieve_port'])) |
|
546 | + { |
|
547 | + $content['acc_sieve_port'] = $sieve_ssl2port[$content['acc_sieve_ssl']]; |
|
548 | + } |
|
508 | 549 | |
509 | 550 | // check smtp connection |
510 | 551 | if ($button == 'continue') |
@@ -563,7 +604,10 @@ discard block |
||
563 | 604 | $content['sieve_output'] .= "\n".get_class($e).': '.$e->getMessage(). |
564 | 605 | ($e->details ? ' '.$e->details : '').' ('.$e->getCode().')'."\n"; |
565 | 606 | $content['sieve_output'] .= $e->getTraceAsString()."\n"; |
566 | - if (self::$debug) _egw_log_exception($e); |
|
607 | + if (self::$debug) |
|
608 | + { |
|
609 | + _egw_log_exception($e); |
|
610 | + } |
|
567 | 611 | } |
568 | 612 | } |
569 | 613 | } |
@@ -631,11 +675,23 @@ discard block |
||
631 | 675 | $readonlys['button[manual]'] = true; |
632 | 676 | } |
633 | 677 | // copy username/password from imap |
634 | - if (!isset($content['acc_smtp_username'])) $content['acc_smtp_username'] = $content['acc_imap_username']; |
|
635 | - if (!isset($content['acc_smtp_password'])) $content['acc_smtp_password'] = $content['acc_imap_password']; |
|
678 | + if (!isset($content['acc_smtp_username'])) |
|
679 | + { |
|
680 | + $content['acc_smtp_username'] = $content['acc_imap_username']; |
|
681 | + } |
|
682 | + if (!isset($content['acc_smtp_password'])) |
|
683 | + { |
|
684 | + $content['acc_smtp_password'] = $content['acc_imap_password']; |
|
685 | + } |
|
636 | 686 | // set default ssl |
637 | - if (!isset($content['acc_smtp_ssl'])) list($content['acc_smtp_ssl']) = each(self::$ssl_types); |
|
638 | - if (empty($content['acc_smtp_port'])) $content['acc_smtp_port'] = $smtp_ssl2port[$content['acc_smtp_ssl']]; |
|
687 | + if (!isset($content['acc_smtp_ssl'])) |
|
688 | + { |
|
689 | + list($content['acc_smtp_ssl']) = each(self::$ssl_types); |
|
690 | + } |
|
691 | + if (empty($content['acc_smtp_port'])) |
|
692 | + { |
|
693 | + $content['acc_smtp_port'] = $smtp_ssl2port[$content['acc_smtp_ssl']]; |
|
694 | + } |
|
639 | 695 | |
640 | 696 | // check smtp connection |
641 | 697 | if ($button == 'continue') |
@@ -665,10 +721,13 @@ discard block |
||
665 | 721 | { |
666 | 722 | $hosts[$server['hostname']] = array('username' => $server['username']); |
667 | 723 | } |
668 | - if (strtoupper($server['socketType']) == 'SSL') // try TLS first |
|
724 | + if (strtoupper($server['socketType']) == 'SSL') |
|
725 | + { |
|
726 | + // try TLS first |
|
669 | 727 | { |
670 | 728 | $hosts[$server['hostname']]['TLS'] = $server['port']; |
671 | 729 | } |
730 | + } |
|
672 | 731 | $hosts[$server['hostname']][strtoupper($server['socketType'])] = $server['port']; |
673 | 732 | // make sure we prefer SSL over STARTTLS over insecure |
674 | 733 | if (count($hosts[$server['hostname']]) > 2) |
@@ -690,7 +749,10 @@ discard block |
||
690 | 749 | } |
691 | 750 | foreach($data as $ssl => $port) |
692 | 751 | { |
693 | - if ($ssl === 'username') continue; |
|
752 | + if ($ssl === 'username') |
|
753 | + { |
|
754 | + continue; |
|
755 | + } |
|
694 | 756 | |
695 | 757 | $content['acc_smtp_ssl'] = (int)self::$ssl2type[$ssl]; |
696 | 758 | |
@@ -755,19 +817,28 @@ discard block |
||
755 | 817 | $content['smtp_output'] .= "\n".$e->getMessage().' ('.$e->getCode().')'."\n"; |
756 | 818 | break; |
757 | 819 | } |
758 | - if (self::$debug) _egw_log_exception($e); |
|
820 | + if (self::$debug) |
|
821 | + { |
|
822 | + _egw_log_exception($e); |
|
823 | + } |
|
759 | 824 | } |
760 | 825 | catch(Horde_Smtp_Exception $e) |
761 | 826 | { |
762 | 827 | // prever $e->details over $e->getMessage() as it contains original message from SMTP server (eg. relay access denied) |
763 | 828 | $content['smtp_output'] .= "\n".(empty($e->details) ? $e->getMessage().' ('.$e->getCode().')' : $e->details)."\n"; |
764 | 829 | //$content['smtp_output'] .= $e->getTraceAsString()."\n"; |
765 | - if (self::$debug) _egw_log_exception($e); |
|
830 | + if (self::$debug) |
|
831 | + { |
|
832 | + _egw_log_exception($e); |
|
833 | + } |
|
766 | 834 | } |
767 | 835 | catch(Exception $e) { |
768 | 836 | $content['smtp_output'] .= "\n".get_class($e).': '.$e->getMessage().' ('.$e->getCode().')'."\n"; |
769 | 837 | //$content['smtp_output'] .= $e->getTraceAsString()."\n"; |
770 | - if (self::$debug) _egw_log_exception($e); |
|
838 | + if (self::$debug) |
|
839 | + { |
|
840 | + _egw_log_exception($e); |
|
841 | + } |
|
771 | 842 | } |
772 | 843 | } |
773 | 844 | } |
@@ -814,14 +885,23 @@ discard block |
||
814 | 885 | // app is trying to tell something, while redirecting to wizard |
815 | 886 | if (empty($content) && $_GET['acc_id'] && empty($msg) && !empty( $_GET['msg'])) |
816 | 887 | { |
817 | - if (stripos($_GET['msg'],'fatal error:')!==false || $_GET['msg_type'] == 'error') $msg_type = 'error'; |
|
888 | + if (stripos($_GET['msg'],'fatal error:')!==false || $_GET['msg_type'] == 'error') |
|
889 | + { |
|
890 | + $msg_type = 'error'; |
|
891 | + } |
|
892 | + } |
|
893 | + if ($content['acc_id'] || (isset($_GET['acc_id']) && (int)$_GET['acc_id'] > 0) ) |
|
894 | + { |
|
895 | + Mail::unsetCachedObjects($content['acc_id']?$content['acc_id']:$_GET['acc_id']); |
|
818 | 896 | } |
819 | - if ($content['acc_id'] || (isset($_GET['acc_id']) && (int)$_GET['acc_id'] > 0) ) Mail::unsetCachedObjects($content['acc_id']?$content['acc_id']:$_GET['acc_id']); |
|
820 | 897 | $tpl = new Etemplate('admin.mailaccount'); |
821 | 898 | |
822 | 899 | if (!is_array($content) || !empty($content['acc_id']) && isset($content['old_acc_id']) && $content['acc_id'] != $content['old_acc_id']) |
823 | 900 | { |
824 | - if (!is_array($content)) $content = array(); |
|
901 | + if (!is_array($content)) |
|
902 | + { |
|
903 | + $content = array(); |
|
904 | + } |
|
825 | 905 | if ($this->is_admin && isset($_GET['account_id'])) |
826 | 906 | { |
827 | 907 | $content['called_for'] = (int)$_GET['account_id']; |
@@ -843,14 +923,20 @@ discard block |
||
843 | 923 | } |
844 | 924 | } |
845 | 925 | catch(Api\Exception\NotFound $e) { |
846 | - if (self::$debug) _egw_log_exception($e); |
|
926 | + if (self::$debug) |
|
927 | + { |
|
928 | + _egw_log_exception($e); |
|
929 | + } |
|
847 | 930 | } |
848 | 931 | } |
849 | 932 | } |
850 | - if (!$content['accounts']) // no email account, call wizard |
|
933 | + if (!$content['accounts']) |
|
934 | + { |
|
935 | + // no email account, call wizard |
|
851 | 936 | { |
852 | 937 | return $this->add(array('account_id' => (int)$_GET['account_id'])); |
853 | 938 | } |
939 | + } |
|
854 | 940 | $content['accounts']['new'] = lang('Create new account'); |
855 | 941 | } |
856 | 942 | if (isset($_GET['acc_id']) && (int)$_GET['acc_id'] > 0) |
@@ -878,15 +964,24 @@ discard block |
||
878 | 964 | // change self::SSL_NONE (=0) to "no" used in sel_options |
879 | 965 | foreach(array('imap','smtp','sieve') as $type) |
880 | 966 | { |
881 | - if (!$content['acc_'.$type.'_ssl']) $content['acc_'.$type.'_ssl'] = 'no'; |
|
967 | + if (!$content['acc_'.$type.'_ssl']) |
|
968 | + { |
|
969 | + $content['acc_'.$type.'_ssl'] = 'no'; |
|
970 | + } |
|
882 | 971 | } |
883 | 972 | } |
884 | 973 | catch(Api\Exception\NotFound $e) { |
885 | - if (self::$debug) _egw_log_exception($e); |
|
974 | + if (self::$debug) |
|
975 | + { |
|
976 | + _egw_log_exception($e); |
|
977 | + } |
|
886 | 978 | Framework::window_close(lang('Account not found!')); |
887 | 979 | } |
888 | 980 | catch(Exception $e) { |
889 | - if (self::$debug) _egw_log_exception($e); |
|
981 | + if (self::$debug) |
|
982 | + { |
|
983 | + _egw_log_exception($e); |
|
984 | + } |
|
890 | 985 | Framework::window_close($e->getMessage().' ('.get_class($e).': '.$e->getCode().')'); |
891 | 986 | } |
892 | 987 | } |
@@ -901,7 +996,10 @@ discard block |
||
901 | 996 | // some defaults for new accounts |
902 | 997 | if (!isset($content['account_id']) || empty($content['acc_id']) || $content['acc_id'] === 'new') |
903 | 998 | { |
904 | - if (!isset($content['account_id'])) $content['account_id'] = array($GLOBALS['egw_info']['user']['account_id']); |
|
999 | + if (!isset($content['account_id'])) |
|
1000 | + { |
|
1001 | + $content['account_id'] = array($GLOBALS['egw_info']['user']['account_id']); |
|
1002 | + } |
|
905 | 1003 | $content['acc_user_editable'] = $content['acc_further_identities'] = true; |
906 | 1004 | $readonlys['ident_id'] = true; // need to create standard identity first |
907 | 1005 | } |
@@ -975,7 +1073,10 @@ discard block |
||
975 | 1073 | )+$content); |
976 | 1074 | $content['identities'][$content['ident_id']] = Mail\Account::identity_name($content); |
977 | 1075 | $msg = lang('Identity saved.'); |
978 | - if ($edit_access) $msg .= ' '.lang('Switch back to standard identity to save account.'); |
|
1076 | + if ($edit_access) |
|
1077 | + { |
|
1078 | + $msg .= ' '.lang('Switch back to standard identity to save account.'); |
|
1079 | + } |
|
979 | 1080 | } |
980 | 1081 | elseif ($edit_access) |
981 | 1082 | { |
@@ -984,7 +1085,10 @@ discard block |
||
984 | 1085 | if ($account->acc_imap_administration) |
985 | 1086 | { |
986 | 1087 | $imap = $account->imapServer(true); |
987 | - if ($imap) $imap->checkAdminConnection(); |
|
1088 | + if ($imap) |
|
1089 | + { |
|
1090 | + $imap->checkAdminConnection(); |
|
1091 | + } |
|
988 | 1092 | } |
989 | 1093 | // test sieve connection, if not called for other user, enabled and credentials available |
990 | 1094 | if (!$content['called_for'] && $account->acc_sieve_enabled && $account->acc_imap_username) |
@@ -1033,10 +1137,13 @@ discard block |
||
1033 | 1137 | } |
1034 | 1138 | if (isset($content['accounts'])) |
1035 | 1139 | { |
1036 | - if (!isset($content['accounts'][$content['acc_id']])) // insert new account as top, not bottom |
|
1140 | + if (!isset($content['accounts'][$content['acc_id']])) |
|
1141 | + { |
|
1142 | + // insert new account as top, not bottom |
|
1037 | 1143 | { |
1038 | 1144 | $content['accounts'] = array($content['acc_id'] => '') + $content['accounts']; |
1039 | 1145 | } |
1146 | + } |
|
1040 | 1147 | $content['accounts'][$content['acc_id']] = Mail\Account::identity_name($content, false); |
1041 | 1148 | } |
1042 | 1149 | } |
@@ -1094,10 +1201,19 @@ discard block |
||
1094 | 1201 | $button = 'apply'; |
1095 | 1202 | $msg_type = 'error'; |
1096 | 1203 | } |
1097 | - if ($content['acc_id']) Mail::unsetCachedObjects($content['acc_id']); |
|
1098 | - if (stripos($msg,'fatal error:')!==false) $msg_type = 'error'; |
|
1204 | + if ($content['acc_id']) |
|
1205 | + { |
|
1206 | + Mail::unsetCachedObjects($content['acc_id']); |
|
1207 | + } |
|
1208 | + if (stripos($msg,'fatal error:')!==false) |
|
1209 | + { |
|
1210 | + $msg_type = 'error'; |
|
1211 | + } |
|
1099 | 1212 | Framework::refresh_opener($msg, 'emailadmin', $content['acc_id'], $new_account ? 'add' : 'update', null, null, null, $msg_type); |
1100 | - if ($button == 'save') Framework::window_close(); |
|
1213 | + if ($button == 'save') |
|
1214 | + { |
|
1215 | + Framework::window_close(); |
|
1216 | + } |
|
1101 | 1217 | break; |
1102 | 1218 | |
1103 | 1219 | case 'delete': |
@@ -1108,7 +1224,10 @@ discard block |
||
1108 | 1224 | } |
1109 | 1225 | elseif (Mail\Account::delete($content['acc_id']) > 0) |
1110 | 1226 | { |
1111 | - if ($content['acc_id']) Mail::unsetCachedObjects($content['acc_id']); |
|
1227 | + if ($content['acc_id']) |
|
1228 | + { |
|
1229 | + Mail::unsetCachedObjects($content['acc_id']); |
|
1230 | + } |
|
1112 | 1231 | Framework::refresh_opener(lang('Account deleted.'), 'emailadmin', $content['acc_id'], 'delete'); |
1113 | 1232 | Framework::window_close(); |
1114 | 1233 | } |
@@ -1162,7 +1281,10 @@ discard block |
||
1162 | 1281 | self::mailboxes(self::imap_client ($content)); |
1163 | 1282 | } |
1164 | 1283 | catch(Exception $e) { |
1165 | - if (self::$debug) _egw_log_exception($e); |
|
1284 | + if (self::$debug) |
|
1285 | + { |
|
1286 | + _egw_log_exception($e); |
|
1287 | + } |
|
1166 | 1288 | // let user know what the problem is and that he can fix it using wizard or deleting |
1167 | 1289 | $msg = lang($e->getMessage())."\n\n".lang('You can use wizard to fix account settings or delete account.'); |
1168 | 1290 | $msg_type = 'error'; |
@@ -1270,9 +1392,15 @@ discard block |
||
1270 | 1392 | 'acc_id' => $content['acc_id'], |
1271 | 1393 | )) as $actions) |
1272 | 1394 | { |
1273 | - if ($actions) $admin_actions = array_merge($admin_actions, $actions); |
|
1395 | + if ($actions) |
|
1396 | + { |
|
1397 | + $admin_actions = array_merge($admin_actions, $actions); |
|
1398 | + } |
|
1399 | + } |
|
1400 | + if ($admin_actions) |
|
1401 | + { |
|
1402 | + $tpl->setElementAttribute('admin_actions', 'actions', $admin_actions); |
|
1274 | 1403 | } |
1275 | - if ($admin_actions) $tpl->setElementAttribute('admin_actions', 'actions', $admin_actions); |
|
1276 | 1404 | } |
1277 | 1405 | $content['admin_actions'] = (bool)$admin_actions; |
1278 | 1406 | |
@@ -1287,7 +1415,10 @@ discard block |
||
1287 | 1415 | */ |
1288 | 1416 | private static function fix_account_id_0(&$account_id=null, $back=false) |
1289 | 1417 | { |
1290 | - if (!isset($account_id)) return; |
|
1418 | + if (!isset($account_id)) |
|
1419 | + { |
|
1420 | + return; |
|
1421 | + } |
|
1291 | 1422 | |
1292 | 1423 | if (!is_array($account_id)) |
1293 | 1424 | { |
@@ -1330,7 +1461,10 @@ discard block |
||
1330 | 1461 | $ordered = array(); |
1331 | 1462 | foreach(array_merge(array('TLS', 'SSL', 'STARTTLS'), array_keys($data)) as $key) |
1332 | 1463 | { |
1333 | - if (array_key_exists($key, $data)) $ordered[$key] = $data[$key]; |
|
1464 | + if (array_key_exists($key, $data)) |
|
1465 | + { |
|
1466 | + $ordered[$key] = $data[$key]; |
|
1467 | + } |
|
1334 | 1468 | } |
1335 | 1469 | return $ordered; |
1336 | 1470 | } |
@@ -1348,21 +1482,33 @@ discard block |
||
1348 | 1482 | */ |
1349 | 1483 | protected static function mozilla_ispdb($domain, $try_mx=true) |
1350 | 1484 | { |
1351 | - if (strpos($domain, '@') !== false) list(,$domain) = explode('@', $domain); |
|
1485 | + if (strpos($domain, '@') !== false) |
|
1486 | + { |
|
1487 | + list(,$domain) = explode('@', $domain); |
|
1488 | + } |
|
1352 | 1489 | |
1353 | 1490 | $url = 'https://autoconfig.thunderbird.net/v1.1/'.$domain; |
1354 | 1491 | try { |
1355 | 1492 | $xml = @simplexml_load_file($url); |
1356 | - if (!$xml->emailProvider) throw new Api\Exception\NotFound(); |
|
1493 | + if (!$xml->emailProvider) |
|
1494 | + { |
|
1495 | + throw new Api\Exception\NotFound(); |
|
1496 | + } |
|
1357 | 1497 | $provider = array( |
1358 | 1498 | 'displayName' => (string)$xml->emailProvider->displayName, |
1359 | 1499 | ); |
1360 | 1500 | foreach($xml->emailProvider->children() as $tag => $server) |
1361 | 1501 | { |
1362 | - if (!in_array($tag, array('incomingServer', 'outgoingServer'))) continue; |
|
1502 | + if (!in_array($tag, array('incomingServer', 'outgoingServer'))) |
|
1503 | + { |
|
1504 | + continue; |
|
1505 | + } |
|
1363 | 1506 | foreach($server->attributes() as $name => $value) |
1364 | 1507 | { |
1365 | - if ($name == 'type') $type = (string)$value; |
|
1508 | + if ($name == 'type') |
|
1509 | + { |
|
1510 | + $type = (string)$value; |
|
1511 | + } |
|
1366 | 1512 | } |
1367 | 1513 | $data = array(); |
1368 | 1514 | foreach($server as $name => $value) |
@@ -1371,7 +1517,10 @@ discard block |
||
1371 | 1517 | { |
1372 | 1518 | $data[$name][$tag] = (string)$val; |
1373 | 1519 | } |
1374 | - if (!isset($data[$name])) $data[$name] = (string)$value; |
|
1520 | + if (!isset($data[$name])) |
|
1521 | + { |
|
1522 | + $data[$name] = (string)$value; |
|
1523 | + } |
|
1375 | 1524 | } |
1376 | 1525 | $provider[$type][] = $data; |
1377 | 1526 | } |
@@ -1417,7 +1566,10 @@ discard block |
||
1417 | 1566 | // try usuall names |
1418 | 1567 | $hosts[$type.'.'.$domain] = true; |
1419 | 1568 | $hosts['mail.'.$domain] = true; |
1420 | - if ($type == 'smtp') $hosts['send.'.$domain] = true; |
|
1569 | + if ($type == 'smtp') |
|
1570 | + { |
|
1571 | + $hosts['send.'.$domain] = true; |
|
1572 | + } |
|
1421 | 1573 | |
1422 | 1574 | if (($dns = dns_get_record($domain, DNS_MX))) |
1423 | 1575 | { |
@@ -1429,14 +1581,20 @@ discard block |
||
1429 | 1581 | } |
1430 | 1582 | $hosts[preg_replace('/^[^.]+/', $type, $dns[0]['target'])] = true; |
1431 | 1583 | $hosts[preg_replace('/^[^.]+/', 'mail', $dns[0]['target'])] = true; |
1432 | - if ($type == 'smtp') $hosts[preg_replace('/^[^.]+/', 'send', $dns[0]['target'])] = true; |
|
1584 | + if ($type == 'smtp') |
|
1585 | + { |
|
1586 | + $hosts[preg_replace('/^[^.]+/', 'send', $dns[0]['target'])] = true; |
|
1587 | + } |
|
1433 | 1588 | $hosts[$dns[0]['target']] = true; |
1434 | 1589 | } |
1435 | 1590 | |
1436 | 1591 | // verify hosts in dns |
1437 | 1592 | foreach(array_keys($hosts) as $host) |
1438 | 1593 | { |
1439 | - if (!dns_get_record($host, DNS_A)) unset($hosts[$host]); |
|
1594 | + if (!dns_get_record($host, DNS_A)) |
|
1595 | + { |
|
1596 | + unset($hosts[$host]); |
|
1597 | + } |
|
1440 | 1598 | } |
1441 | 1599 | //error_log(__METHOD__."('$email') returning ".array2string($hosts)); |
1442 | 1600 | return $hosts; |
@@ -1456,7 +1614,10 @@ discard block |
||
1456 | 1614 | */ |
1457 | 1615 | public function ajax_activeAccounts($_data) |
1458 | 1616 | { |
1459 | - if (!$this->is_admin) die('no rights to be here!'); |
|
1617 | + if (!$this->is_admin) |
|
1618 | + { |
|
1619 | + die('no rights to be here!'); |
|
1620 | + } |
|
1460 | 1621 | $response = Api\Json\Response::get(); |
1461 | 1622 | if (($account = $GLOBALS['egw']->accounts->read($_data['id']))) |
1462 | 1623 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param string $password =null password |
26 | 26 | * @param boolean $run_addaccount_hook =null default run addaccount for new Api\Accounts and editaccount for existing ones |
27 | 27 | */ |
28 | - function __construct($account,$set=null,$password=null,$run_addaccount_hook=null) |
|
28 | + function __construct($account, $set = null, $password = null, $run_addaccount_hook = null) |
|
29 | 29 | { |
30 | 30 | if (!is_array($account)) |
31 | 31 | { |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
50 | 50 | * @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99); |
51 | 51 | */ |
52 | - protected function exec($check_only=false) |
|
52 | + protected function exec($check_only = false) |
|
53 | 53 | { |
54 | 54 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
55 | - if ($this->creator) $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
55 | + if ($this->creator) $this->_check_admin('account_access', $this->account ? 16 : 4); |
|
56 | 56 | |
57 | 57 | admin_cmd::_instanciate_accounts(); |
58 | 58 | |
@@ -68,29 +68,29 @@ discard block |
||
68 | 68 | } |
69 | 69 | if (!$data['account_lid'] && (!$this->account || !is_null($data['account_lid']))) |
70 | 70 | { |
71 | - throw new Api\Exception\WrongUserinput(lang('You must enter a loginid'),9); |
|
71 | + throw new Api\Exception\WrongUserinput(lang('You must enter a loginid'), 9); |
|
72 | 72 | } |
73 | 73 | // Check if an account already exists as system user, and if it does deny creation |
74 | 74 | if ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' && |
75 | 75 | !$GLOBALS['egw_info']['server']['ldap_allow_systemusernames'] && !$data['account_id'] && |
76 | 76 | function_exists('posix_getpwnam') && posix_getpwnam($data['account_lid'])) |
77 | 77 | { |
78 | - throw new Api\Exception\WrongUserinput(lang('There already is a system-user with this name. User\'s should not have the same name as a systemuser'),99); |
|
78 | + throw new Api\Exception\WrongUserinput(lang('There already is a system-user with this name. User\'s should not have the same name as a systemuser'), 99); |
|
79 | 79 | } |
80 | 80 | if (!$data['account_lastname'] && (!$this->account || !is_null($data['account_lastname']))) |
81 | 81 | { |
82 | - throw new Api\Exception\WrongUserinput(lang('You must enter a lastname'),9); |
|
82 | + throw new Api\Exception\WrongUserinput(lang('You must enter a lastname'), 9); |
|
83 | 83 | } |
84 | - if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'],'account_lid','u')) && |
|
84 | + if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'], 'account_lid', 'u')) && |
|
85 | 85 | (string)$id !== (string)$data['account_id']) |
86 | 86 | { |
87 | - throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'),999); |
|
87 | + throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'), 999); |
|
88 | 88 | } |
89 | 89 | if (isset($data['account_passwd_2']) && $data['account_passwd'] != $data['account_passwd_2']) |
90 | 90 | { |
91 | - throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'),0); |
|
91 | + throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'), 0); |
|
92 | 92 | } |
93 | - $expires = self::_parse_expired($data['account_expires'],(boolean)$this->account); |
|
93 | + $expires = self::_parse_expired($data['account_expires'], (boolean)$this->account); |
|
94 | 94 | if ($expires === 0) // deactivated |
95 | 95 | { |
96 | 96 | $data['account_expires'] = -1; |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | $data['account_status'] = is_null($expires) ? null : ($expires == -1 || $expires > time() ? 'A' : ''); |
103 | 103 | } |
104 | 104 | |
105 | - $data['changepassword'] = admin_cmd::parse_boolean($data['changepassword'],$this->account ? null : true); |
|
106 | - $data['anonymous'] = admin_cmd::parse_boolean($data['anonymous'],$this->account ? null : false); |
|
105 | + $data['changepassword'] = admin_cmd::parse_boolean($data['changepassword'], $this->account ? null : true); |
|
106 | + $data['anonymous'] = admin_cmd::parse_boolean($data['anonymous'], $this->account ? null : false); |
|
107 | 107 | if ($data['mustchangepassword'] && $data['changepassword']) |
108 | 108 | { |
109 | - $data['account_lastpwd_change']=0; |
|
109 | + $data['account_lastpwd_change'] = 0; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if (!$data['account_primary_group'] && $this->account) |
113 | 113 | { |
114 | - $data['account_primary_group'] = null; // dont change |
|
114 | + $data['account_primary_group'] = null; // dont change |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | { |
120 | 120 | $data['account_primary_group'] = 'Default'; |
121 | 121 | } |
122 | - $data['account_primary_group'] = admin_cmd::parse_account($data['account_primary_group'],false); |
|
122 | + $data['account_primary_group'] = admin_cmd::parse_account($data['account_primary_group'], false); |
|
123 | 123 | } |
124 | 124 | if (!$data['account_groups'] && $this->account) |
125 | 125 | { |
126 | - $data['account_groups'] = null; // dont change |
|
126 | + $data['account_groups'] = null; // dont change |
|
127 | 127 | } |
128 | 128 | else |
129 | 129 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | { |
132 | 132 | $data['account_groups'] = array('Default'); |
133 | 133 | } |
134 | - $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'],false); |
|
134 | + $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'], false); |
|
135 | 135 | } |
136 | 136 | if ($check_only) return true; |
137 | 137 | |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | Api\Accounts::cache_invalidate($data['account_id']); |
142 | 142 | if (!($old = admin_cmd::$accounts->read($data['account_id']))) |
143 | 143 | { |
144 | - throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
|
144 | + throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $this->account), 15); |
|
145 | 145 | } |
146 | 146 | // as the current account class always sets all values, we have to add the not specified ones |
147 | - foreach($data as $name => &$value) |
|
147 | + foreach ($data as $name => &$value) |
|
148 | 148 | { |
149 | 149 | if (is_null($value)) $value = $old[$name]; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | else |
153 | 153 | { |
154 | - unset($data['account_id']); // otherwise add will fail under postgres |
|
154 | + unset($data['account_id']); // otherwise add will fail under postgres |
|
155 | 155 | } |
156 | 156 | // hook allowing apps to intercept adding/editing Api\Accounts before saving them |
157 | - Api\Hooks::process($data+array( |
|
157 | + Api\Hooks::process($data + array( |
|
158 | 158 | 'location' => $this->account ? 'pre_editaccount' : 'pre_addaccount', |
159 | - ),False,True); // called for every app now, not only enabled ones) |
|
159 | + ), False, True); // called for every app now, not only enabled ones) |
|
160 | 160 | |
161 | 161 | if (!($data['account_id'] = admin_cmd::$accounts->save($data))) |
162 | 162 | { |
163 | 163 | //_debug_array($data); |
164 | - throw new Api\Db\Exception(lang("Error saving account!"),11); |
|
164 | + throw new Api\Db\Exception(lang("Error saving account!"), 11); |
|
165 | 165 | } |
166 | 166 | // make new account_id available to caller |
167 | 167 | $update = (boolean)$this->account; |
@@ -169,44 +169,44 @@ discard block |
||
169 | 169 | |
170 | 170 | if ($data['account_groups']) |
171 | 171 | { |
172 | - admin_cmd::$accounts->set_memberships($data['account_groups'],$data['account_id']); |
|
172 | + admin_cmd::$accounts->set_memberships($data['account_groups'], $data['account_id']); |
|
173 | 173 | } |
174 | 174 | if (!is_null($data['anonymous'])) |
175 | 175 | { |
176 | 176 | admin_cmd::_instanciate_acl(); |
177 | 177 | if ($data['anonymous']) |
178 | 178 | { |
179 | - admin_cmd::$acl->add_repository('phpgwapi','anonymous',$data['account_id'],1); |
|
179 | + admin_cmd::$acl->add_repository('phpgwapi', 'anonymous', $data['account_id'], 1); |
|
180 | 180 | } |
181 | 181 | else |
182 | 182 | { |
183 | - admin_cmd::$acl->delete_repository('phpgwapi','anonymous',$data['account_id']); |
|
183 | + admin_cmd::$acl->delete_repository('phpgwapi', 'anonymous', $data['account_id']); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | if (!is_null($data['changepassword'])) |
187 | 187 | { |
188 | 188 | if (!$data['changepassword']) |
189 | 189 | { |
190 | - admin_cmd::$acl->add_repository('preferences','nopasswordchange',$data['account_id'],1); |
|
190 | + admin_cmd::$acl->add_repository('preferences', 'nopasswordchange', $data['account_id'], 1); |
|
191 | 191 | } |
192 | 192 | else |
193 | 193 | { |
194 | - admin_cmd::$acl->delete_repository('preferences','nopasswordchange',$data['account_id']); |
|
194 | + admin_cmd::$acl->delete_repository('preferences', 'nopasswordchange', $data['account_id']); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | // if we have a password and it's not a hash, and auth_type != account_repository |
198 | 198 | if (!is_null($this->password) && |
199 | - !preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$this->password) && |
|
200 | - !preg_match('/^[0-9a-f]{32}$/',$this->password) && // md5 hash |
|
199 | + !preg_match('/^\\{[a-z5]{3,5}\\}.+/i', $this->password) && |
|
200 | + !preg_match('/^[0-9a-f]{32}$/', $this->password) && // md5 hash |
|
201 | 201 | admin_cmd::$accounts->config['auth_type'] != admin_cmd::$accounts->config['account_repository']) |
202 | 202 | { |
203 | - admin_cmd_change_pw::exec(); // calling the exec method of the admin_cmd_change_pw |
|
203 | + admin_cmd_change_pw::exec(); // calling the exec method of the admin_cmd_change_pw |
|
204 | 204 | } |
205 | 205 | $data['account_passwd'] = $this->password; |
206 | - $GLOBALS['hook_values'] =& $data; |
|
207 | - Api\Hooks::process($GLOBALS['hook_values']+array( |
|
206 | + $GLOBALS['hook_values'] = & $data; |
|
207 | + Api\Hooks::process($GLOBALS['hook_values'] + array( |
|
208 | 208 | 'location' => $update && $this->run_addaccount_hook !== true ? 'editaccount' : 'addaccount' |
209 | - ),False,True); // called for every app now, not only enabled ones) |
|
209 | + ), False, True); // called for every app now, not only enabled ones) |
|
210 | 210 | |
211 | 211 | return lang("Account %1 %2", $data['account_lid'] ? $data['account_lid'] : Api\Accounts::id2name($this->account), |
212 | 212 | $update ? lang('updated') : lang("created with id #%1", $this->account)); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | function __tostring() |
221 | 221 | { |
222 | - return lang('%1 user %2',$this->account ? lang('Edit') : lang('Add'), |
|
222 | + return lang('%1 user %2', $this->account ? lang('Edit') : lang('Add'), |
|
223 | 223 | admin_cmd::display_account($this->account ? $this->account : $this->set['account_lid'])); |
224 | 224 | } |
225 | 225 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | * @return int timestamp, 0 for already, -1 for never or null for dont change |
232 | 232 | * @throws Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6); |
233 | 233 | */ |
234 | - private function _parse_expired($str,$existing) |
|
234 | + private function _parse_expired($str, $existing) |
|
235 | 235 | { |
236 | - switch($str) |
|
236 | + switch ($str) |
|
237 | 237 | { |
238 | 238 | case '': |
239 | 239 | if ($existing) return null; |
@@ -52,16 +52,22 @@ discard block |
||
52 | 52 | protected function exec($check_only=false) |
53 | 53 | { |
54 | 54 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
55 | - if ($this->creator) $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
55 | + if ($this->creator) |
|
56 | + { |
|
57 | + $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | admin_cmd::_instanciate_accounts(); |
58 | 61 | |
59 | 62 | $data = $this->set; |
60 | 63 | $data['account_type'] = 'u'; |
61 | 64 | |
62 | - if ($this->account) // existing account |
|
65 | + if ($this->account) |
|
66 | + { |
|
67 | + // existing account |
|
63 | 68 | { |
64 | 69 | $data['account_id'] = admin_cmd::parse_account($this->account); |
70 | + } |
|
65 | 71 | //error_log(__METHOD__."($check_only) this->account=".array2string($this->account).', data[account_id]='.array2string($data['account_id']).", ...)"); |
66 | 72 | |
67 | 73 | $data['old_loginid'] = admin_cmd::$accounts->id2name($data['account_id']); |
@@ -91,9 +97,12 @@ discard block |
||
91 | 97 | throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'),0); |
92 | 98 | } |
93 | 99 | $expires = self::_parse_expired($data['account_expires'],(boolean)$this->account); |
94 | - if ($expires === 0) // deactivated |
|
100 | + if ($expires === 0) |
|
101 | + { |
|
102 | + // deactivated |
|
95 | 103 | { |
96 | 104 | $data['account_expires'] = -1; |
105 | + } |
|
97 | 106 | $data['account_status'] = ''; |
98 | 107 | } |
99 | 108 | else |
@@ -133,7 +142,10 @@ discard block |
||
133 | 142 | } |
134 | 143 | $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'],false); |
135 | 144 | } |
136 | - if ($check_only) return true; |
|
145 | + if ($check_only) |
|
146 | + { |
|
147 | + return true; |
|
148 | + } |
|
137 | 149 | |
138 | 150 | if ($this->account) |
139 | 151 | { |
@@ -146,7 +158,10 @@ discard block |
||
146 | 158 | // as the current account class always sets all values, we have to add the not specified ones |
147 | 159 | foreach($data as $name => &$value) |
148 | 160 | { |
149 | - if (is_null($value)) $value = $old[$name]; |
|
161 | + if (is_null($value)) |
|
162 | + { |
|
163 | + $value = $old[$name]; |
|
164 | + } |
|
150 | 165 | } |
151 | 166 | } |
152 | 167 | else |
@@ -165,7 +180,10 @@ discard block |
||
165 | 180 | } |
166 | 181 | // make new account_id available to caller |
167 | 182 | $update = (boolean)$this->account; |
168 | - if (!$this->account) $this->account = $data['account_id']; |
|
183 | + if (!$this->account) |
|
184 | + { |
|
185 | + $this->account = $data['account_id']; |
|
186 | + } |
|
169 | 187 | |
170 | 188 | if ($data['account_groups']) |
171 | 189 | { |
@@ -236,7 +254,10 @@ discard block |
||
236 | 254 | switch($str) |
237 | 255 | { |
238 | 256 | case '': |
239 | - if ($existing) return null; |
|
257 | + if ($existing) |
|
258 | + { |
|
259 | + return null; |
|
260 | + } |
|
240 | 261 | // fall through --> default for new Api\Accounts is never |
241 | 262 | case 'never': |
242 | 263 | return -1; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | var $public_functions = array('index' => True); |
22 | 22 | |
23 | - function index($params=null) |
|
23 | + function index($params = null) |
|
24 | 24 | { |
25 | 25 | // if we have a xet file, run new et2 config |
26 | 26 | if (file_exists(EGW_SERVER_ROOT.'/'.$_GET['appname'].'/templates/default/config.xet')) |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | //_debug_array($params); |
47 | 47 | $_appname = $_GET['appname']; |
48 | 48 | } |
49 | - if ($GLOBALS['egw']->acl->check('site_config_acce',1,'admin')) |
|
49 | + if ($GLOBALS['egw']->acl->check('site_config_acce', 1, 'admin')) |
|
50 | 50 | { |
51 | 51 | Egw::redirect_link('/index.php'); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | Api\Translation::add_app($_appname); |
58 | 58 | } |
59 | 59 | |
60 | - if(get_magic_quotes_gpc() && is_array($_POST['newsettings'])) |
|
60 | + if (get_magic_quotes_gpc() && is_array($_POST['newsettings'])) |
|
61 | 61 | { |
62 | 62 | $_POST['newsettings'] = array_stripslashes($_POST['newsettings']); |
63 | 63 | } |
64 | 64 | |
65 | - switch($_appname) |
|
65 | + switch ($_appname) |
|
66 | 66 | { |
67 | 67 | case 'admin': |
68 | 68 | case 'addressbook': |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $t = new Framework\Template(Framework\Template::get_dir($appname)); |
90 | 90 | $t->set_unknowns('keep'); |
91 | 91 | $t->set_file(array('config' => 'config.tpl')); |
92 | - $t->set_block('config','header','header'); |
|
92 | + $t->set_block('config', 'header', 'header'); |
|
93 | 93 | |
94 | 94 | // fix header templates missing essential parts like display of validation errors |
95 | 95 | $header = $t->get_var('header'); |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | } |
108 | 108 | $t->set_var('header', $header); |
109 | 109 | |
110 | - $t->set_block('config','body','body'); |
|
111 | - $t->set_block('config','footer','footer'); |
|
110 | + $t->set_block('config', 'body', 'body'); |
|
111 | + $t->set_block('config', 'footer', 'footer'); |
|
112 | 112 | |
113 | 113 | // fix footer submit buttons to just {submit} {cancel} |
114 | 114 | $t->set_var('footer', preg_replace('/<input[^>]+value="{lang_(submit|cancel)}"[^>]*>/', '{$1}', $t->get_var('footer'))); |
115 | 115 | |
116 | 116 | $c = new Api\Config($config_appname); |
117 | 117 | $c->read_repository(); |
118 | - if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce',2,'admin')) |
|
118 | + if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce', 2, 'admin')) |
|
119 | 119 | { |
120 | 120 | Egw::redirect_link('/admin/index.php?ajax=true'); |
121 | 121 | } |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | if ($_POST['submit'] || $_POST['save'] || $_POST['apply']) |
124 | 124 | { |
125 | 125 | /* Load hook file with functions to validate each Api\Config (one/none/all) */ |
126 | - Api\Hooks::single('config_validate',$appname); |
|
126 | + Api\Hooks::single('config_validate', $appname); |
|
127 | 127 | |
128 | - foreach($_POST['newsettings'] as $key => $config) |
|
128 | + foreach ($_POST['newsettings'] as $key => $config) |
|
129 | 129 | { |
130 | 130 | if ($config) |
131 | 131 | { |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | if (in_array($key, (array)$GLOBALS['egw_info']['server']['found_validation_hook'], true) && function_exists($key)) |
134 | 134 | { |
135 | 135 | call_user_func($key, $config, $c); |
136 | - if($GLOBALS['config_error']) |
|
136 | + if ($GLOBALS['config_error']) |
|
137 | 137 | { |
138 | - $errors .= lang($GLOBALS['config_error']) . "\n"; |
|
138 | + $errors .= lang($GLOBALS['config_error'])."\n"; |
|
139 | 139 | $GLOBALS['config_error'] = False; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
143 | 143 | /* don't erase passwords, since we also don't print them */ |
144 | - elseif(strpos($key,'passwd') === false && strpos($key,'password') === false && strpos($key,'root_pw') === false) |
|
144 | + elseif (strpos($key, 'passwd') === false && strpos($key, 'password') === false && strpos($key, 'root_pw') === false) |
|
145 | 145 | { |
146 | 146 | unset($c->config_data[$key]); |
147 | 147 | } |
148 | 148 | } |
149 | - if(in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) && |
|
149 | + if (in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) && |
|
150 | 150 | function_exists('final_validation')) |
151 | 151 | { |
152 | 152 | final_validation($_POST['newsettings']); |
153 | - if($GLOBALS['config_error']) |
|
153 | + if ($GLOBALS['config_error']) |
|
154 | 154 | { |
155 | - $errors .= lang($GLOBALS['config_error']) . "\n"; |
|
155 | + $errors .= lang($GLOBALS['config_error'])."\n"; |
|
156 | 156 | $GLOBALS['config_error'] = False; |
157 | 157 | } |
158 | 158 | unset($GLOBALS['egw_info']['server']['found_validation_hook']); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | $c->save_repository(); |
162 | 162 | |
163 | - if(!$errors && !$_POST['apply']) |
|
163 | + if (!$errors && !$_POST['apply']) |
|
164 | 164 | { |
165 | 165 | Framework::message(lang('Configuration saved.'), 'success'); |
166 | 166 | Egw::redirect_link('/index.php', array( |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - $t->set_var('error',''); |
|
174 | - if($errors) |
|
173 | + $t->set_var('error', ''); |
|
174 | + if ($errors) |
|
175 | 175 | { |
176 | - Framework::message(lang('Error') . ': ' . $errors, 'error'); |
|
176 | + Framework::message(lang('Error').': '.$errors, 'error'); |
|
177 | 177 | unset($errors); |
178 | 178 | unset($GLOBALS['config_error']); |
179 | 179 | } |
@@ -181,41 +181,41 @@ discard block |
||
181 | 181 | { |
182 | 182 | Framework::message(lang('Configuration saved.'), 'success'); |
183 | 183 | } |
184 | - $t->set_var('title',lang('Site Configuration')); |
|
185 | - $t->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)); |
|
186 | - $t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']); |
|
187 | - $t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']); |
|
188 | - $t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']); |
|
189 | - $t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']); |
|
184 | + $t->set_var('title', lang('Site Configuration')); |
|
185 | + $t->set_var('action_url', $GLOBALS['egw']->link('/index.php', 'menuaction=admin.uiconfig.index&appname='.$appname)); |
|
186 | + $t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']); |
|
187 | + $t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']); |
|
188 | + $t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']); |
|
189 | + $t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']); |
|
190 | 190 | $t->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__CLASS__))); |
191 | 191 | |
192 | 192 | $vars = $t->get_undefined('body'); |
193 | 193 | |
194 | - if (Api\Hooks::single('config',$appname)) // reload the config-values, they might have changed |
|
194 | + if (Api\Hooks::single('config', $appname)) // reload the config-values, they might have changed |
|
195 | 195 | { |
196 | 196 | $c->read_repository(); |
197 | 197 | } |
198 | - foreach($vars as $value) |
|
198 | + foreach ($vars as $value) |
|
199 | 199 | { |
200 | - $valarray = explode('_',$value); |
|
200 | + $valarray = explode('_', $value); |
|
201 | 201 | $type = array_shift($valarray); |
202 | - $newval = implode(' ',$valarray); |
|
202 | + $newval = implode(' ', $valarray); |
|
203 | 203 | |
204 | 204 | switch ($type) |
205 | 205 | { |
206 | 206 | case 'lang': |
207 | - $t->set_var($value,lang($newval)); |
|
207 | + $t->set_var($value, lang($newval)); |
|
208 | 208 | break; |
209 | 209 | case 'value': |
210 | - $newval = str_replace(' ','_',$newval); |
|
210 | + $newval = str_replace(' ', '_', $newval); |
|
211 | 211 | /* Don't show passwords in the form */ |
212 | - if(strpos($value,'passwd') !== false || strpos($value,'password') !== false || strpos($value,'root_pw') !== false) |
|
212 | + if (strpos($value, 'passwd') !== false || strpos($value, 'password') !== false || strpos($value, 'root_pw') !== false) |
|
213 | 213 | { |
214 | - $t->set_var($value,''); |
|
214 | + $t->set_var($value, ''); |
|
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
218 | - $t->set_var($value,$c->config_data[$newval]); |
|
218 | + $t->set_var($value, $c->config_data[$newval]); |
|
219 | 219 | } |
220 | 220 | break; |
221 | 221 | /* |
@@ -233,46 +233,45 @@ discard block |
||
233 | 233 | */ |
234 | 234 | case 'selected': |
235 | 235 | $configs = array(); |
236 | - $newvals = explode(' ',$newval); |
|
236 | + $newvals = explode(' ', $newval); |
|
237 | 237 | $setting = end($newvals); |
238 | - for ($i=0;$i<(count($newvals) - 1); $i++) |
|
238 | + for ($i = 0; $i < (count($newvals) - 1); $i++) |
|
239 | 239 | { |
240 | 240 | $configs[] = $newvals[$i]; |
241 | 241 | } |
242 | - $config = implode('_',$configs); |
|
242 | + $config = implode('_', $configs); |
|
243 | 243 | /* echo $config . '=' . $c->config_data[$config]; */ |
244 | 244 | if ($c->config_data[$config] == $setting) |
245 | 245 | { |
246 | - $t->set_var($value,' selected'); |
|
246 | + $t->set_var($value, ' selected'); |
|
247 | 247 | } |
248 | 248 | else |
249 | 249 | { |
250 | - $t->set_var($value,''); |
|
250 | + $t->set_var($value, ''); |
|
251 | 251 | } |
252 | 252 | break; |
253 | 253 | case 'hook': |
254 | - $newval = str_replace(' ','_',$newval); |
|
255 | - if(function_exists($newval)) |
|
254 | + $newval = str_replace(' ', '_', $newval); |
|
255 | + if (function_exists($newval)) |
|
256 | 256 | { |
257 | - $t->set_var($value,$newval($c->config_data)); |
|
257 | + $t->set_var($value, $newval($c->config_data)); |
|
258 | 258 | } |
259 | 259 | else |
260 | 260 | { |
261 | - $t->set_var($value,''); |
|
261 | + $t->set_var($value, ''); |
|
262 | 262 | } |
263 | 263 | break; |
264 | 264 | case 'call': // eg. call_class::method or call_app.class.method |
265 | - $newval = str_replace(' ','_',$newval); |
|
266 | - $t->set_var($value,ExecMethod($newval,$c->config_data)); |
|
265 | + $newval = str_replace(' ', '_', $newval); |
|
266 | + $t->set_var($value, ExecMethod($newval, $c->config_data)); |
|
267 | 267 | break; |
268 | 268 | default: |
269 | - $t->set_var($value,''); |
|
269 | + $t->set_var($value, ''); |
|
270 | 270 | break; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | $t->set_var('submit', '<div class="dialogFooterToolbar" style="text-align: left">'. |
274 | - ($GLOBALS['egw']->acl->check('site_config_acce',2,'admin') ? '' : |
|
275 | - Api\Html::submit_button('save', 'Save')."\n". |
|
274 | + ($GLOBALS['egw']->acl->check('site_config_acce', 2, 'admin') ? '' : Api\Html::submit_button('save', 'Save')."\n". |
|
276 | 275 | Api\Html::submit_button('apply', 'Apply'))); |
277 | 276 | $t->set_var('cancel', Api\Html::submit_button('cancel', 'Cancel').'</div>'); |
278 | 277 | |
@@ -282,10 +281,10 @@ discard block |
||
282 | 281 | // render the page |
283 | 282 | $GLOBALS['egw']->framework->render( |
284 | 283 | '<div id="admin-config-'.$appname.'" class="admin-config">'. |
285 | - $t->parse('out','header'). |
|
286 | - $t->fp('out','body'). |
|
287 | - $t->fp('out','footer').'</div>', |
|
288 | - null,true |
|
284 | + $t->parse('out', 'header'). |
|
285 | + $t->fp('out', 'body'). |
|
286 | + $t->fp('out', 'footer').'</div>', |
|
287 | + null, true |
|
289 | 288 | ); |
290 | 289 | } |
291 | 290 | } |
@@ -85,7 +85,11 @@ discard block |
||
85 | 85 | $config_appname = $appname; |
86 | 86 | break; |
87 | 87 | } |
88 | - if (ob_get_contents()) ob_end_flush(); // if there is output in buffer, flush it now. |
|
88 | + if (ob_get_contents()) |
|
89 | + { |
|
90 | + ob_end_flush(); |
|
91 | + } |
|
92 | + // if there is output in buffer, flush it now. |
|
89 | 93 | $t = new Framework\Template(Framework\Template::get_dir($appname)); |
90 | 94 | $t->set_unknowns('keep'); |
91 | 95 | $t->set_file(array('config' => 'config.tpl')); |
@@ -191,10 +195,13 @@ discard block |
||
191 | 195 | |
192 | 196 | $vars = $t->get_undefined('body'); |
193 | 197 | |
194 | - if (Api\Hooks::single('config',$appname)) // reload the config-values, they might have changed |
|
198 | + if (Api\Hooks::single('config',$appname)) |
|
199 | + { |
|
200 | + // reload the config-values, they might have changed |
|
195 | 201 | { |
196 | 202 | $c->read_repository(); |
197 | 203 | } |
204 | + } |
|
198 | 205 | foreach($vars as $value) |
199 | 206 | { |
200 | 207 | $valarray = explode('_',$value); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param array $data =array() default parm from parent class, no real parameters |
22 | 22 | */ |
23 | - function __construct($data=array()) |
|
23 | + function __construct($data = array()) |
|
24 | 24 | { |
25 | 25 | admin_cmd::__construct($data); |
26 | 26 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @throws Exception(lang("Unknown account: %1 !!!",$this->account),15); |
35 | 35 | * @throws Exception(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8); |
36 | 36 | */ |
37 | - protected function exec($check_only=false) |
|
37 | + protected function exec($check_only = false) |
|
38 | 38 | { |
39 | 39 | if ($check_only) return true; |
40 | 40 | |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | if (($all_accounts = admin_cmd::$accounts->search(array('type'=>'both')))) |
44 | 44 | { |
45 | 45 | $ids = array(); |
46 | - foreach($all_accounts as $account) |
|
46 | + foreach ($all_accounts as $account) |
|
47 | 47 | { |
48 | 48 | $ids[] = $account['account_id']; |
49 | 49 | } |
50 | - $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',',$ids).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$ids)."')",__LINE__,__FILE__); |
|
50 | + $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',', $ids).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','", $ids)."')", __LINE__, __FILE__); |
|
51 | 51 | $deleted = $GLOBALS['egw']->db->affected_rows(); |
52 | 52 | } |
53 | - return lang("%1 ACL records of not (longer) existing Api\Accounts deleted.",$deleted); |
|
53 | + return lang("%1 ACL records of not (longer) existing Api\Accounts deleted.", $deleted); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -37,7 +37,10 @@ |
||
37 | 37 | */ |
38 | 38 | protected function exec($check_only=false) |
39 | 39 | { |
40 | - if ($check_only) return true; |
|
40 | + if ($check_only) |
|
41 | + { |
|
42 | + return true; |
|
43 | + } |
|
41 | 44 | |
42 | 45 | admin_cmd::_instanciate_accounts(); |
43 | 46 |
@@ -31,25 +31,24 @@ discard block |
||
31 | 31 | * @param array &$readonlys |
32 | 32 | * @return int |
33 | 33 | */ |
34 | - static function get_rows(array $query,&$rows,&$readonlys) |
|
34 | + static function get_rows(array $query, &$rows, &$readonlys) |
|
35 | 35 | { |
36 | 36 | Api\Cache::setSession('admin', 'cmds', $query); |
37 | 37 | |
38 | - $total = admin_cmd::get_rows($query,$rows,$readonlys); |
|
38 | + $total = admin_cmd::get_rows($query, $rows, $readonlys); |
|
39 | 39 | |
40 | 40 | if (!$rows) return array(); |
41 | 41 | |
42 | - foreach($rows as &$row) |
|
42 | + foreach ($rows as &$row) |
|
43 | 43 | { |
44 | 44 | try { |
45 | 45 | $cmd = admin_cmd::instanciate($row); |
46 | - $row['title'] = $cmd->__tostring(); // we call __tostring explicit, as a cast to string requires php5.2+ |
|
46 | + $row['title'] = $cmd->__tostring(); // we call __tostring explicit, as a cast to string requires php5.2+ |
|
47 | 47 | } |
48 | 48 | catch (Exception $e) { |
49 | 49 | $row['title'] = $e->getMessage(); |
50 | 50 | } |
51 | - $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : |
|
52 | - json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
|
51 | + $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
|
53 | 52 | |
54 | 53 | if ($row['status'] == admin_cmd::scheduled) |
55 | 54 | { |
@@ -65,7 +64,7 @@ discard block |
||
65 | 64 | * |
66 | 65 | * @param array $content =null |
67 | 66 | */ |
68 | - static function index(array $content=null) |
|
67 | + static function index(array $content = null) |
|
69 | 68 | { |
70 | 69 | $tpl = new Etemplate('admin.cmds'); |
71 | 70 | |
@@ -75,10 +74,10 @@ discard block |
||
75 | 74 | if (!is_array($content['nm'])) |
76 | 75 | { |
77 | 76 | $content['nm'] = array( |
78 | - 'get_rows' => 'admin.admin_cmds.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
79 | - 'no_filter' => true, // I disable the 1. filter |
|
80 | - 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
81 | - 'no_cat' => true, // I disable the cat-selectbox |
|
77 | + 'get_rows' => 'admin.admin_cmds.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
78 | + 'no_filter' => true, // I disable the 1. filter |
|
79 | + 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
80 | + 'no_cat' => true, // I disable the cat-selectbox |
|
82 | 81 | 'order' => 'cmd_created', |
83 | 82 | 'sort' => 'DESC', |
84 | 83 | 'row_id' => 'id', |
@@ -98,10 +97,10 @@ discard block |
||
98 | 97 | } |
99 | 98 | unset($cmd); |
100 | 99 | } |
101 | - $tpl->exec('admin.admin_cmds.index',$content,array( |
|
100 | + $tpl->exec('admin.admin_cmds.index', $content, array( |
|
102 | 101 | 'status' => admin_cmd::$stati, |
103 | 102 | 'remote_id' => admin_cmd::remote_sites(), |
104 | - ),array(),$content); |
|
103 | + ), array(), $content); |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | /** |
@@ -127,9 +126,9 @@ discard block |
||
127 | 126 | * @param array &$readonlys |
128 | 127 | * @return int |
129 | 128 | */ |
130 | - static function get_remotes(array $query,&$rows,&$readonlys) |
|
129 | + static function get_remotes(array $query, &$rows, &$readonlys) |
|
131 | 130 | { |
132 | - return admin_cmd::get_remotes($query,$rows,$readonlys); |
|
131 | + return admin_cmd::get_remotes($query, $rows, $readonlys); |
|
133 | 132 | } |
134 | 133 | |
135 | 134 | /** |
@@ -137,7 +136,7 @@ discard block |
||
137 | 136 | * |
138 | 137 | * @param array $content =null |
139 | 138 | */ |
140 | - static function remotes(array $content=null) |
|
139 | + static function remotes(array $content = null) |
|
141 | 140 | { |
142 | 141 | $tpl = new Etemplate('admin.remotes'); |
143 | 142 | |
@@ -147,10 +146,10 @@ discard block |
||
147 | 146 | if (!is_array($content['nm'])) |
148 | 147 | { |
149 | 148 | $content['nm'] = array( |
150 | - 'get_rows' => 'admin.admin_cmds.get_remotes', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
151 | - 'no_filter' => true, // I disable the 1. filter |
|
152 | - 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
153 | - 'no_cat' => true, // I disable the cat-selectbox |
|
149 | + 'get_rows' => 'admin.admin_cmds.get_remotes', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
150 | + 'no_filter' => true, // I disable the 1. filter |
|
151 | + 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
152 | + 'no_cat' => true, // I disable the cat-selectbox |
|
154 | 153 | 'order' => 'remote_name', |
155 | 154 | 'sort' => 'ASC', |
156 | 155 | 'row_id' => 'remote_id', |
@@ -165,7 +164,7 @@ discard block |
||
165 | 164 | |
166 | 165 | if ($content['nm']['action']) |
167 | 166 | { |
168 | - switch($content['nm']['action']) |
|
167 | + switch ($content['nm']['action']) |
|
169 | 168 | { |
170 | 169 | case 'edit': |
171 | 170 | $content['remote'] = admin_cmd::read_remote($content['nm']['selected'][0]); |
@@ -175,11 +174,11 @@ discard block |
||
175 | 174 | } |
176 | 175 | unset($content['nm']['action']); |
177 | 176 | } |
178 | - elseif($content['remote']['button']) |
|
177 | + elseif ($content['remote']['button']) |
|
179 | 178 | { |
180 | 179 | list($button) = each($content['remote']['button']); |
181 | 180 | unset($content['remote']['button']); |
182 | - switch($button) |
|
181 | + switch ($button) |
|
183 | 182 | { |
184 | 183 | case 'save': |
185 | 184 | case 'apply': |
@@ -210,7 +209,7 @@ discard block |
||
210 | 209 | unset($content['nm']['add']); |
211 | 210 | } |
212 | 211 | } |
213 | - $tpl->exec('admin.admin_cmds.remotes',$content,array(),array(),$content); |
|
212 | + $tpl->exec('admin.admin_cmds.remotes', $content, array(), array(), $content); |
|
214 | 213 | } |
215 | 214 | |
216 | 215 | /** |
@@ -226,7 +225,7 @@ discard block |
||
226 | 225 | 'default' => true, |
227 | 226 | 'allowOnMultiple' => false, |
228 | 227 | 'nm_action' => 'submit', |
229 | - 'group' => $group=0, |
|
228 | + 'group' => $group = 0, |
|
230 | 229 | ), |
231 | 230 | 'add' => array( |
232 | 231 | 'caption' => 'Add', |
@@ -37,7 +37,10 @@ discard block |
||
37 | 37 | |
38 | 38 | $total = admin_cmd::get_rows($query,$rows,$readonlys); |
39 | 39 | |
40 | - if (!$rows) return array(); |
|
40 | + if (!$rows) |
|
41 | + { |
|
42 | + return array(); |
|
43 | + } |
|
41 | 44 | |
42 | 45 | foreach($rows as &$row) |
43 | 46 | { |
@@ -193,11 +196,15 @@ discard block |
||
193 | 196 | try { |
194 | 197 | $content['remote']['remote_id'] = admin_cmd::save_remote($content['remote']); |
195 | 198 | $content['msg'] = lang('Remote instance saved'); |
196 | - } catch (Exception $e) { |
|
199 | + } |
|
200 | + catch (Exception $e) { |
|
197 | 201 | $content['msg'] = lang('Error saving').': '.$e->getMessage().' ('.$e->getCode().')'; |
198 | 202 | break; |
199 | 203 | } |
200 | - if ($button == 'apply') break; |
|
204 | + if ($button == 'apply') |
|
205 | + { |
|
206 | + break; |
|
207 | + } |
|
201 | 208 | // fall through for save |
202 | 209 | case 'cancel': |
203 | 210 | unset($content['remote']); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string|int|array $account account name or id, or array with all parameters |
24 | 24 | * @param string $password =null password |
25 | 25 | */ |
26 | - function __construct($account,$password=null) |
|
26 | + function __construct($account, $password = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($account)) |
29 | 29 | { |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
45 | 45 | * @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99); |
46 | 46 | */ |
47 | - protected function exec($check_only=false) |
|
47 | + protected function exec($check_only = false) |
|
48 | 48 | { |
49 | - $account_id = admin_cmd::parse_account($this->account,true); // true = user, no group |
|
49 | + $account_id = admin_cmd::parse_account($this->account, true); // true = user, no group |
|
50 | 50 | // check creator is still admin and not explicitly forbidden to edit Api\Accounts |
51 | - if ($this->creator) $this->_check_admin('account_access',16); |
|
51 | + if ($this->creator) $this->_check_admin('account_access', 16); |
|
52 | 52 | |
53 | 53 | if ($check_only) return true; |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | if (!$auth->change_password(null, $this->password, $account_id)) |
58 | 58 | { |
59 | 59 | // as long as the Api\Auth class is not throwing itself ... |
60 | - throw new Exception(lang('Error changing the password for %1 !!!',$this->account),99); |
|
60 | + throw new Exception(lang('Error changing the password for %1 !!!', $this->account), 99); |
|
61 | 61 | } |
62 | 62 | return lang('Password updated'); |
63 | 63 | } |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function __tostring() |
71 | 71 | { |
72 | - return lang('change password for %1',admin_cmd::display_account($this->account)); |
|
72 | + return lang('change password for %1', admin_cmd::display_account($this->account)); |
|
73 | 73 | } |
74 | 74 | } |
@@ -48,9 +48,15 @@ |
||
48 | 48 | { |
49 | 49 | $account_id = admin_cmd::parse_account($this->account,true); // true = user, no group |
50 | 50 | // check creator is still admin and not explicitly forbidden to edit Api\Accounts |
51 | - if ($this->creator) $this->_check_admin('account_access',16); |
|
51 | + if ($this->creator) |
|
52 | + { |
|
53 | + $this->_check_admin('account_access',16); |
|
54 | + } |
|
52 | 55 | |
53 | - if ($check_only) return true; |
|
56 | + if ($check_only) |
|
57 | + { |
|
58 | + return true; |
|
59 | + } |
|
54 | 60 | |
55 | 61 | $auth = new Api\Auth; |
56 | 62 |