]> source.dussan.org Git - nextcloud-server.git/commitdiff
remove used space for versions from db is a user was deleted
authorBjörn Schießle <schiessle@owncloud.com>
Thu, 11 Apr 2013 10:36:08 +0000 (12:36 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Thu, 11 Apr 2013 10:36:08 +0000 (12:36 +0200)
apps/files_versions/appinfo/app.php
apps/files_versions/lib/hooks.php
apps/files_versions/lib/versions.php

index 9be1c88968249a40398c31259fd7a61929b7dc91..0d0850e186432f2e037262826ab432a576b178d2 100644 (file)
@@ -12,3 +12,5 @@ OCP\Util::connectHook('OC_Filesystem', 'write', "OCA\Files_Versions\Hooks", "wri
 // Listen to delete and rename signals
 OCP\Util::connectHook('OC_Filesystem', 'post_delete', "OCA\Files_Versions\Hooks", "remove_hook");
 OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA\Files_Versions\Hooks", "rename_hook");
+//Listen to delete user signal
+OCP\Util::connectHook('OC_User', 'pre_deleteUser', "OCA\Files_Versions\Hooks", "deleteUser_hook");
index 7891b20e92fd2a74e6a28c3cd18d00a1e3efd9db..f0082b301a36d8701b57d417b051f944eca8a02b 100644 (file)
@@ -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);
+                       }
+       }
+
 }
index 5fc26fd090e92c94e6a81258228563d4c423a8de..47d044873ad731399af81dcc1279ba558c7253ce 100644 (file)
@@ -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