'column' => _("Display Options"),
'label' => _("Name Format"),
'desc' => _("Select which format to display names."),
- 'members' => array('name_format'),
+ 'members' => array('name_format', 'name_sort'),
);
// Address Book selection widget
'locked' => false,
'shared' => false,
'type' => 'enum',
- 'desc' => _("Select the format used to display names:"),
+ 'desc' => _("Select the format used to <em>display</em> names:"),
+ 'enum' => array('last_first' => _("\"Lastname, Firstname\" (ie. Doe, John)"),
+ 'first_last' => _("\"Firstname Lastname\" (ie. John Doe)"),
+ 'none' => _("no formatting")),
+);
+
+// the format to sort names. Either 'last_first' or 'first_last'
+$_prefs['name_sort'] = array(
+ 'value' => 'none',
+ 'locked' => false,
+ 'shared' => false,
+ 'type' => 'enum',
+ 'desc' => _("Select the format used to <em>sort</em> names:"),
'enum' => array('last_first' => _("\"Lastname, Firstname\" (ie. Doe, John)"),
'first_last' => _("\"Firstname Lastname\" (ie. John Doe)"),
'none' => _("no formatting")),
v2.3.3-cvs
----------
+[jan] Add preference for the name format to use for sorting (Request #6721).
[jan] Condense whitespace in composite fields (Request #8654).
[jan] Add and fix Oracle-specific SQL scripts.
[jan] Add Croatian translation (Matej Vela <matej.vela@carnet.hr>,
class Turba_ListView_AlphaFilter {
var $_alpha;
+ var $_format;
function Turba_ListView_AlphaFilter($alpha)
{
$this->_alpha = Horde_String::lower($alpha);
+ $this->_format = $GLOBALS['prefs']->getValue('name_sort');
}
function skip(&$ob)
{
- $name = Turba::formatName($ob);
- if ($this->_alpha != '*' && Horde_String::lower(substr($name, 0, 1)) != $this->_alpha) {
+ $name = Turba::formatName($ob, $this->_format);
+ if ($this->_alpha != '*' &&
+ Horde_String::lower(substr($name, 0, 1)) != $this->_alpha) {
return true;
}
return false;
/**
* Formats the name according to the user's preference.
*
- * @param Turba_Object $ob The object to get a name from.
+ * @param Turba_Object $ob The object to get a name from.
+ * @param string $name_format The formatting. One of 'none', 'last_first'
+ * or 'first_last'.
*
* @return string The formatted name, either "Firstname Lastname"
- * or "Lastname, Firstname" depending on the user's
- * preference.
+ * or "Lastname, Firstname" depending on $name_format or
+ * the user's preference.
*/
- function formatName($ob)
+ function formatName($ob, $name_format = null)
{
- global $prefs;
- static $name_format;
+ static $default_format;
- if (!isset($name_format)) {
- $name_format = $prefs->getValue('name_format');
+ if (!$name_format) {
+ if (!isset($default_format)) {
+ $default_format = $GLOBALS['prefs']->getValue('name_format');
+ }
+ $name_format = $default_format;
}
/* if no formatting, return original name */