[turba] name sorting

Babita brana at ualberta.ca
Tue Mar 11 22:06:40 UTC 2008


Hi Liam,

We had that same sorting problem you're encountering. The sorting function 
does ignore the first name when sorting 'last_first'. We did a local hack 
to fix the problem. Edit the cmp function in horde/turba/lib/List.php to 
read:

     function cmp($a, $b)
     {
         switch ($this->_usortType) {
         case 'int':
             return ($a->getValue($this->_usortCriteria) > $b->getValue($this->_usortCriteria)) ? 1 : -1;
             break;

         case 'text':
         default:
             $acmp = String::lower($a->getValue($this->_usortCriteria), true);
             $bcmp = String::lower($b->getValue($this->_usortCriteria), true);

 		/* start local hack */
                 if ($this->_usortCriteria == 'lastname') {
                         $mya = String::lower($a->getValue('name'), true);
                         $myb = String::lower($b->getValue('name'), true);
                         $acmp .= " $mya";
                         $bcmp .= " $myb";
                 }
 		/* end local hack */

             // Use strcoll for locale-safe comparisons.
             return strcoll($acmp, $bcmp);
         }
     }


That should do it.

--
Babita Rana
AICT
University of Alberta



On Tue, 11 Mar 2008, Liam Hoekenga wrote:

> Ok.. so, in order to have our addressbooks sorted alphabetically by
> lastname / surname, it looks like I've got to set $_prefs['name_format']
> to 'last_first'.
>
> What I have noticed, though, is that it only then sorts by lastname; the
> firstname isn't taken into account.  I'm guessing it's display in the
> order that the entries were added to the database.
>
> So, rather than getting..
>
>   Smith, Abel
>   Smith, Barry
>   Smith, Chris
>   Smith, Doug
>
> I might get..
>
>   Smith, Barry
>   Smith, Doug
>   Smith, Abel
>   Smith, Chris
>
> Is it possible to configure turba to sort by lastname, and then firstname?
>
> Is it possible to configure turba to display the addressbook in
> alphabetical order by lastname, without setting $_pref['name_format']?
> (Should it /always/ sort by lastname?).  Would it make sense to see...
>
>   Abel Smith
>   Barry Smith
>   ...
>
> ... if name_format was set to first_last, and the user clicked "S"?
>
> Liam
> -- 
> Turba mailing list - Join the hunt: http://horde.org/bounties/#turba
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: turba-unsubscribe at lists.horde.org
>
>


More information about the turba mailing list