]> source.dussan.org Git - nextcloud-server.git/commitdiff
moved remove and rename hook to libs/hooks.php
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 5 Jul 2012 09:35:08 +0000 (11:35 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Thu, 5 Jul 2012 09:35:08 +0000 (11:35 +0200)
apps/files_versions/appinfo/app.php
apps/files_versions/lib/hooks.php
apps/files_versions/lib/versions.php

index dba612e4b79399213c5a62306769dbec4a93e274..9ac7f6d5cde7eae86a90c09ece79dc1e9277e849 100644 (file)
@@ -12,5 +12,5 @@ OCP\Util::addscript('files_versions', 'versions');
 // Listen to write signals
 OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA_Versions\Hooks", "write_hook");
 // Listen to delete and rename signals
-OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Storage", "removeVersions");
-OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Storage", "renameVersions");
\ No newline at end of file
+OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Versions\Hooks", "remove_hook");
+OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA_Versions\Hooks", "rename_hook");
\ No newline at end of file
index 8a7467053296c132f18d67ab67034e8f3c3abda5..b43fdb9fd33cc43bcb43643de9da00a7dd686eed 100644 (file)
@@ -30,6 +30,43 @@ class Hooks {
                }
        }
        
+       /**\r
+        * @brief Erase versions of deleted file\r
+        * @param array\r
+        *\r
+        * This function is connected to the delete signal of OC_Filesystem\r
+        * cleanup the versions directory if the actual file gets deleted\r
+        */\r
+       public static function remove_hook($params) {\r
+               $rel_path =  $params['path'];\r
+               $abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v';\r
+               if(Storage::isversioned($rel_path)) {\r
+                       $versions = Storage::getVersions($rel_path);\r
+                       foreach ($versions as $v){\r
+                               unlink($abs_path . $v['version']);\r
+                       }\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * @brief rename/move versions of renamed/moved files\r
+        * @param array with oldpath and newpath\r
+        *\r
+        * This function is connected to the rename signal of OC_Filesystem and adjust the name and location\r
+        * of the stored versions along the actual file\r
+        */\r
+       public static function rename_hook($params) {\r
+               $rel_oldpath =  $params['oldpath'];\r
+               $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v';\r
+               $abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v';\r
+               if(Storage::isversioned($rel_oldpath)) {\r
+                       $versions = Storage::getVersions($rel_oldpath);\r
+                       foreach ($versions as $v){\r
+                               rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);\r
+                       }\r
+               }\r
+       }
+       
 }
 
 ?>
index fb78e0a56c046854b226e44dcbd7d5d3ab350c89..412044dba7d61359db75eea1af21c55f26123b39 100644 (file)
@@ -323,41 +323,4 @@ class Storage {
                return $this->view->deleteAll( $dir, true );\r
        \r
         }\r
-\r
-        /**\r
-         * @brief Erase versions of deleted file\r
-         * @param array\r
-         *          \r
-         * This function is connected to the delete signal of OC_Filesystem\r
-         * cleanup the versions directory if the actual file gets deleted\r
-         */\r
-        public static function removeVersions($params) {\r
-               $rel_path =  $params['path'];\r
-               $abs_path = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_path.'.v';\r
-               if(Storage::isversioned($rel_path)) {\r
-                       $versions = Storage::getVersions($rel_path);\r
-                       foreach ($versions as $v){\r
-                               unlink($abs_path . $v['version']);\r
-                       }\r
-               }\r
-        }\r
-        \r
-        /**\r
-         * @brief rename/move versions of renamed/moved files\r
-         * @param array with oldpath and newpath\r
-         * \r
-         * This function is connected to the rename signal of OC_Filesystem and adjust the name and location\r
-         * of the stored versions along the actual file\r
-         */\r
-        public static function renameVersions($params) {\r
-               $rel_oldpath =  $params['oldpath'];\r
-               $abs_oldpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$rel_oldpath.'.v';\r
-               $abs_newpath = \OCP\Config::getSystemValue('datadirectory').'/'.\OCP\User::getUser()."/versions".$params['newpath'].'.v';\r
-               if(Storage::isversioned($rel_oldpath)) {\r
-                       $versions = Storage::getVersions($rel_oldpath);\r
-                       foreach ($versions as $v){\r
-                               rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']);\r
-                       }\r
-               }\r
-        }\r
 }\r