diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index 782c06b3..5b897c27 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -896,6 +896,31 @@ class rcube_kolab_contacts extends rcube_addressbook return false; } + /** + * Check the given data before saving. + * If input not valid, the message to display can be fetched using get_error() + * + * @param array Associative array with contact data to save + * + * @return boolean True if input is valid, False if not. + */ + public function validate($save_data) + { + // validate e-mail addresses + $valid = parent::validate($save_data); + + // require at least one e-mail address (syntax check is already done) + if ($valid) { + if (!strlen($save_data['name']) + && !array_filter($this->get_col_values('email', $save_data, true)) + ) { + $this->set_error('warning', 'kolab_addressbook.noemailnamewarning'); + $valid = false; + } + } + + return $valid; + } /** * Establishes a connection to the Kolab_Data object for accessing contact data @@ -907,7 +932,6 @@ class rcube_kolab_contacts extends rcube_addressbook } } - /** * Establishes a connection to the Kolab_Data object for accessing groups data */ @@ -918,7 +942,6 @@ class rcube_kolab_contacts extends rcube_addressbook } } - /** * Simply fetch all records and store them in private member vars */ @@ -945,7 +968,6 @@ class rcube_kolab_contacts extends rcube_addressbook } } - /** * Callback function for sorting contacts */ @@ -954,7 +976,6 @@ class rcube_kolab_contacts extends rcube_addressbook return strcasecmp($a['name'], $b['name']); } - /** * Read distribution-lists AKA groups from server */ @@ -979,7 +1000,6 @@ class rcube_kolab_contacts extends rcube_addressbook } } - /** * Map fields from internal Kolab_Format to Roundcube contact format */ @@ -1030,6 +1050,9 @@ class rcube_kolab_contacts extends rcube_addressbook return array_filter($out); } + /** + * Map fields from Roundcube format to internal Kolab_Format + */ private function _from_rcube_contact($contact) { $object = array(); diff --git a/plugins/kolab_addressbook/localization/en_US.inc b/plugins/kolab_addressbook/localization/en_US.inc index ce90f60a..f3cb17ea 100644 --- a/plugins/kolab_addressbook/localization/en_US.inc +++ b/plugins/kolab_addressbook/localization/en_US.inc @@ -25,12 +25,13 @@ $labels['globalonly'] = 'Global address book(s) only'; $messages['bookdeleteconfirm'] = 'Do you really want to delete the selected address book and all contacts in it?'; $messages['bookdeleting'] = 'Deleting address book...'; $messages['booksaving'] = 'Saving address book...'; -$messages['bookdeleted'] = 'Address book deleted successfully'; -$messages['bookupdated'] = 'Address book updated successfully'; -$messages['bookcreated'] = 'Address book created successfully'; -$messages['bookdeleteerror'] = 'An error occured while deleting address book'; -$messages['bookupdateerror'] = 'An error occured while updating address book'; -$messages['bookcreateerror'] = 'An error occured while creating address book'; -$messages['nobooknamewarning'] = 'Please, enter address book name'; +$messages['bookdeleted'] = 'Address book deleted successfully.'; +$messages['bookupdated'] = 'Address book updated successfully.'; +$messages['bookcreated'] = 'Address book created successfully.'; +$messages['bookdeleteerror'] = 'An error occured while deleting address book.'; +$messages['bookupdateerror'] = 'An error occured while updating address book.'; +$messages['bookcreateerror'] = 'An error occured while creating address book.'; +$messages['nobooknamewarning'] = 'Please, enter address book name.'; +$messages['noemailnamewarning'] = 'Please, enter email address or contact name.'; ?> diff --git a/plugins/kolab_addressbook/localization/pl_PL.inc b/plugins/kolab_addressbook/localization/pl_PL.inc index 61887231..e2735783 100644 --- a/plugins/kolab_addressbook/localization/pl_PL.inc +++ b/plugins/kolab_addressbook/localization/pl_PL.inc @@ -25,12 +25,13 @@ $labels['parentbook'] = 'Książka nadrzędna'; $messages['bookdeleteconfirm'] = 'Czy na pewno chcesz usunąć wybraną książkę i wszystkie kontakty w niej zapisane?'; $messages['bookdeleting'] = 'Usuwanie książki adresowej...'; $messages['booksaving'] = 'Zapisywanie książki adresowej...'; -$messages['bookdeleted'] = 'Książka adresowa została usunięta'; -$messages['bookupdated'] = 'Książka adresowa została zaktualizowana'; -$messages['bookcreated'] = 'Książka adresowa została utworzona'; -$messages['bookdeleteerror'] = 'Wystąpił błąd podczas usuwania książki adresowej'; -$messages['bookupdateerror'] = 'Wystąpił błąd podczas zmiany książki adresowej'; -$messages['bookcreateerror'] = 'Wystąpił błąd podczas tworzenia książki adresowej'; -$messages['nobooknamewarning'] = 'Proszę podać nazwę książki adresowej'; +$messages['bookdeleted'] = 'Książka adresowa została usunięta.'; +$messages['bookupdated'] = 'Książka adresowa została zaktualizowana.'; +$messages['bookcreated'] = 'Książka adresowa została utworzona.'; +$messages['bookdeleteerror'] = 'Wystąpił błąd podczas usuwania książki adresowej.'; +$messages['bookupdateerror'] = 'Wystąpił błąd podczas zmiany książki adresowej.'; +$messages['bookcreateerror'] = 'Wystąpił błąd podczas tworzenia książki adresowej.'; +$messages['nobooknamewarning'] = 'Proszę podać nazwę książki adresowej.'; +$messages['noemailnamewarning'] = 'Proszę podać adres email lub nazwę kontaktu.'; ?>