diff options
Diffstat (limited to 'apps/files_versions')
28 files changed, 170 insertions, 94 deletions
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 495848b8226..9075095d286 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -10,10 +10,10 @@ $(document).ready(function() { $(document).ready(function(){ if (typeof FileActions !== 'undefined') { - // Add history button to files/index.php + // Add history button to 'files/index.php' FileActions.register( 'file' - ,'History' + , t('files_versions', 'History') , OC.PERMISSION_UPDATE , function() { // Specify icon for hitory button @@ -147,4 +147,4 @@ $(this).click( } -);
\ No newline at end of file +); diff --git a/apps/files_versions/l10n/ca.php b/apps/files_versions/l10n/ca.php index 51ff7aba1dd..d9d966fc7af 100644 --- a/apps/files_versions/l10n/ca.php +++ b/apps/files_versions/l10n/ca.php @@ -1,5 +1,7 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Expira totes les versions", "Versions" => "Versions", -"This will delete all existing backup versions of your files" => "Això eliminarà totes les versions de còpia de seguretat dels vostres fitxers" +"This will delete all existing backup versions of your files" => "Això eliminarà totes les versions de còpia de seguretat dels vostres fitxers", +"Files Versioning" => "Fitxers de Versions", +"Enable" => "Permetre" ); diff --git a/apps/files_versions/l10n/cs_CZ.php b/apps/files_versions/l10n/cs_CZ.php index 5d19f59d706..3995334d9ee 100644 --- a/apps/files_versions/l10n/cs_CZ.php +++ b/apps/files_versions/l10n/cs_CZ.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Vypršet všechny verze", +"History" => "Historie", "Versions" => "Verze", -"This will delete all existing backup versions of your files" => "Odstraní všechny existující zálohované verze Vašich souborů" +"This will delete all existing backup versions of your files" => "Odstraní všechny existující zálohované verze Vašich souborů", +"Files Versioning" => "Verzování souborů", +"Enable" => "Povolit" ); diff --git a/apps/files_versions/l10n/da.php b/apps/files_versions/l10n/da.php index 6a69fdbe4cc..bc02b47f2ad 100644 --- a/apps/files_versions/l10n/da.php +++ b/apps/files_versions/l10n/da.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Lad alle versioner udløbe", +"History" => "Historik", "Versions" => "Versioner", -"This will delete all existing backup versions of your files" => "Dette vil slette alle eksisterende backupversioner af dine filer" +"This will delete all existing backup versions of your files" => "Dette vil slette alle eksisterende backupversioner af dine filer", +"Files Versioning" => "Versionering af filer", +"Enable" => "Aktiver" ); diff --git a/apps/files_versions/l10n/de.php b/apps/files_versions/l10n/de.php index 079d96e679e..a568112d02d 100644 --- a/apps/files_versions/l10n/de.php +++ b/apps/files_versions/l10n/de.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Alle Versionen löschen", +"History" => "Historie", "Versions" => "Versionen", -"This will delete all existing backup versions of your files" => "Dies löscht alle vorhandenen Sicherungsversionen Ihrer Dateien." +"This will delete all existing backup versions of your files" => "Dies löscht alle vorhandenen Sicherungsversionen Ihrer Dateien.", +"Files Versioning" => "Dateiversionierung", +"Enable" => "Aktivieren" ); diff --git a/apps/files_versions/l10n/el.php b/apps/files_versions/l10n/el.php index c26ad806bbd..f6b9a5b2998 100644 --- a/apps/files_versions/l10n/el.php +++ b/apps/files_versions/l10n/el.php @@ -1,3 +1,8 @@ <?php $TRANSLATIONS = array( -"Expire all versions" => "Λήξη όλων των εκδόσεων" +"Expire all versions" => "Λήξη όλων των εκδόσεων", +"History" => "Ιστορικό", +"Versions" => "Εκδόσεις", +"This will delete all existing backup versions of your files" => "Αυτό θα διαγράψει όλες τις υπάρχουσες εκδόσεις των αντιγράφων ασφαλείας των αρχείων σας", +"Files Versioning" => "Εκδόσεις Αρχείων", +"Enable" => "Ενεργοποίηση" ); diff --git a/apps/files_versions/l10n/es.php b/apps/files_versions/l10n/es.php index 1acab15299f..f6b63df7c2b 100644 --- a/apps/files_versions/l10n/es.php +++ b/apps/files_versions/l10n/es.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Expirar todas las versiones", +"History" => "Historial", "Versions" => "Versiones", -"This will delete all existing backup versions of your files" => "Esto eliminará todas las versiones guardadas como copia de seguridad de tus archivos" +"This will delete all existing backup versions of your files" => "Esto eliminará todas las versiones guardadas como copia de seguridad de tus archivos", +"Files Versioning" => "Versionado de archivos", +"Enable" => "Habilitar" ); diff --git a/apps/files_versions/l10n/es_AR.php b/apps/files_versions/l10n/es_AR.php new file mode 100644 index 00000000000..a78264de03f --- /dev/null +++ b/apps/files_versions/l10n/es_AR.php @@ -0,0 +1,8 @@ +<?php $TRANSLATIONS = array( +"Expire all versions" => "Expirar todas las versiones", +"History" => "Historia", +"Versions" => "Versiones", +"This will delete all existing backup versions of your files" => "Hacer estom borrará todas las versiones guardadas como copia de seguridad de tus archivos", +"Files Versioning" => "Versionado de archivos", +"Enable" => "Activar" +); diff --git a/apps/files_versions/l10n/eu.php b/apps/files_versions/l10n/eu.php index 889e762c6b9..d84d9011707 100644 --- a/apps/files_versions/l10n/eu.php +++ b/apps/files_versions/l10n/eu.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Iraungi bertsio guztiak", +"History" => "Historia", "Versions" => "Bertsioak", -"This will delete all existing backup versions of your files" => "Honek zure fitxategien bertsio guztiak ezabatuko ditu" +"This will delete all existing backup versions of your files" => "Honek zure fitxategien bertsio guztiak ezabatuko ditu", +"Files Versioning" => "Fitxategien Bertsioak", +"Enable" => "Gaitu" ); diff --git a/apps/files_versions/l10n/fi_FI.php b/apps/files_versions/l10n/fi_FI.php index bc8aa67dc79..3cec4c04bfe 100644 --- a/apps/files_versions/l10n/fi_FI.php +++ b/apps/files_versions/l10n/fi_FI.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Vanhenna kaikki versiot", +"History" => "Historia", "Versions" => "Versiot", -"This will delete all existing backup versions of your files" => "Tämä poistaa kaikki tiedostojesi olemassa olevat varmuuskopioversiot" +"This will delete all existing backup versions of your files" => "Tämä poistaa kaikki tiedostojesi olemassa olevat varmuuskopioversiot", +"Files Versioning" => "Tiedostojen versiointi", +"Enable" => "Käytä" ); diff --git a/apps/files_versions/l10n/fr.php b/apps/files_versions/l10n/fr.php index b0e658e8df0..e6dbc274456 100644 --- a/apps/files_versions/l10n/fr.php +++ b/apps/files_versions/l10n/fr.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Supprimer les versions intermédiaires", +"History" => "Historique", "Versions" => "Versions", -"This will delete all existing backup versions of your files" => "Cette opération va effacer toutes les versions intermédiaires de vos fichiers (et ne garder que la dernière version en date)." +"This will delete all existing backup versions of your files" => "Cette opération va effacer toutes les versions intermédiaires de vos fichiers (et ne garder que la dernière version en date).", +"Files Versioning" => "Versionnage des fichiers", +"Enable" => "Activer" ); diff --git a/apps/files_versions/l10n/gl.php b/apps/files_versions/l10n/gl.php new file mode 100644 index 00000000000..c0d5937e1b1 --- /dev/null +++ b/apps/files_versions/l10n/gl.php @@ -0,0 +1,7 @@ +<?php $TRANSLATIONS = array( +"Expire all versions" => "Caducar todas as versións", +"Versions" => "Versións", +"This will delete all existing backup versions of your files" => "Esto eliminará todas as copias de respaldo existentes dos seus ficheiros", +"Files Versioning" => "Versionado de ficheiros", +"Enable" => "Habilitar" +); diff --git a/apps/files_versions/l10n/it.php b/apps/files_versions/l10n/it.php index 2b7d2b5c139..0b1e70823d5 100644 --- a/apps/files_versions/l10n/it.php +++ b/apps/files_versions/l10n/it.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Scadenza di tutte le versioni", +"History" => "Cronologia", "Versions" => "Versioni", -"This will delete all existing backup versions of your files" => "Ciò eliminerà tutte le versioni esistenti dei tuoi file" +"This will delete all existing backup versions of your files" => "Ciò eliminerà tutte le versioni esistenti dei tuoi file", +"Files Versioning" => "Controllo di versione dei file", +"Enable" => "Abilita" ); diff --git a/apps/files_versions/l10n/ja_JP.php b/apps/files_versions/l10n/ja_JP.php index 7a00d0b4dad..367152c0743 100644 --- a/apps/files_versions/l10n/ja_JP.php +++ b/apps/files_versions/l10n/ja_JP.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "すべてのバージョンを削除する", +"History" => "履歴", "Versions" => "バージョン", -"This will delete all existing backup versions of your files" => "これは、あなたのファイルのすべてのバックアップバージョンを削除します" +"This will delete all existing backup versions of your files" => "これは、あなたのファイルのすべてのバックアップバージョンを削除します", +"Files Versioning" => "ファイルのバージョン管理", +"Enable" => "有効化" ); diff --git a/apps/files_versions/l10n/nl.php b/apps/files_versions/l10n/nl.php index 486b4ed45cf..1cf875048d7 100644 --- a/apps/files_versions/l10n/nl.php +++ b/apps/files_versions/l10n/nl.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Alle versies laten verlopen", +"History" => "Geschiedenis", "Versions" => "Versies", -"This will delete all existing backup versions of your files" => "Dit zal alle bestaande backup versies van uw bestanden verwijderen" +"This will delete all existing backup versions of your files" => "Dit zal alle bestaande backup versies van uw bestanden verwijderen", +"Files Versioning" => "Bestand versies", +"Enable" => "Zet aan" ); diff --git a/apps/files_versions/l10n/pl.php b/apps/files_versions/l10n/pl.php index a198792a5bc..46c28d4590a 100644 --- a/apps/files_versions/l10n/pl.php +++ b/apps/files_versions/l10n/pl.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Wygasają wszystkie wersje", +"History" => "Historia", "Versions" => "Wersje", -"This will delete all existing backup versions of your files" => "Spowoduje to usunięcie wszystkich istniejących wersji kopii zapasowych plików" +"This will delete all existing backup versions of your files" => "Spowoduje to usunięcie wszystkich istniejących wersji kopii zapasowych plików", +"Files Versioning" => "Wersjonowanie plików", +"Enable" => "Włącz" ); diff --git a/apps/files_versions/l10n/pt_BR.php b/apps/files_versions/l10n/pt_BR.php index 102b6d62743..3d39a533d65 100644 --- a/apps/files_versions/l10n/pt_BR.php +++ b/apps/files_versions/l10n/pt_BR.php @@ -1,3 +1,8 @@ <?php $TRANSLATIONS = array( -"Expire all versions" => "Expirar todas as versões" +"Expire all versions" => "Expirar todas as versões", +"History" => "Histórico", +"Versions" => "Versões", +"This will delete all existing backup versions of your files" => "Isso removerá todas as versões de backup existentes dos seus arquivos", +"Files Versioning" => "Versionamento de Arquivos", +"Enable" => "Habilitar" ); diff --git a/apps/files_versions/l10n/pt_PT.php b/apps/files_versions/l10n/pt_PT.php new file mode 100644 index 00000000000..eb80eec6ed8 --- /dev/null +++ b/apps/files_versions/l10n/pt_PT.php @@ -0,0 +1,7 @@ +<?php $TRANSLATIONS = array( +"Expire all versions" => "Expirar todas as versões", +"History" => "Histórico", +"Versions" => "Versões", +"This will delete all existing backup versions of your files" => "Isto irá apagar todas as versões de backup do seus ficheiros", +"Enable" => "Activar" +); diff --git a/apps/files_versions/l10n/ro.php b/apps/files_versions/l10n/ro.php new file mode 100644 index 00000000000..e23e771e392 --- /dev/null +++ b/apps/files_versions/l10n/ro.php @@ -0,0 +1,8 @@ +<?php $TRANSLATIONS = array( +"Expire all versions" => "Expiră toate versiunile", +"History" => "Istoric", +"Versions" => "Versiuni", +"This will delete all existing backup versions of your files" => "Această acțiune va șterge toate versiunile salvate ale fișierelor tale", +"Files Versioning" => "Versionare fișiere", +"Enable" => "Activare" +); diff --git a/apps/files_versions/l10n/ru_RU.php b/apps/files_versions/l10n/ru_RU.php new file mode 100644 index 00000000000..2563c318bc2 --- /dev/null +++ b/apps/files_versions/l10n/ru_RU.php @@ -0,0 +1,6 @@ +<?php $TRANSLATIONS = array( +"Versions" => "Версии", +"This will delete all existing backup versions of your files" => "Это приведет к удалению всех существующих версий резервной копии ваших файлов", +"Files Versioning" => "Файлы управления версиями", +"Enable" => "Включить" +); diff --git a/apps/files_versions/l10n/sk_SK.php b/apps/files_versions/l10n/sk_SK.php new file mode 100644 index 00000000000..132c6c09682 --- /dev/null +++ b/apps/files_versions/l10n/sk_SK.php @@ -0,0 +1,8 @@ +<?php $TRANSLATIONS = array( +"Expire all versions" => "Expirovať všetky verzie", +"History" => "História", +"Versions" => "Verzie", +"This will delete all existing backup versions of your files" => "Budú zmazané všetky zálohované verzie vašich súborov", +"Files Versioning" => "Vytváranie verzií súborov", +"Enable" => "Zapnúť" +); diff --git a/apps/files_versions/l10n/sl.php b/apps/files_versions/l10n/sl.php index 8c67b568834..056a17decfe 100644 --- a/apps/files_versions/l10n/sl.php +++ b/apps/files_versions/l10n/sl.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Zastaraj vse različice", +"History" => "Zgodovina", "Versions" => "Različice", -"This will delete all existing backup versions of your files" => "To bo izbrisalo vse obstoječe različice varnostnih kopij vaših datotek" +"This will delete all existing backup versions of your files" => "To bo izbrisalo vse obstoječe različice varnostnih kopij vaših datotek", +"Files Versioning" => "Sledenje različicam", +"Enable" => "Omogoči" ); diff --git a/apps/files_versions/l10n/sv.php b/apps/files_versions/l10n/sv.php index 16fd9890bf9..e36164e30ab 100644 --- a/apps/files_versions/l10n/sv.php +++ b/apps/files_versions/l10n/sv.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "Upphör alla versioner", +"History" => "Historik", "Versions" => "Versioner", -"This will delete all existing backup versions of your files" => "Detta kommer att radera alla befintliga säkerhetskopior av dina filer" +"This will delete all existing backup versions of your files" => "Detta kommer att radera alla befintliga säkerhetskopior av dina filer", +"Files Versioning" => "Versionshantering av filer", +"Enable" => "Aktivera" ); diff --git a/apps/files_versions/l10n/th_TH.php b/apps/files_versions/l10n/th_TH.php index 5e075d54a75..89b9f626911 100644 --- a/apps/files_versions/l10n/th_TH.php +++ b/apps/files_versions/l10n/th_TH.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "หมดอายุทุกรุ่น", +"History" => "ประวัติ", "Versions" => "รุ่น", -"This will delete all existing backup versions of your files" => "นี่จะเป็นลบทิ้งไฟล์รุ่นที่ทำการสำรองข้อมูลทั้งหมดที่มีอยู่ของคุณทิ้งไป" +"This will delete all existing backup versions of your files" => "นี่จะเป็นลบทิ้งไฟล์รุ่นที่ทำการสำรองข้อมูลทั้งหมดที่มีอยู่ของคุณทิ้งไป", +"Files Versioning" => "การกำหนดเวอร์ชั่นของไฟล์", +"Enable" => "เปิดใช้งาน" ); diff --git a/apps/files_versions/l10n/zh_CN.GB2312.php b/apps/files_versions/l10n/zh_CN.GB2312.php new file mode 100644 index 00000000000..43af097a21e --- /dev/null +++ b/apps/files_versions/l10n/zh_CN.GB2312.php @@ -0,0 +1,7 @@ +<?php $TRANSLATIONS = array( +"Expire all versions" => "作废所有版本", +"Versions" => "版本", +"This will delete all existing backup versions of your files" => "这将删除所有您现有文件的备份版本", +"Files Versioning" => "文件版本", +"Enable" => "启用" +); diff --git a/apps/files_versions/l10n/zh_CN.php b/apps/files_versions/l10n/zh_CN.php index ba2ea40df96..48e7157c98f 100644 --- a/apps/files_versions/l10n/zh_CN.php +++ b/apps/files_versions/l10n/zh_CN.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( "Expire all versions" => "过期所有版本", +"History" => "历史", "Versions" => "版本", -"This will delete all existing backup versions of your files" => "将会删除您的文件的所有备份版本" +"This will delete all existing backup versions of your files" => "将会删除您的文件的所有备份版本", +"Files Versioning" => "文件版本", +"Enable" => "开启" ); diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index e429782aed1..7d12e58f941 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -35,48 +35,34 @@ class Storage { const DEFAULTMININTERVAL=60; // 1 min const DEFAULTMAXVERSIONS=50; - private $view; - - function __construct() { - - $this->view = \OCP\Files::getStorage('files_versions'); - - } - - /** - * listen to write event. - */ - public static function write_hook($params) { - if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - $path = $params[\OC_Filesystem::signal_param_path]; - if($path<>'') $this->store($path); + private static function getUidAndFilename($filename) + { + if (\OCP\App::isEnabled('files_sharing') + && substr($filename, 0, 7) == '/Shared' + && $source = \OCP\Share::getItemSharedWith('file', + substr($filename, 7), + \OC_Share_Backend_File::FORMAT_SHARED_STORAGE)) { + $filename = $source['path']; + $pos = strpos($filename, '/files', 1); + $uid = substr($filename, 1, $pos - 1); + $filename = substr($filename, $pos + 6); + } else { + $uid = \OCP\User::getUser(); } + return array($uid, $filename); } - - /** * store a new version of a file. */ public function store($filename) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - - $files_view = \OCP\Files::getStorage("files"); - $users_view = \OCP\Files::getStorage("files_versions"); - $users_view->chroot(\OCP\User::getUser().'/'); - - //FIXME OC_Share no longer exists - //if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) { - // $pos = strpos($source, '/files', 1); - // $uid = substr($source, 1, $pos - 1); - // $filename = substr($source, $pos + 6); - //} else { - $uid = \OCP\User::getUser(); - //} - - $versionsFolderName=\OCP\Config::getSystemValue('datadirectory') . $this->view->getAbsolutePath(''); + list($uid, $filename) = self::getUidAndFilename($filename); + $files_view = new \OC_FilesystemView('/'.$uid.'/files'); + $users_view = new \OC_FilesystemView('/'.$uid); //check if source file already exist as version to avoid recursions. + // todo does this check work? if ($users_view->file_exists($filename)) { return false; } @@ -95,6 +81,10 @@ class Storage { return false; } } + // we should have a source file to work with + if (!$files_view->file_exists($filename)) { + return false; + } // check filesize if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) { @@ -104,6 +94,8 @@ class Storage { // check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval) if ($uid == \OCP\User::getUser()) { + $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); + $versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath(''); $matches=glob($versionsFolderName.'/'.$filename.'.v*'); sort($matches); $parts=explode('.v',end($matches)); @@ -114,8 +106,10 @@ class Storage { // create all parent folders - $info=pathinfo($filename); - if(!file_exists($versionsFolderName.'/'.$info['dirname'])) mkdir($versionsFolderName.'/'.$info['dirname'],0700,true); + $dirname = dirname($filename); + if(!$users_view->file_exists('/files_versions/'.$dirname)) { + $users_view->mkdir('/files_versions/'.$dirname,0700,true); + } // store a new version of a file $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.time()); @@ -132,17 +126,8 @@ class Storage { public static function rollback($filename,$revision) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - $users_view = \OCP\Files::getStorage("files_versions"); - $users_view->chroot(\OCP\User::getUser().'/'); - - //FIXME OC_Share no longer exists - //if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) { - // $pos = strpos($source, '/files', 1); - // $uid = substr($source, 1, $pos - 1); - // $filename = substr($source, $pos + 6); - //} else { - $uid = \OCP\User::getUser(); - //} + list($uid, $filename) = self::getUidAndFilename($filename); + $users_view = new \OC_FilesystemView('/'.$uid); // rollback if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) { @@ -164,12 +149,8 @@ class Storage { */ public static function isversioned($filename) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - $versions_fileview = \OCP\Files::getStorage("files_versions"); - //FIXME OC_Share no longer exists - //if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) { - // $pos = strpos($source, '/files', 1); - // $filename = substr($source, $pos + 6); - //} + list($uid, $filename) = self::getUidAndFilename($filename); + $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); $versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath(''); @@ -196,16 +177,9 @@ class Storage { public static function getVersions( $filename, $count = 0 ) { if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { + list($uid, $filename) = self::getUidAndFilename($filename); + $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); - //FIXME OC_Share no longer exists - //if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) { - // $pos = strpos($source, '/files', 1); - // $uid = substr($source, 1, $pos - 1); - // $filename = substr($source, $pos + 6); - //} else { - $uid = \OCP\User::getUser(); - //} - $versions_fileview = \OCP\Files::getStorage('files_versions'); $versionsFolderName = \OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath(''); $versions = array(); @@ -216,7 +190,7 @@ class Storage { $i = 0; - $files_view = \OCP\Files::getStorage('files'); + $files_view = new \OC_FilesystemView('/'.$uid.'/files'); $local_file = $files_view->getLocalFile($filename); foreach( $matches as $ma ) { @@ -270,16 +244,9 @@ class Storage { */ public static function expire($filename) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + list($uid, $filename) = self::getUidAndFilename($filename); + $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); - //FIXME OC_Share no longer exists - //if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) { - // $pos = strpos($source, '/files', 1); - // $uid = substr($source, 1, $pos - 1); - // $filename = substr($source, $pos + 6); - //} else { - $uid = \OCP\User::getUser(); - //} - $versions_fileview = \OCP\Files::getStorage("files_versions"); $versionsFolderName=\OCP\Config::getSystemValue('datadirectory'). $versions_fileview->getAbsolutePath(''); // check for old versions @@ -287,7 +254,7 @@ class Storage { if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) { - $numberToDelete = count( $matches-\OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ); + $numberToDelete = count($matches) - \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ); // delete old versions of a file $deleteItems = array_slice( $matches, 0, $numberToDelete ); @@ -306,6 +273,7 @@ class Storage { * @return true/false */ public function expireAll() { - return $this->view->deleteAll('', true); + $view = \OCP\Files::getStorage('files_versions'); + return $view->deleteAll('', true); } } diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php index 99bc153a816..854d032da62 100644 --- a/apps/files_versions/templates/history.php +++ b/apps/files_versions/templates/history.php @@ -22,7 +22,7 @@ if( isset( $_['message'] ) ) { foreach ( $_['versions'] as $v ) { echo ' '; echo OCP\Util::formatDate( doubleval($v['version']) ); - echo ' <a href="'.OCP\Util::linkTo('files_versions', 'history.php', array('path' => urlencode( $_['path'] ), 'revert' => $v['version'])) .'" class="button">Revert</a><br /><br />'; + echo ' <a href="'.OCP\Util::linkTo('files_versions', 'history.php', array('path' => $_['path'], 'revert' => $v['version'])) .'" class="button">Revert</a><br /><br />'; if ( $v['cur'] ) { echo ' (<b>Current</b>)'; } echo '<br /><br />'; } |