Fixed validation error when editing identity with Enabled not checked.
This commit is contained in:
@@ -186,8 +186,18 @@ class ident_switch extends rcube_plugin
|
||||
if (strcasecmp($args['record']['email'], $rc->user->data['username']) === 0)
|
||||
return $args;
|
||||
|
||||
// Process boolean fields
|
||||
$flags = 0;
|
||||
if (get_input_value('_ident_switch_form_enabled', RCUBE_INPUT_POST))
|
||||
$flags |= $this->db_enabled;
|
||||
if (get_input_value('_ident_switch_form_secure', RCUBE_INPUT_POST))
|
||||
$flags |= $this->db_secure;
|
||||
|
||||
$this->add_texts('localization');
|
||||
if (!($flags & $this->db_enabled))
|
||||
{
|
||||
$this->sw_imap_off($args['iid']);
|
||||
return $args;
|
||||
}
|
||||
|
||||
// Check field values
|
||||
$noErrors = false;
|
||||
@@ -234,7 +244,7 @@ class ident_switch extends rcube_plugin
|
||||
|
||||
if (!$noErrors)
|
||||
{
|
||||
//$rc->output->send();
|
||||
$this->add_texts('localization');
|
||||
$args['abort'] = true;
|
||||
return $args;
|
||||
}
|
||||
@@ -248,20 +258,15 @@ class ident_switch extends rcube_plugin
|
||||
$rc->db->table_name($this->table) .
|
||||
' SET flags = ?, label = ?, host = ?, port = ?, username = ?, password = ?, delimiter = ?, user_id = ?, iid = ?';
|
||||
}
|
||||
else
|
||||
else if ($flags & $this->db_enabled)
|
||||
{ // No record exists, create new one
|
||||
$sql = 'INSERT INTO ' .
|
||||
$rc->db->table_name($this->table) .
|
||||
'(flags, label, host, port, username, password, delimiter, user_id, iid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
}
|
||||
|
||||
// Process boolean fields
|
||||
$flags = 0;
|
||||
if (get_input_value('_ident_switch_form_enabled', RCUBE_INPUT_POST))
|
||||
$flags |= $this->db_enabled;
|
||||
if (get_input_value('_ident_switch_form_secure', RCUBE_INPUT_POST))
|
||||
$flags |= $this->db_secure;
|
||||
|
||||
if ($sql)
|
||||
{
|
||||
// Do we need to update pwd?
|
||||
$fPass = get_input_value('_ident_switch_form_password', RCUBE_INPUT_POST);
|
||||
if ($fPass != $r['password'])
|
||||
@@ -279,6 +284,7 @@ class ident_switch extends rcube_plugin
|
||||
$rc->user->ID,
|
||||
$args['id']
|
||||
);
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
@@ -397,6 +403,14 @@ class ident_switch extends rcube_plugin
|
||||
);
|
||||
}
|
||||
|
||||
protected function sw_imap_off($iid)
|
||||
{
|
||||
$rc = rcmail::get_instance();
|
||||
|
||||
$sql = 'UPDATE ' . $rc->db->table_name($this->table) . ' SET flags = flags & ? WHERE iid = ? AND user_id = ?';
|
||||
$rc->db->query($sql, ~$this->db_enabled, $iid, $rc->user->ID);
|
||||
}
|
||||
|
||||
protected static function ntrim($str)
|
||||
{
|
||||
if (is_null($str))
|
||||
|
||||
Reference in New Issue
Block a user