From 3d8d6d718b65a972648ce7678cda13b2e1117272 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Tue, 21 Feb 2012 20:10:52 +0100 Subject: [PATCH] add 'permissions' as a sql condition in allSharedwithuser --- apps/calendar/lib/share.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index d66095b9771..be2b440c647 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -17,7 +17,7 @@ class OC_Calendar_Share{ * @param: (string) $type - use const self::CALENDAR or self::EVENT * @return: (array) $return - information about calendars */ - public static function allSharedwithuser($userid, $type, $active=null){ + public static function allSharedwithuser($userid, $type, $active=null, $permission=null){ $group_where = ''; $groups = OC_Group::getUserGroups($userid); $i = 0; @@ -30,7 +30,12 @@ class OC_Calendar_Share{ $group_where .= ' (share = \'' . $group . '\' AND sharetype = \'group\') '; $i++; } - $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = \'user\') ' . $group_where . ') AND owner <> ?' . ((!is_null($active) && $active)?' AND active = 1)':')')); + $permission_where = ''; + if(!is_null($permission)){ + $permission_where = 'AND permissions = '; + $permission_where .= ($permission=='rw')?'1':'0'; + } + $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = \'user\') ' . $group_where . ') AND owner <> ? ' . $permission_where . ' ' . ((!is_null($active) && $active)?' AND active = 1)':')')); $result = $stmt->execute(array($userid, $userid)); $return = array(); while( $row = $result->fetchRow()){