Whitespace fixes
This commit is contained in:
parent
78fce83405
commit
bb75dfc021
40 changed files with 448 additions and 452 deletions
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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')) {
|
||||
|
|
|
@ -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':
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
|
@ -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){
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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/>.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 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;
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
// 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;
|
||||
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;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,4 +69,3 @@
|
|||
</td>
|
||||
</tr>
|
||||
<?php endforeach;
|
||||
|
|
@ -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) ))));
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,9 @@ function createVersionsDropdown(filename, files) {
|
|||
} else {
|
||||
$(html).appendTo($('thead .share'));
|
||||
}
|
||||
|
||||
|
||||
$("#makelink").click(function() {
|
||||
goToVersionPage(historyUrl);
|
||||
goToVersionPage(historyUrl);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
|
|
|
@ -41,7 +41,7 @@ class Hooks {
|
|||
if($path<>'') {
|
||||
Storage::delete($path);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ class Hooks {
|
|||
if($oldpath<>'' && $newpath<>'') {
|
||||
Storage::rename( $oldpath, $newpath );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,4 +102,3 @@ class Helper {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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']));
|
||||
}
|
||||
|
|
|
@ -62,12 +62,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
|
|||
}
|
||||
} else {
|
||||
$newPath = $this->path . '/' . $name;
|
||||
|
||||
|
||||
// mark file as partial while uploading (ignored by the scanner)
|
||||
$partpath = $newPath . '.part';
|
||||
|
||||
|
||||
\OC\Files\Filesystem::file_put_contents($partpath, $data);
|
||||
|
||||
|
||||
//detect aborted upload
|
||||
if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
|
||||
if (isset($_SERVER['CONTENT_LENGTH'])) {
|
||||
|
@ -80,10 +80,10 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rename to correct path
|
||||
\OC\Files\Filesystem::rename($partpath, $newPath);
|
||||
|
||||
|
||||
// allow sync clients to send the mtime along in a header
|
||||
$mtime = OC_Request::hasModificationTime();
|
||||
if ($mtime !== false) {
|
||||
|
@ -91,7 +91,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
|
|||
header('X-OC-MTime: accepted');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
|
|||
|
||||
// mark file as partial while uploading (ignored by the scanner)
|
||||
$partpath = $this->path . '.part';
|
||||
|
||||
|
||||
\OC\Files\Filesystem::file_put_contents($partpath, $data);
|
||||
|
||||
|
||||
//detect aborted upload
|
||||
if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
|
||||
if (isset($_SERVER['CONTENT_LENGTH'])) {
|
||||
|
@ -62,10 +62,10 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rename to correct path
|
||||
\OC\Files\Filesystem::rename($partpath, $this->path);
|
||||
|
||||
|
||||
//allow sync clients to send the mtime along in a header
|
||||
$mtime = OC_Request::hasModificationTime();
|
||||
if ($mtime !== false) {
|
||||
|
|
6
lib/files/cache/legacy.php
vendored
6
lib/files/cache/legacy.php
vendored
|
@ -51,12 +51,12 @@ class Legacy {
|
|||
$this->cacheHasItems = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ($result === false || property_exists($result, 'error_message_prefix')) {
|
||||
$this->cacheHasItems = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->cacheHasItems = (bool)$result->fetchRow();
|
||||
return $this->cacheHasItems;
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ class Filesystem {
|
|||
|
||||
$root = \OC_User::getHome($user);
|
||||
self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
|
||||
|
||||
|
||||
// Load system mount points
|
||||
if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file(\OC::$SERVERROOT . '/config/mount.json')) {
|
||||
if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
|
||||
|
|
|
@ -278,7 +278,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
|
|||
return uniqid();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* clean a path, i.e. remove all redundant '.' and '..'
|
||||
* making sure that it can't point to higher than '/'
|
||||
|
@ -289,7 +289,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
|
|||
if (strlen($path) == 0 or $path[0] != '/') {
|
||||
$path = '/' . $path;
|
||||
}
|
||||
|
||||
|
||||
$output = array();
|
||||
foreach (explode('/', $path) as $chunk) {
|
||||
if ($chunk == '..') {
|
||||
|
|
|
@ -286,31 +286,31 @@ class OC_Group {
|
|||
}
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get a list of all display names in a group
|
||||
* @returns array with display names (value) and user ids(key)
|
||||
*/
|
||||
public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
$displayNames=array();
|
||||
foreach(self::$_usedBackends as $backend) {
|
||||
$displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames);
|
||||
}
|
||||
return $displayNames;
|
||||
|
||||
/**
|
||||
* @brief get a list of all display names in a group
|
||||
* @returns array with display names (value) and user ids(key)
|
||||
*/
|
||||
public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
$displayNames=array();
|
||||
foreach(self::$_usedBackends as $backend) {
|
||||
$displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames);
|
||||
}
|
||||
return $displayNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get a list of all display names in several groups
|
||||
* @param array $gids
|
||||
* @param string $search
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return array with display names (Key) user ids (value)
|
||||
*/
|
||||
public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {
|
||||
|
||||
/**
|
||||
* @brief get a list of all display names in several groups
|
||||
* @param array $gids
|
||||
* @param string $search
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return array with display names (Key) user ids (value)
|
||||
*/
|
||||
public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {
|
||||
$displayNames = array();
|
||||
foreach ($gids as $gid) {
|
||||
// TODO Need to apply limits to groups as total
|
||||
foreach ($gids as $gid) {
|
||||
// TODO Need to apply limits to groups as total
|
||||
$diff = array_diff(
|
||||
self::displayNamesInGroup($gid, $search, $limit, $offset),
|
||||
$displayNames
|
||||
|
@ -318,7 +318,7 @@ class OC_Group {
|
|||
if ($diff) {
|
||||
$displayNames = array_merge($diff, $displayNames);
|
||||
}
|
||||
}
|
||||
return $displayNames;
|
||||
}
|
||||
return $displayNames;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,23 +133,23 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
|
|||
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get a list of all display names in a group
|
||||
* @param string $gid
|
||||
* @param string $search
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return array with display names (value) and user ids (key)
|
||||
*/
|
||||
public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
$displayNames = '';
|
||||
$users = $this->usersInGroup($gid, $search, $limit, $offset);
|
||||
foreach ( $users as $user ) {
|
||||
$DisplayNames[$user] = $user;
|
||||
}
|
||||
|
||||
return $DisplayNames;
|
||||
|
||||
/**
|
||||
* @brief get a list of all display names in a group
|
||||
* @param string $gid
|
||||
* @param string $search
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return array with display names (value) and user ids (key)
|
||||
*/
|
||||
public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
$displayNames = '';
|
||||
$users = $this->usersInGroup($gid, $search, $limit, $offset);
|
||||
foreach ( $users as $user ) {
|
||||
$DisplayNames[$user] = $user;
|
||||
}
|
||||
|
||||
return $DisplayNames;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -210,16 +210,16 @@ class OC_Group_Database extends OC_Group_Backend {
|
|||
}
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get a list of all display names in a group
|
||||
* @param string $gid
|
||||
* @param string $search
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return array with display names (value) and user ids (key)
|
||||
*/
|
||||
public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
|
||||
/**
|
||||
* @brief get a list of all display names in a group
|
||||
* @param string $gid
|
||||
* @param string $search
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return array with display names (value) and user ids (key)
|
||||
*/
|
||||
public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||
$displayNames = '';
|
||||
|
||||
$stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname`'
|
||||
|
@ -228,12 +228,12 @@ class OC_Group_Database extends OC_Group_Backend {
|
|||
.' WHERE `gid` = ? AND `*PREFIX*group_user`.`uid` LIKE ?',
|
||||
$limit,
|
||||
$offset);
|
||||
$result = $stmt->execute(array($gid, $search.'%'));
|
||||
$users = array();
|
||||
$result = $stmt->execute(array($gid, $search.'%'));
|
||||
$users = array();
|
||||
while ($row = $result->fetchRow()) {
|
||||
$displayName = trim($row['displayname'], ' ');
|
||||
$displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
|
||||
}
|
||||
return $displayNames;
|
||||
$displayName = trim($row['displayname'], ' ');
|
||||
$displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
|
||||
}
|
||||
return $displayNames;
|
||||
}
|
||||
}
|
||||
|
|
16
lib/hook.php
16
lib/hook.php
|
@ -20,23 +20,23 @@ class OC_Hook{
|
|||
* TODO: write example
|
||||
*/
|
||||
static public function connect( $signalclass, $signalname, $slotclass, $slotname ) {
|
||||
// If we're trying to connect to an emitting class that isn't
|
||||
// If we're trying to connect to an emitting class that isn't
|
||||
// yet registered, register it
|
||||
if( !array_key_exists( $signalclass, self::$registered )) {
|
||||
self::$registered[$signalclass] = array();
|
||||
}
|
||||
// If we're trying to connect to an emitting method that isn't
|
||||
// If we're trying to connect to an emitting method that isn't
|
||||
// yet registered, register it with the emitting class
|
||||
if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
|
||||
if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
|
||||
self::$registered[$signalclass][$signalname] = array();
|
||||
}
|
||||
|
||||
|
||||
// Connect the hook handler to the requested emitter
|
||||
self::$registered[$signalclass][$signalname][] = array(
|
||||
"class" => $slotclass,
|
||||
"name" => $slotname
|
||||
);
|
||||
|
||||
|
||||
// No chance for failure ;-)
|
||||
return true;
|
||||
}
|
||||
|
@ -53,19 +53,19 @@ class OC_Hook{
|
|||
* TODO: write example
|
||||
*/
|
||||
static public function emit( $signalclass, $signalname, $params = array()) {
|
||||
|
||||
|
||||
// Return false if no hook handlers are listening to this
|
||||
// emitting class
|
||||
if( !array_key_exists( $signalclass, self::$registered )) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Return false if no hook handlers are listening to this
|
||||
// emitting method
|
||||
if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Call all slots
|
||||
foreach( self::$registered[$signalclass][$signalname] as $i ) {
|
||||
try {
|
||||
|
|
|
@ -765,7 +765,7 @@ class OC_Image {
|
|||
imagealphablending($process, false);
|
||||
imagesavealpha($process, true);
|
||||
}
|
||||
|
||||
|
||||
imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);
|
||||
if ($process == false) {
|
||||
OC_Log::write('core',
|
||||
|
|
|
@ -384,7 +384,7 @@ class Share {
|
|||
'itemSource' => $itemSource,
|
||||
'shareType' => $shareType,
|
||||
'shareWith' => $shareWith,
|
||||
));
|
||||
));
|
||||
self::delete($item['id']);
|
||||
return true;
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ class Share {
|
|||
'itemType' => $itemType,
|
||||
'itemSource' => $itemSource,
|
||||
'shares' => $shares
|
||||
));
|
||||
));
|
||||
foreach ($shares as $share) {
|
||||
self::delete($share['id']);
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ class Share {
|
|||
if ( isset($row['uid_owner']) && $row['uid_owner'] != '') {
|
||||
$row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']);
|
||||
}
|
||||
|
||||
|
||||
$items[$row['id']] = $row;
|
||||
}
|
||||
if (!empty($items)) {
|
||||
|
|
|
@ -52,25 +52,25 @@ class User {
|
|||
public static function getUsers($search = '', $limit = null, $offset = null) {
|
||||
return \OC_USER::getUsers();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get the user display name of the user currently logged in.
|
||||
* @return string display name
|
||||
*/
|
||||
public static function getDisplayName($user=null) {
|
||||
return \OC_USER::getDisplayName($user);
|
||||
|
||||
/**
|
||||
* @brief get the user display name of the user currently logged in.
|
||||
* @return string display name
|
||||
*/
|
||||
public static function getDisplayName($user=null) {
|
||||
return \OC_USER::getDisplayName($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a list of all display names
|
||||
* @returns array with all display names (value) and the correspondig uids (key)
|
||||
*
|
||||
* Get a list of all display names and user ids.
|
||||
*/
|
||||
public static function getDisplayNames($search = '', $limit = null, $offset = null) {
|
||||
return \OC_USER::getDisplayNames($search, $limit, $offset);
|
||||
|
||||
/**
|
||||
* @brief Get a list of all display names
|
||||
* @returns array with all display names (value) and the correspondig uids (key)
|
||||
*
|
||||
* Get a list of all display names and user ids.
|
||||
*/
|
||||
public static function getDisplayNames($search = '', $limit = null, $offset = null) {
|
||||
return \OC_USER::getDisplayNames($search, $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if the user is logged in
|
||||
* @returns true/false
|
||||
|
|
|
@ -149,7 +149,7 @@ class OC_Request {
|
|||
return 'gzip';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if the requester sent along an mtime
|
||||
* @returns false or an mtime
|
||||
|
|
|
@ -57,14 +57,14 @@ class OC_Search{
|
|||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove an existing search provider
|
||||
* @param string $provider class name of a OC_Search_Provider
|
||||
*/
|
||||
public static function removeProvider($provider) {
|
||||
self::$registeredProviders = array_filter(
|
||||
self::$registeredProviders,
|
||||
self::$registeredProviders,
|
||||
function ($element) use ($provider) {
|
||||
return ($element['class'] != $provider);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class OC_Setup {
|
|||
$error[] = array(
|
||||
'error' => $e->getMessage(),
|
||||
'hint' => $e->getHint()
|
||||
);
|
||||
);
|
||||
return($error);
|
||||
} catch (Exception $e) {
|
||||
$error[] = array(
|
||||
|
@ -174,7 +174,7 @@ class OC_Setup {
|
|||
OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
|
||||
OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
|
||||
OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
|
||||
|
||||
|
||||
OC_Group::createGroup('admin');
|
||||
OC_Group::addToGroup($username, 'admin');
|
||||
OC_User::login($username, $password);
|
||||
|
@ -276,7 +276,7 @@ class OC_Setup {
|
|||
$query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
|
||||
$result = mysql_query($query, $connection);
|
||||
if (!$result) {
|
||||
throw new DatabaseSetupException($l->t("MySQL user '%s'@'%%' already exists", array($name)),
|
||||
throw new DatabaseSetupException($l->t("MySQL user '%s'@'%%' already exists", array($name)),
|
||||
$l->t("Drop this user from MySQL."));
|
||||
}
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ class OC_Setup {
|
|||
$result = oci_execute($stmt);
|
||||
if(!$result) {
|
||||
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry .= $l->t('Offending command was: "%s", name: %s, password: %s',
|
||||
$entry .= $l->t('Offending command was: "%s", name: %s, password: %s',
|
||||
array($query, $name, $password)) . '<br />';
|
||||
echo($entry);
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ class OC_Setup {
|
|||
$result = oci_execute($stmt);
|
||||
if(!$result) {
|
||||
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
|
||||
$entry .= $l->t('Offending command was: "%s", name: %s, password: %s',
|
||||
$entry .= $l->t('Offending command was: "%s", name: %s, password: %s',
|
||||
array($query, $name, $password)) . '<br />';
|
||||
echo($entry);
|
||||
}
|
||||
|
|
|
@ -437,7 +437,7 @@ class OC_User {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check whether user can change his display name
|
||||
* @param $uid The username
|
||||
|
|
|
@ -124,7 +124,7 @@ abstract class OC_User_Backend implements OC_User_Interface {
|
|||
public function getHome($uid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief get display name of the user
|
||||
* @param $uid user ID of the user
|
||||
|
@ -133,7 +133,7 @@ abstract class OC_User_Backend implements OC_User_Interface {
|
|||
public function getDisplayName($uid) {
|
||||
return $uid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get a list of all display names
|
||||
* @returns array with all displayNames (value) and the corresponding uids (key)
|
||||
|
|
|
@ -110,7 +110,7 @@ class OC_User_Database extends OC_User_Backend {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set display name
|
||||
* @param $uid The username
|
||||
|
@ -146,7 +146,7 @@ class OC_User_Database extends OC_User_Backend {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get a list of all display names
|
||||
* @returns array with all displayNames (value) and the correspondig uids (key)
|
||||
|
@ -162,7 +162,7 @@ class OC_User_Database extends OC_User_Backend {
|
|||
while ($row = $result->fetchRow()) {
|
||||
$displayNames[$row['uid']] = $row['displayname'];
|
||||
}
|
||||
|
||||
|
||||
// let's see if we can also find some users who don't have a display name yet
|
||||
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
|
||||
.' WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset);
|
||||
|
@ -173,11 +173,11 @@ class OC_User_Database extends OC_User_Backend {
|
|||
$displayNames[$row['uid']] = $row['uid'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $displayNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if the password is correct
|
||||
* @param $uid The username
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
<?php
|
||||
// Check if we are a user
|
||||
|
||||
OCP\JSON::callCheck();
|
||||
OC_JSON::checkLoggedIn();
|
||||
|
||||
$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
|
||||
$displayName = $_POST["displayName"];
|
||||
|
||||
$userstatus = null;
|
||||
if(OC_User::isAdminUser(OC_User::getUser())) {
|
||||
$userstatus = 'admin';
|
||||
}
|
||||
if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
|
||||
$userstatus = 'subadmin';
|
||||
}
|
||||
|
||||
if ($username == OC_User::getUser() && OC_User::canUserChangeDisplayName($username)) {
|
||||
$userstatus = 'changeOwnDisplayName';
|
||||
}
|
||||
|
||||
if(is_null($userstatus)) {
|
||||
OC_JSON::error( array( "data" => array( "message" => $l->t("Authentication error") )));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Return Success story
|
||||
if( OC_User::setDisplayName( $username, $displayName )) {
|
||||
OC_JSON::success(array("data" => array( "username" => $username, 'displayName' => $displayName )));
|
||||
}
|
||||
else{
|
||||
<?php
|
||||
// Check if we are a user
|
||||
|
||||
OCP\JSON::callCheck();
|
||||
OC_JSON::checkLoggedIn();
|
||||
|
||||
$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
|
||||
$displayName = $_POST["displayName"];
|
||||
|
||||
$userstatus = null;
|
||||
if(OC_User::isAdminUser(OC_User::getUser())) {
|
||||
$userstatus = 'admin';
|
||||
}
|
||||
if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
|
||||
$userstatus = 'subadmin';
|
||||
}
|
||||
|
||||
if ($username == OC_User::getUser() && OC_User::canUserChangeDisplayName($username)) {
|
||||
$userstatus = 'changeOwnDisplayName';
|
||||
}
|
||||
|
||||
if(is_null($userstatus)) {
|
||||
OC_JSON::error( array( "data" => array( "message" => $l->t("Authentication error") )));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Return Success story
|
||||
if( OC_User::setDisplayName( $username, $displayName )) {
|
||||
OC_JSON::success(array("data" => array( "username" => $username, 'displayName' => $displayName )));
|
||||
}
|
||||
else{
|
||||
OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change display name"), 'displayName' => OC_User::getDisplayName($username) )));
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ $this->create('settings_ajax_removegroup', '/settings/ajax/removegroup.php')
|
|||
->actionInclude('settings/ajax/removegroup.php');
|
||||
$this->create('settings_ajax_changepassword', '/settings/ajax/changepassword.php')
|
||||
->actionInclude('settings/ajax/changepassword.php');
|
||||
$this->create('settings_ajax_changedisplayname', '/settings/ajax/changedisplayname.php')
|
||||
$this->create('settings_ajax_changedisplayname', '/settings/ajax/changedisplayname.php')
|
||||
->actionInclude('settings/ajax/changedisplayname.php');
|
||||
// personel
|
||||
$this->create('settings_ajax_lostpassword', '/settings/ajax/lostpassword.php')
|
||||
|
|
Loading…
Reference in a new issue