Beispiel #1
0
sqgetGlobalVar('compose_to', $compose_to, SQ_POST);
sqgetGlobalVar('sel', $sel, SQ_POST);
sqgetGlobalVar('oldnick', $oldnick, SQ_POST);
sqgetGlobalVar('backend', $backend, SQ_POST);
sqgetGlobalVar('doedit', $doedit, SQ_POST);
$page_size = $abook_show_num;
if (!sqGetGlobalVar('page_number', $page_number, SQ_FORM)) {
    if (!sqGetGlobalVar('current_page_number', $page_number, SQ_FORM)) {
        $page_number = 1;
    }
}
if (!sqGetGlobalVar('show_all', $show_all, SQ_FORM)) {
    $show_all = 0;
}
/* Get sorting order */
$abook_sort_order = get_abook_sort();
// Create page header before addressbook_init in order to
// display error messages correctly, unless we might be
// redirecting the browser to the compose page.
//
if (empty($compose_to) || sizeof($sel) < 1) {
    displayPageHeader($color);
}
/* Open addressbook with error messages on.
 remote backends (LDAP) are enabled because they can be used. (list_addr function)
*/
$abook = addressbook_init(true, false);
// FIXME: do we really have to stop use of address book when localbackend is not present?
if ($abook->localbackend == 0) {
    plain_error_message(_("No personal address book is defined. Contact administrator."));
    exit;
/**
 * Sort array by the key "name"
 */
function alistcmp($a, $b)
{
    $abook_sort_order = get_abook_sort();
    switch ($abook_sort_order) {
        case 0:
        case 1:
            $abook_sort = 'nickname';
            break;
        case 4:
        case 5:
            $abook_sort = 'email';
            break;
        case 6:
        case 7:
            $abook_sort = 'label';
            break;
        case 2:
        case 3:
        case 8:
        default:
            $abook_sort = 'name';
    }
    if ($a['backend'] > $b['backend']) {
        return 1;
    } else {
        if ($a['backend'] < $b['backend']) {
            return -1;
        }
    }
    if (($abook_sort_order + 2) % 2 == 1) {
        return strtolower($a[$abook_sort]) < strtolower($b[$abook_sort]) ? 1 : -1;
    } else {
        return strtolower($a[$abook_sort]) > strtolower($b[$abook_sort]) ? 1 : -1;
    }
}