From 48f42176cdc1d75f2b9cd7b5c6d0cc4ee9050ced Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 22 Feb 2012 10:41:16 +0100 Subject: [PATCH] add is_editing_allowed function to OC_Calendar_Share --- apps/calendar/lib/share.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index 621ff8ce21..a5ca0a6e73 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -181,4 +181,21 @@ class OC_Calendar_Share{ } return $active_where; } + /* + * @brief: checks the permission for editing an event + * @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public) + * @param: (string) $id - id of the calendar / event + * @param: (string) $type - use const self::CALENDAR or self::EVENT + * @return (bool) + */ + public static function is_editing_allowed($share, $id, $type){ + $group_where = self::group_sql(OC_Group::getUserGroups($share)); + $permission_where = self::permission_sql('rw'); + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where . ')'); + $result = $stmt->execute(array($share)); + if($result->numRows() == 1){ + return true; + } + return false; + } } \ No newline at end of file