summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_versions/lib')
-rw-r--r--apps/files_versions/lib/hooks.php14
-rw-r--r--apps/files_versions/lib/versions.php12
2 files changed, 26 insertions, 0 deletions
diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php
index 7891b20e92f..f0082b301a3 100644
--- a/apps/files_versions/lib/hooks.php
+++ b/apps/files_versions/lib/hooks.php
@@ -63,4 +63,18 @@ class Hooks {
}
}
+ /**
+ * @brief clean up user specific settings if user gets deleted
+ * @param array with uid
+ *
+ * This function is connected to the pre_deleteUser signal of OC_Users
+ * to remove the used space for versions stored in the database
+ */
+ public static function deleteUser_hook($params) {
+ if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
+ $uid = $params['uid'];
+ Storage::deleteUser($uid);
+ }
+ }
+
}
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 5fc26fd090e..47d044873ad 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -279,6 +279,18 @@ class Storage {
}
+
+ /**
+ * @brief deletes used space for files versions in db if user was deleted
+ *
+ * @param type $uid id of deleted user
+ * @return result of db delete operation
+ */
+ public static function deleteUser($uid) {
+ $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_versions` WHERE `user`=?');
+ return $query->execute(array($uid));
+ }
+
/**
* @brief get the size of all stored versions from a given user
* @param $uid id from the user