aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-06-22 20:16:54 -0700
committerzotlabs <mike@macgirvin.com>2017-06-22 20:16:54 -0700
commit02b7bc08033b21ea5438aa667e8dbb1fd72022bb (patch)
tree739cc3310448c1becfd66d15e8159ee3c47584c7 /include
parent681d6ca1dd1e5c16dfb73ada131f2d6b7a24f942 (diff)
downloadvolse-hubzilla-02b7bc08033b21ea5438aa667e8dbb1fd72022bb.tar.gz
volse-hubzilla-02b7bc08033b21ea5438aa667e8dbb1fd72022bb.tar.bz2
volse-hubzilla-02b7bc08033b21ea5438aa667e8dbb1fd72022bb.zip
cdav migration to core
Diffstat (limited to 'include')
-rw-r--r--include/event.php68
1 files changed, 68 insertions, 0 deletions
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 . ')'];
+ }
+}