Blame view
sources/apps/files_versions/lib/hooks.php
2.13 KB
|
03e52840d
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php
/**
* Copyright (c) 2012 Sam Tuke <samtuke@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
/**
* This class contains all hooks.
*/
namespace OCA\Files_Versions;
class Hooks {
/**
* listen to write event.
*/
public static function write_hook( $params ) {
|
|
31b7f2792
|
21 |
if (\OCP\App::isEnabled('files_versions')) {
|
|
03e52840d
|
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
$path = $params[\OC\Files\Filesystem::signal_param_path];
if($path<>'') {
Storage::store($path);
}
}
}
/**
* @brief Erase versions of deleted file
* @param array
*
* This function is connected to the delete signal of OC_Filesystem
* cleanup the versions directory if the actual file gets deleted
*/
public static function remove_hook($params) {
|
|
31b7f2792
|
38 39 |
if (\OCP\App::isEnabled('files_versions')) {
|
|
03e52840d
|
40 41 42 43 |
$path = $params[\OC\Files\Filesystem::signal_param_path];
if($path<>'') {
Storage::delete($path);
}
|
|
03e52840d
|
44 45 46 47 |
} } /** |
|
31b7f2792
|
48 49 50 51 52 53 54 55 56 57 58 |
* @brief mark file as "deleted" so that we can clean up the versions if the file is gone
* @param array $params
*/
public static function pre_remove_hook($params) {
$path = $params[\OC\Files\Filesystem::signal_param_path];
if($path<>'') {
Storage::markDeletedFile($path);
}
}
/**
|
|
03e52840d
|
59 60 61 62 63 64 65 |
* @brief rename/move versions of renamed/moved files
* @param array with oldpath and newpath
*
* This function is connected to the rename signal of OC_Filesystem and adjust the name and location
* of the stored versions along the actual file
*/
public static function rename_hook($params) {
|
|
31b7f2792
|
66 67 |
if (\OCP\App::isEnabled('files_versions')) {
|
|
03e52840d
|
68 69 70 71 72 |
$oldpath = $params['oldpath'];
$newpath = $params['newpath'];
if($oldpath<>'' && $newpath<>'') {
Storage::rename( $oldpath, $newpath );
}
|
|
03e52840d
|
73 74 75 76 77 78 79 80 81 82 83 |
}
}
/**
* @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) {
|
|
31b7f2792
|
84 85 |
if (\OCP\App::isEnabled('files_versions')) {
|
|
03e52840d
|
86 87 |
$uid = $params['uid']; Storage::deleteUser($uid); |
|
31b7f2792
|
88 |
} |
|
03e52840d
|
89 90 91 |
} } |