Skip to content
Snippets Groups Projects
Commit a775deaf authored by Sam Tuke's avatar Sam Tuke
Browse files

Moved hooks and versions.php into new lib directory

Part-ported filesystem operations to OC_FilesystemView
Refactored Storage class to depend on an OC_FsV object and have fewer static classes
parent ca2b1f78
Branches
No related tags found
No related merge requests found
......@@ -28,7 +28,9 @@
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('files_versions');
if( OCA_Versions\Storage::expireAll() ){
$versions = new OCA_Versions\Storage( new OC_FilesystemView('') );
if( $versions->expireAll() ){
OCP\JSON::success();
die();
......
<?php
OCP\JSON::checkAppEnabled('files_versions');
require_once('apps/files_versions/versions.php');
$userDirectory = "/".OCP\USER::getUser()."/files";
$source = $_GET['source'];
......
<?php
require_once('files_versions/versions.php');
//require_once('files_versions/versions.php');
OC::$CLASSPATH['OCA_Versions\Storage'] = 'apps/files_versions/lib/versions.php';
OC::$CLASSPATH['OCA_Versions\Hooks'] = 'apps/files_versions/lib/hooks.php';
OCP\App::registerAdmin('files_versions', 'settings');
OCP\App::registerPersonal('files_versions','settings-personal');
......@@ -8,7 +10,7 @@ OCP\App::registerPersonal('files_versions','settings-personal');
OCP\Util::addscript('files_versions', 'versions');
// Listen to write signals
OCP\Util::connectHook('OC_Filesystem', 'post_write', "OCA_Versions\Storage", "write_hook");
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
......@@ -30,11 +30,12 @@ if ( isset( $_GET['path'] ) ) {
$path = $_GET['path'];
$path = strip_tags( $path );
$tmpl->assign( 'path', $path );
$versions = new OCA_Versions\Storage( new OC_FilesystemView('') );
// roll back to old version if button clicked
if( isset( $_GET['revert'] ) ) {
if( \OCA_Versions\Storage::rollback( $path, $_GET['revert'] ) ) {
if( $versions->rollback( $path, $_GET['revert'] ) ) {
$tmpl->assign( 'outcome_stat', 'success' );
......
<?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_Versions;
class Hooks {
/**
* listen to write event.
*/
public static function write_hook( $params ) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
$versions = new Storage( new \OC_FilesystemView('') );
$path = $params[\OC_Filesystem::signal_param_path];
if($path<>'') $versions->store( $path );
}
}
}
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment