diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php
index 4fe88171403c47624964a5e90b68852b6cea4731..e5ffc04143a6599336520ae034ad44ba507265af 100644
--- a/apps/calendar/lib/share.php
+++ b/apps/calendar/lib/share.php
@@ -18,19 +18,16 @@ class OC_Calendar_Share{
 	 * @return: array $return - information about calendars
 	 */
 	public static function allSharedwithuser($userid, $type, $active=null, $permission=null){
-		$group_where = self::group_sql(OC_Group::getUserGroups($userid));
-		$permission_where = self::permission_sql($permission);
-		if($type == self::CALENDAR){
-			$active_where = self::active_sql($active);
-		}else{
-			$active_where = '';
-		}
-		$stmt = OCP\DB::prepare("SELECT * FROM *PREFIX*calendar_share_" . $type . " WHERE ((share = ? AND sharetype = 'user') " . $group_where . ") AND owner <> ? " . $permission_where . " " . $active_where);
-		$result = $stmt->execute(array($userid, $userid));
-		$return = array();
-		while( $row = $result->fetchRow()){
-			$return[] = $row;
+		$format = OC_Share_Backend_Calendar::FORMAT_CALENDAR;
+		if ($type == self::EVENT) {
+			$format = OC_Share_Backend_Event::FORMAT_EVENT;
 		}
+		$return = OCP\Share::getItemsSharedWith($type,
+			$format,
+			array(
+				'active' => $active,
+				'permissions' => $permission,
+			));
 		return $return;
 	}
 	/**
diff --git a/apps/calendar/lib/share/calendar.php b/apps/calendar/lib/share/calendar.php
index 9b68437531f2d08a27c83875abade2c8c55f0f3a..0ddca2400a9cb4c05a5b0875c9bdc51968e291bc 100644
--- a/apps/calendar/lib/share/calendar.php
+++ b/apps/calendar/lib/share/calendar.php
@@ -43,8 +43,14 @@ class OC_Share_Backend_Calendar implements OCP\Share_Backend_Collection {
 		$calendars = array();
 		if ($format == self::FORMAT_CALENDAR) {
 			foreach ($items as $item) {
-				$calendar = OC_Calendar_App::getCalendar($item['item_source']);
+				$calendar = OC_Calendar_App::getCalendar($item['item_source'], false);
+				// TODO: really check $parameters['permissions'] == 'rw'/'r'
+				if ($parameters['permissions'] == 'rw') {
+					continue; // TODO
+				}
 				$calendar['displaynamename'] = $item['item_target'];
+				$calendar['calendarid'] = $calendar['id'];
+				$calendar['owner'] = $calendar['userid'];
 				$calendars[] = $calendar;
 			}
 		}