Skip to content

Commit 0015fa3

Browse files
committed
pass: short array syntax and minor code refactoring
1 parent a36abcf commit 0015fa3

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

ispconfig3_pass/ispconfig3_pass.php

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ function init()
1313
$this->require_plugin('ispconfig3_account');
1414
$this->require_plugin('jqueryui');
1515

16-
$this->register_action('plugin.ispconfig3_pass', array($this, 'init_html'));
17-
$this->register_action('plugin.ispconfig3_pass.save', array($this, 'save'));
16+
$this->register_action('plugin.ispconfig3_pass', [$this, 'init_html']);
17+
$this->register_action('plugin.ispconfig3_pass.save', [$this, 'save']);
1818

1919
if (strpos($this->rcmail->action, 'plugin.ispconfig3_pass') === 0) {
2020
$this->load_config('config/config.inc.php.dist');
2121
if (file_exists($this->home . '/config/config.inc.php')) {
2222
$this->load_config('config/config.inc.php');
2323
}
2424

25-
$this->api->output->add_handler('pass_form', array($this, 'gen_form'));
26-
$this->api->output->add_handler('sectionname_pass', array($this, 'prefs_section_name'));
25+
$this->api->output->add_handler('pass_form', [$this, 'gen_form']);
26+
$this->api->output->add_handler('sectionname_pass', [$this, 'prefs_section_name']);
2727

2828
$this->include_script('pwdmeter.js');
2929
$this->include_script('pass.js');
@@ -46,8 +46,9 @@ function save()
4646
{
4747
$confirm = $this->rcmail->config->get('password_confirm_current');
4848

49-
if (($confirm && !isset($_POST['_curpasswd'])) || !isset($_POST['_newpasswd']))
49+
if (($confirm && !isset($_POST['_curpasswd'])) || !isset($_POST['_newpasswd'])) {
5050
$this->rcmail->output->command('display_message', $this->gettext('nopassword'), 'error');
51+
}
5152
else {
5253
$curpwd = rcube_utils::get_input_value('_curpasswd', rcube_utils::INPUT_POST);
5354
$newpwd = rcube_utils::get_input_value('_newpasswd', rcube_utils::INPUT_POST);
@@ -96,41 +97,41 @@ function save()
9697

9798
if (!$error) {
9899
try {
99-
$soap = new SoapClient(null, array(
100+
$soap = new SoapClient(null, [
100101
'location' => $this->rcmail->config->get('soap_url') . 'index.php',
101102
'uri' => $this->rcmail->config->get('soap_url'),
102103
$this->rcmail->config->get('soap_validate_cert') ?:
103-
'stream_context' => stream_context_create(
104-
array('ssl' => array(
105-
'verify_peer' => false,
106-
'verify_peer_name' => false,
107-
'allow_self_signed' => true
108-
)
109-
))
110-
));
104+
'stream_context' => stream_context_create(['ssl' => [
105+
'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true
106+
]])
107+
]);
111108

112109
$session_id = $soap->login($this->rcmail->config->get('remote_soap_user'), $this->rcmail->config->get('remote_soap_pass'));
113-
$mail_user = $soap->mail_user_get($session_id, array('login' => $this->rcmail->user->data['username']));
110+
$mail_user = $soap->mail_user_get($session_id, ['login' => $this->rcmail->user->data['username']]);
114111
// Alternatively also search the email field, this can differ from the login field for legacy reasons.
115112
if (empty($mail_user)) {
116-
$mail_user = $this->soap->mail_user_get($session_id, array('email' => $this->rcmail->user->data['username']));
113+
$mail_user = $soap->mail_user_get($session_id, ['email' => $this->rcmail->user->data['username']]);
117114
}
118115

119116
$params = $mail_user[0];
120117

121118
$ispconfig_version = $soap->server_get_app_version($session_id);
122119
if (version_compare($ispconfig_version['ispc_app_version'], '3.1dev', '<')) {
123-
$startdate = array('year' => substr($params['autoresponder_start_date'], 0, 4),
120+
$startdate = [
121+
'year' => substr($params['autoresponder_start_date'], 0, 4),
124122
'month' => substr($params['autoresponder_start_date'], 5, 2),
125123
'day' => substr($params['autoresponder_start_date'], 8, 2),
126124
'hour' => substr($params['autoresponder_start_date'], 11, 2),
127-
'minute' => substr($params['autoresponder_start_date'], 14, 2));
125+
'minute' => substr($params['autoresponder_start_date'], 14, 2)
126+
];
128127

129-
$enddate = array('year' => substr($params['autoresponder_end_date'], 0, 4),
128+
$enddate = [
129+
'year' => substr($params['autoresponder_end_date'], 0, 4),
130130
'month' => substr($params['autoresponder_end_date'], 5, 2),
131131
'day' => substr($params['autoresponder_end_date'], 8, 2),
132132
'hour' => substr($params['autoresponder_end_date'], 11, 2),
133-
'minute' => substr($params['autoresponder_end_date'], 14, 2));
133+
'minute' => substr($params['autoresponder_end_date'], 14, 2)
134+
];
134135

135136
$params['autoresponder_end_date'] = $enddate;
136137
$params['autoresponder_start_date'] = $startdate;
@@ -139,7 +140,7 @@ function save()
139140
$params['password'] = $newpwd;
140141

141142
$uid = $soap->client_get_id($session_id, $mail_user[0]['sys_userid']);
142-
$update = $soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params);
143+
$soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params);
143144
$soap->logout($session_id);
144145

145146
$this->rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
@@ -161,11 +162,13 @@ function save()
161162

162163
function gen_form($attrib)
163164
{
164-
$this->rcmail->output->add_label('ispconfig3_pass.nopassword',
165+
$this->rcmail->output->add_label(
166+
'ispconfig3_pass.nopassword',
165167
'ispconfig3_pass.nocurpassword',
166168
'ispconfig3_pass.passwordinconsistency',
167169
'ispconfig3_pass.changepasswd',
168-
'ispconfig3_pass.passwordminlength');
170+
'ispconfig3_pass.passwordminlength'
171+
);
169172

170173
$confirm = $this->rcmail->config->get('password_confirm_current');
171174
$pwl = $this->rcmail->config->get('password_min_length');
@@ -180,33 +183,33 @@ function gen_form($attrib)
180183
$this->rcmail->output->add_script('var pw_min_length =' . $pwl . ';');
181184

182185
$form_id = $attrib['id'] ?: 'form';
183-
$out = $this->rcmail->output->request_form(array(
186+
$out = $this->rcmail->output->request_form([
184187
'id' => $form_id,
185188
'name' => $form_id,
186189
'method' => 'post',
187190
'task' => 'settings',
188191
'action' => 'plugin.ispconfig3_pass.save',
189192
'noclose' => true
190-
) + $attrib);
193+
] + $attrib);
191194

192195
$out .= '<fieldset><legend>' . $this->gettext('password') . '</legend>' . "\n";
193196

194-
$table = new html_table(array('cols' => 2, 'class' => 'propform'));
197+
$table = new html_table(['cols' => 2, 'class' => 'propform']);
195198

196199
if ($confirm) {
197200
$field_id = 'curpasswd';
198-
$input_newpasswd = new html_passwordfield(array('name' => '_' . $field_id, 'id' => $field_id, 'size' => 20));
201+
$input_newpasswd = new html_passwordfield(['name' => '_' . $field_id, 'id' => $field_id, 'size' => 20]);
199202
$table->add('title', html::label($field_id, rcube::Q($this->gettext('curpasswd'))));
200203
$table->add('', $input_newpasswd->show());
201204
}
202205

203206
$field_id = 'newpasswd';
204-
$input_newpasswd2 = new html_passwordfield(array('name' => '_' . $field_id, 'id' => $field_id, 'size' => 20));
207+
$input_newpasswd2 = new html_passwordfield(['name' => '_' . $field_id, 'id' => $field_id, 'size' => 20]);
205208
$table->add('title', html::label($field_id, rcube::Q($this->gettext('newpasswd'))));
206209
$table->add('', $input_newpasswd2->show() . '<div id="pass-check">');
207210

208211
$field_id = 'confpasswd';
209-
$input_confpasswd = new html_passwordfield(array('name' => '_' . $field_id, 'id' => $field_id, 'size' => 20));
212+
$input_confpasswd = new html_passwordfield(['name' => '_' . $field_id, 'id' => $field_id, 'size' => 20]);
210213
$table->add('title', html::label($field_id, rcube::Q($this->gettext('confpasswd'))));
211214
$table->add('', $input_confpasswd->show());
212215

0 commit comments

Comments
 (0)