summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorTom Needham <tom@owncloud.com>2013-03-05 00:25:56 +0000
committerTom Needham <tom@owncloud.com>2013-03-05 00:25:56 +0000
commit370f202251df2425ec49c78265859a804a88433f (patch)
tree75fa9d4d8694032dcb6e0987bc97ef379691e546 /apps/files_versions
parentf141f8b523f71351841f64ab1e4782b4535ca1b7 (diff)
parentef70978524ad0f00c3e5f03a489753547afee45a (diff)
downloadnextcloud-server-370f202251df2425ec49c78265859a804a88433f.tar.gz
nextcloud-server-370f202251df2425ec49c78265859a804a88433f.zip
Rebase to current master
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/ajax/getVersions.php5
-rw-r--r--apps/files_versions/ajax/rollbackVersion.php1
-rw-r--r--apps/files_versions/ajax/togglesettings.php10
-rw-r--r--apps/files_versions/appinfo/app.php5
-rw-r--r--apps/files_versions/appinfo/database.xml35
-rw-r--r--apps/files_versions/appinfo/info.xml2
-rw-r--r--apps/files_versions/appinfo/version2
-rw-r--r--apps/files_versions/history.php3
-rw-r--r--apps/files_versions/js/versions.js24
-rw-r--r--apps/files_versions/l10n/ar.php4
-rw-r--r--apps/files_versions/l10n/bg_BG.php3
-rw-r--r--apps/files_versions/l10n/bn_BD.php4
-rw-r--r--apps/files_versions/l10n/ca.php6
-rw-r--r--apps/files_versions/l10n/cs_CZ.php6
-rw-r--r--apps/files_versions/l10n/da.php11
-rw-r--r--apps/files_versions/l10n/de.php12
-rw-r--r--apps/files_versions/l10n/de_DE.php10
-rw-r--r--apps/files_versions/l10n/el.php11
-rw-r--r--apps/files_versions/l10n/es.php6
-rw-r--r--apps/files_versions/l10n/es_AR.php12
-rw-r--r--apps/files_versions/l10n/et_EE.php7
-rw-r--r--apps/files_versions/l10n/eu.php12
-rw-r--r--apps/files_versions/l10n/fa.php8
-rw-r--r--apps/files_versions/l10n/fi_FI.php11
-rw-r--r--apps/files_versions/l10n/fr.php5
-rw-r--r--apps/files_versions/l10n/gl.php12
-rw-r--r--apps/files_versions/l10n/hu_HU.php12
-rw-r--r--apps/files_versions/l10n/id.php11
-rw-r--r--apps/files_versions/l10n/is.php4
-rw-r--r--apps/files_versions/l10n/it.php6
-rw-r--r--apps/files_versions/l10n/ja_JP.php6
-rw-r--r--apps/files_versions/l10n/lv.php6
-rw-r--r--apps/files_versions/l10n/mk.php4
-rw-r--r--apps/files_versions/l10n/nl.php11
-rw-r--r--apps/files_versions/l10n/pl.php12
-rw-r--r--apps/files_versions/l10n/pt_BR.php11
-rw-r--r--apps/files_versions/l10n/pt_PT.php11
-rw-r--r--apps/files_versions/l10n/ru.php6
-rw-r--r--apps/files_versions/l10n/sk_SK.php11
-rw-r--r--apps/files_versions/l10n/sl.php4
-rw-r--r--apps/files_versions/l10n/sv.php11
-rw-r--r--apps/files_versions/l10n/tr.php11
-rw-r--r--apps/files_versions/l10n/uk.php11
-rw-r--r--apps/files_versions/l10n/vi.php11
-rw-r--r--apps/files_versions/l10n/zh_CN.php12
-rw-r--r--apps/files_versions/lib/hooks.php31
-rw-r--r--apps/files_versions/lib/versions.php256
-rw-r--r--apps/files_versions/settings.php9
-rw-r--r--apps/files_versions/templates/history.php21
-rw-r--r--apps/files_versions/templates/settings.php6
50 files changed, 416 insertions, 305 deletions
diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php
index 53fc04625c6..f9174c45a65 100644
--- a/apps/files_versions/ajax/getVersions.php
+++ b/apps/files_versions/ajax/getVersions.php
@@ -1,11 +1,10 @@
<?php
OCP\JSON::checkAppEnabled('files_versions');
-$userDirectory = "/".OCP\USER::getUser()."/files";
$source = $_GET['source'];
-
+list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
$count = 5; //show the newest revisions
-if( ($versions = OCA\Files_Versions\Storage::getVersions( $source, $count)) ) {
+if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $count)) ) {
$versionsFormatted = array();
diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php
index 2970915ac63..284b46ee093 100644
--- a/apps/files_versions/ajax/rollbackVersion.php
+++ b/apps/files_versions/ajax/rollbackVersion.php
@@ -14,4 +14,3 @@ if(OCA\Files_Versions\Storage::rollback( $file, $revision )) {
$l = OC_L10N::get('files_versions');
OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) ))));
}
-
diff --git a/apps/files_versions/ajax/togglesettings.php b/apps/files_versions/ajax/togglesettings.php
deleted file mode 100644
index 546b37ae1aa..00000000000
--- a/apps/files_versions/ajax/togglesettings.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-OCP\JSON::checkAppEnabled('files_versions');
-OCP\JSON::checkAdminUser();
-OCP\JSON::callCheck();
-if (OCP\Config::getSystemValue('versions', 'true')=='true') {
- OCP\Config::setSystemValue('versions', 'false');
-} else {
- OCP\Config::setSystemValue('versions', 'true');
-}
diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php
index 8de5dc27ca5..761e0b723af 100644
--- a/apps/files_versions/appinfo/app.php
+++ b/apps/files_versions/appinfo/app.php
@@ -5,13 +5,10 @@ OC::$CLASSPATH['OCA\Files_Versions\Storage'] = 'apps/files_versions/lib/versions
OC::$CLASSPATH['OCA\Files_Versions\Hooks'] = 'apps/files_versions/lib/hooks.php';
OC::$CLASSPATH['OCA\Files_Versions\Capabilities'] = 'apps/files_versions/lib/capabilities.php';
-OCP\App::registerAdmin('files_versions', 'settings');
-OCP\App::registerPersonal('files_versions', 'settings-personal');
-
OCP\Util::addscript('files_versions', 'versions');
// Listen to write signals
OCP\Util::connectHook('OC_Filesystem', 'write', "OCA\Files_Versions\Hooks", "write_hook");
// Listen to delete and rename signals
-OCP\Util::connectHook('OC_Filesystem', 'post-delete', "OCA\Files_Versions\Hooks", "remove_hook");
+OCP\Util::connectHook('OC_Filesystem', 'post_delete', "OCA\Files_Versions\Hooks", "remove_hook");
OCP\Util::connectHook('OC_Filesystem', 'rename', "OCA\Files_Versions\Hooks", "rename_hook");
diff --git a/apps/files_versions/appinfo/database.xml b/apps/files_versions/appinfo/database.xml
new file mode 100644
index 00000000000..d3854776980
--- /dev/null
+++ b/apps/files_versions/appinfo/database.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<database>
+
+ <name>*dbname*</name>
+ <create>true</create>
+ <overwrite>false</overwrite>
+
+ <charset>utf8</charset>
+
+ <table>
+
+ <name>*dbprefix*files_versions</name>
+
+ <declaration>
+
+ <field>
+ <name>user</name>
+ <type>text</type>
+ <default></default>
+ <notnull>true</notnull>
+ <length>64</length>
+ </field>
+ <field>
+ <name>size</name>
+ <type>text</type>
+ <default></default>
+ <notnull>true</notnull>
+ <length>50</length>
+ </field>
+
+ </declaration>
+
+ </table>
+
+</database>
diff --git a/apps/files_versions/appinfo/info.xml b/apps/files_versions/appinfo/info.xml
index 0155f8e830f..44878da5e4d 100644
--- a/apps/files_versions/appinfo/info.xml
+++ b/apps/files_versions/appinfo/info.xml
@@ -4,7 +4,7 @@
<name>Versions</name>
<licence>AGPL</licence>
<author>Frank Karlitschek</author>
- <require>4.91</require>
+ <require>4.93</require>
<shipped>true</shipped>
<description>Versioning of files</description>
<types>
diff --git a/apps/files_versions/appinfo/version b/apps/files_versions/appinfo/version
index e6d5cb833c6..e4c0d46e55f 100644
--- a/apps/files_versions/appinfo/version
+++ b/apps/files_versions/appinfo/version
@@ -1 +1 @@
-1.0.2 \ No newline at end of file
+1.0.3 \ No newline at end of file
diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php
index 437a3fec065..719a7208fed 100644
--- a/apps/files_versions/history.php
+++ b/apps/files_versions/history.php
@@ -59,7 +59,8 @@ if ( isset( $_GET['path'] ) ) {
// show the history only if there is something to show
$count = 999; //show the newest revisions
- if( ($versions = OCA\Files_Versions\Storage::getVersions( $path, $count)) ) {
+ list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($path);
+ if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $count)) ) {
$tmpl->assign( 'versions', array_reverse( $versions ) );
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js
index b9c54689813..a5b24417483 100644
--- a/apps/files_versions/js/versions.js
+++ b/apps/files_versions/js/versions.js
@@ -1,19 +1,9 @@
-$(document).ready(function() {
- $('#versions').bind('change', function() {
- var checked = 1;
- if (!this.checked) {
- checked = 0;
- }
- $.post(OC.filePath('files_versions','ajax','togglesettings.php'), 'versions='+checked);
- });
-});
-
$(document).ready(function(){
if (typeof FileActions !== 'undefined') {
- // Add history button to 'files/index.php'
+ // Add versions button to 'files/index.php'
FileActions.register(
'file'
- , t('files_versions', 'History')
+ , t('files_versions', 'Versions')
, OC.PERMISSION_UPDATE
, function() {
// Specify icon for hitory button
@@ -41,6 +31,10 @@ $(document).ready(function(){
}
});
+function goToVersionPage(url){
+ window.location.assign(url);
+}
+
function createVersionsDropdown(filename, files) {
var historyUrl = OC.linkTo('files_versions', 'history.php') + '?path='+encodeURIComponent( $( '#dir' ).val() ).replace( /%2F/g, '/' )+'/'+encodeURIComponent( filename );
@@ -51,7 +45,7 @@ function createVersionsDropdown(filename, files) {
html += '<option value=""></option>';
html += '</select>';
html += '</div>';
- html += '<input type="button" value="All versions..." onclick="window.location=\''+historyUrl+'\'" name="makelink" id="makelink" />';
+ html += '<input type="button" value="All versions..." name="makelink" id="makelink" />';
html += '<input id="link" style="display:none; width:90%;" />';
if (filename) {
@@ -61,6 +55,10 @@ function createVersionsDropdown(filename, files) {
$(html).appendTo($('thead .share'));
}
+ $("#makelink").click(function() {
+ goToVersionPage(historyUrl);
+ });
+
$.ajax({
type: 'GET',
url: OC.filePath('files_versions', 'ajax', 'getVersions.php'),
diff --git a/apps/files_versions/l10n/ar.php b/apps/files_versions/l10n/ar.php
index 1f1f3100405..b84445972d3 100644
--- a/apps/files_versions/l10n/ar.php
+++ b/apps/files_versions/l10n/ar.php
@@ -1,5 +1,3 @@
<?php $TRANSLATIONS = array(
-"History" => "السجل الزمني",
-"Files Versioning" => "أصدرة الملفات",
-"Enable" => "تفعيل"
+"Versions" => "الإصدارات"
);
diff --git a/apps/files_versions/l10n/bg_BG.php b/apps/files_versions/l10n/bg_BG.php
index 6ecf12d0b00..6a1882c2bfd 100644
--- a/apps/files_versions/l10n/bg_BG.php
+++ b/apps/files_versions/l10n/bg_BG.php
@@ -1,4 +1,3 @@
<?php $TRANSLATIONS = array(
-"History" => "История",
-"Enable" => "Включено"
+"Versions" => "Версии"
);
diff --git a/apps/files_versions/l10n/bn_BD.php b/apps/files_versions/l10n/bn_BD.php
index dffa4d79a06..f3b0071a356 100644
--- a/apps/files_versions/l10n/bn_BD.php
+++ b/apps/files_versions/l10n/bn_BD.php
@@ -1,5 +1,3 @@
<?php $TRANSLATIONS = array(
-"History" => "ইতিহাস",
-"Files Versioning" => "ফাইল ভার্সন করা",
-"Enable" => "সক্রিয় "
+"Versions" => "ভার্সন"
);
diff --git a/apps/files_versions/l10n/ca.php b/apps/files_versions/l10n/ca.php
index fc900c47dc7..433d974c8cb 100644
--- a/apps/files_versions/l10n/ca.php
+++ b/apps/files_versions/l10n/ca.php
@@ -6,8 +6,6 @@
"File %s could not be reverted to version %s" => "El fitxer %s no s'ha pogut revertir a la versió %s",
"No old versions available" => "No hi ha versións antigues disponibles",
"No path specified" => "No heu especificat el camí",
-"History" => "Historial",
-"Revert a file to a previous version by clicking on its revert button" => "Reverteix un fitxer a una versió anterior fent clic en el seu botó de reverteix",
-"Files Versioning" => "Fitxers de Versions",
-"Enable" => "Habilita"
+"Versions" => "Versions",
+"Revert a file to a previous version by clicking on its revert button" => "Reverteix un fitxer a una versió anterior fent clic en el seu botó de reverteix"
);
diff --git a/apps/files_versions/l10n/cs_CZ.php b/apps/files_versions/l10n/cs_CZ.php
index 22d4a2ad827..087d800137e 100644
--- a/apps/files_versions/l10n/cs_CZ.php
+++ b/apps/files_versions/l10n/cs_CZ.php
@@ -6,8 +6,6 @@
"File %s could not be reverted to version %s" => "Soubor %s nemohl být navrácen na verzi %s",
"No old versions available" => "Nejsou dostupné žádné starší verze",
"No path specified" => "Nezadána cesta",
-"History" => "Historie",
-"Revert a file to a previous version by clicking on its revert button" => "Navraťte soubor do předchozí verze kliknutím na tlačítko navrátit",
-"Files Versioning" => "Verzování souborů",
-"Enable" => "Povolit"
+"Versions" => "Verze",
+"Revert a file to a previous version by clicking on its revert button" => "Navraťte soubor do předchozí verze kliknutím na tlačítko navrátit"
);
diff --git a/apps/files_versions/l10n/da.php b/apps/files_versions/l10n/da.php
index 98579747643..76ababe665a 100644
--- a/apps/files_versions/l10n/da.php
+++ b/apps/files_versions/l10n/da.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Historik",
-"Files Versioning" => "Versionering af filer",
-"Enable" => "Aktiver"
+"Could not revert: %s" => "Kunne ikke genskabe: %s",
+"success" => "success",
+"File %s was reverted to version %s" => "Filen %s blev genskabt til version: %s",
+"failure" => "fejl",
+"File %s could not be reverted to version %s" => "Filen %s blev genskabt til version: %s",
+"No old versions available" => "Ingen gamle version tilgængelige",
+"No path specified" => "Ingen sti specificeret",
+"Revert a file to a previous version by clicking on its revert button" => "Genskab en fil til en tidligere version ved at klikke på denne genskab knap."
);
diff --git a/apps/files_versions/l10n/de.php b/apps/files_versions/l10n/de.php
index 2fcb996de7b..c34a8c1fd3e 100644
--- a/apps/files_versions/l10n/de.php
+++ b/apps/files_versions/l10n/de.php
@@ -1,5 +1,11 @@
<?php $TRANSLATIONS = array(
-"History" => "Historie",
-"Files Versioning" => "Dateiversionierung",
-"Enable" => "Aktivieren"
+"Could not revert: %s" => "Konnte %s nicht zurücksetzen",
+"success" => "Erfolgreich",
+"File %s was reverted to version %s" => "Datei %s wurde auf Version %s zurückgesetzt",
+"failure" => "Fehlgeschlagen",
+"File %s could not be reverted to version %s" => "Datei %s konnte nicht auf Version %s zurückgesetzt werden",
+"No old versions available" => "Keine älteren Versionen verfügbar",
+"No path specified" => "Kein Pfad angegeben",
+"Versions" => "Versionen",
+"Revert a file to a previous version by clicking on its revert button" => "Setze eine Datei durch klicken auf den Zurücksetzen Button zurück"
);
diff --git a/apps/files_versions/l10n/de_DE.php b/apps/files_versions/l10n/de_DE.php
index cf33bb071e6..c0b2f2a83f7 100644
--- a/apps/files_versions/l10n/de_DE.php
+++ b/apps/files_versions/l10n/de_DE.php
@@ -1,9 +1,11 @@
<?php $TRANSLATIONS = array(
+"Could not revert: %s" => "Konnte %s nicht zurücksetzen",
"success" => "Erfolgreich",
+"File %s was reverted to version %s" => "Die Datei %s wurde zur Version %s zurückgesetzt",
"failure" => "Fehlgeschlagen",
-"No old versions available" => "keine älteren Versionen verfügbar",
+"File %s could not be reverted to version %s" => "Die Datei %s konnte nicht zur Version %s zurückgesetzt werden",
+"No old versions available" => "Keine älteren Versionen verfügbar",
"No path specified" => "Kein Pfad angegeben",
-"History" => "Historie",
-"Files Versioning" => "Dateiversionierung",
-"Enable" => "Aktivieren"
+"Versions" => "Versionen",
+"Revert a file to a previous version by clicking on its revert button" => "Setze eine Datei durch Klicken auf den Zurücksetzen-Button auf eine frühere Version zurück"
);
diff --git a/apps/files_versions/l10n/el.php b/apps/files_versions/l10n/el.php
index 6b189c2cdd3..6e1900b233b 100644
--- a/apps/files_versions/l10n/el.php
+++ b/apps/files_versions/l10n/el.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Ιστορικό",
-"Files Versioning" => "Εκδόσεις Αρχείων",
-"Enable" => "Ενεργοποίηση"
+"Could not revert: %s" => "Αδυναμία επαναφοράς του: %s",
+"success" => "επιτυχία",
+"File %s was reverted to version %s" => "Το αρχείο %s επαναφέρθηκε στην έκδοση %s",
+"failure" => "αποτυχία",
+"File %s could not be reverted to version %s" => "Το αρχείο %s δεν είναι δυνατό να επαναφερθεί στην έκδοση %s",
+"No old versions available" => "Μη διαθέσιμες παλιές εκδόσεις",
+"No path specified" => "Δεν καθορίστηκε διαδρομή",
+"Revert a file to a previous version by clicking on its revert button" => "Επαναφορά ενός αρχείου σε προηγούμενη έκδοση πατώντας στο κουμπί επαναφοράς"
);
diff --git a/apps/files_versions/l10n/es.php b/apps/files_versions/l10n/es.php
index 608e171a4b1..8c1a30f822a 100644
--- a/apps/files_versions/l10n/es.php
+++ b/apps/files_versions/l10n/es.php
@@ -6,8 +6,6 @@
"File %s could not be reverted to version %s" => "El archivo %s no puede ser revertido a la version %s",
"No old versions available" => "No hay versiones antiguas disponibles",
"No path specified" => "Ruta no especificada",
-"History" => "Historial",
-"Revert a file to a previous version by clicking on its revert button" => "Revertir un archivo a una versión anterior haciendo clic en el boton de revertir",
-"Files Versioning" => "Versionado de archivos",
-"Enable" => "Habilitar"
+"Versions" => "Revisiones",
+"Revert a file to a previous version by clicking on its revert button" => "Revertir un archivo a una versión anterior haciendo clic en el boton de revertir"
);
diff --git a/apps/files_versions/l10n/es_AR.php b/apps/files_versions/l10n/es_AR.php
index 74d8907fc35..363693c913b 100644
--- a/apps/files_versions/l10n/es_AR.php
+++ b/apps/files_versions/l10n/es_AR.php
@@ -1,5 +1,11 @@
<?php $TRANSLATIONS = array(
-"History" => "Historia",
-"Files Versioning" => "Versionado de archivos",
-"Enable" => "Activar"
+"Could not revert: %s" => "No se pudo revertir: %s ",
+"success" => "Éxito",
+"File %s was reverted to version %s" => "El archivo %s fue revertido a la versión %s",
+"failure" => "error",
+"File %s could not be reverted to version %s" => "El archivo %s no pudo ser revertido a la versión %s",
+"No old versions available" => "No hay versiones antiguas disponibles",
+"No path specified" => "Ruta de acceso no especificada",
+"Versions" => "Versiones",
+"Revert a file to a previous version by clicking on its revert button" => "Revertí un archivo a una versión anterior haciendo click en su botón de \"revertir\""
);
diff --git a/apps/files_versions/l10n/et_EE.php b/apps/files_versions/l10n/et_EE.php
index ff119d5374e..fa2a33f9dda 100644
--- a/apps/files_versions/l10n/et_EE.php
+++ b/apps/files_versions/l10n/et_EE.php
@@ -1,5 +1,6 @@
<?php $TRANSLATIONS = array(
-"History" => "Ajalugu",
-"Files Versioning" => "Failide versioonihaldus",
-"Enable" => "Luba"
+"success" => "korras",
+"failure" => "ebaõnnestus",
+"No old versions available" => "Vanu versioone pole saadaval",
+"No path specified" => "Asukohta pole määratud"
);
diff --git a/apps/files_versions/l10n/eu.php b/apps/files_versions/l10n/eu.php
index c6b4cd7692d..2a7f279af16 100644
--- a/apps/files_versions/l10n/eu.php
+++ b/apps/files_versions/l10n/eu.php
@@ -1,5 +1,11 @@
<?php $TRANSLATIONS = array(
-"History" => "Historia",
-"Files Versioning" => "Fitxategien Bertsioak",
-"Enable" => "Gaitu"
+"Could not revert: %s" => "Ezin izan da leheneratu: %s",
+"success" => "arrakasta",
+"File %s was reverted to version %s" => "%s fitxategia %s bertsiora leheneratu da",
+"failure" => "errorea",
+"File %s could not be reverted to version %s" => "%s fitxategia ezin da %s bertsiora leheneratu",
+"No old versions available" => "Ez dago bertsio zaharrik eskuragarri",
+"No path specified" => "Ez da bidea zehaztu",
+"Versions" => "Bertsioak",
+"Revert a file to a previous version by clicking on its revert button" => "Itzuli fitxategi bat aurreko bertsio batera leheneratu bere leheneratu botoia sakatuz"
);
diff --git a/apps/files_versions/l10n/fa.php b/apps/files_versions/l10n/fa.php
index 9b618fdd320..4ec6aa1bbb4 100644
--- a/apps/files_versions/l10n/fa.php
+++ b/apps/files_versions/l10n/fa.php
@@ -1,4 +1,8 @@
<?php $TRANSLATIONS = array(
-"History" => "تاریخچه",
-"Enable" => "فعال"
+"Could not revert: %s" => "بازگردانی امکان ناپذیر است: %s",
+"success" => "موفقیت",
+"failure" => "شکست",
+"No old versions available" => "هیچ نسخه قدیمی در دسترس نیست",
+"No path specified" => "هیچ مسیری مشخص نشده است",
+"Revert a file to a previous version by clicking on its revert button" => "بازگردانی یک پرورنده به نسخه قدیمی اش از طریق دکمه بازگردانی امکان پذیر است"
);
diff --git a/apps/files_versions/l10n/fi_FI.php b/apps/files_versions/l10n/fi_FI.php
index bdce8e9fe52..0dec7fc2580 100644
--- a/apps/files_versions/l10n/fi_FI.php
+++ b/apps/files_versions/l10n/fi_FI.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Historia",
-"Files Versioning" => "Tiedostojen versiointi",
-"Enable" => "Käytä"
+"Could not revert: %s" => "Palautus epäonnistui: %s",
+"success" => "onnistui",
+"File %s was reverted to version %s" => "Tiedosto %s palautettiin versioon %s",
+"failure" => "epäonnistui",
+"File %s could not be reverted to version %s" => "Tiedoston %s palautus versioon %s epäonnistui",
+"No old versions available" => "Vanhoja ei ole saatavilla",
+"No path specified" => "Polkua ei ole määritetty",
+"Revert a file to a previous version by clicking on its revert button" => "Palauta tiedoston edellinen versio napsauttamalla palautuspainiketta"
);
diff --git a/apps/files_versions/l10n/fr.php b/apps/files_versions/l10n/fr.php
index 6b2cf9ba6b5..76ad8fc97a6 100644
--- a/apps/files_versions/l10n/fr.php
+++ b/apps/files_versions/l10n/fr.php
@@ -6,8 +6,5 @@
"File %s could not be reverted to version %s" => "Le fichier %s ne peut être restauré dans sa version %s",
"No old versions available" => "Aucune ancienne version n'est disponible",
"No path specified" => "Aucun chemin spécifié",
-"History" => "Historique",
-"Revert a file to a previous version by clicking on its revert button" => "Restaurez un fichier dans une version antérieure en cliquant sur son bouton de restauration",
-"Files Versioning" => "Versionnage des fichiers",
-"Enable" => "Activer"
+"Revert a file to a previous version by clicking on its revert button" => "Restaurez un fichier dans une version antérieure en cliquant sur son bouton de restauration"
);
diff --git a/apps/files_versions/l10n/gl.php b/apps/files_versions/l10n/gl.php
index 7e44b8898bf..586ef8c3a68 100644
--- a/apps/files_versions/l10n/gl.php
+++ b/apps/files_versions/l10n/gl.php
@@ -1,5 +1,11 @@
<?php $TRANSLATIONS = array(
-"History" => "Historial",
-"Files Versioning" => "Sistema de versión de ficheiros",
-"Enable" => "Activar"
+"Could not revert: %s" => "Non foi posíbel reverter: %s",
+"success" => "feito",
+"File %s was reverted to version %s" => "O ficheiro %s foi revertido á versión %s",
+"failure" => "produciuse un fallo",
+"File %s could not be reverted to version %s" => "Non foi posíbel reverter o ficheiro %s á versión %s",
+"No old versions available" => "Non hai versións antigas dispoñíbeis",
+"No path specified" => "Non foi indicada a ruta",
+"Versions" => "Versións",
+"Revert a file to a previous version by clicking on its revert button" => "Reverta un ficheiro a unha versión anterior premendo no botón reversión"
);
diff --git a/apps/files_versions/l10n/hu_HU.php b/apps/files_versions/l10n/hu_HU.php
index 95d37ad06ed..9f7420157e1 100644
--- a/apps/files_versions/l10n/hu_HU.php
+++ b/apps/files_versions/l10n/hu_HU.php
@@ -1,5 +1,11 @@
<?php $TRANSLATIONS = array(
-"History" => "Korábbi változatok",
-"Files Versioning" => "Az állományok verzionálása",
-"Enable" => "engedélyezve"
+"Could not revert: %s" => "Nem sikerült átállni a változatra: %s",
+"success" => "sikerült",
+"File %s was reverted to version %s" => "%s állományt átállítottuk erre a változatra: %s",
+"failure" => "nem sikerült",
+"File %s could not be reverted to version %s" => "%s állományt nem sikerült átállítani erre a változatra: %s",
+"No old versions available" => "Nincs régebbi változat",
+"No path specified" => "Nincs megadva az útvonal",
+"Versions" => "Az állományok korábbi változatai",
+"Revert a file to a previous version by clicking on its revert button" => "Az állomány átállítható egy régebbi változatra, ha a gombra kattint"
);
diff --git a/apps/files_versions/l10n/id.php b/apps/files_versions/l10n/id.php
index 6c553327c42..4662aa86432 100644
--- a/apps/files_versions/l10n/id.php
+++ b/apps/files_versions/l10n/id.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "riwayat",
-"Files Versioning" => "pembuatan versi file",
-"Enable" => "aktifkan"
+"Could not revert: %s" => "Tidak dapat mengembalikan: %s",
+"success" => "sukses",
+"File %s was reverted to version %s" => "Berkas %s telah dikembalikan ke versi %s",
+"failure" => "gagal",
+"File %s could not be reverted to version %s" => "Berkas %s gagal dikembalikan ke versi %s",
+"No old versions available" => "Versi lama tidak tersedia",
+"No path specified" => "Lokasi tidak ditentukan",
+"Revert a file to a previous version by clicking on its revert button" => "Kembalikan berkas ke versi sebelumnya dengan mengklik tombol kembalikan"
);
diff --git a/apps/files_versions/l10n/is.php b/apps/files_versions/l10n/is.php
index ccb8287b71e..d165a78c31e 100644
--- a/apps/files_versions/l10n/is.php
+++ b/apps/files_versions/l10n/is.php
@@ -1,5 +1,3 @@
<?php $TRANSLATIONS = array(
-"History" => "Saga",
-"Files Versioning" => "Útgáfur af skrám",
-"Enable" => "Virkja"
+"Versions" => "Útgáfur"
);
diff --git a/apps/files_versions/l10n/it.php b/apps/files_versions/l10n/it.php
index 3289f7f68d1..bca00879993 100644
--- a/apps/files_versions/l10n/it.php
+++ b/apps/files_versions/l10n/it.php
@@ -6,8 +6,6 @@
"File %s could not be reverted to version %s" => "Il file %s non può essere ripristinato alla versione %s",
"No old versions available" => "Non sono disponibili versioni precedenti",
"No path specified" => "Nessun percorso specificato",
-"History" => "Cronologia",
-"Revert a file to a previous version by clicking on its revert button" => "Ripristina un file a una versione precedente facendo clic sul rispettivo pulsante di ripristino",
-"Files Versioning" => "Controllo di versione dei file",
-"Enable" => "Abilita"
+"Versions" => "Versioni",
+"Revert a file to a previous version by clicking on its revert button" => "Ripristina un file a una versione precedente facendo clic sul rispettivo pulsante di ripristino"
);
diff --git a/apps/files_versions/l10n/ja_JP.php b/apps/files_versions/l10n/ja_JP.php
index 16018765708..0c2dbd401c4 100644
--- a/apps/files_versions/l10n/ja_JP.php
+++ b/apps/files_versions/l10n/ja_JP.php
@@ -6,8 +6,6 @@
"File %s could not be reverted to version %s" => "ファイル %s をバージョン %s に戻せませんでした",
"No old versions available" => "利用可能な古いバージョンはありません",
"No path specified" => "パスが指定されていません",
-"History" => "履歴",
-"Revert a file to a previous version by clicking on its revert button" => "もとに戻すボタンをクリックすると、ファイルを過去のバージョンに戻します",
-"Files Versioning" => "ファイルのバージョン管理",
-"Enable" => "有効化"
+"Versions" => "バージョン",
+"Revert a file to a previous version by clicking on its revert button" => "もとに戻すボタンをクリックすると、ファイルを過去のバージョンに戻します"
);
diff --git a/apps/files_versions/l10n/lv.php b/apps/files_versions/l10n/lv.php
index 2203dc706b8..bf8d40fa0f0 100644
--- a/apps/files_versions/l10n/lv.php
+++ b/apps/files_versions/l10n/lv.php
@@ -6,8 +6,6 @@
"File %s could not be reverted to version %s" => "Datni %s nevarēja atgriezt uz versiju %s",
"No old versions available" => "Nav pieejamu vecāku versiju",
"No path specified" => "Nav norādīts ceļš",
-"History" => "Vēsture",
-"Revert a file to a previous version by clicking on its revert button" => "Atgriez datni uz iepriekšēju versiju, spiežot uz tās atgriešanas pogu",
-"Files Versioning" => "Datņu versiju izskošana",
-"Enable" => "Aktivēt"
+"Versions" => "Versijas",
+"Revert a file to a previous version by clicking on its revert button" => "Atgriez datni uz iepriekšēju versiju, spiežot uz tās atgriešanas pogu"
);
diff --git a/apps/files_versions/l10n/mk.php b/apps/files_versions/l10n/mk.php
index d3ec233fe41..6a1882c2bfd 100644
--- a/apps/files_versions/l10n/mk.php
+++ b/apps/files_versions/l10n/mk.php
@@ -1,5 +1,3 @@
<?php $TRANSLATIONS = array(
-"History" => "Историја",
-"Files Versioning" => "Верзии на датотеки",
-"Enable" => "Овозможи"
+"Versions" => "Версии"
);
diff --git a/apps/files_versions/l10n/nl.php b/apps/files_versions/l10n/nl.php
index cd147ca693f..c50f76c7add 100644
--- a/apps/files_versions/l10n/nl.php
+++ b/apps/files_versions/l10n/nl.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Geschiedenis",
-"Files Versioning" => "Bestand versies",
-"Enable" => "Activeer"
+"Could not revert: %s" => "Kon niet terugdraaien: %s",
+"success" => "succes",
+"File %s was reverted to version %s" => "Bestand %s is teruggedraaid naar versie %s",
+"failure" => "mislukking",
+"File %s could not be reverted to version %s" => "Bestand %s kon niet worden teruggedraaid naar versie %s",
+"No old versions available" => "Geen oudere versies beschikbaar",
+"No path specified" => "Geen pad opgegeven",
+"Revert a file to a previous version by clicking on its revert button" => "Draai een bestand terug naar een voorgaande versie door te klikken op de terugdraai knop"
);
diff --git a/apps/files_versions/l10n/pl.php b/apps/files_versions/l10n/pl.php
index a0247b8abc6..68944e86760 100644
--- a/apps/files_versions/l10n/pl.php
+++ b/apps/files_versions/l10n/pl.php
@@ -1,5 +1,11 @@
<?php $TRANSLATIONS = array(
-"History" => "Historia",
-"Files Versioning" => "Wersjonowanie plików",
-"Enable" => "Włącz"
+"Could not revert: %s" => "Nie można było przywrócić: %s",
+"success" => "sukces",
+"File %s was reverted to version %s" => "Plik %s został przywrócony do wersji %s",
+"failure" => "porażka",
+"File %s could not be reverted to version %s" => "Plik %s nie mógł być przywrócony do wersji %s",
+"No old versions available" => "Nie są dostępne żadne starsze wersje",
+"No path specified" => "Nie podano ścieżki",
+"Versions" => "Wersje",
+"Revert a file to a previous version by clicking on its revert button" => "Przywróć plik do poprzedniej wersji klikając w jego przycisk przywrócenia"
);
diff --git a/apps/files_versions/l10n/pt_BR.php b/apps/files_versions/l10n/pt_BR.php
index 854a30e6bee..f68197ef092 100644
--- a/apps/files_versions/l10n/pt_BR.php
+++ b/apps/files_versions/l10n/pt_BR.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Histórico",
-"Files Versioning" => "Versionamento de Arquivos",
-"Enable" => "Habilitar"
+"Could not revert: %s" => "Não foi possível reverter: %s",
+"success" => "sucesso",
+"File %s was reverted to version %s" => "Arquivo %s revertido à versão %s",
+"failure" => "falha",
+"File %s could not be reverted to version %s" => "Arquivo %s não pôde ser revertido à versão %s",
+"No old versions available" => "Nenhuma versão antiga disponível",
+"No path specified" => "Nenhum caminho especificado",
+"Revert a file to a previous version by clicking on its revert button" => "Reverta um arquivo a uma versão anterior clicando no botão reverter"
);
diff --git a/apps/files_versions/l10n/pt_PT.php b/apps/files_versions/l10n/pt_PT.php
index dc1bde08cad..2baccf3def8 100644
--- a/apps/files_versions/l10n/pt_PT.php
+++ b/apps/files_versions/l10n/pt_PT.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Histórico",
-"Files Versioning" => "Versionamento de Ficheiros",
-"Enable" => "Activar"
+"Could not revert: %s" => "Não foi possível reverter: %s",
+"success" => "Sucesso",
+"File %s was reverted to version %s" => "O ficheiro %s foi revertido para a versão %s",
+"failure" => "Falha",
+"File %s could not be reverted to version %s" => "Não foi possível reverter o ficheiro %s para a versão %s",
+"No old versions available" => "Não existem versões mais antigas",
+"No path specified" => "Nenhum caminho especificado",
+"Revert a file to a previous version by clicking on its revert button" => "Reverter um ficheiro para uma versão anterior clicando no seu botão reverter."
);
diff --git a/apps/files_versions/l10n/ru.php b/apps/files_versions/l10n/ru.php
index 221d24ce8d1..7377fbb5382 100644
--- a/apps/files_versions/l10n/ru.php
+++ b/apps/files_versions/l10n/ru.php
@@ -6,8 +6,6 @@
"File %s could not be reverted to version %s" => "Файл %s не может быть возвращён к версии %s",
"No old versions available" => "Нет доступных старых версий",
"No path specified" => "Путь не указан",
-"History" => "История",
-"Revert a file to a previous version by clicking on its revert button" => "Вернуть файл к предыдущей версии нажатием на кнопку возврата",
-"Files Versioning" => "Версии файлов",
-"Enable" => "Включить"
+"Versions" => "Версии",
+"Revert a file to a previous version by clicking on its revert button" => "Вернуть файл к предыдущей версии нажатием на кнопку возврата"
);
diff --git a/apps/files_versions/l10n/sk_SK.php b/apps/files_versions/l10n/sk_SK.php
index 8a59286b5a5..50e4af4d964 100644
--- a/apps/files_versions/l10n/sk_SK.php
+++ b/apps/files_versions/l10n/sk_SK.php
@@ -1,10 +1,11 @@
<?php $TRANSLATIONS = array(
-"success" => "uspech",
-"File %s was reverted to version %s" => "Subror %s bol vrateny na verziu %s",
+"Could not revert: %s" => "Nemožno obnoviť: %s",
+"success" => "úspech",
+"File %s was reverted to version %s" => "Súbor %s bol obnovený na verziu %s",
"failure" => "chyba",
+"File %s could not be reverted to version %s" => "Súbor %s nemohol byť obnovený na verziu %s",
"No old versions available" => "Nie sú dostupné žiadne staršie verzie",
"No path specified" => "Nevybrali ste cestu",
-"History" => "História",
-"Files Versioning" => "Vytváranie verzií súborov",
-"Enable" => "Zapnúť"
+"Versions" => "Verzie",
+"Revert a file to a previous version by clicking on its revert button" => "Obnovte súbor do predošlej verzie kliknutím na tlačítko obnoviť"
);
diff --git a/apps/files_versions/l10n/sl.php b/apps/files_versions/l10n/sl.php
index 7f386c9edaa..b6ad6a1e9bb 100644
--- a/apps/files_versions/l10n/sl.php
+++ b/apps/files_versions/l10n/sl.php
@@ -1,5 +1,3 @@
<?php $TRANSLATIONS = array(
-"History" => "Zgodovina",
-"Files Versioning" => "Sledenje različicam",
-"Enable" => "Omogoči"
+"No old versions available" => "Starejših različic ni na voljo"
);
diff --git a/apps/files_versions/l10n/sv.php b/apps/files_versions/l10n/sv.php
index 6788d1fb0f9..46e2c0f8bcf 100644
--- a/apps/files_versions/l10n/sv.php
+++ b/apps/files_versions/l10n/sv.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Historik",
-"Files Versioning" => "Versionshantering av filer",
-"Enable" => "Aktivera"
+"Could not revert: %s" => "Kunde inte återställa: %s",
+"success" => "lyckades",
+"File %s was reverted to version %s" => "Filen %s återställdes till version %s",
+"failure" => "misslyckades",
+"File %s could not be reverted to version %s" => "Filen %s kunde inte återställas till version %s",
+"No old versions available" => "Inga gamla versioner finns tillgängliga",
+"No path specified" => "Ingen sökväg angiven",
+"Revert a file to a previous version by clicking on its revert button" => "Återställ en fil till en tidigare version genom att klicka på knappen"
);
diff --git a/apps/files_versions/l10n/tr.php b/apps/files_versions/l10n/tr.php
index e9a4c4702e1..745400d331c 100644
--- a/apps/files_versions/l10n/tr.php
+++ b/apps/files_versions/l10n/tr.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Geçmiş",
-"Files Versioning" => "Dosya Sürümleri",
-"Enable" => "Etkinleştir"
+"Could not revert: %s" => "Geri alınamıyor: %s",
+"success" => "Başarılı.",
+"File %s was reverted to version %s" => "Dosya %s, %s versiyonuna döndürüldü",
+"failure" => "hata",
+"File %s could not be reverted to version %s" => "Dosya %s, %s versiyonuna döndürülemedi.",
+"No old versions available" => "Eski versiyonlar mevcut değil.",
+"No path specified" => "Yama belirtilmemiş",
+"Versions" => "Sürümler"
);
diff --git a/apps/files_versions/l10n/uk.php b/apps/files_versions/l10n/uk.php
index 49acda81079..bfee066c63d 100644
--- a/apps/files_versions/l10n/uk.php
+++ b/apps/files_versions/l10n/uk.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Історія",
-"Files Versioning" => "Версії файлів",
-"Enable" => "Включити"
+"Could not revert: %s" => "Не вдалося відновити: %s",
+"success" => "успішно",
+"File %s was reverted to version %s" => "Файл %s був відновлений до версії %s",
+"failure" => "неуспішно",
+"File %s could not be reverted to version %s" => "Файл %s не може бути відновлений до версії %s",
+"No old versions available" => "Старі версії недоступні",
+"No path specified" => "Шлях не вказаний",
+"Revert a file to a previous version by clicking on its revert button" => "Відновити файл на попередню версію, натиснувши на кнопку Відновити"
);
diff --git a/apps/files_versions/l10n/vi.php b/apps/files_versions/l10n/vi.php
index bb7163f6b18..f2499e7bf35 100644
--- a/apps/files_versions/l10n/vi.php
+++ b/apps/files_versions/l10n/vi.php
@@ -1,5 +1,10 @@
<?php $TRANSLATIONS = array(
-"History" => "Lịch sử",
-"Files Versioning" => "Phiên bản tập tin",
-"Enable" => "Bật "
+"Could not revert: %s" => "Không thể khôi phục: %s",
+"success" => "thành công",
+"File %s was reverted to version %s" => "File %s đã được khôi phục về phiên bản %s",
+"failure" => "Thất bại",
+"File %s could not be reverted to version %s" => "File %s không thể khôi phục về phiên bản %s",
+"No old versions available" => "Không có phiên bản cũ nào",
+"No path specified" => "Không chỉ ra đường dẫn rõ ràng",
+"Revert a file to a previous version by clicking on its revert button" => "Khôi phục một file về phiên bản trước đó bằng cách click vào nút Khôi phục tương ứng"
);
diff --git a/apps/files_versions/l10n/zh_CN.php b/apps/files_versions/l10n/zh_CN.php
index 14301ff0c04..65d0d284a07 100644
--- a/apps/files_versions/l10n/zh_CN.php
+++ b/apps/files_versions/l10n/zh_CN.php
@@ -1,5 +1,11 @@
<?php $TRANSLATIONS = array(
-"History" => "历史",
-"Files Versioning" => "文件版本",
-"Enable" => "开启"
+"Could not revert: %s" => "无法恢复: %s",
+"success" => "成功",
+"File %s was reverted to version %s" => "文件 %s 已被恢复到历史版本 %s",
+"failure" => "失败",
+"File %s could not be reverted to version %s" => "文件 %s 无法被恢复到历史版本 %s",
+"No old versions available" => "该文件没有历史版本",
+"No path specified" => "未指定路径",
+"Versions" => "版本",
+"Revert a file to a previous version by clicking on its revert button" => "点击恢复按钮可将文件恢复到之前的版本"
);
diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php
index dc02c605c44..7891b20e92f 100644
--- a/apps/files_versions/lib/hooks.php
+++ b/apps/files_versions/lib/hooks.php
@@ -20,13 +20,10 @@ class Hooks {
public static function write_hook( $params ) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
-
- $versions = new Storage( new \OC\Files\View('') );
-
$path = $params[\OC\Files\Filesystem::signal_param_path];
-
- if($path<>'') $versions->store( $path );
-
+ if($path<>'') {
+ Storage::store($path);
+ }
}
}
@@ -40,13 +37,11 @@ class Hooks {
*/
public static function remove_hook($params) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
-
- $versions = new Storage( new \OC_FilesystemView('') );
-
$path = $params[\OC\Files\Filesystem::signal_param_path];
-
- if($path<>'') $versions->delete( $path );
-
+ if($path<>'') {
+ Storage::delete($path);
+ }
+
}
}
@@ -59,15 +54,13 @@ class Hooks {
*/
public static function rename_hook($params) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
-
- $versions = new Storage( new \OC_FilesystemView('') );
-
$oldpath = $params['oldpath'];
$newpath = $params['newpath'];
-
- if($oldpath<>'' && $newpath<>'') $versions->rename( $oldpath, $newpath );
-
+ if($oldpath<>'' && $newpath<>'') {
+ Storage::rename( $oldpath, $newpath );
+ }
+
}
}
-
+
}
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index b54bc4a4422..178ef722735 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -19,53 +19,74 @@ class Storage {
const DEFAULTENABLED=true;
const DEFAULTMAXSIZE=50; // unit: percentage; 50% of available disk space/quota
-
+
private static $max_versions_per_interval = array(
- 1 => array('intervalEndsAfter' => 10, //first 10sec, one version every 2sec
- 'step' => 2),
- 2 => array('intervalEndsAfter' => 60, //next minute, one version every 10sec
- 'step' => 10),
- 3 => array('intervalEndsAfter' => 3600, //next hour, one version every minute
- 'step' => 60),
- 4 => array('intervalEndsAfter' => 86400, //next 24h, one version every hour
- 'step' => 3600),
- 5 => array('intervalEndsAfter' => 2592000, //next 30days, one version per day
- 'step' => 86400),
- 6 => array('intervalEndsAfter' => -1, //until the end one version per week
- 'step' => 604800),
- );
-
- 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();
+ //first 10sec, one version every 2sec
+ 1 => array('intervalEndsAfter' => 10, 'step' => 2),
+ //next minute, one version every 10sec
+ 2 => array('intervalEndsAfter' => 60, 'step' => 10),
+ //next hour, one version every minute
+ 3 => array('intervalEndsAfter' => 3600, 'step' => 60),
+ //next 24h, one version every hour
+ 4 => array('intervalEndsAfter' => 86400, 'step' => 3600),
+ //next 30days, one version per day
+ 5 => array('intervalEndsAfter' => 2592000, 'step' => 86400),
+ //until the end one version per week
+ 6 => array('intervalEndsAfter' => -1, 'step' => 604800),
+ );
+
+ public static function getUidAndFilename($filename) {
+ $uid = \OC\Files\Filesystem::getOwner($filename);
+ \OC\Files\Filesystem::initMountPoints($uid);
+ if ( $uid != \OCP\User::getUser() ) {
+ $info = \OC\Files\Filesystem::getFileInfo($filename);
+ $ownerView = new \OC\Files\View('/'.$uid.'/files');
+ $filename = $ownerView->getPath($info['fileid']);
}
return array($uid, $filename);
}
/**
+ * get current size of all versions from a given user
+ *
+ * @param $user user who owns the versions
+ * @return mixed versions size or false if no versions size is stored
+ */
+ private static function getVersionsSize($user) {
+ $query = \OC_DB::prepare('SELECT size FROM *PREFIX*files_versions WHERE user=?');
+ $result = $query->execute(array($user))->fetchAll();
+
+ if ($result) {
+ return $result[0]['size'];
+ }
+ return false;
+ }
+
+ /**
+ * write to the database how much space is in use for versions
+ *
+ * @param $user owner of the versions
+ * @param $size size of the versions
+ */
+ private static function setVersionsSize($user, $size) {
+ if ( self::getVersionsSize($user) === false) {
+ $query = \OC_DB::prepare('INSERT INTO *PREFIX*files_versions (size, user) VALUES (?, ?)');
+ }else {
+ $query = \OC_DB::prepare('UPDATE *PREFIX*files_versions SET size=? WHERE user=?');
+ }
+ $query->execute(array($size, $user));
+ }
+
+ /**
* store a new version of a file.
*/
- public function store($filename) {
+ public static function store($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
list($uid, $filename) = self::getUidAndFilename($filename);
- $files_view = new \OC\Files\View('/'.\OCP\User::getUser() .'/files');
- $users_view = new \OC\Files\View('/'.\OCP\User::getUser());
- //check if source file already exist as version to avoid recursions.
- // todo does this check work?
- if ($users_view->file_exists($filename)) {
- return false;
- }
+ $files_view = new \OC\Files\View('/'.$uid .'/files');
+ $users_view = new \OC\Files\View('/'.$uid);
+ $versions_view = new \OC\Files\View('/'.$uid.'/files_versions');
// check if filename is a directory
if($files_view->is_dir($filename)) {
@@ -79,23 +100,25 @@ class Storage {
// create all parent folders
$info=pathinfo($filename);
- $versionsFolderName=\OCP\Config::getSystemValue('datadirectory').$users_view->getAbsolutePath('files_versions/');
+ $versionsFolderName=$versions_view->getLocalFolder('');
if(!file_exists($versionsFolderName.'/'.$info['dirname'])) {
mkdir($versionsFolderName.'/'.$info['dirname'], 0750, true);
}
// store a new version of a file
- $result = $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename));
- if ( ($versionsSize = \OCP\Config::getAppValue('files_versions', 'size')) === null ) {
+ $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename));
+ $versionsSize = self::getVersionsSize($uid);
+ if ( $versionsSize === false || $versionsSize < 0 ) {
$versionsSize = self::calculateSize($uid);
}
+
$versionsSize += $users_view->filesize('files'.$filename);
-
+
// expire old revisions if necessary
$newSize = self::expire($filename, $versionsSize);
-
- if ( $newSize != $versionsSize ) {
- \OCP\Config::setAppValue('files_versions', 'size', $versionsSize);
+
+ if ( $newSize != $versionsSize ) {
+ self::setVersionsSize($uid, $newSize);
}
}
}
@@ -106,43 +129,43 @@ class Storage {
*/
public static function delete($filename) {
list($uid, $filename) = self::getUidAndFilename($filename);
- $versions_fileview = new \OC_FilesystemView('/'.$uid .'/files_versions');
-
- $abs_path = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$filename.'.v';
- if( ($versions = self::getVersions($filename)) ) {
- if ( ($versionsSize = \OCP\Config::getAppValue('files_versions', 'size')) === null ) {
+ $versions_fileview = new \OC\Files\View('/'.$uid .'/files_versions');
+
+ $abs_path = $versions_fileview->getLocalFile($filename.'.v');
+ if( ($versions = self::getVersions($uid, $filename)) ) {
+ $versionsSize = self::getVersionsSize($uid);
+ if ( $versionsSize === false || $versionsSize < 0 ) {
$versionsSize = self::calculateSize($uid);
}
foreach ($versions as $v) {
unlink($abs_path . $v['version']);
$versionsSize -= $v['size'];
}
- \OCP\Config::setAppValue('files_versions', 'size', $versionsSize);
+ self::setVersionsSize($uid, $versionsSize);
}
}
-
+
/**
* rename versions of a file
*/
public static function rename($oldpath, $newpath) {
list($uid, $oldpath) = self::getUidAndFilename($oldpath);
list($uidn, $newpath) = self::getUidAndFilename($newpath);
- $versions_view = new \OC_FilesystemView('/'.$uid .'/files_versions');
- $files_view = new \OC_FilesystemView('/'.$uid .'/files');
- $abs_newpath = \OCP\Config::getSystemValue('datadirectory').$versions_view->getAbsolutePath('').$newpath;
-
+ $versions_view = new \OC\Files\View('/'.$uid .'/files_versions');
+ $files_view = new \OC\Files\View('/'.$uid .'/files');
+ $abs_newpath = $versions_view->getLocalFile($newpath);
+
if ( $files_view->is_dir($oldpath) && $versions_view->is_dir($oldpath) ) {
$versions_view->rename($oldpath, $newpath);
- } else if ( ($versions = Storage::getVersions($oldpath)) ) {
+ } else if ( ($versions = Storage::getVersions($uid, $oldpath)) ) {
$info=pathinfo($abs_newpath);
if(!file_exists($info['dirname'])) mkdir($info['dirname'], 0750, true);
- $versions = Storage::getVersions($oldpath);
foreach ($versions as $v) {
$versions_view->rename($oldpath.'.v'.$v['version'], $newpath.'.v'.$v['version']);
}
}
}
-
+
/**
* rollback to an old version of a file.
*/
@@ -152,14 +175,14 @@ class Storage {
list($uid, $filename) = self::getUidAndFilename($filename);
$users_view = new \OC\Files\View('/'.$uid);
$versionCreated = false;
-
+
//first create a new version
$version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename);
if ( !$users_view->file_exists($version)) {
$users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename));
$versionCreated = true;
}
-
+
// rollback
if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) {
$users_view->touch('files'.$filename, $revision);
@@ -177,23 +200,27 @@ class Storage {
/**
* @brief get a list of all available versions of a file in descending chronological order
+ * @param $uid user id from the owner of the file
* @param $filename file to find versions of, relative to the user files dir
* @param $count number of versions to return
* @returns array
*/
- public static function getVersions( $filename, $count = 0 ) {
+ public static function getVersions($uid, $filename, $count = 0 ) {
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
- list($uid, $filename) = self::getUidAndFilename($filename);
- $versions_fileview = new \OC\Files\View('/' . \OCP\User::getUser() . '/files_versions');
-
- $versionsName = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename);
+ $versions_fileview = new \OC\Files\View('/' . $uid . '/files_versions');
+ $versionsName = $versions_fileview->getLocalFile($filename);
+
$versions = array();
// fetch for old versions
- $matches = glob( $versionsName.'.v*' );
+ $matches = glob(preg_quote($versionsName).'.v*' );
+
+ if ( !$matches ) {
+ return $versions;
+ }
sort( $matches );
- $files_view = new \OC_FilesystemView('/'.$uid.'/files');
+ $files_view = new \OC\Files\View('/'.$uid.'/files');
$local_file = $files_view->getLocalFile($filename);
$local_file_md5 = \md5_file( $local_file );
@@ -244,24 +271,27 @@ class Storage {
*/
private static function calculateSize($uid) {
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
- $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
- $versionsRoot = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('');
-
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($versionsRoot), \RecursiveIteratorIterator::CHILD_FIRST);
-
+ $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions');
+ $versionsRoot = $versions_fileview->getLocalFolder('');
+
+ $iterator = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($versionsRoot),
+ \RecursiveIteratorIterator::CHILD_FIRST
+ );
+
$size = 0;
-
+
foreach ($iterator as $path) {
if ( preg_match('/^.+\.v(\d+)$/', $path, $match) ) {
$relpath = substr($path, strlen($versionsRoot)-1);
$size += $versions_fileview->filesize($relpath);
}
}
-
+
return $size;
}
}
-
+
/**
* @brief returns all stored file versions from a given user
* @param $uid id to the user
@@ -269,26 +299,29 @@ class Storage {
*/
private static function getAllVersions($uid) {
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
- $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
- $versionsRoot = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('');
-
- $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($versionsRoot), \RecursiveIteratorIterator::CHILD_FIRST);
-
+ $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions');
+ $versionsRoot = $versions_fileview->getLocalFolder('');
+
+ $iterator = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($versionsRoot),
+ \RecursiveIteratorIterator::CHILD_FIRST
+ );
+
$versions = array();
-
+
foreach ($iterator as $path) {
if ( preg_match('/^.+\.v(\d+)$/', $path, $match) ) {
$relpath = substr($path, strlen($versionsRoot)-1);
$versions[$match[1].'#'.$relpath] = array('path' => $relpath, 'timestamp' => $match[1]);
}
}
-
+
ksort($versions);
-
+
$i = 0;
-
+
$result = array();
-
+
foreach( $versions as $key => $value ) {
$i++;
$size = $versions_fileview->filesize($value['path']);
@@ -297,14 +330,14 @@ class Storage {
$result['all'][$key]['version'] = $value['timestamp'];
$result['all'][$key]['path'] = $filename;
$result['all'][$key]['size'] = $size;
-
+
$filename = substr($value['path'], 0, -strlen($value['timestamp'])-2);
$result['by_file'][$filename][$key]['version'] = $value['timestamp'];
$result['by_file'][$filename][$key]['path'] = $filename;
$result['by_file'][$filename][$key]['size'] = $size;
-
+
}
-
+
return $result;
}
}
@@ -314,68 +347,71 @@ class Storage {
*/
private static function expire($filename, $versionsSize = null) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
- list($uid, $filename) = self::getUidAndFilename($filename);
- $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions');
-
+ list($uid, $filename) = self::getUidAndFilename($filename);
+ $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions');
+
// get available disk space for user
- $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($uid, 'files', 'quota'));
- if ( $quota == null ) {
- $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota'));
+ $quota = \OC_Preferences::getValue($uid, 'files', 'quota');
+ if ( $quota === null || $quota === 'default') {
+ $quota = \OC_Appconfig::getValue('files', 'default_quota');
}
- if ( $quota == null ) {
- $quota = \OC\Files\Filesystem::free_space('/');
+ if ( $quota === null || $quota === 'none' ) {
+ $quota = \OC\Files\Filesystem::free_space('/') / count(\OCP\User::getUsers());
+ } else {
+ $quota = \OCP\Util::computerFileSize($quota);
}
// make sure that we have the current size of the version history
if ( $versionsSize === null ) {
- if ( ($versionsSize = \OCP\Config::getAppValue('files_versions', 'size')) === null ) {
+ $versionsSize = self::getVersionsSize($uid);
+ if ( $versionsSize === false || $versionsSize < 0 ) {
$versionsSize = self::calculateSize($uid);
}
}
// calculate available space for version history
- $files_view = new \OC_FilesystemView('/'.$uid.'/files');
+ $files_view = new \OC\Files\View('/'.$uid.'/files');
$rootInfo = $files_view->getFileInfo('/');
$free = $quota-$rootInfo['size']; // remaining free space for user
if ( $free > 0 ) {
$availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $versionsSize; // how much space can be used for versions
} else {
$availableSpace = $free-$versionsSize;
- }
+ }
- // after every 1000s run reduce the number of all versions not only for the current file
+ // after every 1000s run reduce the number of all versions not only for the current file
$random = rand(0, 1000);
if ($random == 0) {
$result = Storage::getAllVersions($uid);
$versions_by_file = $result['by_file'];
$all_versions = $result['all'];
} else {
- $all_versions = Storage::getVersions($filename);
+ $all_versions = Storage::getVersions($uid, $filename);
$versions_by_file[$filename] = $all_versions;
}
-
+
$time = time();
-
+
// it is possible to expire versions from more than one file
// iterate through all given files
foreach ($versions_by_file as $filename => $versions) {
$versions = array_reverse($versions); // newest version first
-
+
$interval = 1;
- $step = Storage::$max_versions_per_interval[$interval]['step'];
+ $step = Storage::$max_versions_per_interval[$interval]['step'];
if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) {
$nextInterval = -1;
} else {
$nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'];
}
-
+
$firstVersion = reset($versions);
$firstKey = key($versions);
$prevTimestamp = $firstVersion['version'];
$nextVersion = $firstVersion['version'] - $step;
$remaining_versions[$firstKey] = $firstVersion;
unset($versions[$firstKey]);
-
+
foreach ($versions as $key => $version) {
$newInterval = true;
while ( $newInterval ) {
@@ -405,11 +441,11 @@ class Storage {
$prevTimestamp = $version['version'];
}
}
-
+
// check if enough space is available after versions are rearranged.
// if not we delete the oldest versions until we meet the size limit for versions
$numOfVersions = count($all_versions);
- $i = 0;
+ $i = 0;
while ($availableSpace < 0) {
if ($i = $numOfVersions-2) break; // keep at least the last version
$versions_fileview->unlink($all_versions[$i]['path'].'.v'.$all_versions[$i]['version']);
@@ -417,10 +453,10 @@ class Storage {
$availableSpace += $all_versions[$i]['size'];
$i++;
}
-
+
return $versionsSize; // finally return the new size of the version history
}
-
+
return false;
}
}
diff --git a/apps/files_versions/settings.php b/apps/files_versions/settings.php
deleted file mode 100644
index f2873b8f7c2..00000000000
--- a/apps/files_versions/settings.php
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-
-OCP\User::checkAdminUser();
-
-OCP\Util::addscript( 'files_versions', 'versions' );
-
-$tmpl = new OCP\Template( 'files_versions', 'settings');
-
-return $tmpl->fetchPage();
diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php
index 850ece89c98..f7284439041 100644
--- a/apps/files_versions/templates/history.php
+++ b/apps/files_versions/templates/history.php
@@ -5,28 +5,29 @@
if( isset( $_['message'] ) ) {
- if( isset($_['path'] ) ) echo('<strong>File: '.$_['path'] ).'</strong><br>';
- echo('<strong>'.$_['message'] ).'</strong><br>';
+ if( isset($_['path'] ) ) print_unescaped('<strong>File: '.OC_Util::sanitizeHTML($_['path'])).'</strong><br>';
+ print_unescaped('<strong>'.OC_Util::sanitizeHTML($_['message']) ).'</strong><br>';
}else{
if( isset( $_['outcome_stat'] ) ) {
- echo( '<div id="feedback-messages" class="'.$_['outcome_stat'].'"><h3>'.$_['outcome_msg'] ).'</h3></div><br>';
+ print_unescaped( '<div id="feedback-messages" class="'.OC_Util::sanitizeHTML($_['outcome_stat']).'"><h3>'.OC_Util::sanitizeHTML($_['outcome_msg']) ).'</h3></div><br>';
}
- echo( '<strong>Versions of '.$_['path'] ).'</strong><br>';
- echo('<p><em>'.$l->t('Revert a file to a previous version by clicking on its revert button').'</em></p><br />');
+ print_unescaped( '<strong>Versions of '.OC_Util::sanitizeHTML($_['path']) ).'</strong><br>';
+ print_unescaped('<p><em>'.OC_Util::sanitizeHTML($l->t('Revert a file to a previous version by clicking on its revert button')).'</em></p><br />');
foreach ( $_['versions'] as $v ) {
- echo ' ';
- echo OCP\Util::formatDate( doubleval($v['version']) );
- echo ' <a href="'.OCP\Util::linkTo('files_versions', 'history.php', array('path' => $_['path'], 'revert' => $v['version'])) .'" class="button">Revert</a><br /><br />';
+ p(' ');
+ p(OCP\Util::formatDate( doubleval($v['version'])));
+ print_unescaped(' <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>)';
+ print_unescaped(' (<b>Current</b>)');
}
- echo '<br /><br />';
+ print_unescaped('<br /><br />');
}
}
diff --git a/apps/files_versions/templates/settings.php b/apps/files_versions/templates/settings.php
deleted file mode 100644
index bfca8366f5d..00000000000
--- a/apps/files_versions/templates/settings.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<form id="versionssettings">
- <fieldset class="personalblock">
- <legend><strong><?php echo $l->t('Files Versioning');?></strong></legend>
- <input type="checkbox" name="versions" id="versions" value="1" <?php if (OCP\Config::getSystemValue('versions', 'true')=='true') echo ' checked="checked"'; ?> /> <label for="versions"><?php echo $l->t('Enable'); ?></label> <br/>
- </fieldset>
-</form>