/**
*/
public function davGetCollections($user)
{
global $injector, $registry;
$hordeUser = $registry->convertUsername($user, true);
$dav = $injector->getInstance('Horde_Dav_Storage');
$factory = $injector->getInstance('Turba_Shares');
$books = array();
foreach (Turba::getAddressBooks(Horde_Perms::SHOW) as $id => $book) {
$readOnly = false;
switch ($book['type']) {
// Ugly hack! There is currently no clean way to retrieve address
// books that the user "owns", or to find out if a SQL/LDAP/Kolab
// address book contains per-user or global contacts.
case 'share':
$share = $factory->getShare($id);
if ($user == '-system-' && strlen($share->get('owner')) || $user != '-system-' && $hordeUser != $share->get('owner') && $hordeUser != $registry->getAuth()) {
continue;
}
$readOnly = !$share->hasPermission($hordeUser, Horde_Perms::EDIT);
break;
case 'facebook':
case 'favourites':
case 'vbook':
if ($user == '-system-') {
continue;
}
$readOnly = true;
break;
default:
if (!Turba::permissionsFilter(array($id => $book), Horde_Perms::EDIT)) {
$readOnly = true;
}
break;
}
try {
$id = $dav->getExternalCollectionId($id, 'contacts') ?: $id;
} catch (Horde_Dav_Exception $e) {
}
$books[] = array('id' => $id, 'uri' => $id, 'principaluri' => 'principals/' . $user, '{DAV:}displayname' => $book['title'], '{' . CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' => new CardDAV\Property\SupportedAddressData(array(array('contentType' => 'text/directory', 'version' => '3.0'), array('contentType' => 'text/vcard', 'version' => '3.0'), array('contentType' => 'text/x-vcard', 'version' => '2.1'))), '{http://sabredav.org/ns}read-only' => $readOnly);
}
return $books;
}