summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-04-11 12:36:08 +0200
committerBjörn Schießle <schiessle@owncloud.com>2013-04-11 14:39:56 +0200
commit544a46c69067fcbdf55391415c9d06c73fd21331 (patch)
tree531902325d009be7e8b56881e13fe2441913671c /apps/files_versions/lib
parent18c873d1e5746bd0e032c9c6e402da487fa9634a (diff)
downloadnextcloud-server-544a46c69067fcbdf55391415c9d06c73fd21331.tar.gz
nextcloud-server-544a46c69067fcbdf55391415c9d06c73fd21331.zip
remove used space for versions from db is a user was deleted
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