From 02b7bc08033b21ea5438aa667e8dbb1fd72022bb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 22 Jun 2017 20:16:54 -0700 Subject: cdav migration to core --- include/event.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'include') diff --git a/include/event.php b/include/event.php index 001bd7dd3..b56a5fb3e 100644 --- a/include/event.php +++ b/include/event.php @@ -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 . ')']; + } +} -- cgit v1.2.3