Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 4.12.3
-
Component/s: None
-
Labels:None
Description
- Under Settings > Company > Client Options > General Client Settings, Enable email verification
- Under Settings > Company > Client Options > Required Client Field select Address 1
- Login as a client
- Change their email under the account settings
- Go back to the client profile in the admin interface and switch them to verified
- See that the contact email is not updated
To fix:
In app/models/contacts.php starting at line 1400 change:
$rules = array_merge($rules, $this->getRequiredFieldRules($vars['client_id']));
To
$rules = array_merge($rules, $this->getRequiredFieldRules($vars['client_id'], $edit));
Replace the getRequiredFieldRules() with
/**
* Gets the rules for all contact fields that are require by the client group
*
* @param int $client_id The ID of the client this contact is associated with
* @param bool $edit Whether this data is being validated for an edit (optional, default false)
* @return array A list of rules with the addition of the client groups required fields
*/
private function getRequiredFieldRules($client_id, $edit = false)
{
Loader::loadModels($this, ['ClientGroups']);
$required_fields = [];
$client = $this->Record->select('client_group_id')
->from('clients')
->where('id', '=', $client_id)
->fetch();
if ($client) {
$required_contact_fields = $this->ClientGroups->getSetting(
$client->client_group_id,
'required_contact_fields'
);
if ($required_contact_fields) {
$required_fields = unserialize(base64_decode($required_contact_fields->value));
}
}
$rules = [];
foreach ($required_fields as $field) {
$rules[$field]['empty'] = [
'if_set' => $edit,
'rule' => 'isEmpty',
'negate' => true,
'message' => $this->_('Contacts.!error.' . $field . '.empty')
];
}
return $rules;
}