summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/lib/Roundcube/rcube_addressbook.php17
-rw-r--r--program/lib/Roundcube/rcube_contacts.php4
2 files changed, 17 insertions, 4 deletions
diff --git a/program/lib/Roundcube/rcube_addressbook.php b/program/lib/Roundcube/rcube_addressbook.php
index 6e2b439d8..b245ea69d 100644
--- a/program/lib/Roundcube/rcube_addressbook.php
+++ b/program/lib/Roundcube/rcube_addressbook.php
@@ -209,6 +209,7 @@ abstract class rcube_addressbook
public function validate(&$save_data, $autofix = false)
{
$rcube = rcube::get_instance();
+ $valid = true;
// check validity of email addresses
foreach ($this->get_col_values('email', $save_data, true) as $email) {
@@ -216,12 +217,24 @@ abstract class rcube_addressbook
if (!rcube_utils::check_email(rcube_utils::idn_to_ascii($email))) {
$error = $rcube->gettext(array('name' => 'emailformaterror', 'vars' => array('email' => $email)));
$this->set_error(self::ERROR_VALIDATE, $error);
- return false;
+ $valid = false;
+ break;
}
}
}
- return true;
+ // allow plugins to do contact validation and auto-fixing
+ $plugin = $rcube->plugins->exec_hook('contact_validate', array(
+ 'record' => $save_data,
+ 'autofix' => $autofix,
+ 'valid' => $valid,
+ ));
+
+ if (is_array($plugin['record'])) {
+ $save_data = $plugin['record'];
+ }
+
+ return $plugin['valid'];
}
/**
diff --git a/program/lib/Roundcube/rcube_contacts.php b/program/lib/Roundcube/rcube_contacts.php
index 6d01368a1..5c9e5ab39 100644
--- a/program/lib/Roundcube/rcube_contacts.php
+++ b/program/lib/Roundcube/rcube_contacts.php
@@ -592,8 +592,8 @@ class rcube_contacts extends rcube_addressbook
// validate e-mail addresses
$valid = parent::validate($save_data, $autofix);
- // require at least one e-mail address (syntax check is already done)
- if ($valid && !array_filter($this->get_col_values('email', $save_data, true))) {
+ // require at least one email address or a name
+ if ($valid && !strlen($save_data['firstname'].$save_data['surname'].$save_data['name']) && !array_filter($this->get_col_values('email', $save_data, true))) {
$this->set_error(self::ERROR_VALIDATE, 'noemailwarning');
$valid = false;
}