summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-02-22 17:21:57 +0100
committerBart Visscher <bartv@thisnet.nl>2013-02-22 19:05:36 +0100
commitbb75dfc021a68bcd9526ef40f78bca4910798345 (patch)
tree30185c8198f4da87f180214bf1f2076ec48f3777 /apps
parent78fce834058a38a7dbcc5310e16095c743434bc6 (diff)
downloadnextcloud-server-bb75dfc021a68bcd9526ef40f78bca4910798345.tar.gz
nextcloud-server-bb75dfc021a68bcd9526ef40f78bca4910798345.zip
Whitespace fixes
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/filelist.js14
-rw-r--r--apps/files/js/files.js20
-rwxr-xr-xapps/files_external/lib/config.php16
-rw-r--r--apps/files_external/lib/sftp.php14
-rw-r--r--apps/files_sharing/public.php3
-rw-r--r--apps/files_trashbin/ajax/delete.php2
-rw-r--r--apps/files_trashbin/ajax/undelete.php4
-rw-r--r--apps/files_trashbin/appinfo/app.php6
-rw-r--r--apps/files_trashbin/index.php28
-rw-r--r--apps/files_trashbin/js/disableDefaultActions.js6
-rw-r--r--apps/files_trashbin/js/trash.js24
-rw-r--r--apps/files_trashbin/lib/hooks.php40
-rw-r--r--apps/files_trashbin/lib/trash.php322
-rw-r--r--apps/files_trashbin/templates/part.list.php1
-rw-r--r--apps/files_versions/ajax/rollbackVersion.php1
-rw-r--r--apps/files_versions/js/versions.js4
-rw-r--r--apps/files_versions/lib/hooks.php6
-rw-r--r--apps/files_versions/lib/versions.php84
-rw-r--r--apps/user_ldap/lib/helper.php1
-rwxr-xr-xapps/user_webdavauth/settings.php2
20 files changed, 297 insertions, 301 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 0bf1f79ab77..ea721059c3f 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -35,7 +35,7 @@ var FileList={
if(extension){
name_span.append($('<span></span>').addClass('extension').text(extension));
}
- //dirs can show the number of uploaded files
+ //dirs can show the number of uploaded files
if (type == 'dir') {
link_elem.append($('<span></span>').attr({
'class': 'uploadtext',
@@ -44,7 +44,7 @@ var FileList={
}
td.append(link_elem);
tr.append(td);
-
+
//size column
if(size!=t('files', 'Pending')){
simpleSize=simpleFileSize(size);
@@ -59,7 +59,7 @@ var FileList={
"style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'
}).text(simpleSize);
tr.append(td);
-
+
// date column
var modifiedColor = Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
td = $('<td></td>').attr({ "class": "date" });
@@ -87,7 +87,7 @@ var FileList={
lastModified,
$('#permissions').val()
);
-
+
FileList.insertElement(name, 'file', tr.attr('data-file',name));
var row = $('tr').filterAttr('data-file',name);
if(loading){
@@ -101,7 +101,7 @@ var FileList={
FileActions.display(row.find('td.filename'));
},
addDir:function(name,size,lastModified,hidden){
-
+
var tr = this.createRow(
'dir',
name,
@@ -111,7 +111,7 @@ var FileList={
lastModified,
$('#permissions').val()
);
-
+
FileList.insertElement(name,'dir',tr);
var row = $('tr').filterAttr('data-file',name);
row.find('td.filename').draggable(dragOptions);
@@ -344,7 +344,7 @@ var FileList={
var deleteAction = $('tr').filterAttr('data-file',file).children("td.date").children(".move2trash");
deleteAction[0].outerHTML = oldHTML;
});
- }
+ }
});
}
};
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 8327460cca6..6801fb59910 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -114,7 +114,7 @@ $(document).ready(function() {
$(this).parent().children('#file_upload_start').trigger('click');
return false;
});
-
+
// Show trash bin
$('#trash a').live('click', function() {
window.location=OC.filePath('files_trashbin', '', 'index.php');
@@ -817,26 +817,26 @@ var createDragShadow = function(event){
//select dragged file
$(event.target).parents('tr').find('td input:first').prop('checked',true);
}
-
+
var selectedFiles = getSelectedFiles();
-
+
if (!isDragSelected && selectedFiles.length == 1) {
//revert the selection
$(event.target).parents('tr').find('td input:first').prop('checked',false);
}
-
+
//also update class when we dragged more than one file
if (selectedFiles.length > 1) {
$(event.target).parents('tr').addClass('selected');
}
-
+
// build dragshadow
var dragshadow = $('<table class="dragshadow"></table>');
var tbody = $('<tbody></tbody>');
dragshadow.append(tbody);
-
+
var dir=$('#dir').val();
-
+
$(selectedFiles).each(function(i,elem){
var newtr = $('<tr data-dir="'+dir+'" data-filename="'+elem.name+'">'
+'<td class="filename">'+elem.name+'</td><td class="size">'+humanFileSize(elem.size)+'</td>'
@@ -850,7 +850,7 @@ var createDragShadow = function(event){
});
}
});
-
+
return dragshadow;
}
@@ -870,9 +870,9 @@ var folderDropOptions={
if ($(event.target).parents('tr').find('td input:first').prop('checked') === true) {
return false;
}
-
+
var target=$.trim($(this).find('.nametext').text());
-
+
var files = ui.helper.find('tr');
$(files).each(function(i,row){
var dir = $(row).data('dir');
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index d31c2f35a68..905c5d50cde 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -38,7 +38,7 @@ class OC_Mount_Config {
* @return array
*/
public static function getBackends() {
-
+
$backends['\OC\Files\Storage\Local']=array(
'backend' => 'Local',
'configuration' => array(
@@ -77,7 +77,7 @@ class OC_Mount_Config {
'token' => '#token',
'token_secret' => '#token secret'),
'custom' => 'google');
-
+
$backends['\OC\Files\Storage\SWIFT']=array(
'backend' => 'OpenStack Swift',
'configuration' => array(
@@ -86,7 +86,7 @@ class OC_Mount_Config {
'token' => '*Token',
'root' => '&Root',
'secure' => '!Secure ftps://'));
-
+
if(OC_Mount_Config::checksmbclient()) $backends['\OC\Files\Storage\SMB']=array(
'backend' => 'SMB / CIFS',
'configuration' => array(
@@ -95,7 +95,7 @@ class OC_Mount_Config {
'password' => '*Password',
'share' => 'Share',
'root' => '&Root'));
-
+
$backends['\OC\Files\Storage\DAV']=array(
'backend' => 'ownCloud / WebDAV',
'configuration' => array(
@@ -104,13 +104,13 @@ class OC_Mount_Config {
'password' => '*Password',
'root' => '&Root',
'secure' => '!Secure https://'));
-
+
$backends['\OC\Files\Storage\SFTP']=array(
'backend' => 'SFTP',
'configuration' => array(
'host' => 'URL',
- 'user' => 'Username',
- 'password' => '*Password',
+ 'user' => 'Username',
+ 'password' => '*Password',
'root' => '&Root'));
return($backends);
@@ -378,7 +378,7 @@ class OC_Mount_Config {
}
/**
- * check if php-ftp is installed
+ * check if php-ftp is installed
*/
public static function checkphpftp() {
if(function_exists('ftp_login')) {
diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php
index 785eb7dfc42..ede6c251fd9 100644
--- a/apps/files_external/lib/sftp.php
+++ b/apps/files_external/lib/sftp.php
@@ -32,7 +32,7 @@ class SFTP extends \OC\Files\Storage\Common {
$this->root = isset($params['root']) ? $this->cleanPath($params['root']) : '/';
if ($this->root[0] != '/') $this->root = '/' . $this->root;
if (substr($this->root, -1, 1) != '/') $this->root .= '/';
-
+
$host_keys = $this->read_host_keys();
$this->client = new \Net_SFTP($this->host);
@@ -50,18 +50,18 @@ class SFTP extends \OC\Files\Storage\Common {
$host_keys[$this->host] = $current_host_key;
$this->write_host_keys($host_keys);
}
-
+
if(!$this->file_exists('')){
$this->mkdir('');
}
}
-
+
public function test() {
if (!isset($params['host']) || !isset($params['user']) || !isset($params['password'])) {
throw new \Exception("Required parameters not set");
- }
+ }
}
-
+
public function getId(){
return 'sftp::' . $this->user . '@' . $this->host . '/' . $this->root;
}
@@ -109,7 +109,7 @@ class SFTP extends \OC\Files\Storage\Common {
$host_key_arr = explode("::", $line, 2);
if (count($host_key_arr) == 2) {
$hosts[] = $host_key_arr[0];
- $keys[] = $host_key_arr[1];
+ $keys[] = $host_key_arr[1];
}
}
return array_combine($hosts, $keys);
@@ -203,7 +203,7 @@ class SFTP extends \OC\Files\Storage\Common {
$tmp = \OC_Helper::tmpFile($ext);
$this->getFile($abs_path, $tmp);
return fopen($tmp, $mode);
-
+
case 'w':
case 'wb':
case 'a':
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index f265a7dd014..243ee668f1f 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -43,7 +43,7 @@ if (isset($_GET['t'])) {
$path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
}
}
-}
+}
if (isset($path)) {
if (!isset($linkItem['item_type'])) {
OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR);
@@ -212,4 +212,3 @@ if (isset($path)) {
header('HTTP/1.0 404 Not Found');
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->printPage();
-
diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php
index 34f35c39ccb..1834fb54003 100644
--- a/apps/files_trashbin/ajax/delete.php
+++ b/apps/files_trashbin/ajax/delete.php
@@ -20,7 +20,7 @@ foreach ($list as $file) {
$filename = $file;
$timestamp = null;
}
-
+
OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp);
if (!OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) {
$success[$i]['filename'] = $file;
diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php
index 93f2aaf1fa2..80de3c31f91 100644
--- a/apps/files_trashbin/ajax/undelete.php
+++ b/apps/files_trashbin/ajax/undelete.php
@@ -1,4 +1,4 @@
-<?php
+<?php
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
@@ -21,7 +21,7 @@ foreach ($list as $file) {
$filename = $path_parts['basename'];
$timestamp = null;
}
-
+
if ( !OCA\Files_Trashbin\Trashbin::restore($file, $filename, $timestamp) ) {
$error[] = $filename;
} else {
diff --git a/apps/files_trashbin/appinfo/app.php b/apps/files_trashbin/appinfo/app.php
index b1a15cd13d1..7c04e583db1 100644
--- a/apps/files_trashbin/appinfo/app.php
+++ b/apps/files_trashbin/appinfo/app.php
@@ -1,7 +1,7 @@
<?php
-OC::$CLASSPATH['OCA\Files_Trashbin\Hooks'] = 'apps/files_trashbin/lib/hooks.php';
-OC::$CLASSPATH['OCA\Files_Trashbin\Trashbin'] = 'apps/files_trashbin/lib/trash.php';
+OC::$CLASSPATH['OCA\Files_Trashbin\Hooks'] = 'apps/files_trashbin/lib/hooks.php';
+OC::$CLASSPATH['OCA\Files_Trashbin\Trashbin'] = 'apps/files_trashbin/lib/trash.php';
+
-
OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Files_Trashbin\Hooks", "remove_hook");
diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php
index d0b3030dbf8..4615df3586f 100644
--- a/apps/files_trashbin/index.php
+++ b/apps/files_trashbin/index.php
@@ -1,6 +1,6 @@
<?php
-// Check if we are a user
+// Check if we are a user
OCP\User::checkLoggedIn();
OCP\Util::addScript('files_trashbin', 'trash');
@@ -19,7 +19,7 @@ $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
$result = array();
if ($dir) {
$dirlisting = true;
- $view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_trashbin');
+ $view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_trashbin');
$fullpath = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($dir);
$dirContent = opendir($fullpath);
$i = 0;
@@ -36,10 +36,10 @@ if ($dir) {
'type' => $view->is_dir($dir.'/'.$entryName) ? 'dir' : 'file',
'location' => $dir,
);
- }
+ }
}
closedir($dirContent);
-
+
} else {
$dirlisting = false;
$query = \OC_DB::prepare('SELECT id,location,timestamp,type,mime FROM *PREFIX*files_trash WHERE user=?');
@@ -67,28 +67,28 @@ foreach ($result as $r) {
$files[] = $i;
}
-// Make breadcrumb
+// Make breadcrumb
$pathtohere = '';
-$breadcrumb = array();
-foreach (explode('/', $dir) as $i) {
+$breadcrumb = array();
+foreach (explode('/', $dir) as $i) {
if ($i != '') {
if ( preg_match('/^(.+)\.d[0-9]+$/', $i, $match) ) {
$name = $match[1];
} else {
$name = $i;
- }
- $pathtohere .= '/' . $i;
- $breadcrumb[] = array('dir' => $pathtohere, 'name' => $name);
- }
+ }
+ $pathtohere .= '/' . $i;
+ $breadcrumb[] = array('dir' => $pathtohere, 'name' => $name);
+ }
}
-$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
-$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
+$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
+$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php') . '?dir=', false);
$list = new OCP\Template('files_trashbin', 'part.list', '');
$list->assign('files', $files, false);
-$list->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php'). '?dir='.$dir, false);
+$list->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php'). '?dir='.$dir, false);
$list->assign('downloadURL', OCP\Util::linkTo('files_trashbin', 'download.php') . '?file='.$dir, false);
$list->assign('disableSharing', true);
$list->assign('dirlisting', $dirlisting);
diff --git a/apps/files_trashbin/js/disableDefaultActions.js b/apps/files_trashbin/js/disableDefaultActions.js
index 27c3e13db4d..df08bfb1a50 100644
--- a/apps/files_trashbin/js/disableDefaultActions.js
+++ b/apps/files_trashbin/js/disableDefaultActions.js
@@ -1,4 +1,4 @@
-/* disable download and sharing actions */
-var disableDownloadActions = true;
-var disableSharing = true;
+/* disable download and sharing actions */
+var disableDownloadActions = true;
+var disableSharing = true;
var trashBinApp = true; \ No newline at end of file
diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js
index 208cc88f0fd..7769def535e 100644
--- a/apps/files_trashbin/js/trash.js
+++ b/apps/files_trashbin/js/trash.js
@@ -19,22 +19,22 @@ $(document).ready(function() {
OC.dialogs.alert(result.data.message, 'Error');
}
});
-
+
});
};
-
+
FileActions.register('all', 'Delete', OC.PERMISSION_READ, function () {
return OC.imagePath('core', 'actions/delete');
}, function (filename) {
$('.tipsy').remove();
-
+
var tr=$('tr').filterAttr('data-file', filename);
var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete");
var oldHTML = deleteAction[0].outerHTML;
var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'delete file permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
var files = tr.attr('data-file');
deleteAction[0].outerHTML = newHTML;
-
+
$.post(OC.filePath('files_trashbin','ajax','delete.php'),
{files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') },
function(result){
@@ -46,9 +46,9 @@ $(document).ready(function() {
OC.dialogs.alert(result.data.message, 'Error');
}
});
-
+
});
-
+
// Sets the select_all checkbox behaviour :
$('#select_all').click(function() {
if($(this).attr('checked')){
@@ -91,18 +91,18 @@ $(document).ready(function() {
}
processSelection();
});
-
+
$('.undelete').click('click',function(event) {
var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>';
var files=getSelectedFiles('file');
var fileslist = JSON.stringify(files);
var dirlisting=getSelectedFiles('dirlisting')[0];
-
+
for (var i=0; i<files.length; i++) {
var undeleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date");
undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner;
}
-
+
$.post(OC.filePath('files_trashbin','ajax','undelete.php'),
{files:fileslist, dirlisting:dirlisting},
function(result){
@@ -115,19 +115,19 @@ $(document).ready(function() {
}
});
});
-
+
$('.delete').click('click',function(event) {
console.log("delete selected");
var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'Delete permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>';
var files=getSelectedFiles('file');
var fileslist = JSON.stringify(files);
var dirlisting=getSelectedFiles('dirlisting')[0];
-
+
for (var i=0; i<files.length; i++) {
var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date");
deleteAction[0].innerHTML = deleteAction[0].innerHTML+spinner;
}
-
+
$.post(OC.filePath('files_trashbin','ajax','delete.php'),
{files:fileslist, dirlisting:dirlisting},
function(result){
diff --git a/apps/files_trashbin/lib/hooks.php b/apps/files_trashbin/lib/hooks.php
index d6a62d447b8..9081706a2c5 100644
--- a/apps/files_trashbin/lib/hooks.php
+++ b/apps/files_trashbin/lib/hooks.php
@@ -1,23 +1,23 @@
<?php
-/**
- * ownCloud - trash bin
- *
- * @author Bjoern Schiessle
- * @copyright 2013 Bjoern Schiessle schiessle@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+/**
+ * ownCloud - trash bin
+ *
+ * @author Bjoern Schiessle
+ * @copyright 2013 Bjoern Schiessle schiessle@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
/**
@@ -36,7 +36,7 @@ class Hooks {
* to copy the file to the trash bin
*/
public static function remove_hook($params) {
-
+
if ( \OCP\App::isEnabled('files_trashbin') ) {
$path = $params['path'];
Trashbin::move2trash($path);
diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php
index 2b8b32c3a16..8355c7252b0 100644
--- a/apps/files_trashbin/lib/trash.php
+++ b/apps/files_trashbin/lib/trash.php
@@ -1,67 +1,67 @@
<?php
-/**
- * ownCloud - trash bin
- *
- * @author Bjoern Schiessle
- * @copyright 2013 Bjoern Schiessle schiessle@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Files_Trashbin;
-
+/**
+ * ownCloud - trash bin
+ *
+ * @author Bjoern Schiessle
+ * @copyright 2013 Bjoern Schiessle schiessle@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files_Trashbin;
+
class Trashbin {
// how long do we keep files in the trash bin if no other value is defined in the config file (unit: days)
const DEFAULT_RETENTION_OBLIGATION=180;
// unit: percentage; 50% of available disk space/quota
const DEFAULTMAXSIZE=50;
-
+
/**
* move file to the trash bin
- *
+ *
* @param $file_path path to the deleted file/directory relative to the files root directory
*/
public static function move2trash($file_path) {
$user = \OCP\User::getUser();
- $view = new \OC_FilesystemView('/'. $user);
- if (!$view->is_dir('files_trashbin')) {
- $view->mkdir('files_trashbin');
- $view->mkdir("versions_trashbin");
- }
-
- $path_parts = pathinfo($file_path);
-
- $deleted = $path_parts['basename'];
- $location = $path_parts['dirname'];
- $timestamp = time();
- $mime = $view->getMimeType('files'.$file_path);
-
- if ( $view->is_dir('files'.$file_path) ) {
- $type = 'dir';
- } else {
- $type = 'file';
+ $view = new \OC_FilesystemView('/'. $user);
+ if (!$view->is_dir('files_trashbin')) {
+ $view->mkdir('files_trashbin');
+ $view->mkdir("versions_trashbin");
}
-
- if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) {
+
+ $path_parts = pathinfo($file_path);
+
+ $deleted = $path_parts['basename'];
+ $location = $path_parts['dirname'];
+ $timestamp = time();
+ $mime = $view->getMimeType('files'.$file_path);
+
+ if ( $view->is_dir('files'.$file_path) ) {
+ $type = 'dir';
+ } else {
+ $type = 'file';
+ }
+
+ if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) {
$trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin'));
- $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin'));
+ $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin'));
}
$trashbinSize += self::copy_recursive($file_path, 'files_trashbin/'.$deleted.'.d'.$timestamp, $view);
- if ( $view->file_exists('files_trashbin/'.$deleted.'.d'.$timestamp) ) {
+ if ( $view->file_exists('files_trashbin/'.$deleted.'.d'.$timestamp) ) {
$query = \OC_DB::prepare("INSERT INTO *PREFIX*files_trash (id,timestamp,location,type,mime,user)"
." VALUES (?,?,?,?,?,?)");
$result = $query->execute(array($deleted, $timestamp, $location, $type, $mime, $user));
@@ -69,49 +69,49 @@ class Trashbin {
$view->deleteAll('files_trashbin/'.$deleted.'.d'.$timestamp);
\OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR);
return;
- }
-
- if ( \OCP\App::isEnabled('files_versions') ) {
+ }
+
+ if ( \OCP\App::isEnabled('files_versions') ) {
if ( $view->is_dir('files_versions'.$file_path) ) {
$trashbinSize += self::calculateSize(
new \OC_FilesystemView('/'. $user.'/files_versions/'.$file_path)
);
- $view->rename('files_versions'.$file_path, 'versions_trashbin/'. $deleted.'.d'.$timestamp);
- } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) {
+ $view->rename('files_versions'.$file_path, 'versions_trashbin/'. $deleted.'.d'.$timestamp);
+ } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) {
foreach ($versions as $v) {
- $trashbinSize += $view->filesize('files_versions'.$v['path'].'.v'.$v['version']);
+ $trashbinSize += $view->filesize('files_versions'.$v['path'].'.v'.$v['version']);
$view->rename('files_versions'.$v['path'].'.v'.$v['version'],
'versions_trashbin/'. $deleted.'.v'.$v['version'].'.d'.$timestamp);
- }
- }
+ }
+ }
}
} else {
\OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin', \OC_log::ERROR);
}
-
- // get available disk space for user
- $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($user, 'files', 'quota'));
- if ( $quota == null ) {
- $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota'));
- }
- if ( $quota == null ) {
- $quota = \OC\Files\Filesystem::free_space('/');
+
+ // get available disk space for user
+ $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($user, 'files', 'quota'));
+ if ( $quota == null ) {
+ $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota'));
+ }
+ if ( $quota == null ) {
+ $quota = \OC\Files\Filesystem::free_space('/');
}
-
- // calculate available space for trash bin
- $rootInfo = $view->getFileInfo('/files');
- $free = $quota-$rootInfo['size']; // remaining free space for user
- if ( $free > 0 ) {
- $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions
- } else {
- $availableSpace = $free-$trashbinSize;
+
+ // calculate available space for trash bin
+ $rootInfo = $view->getFileInfo('/files');
+ $free = $quota-$rootInfo['size']; // remaining free space for user
+ if ( $free > 0 ) {
+ $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions
+ } else {
+ $availableSpace = $free-$trashbinSize;
}
-
+
$trashbinSize -= self::expire($availableSpace);
- \OCP\Config::setAppValue('files_trashbin', 'size', $trashbinSize);
+ \OCP\Config::setAppValue('files_trashbin', 'size', $trashbinSize);
}
-
-
+
+
/**
* restore files from trash bin
* @param $file path to the deleted file
@@ -121,10 +121,10 @@ class Trashbin {
public static function restore($file, $filename, $timestamp) {
$user = \OCP\User::getUser();
$view = new \OC_FilesystemView('/'.$user);
-
- if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) {
- $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin'));
- $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin'));
+
+ if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) {
+ $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin'));
+ $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin'));
}
if ( $timestamp ) {
$query = \OC_DB::prepare('SELECT location,type FROM *PREFIX*files_trash'
@@ -134,13 +134,13 @@ class Trashbin {
\OC_Log::write('files_trashbin', 'trash bin database inconsistent!', \OC_Log::ERROR);
return false;
}
-
- // if location no longer exists, restore file in the root directory
- $location = $result[0]['location'];
- if ( $result[0]['location'] != '/' &&
+
+ // if location no longer exists, restore file in the root directory
+ $location = $result[0]['location'];
+ if ( $result[0]['location'] != '/' &&
(!$view->is_dir('files'.$result[0]['location']) ||
- !$view->isUpdatable('files'.$result[0]['location'])) ) {
- $location = '';
+ !$view->isUpdatable('files'.$result[0]['location'])) ) {
+ $location = '';
}
} else {
$path_parts = pathinfo($filename);
@@ -150,10 +150,10 @@ class Trashbin {
);
$location = '';
}
-
+
$source = \OC_Filesystem::normalizePath('files_trashbin/'.$file);
$target = \OC_Filesystem::normalizePath('files/'.$location.'/'.$filename);
-
+
// we need a extension in case a file/dir with the same name already exists
$ext = self::getUniqueExtension($location, $filename, $view);
$mtime = $view->filemtime($source);
@@ -170,14 +170,14 @@ class Trashbin {
$versionedFile = $filename;
} else {
$versionedFile = $file;
- }
+ }
if ( $result[0]['type'] == 'dir' ) {
$trashbinSize -= self::calculateSize(
new \OC_FilesystemView('/'.$user.'/'.'versions_trashbin/'. $file)
);
$view->rename(\OC_Filesystem::normalizePath('versions_trashbin/'. $file),
\OC_Filesystem::normalizePath('files_versions/'.$location.'/'.$filename.$ext));
- } else if ( $versions = self::getVersionsFromTrash($versionedFile, $timestamp) ) {
+ } else if ( $versions = self::getVersionsFromTrash($versionedFile, $timestamp) ) {
foreach ($versions as $v) {
if ($timestamp ) {
$trashbinSize -= $view->filesize('versions_trashbin/'.$versionedFile.'.v'.$v.'.d'.$timestamp);
@@ -187,13 +187,13 @@ class Trashbin {
$trashbinSize -= $view->filesize('versions_trashbin/'.$versionedFile.'.v'.$v);
$view->rename('versions_trashbin/'.$versionedFile.'.v'.$v,
'files_versions/'.$location.'/'.$filename.$ext.'.v'.$v);
- }
- }
- }
+ }
+ }
+ }
}
if ( $timestamp ) {
- $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?');
+ $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?');
$query->execute(array($user,$filename,$timestamp));
}
@@ -205,31 +205,31 @@ class Trashbin {
return false;
}
-
- /**
- * delete file from trash bin permanently
+
+ /**
+ * delete file from trash bin permanently
* @param $filename path to the file
- * @param $timestamp of deletion time
- * @return size of deleted files
- */
- public static function delete($filename, $timestamp=null) {
- $user = \OCP\User::getUser();
+ * @param $timestamp of deletion time
+ * @return size of deleted files
+ */
+ public static function delete($filename, $timestamp=null) {
+ $user = \OCP\User::getUser();
$view = new \OC_FilesystemView('/'.$user);
- $size = 0;
-
- if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) {
- $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin'));
- $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin'));
+ $size = 0;
+
+ if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) {
+ $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin'));
+ $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin'));
}
-
- if ( $timestamp ) {
- $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?');
- $query->execute(array($user,$filename,$timestamp));
+
+ if ( $timestamp ) {
+ $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?');
+ $query->execute(array($user,$filename,$timestamp));
$file = $filename.'.d'.$timestamp;
} else {
$file = $filename;
}
-
+
if ( \OCP\App::isEnabled('files_versions') ) {
if ($view->is_dir('versions_trashbin/'.$file)) {
$size += self::calculateSize(new \OC_Filesystemview('/'.$user.'/versions_trashbin/'.$file));
@@ -245,8 +245,8 @@ class Trashbin {
}
}
}
- }
-
+ }
+
if ($view->is_dir('/files_trashbin/'.$file)) {
$size += self::calculateSize(new \OC_Filesystemview('/'.$user.'/files_trashbin/'.$file));
} else {
@@ -255,8 +255,8 @@ class Trashbin {
$view->unlink('/files_trashbin/'.$file);
$trashbinSize -= $size;
\OCP\Config::setAppValue('files_trashbin', 'size', $trashbinSize);
-
- return $size;
+
+ return $size;
}
/**
@@ -279,22 +279,22 @@ class Trashbin {
return $view->file_exists($target);
}
- /**
+ /**
* clean up the trash bin
- * @param max. available disk space for trashbin
- */
+ * @param max. available disk space for trashbin
+ */
private static function expire($availableSpace) {
-
+
$user = \OCP\User::getUser();
$view = new \OC_FilesystemView('/'.$user);
$size = 0;
-
- $query = \OC_DB::prepare('SELECT location,type,id,timestamp FROM *PREFIX*files_trash WHERE user=?');
+
+ $query = \OC_DB::prepare('SELECT location,type,id,timestamp FROM *PREFIX*files_trash WHERE user=?');
$result = $query->execute(array($user))->fetchAll();
-
+
$retention_obligation = \OC_Config::getValue('trashbin_retention_obligation',
self::DEFAULT_RETENTION_OBLIGATION);
-
+
$limit = time() - ($retention_obligation * 86400);
foreach ( $result as $r ) {
@@ -318,14 +318,14 @@ class Trashbin {
foreach ($versions as $v) {
$size += $view->filesize('versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp);
$view->unlink('versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp);
- }
+ }
}
}
}
-
- $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND timestamp<?');
+
+ $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND timestamp<?');
$query->execute(array($user,$limit));
-
+
$availableSpace = $availableSpace + $size;
// if size limit for trash bin reached, delete oldest files in trash bin
if ($availableSpace < 0) {
@@ -340,15 +340,15 @@ class Trashbin {
$size += $tmp;
$i++;
}
-
+
}
-
- return $size;
+
+ return $size;
}
-
+
/**
* recursive copy to copy a whole directory
- *
+ *
* @param $source source path, relative to the users files directory
* @param $destination destination path relative to the users root directoy
* @param $view file view for the users root directory
@@ -375,7 +375,7 @@ class Trashbin {
}
return $size;
}
-
+
/**
* find all versions which belong to the file we want to restore
* @param $filename name of the file which should be restored
@@ -383,7 +383,7 @@ class Trashbin {
*/
private static function getVersionsFromTrash($filename, $timestamp) {
$view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/versions_trashbin');
- $versionsName = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($filename);
+ $versionsName = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($filename);
$versions = array();
if ($timestamp ) {
// fetch for old versions
@@ -391,20 +391,20 @@ class Trashbin {
$offset = -strlen($timestamp)-2;
} else {
$matches = glob( $versionsName.'.v*' );
- }
-
+ }
+
foreach( $matches as $ma ) {
if ( $timestamp ) {
- $parts = explode( '.v', substr($ma, 0, $offset) );
+ $parts = explode( '.v', substr($ma, 0, $offset) );
$versions[] = ( end( $parts ) );
} else {
- $parts = explode( '.v', $ma );
+ $parts = explode( '.v', $ma );
$versions[] = ( end( $parts ) );
}
}
return $versions;
}
-
+
/**
* find unique extension for restored file if a file with the same name already exists
* @param $location where the file should be restored
@@ -413,40 +413,40 @@ class Trashbin {
* @return string with unique extension
*/
private static function getUniqueExtension($location, $filename, $view) {
- $ext = '';
- if ( $view->file_exists('files'.$location.'/'.$filename) ) {
- $tmpext = '.restored';
- $ext = $tmpext;
- $i = 1;
- while ( $view->file_exists('files'.$location.'/'.$filename.$ext) ) {
- $ext = $tmpext.$i;
- $i++;
- }
+ $ext = '';
+ if ( $view->file_exists('files'.$location.'/'.$filename) ) {
+ $tmpext = '.restored';
+ $ext = $tmpext;
+ $i = 1;
+ while ( $view->file_exists('files'.$location.'/'.$filename.$ext) ) {
+ $ext = $tmpext.$i;
+ $i++;
+ }
}
return $ext;
}
- /**
+ /**
* @brief get the size from a given root folder
- * @param $view file view on the root folder
- * @return size of the folder
- */
- private static function calculateSize($view) {
- $root = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath('');
+ * @param $view file view on the root folder
+ * @return size of the folder
+ */
+ private static function calculateSize($view) {
+ $root = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath('');
if (!file_exists($root)) {
return 0;
}
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root),
- \RecursiveIteratorIterator::CHILD_FIRST);
- $size = 0;
-
+ \RecursiveIteratorIterator::CHILD_FIRST);
+ $size = 0;
+
foreach ($iterator as $path) {
$relpath = substr($path, strlen($root)-1);
if ( !$view->is_dir($relpath) ) {
$size += $view->filesize($relpath);
- }
- }
- return $size;
+ }
+ }
+ return $size;
}
-
-}
+
+}
diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php
index 2de0d7ee91a..dea0a43cd4c 100644
--- a/apps/files_trashbin/templates/part.list.php
+++ b/apps/files_trashbin/templates/part.list.php
@@ -69,4 +69,3 @@
</td>
</tr>
<?php endforeach;
- \ No newline at end of file
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/js/versions.js b/apps/files_versions/js/versions.js
index dec222eefce..109829fa03f 100644
--- a/apps/files_versions/js/versions.js
+++ b/apps/files_versions/js/versions.js
@@ -64,9 +64,9 @@ function createVersionsDropdown(filename, files) {
} else {
$(html).appendTo($('thead .share'));
}
-
+
$("#makelink").click(function() {
- goToVersionPage(historyUrl);
+ goToVersionPage(historyUrl);
});
$.ajax({
diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php
index 6c87eba423d..7891b20e92f 100644
--- a/apps/files_versions/lib/hooks.php
+++ b/apps/files_versions/lib/hooks.php
@@ -41,7 +41,7 @@ class Hooks {
if($path<>'') {
Storage::delete($path);
}
-
+
}
}
@@ -59,8 +59,8 @@ class Hooks {
if($oldpath<>'' && $newpath<>'') {
Storage::rename( $oldpath, $newpath );
}
-
+
}
}
-
+
}
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 8a67de04d83..adbf2c1df7e 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -19,7 +19,7 @@ class Storage {
const DEFAULTENABLED=true;
const DEFAULTMAXSIZE=50; // unit: percentage; 50% of available disk space/quota
-
+
private static $max_versions_per_interval = array(
//first 10sec, one version every 2sec
1 => array('intervalEndsAfter' => 10, 'step' => 2),
@@ -45,14 +45,14 @@ class Storage {
}
return array($uid, $filename);
}
-
+
/**
* store a new version of a file.
*/
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('/'.$uid .'/files');
$users_view = new \OC\Files\View('/'.$uid);
@@ -79,10 +79,10 @@ class Storage {
$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);
}
@@ -96,7 +96,7 @@ class Storage {
public static function delete($filename) {
list($uid, $filename) = self::getUidAndFilename($filename);
$versions_fileview = new \OC\Files\View('/'.$uid .'/files_versions');
-
+
$abs_path = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$filename.'.v';
if( ($versions = self::getVersions($uid, $filename)) ) {
if ( ($versionsSize = \OCP\Config::getAppValue('files_versions', 'size')) === null ) {
@@ -109,7 +109,7 @@ class Storage {
\OCP\Config::setAppValue('files_versions', 'size', $versionsSize);
}
}
-
+
/**
* rename versions of a file
*/
@@ -119,7 +119,7 @@ class Storage {
$versions_view = new \OC\Files\View('/'.$uid .'/files_versions');
$files_view = new \OC\Files\View('/'.$uid .'/files');
$abs_newpath = \OCP\Config::getSystemValue('datadirectory').$versions_view->getAbsolutePath('').$newpath;
-
+
if ( $files_view->is_dir($oldpath) && $versions_view->is_dir($oldpath) ) {
$versions_view->rename($oldpath, $newpath);
} else if ( ($versions = Storage::getVersions($uid, $oldpath)) ) {
@@ -130,7 +130,7 @@ class Storage {
}
}
}
-
+
/**
* rollback to an old version of a file.
*/
@@ -140,14 +140,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);
@@ -178,7 +178,7 @@ class Storage {
$versions = array();
// fetch for old versions
$matches = glob( $versionsName.'.v*' );
-
+
if ( !$matches ) {
return $versions;
}
@@ -238,25 +238,25 @@ class Storage {
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
$versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions');
$versionsRoot = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('');
-
+
$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
@@ -266,27 +266,27 @@ class Storage {
if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) {
$versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions');
$versionsRoot = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('');
-
+
$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']);
@@ -295,14 +295,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;
}
}
@@ -312,9 +312,9 @@ class Storage {
*/
private static function expire($filename, $versionsSize = null) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
- list($uid, $filename) = self::getUidAndFilename($filename);
+ 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 ) {
@@ -323,7 +323,7 @@ class Storage {
if ( $quota == null ) {
$quota = \OC\Files\Filesystem::free_space('/');
}
-
+
// make sure that we have the current size of the version history
if ( $versionsSize === null ) {
if ( ($versionsSize = \OCP\Config::getAppValue('files_versions', 'size')) === null ) {
@@ -339,9 +339,9 @@ class Storage {
$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);
@@ -351,29 +351,29 @@ class Storage {
$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 ) {
@@ -403,11 +403,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']);
@@ -415,10 +415,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/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php
index 29ce998dae7..45c379445af 100644
--- a/apps/user_ldap/lib/helper.php
+++ b/apps/user_ldap/lib/helper.php
@@ -102,4 +102,3 @@ class Helper {
return true;
}
}
-
diff --git a/apps/user_webdavauth/settings.php b/apps/user_webdavauth/settings.php
index 7eabb0d48cc..ae9cb7e4c92 100755
--- a/apps/user_webdavauth/settings.php
+++ b/apps/user_webdavauth/settings.php
@@ -26,7 +26,7 @@ OC_Util::checkAdminUser();
if($_POST) {
// CSRF check
OCP\JSON::callCheck();
-
+
if(isset($_POST['webdav_url'])) {
OC_CONFIG::setValue('user_webdavauth_url', strip_tags($_POST['webdav_url']));
}