summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-05-13 20:03:27 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-05-13 20:03:52 +0200
commitddf0903ace00d201e4575790d9e910b2bc24496b (patch)
treeeb1ac751892af1f979835e5fee80104ed07d5ca6 /apps
parentee0294bbb1770fa74c808158ab2f7899a8304441 (diff)
downloadnextcloud-server-ddf0903ace00d201e4575790d9e910b2bc24496b.tar.gz
nextcloud-server-ddf0903ace00d201e4575790d9e910b2bc24496b.zip
add post user delete hook for calendar sharing
Diffstat (limited to 'apps')
-rw-r--r--apps/calendar/lib/hooks.php2
-rwxr-xr-xapps/calendar/lib/share.php17
2 files changed, 19 insertions, 0 deletions
diff --git a/apps/calendar/lib/hooks.php b/apps/calendar/lib/hooks.php
index 22e8d8e20f2..328d2951d23 100644
--- a/apps/calendar/lib/hooks.php
+++ b/apps/calendar/lib/hooks.php
@@ -22,6 +22,8 @@ class OC_Calendar_Hooks{
OC_Calendar_Calendar::deleteCalendar($calendar['id']);
}
+ OC_Calendar_Share::post_userdelete($parameters['uid']);
+
return true;
}
}
diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php
index 488495aefc4..54c531892f0 100755
--- a/apps/calendar/lib/share.php
+++ b/apps/calendar/lib/share.php
@@ -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;
+ }
} \ No newline at end of file