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)
|
if (strcasecmp($args['record']['email'], $rc->user->data['username']) === 0)
|
||||||
return $args;
|
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
|
// Check field values
|
||||||
$noErrors = false;
|
$noErrors = false;
|
||||||
@@ -234,7 +244,7 @@ class ident_switch extends rcube_plugin
|
|||||||
|
|
||||||
if (!$noErrors)
|
if (!$noErrors)
|
||||||
{
|
{
|
||||||
//$rc->output->send();
|
$this->add_texts('localization');
|
||||||
$args['abort'] = true;
|
$args['abort'] = true;
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
@@ -248,20 +258,15 @@ class ident_switch extends rcube_plugin
|
|||||||
$rc->db->table_name($this->table) .
|
$rc->db->table_name($this->table) .
|
||||||
' SET flags = ?, label = ?, host = ?, port = ?, username = ?, password = ?, delimiter = ?, user_id = ?, iid = ?';
|
' SET flags = ?, label = ?, host = ?, port = ?, username = ?, password = ?, delimiter = ?, user_id = ?, iid = ?';
|
||||||
}
|
}
|
||||||
else
|
else if ($flags & $this->db_enabled)
|
||||||
{ // No record exists, create new one
|
{ // No record exists, create new one
|
||||||
$sql = 'INSERT INTO ' .
|
$sql = 'INSERT INTO ' .
|
||||||
$rc->db->table_name($this->table) .
|
$rc->db->table_name($this->table) .
|
||||||
'(flags, label, host, port, username, password, delimiter, user_id, iid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
'(flags, label, host, port, username, password, delimiter, user_id, iid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process boolean fields
|
if ($sql)
|
||||||
$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;
|
|
||||||
|
|
||||||
// Do we need to update pwd?
|
// Do we need to update pwd?
|
||||||
$fPass = get_input_value('_ident_switch_form_password', RCUBE_INPUT_POST);
|
$fPass = get_input_value('_ident_switch_form_password', RCUBE_INPUT_POST);
|
||||||
if ($fPass != $r['password'])
|
if ($fPass != $r['password'])
|
||||||
@@ -279,6 +284,7 @@ class ident_switch extends rcube_plugin
|
|||||||
$rc->user->ID,
|
$rc->user->ID,
|
||||||
$args['id']
|
$args['id']
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $args;
|
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)
|
protected static function ntrim($str)
|
||||||
{
|
{
|
||||||
if (is_null($str))
|
if (is_null($str))
|
||||||
|
|||||||
Reference in New Issue
Block a user