]> source.dussan.org Git - nextcloud-server.git/commitdiff
add public sharing fir calendars and events - add function in Share class
authorGeorg Ehrke <dev@georgswebsite.de>
Sat, 31 Mar 2012 20:12:27 +0000 (16:12 -0400)
committerGeorg Ehrke <dev@georgswebsite.de>
Sat, 31 Mar 2012 20:12:27 +0000 (16:12 -0400)
apps/calendar/lib/share.php

index 42dfc8a31016029b08dbfc537ebeb917f49568e8..3e03a2d7ccf9dd668f29464a3767b8919323eba3 100644 (file)
@@ -218,4 +218,27 @@ class OC_Calendar_Share{
                }
                return false;
        }
+        /*
+         * @brief: returns the calendardata of an event or a calendar
+         * @param: (string) $token - token which should be searched
+         * @return: mixed - bool if false, array with type and id if true
+         */
+        public static function getElementByToken($token){
+            $stmt_calendar = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::CALENDAR . ' WHERE sharetype = "public" AND share = ?');
+            $result_calendar = $stmt_calendar->execute(array($token));
+            $stmt_event = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . OC_Calendar_Share::EVENT . ' WHERE sharetype = "public" AND share = ?');
+            $result_event = $stmt_calendar->execute(array($token));
+            $return = array();
+            if($result_calendar->numRows() == 0 && $result_event->numRows() == 0){
+                return false;
+            }elseif($result_calendar->numRows() != 0){
+                $return ['type'] = 'calendar';
+                $calendar = $result_calendar->fetchRow();
+                $return ['id'] = $calendar['calendarid'];
+            }else{
+                $return ['type'] = 'event';
+                $event = $result_event->fetchRow();
+                $return ['id'] = $event['eventid'];
+            }
+        }
 }
\ No newline at end of file