add post user delete hook for calendar sharing

This commit is contained in:
Georg Ehrke 2012-05-13 20:03:27 +02:00
parent ee0294bbb1
commit ddf0903ace
2 changed files with 19 additions and 0 deletions

View File

@ -22,6 +22,8 @@ class OC_Calendar_Hooks{
OC_Calendar_Calendar::deleteCalendar($calendar['id']);
}
OC_Calendar_Share::post_userdelete($parameters['uid']);
return true;
}
}

View File

@ -256,4 +256,21 @@ class OC_Calendar_Share{
$stmt = OCP\DB::prepare("UPDATE *PREFIX*calendar_share_calendar SET active = ? WHERE share = ? AND sharetype = 'user' AND calendarid = ?");
$stmt->execute(array($active, $share, $id));
}
/*
* @brief delete all shared calendars / events after a user was deleted
* @param (string) $userid
* @return (bool)
*/
public static function post_userdelete($userid){
$stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_share_calendar WHERE owner = ?');
$stmt->execute(array($userid));
$stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_share_event WHERE owner = ?');
$stmt->execute(array($userid));
$stmt = OCP\DB::prepare("DELETE FROM *PREFIX*calendar_share_calendar WHERE share = ? AND sharetype = 'user'");
$stmt->execute(array($userid));
$stmt = OCP\DB::prepare("DELETE FROM *PREFIX*calendar_share_event WHERE share = ? AND sharetype = 'user'");
$stmt->execute(array($userid));
return true;
}
}