2012-07-03 20:42:51 +04:00
|
|
|
<?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.
|
|
|
|
*/
|
2012-09-07 16:10:43 +04:00
|
|
|
|
2012-09-19 22:59:57 +04:00
|
|
|
namespace OCA\Files_Versions;
|
2012-07-03 20:42:51 +04:00
|
|
|
|
|
|
|
class Hooks {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* listen to write event.
|
|
|
|
*/
|
|
|
|
public static function write_hook( $params ) {
|
2012-09-07 16:10:43 +04:00
|
|
|
|
2012-07-03 20:42:51 +04:00
|
|
|
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
2012-10-10 15:18:36 +04:00
|
|
|
$path = $params[\OC\Files\Filesystem::signal_param_path];
|
2013-02-10 17:17:18 +04:00
|
|
|
if($path<>'') {
|
|
|
|
Storage::store($path);
|
|
|
|
}
|
2012-07-03 20:42:51 +04:00
|
|
|
}
|
|
|
|
}
|
2012-07-09 18:07:26 +04:00
|
|
|
|
2012-09-07 16:10:43 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2012-07-09 18:51:16 +04:00
|
|
|
public static function remove_hook($params) {
|
2013-01-28 23:04:10 +04:00
|
|
|
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
|
|
|
$path = $params[\OC\Files\Filesystem::signal_param_path];
|
2013-02-10 17:17:18 +04:00
|
|
|
if($path<>'') {
|
|
|
|
Storage::delete($path);
|
|
|
|
}
|
2013-02-22 20:21:57 +04:00
|
|
|
|
2013-01-28 23:04:10 +04:00
|
|
|
}
|
2012-09-07 16:10:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2012-07-09 18:51:16 +04:00
|
|
|
public static function rename_hook($params) {
|
2013-01-28 23:04:10 +04:00
|
|
|
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
|
2013-01-11 17:23:28 +04:00
|
|
|
$oldpath = $params['oldpath'];
|
2013-01-28 23:04:10 +04:00
|
|
|
$newpath = $params['newpath'];
|
2013-02-10 17:17:18 +04:00
|
|
|
if($oldpath<>'' && $newpath<>'') {
|
|
|
|
Storage::rename( $oldpath, $newpath );
|
|
|
|
}
|
2013-02-22 20:21:57 +04:00
|
|
|
|
2012-09-07 16:10:43 +04:00
|
|
|
}
|
2012-07-05 13:35:08 +04:00
|
|
|
}
|
2013-02-22 20:21:57 +04:00
|
|
|
|
2013-04-11 14:36:08 +04:00
|
|
|
/**
|
|
|
|
* @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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-03 20:42:51 +04:00
|
|
|
}
|