summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-02-06 22:21:23 +0000
committerthomascube <thomas@roundcube.net>2011-02-06 22:21:23 +0000
commit07b95dc49b31d131b1fecdabf2059a447935c196 (patch)
tree91f3fd3b86ecb88da28e16edceab52306bb3458e /program/steps
parent361ce60948bfc0eb75a4c144f9e1e76c3cdd7f35 (diff)
Delegate contact input validation to rcube_addressbook instance; accept already localized texts in rcube_output::show_message()
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/save.inc29
1 files changed, 10 insertions, 19 deletions
diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc
index 3d55d953c..10155a1a9 100644
--- a/program/steps/addressbook/save.inc
+++ b/program/steps/addressbook/save.inc
@@ -128,27 +128,18 @@ foreach ($GLOBALS['CONTACT_COLTYPES'] as $col => $colprop) {
}
}
-if (empty($a_record['name']))
- $a_record['name'] = join(' ', array_filter(array($a_record['prefix'], $a_record['firstname'], $a_record['middlename'], $a_record['surname'], $a_record['suffix'],)));
-
-
-// Basic input checks (TODO: delegate to $CONTACTS instance)
-if (empty($a_record['name'])/* || empty($a_record['email'])*/) {
- $OUTPUT->show_message('formincomplete', 'warning');
- rcmail_overwrite_action($return_action);
- return;
+if (empty($a_record['name'])) {
+ // TODO: let a dedicated function or a plugin compose the full name
+ $a_record['name'] = join(' ', array_filter(array($a_record['prefix'], $a_record['firstname'], $a_record['middlename'], $a_record['surname'], $a_record['suffix'],)));
}
-// Validity checks
-foreach ($CONTACTS->get_col_values('email', $a_record, true) as $email) {
- if (strlen($email)) {
- $_email = rcube_idn_to_ascii($email);
- if (!check_email($_email)) {
- $OUTPUT->show_message('emailformaterror', 'warning', array('email' => $email));
- rcmail_overwrite_action($return_action);
- return;
- }
- }
+
+// do input checks (delegated to $CONTACTS instance)
+if (!$CONTACTS->validate($a_record)) {
+ $err = (array)$CONTACTS->get_error() + array('message' => 'formincomplete', 'type' => 'warning');
+ $OUTPUT->show_message($err['message'], $err['type']);
+ rcmail_overwrite_action($return_action);
+ return;
}
// get raw photo data if changed