Skip to content
Browse files

Backported r5871 to 0.7 release branch

  • Loading branch information...
1 parent ba36dd0 commit 4dc22dd63417d6043489898d6ff9ac551c1b4231 @thomascube thomascube committed Feb 11, 2012
View
2 CHANGELOG
@@ -1,6 +1,8 @@
CHANGELOG Roundcube Webmail
===========================
+- User configurable setting how to display contact names in list
+- Make contacts list sorting configurable for the admin/user
- Fix parse errors in DDL files for MS SQL Server
- Revert SORT=DISPLAY support, removed by mistake (#1488327)
- Add lost translation label in de_DE (#1488315)
View
7 config/main.inc.php.dist
@@ -656,6 +656,13 @@ $rcmail_config['pagesize'] = 40;
// sort contacts by this col (preferably either one of name, firstname, surname)
$rcmail_config['addressbook_sort_col'] = 'surname';
+// the way how contact names are displayed in the list
+// 0: display name
+// 1: (prefix) firstname middlename surname (suffix)
+// 2: (prefix) surname firstname middlename (suffix)
+// 3: (prefix) surname, firstname middlename (suffix)
+$rcmail_config['addressbook_name_listing'] = 0;
+
// use this timezone to display date/time
$rcmail_config['timezone'] = 'auto';
View
48 program/include/rcube_addressbook.php
@@ -469,24 +469,24 @@ protected static function normalize_string($str)
* Compose a valid display name from the given structured contact data
*
* @param array Hash array with contact data as key-value pairs
- * @param bool The name will be used on the list
+ * @param bool Don't attempt to extract components from the email address
*
* @return string Display name
*/
- public static function compose_display_name($contact, $list_mode = false)
+ public static function compose_display_name($contact, $full_email = false)
{
$contact = rcmail::get_instance()->plugins->exec_hook('contact_displayname', $contact);
$fn = $contact['name'];
- if (!$fn)
+ if (!$fn) // default display name composition according to vcard standard
$fn = join(' ', array_filter(array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix'])));
// use email address part for name
$email = is_array($contact['email']) ? $contact['email'][0] : $contact['email'];
if ($email && (empty($fn) || $fn == $email)) {
- // Use full email address on contacts list
- if ($list_mode)
+ // return full email
+ if ($full_email)
return $email;
list($emailname) = explode('@', $email);
@@ -499,5 +499,43 @@ public static function compose_display_name($contact, $list_mode = false)
return $fn;
}
+
+ /**
+ * Compose the name to display in the contacts list for the given contact record.
+ * This respects the settings parameter how to list conacts.
+ *
+ * @param array Hash array with contact data as key-value pairs
+ * @return string List name
+ */
+ public static function compose_list_name($contact)
+ {
+ static $compose_mode;
+
+ if (!isset($compose_mode)) // cache this
+ $compose_mode = rcmail::get_instance()->config->get('addressbook_name_listing', 0);
+
+ if ($compose_mode == 3)
+ $fn = join(' ', array($contact['surname'] . ',', $contact['firstname'], $contact['middlename']));
+ else if ($compose_mode == 2)
+ $fn = join(' ', array($contact['surname'], $contact['firstname'], $contact['middlename']));
+ else if ($compose_mode == 1)
+ $fn = join(' ', array($contact['firstname'], $contact['middlename'], $contact['surname']));
+ else
+ $fn = !empty($contact['name']) ? $contact['name'] : join(' ', array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix']));
+
+ $fn = trim($fn, ', ');
+
+ // fallback to display name
+ if (empty($fn) && $contact['name'])
+ $fn = $contact['name'];
+
+ // fallback to email address
+ $email = is_array($contact['email']) ? $contact['email'][0] : $contact['email'];
+ if (empty($fn) && $email)
+ return $email;
+
+ return $fn;
+ }
+
}
View
7 program/include/rcube_contacts.php
@@ -250,13 +250,6 @@ function list_records($cols=null, $subset=0, $nocount=false)
$sql_arr['email'] = array_map('trim', $sql_arr['email']);
}
- // make sure we have a name to display
- if (empty($sql_arr['name'])) {
- if (empty($sql_arr['email']))
- $sql_arr['email'] = $this->get_col_values('email', $sql_arr, true);
- $sql_arr['name'] = $sql_arr['email'][0];
- }
-
$this->result->add($sql_arr);
}
View
1 program/localization/de_CH/labels.inc
@@ -385,6 +385,7 @@ $labels['reqdsn'] = 'Übermittlungsbestätigung (DSN) immer anfordern';
$labels['replysamefolder'] = 'Antworten im selben Ordner wie Original speichern';
$labels['defaultaddressbook'] = 'Neue Kontakte speichern in';
$labels['autocompletesingle'] = 'Keine alternativen E-Mail-Adressen in Autovervollständigung';
+$labels['listnamedisplay'] = 'Kontakte auflisten als';
$labels['spellcheckbeforesend'] = 'Rechtscheibung vor dem Senden prüfen';
$labels['spellcheckoptions'] = 'Rechtschreibprüfungsoptionen';
$labels['spellcheckignoresyms'] = 'Wörter mit Symbolen überspringen';
View
3 program/localization/de_DE/labels.inc
@@ -375,6 +375,8 @@ $labels['reqmdn'] = 'Empfangsbestätigung (MSN) immer anfordern';
$labels['reqdsn'] = 'Übermittlungsbestätigung (DSN) immer anfordern';
$labels['replysamefolder'] = 'Antworten im selben Ordner wie Original speichern';
$labels['defaultaddressbook'] = 'Neue Kontakte zum ausgewählten Adressbuch hinzufügen';
+$labels['autocompletesingle'] = 'Alternative E-Mailadressen bei der Auto-Vervollständigung nicht berücksichtigen';
+$labels['listnamedisplay'] = 'Kontakte auflisten als';
$labels['spellcheckbeforesend'] = 'Rechtschreibprüfung vor dem Absenden der Nachricht';
$labels['spellcheckoptions'] = 'Rechtschreibprüfungsoptionen';
$labels['spellcheckignoresyms'] = 'Wörter mit Symbolen überspringen';
@@ -427,6 +429,5 @@ $labels['vietnamese'] = 'Vietnamesisch';
$labels['japanese'] = 'Japanisch';
$labels['korean'] = 'Koreanisch';
$labels['chinese'] = 'Chinesisch';
-$labels['autocompletesingle'] = 'Alternative E-Mailadressen bei der Auto-Vervollständigung nicht berücksichtigen';
?>
View
1 program/localization/en_US/labels.inc
@@ -431,6 +431,7 @@ $labels['reqdsn'] = 'Always request a delivery status notification';
$labels['replysamefolder'] = 'Place replies in the folder of the message being replied to';
$labels['defaultaddressbook'] = 'Add new contacts to the selected addressbook';
$labels['autocompletesingle'] = 'Skip alternative email addresses in autocompletion';
+$labels['listnamedisplay'] = 'List contacts as';
$labels['spellcheckbeforesend'] = 'Check spelling before sending a message';
$labels['spellcheckoptions'] = 'Spellcheck Options';
$labels['spellcheckignoresyms'] = 'Ignore words with symbols';
View
8 program/steps/addressbook/func.inc
@@ -338,13 +338,9 @@ function rcmail_js_contacts_list($result, $prefix='')
// format each col
foreach ($a_show_cols as $col) {
- $val = $row[$col];
- if ($val == '' && $col == 'name') {
- $val = rcube_addressbook::compose_display_name($row, true);
- }
-
+ $val = $col == 'name' ? rcube_addressbook::compose_list_name($row) : $row[$col];
$a_row_cols[$col] = Q($val);
- }
+ }
$OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols);
}
View
3 program/steps/addressbook/save.inc
@@ -132,8 +132,7 @@ if (!empty($cid))
$a_js_cols = array();
$record = $CONTACTS->get_record($newcid ? $newcid : $cid, true);
$record['email'] = reset($CONTACTS->get_col_values('email', $record, true));
- if (empty($record['name']))
- $record['name'] = rcube_addressbook::compose_display_name($record, true);
+ $record['name'] = rcube_addressbook::compose_list_name($record);
foreach (array('name', 'email') as $col)
$a_js_cols[] = Q((string)$record[$col]);
View
5 program/steps/mail/addcontact.inc
@@ -58,7 +58,10 @@ if (!empty($_POST['_address']) && is_object($CONTACTS))
}
$contact['email'] = rcube_idn_to_utf8($contact['email']);
- $contact['name'] = rcube_addressbook::compose_display_name($contact);
+ $contact = $RCMAIL->plugins->exec_hook('contact_displayname', $contact);
+
+ if (empty($contact['firstname']) || empty($contact['surname']))
+ $contact['name'] = rcube_addressbook::compose_display_name($contact);
// validate contact record
if (!$CONTACTS->validate($contact, true)) {
View
15 program/steps/settings/func.inc
@@ -660,6 +660,21 @@ function rcmail_user_prefs($current=null)
);
}
+ // show addressbook listing mode selection
+ if (!isset($no_override['addressbook_name_listing'])) {
+ $field_id = 'rcmfd_addressbook_name_listing';
+ $select_listing = new html_select(array('name' => '_addressbook_name_listing', 'id' => $field_id));
+ $select_listing->add(rcube_label('name'), 0);
+ $select_listing->add(rcube_label('firstname') . ' ' . rcube_label('surname'), 1);
+ $select_listing->add(rcube_label('surname') . ' ' . rcube_label('firstname'), 2);
+ $select_listing->add(rcube_label('surname') . ', ' . rcube_label('firstname'), 3);
+
+ $blocks['main']['options']['list_name_listing'] = array(
+ 'title' => html::label($field_id, Q(rcube_label('listnamedisplay'))),
+ 'content' => $select_listing->show($config['addressbook_name_listing']),
+ );
+ }
+
// show addressbook sort column
if (!isset($no_override['addressbook_sort_col'])) {
$field_id = 'rcmfd_addressbook_sort_col';
View
3 program/steps/settings/save_prefs.inc
@@ -93,8 +93,9 @@ switch ($CURR_SECTION)
case 'addressbook':
$a_user_prefs = array(
'default_addressbook' => get_input_value('_default_addressbook', RCUBE_INPUT_POST, true),
- 'addressbook_sort_col' => get_input_value('_addressbook_sort_col', RCUBE_INPUT_POST),
'autocomplete_single' => isset($_POST['_autocomplete_single']) ? TRUE : FALSE,
+ 'addressbook_sort_col' => get_input_value('_addressbook_sort_col', RCUBE_INPUT_POST),
+ 'addressbook_name_listing' => intval(get_input_value('_addressbook_name_listing', RCUBE_INPUT_POST)),
);
break;

0 comments on commit 4dc22dd

Please sign in to comment.
Something went wrong with that request. Please try again.