Use new sharing API in OC_Calendar_Share::allSharedwithuser

This commit is contained in:
Bart Visscher 2012-08-07 23:31:06 +02:00
parent d4882df8cb
commit 35a1738a39
2 changed files with 16 additions and 13 deletions

View File

@ -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;
}
/**

View File

@ -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;
}
}