cdav migration to core

This commit is contained in:
zotlabs
2017-06-22 20:16:54 -07:00
parent 681d6ca1dd
commit 02b7bc0803
5 changed files with 371 additions and 6 deletions

View File

@@ -1236,3 +1236,71 @@ function tasks_fetch($arr) {
return $ret;
}
function cdav_principal($uri) {
$r = q("SELECT uri FROM principals WHERE uri = '%s' LIMIT 1",
dbesc($uri)
);
if($r[0]['uri'] === $uri)
return true;
else
return false;
}
function cdav_perms($needle, $haystack, $check_rw = false) {
foreach ($haystack as $item) {
if($check_rw) {
if(is_array($item['id'])) {
if ($item['id'][0] == $needle && $item['share-access'] != 2) {
return $item['{DAV:}displayname'];
}
}
else {
if ($item['id'] == $needle && $item['share-access'] != 2) {
return $item['{DAV:}displayname'];
}
}
}
else {
if(is_array($item['id'])) {
if ($item['id'][0] == $needle) {
return $item['{DAV:}displayname'];
}
}
else {
if ($item['id'] == $needle) {
return $item['{DAV:}displayname'];
}
}
}
}
return false;
}
function translate_type($type) {
if(!$type)
return;
$type = strtoupper($type);
$map = [
'CELL' => t('Mobile'),
'HOME' => t('Home'),
'HOME,VOICE' => t('Home, Voice'),
'HOME,FAX' => t('Home, Fax'),
'WORK' => t('Work'),
'WORK,VOICE' => t('Work, Voice'),
'WORK,FAX' => t('Work, Fax'),
'OTHER' => t('Other')
];
if (array_key_exists($type, $map)) {
return [$type, $map[$type]];
}
else {
return [$type, t('Other') . ' (' . $type . ')'];
}
}