<?php
if ($registry->hasMethod('contacts/sources')) {
    $address_books = $registry->call('contacts/sources');
    $address_bookSaved = unserialize($prefs->getValue('search_abook'));
    $address_bookSelect = '';

    foreach ($address_books as $address_book => $description) {
        if (!is_bool(array_search($address_book, $address_bookSaved))) {
            $address_bookSelect .= '<option value="' . $address_book . '" selected>' . $description . '</option>';
        } else {
            $address_bookSelect .= '<option value="' . $address_book . '">' . $description . '</option>';
        }
    }
}

if (!$prefs->isLocked('search_abook') && isset($address_bookSelect)) {
    echo _("Choose the address books to search for free/busy URLs:") . '<br />';
    echo '<select multiple="multiple" name="search_abook[]">' . $address_bookSelect . '</select>';
}
