[turba] name sorting

Liam Hoekenga liamr at umich.edu
Wed Apr 23 20:35:30 UTC 2008


Would the proper way to implement "firstname aware lastname sorting"  
be to submit a patch against horde/turba/lib/List.php, or to propose a  
new hook mechanism for sorting?

As it it, I believe that entries sorted by lastname are sorted  
properly by last name, firstname isn't taken into account.

Liam


Quoting Babita <brana at ualberta.ca>:

> 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
>>
>>
> --
> 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
>
> !DSPAM:47d7086f275842401011739!
>
>
>
>



More information about the turba mailing list