merge master into webdav-injection
This commit is contained in:
commit
84cf40ed82
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"camelCase": true,
|
"camelcase": true,
|
||||||
"eqeqeq": true,
|
"eqeqeq": true,
|
||||||
"immed": true,
|
"immed": true,
|
||||||
"latedef": false,
|
"latedef": false,
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
filter:
|
||||||
|
excluded_paths:
|
||||||
|
- '3rdparty/*'
|
||||||
|
- 'apps/*/3rdparty/*'
|
||||||
|
- 'l10n/*'
|
||||||
|
- 'core/l10n/*'
|
||||||
|
- 'apps/*/l10n/*'
|
||||||
|
- 'lib/l10n/*'
|
||||||
|
- 'core/js/tests/lib/*.js'
|
||||||
|
- 'core/js/jquery-1.10.0.min.js'
|
||||||
|
- 'core/js/jquery-migrate-1.2.1.min.js'
|
||||||
|
- 'core/js/jquery-showpassword.js'
|
||||||
|
- 'core/js/jquery-tipsy.js'
|
||||||
|
- 'core/js/jquery.infieldlabel.js'
|
||||||
|
- 'core/js/jquery-ui-1.10.0.custom.js'
|
||||||
|
- 'core/js/jquery.inview.js'
|
||||||
|
- 'core/js/jquery.placeholder.js'
|
||||||
|
|
||||||
|
|
||||||
|
imports:
|
||||||
|
- javascript
|
||||||
|
- php
|
||||||
|
|
2
3rdparty
2
3rdparty
|
@ -1 +1 @@
|
||||||
Subproject commit 478de4b756f3729f762d838b29f69f2a40e5f4f8
|
Subproject commit 184f0a59f87c590ee7e89ced401205a87f213954
|
|
@ -18,7 +18,7 @@ if(\OC\Files\Filesystem::file_exists($target . '/' . $file)) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dir != '' || $file != 'Shared') {
|
if ($target != '' || strtolower($file) != 'shared') {
|
||||||
$targetFile = \OC\Files\Filesystem::normalizePath($target . '/' . $file);
|
$targetFile = \OC\Files\Filesystem::normalizePath($target . '/' . $file);
|
||||||
$sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
|
$sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
|
||||||
if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) {
|
if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// only need filesystem apps
|
// only need filesystem apps
|
||||||
$RUNTIME_APPTYPES=array('filesystem');
|
$RUNTIME_APPTYPES = array('filesystem');
|
||||||
|
|
||||||
OCP\JSON::checkLoggedIn();
|
OCP\JSON::checkLoggedIn();
|
||||||
|
|
||||||
// Load the files
|
// Load the files
|
||||||
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
|
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
|
||||||
$mimetypes = isset($_GET['mimetypes']) ? json_decode($_GET['mimetypes'], true) : '';
|
$mimetypes = isset($_GET['mimetypes']) ? json_decode($_GET['mimetypes'], true) : '';
|
||||||
|
|
||||||
// Clean up duplicates from array and deal with non-array requests
|
// Clean up duplicates from array and deal with non-array requests
|
||||||
|
@ -18,43 +18,40 @@ if (is_array($mimetypes)) {
|
||||||
|
|
||||||
// make filelist
|
// make filelist
|
||||||
$files = array();
|
$files = array();
|
||||||
|
/**
|
||||||
|
* @var \OCP\Files\FileInfo[] $files
|
||||||
|
*/
|
||||||
// If a type other than directory is requested first load them.
|
// If a type other than directory is requested first load them.
|
||||||
if($mimetypes && !in_array('httpd/unix-directory', $mimetypes)) {
|
if ($mimetypes && !in_array('httpd/unix-directory', $mimetypes)) {
|
||||||
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, 'httpd/unix-directory' ) as $file ) {
|
$files = array_merge($files, \OC\Files\Filesystem::getDirectoryContent($dir, 'httpd/unix-directory'));
|
||||||
$file['directory'] = $dir;
|
|
||||||
$file['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file['mimetype']);
|
|
||||||
$file["date"] = OCP\Util::formatDate($file["mtime"]);
|
|
||||||
$file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
|
|
||||||
$files[] = $file;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($mimetypes) && count($mimetypes)) {
|
if (is_array($mimetypes) && count($mimetypes)) {
|
||||||
foreach ($mimetypes as $mimetype) {
|
foreach ($mimetypes as $mimetype) {
|
||||||
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $file ) {
|
$files = array_merge($files, \OC\Files\Filesystem::getDirectoryContent($dir, $mimetype));
|
||||||
$file['directory'] = $dir;
|
|
||||||
$file['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file['mimetype']);
|
|
||||||
$file["date"] = OCP\Util::formatDate($file["mtime"]);
|
|
||||||
$file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
|
|
||||||
$files[] = $file;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $file ) {
|
$files = array_merge($files, \OC\Files\Filesystem::getDirectoryContent($dir));
|
||||||
$file['directory'] = $dir;
|
}
|
||||||
$file['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file['mimetype']);
|
|
||||||
$file["date"] = OCP\Util::formatDate($file["mtime"]);
|
$result = array();
|
||||||
$file['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
|
foreach ($files as $file) {
|
||||||
$files[] = $file;
|
$fileData = array();
|
||||||
}
|
$fileData['directory'] = $dir;
|
||||||
|
$fileData['name'] = $file->getName();
|
||||||
|
$fileData['type'] = $file->getType();
|
||||||
|
$fileData['path'] = $file['path'];
|
||||||
|
$fileData['id'] = $file->getId();
|
||||||
|
$fileData['size'] = $file->getSize();
|
||||||
|
$fileData['mtime'] = $file->getMtime();
|
||||||
|
$fileData['mimetype'] = $file->getMimetype();
|
||||||
|
$fileData['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($file->getMimetype());
|
||||||
|
$fileData["date"] = OCP\Util::formatDate($file->getMtime());
|
||||||
|
$fileData['mimetype_icon'] = \OCA\Files\Helper::determineIcon($file);
|
||||||
|
$result[] = $fileData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort by name
|
// Sort by name
|
||||||
usort($files, function ($a, $b) {
|
usort($result, array('\OCA\Files\Helper', 'fileCmp'));
|
||||||
if ($a['name'] === $b['name']) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ($a['name'] < $b['name']) ? -1 : 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
OC_JSON::success(array('data' => $files));
|
OC_JSON::success(array('data' => $result));
|
||||||
|
|
|
@ -8,19 +8,22 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function switchPublicFolder()
|
function switchPublicFolder() {
|
||||||
{
|
|
||||||
var publicEnable = $('#publicEnable').is(':checked');
|
var publicEnable = $('#publicEnable').is(':checked');
|
||||||
var sharingaimGroup = $('input:radio[name=sharingaim]'); //find all radiobuttons of that group
|
// find all radiobuttons of that group
|
||||||
|
var sharingaimGroup = $('input:radio[name=sharingaim]');
|
||||||
$.each(sharingaimGroup, function(index, sharingaimItem) {
|
$.each(sharingaimGroup, function(index, sharingaimItem) {
|
||||||
sharingaimItem.disabled = !publicEnable; //set all buttons to the correct state
|
// set all buttons to the correct state
|
||||||
|
sharingaimItem.disabled = !publicEnable;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function() {
|
||||||
switchPublicFolder(); // Execute the function after loading DOM tree
|
// Execute the function after loading DOM tree
|
||||||
$('#publicEnable').click(function(){
|
switchPublicFolder();
|
||||||
switchPublicFolder(); // To get rid of onClick()
|
$('#publicEnable').click(function() {
|
||||||
|
// To get rid of onClick()
|
||||||
|
switchPublicFolder();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#allowZipDownload').bind('change', function() {
|
$('#allowZipDownload').bind('change', function() {
|
||||||
|
|
|
@ -82,7 +82,7 @@ OC.Upload = {
|
||||||
*/
|
*/
|
||||||
isProcessing:function() {
|
isProcessing:function() {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
jQuery.each(this._uploads,function(i, data) {
|
jQuery.each(this._uploads,function(i, data) {
|
||||||
if (data.state() === 'pending') {
|
if (data.state() === 'pending') {
|
||||||
count++;
|
count++;
|
||||||
|
@ -208,13 +208,13 @@ $(document).ready(function() {
|
||||||
add: function(e, data) {
|
add: function(e, data) {
|
||||||
OC.Upload.log('add', e, data);
|
OC.Upload.log('add', e, data);
|
||||||
var that = $(this);
|
var that = $(this);
|
||||||
|
|
||||||
// we need to collect all data upload objects before starting the upload so we can check their existence
|
// we need to collect all data upload objects before starting the upload so we can check their existence
|
||||||
// and set individual conflict actions. unfortunately there is only one variable that we can use to identify
|
// and set individual conflict actions. unfortunately there is only one variable that we can use to identify
|
||||||
// the selection a data upload is part of, so we have to collect them in data.originalFiles
|
// the selection a data upload is part of, so we have to collect them in data.originalFiles
|
||||||
// turning singleFileUploads off is not an option because we want to gracefully handle server errors like
|
// turning singleFileUploads off is not an option because we want to gracefully handle server errors like
|
||||||
// already exists
|
// already exists
|
||||||
|
|
||||||
// create a container where we can store the data objects
|
// create a container where we can store the data objects
|
||||||
if ( ! data.originalFiles.selection ) {
|
if ( ! data.originalFiles.selection ) {
|
||||||
// initialize selection and remember number of files to upload
|
// initialize selection and remember number of files to upload
|
||||||
|
@ -225,34 +225,34 @@ $(document).ready(function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var selection = data.originalFiles.selection;
|
var selection = data.originalFiles.selection;
|
||||||
|
|
||||||
// add uploads
|
// add uploads
|
||||||
if ( selection.uploads.length < selection.filesToUpload ) {
|
if ( selection.uploads.length < selection.filesToUpload ) {
|
||||||
// remember upload
|
// remember upload
|
||||||
selection.uploads.push(data);
|
selection.uploads.push(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//examine file
|
//examine file
|
||||||
var file = data.files[0];
|
var file = data.files[0];
|
||||||
try {
|
try {
|
||||||
// FIXME: not so elegant... need to refactor that method to return a value
|
// FIXME: not so elegant... need to refactor that method to return a value
|
||||||
Files.isFileNameValid(file.name);
|
Files.isFileNameValid(file.name, FileList.getCurrentDirectory());
|
||||||
}
|
}
|
||||||
catch (errorMessage) {
|
catch (errorMessage) {
|
||||||
data.textStatus = 'invalidcharacters';
|
data.textStatus = 'invalidcharacters';
|
||||||
data.errorThrown = errorMessage;
|
data.errorThrown = errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.type === '' && file.size === 4096) {
|
if (file.type === '' && file.size === 4096) {
|
||||||
data.textStatus = 'dirorzero';
|
data.textStatus = 'dirorzero';
|
||||||
data.errorThrown = t('files', 'Unable to upload {filename} as it is a directory or has 0 bytes',
|
data.errorThrown = t('files', 'Unable to upload {filename} as it is a directory or has 0 bytes',
|
||||||
{filename: file.name}
|
{filename: file.name}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add size
|
// add size
|
||||||
selection.totalBytes += file.size;
|
selection.totalBytes += file.size;
|
||||||
|
|
||||||
// check PHP upload limit
|
// check PHP upload limit
|
||||||
if (selection.totalBytes > $('#upload_limit').val()) {
|
if (selection.totalBytes > $('#upload_limit').val()) {
|
||||||
data.textStatus = 'sizeexceedlimit';
|
data.textStatus = 'sizeexceedlimit';
|
||||||
|
@ -270,7 +270,7 @@ $(document).ready(function() {
|
||||||
'size2': humanFileSize($('#free_space').val())
|
'size2': humanFileSize($('#free_space').val())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// end upload for whole selection on error
|
// end upload for whole selection on error
|
||||||
if (data.errorThrown) {
|
if (data.errorThrown) {
|
||||||
// trigger fileupload fail
|
// trigger fileupload fail
|
||||||
|
@ -281,12 +281,12 @@ $(document).ready(function() {
|
||||||
|
|
||||||
// check existing files when all is collected
|
// check existing files when all is collected
|
||||||
if ( selection.uploads.length >= selection.filesToUpload ) {
|
if ( selection.uploads.length >= selection.filesToUpload ) {
|
||||||
|
|
||||||
//remove our selection hack:
|
//remove our selection hack:
|
||||||
delete data.originalFiles.selection;
|
delete data.originalFiles.selection;
|
||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
|
|
||||||
onNoConflicts: function (selection) {
|
onNoConflicts: function (selection) {
|
||||||
$.each(selection.uploads, function(i, upload) {
|
$.each(selection.uploads, function(i, upload) {
|
||||||
upload.submit();
|
upload.submit();
|
||||||
|
@ -309,7 +309,7 @@ $(document).ready(function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
OC.Upload.checkExistingFiles(selection, callbacks);
|
OC.Upload.checkExistingFiles(selection, callbacks);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; // continue adding files
|
return true; // continue adding files
|
||||||
|
@ -439,7 +439,7 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
fileupload.on('fileuploadstop', function(e, data) {
|
fileupload.on('fileuploadstop', function(e, data) {
|
||||||
OC.Upload.log('progress handle fileuploadstop', e, data);
|
OC.Upload.log('progress handle fileuploadstop', e, data);
|
||||||
|
|
||||||
$('#uploadprogresswrapper input.stop').fadeOut();
|
$('#uploadprogresswrapper input.stop').fadeOut();
|
||||||
$('#uploadprogressbar').fadeOut();
|
$('#uploadprogressbar').fadeOut();
|
||||||
Files.updateStorageStatistics();
|
Files.updateStorageStatistics();
|
||||||
|
@ -531,7 +531,7 @@ $(document).ready(function() {
|
||||||
if ($(this).children('p').length === 0) {
|
if ($(this).children('p').length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#new .error').tipsy('hide');
|
$('#new .error').tipsy('hide');
|
||||||
|
|
||||||
$('#new li').each(function(i,element) {
|
$('#new li').each(function(i,element) {
|
||||||
|
@ -545,7 +545,7 @@ $(document).ready(function() {
|
||||||
var text=$(this).children('p').text();
|
var text=$(this).children('p').text();
|
||||||
$(this).data('text',text);
|
$(this).data('text',text);
|
||||||
$(this).children('p').remove();
|
$(this).children('p').remove();
|
||||||
|
|
||||||
// add input field
|
// add input field
|
||||||
var form = $('<form></form>');
|
var form = $('<form></form>');
|
||||||
var input = $('<input type="text">');
|
var input = $('<input type="text">');
|
||||||
|
@ -562,7 +562,7 @@ $(document).ready(function() {
|
||||||
throw t('files', 'URL cannot be empty');
|
throw t('files', 'URL cannot be empty');
|
||||||
} else if (type !== 'web' && !Files.isFileNameValid(filename)) {
|
} else if (type !== 'web' && !Files.isFileNameValid(filename)) {
|
||||||
// Files.isFileNameValid(filename) throws an exception itself
|
// Files.isFileNameValid(filename) throws an exception itself
|
||||||
} else if ($('#dir').val() === '/' && filename === 'Shared') {
|
} else if (FileList.getCurrentDirectory() === '/' && filename.toLowerCase() === 'shared') {
|
||||||
throw t('files', 'In the home folder \'Shared\' is a reserved filename');
|
throw t('files', 'In the home folder \'Shared\' is a reserved filename');
|
||||||
} else if (FileList.inList(filename)) {
|
} else if (FileList.inList(filename)) {
|
||||||
throw t('files', '{new_name} already exists', {new_name: filename});
|
throw t('files', '{new_name} already exists', {new_name: filename});
|
||||||
|
|
|
@ -419,15 +419,12 @@ window.FileList={
|
||||||
len = input.val().length;
|
len = input.val().length;
|
||||||
}
|
}
|
||||||
input.selectRange(0, len);
|
input.selectRange(0, len);
|
||||||
|
|
||||||
var checkInput = function () {
|
var checkInput = function () {
|
||||||
var filename = input.val();
|
var filename = input.val();
|
||||||
if (filename !== oldname) {
|
if (filename !== oldname) {
|
||||||
if (!Files.isFileNameValid(filename)) {
|
// Files.isFileNameValid(filename) throws an exception itself
|
||||||
// Files.isFileNameValid(filename) throws an exception itself
|
Files.isFileNameValid(filename, FileList.getCurrentDirectory());
|
||||||
} else if($('#dir').val() === '/' && filename === 'Shared') {
|
if (FileList.inList(filename)) {
|
||||||
throw t('files','In the home folder \'Shared\' is a reserved filename');
|
|
||||||
} else if (FileList.inList(filename)) {
|
|
||||||
throw t('files', '{new_name} already exists', {new_name: filename});
|
throw t('files', '{new_name} already exists', {new_name: filename});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1156,9 +1153,9 @@ $(document).ready(function() {
|
||||||
// need to initially switch the dir to the one from the hash (IE8)
|
// need to initially switch the dir to the one from the hash (IE8)
|
||||||
FileList.changeDirectory(parseCurrentDirFromUrl(), false, true);
|
FileList.changeDirectory(parseCurrentDirFromUrl(), false, true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FileList.setCurrentDir(parseCurrentDirFromUrl(), false);
|
FileList.setCurrentDir(parseCurrentDirFromUrl(), false);
|
||||||
|
}
|
||||||
|
|
||||||
FileList.createFileSummary();
|
FileList.createFileSummary();
|
||||||
});
|
});
|
||||||
|
|
|
@ -87,9 +87,12 @@ var Files = {
|
||||||
* Throws a string exception with an error message if
|
* Throws a string exception with an error message if
|
||||||
* the file name is not valid
|
* the file name is not valid
|
||||||
*/
|
*/
|
||||||
isFileNameValid: function (name) {
|
isFileNameValid: function (name, root) {
|
||||||
var trimmedName = name.trim();
|
var trimmedName = name.trim();
|
||||||
if (trimmedName === '.' || trimmedName === '..') {
|
if (trimmedName === '.'
|
||||||
|
|| trimmedName === '..'
|
||||||
|
|| (root === '/' && trimmedName.toLowerCase() === 'shared'))
|
||||||
|
{
|
||||||
throw t('files', '"{name}" is an invalid file name.', {name: name});
|
throw t('files', '"{name}" is an invalid file name.', {name: name});
|
||||||
} else if (trimmedName.length === 0) {
|
} else if (trimmedName.length === 0) {
|
||||||
throw t('files', 'File name cannot be empty.');
|
throw t('files', 'File name cannot be empty.');
|
||||||
|
|
|
@ -17,7 +17,13 @@ $totalsize = 0; ?>
|
||||||
data-mime="<?php p($file['mimetype'])?>"
|
data-mime="<?php p($file['mimetype'])?>"
|
||||||
data-size="<?php p($file['size']);?>"
|
data-size="<?php p($file['size']);?>"
|
||||||
data-etag="<?php p($file['etag']);?>"
|
data-etag="<?php p($file['etag']);?>"
|
||||||
data-permissions="<?php p($file['permissions']); ?>">
|
data-permissions="<?php p($file['permissions']); ?>"
|
||||||
|
|
||||||
|
<?php if(isset($file['displayname_owner'])): ?>
|
||||||
|
data-share-owner="<?php p($file['displayname_owner']) ?>"
|
||||||
|
<?php endif; ?>
|
||||||
|
>
|
||||||
|
|
||||||
<?php if(isset($file['isPreviewAvailable']) and $file['isPreviewAvailable']): ?>
|
<?php if(isset($file['isPreviewAvailable']) and $file['isPreviewAvailable']): ?>
|
||||||
<td class="filename svg preview-icon"
|
<td class="filename svg preview-icon"
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
@ -34,17 +40,15 @@ $totalsize = 0; ?>
|
||||||
<span class="nametext">
|
<span class="nametext">
|
||||||
<?php print_unescaped(htmlspecialchars($file['name']));?>
|
<?php print_unescaped(htmlspecialchars($file['name']));?>
|
||||||
</span>
|
</span>
|
||||||
|
<span class="uploadtext" currentUploads="0">
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a class="name" href="<?php p(rtrim($_['downloadURL'],'/').'/'.trim($directory,'/').'/'.$name); ?>">
|
<a class="name" href="<?php p(rtrim($_['downloadURL'],'/').'/'.trim($directory,'/').'/'.$name); ?>">
|
||||||
<label class="filetext" title="" for="select-<?php p($file['fileid']); ?>"></label>
|
<label class="filetext" title="" for="select-<?php p($file['fileid']); ?>"></label>
|
||||||
<span class="nametext"><?php print_unescaped(htmlspecialchars($file['basename']));?><span class='extension'><?php p($file['extension']);?></span></span>
|
<span class="nametext"><?php print_unescaped(htmlspecialchars($file['basename']));?><span class='extension'><?php p($file['extension']);?></span></span>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if($file['type'] == 'dir'):?>
|
|
||||||
<span class="uploadtext" currentUploads="0">
|
|
||||||
</span>
|
|
||||||
<?php endif;?>
|
|
||||||
</a>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="filesize"
|
<td class="filesize"
|
||||||
style="color:rgb(<?php p($simple_size_color.','.$simple_size_color.','.$simple_size_color) ?>)">
|
style="color:rgb(<?php p($simple_size_color.','.$simple_size_color.','.$simple_size_color) ?>)">
|
||||||
|
|
|
@ -48,6 +48,41 @@ describe('Files tests', function() {
|
||||||
expect(error).toEqual(false);
|
expect(error).toEqual(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
it('Validates correct file names do not create Shared folder in root', function() {
|
||||||
|
// create shared file in subfolder
|
||||||
|
var error = false;
|
||||||
|
try {
|
||||||
|
expect(Files.isFileNameValid('shared', '/foo')).toEqual(true);
|
||||||
|
expect(Files.isFileNameValid('Shared', '/foo')).toEqual(true);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
expect(error).toEqual(false);
|
||||||
|
|
||||||
|
// create shared file in root
|
||||||
|
var threwException = false;
|
||||||
|
try {
|
||||||
|
Files.isFileNameValid('Shared', '/');
|
||||||
|
console.error('Invalid file name not detected');
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
threwException = true;
|
||||||
|
}
|
||||||
|
expect(threwException).toEqual(true);
|
||||||
|
|
||||||
|
// create shared file in root
|
||||||
|
var threwException = false;
|
||||||
|
try {
|
||||||
|
Files.isFileNameValid('shared', '/');
|
||||||
|
console.error('Invalid file name not detected');
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
threwException = true;
|
||||||
|
}
|
||||||
|
expect(threwException).toEqual(true);
|
||||||
|
|
||||||
|
});
|
||||||
it('Detects invalid file names', function() {
|
it('Detects invalid file names', function() {
|
||||||
var fileNames = [
|
var fileNames = [
|
||||||
'',
|
'',
|
||||||
|
|
|
@ -7,28 +7,6 @@
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
OC.msg={
|
|
||||||
startSaving:function(selector){
|
|
||||||
$(selector)
|
|
||||||
.html( t('settings', 'Saving...') )
|
|
||||||
.removeClass('success')
|
|
||||||
.removeClass('error')
|
|
||||||
.stop(true, true)
|
|
||||||
.show();
|
|
||||||
},
|
|
||||||
finishedSaving:function(selector, data){
|
|
||||||
if( data.status === "success" ){
|
|
||||||
$(selector).html( data.data.message )
|
|
||||||
.addClass('success')
|
|
||||||
.stop(true, true)
|
|
||||||
.delay(3000)
|
|
||||||
.fadeOut(900);
|
|
||||||
}else{
|
|
||||||
$(selector).html( data.data.message ).addClass('error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
// Trigger ajax on recoveryAdmin status change
|
// Trigger ajax on recoveryAdmin status change
|
||||||
var enabledStatus = $('#adminEnableRecovery').val();
|
var enabledStatus = $('#adminEnableRecovery').val();
|
||||||
|
|
|
@ -38,6 +38,7 @@ class Proxy extends \OC_FileProxy {
|
||||||
|
|
||||||
private static $blackList = null; //mimetypes blacklisted from encryption
|
private static $blackList = null; //mimetypes blacklisted from encryption
|
||||||
private static $unencryptedSizes = array(); // remember unencrypted size
|
private static $unencryptedSizes = array(); // remember unencrypted size
|
||||||
|
private static $fopenMode = array(); // remember the fopen mode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a file requires encryption
|
* Check if a file requires encryption
|
||||||
|
@ -146,7 +147,7 @@ class Proxy extends \OC_FileProxy {
|
||||||
if ( isset(self::$unencryptedSizes[$normalizedPath]) ) {
|
if ( isset(self::$unencryptedSizes[$normalizedPath]) ) {
|
||||||
$view = new \OC_FilesystemView('/');
|
$view = new \OC_FilesystemView('/');
|
||||||
$view->putFileInfo($normalizedPath,
|
$view->putFileInfo($normalizedPath,
|
||||||
array('encrypted' => true, 'encrypted_size' => self::$unencryptedSizes[$normalizedPath]));
|
array('encrypted' => true, 'unencrypted_size' => self::$unencryptedSizes[$normalizedPath]));
|
||||||
unset(self::$unencryptedSizes[$normalizedPath]);
|
unset(self::$unencryptedSizes[$normalizedPath]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +214,16 @@ class Proxy extends \OC_FileProxy {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief remember initial fopen mode because sometimes it gets changed during the request
|
||||||
|
* @param string $path path
|
||||||
|
* @param string $mode type of access
|
||||||
|
*/
|
||||||
|
public function preFopen($path, $mode) {
|
||||||
|
self::$fopenMode[$path] = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $path
|
* @param $path
|
||||||
* @param $result
|
* @param $result
|
||||||
|
@ -240,7 +251,15 @@ class Proxy extends \OC_FileProxy {
|
||||||
$proxyStatus = \OC_FileProxy::$enabled;
|
$proxyStatus = \OC_FileProxy::$enabled;
|
||||||
\OC_FileProxy::$enabled = false;
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
$meta = stream_get_meta_data($result);
|
// if we remember the mode from the pre proxy we re-use it
|
||||||
|
// oterwise we fall back to stream_get_meta_data()
|
||||||
|
if (isset(self::$fopenMode[$path])) {
|
||||||
|
$mode = self::$fopenMode[$path];
|
||||||
|
unset(self::$fopenMode[$path]);
|
||||||
|
} else {
|
||||||
|
$meta = stream_get_meta_data($result);
|
||||||
|
$mode = $meta['mode'];
|
||||||
|
}
|
||||||
|
|
||||||
$view = new \OC_FilesystemView('');
|
$view = new \OC_FilesystemView('');
|
||||||
|
|
||||||
|
@ -258,14 +277,15 @@ class Proxy extends \OC_FileProxy {
|
||||||
|
|
||||||
// Open the file using the crypto stream wrapper
|
// Open the file using the crypto stream wrapper
|
||||||
// protocol and let it do the decryption work instead
|
// protocol and let it do the decryption work instead
|
||||||
$result = fopen('crypt://' . $path, $meta['mode']);
|
$result = fopen('crypt://' . $path, $mode);
|
||||||
|
|
||||||
} elseif (
|
} elseif (
|
||||||
self::shouldEncrypt($path)
|
self::shouldEncrypt($path)
|
||||||
and $meta['mode'] !== 'r'
|
and $mode !== 'r'
|
||||||
and $meta['mode'] !== 'rb'
|
and $mode !== 'rb'
|
||||||
|
|
||||||
) {
|
) {
|
||||||
$result = fopen('crypt://' . $path, $meta['mode']);
|
$result = fopen('crypt://' . $path, $mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-enable the proxy
|
// Re-enable the proxy
|
||||||
|
|
|
@ -134,6 +134,14 @@ class Session {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief remove encryption keys and init status from session
|
||||||
|
*/
|
||||||
|
public function closeSession() {
|
||||||
|
\OC::$session->remove('encryptionInitialized');
|
||||||
|
\OC::$session->remove('privateKey');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets status if we already tried to initialize the encryption app
|
* @brief Gets status if we already tried to initialize the encryption app
|
||||||
|
|
|
@ -167,6 +167,9 @@ class Stream {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$this->meta = stream_get_meta_data($this->handle);
|
$this->meta = stream_get_meta_data($this->handle);
|
||||||
|
// sometimes fopen changes the mode, e.g. for a url "r" convert to "r+"
|
||||||
|
// but we need to remember the original access type
|
||||||
|
$this->meta['mode'] = $mode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,6 @@ class Util {
|
||||||
// Set directories to check / create
|
// Set directories to check / create
|
||||||
$setUpDirs = array(
|
$setUpDirs = array(
|
||||||
$this->userDir,
|
$this->userDir,
|
||||||
$this->userFilesDir,
|
|
||||||
$this->publicKeyDir,
|
$this->publicKeyDir,
|
||||||
$this->encryptionDir,
|
$this->encryptionDir,
|
||||||
$this->keyfilesPath,
|
$this->keyfilesPath,
|
||||||
|
@ -1772,4 +1771,12 @@ class Util {
|
||||||
return $session;
|
return $session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief remove encryption related keys from the session
|
||||||
|
*/
|
||||||
|
public function closeEncryptionSession() {
|
||||||
|
$session = new \OCA\Encryption\Session($this->view);
|
||||||
|
$session->closeSession();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
// check if mtime and etags unchanged
|
// check if mtime and etags unchanged
|
||||||
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
|
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
|
||||||
$this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
|
$this->assertSame($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
|
||||||
|
|
||||||
$this->view->unlink($this->userId . '/files/' . $filename);
|
$this->view->unlink($this->userId . '/files/' . $filename);
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
// check if mtime and etags unchanged
|
// check if mtime and etags unchanged
|
||||||
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
|
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
|
||||||
$this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
|
$this->assertSame($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
|
||||||
// file should no longer be encrypted
|
// file should no longer be encrypted
|
||||||
$this->assertEquals(0, $fileInfoUnencrypted['encrypted']);
|
$this->assertEquals(0, $fileInfoUnencrypted['encrypted']);
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ $(document).ready(function() {
|
||||||
OC.MountConfig.saveStorage($(this).parent().parent());
|
OC.MountConfig.saveStorage($(this).parent().parent());
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#sslCertificate').on('click', 'td.remove>img', function() {
|
$('#sslCertificate').on('click', 'td.remove>img', function() {
|
||||||
var $tr = $(this).parent().parent();
|
var $tr = $(this).parent().parent();
|
||||||
var row = this.parentNode.parentNode;
|
var row = this.parentNode.parentNode;
|
||||||
$.post(OC.filePath('files_external', 'ajax', 'removeRootCertificate.php'), {cert: row.id});
|
$.post(OC.filePath('files_external', 'ajax', 'removeRootCertificate.php'), {cert: row.id});
|
||||||
|
@ -302,13 +302,23 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#allowUserMounting').bind('change', function() {
|
$('#allowUserMounting').bind('change', function() {
|
||||||
|
OC.msg.startSaving('#userMountingMsg');
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'yes');
|
OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'yes');
|
||||||
|
$('#userMountingBackups').removeClass('hidden');
|
||||||
} else {
|
} else {
|
||||||
OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'no');
|
OC.AppConfig.setValue('files_external', 'allow_user_mounting', 'no');
|
||||||
|
$('#userMountingBackups').addClass('hidden');
|
||||||
}
|
}
|
||||||
|
OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('input[name="allowUserMountingBackends\\[\\]"]').bind('change', function() {
|
||||||
|
OC.msg.startSaving('#userMountingMsg');
|
||||||
|
var user_mounting_backends = $('input[name="allowUserMountingBackends\\[\\]"]:checked').map(function(){return $(this).val();}).get();
|
||||||
|
OC.AppConfig.setValue('files_external', 'user_mounting_backends', user_mounting_backends.join());
|
||||||
|
OC.msg.finishedSaving('#userMountingMsg', {status: 'success', data: {message: t('settings', 'Saved')}});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -45,7 +45,7 @@ class OC_Mount_Config {
|
||||||
'datadir' => 'Location'));
|
'datadir' => 'Location'));
|
||||||
|
|
||||||
$backends['\OC\Files\Storage\AmazonS3']=array(
|
$backends['\OC\Files\Storage\AmazonS3']=array(
|
||||||
'backend' => 'Amazon S3',
|
'backend' => 'Amazon S3 and compliant',
|
||||||
'configuration' => array(
|
'configuration' => array(
|
||||||
'key' => 'Access Key',
|
'key' => 'Access Key',
|
||||||
'secret' => '*Secret Key',
|
'secret' => '*Secret Key',
|
||||||
|
@ -155,6 +155,35 @@ class OC_Mount_Config {
|
||||||
return($backends);
|
return($backends);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get details on each of the external storage backends, used for the mount config UI
|
||||||
|
* Some backends are not available as a personal backend, f.e. Local and such that have
|
||||||
|
* been disabled by the admin.
|
||||||
|
*
|
||||||
|
* If a custom UI is needed, add the key 'custom' and a javascript file with that name will be loaded
|
||||||
|
* If the configuration parameter should be secret, add a '*' to the beginning of the value
|
||||||
|
* If the configuration parameter is a boolean, add a '!' to the beginning of the value
|
||||||
|
* If the configuration parameter is optional, add a '&' to the beginning of the value
|
||||||
|
* If the configuration parameter is hidden, add a '#' to the beginning of the value
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getPersonalBackends() {
|
||||||
|
|
||||||
|
$backends = self::getBackends();
|
||||||
|
|
||||||
|
// Remove local storage and other disabled storages
|
||||||
|
unset($backends['\OC\Files\Storage\Local']);
|
||||||
|
|
||||||
|
$allowed_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''));
|
||||||
|
foreach ($backends as $backend => $null) {
|
||||||
|
if (!in_array($backend, $allowed_backends)) {
|
||||||
|
unset($backends[$backend]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $backends;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the system mount points
|
* Get the system mount points
|
||||||
* The returned array is not in the same format as getUserMountPoints()
|
* The returned array is not in the same format as getUserMountPoints()
|
||||||
|
@ -287,11 +316,12 @@ class OC_Mount_Config {
|
||||||
if (!isset($backends[$class])) {
|
if (!isset($backends[$class])) {
|
||||||
// invalid backend
|
// invalid backend
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($isPersonal) {
|
if ($isPersonal) {
|
||||||
// Verify that the mount point applies for the current user
|
// Verify that the mount point applies for the current user
|
||||||
// Prevent non-admin users from mounting local storage
|
// Prevent non-admin users from mounting local storage and other disabled backends
|
||||||
if ($applicable !== OCP\User::getUser() || strtolower($class) === '\oc\files\storage\local') {
|
$allowed_backends = self::getPersonalBackends();
|
||||||
|
if ($applicable != OCP\User::getUser() || !in_array($class, $allowed_backends)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/');
|
$mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/');
|
||||||
|
@ -359,7 +389,8 @@ class OC_Mount_Config {
|
||||||
$jsonFile = OC_User::getHome(OCP\User::getUser()).'/mount.json';
|
$jsonFile = OC_User::getHome(OCP\User::getUser()).'/mount.json';
|
||||||
} else {
|
} else {
|
||||||
$phpFile = OC::$SERVERROOT.'/config/mount.php';
|
$phpFile = OC::$SERVERROOT.'/config/mount.php';
|
||||||
$jsonFile = \OC_Config::getValue("mount_file", \OC::$SERVERROOT . "/data/mount.json");
|
$datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
|
||||||
|
$jsonFile = \OC_Config::getValue('mount_file', $datadir . '/mount.json');
|
||||||
}
|
}
|
||||||
if (is_file($jsonFile)) {
|
if (is_file($jsonFile)) {
|
||||||
$mountPoints = json_decode(file_get_contents($jsonFile), true);
|
$mountPoints = json_decode(file_get_contents($jsonFile), true);
|
||||||
|
@ -385,7 +416,8 @@ class OC_Mount_Config {
|
||||||
if ($isPersonal) {
|
if ($isPersonal) {
|
||||||
$file = OC_User::getHome(OCP\User::getUser()).'/mount.json';
|
$file = OC_User::getHome(OCP\User::getUser()).'/mount.json';
|
||||||
} else {
|
} else {
|
||||||
$file = \OC_Config::getValue("mount_file", \OC::$SERVERROOT . "/data/mount.json");
|
$datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
|
||||||
|
$file = \OC_Config::getValue('mount_file', $datadir . '/mount.json');
|
||||||
}
|
}
|
||||||
$content = json_encode($data);
|
$content = json_encode($data);
|
||||||
@file_put_contents($file, $content);
|
@file_put_contents($file, $content);
|
||||||
|
@ -444,7 +476,7 @@ class OC_Mount_Config {
|
||||||
*/
|
*/
|
||||||
public static function checksmbclient() {
|
public static function checksmbclient() {
|
||||||
if(function_exists('shell_exec')) {
|
if(function_exists('shell_exec')) {
|
||||||
$output=shell_exec('which smbclient 2> /dev/null');
|
$output=shell_exec('command -v smbclient 2> /dev/null');
|
||||||
return !empty($output);
|
return !empty($output);
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -22,9 +22,8 @@
|
||||||
|
|
||||||
OCP\Util::addScript('files_external', 'settings');
|
OCP\Util::addScript('files_external', 'settings');
|
||||||
OCP\Util::addStyle('files_external', 'settings');
|
OCP\Util::addStyle('files_external', 'settings');
|
||||||
$backends = OC_Mount_Config::getBackends();
|
$backends = OC_Mount_Config::getPersonalBackends();
|
||||||
// Remove local storage
|
|
||||||
unset($backends['\OC\Files\Storage\Local']);
|
|
||||||
$tmpl = new OCP\Template('files_external', 'settings');
|
$tmpl = new OCP\Template('files_external', 'settings');
|
||||||
$tmpl->assign('isAdminPage', false);
|
$tmpl->assign('isAdminPage', false);
|
||||||
$tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints());
|
$tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints());
|
||||||
|
|
|
@ -26,10 +26,26 @@ OCP\Util::addScript('files_external', 'settings');
|
||||||
OCP\Util::addscript('3rdparty', 'chosen/chosen.jquery.min');
|
OCP\Util::addscript('3rdparty', 'chosen/chosen.jquery.min');
|
||||||
OCP\Util::addStyle('files_external', 'settings');
|
OCP\Util::addStyle('files_external', 'settings');
|
||||||
OCP\Util::addStyle('3rdparty', 'chosen/chosen');
|
OCP\Util::addStyle('3rdparty', 'chosen/chosen');
|
||||||
|
|
||||||
|
$backends = OC_Mount_Config::getBackends();
|
||||||
|
$personal_backends = array();
|
||||||
|
$enabled_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''));
|
||||||
|
foreach ($backends as $class => $backend)
|
||||||
|
{
|
||||||
|
if ($class != '\OC\Files\Storage\Local')
|
||||||
|
{
|
||||||
|
$personal_backends[$class] = array(
|
||||||
|
'backend' => $backend['backend'],
|
||||||
|
'enabled' => in_array($class, $enabled_backends),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$tmpl = new OCP\Template('files_external', 'settings');
|
$tmpl = new OCP\Template('files_external', 'settings');
|
||||||
$tmpl->assign('isAdminPage', true);
|
$tmpl->assign('isAdminPage', true);
|
||||||
$tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints());
|
$tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints());
|
||||||
$tmpl->assign('backends', OC_Mount_Config::getBackends());
|
$tmpl->assign('backends', $backends);
|
||||||
|
$tmpl->assign('personal_backends', $personal_backends);
|
||||||
$tmpl->assign('groups', OC_Group::getGroups());
|
$tmpl->assign('groups', OC_Group::getGroups());
|
||||||
$tmpl->assign('users', OCP\User::getUsers());
|
$tmpl->assign('users', OCP\User::getUsers());
|
||||||
$tmpl->assign('userDisplayNames', OC_User::getDisplayNames());
|
$tmpl->assign('userDisplayNames', OC_User::getDisplayNames());
|
||||||
|
|
|
@ -122,12 +122,18 @@
|
||||||
|
|
||||||
<?php if ($_['isAdminPage']): ?>
|
<?php if ($_['isAdminPage']): ?>
|
||||||
<br />
|
<br />
|
||||||
<input type="checkbox"
|
<input type="checkbox" name="allowUserMounting" id="allowUserMounting"
|
||||||
name="allowUserMounting"
|
value="1" <?php if ($_['allowUserMounting'] == 'yes') print_unescaped(' checked="checked"'); ?> />
|
||||||
id="allowUserMounting"
|
<label for="allowUserMounting"><?php p($l->t('Enable User External Storage')); ?></label> <span id="userMountingMsg" class="msg"></span>
|
||||||
value="1" <?php if ($_['allowUserMounting'] == 'yes') print_unescaped(' checked="checked"'); ?> />
|
|
||||||
<label for="allowUserMounting"><?php p($l->t('Enable User External Storage')); ?></label><br/>
|
<p id="userMountingBackups"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>>
|
||||||
<em><?php p($l->t('Allow users to mount their own external storage')); ?></em>
|
<?php p($l->t('Allow users to mount the following external storage')); ?><br />
|
||||||
|
<?php $i = 0; foreach ($_['personal_backends'] as $class => $backend): ?>
|
||||||
|
<input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($class); ?>" <?php if ($backend['enabled']) print_unescaped(' checked="checked"'); ?> />
|
||||||
|
<label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend['backend']); ?></label> <br />
|
||||||
|
<?php $i++; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -5,6 +5,14 @@ $(document).ready(function() {
|
||||||
|
|
||||||
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !disableSharing) {
|
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !disableSharing) {
|
||||||
$('#fileList').on('fileActionsReady',function(){
|
$('#fileList').on('fileActionsReady',function(){
|
||||||
|
|
||||||
|
var allShared = $('#fileList').find('[data-share-owner]').find('[data-Action="Share"]');
|
||||||
|
allShared.addClass('permanent');
|
||||||
|
allShared.find('span').text(function(){
|
||||||
|
$owner = $(this).closest('tr').attr('data-share-owner');
|
||||||
|
return ' ' + t('files_sharing', 'Shared by {owner}', {owner: $owner});
|
||||||
|
});
|
||||||
|
|
||||||
if (!sharesLoaded){
|
if (!sharesLoaded){
|
||||||
OC.Share.loadIcons('file');
|
OC.Share.loadIcons('file');
|
||||||
// assume that we got all shares, so switching directories
|
// assume that we got all shares, so switching directories
|
||||||
|
@ -17,16 +25,15 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {
|
FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {
|
||||||
if ($('#dir').val() == '/') {
|
var dir = $('#dir').val();
|
||||||
var item = $('#dir').val() + filename;
|
var item = dir + '/' + filename;
|
||||||
} else {
|
if (dir == '/') {
|
||||||
var item = $('#dir').val() + '/' + filename;
|
item = dir + filename;
|
||||||
}
|
}
|
||||||
var tr = FileList.findFileEl(filename);
|
var tr = FileList.findFileEl(filename);
|
||||||
|
var itemType = 'file';
|
||||||
if ($(tr).data('type') == 'dir') {
|
if ($(tr).data('type') == 'dir') {
|
||||||
var itemType = 'folder';
|
itemType = 'folder';
|
||||||
} else {
|
|
||||||
var itemType = 'file';
|
|
||||||
}
|
}
|
||||||
var possiblePermissions = $(tr).data('permissions');
|
var possiblePermissions = $(tr).data('permissions');
|
||||||
var appendTo = $(tr).find('td.filename');
|
var appendTo = $(tr).find('td.filename');
|
||||||
|
|
|
@ -172,12 +172,12 @@ class Api {
|
||||||
// workaround because folders are named 'dir' in this context
|
// workaround because folders are named 'dir' in this context
|
||||||
$itemType = $file['type'] === 'file' ? 'file' : 'folder';
|
$itemType = $file['type'] === 'file' ? 'file' : 'folder';
|
||||||
$share = \OCP\Share::getItemShared($itemType, $file['fileid']);
|
$share = \OCP\Share::getItemShared($itemType, $file['fileid']);
|
||||||
$receivedFrom = \OCP\Share::getItemSharedWithBySource($itemType, $file['fileid']);
|
if($share) {
|
||||||
if ($receivedFrom) {
|
$receivedFrom = \OCP\Share::getItemSharedWithBySource($itemType, $file['fileid']);
|
||||||
$share['received_from'] = $receivedFrom['uid_owner'];
|
if ($receivedFrom) {
|
||||||
$share['received_from_displayname'] = \OCP\User::getDisplayName($receivedFrom['uid_owner']);
|
$share['received_from'] = $receivedFrom['uid_owner'];
|
||||||
}
|
$share['received_from_displayname'] = \OCP\User::getDisplayName($receivedFrom['uid_owner']);
|
||||||
if ($share) {
|
}
|
||||||
$result = array_merge($result, $share);
|
$result = array_merge($result, $share);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,9 +137,12 @@ class Shared_Cache extends Cache {
|
||||||
} else {
|
} else {
|
||||||
$cache = $this->getSourceCache($folder);
|
$cache = $this->getSourceCache($folder);
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
|
$parent = $this->storage->getFile($folder);
|
||||||
$sourceFolderContent = $cache->getFolderContents($this->files[$folder]);
|
$sourceFolderContent = $cache->getFolderContents($this->files[$folder]);
|
||||||
foreach ($sourceFolderContent as $key => $c) {
|
foreach ($sourceFolderContent as $key => $c) {
|
||||||
$sourceFolderContent[$key]['usersPath'] = 'files/Shared/' . $folder . '/' . $c['name'];
|
$sourceFolderContent[$key]['usersPath'] = 'files/Shared/' . $folder . '/' . $c['name'];
|
||||||
|
$sourceFolderContent[$key]['uid_owner'] = $parent['uid_owner'];
|
||||||
|
$sourceFolderContent[$key]['displayname_owner'] = $parent['uid_owner'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sourceFolderContent;
|
return $sourceFolderContent;
|
||||||
|
|
|
@ -94,6 +94,9 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
|
||||||
$file['mtime'] = $item['mtime'];
|
$file['mtime'] = $item['mtime'];
|
||||||
$file['encrypted'] = $item['encrypted'];
|
$file['encrypted'] = $item['encrypted'];
|
||||||
$file['etag'] = $item['etag'];
|
$file['etag'] = $item['etag'];
|
||||||
|
$file['uid_owner'] = $item['uid_owner'];
|
||||||
|
$file['displayname_owner'] = $item['displayname_owner'];
|
||||||
|
|
||||||
$storage = \OC\Files\Filesystem::getStorage('/');
|
$storage = \OC\Files\Filesystem::getStorage('/');
|
||||||
$cache = $storage->getCache();
|
$cache = $storage->getCache();
|
||||||
if ($item['encrypted'] or ($item['unencrypted_size'] > 0 and $cache->getMimetype($item['mimetype']) === 'httpd/unix-directory')) {
|
if ($item['encrypted'] or ($item['unencrypted_size'] > 0 and $cache->getMimetype($item['mimetype']) === 'httpd/unix-directory')) {
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<p class="infield">
|
<p class="infield">
|
||||||
<label for="password" class="infield"><?php p($l->t('Password')); ?></label>
|
<label for="password" class="infield"><?php p($l->t('Password')); ?></label>
|
||||||
<input type="password" name="password" id="password" placeholder="" value="" autofocus />
|
<input type="password" name="password" id="password"
|
||||||
|
placeholder="" value=""
|
||||||
|
autocomplete="off" autocapitalize="off" autocorrect="off"
|
||||||
|
autofocus />
|
||||||
<input type="submit" value="" class="svg icon icon-confirm" />
|
<input type="submit" value="" class="svg icon icon-confirm" />
|
||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
@ -33,13 +33,16 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->folder = '/folder_share_api_test';
|
$this->folder = '/folder_share_api_test';
|
||||||
|
$this->subfolder = '/subfolder_share_api_test';
|
||||||
|
|
||||||
$this->filename = 'share-api-test.txt';
|
$this->filename = 'share-api-test.txt';
|
||||||
|
|
||||||
// save file with content
|
// save file with content
|
||||||
$this->view->file_put_contents($this->filename, $this->data);
|
$this->view->file_put_contents($this->filename, $this->data);
|
||||||
$this->view->mkdir($this->folder);
|
$this->view->mkdir($this->folder);
|
||||||
|
$this->view->mkdir($this->folder . '/' . $this->subfolder);
|
||||||
$this->view->file_put_contents($this->folder.'/'.$this->filename, $this->data);
|
$this->view->file_put_contents($this->folder.'/'.$this->filename, $this->data);
|
||||||
|
$this->view->file_put_contents($this->folder.'/' . $this->subfolder . '/' .$this->filename, $this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
@ -286,6 +289,71 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief share a folder, than reshare a file within the shared folder and check if we construct the correct path
|
||||||
|
* @medium
|
||||||
|
*/
|
||||||
|
function testGetShareFromFolderReshares() {
|
||||||
|
|
||||||
|
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
|
||||||
|
|
||||||
|
$fileInfo1 = $this->view->getFileInfo($this->folder);
|
||||||
|
$fileInfo2 = $this->view->getFileInfo($this->folder.'/'.$this->filename);
|
||||||
|
$fileInfo3 = $this->view->getFileInfo($this->folder.'/' . $this->subfolder . '/' .$this->filename);
|
||||||
|
|
||||||
|
// share root folder to user2
|
||||||
|
$result = \OCP\Share::shareItem('folder', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER,
|
||||||
|
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
|
||||||
|
|
||||||
|
// share was successful?
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
// login as user2
|
||||||
|
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
|
||||||
|
|
||||||
|
// share file in root folder
|
||||||
|
$result = \OCP\Share::shareItem('file', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_LINK, null, 1);
|
||||||
|
// share was successful?
|
||||||
|
$this->assertTrue(is_string($result));
|
||||||
|
|
||||||
|
// share file in subfolder
|
||||||
|
$result = \OCP\Share::shareItem('file', $fileInfo3['fileid'], \OCP\Share::SHARE_TYPE_LINK, null, 1);
|
||||||
|
// share was successful?
|
||||||
|
$this->assertTrue(is_string($result));
|
||||||
|
|
||||||
|
$testValues=array(
|
||||||
|
array('query' => 'Shared/' . $this->folder,
|
||||||
|
'expectedResult' => '/Shared' . $this->folder . '/' . $this->filename),
|
||||||
|
array('query' => 'Shared/' . $this->folder . $this->subfolder,
|
||||||
|
'expectedResult' => '/Shared' . $this->folder . $this->subfolder . '/' . $this->filename),
|
||||||
|
);
|
||||||
|
foreach ($testValues as $value) {
|
||||||
|
|
||||||
|
$_GET['path'] = $value['query'];
|
||||||
|
$_GET['subfiles'] = 'true';
|
||||||
|
|
||||||
|
$result = Share\Api::getAllShares(array());
|
||||||
|
|
||||||
|
$this->assertTrue($result->succeeded());
|
||||||
|
|
||||||
|
// test should return one share within $this->folder
|
||||||
|
$data = $result->getData();
|
||||||
|
|
||||||
|
$this->assertEquals($value['expectedResult'], $data[0]['path']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
|
||||||
|
\OCP\Share::unshare('file', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_LINK, null);
|
||||||
|
\OCP\Share::unshare('file', $fileInfo3['fileid'], \OCP\Share::SHARE_TYPE_LINK, null);
|
||||||
|
|
||||||
|
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
|
||||||
|
|
||||||
|
\OCP\Share::unshare('folder', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER,
|
||||||
|
\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @medium
|
* @medium
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,6 +43,7 @@ abstract class Test_Files_Sharing_Base extends \PHPUnit_Framework_TestCase {
|
||||||
*/
|
*/
|
||||||
public $view;
|
public $view;
|
||||||
public $folder;
|
public $folder;
|
||||||
|
public $subfolder;
|
||||||
|
|
||||||
public static function setUpBeforeClass() {
|
public static function setUpBeforeClass() {
|
||||||
// reset backend
|
// reset backend
|
||||||
|
|
|
@ -120,7 +120,7 @@ class Helper {
|
||||||
|
|
||||||
$saveOtherConfigurations = '';
|
$saveOtherConfigurations = '';
|
||||||
if(empty($prefix)) {
|
if(empty($prefix)) {
|
||||||
$saveOtherConfigurations = 'AND `Configkey` NOT LIKE \'s%\'';
|
$saveOtherConfigurations = 'AND `configkey` NOT LIKE \'s%\'';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = \OCP\DB::prepare('
|
$query = \OCP\DB::prepare('
|
||||||
|
|
|
@ -54,11 +54,15 @@ class User_Proxy extends lib\Proxy implements \OCP\UserInterface {
|
||||||
protected function walkBackends($uid, $method, $parameters) {
|
protected function walkBackends($uid, $method, $parameters) {
|
||||||
$cacheKey = $this->getUserCacheKey($uid);
|
$cacheKey = $this->getUserCacheKey($uid);
|
||||||
foreach($this->backends as $configPrefix => $backend) {
|
foreach($this->backends as $configPrefix => $backend) {
|
||||||
// print("walkBackend '$configPrefix'<br/>");
|
$instance = $backend;
|
||||||
if($result = call_user_func_array(array($backend, $method), $parameters)) {
|
if(!method_exists($instance, $method)
|
||||||
|
&& method_exists($this->getAccess($configPrefix), $method)) {
|
||||||
|
$instance = $this->getAccess($configPrefix);
|
||||||
|
}
|
||||||
|
if($result = call_user_func_array(array($instance, $method), $parameters)) {
|
||||||
$this->writeToCache($cacheKey, $configPrefix);
|
$this->writeToCache($cacheKey, $configPrefix);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +81,12 @@ class User_Proxy extends lib\Proxy implements \OCP\UserInterface {
|
||||||
//in case the uid has been found in the past, try this stored connection first
|
//in case the uid has been found in the past, try this stored connection first
|
||||||
if(!is_null($prefix)) {
|
if(!is_null($prefix)) {
|
||||||
if(isset($this->backends[$prefix])) {
|
if(isset($this->backends[$prefix])) {
|
||||||
$result = call_user_func_array(array($this->backends[$prefix], $method), $parameters);
|
$instance = $this->backends[$prefix];
|
||||||
|
if(!method_exists($instance, $method)
|
||||||
|
&& method_exists($this->getAccess($prefix), $method)) {
|
||||||
|
$instance = $this->getAccess($prefix);
|
||||||
|
}
|
||||||
|
$result = call_user_func_array(array($instance, $method), $parameters);
|
||||||
if($result === $passOnWhen) {
|
if($result === $passOnWhen) {
|
||||||
//not found here, reset cache to null if user vanished
|
//not found here, reset cache to null if user vanished
|
||||||
//because sometimes methods return false with a reason
|
//because sometimes methods return false with a reason
|
||||||
|
|
|
@ -178,6 +178,9 @@ $CONFIG = array(
|
||||||
/* Enable or disable the logging of IP addresses in case of webform auth failures */
|
/* Enable or disable the logging of IP addresses in case of webform auth failures */
|
||||||
"log_authfailip" => false,
|
"log_authfailip" => false,
|
||||||
|
|
||||||
|
/* Whether http-basic username must equal username to login */
|
||||||
|
"basic_auth" => true,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure the size in bytes log rotation should happen, 0 or false disables the rotation.
|
* Configure the size in bytes log rotation should happen, 0 or false disables the rotation.
|
||||||
* This rotates the current owncloud logfile to a new name, this way the total log usage
|
* This rotates the current owncloud logfile to a new name, this way the total log usage
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.icon {
|
[class^="icon-"], [class*=" icon-"] {
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,8 @@
|
||||||
.icon-delete {
|
.icon-delete {
|
||||||
background-image: url('../img/actions/delete.svg');
|
background-image: url('../img/actions/delete.svg');
|
||||||
}
|
}
|
||||||
.icon-delete-hover {
|
.icon-delete:hover,
|
||||||
|
.icon-delete:focus {
|
||||||
background-image: url('../img/actions/delete-hover.svg');
|
background-image: url('../img/actions/delete-hover.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,11 +156,15 @@
|
||||||
background-image: url('../img/actions/sound-off.svg');
|
background-image: url('../img/actions/sound-off.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-star {
|
.icon-star,
|
||||||
|
.icon-starred:hover,
|
||||||
|
.icon-starred:focus {
|
||||||
background-image: url('../img/actions/star.svg');
|
background-image: url('../img/actions/star.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-starred {
|
.icon-starred,
|
||||||
|
.icon-star:hover,
|
||||||
|
.icon-star:focus {
|
||||||
background-image: url('../img/actions/starred.svg');
|
background-image: url('../img/actions/starred.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,7 @@ button, .button,
|
||||||
border: 1px solid rgba(190,190,190,.9);
|
border: 1px solid rgba(190,190,190,.9);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
outline: none;
|
||||||
}
|
}
|
||||||
input[type="submit"]:hover, input[type="submit"]:focus,
|
input[type="submit"]:hover, input[type="submit"]:focus,
|
||||||
input[type="button"]:hover, input[type="button"]:focus,
|
input[type="button"]:hover, input[type="button"]:focus,
|
||||||
|
@ -204,18 +205,18 @@ textarea:disabled {
|
||||||
/* Primary action button, use sparingly */
|
/* Primary action button, use sparingly */
|
||||||
.primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary {
|
.primary, input[type="submit"].primary, input[type="button"].primary, button.primary, .button.primary {
|
||||||
border: 1px solid #1d2d44;
|
border: 1px solid #1d2d44;
|
||||||
background: #35537a;
|
background-color: #35537a;
|
||||||
color: #ddd;
|
color: #ddd;
|
||||||
}
|
}
|
||||||
.primary:hover, input[type="submit"].primary:hover, input[type="button"].primary:hover, button.primary:hover, .button.primary:hover,
|
.primary:hover, input[type="submit"].primary:hover, input[type="button"].primary:hover, button.primary:hover, .button.primary:hover,
|
||||||
.primary:focus, input[type="submit"].primary:focus, input[type="button"].primary:focus, button.primary:focus, .button.primary:focus {
|
.primary:focus, input[type="submit"].primary:focus, input[type="button"].primary:focus, button.primary:focus, .button.primary:focus {
|
||||||
border: 1px solid #1d2d44;
|
border: 1px solid #1d2d44;
|
||||||
background: #304d76;
|
background-color: #304d76;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active {
|
.primary:active, input[type="submit"].primary:active, input[type="button"].primary:active, button.primary:active, .button.primary:active {
|
||||||
border: 1px solid #1d2d44;
|
border: 1px solid #1d2d44;
|
||||||
background: #1d2d44;
|
background-color: #1d2d44;
|
||||||
color: #bbb;
|
color: #bbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +234,7 @@ textarea:disabled {
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="submit"].enabled {
|
input[type="submit"].enabled {
|
||||||
background: #66f866;
|
background-color: #66f866;
|
||||||
border: 1px solid #5e5;
|
border: 1px solid #5e5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,11 +406,9 @@ input[name="adminpass-clone"] { padding-left:1.8em; width:11.7em !important; }
|
||||||
/* General new input field look */
|
/* General new input field look */
|
||||||
#body-login input[type="text"],
|
#body-login input[type="text"],
|
||||||
#body-login input[type="password"],
|
#body-login input[type="password"],
|
||||||
#body-login input[type="email"] {
|
#body-login input[type="email"],
|
||||||
border: 1px solid #323233;
|
#body-login input[type="submit"] {
|
||||||
border-radius: 5px;
|
border: none;
|
||||||
}
|
|
||||||
#body-login input[type='submit'] {
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.2 KiB |
|
@ -61,8 +61,10 @@ $array = array(
|
||||||
"firstDay" => json_encode($l->l('firstday', 'firstday')) ,
|
"firstDay" => json_encode($l->l('firstday', 'firstday')) ,
|
||||||
"oc_config" => json_encode(
|
"oc_config" => json_encode(
|
||||||
array(
|
array(
|
||||||
'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')),
|
'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')),
|
||||||
'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true)
|
'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true),
|
||||||
|
'version' => implode('.', OC_Util::getVersion()),
|
||||||
|
'versionstring' => OC_Util::getVersionString(),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
"oc_defaults" => json_encode(
|
"oc_defaults" => json_encode(
|
||||||
|
|
|
@ -467,6 +467,34 @@ OC.search.lastResults={};
|
||||||
OC.addStyle.loaded=[];
|
OC.addStyle.loaded=[];
|
||||||
OC.addScript.loaded=[];
|
OC.addScript.loaded=[];
|
||||||
|
|
||||||
|
OC.msg={
|
||||||
|
startSaving:function(selector){
|
||||||
|
OC.msg.startAction(selector, t('core', 'Saving...'));
|
||||||
|
},
|
||||||
|
finishedSaving:function(selector, data){
|
||||||
|
OC.msg.finishedAction(selector, data);
|
||||||
|
},
|
||||||
|
startAction:function(selector, message){
|
||||||
|
$(selector)
|
||||||
|
.html( message )
|
||||||
|
.removeClass('success')
|
||||||
|
.removeClass('error')
|
||||||
|
.stop(true, true)
|
||||||
|
.show();
|
||||||
|
},
|
||||||
|
finishedAction:function(selector, data){
|
||||||
|
if( data.status === "success" ){
|
||||||
|
$(selector).html( data.data.message )
|
||||||
|
.addClass('success')
|
||||||
|
.stop(true, true)
|
||||||
|
.delay(3000)
|
||||||
|
.fadeOut(900);
|
||||||
|
}else{
|
||||||
|
$(selector).html( data.data.message ).addClass('error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
OC.Notification={
|
OC.Notification={
|
||||||
queuedNotifications: [],
|
queuedNotifications: [],
|
||||||
getDefaultNotificationFunction: null,
|
getDefaultNotificationFunction: null,
|
||||||
|
|
|
@ -32,37 +32,37 @@ OC.Router = {
|
||||||
var optional = true;
|
var optional = true;
|
||||||
$(route.tokens).each(function(i, token) {
|
$(route.tokens).each(function(i, token) {
|
||||||
if ('text' === token[0]) {
|
if ('text' === token[0]) {
|
||||||
url = token[1] + url;
|
url = token[1] + url;
|
||||||
optional = false;
|
optional = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('variable' === token[0]) {
|
if ('variable' === token[0]) {
|
||||||
if (false === optional || !(token[3] in route.defaults)
|
if (false === optional || !(token[3] in route.defaults)
|
||||||
|| ((token[3] in params) && params[token[3]] != route.defaults[token[3]])) {
|
|| ((token[3] in params) && params[token[3]] != route.defaults[token[3]])) {
|
||||||
var value;
|
var value;
|
||||||
if (token[3] in params) {
|
if (token[3] in params) {
|
||||||
value = params[token[3]];
|
value = params[token[3]];
|
||||||
delete unusedParams[token[3]];
|
delete unusedParams[token[3]];
|
||||||
} else if (token[3] in route.defaults) {
|
} else if (token[3] in route.defaults) {
|
||||||
value = route.defaults[token[3]];
|
value = route.defaults[token[3]];
|
||||||
} else if (optional) {
|
} else if (optional) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('The route "' + name + '" requires the parameter "' + token[3] + '".');
|
throw new Error('The route "' + name + '" requires the parameter "' + token[3] + '".');
|
||||||
}
|
}
|
||||||
|
|
||||||
var empty = true === value || false === value || '' === value;
|
var empty = true === value || false === value || '' === value;
|
||||||
|
|
||||||
if (!empty || !optional) {
|
if (!empty || !optional) {
|
||||||
url = token[1] + encodeURIComponent(value).replace(/%2F/g, '/') + url;
|
url = token[1] + encodeURIComponent(value).replace(/%2F/g, '/') + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
optional = false;
|
optional = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error('The token type "' + token[0] + '" is not supported.');
|
throw new Error('The token type "' + token[0] + '" is not supported.');
|
||||||
|
|
|
@ -36,6 +36,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$('#showAdvanced').click(function() {
|
$('#showAdvanced').click(function() {
|
||||||
$('#datadirContent').slideToggle(250);
|
$('#datadirContent').slideToggle(250);
|
||||||
|
$('#databaseBackend').slideToggle(250);
|
||||||
$('#databaseField').slideToggle(250);
|
$('#databaseField').slideToggle(250);
|
||||||
});
|
});
|
||||||
$("form").submit(function(){
|
$("form").submit(function(){
|
||||||
|
@ -73,6 +74,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
if (currentDbType === 'sqlite' || (dbtypes.sqlite && currentDbType === undefined)){
|
if (currentDbType === 'sqlite' || (dbtypes.sqlite && currentDbType === undefined)){
|
||||||
$('#datadirContent').hide(250);
|
$('#datadirContent').hide(250);
|
||||||
|
$('#databaseBackend').hide(250);
|
||||||
$('#databaseField').hide(250);
|
$('#databaseField').hide(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -584,8 +584,8 @@ $(document).ready(function() {
|
||||||
$(checkboxes).filter('input[name="edit"]').attr('checked', false);
|
$(checkboxes).filter('input[name="edit"]').attr('checked', false);
|
||||||
// Check Edit if Create, Update, or Delete is checked
|
// Check Edit if Create, Update, or Delete is checked
|
||||||
} else if (($(this).attr('name') == 'create'
|
} else if (($(this).attr('name') == 'create'
|
||||||
|| $(this).attr('name') == 'update'
|
|| $(this).attr('name') == 'update'
|
||||||
|| $(this).attr('name') == 'delete'))
|
|| $(this).attr('name') == 'delete'))
|
||||||
{
|
{
|
||||||
$(checkboxes).filter('input[name="edit"]').attr('checked', true);
|
$(checkboxes).filter('input[name="edit"]').attr('checked', true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Controller {
|
||||||
$defaults = new \OC_Defaults();
|
$defaults = new \OC_Defaults();
|
||||||
\OC_Mail::send($email, $_POST['user'], $l->t('%s password reset', array($defaults->getName())), $msg, $from, $defaults->getName());
|
\OC_Mail::send($email, $_POST['user'], $l->t('%s password reset', array($defaults->getName())), $msg, $from, $defaults->getName());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
\OC_Template::printErrorPage( 'A problem occurs during sending the e-mail please contact your administrator.');
|
\OC_Template::printErrorPage( $l->t('A problem has occurred whilst sending the email, please contact your administrator.') );
|
||||||
}
|
}
|
||||||
self::displayLostPasswordPage(false, true);
|
self::displayLostPasswordPage(false, true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
|
|
||||||
<?php if(!$_['directoryIsSet'] OR !$_['dbIsSet'] OR count($_['errors']) > 0): ?>
|
<?php if(!$_['directoryIsSet'] OR !$_['dbIsSet'] OR count($_['errors']) > 0): ?>
|
||||||
<fieldset id="advancedHeader">
|
<fieldset id="advancedHeader">
|
||||||
<legend><a id="showAdvanced"><?php p($l->t( 'Advanced' )); ?> <img class="svg" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a></legend>
|
<legend><a id="showAdvanced"><?php p($l->t( 'Storage & database' )); ?> <img class="svg" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a></legend>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if(!$_['dbIsSet'] OR count($_['errors']) > 0): ?>
|
<?php if(!$_['dbIsSet'] OR count($_['errors']) > 0): ?>
|
||||||
<fieldset id='databaseField'>
|
<fieldset id='databaseBackend'>
|
||||||
<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'] or $_['hasMSSQL'])
|
<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'] or $_['hasMSSQL'])
|
||||||
$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite ?>
|
$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite ?>
|
||||||
<legend><?php p($l->t( 'Configure the database' )); ?></legend>
|
<legend><?php p($l->t( 'Configure the database' )); ?></legend>
|
||||||
|
@ -100,8 +100,10 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<?php if($hasOtherDB): ?>
|
<?php if($hasOtherDB): ?>
|
||||||
|
<fieldset id='databaseField'>
|
||||||
<div id="use_other_db">
|
<div id="use_other_db">
|
||||||
<p class="infield grouptop">
|
<p class="infield grouptop">
|
||||||
<label for="dbuser" class="infield"><?php p($l->t( 'Database user' )); ?></label>
|
<label for="dbuser" class="infield"><?php p($l->t( 'Database user' )); ?></label>
|
||||||
|
@ -141,8 +143,8 @@
|
||||||
autocomplete="off" autocapitalize="off" autocorrect="off" />
|
autocomplete="off" autocapitalize="off" autocorrect="off" />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
</fieldset>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</fieldset>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="buttons"><input type="submit" class="primary" value="<?php p($l->t( 'Finish setup' )); ?>" data-finishing="<?php p($l->t( 'Finishing …' )); ?>" /></div>
|
<div class="buttons"><input type="submit" class="primary" value="<?php p($l->t( 'Finish setup' )); ?>" data-finishing="<?php p($l->t( 'Finishing …' )); ?>" /></div>
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<table cellspacing="0" cellpadding="0" border="0" width="600px">
|
<table cellspacing="0" cellpadding="0" border="0" width="600px">
|
||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#1d2d44" width="20px"> </td>
|
<td bgcolor="<?php p($theme->getMailHeaderColor());?>" width="20px"> </td>
|
||||||
<td bgcolor="#1d2d44">
|
<td bgcolor="<?php p($theme->getMailHeaderColor());?>">
|
||||||
<img src="<?php print_unescaped(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/>
|
<img src="<?php p(OC_Helper::makeURLAbsolute(image_path('', 'logo-mail.gif'))); ?>" alt="<?php p($theme->getName()); ?>"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td bgcolor="#f8f8f8" colspan="2"> </td></tr>
|
<tr><td colspan="2"> </td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#f8f8f8" width="20px"> </td>
|
<td width="20px"> </td>
|
||||||
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
|
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
|
||||||
<?php
|
<?php
|
||||||
print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared <strong>%s</strong> with you.<br><a href="%s">View it!</a><br><br>', array($_['user_displayname'], $_['filename'], $_['link'])));
|
print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared <strong>%s</strong> with you.<br><a href="%s">View it!</a><br><br>', array($_['user_displayname'], $_['filename'], $_['link'])));
|
||||||
if ( isset($_['expiration']) ) {
|
if ( isset($_['expiration']) ) {
|
||||||
|
@ -21,17 +21,17 @@ p($l->t('Cheers!'));
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td bgcolor="#f8f8f8" colspan="2"> </td></tr>
|
<tr><td colspan="2"> </td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#f8f8f8" width="20px"> </td>
|
<td width="20px"> </td>
|
||||||
<td bgcolor="#f8f8f8" style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
|
<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
|
||||||
<?php p($theme->getName()); ?> -
|
<?php p($theme->getName()); ?> -
|
||||||
<?php p($theme->getSlogan()); ?>
|
<?php p($theme->getSlogan()); ?>
|
||||||
<br><a href="<?php print_unescaped($theme->getBaseUrl()); ?>"><?php print_unescaped($theme->getBaseUrl());?></a>
|
<br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl());?></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td bgcolor="#f8f8f8" colspan="2"> </td>
|
<td colspan="2"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
|
@ -554,7 +554,8 @@ class OC {
|
||||||
OC_User::useBackend(new OC_User_Database());
|
OC_User::useBackend(new OC_User_Database());
|
||||||
OC_Group::useBackend(new OC_Group_Database());
|
OC_Group::useBackend(new OC_Group_Database());
|
||||||
|
|
||||||
if (isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('loginname')
|
$basic_auth = OC_Config::getValue('basic_auth', true);
|
||||||
|
if ($basic_auth && isset($_SERVER['PHP_AUTH_USER']) && self::$session->exists('loginname')
|
||||||
&& $_SERVER['PHP_AUTH_USER'] !== self::$session->get('loginname')) {
|
&& $_SERVER['PHP_AUTH_USER'] !== self::$session->get('loginname')) {
|
||||||
$sessionUser = self::$session->get('loginname');
|
$sessionUser = self::$session->get('loginname');
|
||||||
$serverUser = $_SERVER['PHP_AUTH_USER'];
|
$serverUser = $_SERVER['PHP_AUTH_USER'];
|
||||||
|
@ -752,7 +753,8 @@ class OC {
|
||||||
OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
|
OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
|
||||||
}
|
}
|
||||||
OC_User::logout();
|
OC_User::logout();
|
||||||
header("Location: " . OC::$WEBROOT . '/');
|
// redirect to webroot and add slash if webroot is empty
|
||||||
|
header("Location: " . OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : ''));
|
||||||
} else {
|
} else {
|
||||||
if (is_null($file)) {
|
if (is_null($file)) {
|
||||||
$param['file'] = 'index.php';
|
$param['file'] = 'index.php';
|
||||||
|
|
|
@ -219,6 +219,8 @@ class OC_App{
|
||||||
$appdata=OC_OCSClient::getApplication($app);
|
$appdata=OC_OCSClient::getApplication($app);
|
||||||
$download=OC_OCSClient::getApplicationDownload($app, 1);
|
$download=OC_OCSClient::getApplicationDownload($app, 1);
|
||||||
if(isset($download['downloadlink']) and $download['downloadlink']!='') {
|
if(isset($download['downloadlink']) and $download['downloadlink']!='') {
|
||||||
|
// Replace spaces in download link without encoding entire URL
|
||||||
|
$download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']);
|
||||||
$info = array('source'=>'http', 'href'=>$download['downloadlink'], 'appdata'=>$appdata);
|
$info = array('source'=>'http', 'href'=>$download['downloadlink'], 'appdata'=>$appdata);
|
||||||
$app=OC_Installer::installApp($info);
|
$app=OC_Installer::installApp($info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Config {
|
||||||
/**
|
/**
|
||||||
* @brief Gets a value from config.php
|
* @brief Gets a value from config.php
|
||||||
* @param string $key key
|
* @param string $key key
|
||||||
* @param string|null $default = null default value
|
* @param array|bool|string|null $default = null default value
|
||||||
* @return string the value or $default
|
* @return string the value or $default
|
||||||
*
|
*
|
||||||
* This function gets the value from config.php. If it does not exist,
|
* This function gets the value from config.php. If it does not exist,
|
||||||
|
|
|
@ -50,7 +50,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
|
||||||
*/
|
*/
|
||||||
public function createFile($name, $data = null) {
|
public function createFile($name, $data = null) {
|
||||||
|
|
||||||
if ($name === 'Shared' && empty($this->path)) {
|
if (strtolower($name) === 'shared' && empty($this->path)) {
|
||||||
throw new \Sabre_DAV_Exception_Forbidden();
|
throw new \Sabre_DAV_Exception_Forbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
|
||||||
*/
|
*/
|
||||||
public function createDirectory($name) {
|
public function createDirectory($name) {
|
||||||
|
|
||||||
if ($name === 'Shared' && empty($this->path)) {
|
if (strtolower($name) === 'shared' && empty($this->path)) {
|
||||||
throw new \Sabre_DAV_Exception_Forbidden();
|
throw new \Sabre_DAV_Exception_Forbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
|
||||||
}
|
}
|
||||||
if ($sourceDir !== $destinationDir) {
|
if ($sourceDir !== $destinationDir) {
|
||||||
// for a full move we need update privileges on sourcePath and sourceDir as well as destinationDir
|
// for a full move we need update privileges on sourcePath and sourceDir as well as destinationDir
|
||||||
|
if (ltrim($destinationDir, '/') === '' && strtolower($sourceNode->getName()) === 'shared') {
|
||||||
|
throw new \Sabre_DAV_Exception_Forbidden();
|
||||||
|
}
|
||||||
if (!$this->fileView->isUpdatable($sourceDir)) {
|
if (!$this->fileView->isUpdatable($sourceDir)) {
|
||||||
throw new \Sabre_DAV_Exception_Forbidden();
|
throw new \Sabre_DAV_Exception_Forbidden();
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,9 @@ class MDB2SchemaManager {
|
||||||
$platform = $this->conn->getDatabasePlatform();
|
$platform = $this->conn->getDatabasePlatform();
|
||||||
foreach($schemaDiff->changedTables as $tableDiff) {
|
foreach($schemaDiff->changedTables as $tableDiff) {
|
||||||
$tableDiff->name = $platform->quoteIdentifier($tableDiff->name);
|
$tableDiff->name = $platform->quoteIdentifier($tableDiff->name);
|
||||||
|
foreach($tableDiff->changedColumns as $column) {
|
||||||
|
$column->oldColumnName = $platform->quoteIdentifier($column->oldColumnName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($generateSql) {
|
if ($generateSql) {
|
||||||
|
|
|
@ -41,7 +41,9 @@ class MDB2SchemaReader {
|
||||||
*/
|
*/
|
||||||
public function loadSchemaFromFile($file) {
|
public function loadSchemaFromFile($file) {
|
||||||
$schema = new \Doctrine\DBAL\Schema\Schema();
|
$schema = new \Doctrine\DBAL\Schema\Schema();
|
||||||
|
$loadEntities = libxml_disable_entity_loader(false);
|
||||||
$xml = simplexml_load_file($file);
|
$xml = simplexml_load_file($file);
|
||||||
|
libxml_disable_entity_loader($loadEntities);
|
||||||
foreach ($xml->children() as $child) {
|
foreach ($xml->children() as $child) {
|
||||||
/**
|
/**
|
||||||
* @var \SimpleXMLElement $child
|
* @var \SimpleXMLElement $child
|
||||||
|
|
|
@ -21,6 +21,7 @@ class OC_Defaults {
|
||||||
private $defaultDocBaseUrl;
|
private $defaultDocBaseUrl;
|
||||||
private $defaultSlogan;
|
private $defaultSlogan;
|
||||||
private $defaultLogoClaim;
|
private $defaultLogoClaim;
|
||||||
|
private $defaultMailHeaderColor;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$this->l = OC_L10N::get('core');
|
$this->l = OC_L10N::get('core');
|
||||||
|
@ -33,6 +34,7 @@ class OC_Defaults {
|
||||||
$this->defaultDocBaseUrl = "http://doc.owncloud.org";
|
$this->defaultDocBaseUrl = "http://doc.owncloud.org";
|
||||||
$this->defaultSlogan = $this->l->t("web services under your control");
|
$this->defaultSlogan = $this->l->t("web services under your control");
|
||||||
$this->defaultLogoClaim = "";
|
$this->defaultLogoClaim = "";
|
||||||
|
$this->defaultMailHeaderColor = "#1d2d44"; /* header color of mail notifications */
|
||||||
|
|
||||||
if (class_exists("OC_Theme")) {
|
if (class_exists("OC_Theme")) {
|
||||||
$this->theme = new OC_Theme();
|
$this->theme = new OC_Theme();
|
||||||
|
@ -174,4 +176,23 @@ class OC_Defaults {
|
||||||
return $footer;
|
return $footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function buildDocLinkToKey($key) {
|
||||||
|
if ($this->themeExist('buildDocLinkToKey')) {
|
||||||
|
return $this->theme->buildDocLinkToKey($key);
|
||||||
|
}
|
||||||
|
return $this->getDocBaseUrl() . '/server/6.0/go.php?to=' . $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns mail header color
|
||||||
|
* @return mail header color
|
||||||
|
*/
|
||||||
|
public function getMailHeaderColor() {
|
||||||
|
if ($this->themeExist('getMailHeaderColor')) {
|
||||||
|
return $this->theme->getMailHeaderColor();
|
||||||
|
} else {
|
||||||
|
return $this->defaultMailHeaderColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,22 +21,39 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: get rid of this using proper composer packages
|
||||||
|
require_once 'mcnetic/phpzipstreamer/ZipStreamer.php';
|
||||||
|
|
||||||
|
class GET_TYPE {
|
||||||
|
const FILE = 1;
|
||||||
|
const ZIP_FILES = 2;
|
||||||
|
const ZIP_DIR = 3;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for fileserver access
|
* Class for file server access
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class OC_Files {
|
class OC_Files {
|
||||||
static $tmpFiles = array();
|
|
||||||
|
|
||||||
static public function getFileInfo($path, $includeMountPoints = true){
|
|
||||||
return \OC\Files\Filesystem::getFileInfo($path, $includeMountPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $path
|
* @param string $filename
|
||||||
|
* @param string $name
|
||||||
|
* @param bool $zip
|
||||||
*/
|
*/
|
||||||
static public function getDirectoryContent($path){
|
private static function sendHeaders($filename, $name, $zip = false) {
|
||||||
return \OC\Files\Filesystem::getDirectoryContent($path);
|
OC_Response::setContentDispositionHeader($name, 'attachment');
|
||||||
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
OC_Response::disableCaching();
|
||||||
|
if ($zip) {
|
||||||
|
header('Content-Type: application/zip');
|
||||||
|
} else {
|
||||||
|
$filesize = \OC\Files\Filesystem::filesize($filename);
|
||||||
|
header('Content-Type: '.\OC\Files\Filesystem::getMimeType($filename));
|
||||||
|
if ($filesize > -1) {
|
||||||
|
header("Content-Length: ".$filesize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,97 +71,50 @@ class OC_Files {
|
||||||
$xsendfile = true;
|
$xsendfile = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($files) && count($files) == 1) {
|
if (is_array($files) && count($files) === 1) {
|
||||||
$files = $files[0];
|
$files = $files[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($files)) {
|
if (is_array($files)) {
|
||||||
self::validateZipDownload($dir, $files);
|
$get_type = GET_TYPE::ZIP_FILES;
|
||||||
$executionTime = intval(ini_get('max_execution_time'));
|
|
||||||
set_time_limit(0);
|
|
||||||
$zip = new ZipArchive();
|
|
||||||
$filename = OC_Helper::tmpFile('.zip');
|
|
||||||
if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
|
|
||||||
$l = OC_L10N::get('lib');
|
|
||||||
throw new Exception($l->t('cannot open "%s"', array($filename)));
|
|
||||||
}
|
|
||||||
foreach ($files as $file) {
|
|
||||||
$file = $dir . '/' . $file;
|
|
||||||
if (\OC\Files\Filesystem::is_file($file)) {
|
|
||||||
$tmpFile = \OC\Files\Filesystem::toTmpFile($file);
|
|
||||||
self::$tmpFiles[] = $tmpFile;
|
|
||||||
$zip->addFile($tmpFile, basename($file));
|
|
||||||
} elseif (\OC\Files\Filesystem::is_dir($file)) {
|
|
||||||
self::zipAddDir($file, $zip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$zip->close();
|
|
||||||
if ($xsendfile) {
|
|
||||||
$filename = OC_Helper::moveToNoClean($filename);
|
|
||||||
}
|
|
||||||
$basename = basename($dir);
|
$basename = basename($dir);
|
||||||
if ($basename) {
|
if ($basename) {
|
||||||
$name = $basename . '.zip';
|
$name = $basename . '.zip';
|
||||||
} else {
|
} else {
|
||||||
$name = 'download.zip';
|
$name = 'download.zip';
|
||||||
}
|
}
|
||||||
|
|
||||||
set_time_limit($executionTime);
|
$filename = $dir . '/' . $name;
|
||||||
} elseif (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
|
|
||||||
self::validateZipDownload($dir, $files);
|
|
||||||
$executionTime = intval(ini_get('max_execution_time'));
|
|
||||||
set_time_limit(0);
|
|
||||||
$zip = new ZipArchive();
|
|
||||||
$filename = OC_Helper::tmpFile('.zip');
|
|
||||||
if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
|
|
||||||
$l = OC_L10N::get('lib');
|
|
||||||
throw new Exception($l->t('cannot open "%s"', array($filename)));
|
|
||||||
}
|
|
||||||
$file = $dir . '/' . $files;
|
|
||||||
self::zipAddDir($file, $zip);
|
|
||||||
$zip->close();
|
|
||||||
if ($xsendfile) {
|
|
||||||
$filename = OC_Helper::moveToNoClean($filename);
|
|
||||||
}
|
|
||||||
// downloading root ?
|
|
||||||
if ($files === '') {
|
|
||||||
$name = 'download.zip';
|
|
||||||
} else {
|
|
||||||
$name = $files . '.zip';
|
|
||||||
}
|
|
||||||
set_time_limit($executionTime);
|
|
||||||
} else {
|
} else {
|
||||||
$zip = false;
|
|
||||||
$filename = $dir . '/' . $files;
|
$filename = $dir . '/' . $files;
|
||||||
$name = $files;
|
if (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
|
||||||
|
$get_type = GET_TYPE::ZIP_DIR;
|
||||||
|
// downloading root ?
|
||||||
|
if ($files === '') {
|
||||||
|
$name = 'download.zip';
|
||||||
|
} else {
|
||||||
|
$name = $files . '.zip';
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$get_type = GET_TYPE::FILE;
|
||||||
|
$name = $files;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($get_type === GET_TYPE::FILE) {
|
||||||
|
$zip = false;
|
||||||
if ($xsendfile && OC_App::isEnabled('files_encryption')) {
|
if ($xsendfile && OC_App::isEnabled('files_encryption')) {
|
||||||
$xsendfile = false;
|
$xsendfile = false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
self::validateZipDownload($dir, $files);
|
||||||
|
$zip = new ZipStreamer(false);
|
||||||
}
|
}
|
||||||
OC_Util::obEnd();
|
OC_Util::obEnd();
|
||||||
if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
|
if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
|
||||||
OC_Response::setContentDispositionHeader($name, 'attachment');
|
self::sendHeaders($filename, $name, $zip);
|
||||||
header('Content-Transfer-Encoding: binary');
|
} elseif (!\OC\Files\Filesystem::file_exists($filename)) {
|
||||||
OC_Response::disableCaching();
|
|
||||||
if ($zip) {
|
|
||||||
ini_set('zlib.output_compression', 'off');
|
|
||||||
header('Content-Type: application/zip');
|
|
||||||
header('Content-Length: ' . filesize($filename));
|
|
||||||
self::addSendfileHeader($filename);
|
|
||||||
}else{
|
|
||||||
$filesize = \OC\Files\Filesystem::filesize($filename);
|
|
||||||
header('Content-Type: '.\OC\Files\Filesystem::getMimeType($filename));
|
|
||||||
if ($filesize > -1) {
|
|
||||||
header("Content-Length: ".$filesize);
|
|
||||||
}
|
|
||||||
if ($xsendfile) {
|
|
||||||
list($storage) = \OC\Files\Filesystem::resolvePath(\OC\Files\Filesystem::getView()->getAbsolutePath($filename));
|
|
||||||
if ($storage->isLocal()) {
|
|
||||||
self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elseif ($zip or !\OC\Files\Filesystem::file_exists($filename)) {
|
|
||||||
header("HTTP/1.0 404 Not Found");
|
header("HTTP/1.0 404 Not Found");
|
||||||
$tmpl = new OC_Template('', '404', 'guest');
|
$tmpl = new OC_Template('', '404', 'guest');
|
||||||
$tmpl->assign('file', $name);
|
$tmpl->assign('file', $name);
|
||||||
|
@ -157,23 +127,36 @@ class OC_Files {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
if ($zip) {
|
if ($zip) {
|
||||||
$handle = fopen($filename, 'r');
|
$executionTime = intval(ini_get('max_execution_time'));
|
||||||
if ($handle) {
|
set_time_limit(0);
|
||||||
$chunkSize = 8 * 1024; // 1 MB chunks
|
if ($get_type === GET_TYPE::ZIP_FILES) {
|
||||||
while (!feof($handle)) {
|
foreach ($files as $file) {
|
||||||
echo fread($handle, $chunkSize);
|
$file = $dir . '/' . $file;
|
||||||
flush();
|
if (\OC\Files\Filesystem::is_file($file)) {
|
||||||
|
$fh = \OC\Files\Filesystem::fopen($file, 'r');
|
||||||
|
$zip->addFileFromStream($fh, basename($file));
|
||||||
|
fclose($fh);
|
||||||
|
} elseif (\OC\Files\Filesystem::is_dir($file)) {
|
||||||
|
self::zipAddDir($file, $zip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} elseif ($get_type === GET_TYPE::ZIP_DIR) {
|
||||||
|
$file = $dir . '/' . $files;
|
||||||
|
self::zipAddDir($file, $zip);
|
||||||
}
|
}
|
||||||
if (!$xsendfile) {
|
$zip->finalize();
|
||||||
unlink($filename);
|
set_time_limit($executionTime);
|
||||||
}
|
} else {
|
||||||
}else{
|
if ($xsendfile) {
|
||||||
\OC\Files\Filesystem::readfile($filename);
|
/** @var $storage \OC\Files\Storage\Storage */
|
||||||
}
|
list($storage) = \OC\Files\Filesystem::resolvePath($filename);
|
||||||
foreach (self::$tmpFiles as $tmpFile) {
|
if ($storage->isLocal()) {
|
||||||
if (file_exists($tmpFile) and is_file($tmpFile)) {
|
self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
|
||||||
unlink($tmpFile);
|
} else {
|
||||||
|
\OC\Files\Filesystem::readfile($filename);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
\OC\Files\Filesystem::readfile($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,10 +169,10 @@ class OC_Files {
|
||||||
header("X-Sendfile: " . $filename);
|
header("X-Sendfile: " . $filename);
|
||||||
}
|
}
|
||||||
if (isset($_SERVER['MOD_X_SENDFILE2_ENABLED'])) {
|
if (isset($_SERVER['MOD_X_SENDFILE2_ENABLED'])) {
|
||||||
if (isset($_SERVER['HTTP_RANGE']) &&
|
if (isset($_SERVER['HTTP_RANGE']) &&
|
||||||
preg_match("/^bytes=([0-9]+)-([0-9]*)$/", $_SERVER['HTTP_RANGE'], $range)) {
|
preg_match("/^bytes=([0-9]+)-([0-9]*)$/", $_SERVER['HTTP_RANGE'], $range)) {
|
||||||
$filelength = filesize($filename);
|
$filelength = filesize($filename);
|
||||||
if ($range[2] == "") {
|
if ($range[2] === "") {
|
||||||
$range[2] = $filelength - 1;
|
$range[2] = $filelength - 1;
|
||||||
}
|
}
|
||||||
header("Content-Range: bytes $range[1]-$range[2]/" . $filelength);
|
header("Content-Range: bytes $range[1]-$range[2]/" . $filelength);
|
||||||
|
@ -199,7 +182,7 @@ class OC_Files {
|
||||||
header("X-Sendfile: " . $filename);
|
header("X-Sendfile: " . $filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
|
if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
|
||||||
header("X-Accel-Redirect: " . $filename);
|
header("X-Accel-Redirect: " . $filename);
|
||||||
}
|
}
|
||||||
|
@ -207,22 +190,27 @@ class OC_Files {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @param ZipArchive $zip
|
* @param ZipStreamer $zip
|
||||||
|
* @param string $internalDir
|
||||||
*/
|
*/
|
||||||
public static function zipAddDir($dir, $zip, $internalDir='') {
|
public static function zipAddDir($dir, $zip, $internalDir='') {
|
||||||
$dirname=basename($dir);
|
$dirname=basename($dir);
|
||||||
$zip->addEmptyDir($internalDir.$dirname);
|
$rootDir = $internalDir.$dirname;
|
||||||
|
if (!empty($rootDir)) {
|
||||||
|
$zip->addEmptyDir($rootDir);
|
||||||
|
}
|
||||||
$internalDir.=$dirname.='/';
|
$internalDir.=$dirname.='/';
|
||||||
// prevent absolute dirs
|
// prevent absolute dirs
|
||||||
$internalDir = ltrim($internalDir, '/');
|
$internalDir = ltrim($internalDir, '/');
|
||||||
$files=OC_Files::getDirectoryContent($dir);
|
|
||||||
|
$files=\OC\Files\Filesystem::getDirectoryContent($dir);
|
||||||
foreach($files as $file) {
|
foreach($files as $file) {
|
||||||
$filename=$file['name'];
|
$filename=$file['name'];
|
||||||
$file=$dir.'/'.$filename;
|
$file=$dir.'/'.$filename;
|
||||||
if(\OC\Files\Filesystem::is_file($file)) {
|
if(\OC\Files\Filesystem::is_file($file)) {
|
||||||
$tmpFile=\OC\Files\Filesystem::toTmpFile($file);
|
$fh = \OC\Files\Filesystem::fopen($file, 'r');
|
||||||
OC_Files::$tmpFiles[]=$tmpFile;
|
$zip->addFileFromStream($fh, $internalDir.$filename);
|
||||||
$zip->addFile($tmpFile, $internalDir.$filename);
|
fclose($fh);
|
||||||
}elseif(\OC\Files\Filesystem::is_dir($file)) {
|
}elseif(\OC\Files\Filesystem::is_dir($file)) {
|
||||||
self::zipAddDir($file, $zip, $internalDir);
|
self::zipAddDir($file, $zip, $internalDir);
|
||||||
}
|
}
|
||||||
|
@ -232,8 +220,8 @@ class OC_Files {
|
||||||
/**
|
/**
|
||||||
* checks if the selected files are within the size constraint. If not, outputs an error page.
|
* checks if the selected files are within the size constraint. If not, outputs an error page.
|
||||||
*
|
*
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @param files $files
|
* @param array | string $files
|
||||||
*/
|
*/
|
||||||
static function validateZipDownload($dir, $files) {
|
static function validateZipDownload($dir, $files) {
|
||||||
if (!OC_Config::getValue('allowZipDownload', true)) {
|
if (!OC_Config::getValue('allowZipDownload', true)) {
|
||||||
|
@ -280,8 +268,8 @@ class OC_Files {
|
||||||
/**
|
/**
|
||||||
* set the maximum upload size limit for apache hosts using .htaccess
|
* set the maximum upload size limit for apache hosts using .htaccess
|
||||||
*
|
*
|
||||||
* @param int size filesisze in bytes
|
* @param int $size file size in bytes
|
||||||
* @return false on failure, size on success
|
* @return bool false on failure, size on success
|
||||||
*/
|
*/
|
||||||
static function setUploadLimit($size) {
|
static function setUploadLimit($size) {
|
||||||
//don't allow user to break his config -- upper boundary
|
//don't allow user to break his config -- upper boundary
|
||||||
|
@ -297,11 +285,12 @@ class OC_Files {
|
||||||
}
|
}
|
||||||
|
|
||||||
//don't allow user to break his config -- broken or malicious size input
|
//don't allow user to break his config -- broken or malicious size input
|
||||||
if (intval($size) == 0) {
|
if (intval($size) === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$htaccess = @file_get_contents(OC::$SERVERROOT . '/.htaccess'); //supress errors in case we don't have permissions for
|
//suppress errors in case we don't have permissions for
|
||||||
|
$htaccess = @file_get_contents(OC::$SERVERROOT . '/.htaccess');
|
||||||
if (!$htaccess) {
|
if (!$htaccess) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +308,7 @@ class OC_Files {
|
||||||
if ($content !== null) {
|
if ($content !== null) {
|
||||||
$htaccess = $content;
|
$htaccess = $content;
|
||||||
}
|
}
|
||||||
if ($hasReplaced == 0) {
|
if ($hasReplaced === 0) {
|
||||||
$htaccess .= "\n" . $setting;
|
$htaccess .= "\n" . $setting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,16 @@ class Cache {
|
||||||
*/
|
*/
|
||||||
public function getFolderContents($folder) {
|
public function getFolderContents($folder) {
|
||||||
$fileId = $this->getId($folder);
|
$fileId = $this->getId($folder);
|
||||||
|
return $this->getFolderContentsById($fileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the metadata of all files stored in $folder
|
||||||
|
*
|
||||||
|
* @param int $fileId the file id of the folder
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getFolderContentsById($fileId) {
|
||||||
if ($fileId > -1) {
|
if ($fileId > -1) {
|
||||||
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`,
|
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`,
|
||||||
`storage_mtime`, `encrypted`, `unencrypted_size`, `etag`
|
`storage_mtime`, `encrypted`, `unencrypted_size`, `etag`
|
||||||
|
|
|
@ -320,7 +320,8 @@ class Filesystem {
|
||||||
else {
|
else {
|
||||||
self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
|
self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
|
||||||
}
|
}
|
||||||
$mount_file = \OC_Config::getValue("mount_file", \OC::$SERVERROOT . "/data/mount.json");
|
$datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
|
||||||
|
$mount_file = \OC_Config::getValue("mount_file", $datadir . "/mount.json");
|
||||||
|
|
||||||
//move config file to it's new position
|
//move config file to it's new position
|
||||||
if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
|
if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
|
||||||
|
@ -760,7 +761,7 @@ class Filesystem {
|
||||||
*
|
*
|
||||||
* @param string $directory path under datadirectory
|
* @param string $directory path under datadirectory
|
||||||
* @param string $mimetype_filter limit returned content to this mimetype or mimepart
|
* @param string $mimetype_filter limit returned content to this mimetype or mimepart
|
||||||
* @return array
|
* @return \OC\Files\FileInfo[]
|
||||||
*/
|
*/
|
||||||
public static function getDirectoryContent($directory, $mimetype_filter = '') {
|
public static function getDirectoryContent($directory, $mimetype_filter = '') {
|
||||||
return self::$defaultInstance->getDirectoryContent($directory, $mimetype_filter);
|
return self::$defaultInstance->getDirectoryContent($directory, $mimetype_filter);
|
||||||
|
|
|
@ -882,12 +882,13 @@ class View {
|
||||||
$watcher->checkUpdate($internalPath);
|
$watcher->checkUpdate($internalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$folderId = $cache->getId($internalPath);
|
||||||
$files = array();
|
$files = array();
|
||||||
$contents = $cache->getFolderContents($internalPath); //TODO: mimetype_filter
|
$contents = $cache->getFolderContents($internalPath, $folderId); //TODO: mimetype_filter
|
||||||
foreach ($contents as $content) {
|
foreach ($contents as $content) {
|
||||||
$files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content);
|
$files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content);
|
||||||
}
|
}
|
||||||
$permissions = $permissionsCache->getDirectoryPermissions($cache->getId($internalPath), $user);
|
$permissions = $permissionsCache->getDirectoryPermissions($folderId, $user);
|
||||||
|
|
||||||
$ids = array();
|
$ids = array();
|
||||||
foreach ($files as $i => $file) {
|
foreach ($files as $i => $file) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ class OC_Helper {
|
||||||
*/
|
*/
|
||||||
public static function linkToDocs($key) {
|
public static function linkToDocs($key) {
|
||||||
$theme = new OC_Defaults();
|
$theme = new OC_Defaults();
|
||||||
return $theme->getDocBaseUrl() . '/server/6.0/go.php?to=' . $key;
|
return $theme->buildDocLinkToKey($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,8 +41,7 @@ class OC_Image {
|
||||||
// exif_imagetype throws "read error!" if file is less than 12 byte
|
// exif_imagetype throws "read error!" if file is less than 12 byte
|
||||||
if (filesize($filePath) > 11) {
|
if (filesize($filePath) > 11) {
|
||||||
$imageType = exif_imagetype($filePath);
|
$imageType = exif_imagetype($filePath);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$imageType = false;
|
$imageType = false;
|
||||||
}
|
}
|
||||||
return $imageType ? image_type_to_mime_type($imageType) : '';
|
return $imageType ? image_type_to_mime_type($imageType) : '';
|
||||||
|
@ -50,7 +49,7 @@ class OC_Image {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor.
|
* @brief Constructor.
|
||||||
* @param $imageref The path to a local file, a base64 encoded string or a resource created by an imagecreate* function.
|
* @param string|resource $imageref The path to a local file, a base64 encoded string or a resource created by an imagecreate* function.
|
||||||
* @returns bool False on error
|
* @returns bool False on error
|
||||||
*/
|
*/
|
||||||
public function __construct($imageRef = null) {
|
public function __construct($imageRef = null) {
|
||||||
|
@ -115,13 +114,11 @@ class OC_Image {
|
||||||
case 3:
|
case 3:
|
||||||
case 4: // Not tested
|
case 4: // Not tested
|
||||||
return $this->width();
|
return $this->width();
|
||||||
break;
|
|
||||||
case 5: // Not tested
|
case 5: // Not tested
|
||||||
case 6:
|
case 6:
|
||||||
case 7: // Not tested
|
case 7: // Not tested
|
||||||
case 8:
|
case 8:
|
||||||
return $this->height();
|
return $this->height();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $this->width();
|
return $this->width();
|
||||||
}
|
}
|
||||||
|
@ -140,13 +137,11 @@ class OC_Image {
|
||||||
case 3:
|
case 3:
|
||||||
case 4: // Not tested
|
case 4: // Not tested
|
||||||
return $this->height();
|
return $this->height();
|
||||||
break;
|
|
||||||
case 5: // Not tested
|
case 5: // Not tested
|
||||||
case 6:
|
case 6:
|
||||||
case 7: // Not tested
|
case 7: // Not tested
|
||||||
case 8:
|
case 8:
|
||||||
return $this->width();
|
return $this->width();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $this->height();
|
return $this->height();
|
||||||
}
|
}
|
||||||
|
@ -197,7 +192,6 @@ class OC_Image {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$retVal = false;
|
|
||||||
switch($this->imageType) {
|
switch($this->imageType) {
|
||||||
case IMAGETYPE_GIF:
|
case IMAGETYPE_GIF:
|
||||||
$retVal = imagegif($this->resource, $filePath);
|
$retVal = imagegif($this->resource, $filePath);
|
||||||
|
@ -264,8 +258,8 @@ class OC_Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns Returns a base64 encoded string suitable for embedding in a VCard.
|
* @return string - base64 encoded, which is suitable for embedding in a VCard.
|
||||||
*/
|
*/
|
||||||
function __toString() {
|
function __toString() {
|
||||||
return base64_encode($this->data());
|
return base64_encode($this->data());
|
||||||
}
|
}
|
||||||
|
@ -307,43 +301,33 @@ class OC_Image {
|
||||||
$o = $this->getOrientation();
|
$o = $this->getOrientation();
|
||||||
OC_Log::write('core', 'OC_Image->fixOrientation() Orientation: '.$o, OC_Log::DEBUG);
|
OC_Log::write('core', 'OC_Image->fixOrientation() Orientation: '.$o, OC_Log::DEBUG);
|
||||||
$rotate = 0;
|
$rotate = 0;
|
||||||
$flip = false;
|
|
||||||
switch($o) {
|
switch($o) {
|
||||||
case -1:
|
case -1:
|
||||||
return false; //Nothing to fix
|
return false; //Nothing to fix
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
$rotate = 0;
|
$rotate = 0;
|
||||||
$flip = false;
|
|
||||||
break;
|
break;
|
||||||
case 2: // Not tested
|
case 2: // Not tested
|
||||||
$rotate = 0;
|
$rotate = 0;
|
||||||
$flip = true;
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$rotate = 180;
|
$rotate = 180;
|
||||||
$flip = false;
|
|
||||||
break;
|
break;
|
||||||
case 4: // Not tested
|
case 4: // Not tested
|
||||||
$rotate = 180;
|
$rotate = 180;
|
||||||
$flip = true;
|
|
||||||
break;
|
break;
|
||||||
case 5: // Not tested
|
case 5: // Not tested
|
||||||
$rotate = 90;
|
$rotate = 90;
|
||||||
$flip = true;
|
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
//$rotate = 90;
|
//$rotate = 90;
|
||||||
$rotate = 270;
|
$rotate = 270;
|
||||||
$flip = false;
|
|
||||||
break;
|
break;
|
||||||
case 7: // Not tested
|
case 7: // Not tested
|
||||||
$rotate = 270;
|
$rotate = 270;
|
||||||
$flip = true;
|
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
$rotate = 90;
|
$rotate = 90;
|
||||||
$flip = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($rotate) {
|
if($rotate) {
|
||||||
|
@ -367,6 +351,7 @@ class OC_Image {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -599,9 +584,9 @@ class OC_Image {
|
||||||
$meta['imagesize'] = $meta['filesize'] - $meta['offset'];
|
$meta['imagesize'] = $meta['filesize'] - $meta['offset'];
|
||||||
// in rare cases filesize is equal to offset so we need to read physical size
|
// in rare cases filesize is equal to offset so we need to read physical size
|
||||||
if ($meta['imagesize'] < 1) {
|
if ($meta['imagesize'] < 1) {
|
||||||
$meta['imagesize'] = @filesize($filename) - $meta['offset'];
|
$meta['imagesize'] = @filesize($fileName) - $meta['offset'];
|
||||||
if ($meta['imagesize'] < 1) {
|
if ($meta['imagesize'] < 1) {
|
||||||
trigger_error('imagecreatefrombmp: Can not obtain filesize of ' . $filename . '!', E_USER_WARNING);
|
trigger_error('imagecreatefrombmp: Can not obtain filesize of ' . $fileName . '!', E_USER_WARNING);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -947,7 +932,7 @@ if ( ! function_exists( 'imagebmp') ) {
|
||||||
$index = imagecolorat($im, $i, $j);
|
$index = imagecolorat($im, $i, $j);
|
||||||
if ($index !== $lastIndex || $sameNum > 255) {
|
if ($index !== $lastIndex || $sameNum > 255) {
|
||||||
if ($sameNum != 0) {
|
if ($sameNum != 0) {
|
||||||
$bmpData .= chr($same_num) . chr($lastIndex);
|
$bmpData .= chr($sameNum) . chr($lastIndex);
|
||||||
}
|
}
|
||||||
$lastIndex = $index;
|
$lastIndex = $index;
|
||||||
$sameNum = 1;
|
$sameNum = 1;
|
||||||
|
|
|
@ -464,7 +464,7 @@ class OC_Installer{
|
||||||
// is the code checker enabled?
|
// is the code checker enabled?
|
||||||
if(OC_Config::getValue('appcodechecker', true)) {
|
if(OC_Config::getValue('appcodechecker', true)) {
|
||||||
// check if grep is installed
|
// check if grep is installed
|
||||||
$grep = exec('which grep');
|
$grep = exec('command -v grep');
|
||||||
if($grep=='') {
|
if($grep=='') {
|
||||||
OC_Log::write('core',
|
OC_Log::write('core',
|
||||||
'grep not installed. So checking the code of the app "'.$appname.'" was not possible',
|
'grep not installed. So checking the code of the app "'.$appname.'" was not possible',
|
||||||
|
|
|
@ -73,8 +73,8 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get an L10N instance
|
* get an L10N instance
|
||||||
* @param $app string
|
* @param string $app
|
||||||
* @param $lang string|null
|
* @param string|null $lang
|
||||||
* @return OC_L10N
|
* @return OC_L10N
|
||||||
*/
|
*/
|
||||||
public static function get($app, $lang=null) {
|
public static function get($app, $lang=null) {
|
||||||
|
@ -87,8 +87,8 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The constructor
|
* @brief The constructor
|
||||||
* @param $app string app requesting l10n
|
* @param string $app app requesting l10n
|
||||||
* @param $lang string default: null Language
|
* @param string $lang default: null Language
|
||||||
* @returns OC_L10N-Object
|
* @returns OC_L10N-Object
|
||||||
*
|
*
|
||||||
* If language is not set, the constructor tries to find the right
|
* If language is not set, the constructor tries to find the right
|
||||||
|
@ -237,7 +237,7 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Translating
|
* @brief Translating
|
||||||
* @param $text String The text we need a translation for
|
* @param string $text The text we need a translation for
|
||||||
* @param array $parameters default:array() Parameters for sprintf
|
* @param array $parameters default:array() Parameters for sprintf
|
||||||
* @return \OC_L10N_String Translation or the same text
|
* @return \OC_L10N_String Translation or the same text
|
||||||
*
|
*
|
||||||
|
@ -250,9 +250,9 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Translating
|
* @brief Translating
|
||||||
* @param $text_singular String the string to translate for exactly one object
|
* @param string $text_singular the string to translate for exactly one object
|
||||||
* @param $text_plural String the string to translate for n objects
|
* @param string $text_plural the string to translate for n objects
|
||||||
* @param $count Integer Number of objects
|
* @param integer $count Number of objects
|
||||||
* @param array $parameters default:array() Parameters for sprintf
|
* @param array $parameters default:array() Parameters for sprintf
|
||||||
* @return \OC_L10N_String Translation or the same text
|
* @return \OC_L10N_String Translation or the same text
|
||||||
*
|
*
|
||||||
|
@ -351,7 +351,7 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Localization
|
* @brief Localization
|
||||||
* @param $type Type of localization
|
* @param string $type Type of localization
|
||||||
* @param $params parameters for this localization
|
* @param $params parameters for this localization
|
||||||
* @returns String or false
|
* @returns String or false
|
||||||
*
|
*
|
||||||
|
@ -406,7 +406,7 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Choose a language
|
* @brief Choose a language
|
||||||
* @param $texts Associative Array with possible strings
|
* @param array $text Associative Array with possible strings
|
||||||
* @returns String
|
* @returns String
|
||||||
*
|
*
|
||||||
* $text is an array 'de' => 'hallo welt', 'en' => 'hello world', ...
|
* $text is an array 'de' => 'hallo welt', 'en' => 'hello world', ...
|
||||||
|
@ -421,7 +421,7 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief find the best language
|
* @brief find the best language
|
||||||
* @param $app Array or string, details below
|
* @param array|string $app details below
|
||||||
* @returns string language
|
* @returns string language
|
||||||
*
|
*
|
||||||
* If $app is an array, ownCloud assumes that these are the available
|
* If $app is an array, ownCloud assumes that these are the available
|
||||||
|
@ -494,7 +494,7 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief find the l10n directory
|
* @brief find the l10n directory
|
||||||
* @param $app App that needs to be translated
|
* @param string $app App that needs to be translated
|
||||||
* @returns directory
|
* @returns directory
|
||||||
*/
|
*/
|
||||||
protected static function findI18nDir($app) {
|
protected static function findI18nDir($app) {
|
||||||
|
@ -514,7 +514,7 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief find all available languages for an app
|
* @brief find all available languages for an app
|
||||||
* @param $app App that needs to be translated
|
* @param string $app App that needs to be translated
|
||||||
* @returns array an array of available languages
|
* @returns array an array of available languages
|
||||||
*/
|
*/
|
||||||
public static function findAvailableLanguages($app=null) {
|
public static function findAvailableLanguages($app=null) {
|
||||||
|
@ -533,7 +533,9 @@ class OC_L10N implements \OCP\IL10N {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string $app
|
||||||
* @param string $lang
|
* @param string $lang
|
||||||
|
* @returns bool
|
||||||
*/
|
*/
|
||||||
public static function languageExists($app, $lang) {
|
public static function languageExists($app, $lang) {
|
||||||
if ($lang == 'en') {//english is always available
|
if ($lang == 'en') {//english is always available
|
||||||
|
|
|
@ -31,6 +31,7 @@ return array(
|
||||||
'bash' => 'text/x-shellscript',
|
'bash' => 'text/x-shellscript',
|
||||||
'blend' => 'application/x-blender',
|
'blend' => 'application/x-blender',
|
||||||
'bin' => 'application/x-bin',
|
'bin' => 'application/x-bin',
|
||||||
|
'bmp' => 'image/bmp',
|
||||||
'cb7' => 'application/x-cbr',
|
'cb7' => 'application/x-cbr',
|
||||||
'cba' => 'application/x-cbr',
|
'cba' => 'application/x-cbr',
|
||||||
'cbr' => 'application/x-cbr',
|
'cbr' => 'application/x-cbr',
|
||||||
|
|
|
@ -61,17 +61,29 @@ class OC_OCS_Cloud {
|
||||||
* the user from whom the information will be returned
|
* the user from whom the information will be returned
|
||||||
*/
|
*/
|
||||||
public static function getUser($parameters) {
|
public static function getUser($parameters) {
|
||||||
|
$return = array();
|
||||||
// Check if they are viewing information on themselves
|
// Check if they are viewing information on themselves
|
||||||
if($parameters['userid'] === OC_User::getUser()) {
|
if($parameters['userid'] === OC_User::getUser()) {
|
||||||
// Self lookup
|
// Self lookup
|
||||||
$storage = OC_Helper::getStorageInfo('/');
|
$storage = OC_Helper::getStorageInfo('/');
|
||||||
$quota = array(
|
$return['quota'] = array(
|
||||||
'free' => $storage['free'],
|
'free' => $storage['free'],
|
||||||
'used' => $storage['used'],
|
'used' => $storage['used'],
|
||||||
'total' => $storage['total'],
|
'total' => $storage['total'],
|
||||||
'relative' => $storage['relative'],
|
'relative' => $storage['relative'],
|
||||||
);
|
);
|
||||||
return new OC_OCS_Result(array('quota' => $quota));
|
}
|
||||||
|
if(OC_User::isAdminUser(OC_User::getUser())
|
||||||
|
|| OC_Subadmin::isUserAccessible(OC_User::getUser(), $parameters['userid'])) {
|
||||||
|
if(OC_User::userExists($parameters['userid'])) {
|
||||||
|
// Is an admin/subadmin so can see display name
|
||||||
|
$return['displayname'] = OC_User::getDisplayName($parameters['userid']);
|
||||||
|
} else {
|
||||||
|
return new OC_OCS_Result(null, 101);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count($return)) {
|
||||||
|
return new OC_OCS_Result($return);
|
||||||
} else {
|
} else {
|
||||||
// No permission to view this user data
|
// No permission to view this user data
|
||||||
return new OC_OCS_Result(null, 997);
|
return new OC_OCS_Result(null, 997);
|
||||||
|
|
|
@ -52,6 +52,11 @@ class Preview {
|
||||||
static private $providers = array();
|
static private $providers = array();
|
||||||
static private $registeredProviders = array();
|
static private $registeredProviders = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \OCP\Files\FileInfo
|
||||||
|
*/
|
||||||
|
protected $info;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief check if thumbnail or bigger version of thumbnail of file is cached
|
* @brief check if thumbnail or bigger version of thumbnail of file is cached
|
||||||
* @param string $user userid - if no user is given, OC_User::getUser will be used
|
* @param string $user userid - if no user is given, OC_User::getUser will be used
|
||||||
|
@ -61,12 +66,12 @@ class Preview {
|
||||||
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
|
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
|
||||||
* @param bool $scalingUp Disable/Enable upscaling of previews
|
* @param bool $scalingUp Disable/Enable upscaling of previews
|
||||||
* @return mixed (bool / string)
|
* @return mixed (bool / string)
|
||||||
* false if thumbnail does not exist
|
* false if thumbnail does not exist
|
||||||
* path to thumbnail if thumbnail exists
|
* path to thumbnail if thumbnail exists
|
||||||
*/
|
*/
|
||||||
public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingUp=true) {
|
public function __construct($user = '', $root = '/', $file = '', $maxX = 1, $maxY = 1, $scalingUp = true) {
|
||||||
//init fileviews
|
//init fileviews
|
||||||
if($user === ''){
|
if ($user === '') {
|
||||||
$user = \OC_User::getUser();
|
$user = \OC_User::getUser();
|
||||||
}
|
}
|
||||||
$this->fileView = new \OC\Files\View('/' . $user . '/' . $root);
|
$this->fileView = new \OC\Files\View('/' . $user . '/' . $root);
|
||||||
|
@ -86,11 +91,11 @@ class Preview {
|
||||||
$this->preview = null;
|
$this->preview = null;
|
||||||
|
|
||||||
//check if there are preview backends
|
//check if there are preview backends
|
||||||
if(empty(self::$providers)) {
|
if (empty(self::$providers)) {
|
||||||
self::initProviders();
|
self::initProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty(self::$providers)) {
|
if (empty(self::$providers)) {
|
||||||
\OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR);
|
\OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR);
|
||||||
throw new \Exception('No preview providers');
|
throw new \Exception('No preview providers');
|
||||||
}
|
}
|
||||||
|
@ -99,15 +104,15 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief returns the path of the file you want a thumbnail from
|
* @brief returns the path of the file you want a thumbnail from
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFile() {
|
public function getFile() {
|
||||||
return $this->file;
|
return $this->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief returns the max width of the preview
|
* @brief returns the max width of the preview
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getMaxX() {
|
public function getMaxX() {
|
||||||
return $this->maxX;
|
return $this->maxX;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +120,7 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief returns the max height of the preview
|
* @brief returns the max height of the preview
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getMaxY() {
|
public function getMaxY() {
|
||||||
return $this->maxY;
|
return $this->maxY;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +128,7 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief returns whether or not scalingup is enabled
|
* @brief returns whether or not scalingup is enabled
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getScalingUp() {
|
public function getScalingUp() {
|
||||||
return $this->scalingup;
|
return $this->scalingup;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +136,7 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief returns the name of the thumbnailfolder
|
* @brief returns the name of the thumbnailfolder
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getThumbnailsFolder() {
|
public function getThumbnailsFolder() {
|
||||||
return self::THUMBNAILS_FOLDER;
|
return self::THUMBNAILS_FOLDER;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +144,7 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief returns the max scale factor
|
* @brief returns the max scale factor
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getMaxScaleFactor() {
|
public function getMaxScaleFactor() {
|
||||||
return $this->maxScaleFactor;
|
return $this->maxScaleFactor;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +152,7 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief returns the max width set in ownCloud's config
|
* @brief returns the max width set in ownCloud's config
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getConfigMaxX() {
|
public function getConfigMaxX() {
|
||||||
return $this->configMaxX;
|
return $this->configMaxX;
|
||||||
}
|
}
|
||||||
|
@ -155,20 +160,28 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief returns the max height set in ownCloud's config
|
* @brief returns the max height set in ownCloud's config
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getConfigMaxY() {
|
public function getConfigMaxY() {
|
||||||
return $this->configMaxY;
|
return $this->configMaxY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getFileInfo() {
|
||||||
|
if (!$this->info) {
|
||||||
|
$this->info = $this->fileView->getFileInfo($this->file);
|
||||||
|
}
|
||||||
|
return $this->info;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief set the path of the file you want a thumbnail from
|
* @brief set the path of the file you want a thumbnail from
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setFile($file) {
|
public function setFile($file) {
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
|
$this->info = null;
|
||||||
if ($file !== '') {
|
if ($file !== '') {
|
||||||
$this->mimetype = $this->fileView->getMimeType($this->file);
|
$this->mimetype = $this->getFileInfo()->getMimetype();
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -185,14 +198,14 @@ class Preview {
|
||||||
* @brief set the the max width of the preview
|
* @brief set the the max width of the preview
|
||||||
* @param int $maxX
|
* @param int $maxX
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setMaxX($maxX=1) {
|
public function setMaxX($maxX = 1) {
|
||||||
if($maxX <= 0) {
|
if ($maxX <= 0) {
|
||||||
throw new \Exception('Cannot set width of 0 or smaller!');
|
throw new \Exception('Cannot set width of 0 or smaller!');
|
||||||
}
|
}
|
||||||
$configMaxX = $this->getConfigMaxX();
|
$configMaxX = $this->getConfigMaxX();
|
||||||
if(!is_null($configMaxX)) {
|
if (!is_null($configMaxX)) {
|
||||||
if($maxX > $configMaxX) {
|
if ($maxX > $configMaxX) {
|
||||||
\OC_Log::write('core', 'maxX reduced from ' . $maxX . ' to ' . $configMaxX, \OC_Log::DEBUG);
|
\OC_Log::write('core', 'maxX reduced from ' . $maxX . ' to ' . $configMaxX, \OC_Log::DEBUG);
|
||||||
$maxX = $configMaxX;
|
$maxX = $configMaxX;
|
||||||
}
|
}
|
||||||
|
@ -205,14 +218,14 @@ class Preview {
|
||||||
* @brief set the the max height of the preview
|
* @brief set the the max height of the preview
|
||||||
* @param int $maxY
|
* @param int $maxY
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setMaxY($maxY=1) {
|
public function setMaxY($maxY = 1) {
|
||||||
if($maxY <= 0) {
|
if ($maxY <= 0) {
|
||||||
throw new \Exception('Cannot set height of 0 or smaller!');
|
throw new \Exception('Cannot set height of 0 or smaller!');
|
||||||
}
|
}
|
||||||
$configMaxY = $this->getConfigMaxY();
|
$configMaxY = $this->getConfigMaxY();
|
||||||
if(!is_null($configMaxY)) {
|
if (!is_null($configMaxY)) {
|
||||||
if($maxY > $configMaxY) {
|
if ($maxY > $configMaxY) {
|
||||||
\OC_Log::write('core', 'maxX reduced from ' . $maxY . ' to ' . $configMaxY, \OC_Log::DEBUG);
|
\OC_Log::write('core', 'maxX reduced from ' . $maxY . ' to ' . $configMaxY, \OC_Log::DEBUG);
|
||||||
$maxY = $configMaxY;
|
$maxY = $configMaxY;
|
||||||
}
|
}
|
||||||
|
@ -225,9 +238,9 @@ class Preview {
|
||||||
* @brief set whether or not scalingup is enabled
|
* @brief set whether or not scalingup is enabled
|
||||||
* @param bool $scalingUp
|
* @param bool $scalingUp
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setScalingup($scalingUp) {
|
public function setScalingup($scalingUp) {
|
||||||
if($this->getMaxScaleFactor() === 1) {
|
if ($this->getMaxScaleFactor() === 1) {
|
||||||
$scalingUp = false;
|
$scalingUp = false;
|
||||||
}
|
}
|
||||||
$this->scalingup = $scalingUp;
|
$this->scalingup = $scalingUp;
|
||||||
|
@ -237,15 +250,15 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief check if all parameters are valid
|
* @brief check if all parameters are valid
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isFileValid() {
|
public function isFileValid() {
|
||||||
$file = $this->getFile();
|
$file = $this->getFile();
|
||||||
if($file === '') {
|
if ($file === '') {
|
||||||
\OC_Log::write('core', 'No filename passed', \OC_Log::DEBUG);
|
\OC_Log::write('core', 'No filename passed', \OC_Log::DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->fileView->file_exists($file)) {
|
if (!$this->fileView->file_exists($file)) {
|
||||||
\OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::DEBUG);
|
\OC_Log::write('core', 'File:"' . $file . '" not found', \OC_Log::DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -256,40 +269,38 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief deletes previews of a file with specific x and y
|
* @brief deletes previews of a file with specific x and y
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function deletePreview() {
|
public function deletePreview() {
|
||||||
$file = $this->getFile();
|
$file = $this->getFile();
|
||||||
|
|
||||||
$fileInfo = $this->fileView->getFileInfo($file);
|
$fileInfo = $this->getFileInfo($file);
|
||||||
$fileId = $fileInfo['fileid'];
|
$fileId = $fileInfo->getId();
|
||||||
|
|
||||||
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png';
|
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/' . $this->getMaxX() . '-' . $this->getMaxY() . '.png';
|
||||||
$this->userView->unlink($previewPath);
|
return $this->userView->unlink($previewPath);
|
||||||
return !$this->userView->file_exists($previewPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief deletes all previews of a file
|
* @brief deletes all previews of a file
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function deleteAllPreviews() {
|
public function deleteAllPreviews() {
|
||||||
$file = $this->getFile();
|
$file = $this->getFile();
|
||||||
|
|
||||||
$fileInfo = $this->fileView->getFileInfo($file);
|
$fileInfo = $this->getFileInfo($file);
|
||||||
$fileId = $fileInfo['fileid'];
|
$fileId = $fileInfo->getId();
|
||||||
|
|
||||||
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
||||||
$this->userView->deleteAll($previewPath);
|
$this->userView->deleteAll($previewPath);
|
||||||
$this->userView->rmdir($previewPath);
|
return $this->userView->rmdir($previewPath);
|
||||||
return !$this->userView->is_dir($previewPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief check if thumbnail or bigger version of thumbnail of file is cached
|
* @brief check if thumbnail or bigger version of thumbnail of file is cached
|
||||||
* @return mixed (bool / string)
|
* @return mixed (bool / string)
|
||||||
* false if thumbnail does not exist
|
* false if thumbnail does not exist
|
||||||
* path to thumbnail if thumbnail exists
|
* path to thumbnail if thumbnail exists
|
||||||
*/
|
*/
|
||||||
private function isCached() {
|
private function isCached() {
|
||||||
$file = $this->getFile();
|
$file = $this->getFile();
|
||||||
$maxX = $this->getMaxX();
|
$maxX = $this->getMaxX();
|
||||||
|
@ -297,75 +308,75 @@ class Preview {
|
||||||
$scalingUp = $this->getScalingUp();
|
$scalingUp = $this->getScalingUp();
|
||||||
$maxScaleFactor = $this->getMaxScaleFactor();
|
$maxScaleFactor = $this->getMaxScaleFactor();
|
||||||
|
|
||||||
$fileInfo = $this->fileView->getFileInfo($file);
|
$fileInfo = $this->getFileInfo($file);
|
||||||
$fileId = $fileInfo['fileid'];
|
$fileId = $fileInfo->getId();
|
||||||
|
|
||||||
if(is_null($fileId)) {
|
if (is_null($fileId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
||||||
if(!$this->userView->is_dir($previewPath)) {
|
if (!$this->userView->is_dir($previewPath)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//does a preview with the wanted height and width already exist?
|
//does a preview with the wanted height and width already exist?
|
||||||
if($this->userView->file_exists($previewPath . $maxX . '-' . $maxY . '.png')) {
|
if ($this->userView->file_exists($previewPath . $maxX . '-' . $maxY . '.png')) {
|
||||||
return $previewPath . $maxX . '-' . $maxY . '.png';
|
return $previewPath . $maxX . '-' . $maxY . '.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
$wantedAspectRatio = (float) ($maxX / $maxY);
|
$wantedAspectRatio = (float)($maxX / $maxY);
|
||||||
|
|
||||||
//array for usable cached thumbnails
|
//array for usable cached thumbnails
|
||||||
$possibleThumbnails = array();
|
$possibleThumbnails = array();
|
||||||
|
|
||||||
$allThumbnails = $this->userView->getDirectoryContent($previewPath);
|
$allThumbnails = $this->userView->getDirectoryContent($previewPath);
|
||||||
foreach($allThumbnails as $thumbnail) {
|
foreach ($allThumbnails as $thumbnail) {
|
||||||
$name = rtrim($thumbnail['name'], '.png');
|
$name = rtrim($thumbnail['name'], '.png');
|
||||||
$size = explode('-', $name);
|
$size = explode('-', $name);
|
||||||
$x = (int) $size[0];
|
$x = (int)$size[0];
|
||||||
$y = (int) $size[1];
|
$y = (int)$size[1];
|
||||||
|
|
||||||
$aspectRatio = (float) ($x / $y);
|
$aspectRatio = (float)($x / $y);
|
||||||
if($aspectRatio !== $wantedAspectRatio) {
|
if ($aspectRatio !== $wantedAspectRatio) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($x < $maxX || $y < $maxY) {
|
if ($x < $maxX || $y < $maxY) {
|
||||||
if($scalingUp) {
|
if ($scalingUp) {
|
||||||
$scalefactor = $maxX / $x;
|
$scalefactor = $maxX / $x;
|
||||||
if($scalefactor > $maxScaleFactor) {
|
if ($scalefactor > $maxScaleFactor) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$possibleThumbnails[$x] = $thumbnail['path'];
|
$possibleThumbnails[$x] = $thumbnail['path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($possibleThumbnails) === 0) {
|
if (count($possibleThumbnails) === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($possibleThumbnails) === 1) {
|
if (count($possibleThumbnails) === 1) {
|
||||||
return current($possibleThumbnails);
|
return current($possibleThumbnails);
|
||||||
}
|
}
|
||||||
|
|
||||||
ksort($possibleThumbnails);
|
ksort($possibleThumbnails);
|
||||||
|
|
||||||
if(key(reset($possibleThumbnails)) > $maxX) {
|
if (key(reset($possibleThumbnails)) > $maxX) {
|
||||||
return current(reset($possibleThumbnails));
|
return current(reset($possibleThumbnails));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(key(end($possibleThumbnails)) < $maxX) {
|
if (key(end($possibleThumbnails)) < $maxX) {
|
||||||
return current(end($possibleThumbnails));
|
return current(end($possibleThumbnails));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($possibleThumbnails as $width => $path) {
|
foreach ($possibleThumbnails as $width => $path) {
|
||||||
if($width < $maxX) {
|
if ($width < $maxX) {
|
||||||
continue;
|
continue;
|
||||||
}else{
|
} else {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,9 +385,9 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief return a preview of a file
|
* @brief return a preview of a file
|
||||||
* @return \OC_Image
|
* @return \OC_Image
|
||||||
*/
|
*/
|
||||||
public function getPreview() {
|
public function getPreview() {
|
||||||
if(!is_null($this->preview) && $this->preview->valid()){
|
if (!is_null($this->preview) && $this->preview->valid()) {
|
||||||
return $this->preview;
|
return $this->preview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,22 +397,25 @@ class Preview {
|
||||||
$maxY = $this->getMaxY();
|
$maxY = $this->getMaxY();
|
||||||
$scalingUp = $this->getScalingUp();
|
$scalingUp = $this->getScalingUp();
|
||||||
|
|
||||||
$fileInfo = $this->fileView->getFileInfo($file);
|
$fileInfo = $this->getFileInfo($file);
|
||||||
$fileId = $fileInfo['fileid'];
|
$fileId = $fileInfo->getId();
|
||||||
|
|
||||||
$cached = $this->isCached();
|
$cached = $this->isCached();
|
||||||
|
|
||||||
if($cached) {
|
if ($cached) {
|
||||||
$image = new \OC_Image($this->userView->file_get_contents($cached, 'r'));
|
$stream = $this->userView->fopen($cached, 'r');
|
||||||
|
$image = new \OC_Image();
|
||||||
|
$image->loadFromFileHandle($stream);
|
||||||
$this->preview = $image->valid() ? $image : null;
|
$this->preview = $image->valid() ? $image : null;
|
||||||
$this->resizeAndCrop();
|
$this->resizeAndCrop();
|
||||||
|
fclose($stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_null($this->preview)) {
|
if (is_null($this->preview)) {
|
||||||
$preview = null;
|
$preview = null;
|
||||||
|
|
||||||
foreach(self::$providers as $supportedMimetype => $provider) {
|
foreach (self::$providers as $supportedMimetype => $provider) {
|
||||||
if(!preg_match($supportedMimetype, $this->mimetype)) {
|
if (!preg_match($supportedMimetype, $this->mimetype)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +423,7 @@ class Preview {
|
||||||
|
|
||||||
$preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileView);
|
$preview = $provider->getThumbnail($file, $maxX, $maxY, $scalingUp, $this->fileView);
|
||||||
|
|
||||||
if(!($preview instanceof \OC_Image)) {
|
if (!($preview instanceof \OC_Image)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,11 +433,11 @@ class Preview {
|
||||||
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
|
||||||
$cachePath = $previewPath . $maxX . '-' . $maxY . '.png';
|
$cachePath = $previewPath . $maxX . '-' . $maxY . '.png';
|
||||||
|
|
||||||
if($this->userView->is_dir($this->getThumbnailsFolder() . '/') === false) {
|
if ($this->userView->is_dir($this->getThumbnailsFolder() . '/') === false) {
|
||||||
$this->userView->mkdir($this->getThumbnailsFolder() . '/');
|
$this->userView->mkdir($this->getThumbnailsFolder() . '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->userView->is_dir($previewPath) === false) {
|
if ($this->userView->is_dir($previewPath) === false) {
|
||||||
$this->userView->mkdir($previewPath);
|
$this->userView->mkdir($previewPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +447,7 @@ class Preview {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_null($this->preview)) {
|
if (is_null($this->preview)) {
|
||||||
$this->preview = new \OC_Image();
|
$this->preview = new \OC_Image();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,10 +457,10 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief show preview
|
* @brief show preview
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function showPreview() {
|
public function showPreview() {
|
||||||
\OCP\Response::enableCaching(3600 * 24); // 24 hours
|
\OCP\Response::enableCaching(3600 * 24); // 24 hours
|
||||||
if(is_null($this->preview)) {
|
if (is_null($this->preview)) {
|
||||||
$this->getPreview();
|
$this->getPreview();
|
||||||
}
|
}
|
||||||
$this->preview->show();
|
$this->preview->show();
|
||||||
|
@ -456,7 +470,7 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief show preview
|
* @brief show preview
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function show() {
|
public function show() {
|
||||||
$this->showPreview();
|
$this->showPreview();
|
||||||
return;
|
return;
|
||||||
|
@ -465,7 +479,7 @@ class Preview {
|
||||||
/**
|
/**
|
||||||
* @brief resize, crop and fix orientation
|
* @brief resize, crop and fix orientation
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function resizeAndCrop() {
|
private function resizeAndCrop() {
|
||||||
$image = $this->preview;
|
$image = $this->preview;
|
||||||
$x = $this->getMaxX();
|
$x = $this->getMaxX();
|
||||||
|
@ -473,17 +487,17 @@ class Preview {
|
||||||
$scalingUp = $this->getScalingUp();
|
$scalingUp = $this->getScalingUp();
|
||||||
$maxscalefactor = $this->getMaxScaleFactor();
|
$maxscalefactor = $this->getMaxScaleFactor();
|
||||||
|
|
||||||
if(!($image instanceof \OC_Image)) {
|
if (!($image instanceof \OC_Image)) {
|
||||||
\OC_Log::write('core', '$this->preview is not an instance of OC_Image', \OC_Log::DEBUG);
|
\OC_Log::write('core', '$this->preview is not an instance of OC_Image', \OC_Log::DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$image->fixOrientation();
|
$image->fixOrientation();
|
||||||
|
|
||||||
$realx = (int) $image->width();
|
$realx = (int)$image->width();
|
||||||
$realy = (int) $image->height();
|
$realy = (int)$image->height();
|
||||||
|
|
||||||
if($x === $realx && $y === $realy) {
|
if ($x === $realx && $y === $realy) {
|
||||||
$this->preview = $image;
|
$this->preview = $image;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -491,36 +505,36 @@ class Preview {
|
||||||
$factorX = $x / $realx;
|
$factorX = $x / $realx;
|
||||||
$factorY = $y / $realy;
|
$factorY = $y / $realy;
|
||||||
|
|
||||||
if($factorX >= $factorY) {
|
if ($factorX >= $factorY) {
|
||||||
$factor = $factorX;
|
$factor = $factorX;
|
||||||
}else{
|
} else {
|
||||||
$factor = $factorY;
|
$factor = $factorY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($scalingUp === false) {
|
if ($scalingUp === false) {
|
||||||
if($factor > 1) {
|
if ($factor > 1) {
|
||||||
$factor = 1;
|
$factor = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($maxscalefactor)) {
|
if (!is_null($maxscalefactor)) {
|
||||||
if($factor > $maxscalefactor) {
|
if ($factor > $maxscalefactor) {
|
||||||
\OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $maxscalefactor, \OC_Log::DEBUG);
|
\OC_Log::write('core', 'scalefactor reduced from ' . $factor . ' to ' . $maxscalefactor, \OC_Log::DEBUG);
|
||||||
$factor = $maxscalefactor;
|
$factor = $maxscalefactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$newXsize = (int) ($realx * $factor);
|
$newXsize = (int)($realx * $factor);
|
||||||
$newYsize = (int) ($realy * $factor);
|
$newYsize = (int)($realy * $factor);
|
||||||
|
|
||||||
$image->preciseResize($newXsize, $newYsize);
|
$image->preciseResize($newXsize, $newYsize);
|
||||||
|
|
||||||
if($newXsize === $x && $newYsize === $y) {
|
if ($newXsize === $x && $newYsize === $y) {
|
||||||
$this->preview = $image;
|
$this->preview = $image;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($newXsize >= $x && $newYsize >= $y) {
|
if ($newXsize >= $x && $newYsize >= $y) {
|
||||||
$cropX = floor(abs($x - $newXsize) * 0.5);
|
$cropX = floor(abs($x - $newXsize) * 0.5);
|
||||||
//don't crop previews on the Y axis, this sucks if it's a document.
|
//don't crop previews on the Y axis, this sucks if it's a document.
|
||||||
//$cropY = floor(abs($y - $newYsize) * 0.5);
|
//$cropY = floor(abs($y - $newYsize) * 0.5);
|
||||||
|
@ -532,19 +546,19 @@ class Preview {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($newXsize < $x || $newYsize < $y) {
|
if ($newXsize < $x || $newYsize < $y) {
|
||||||
if($newXsize > $x) {
|
if ($newXsize > $x) {
|
||||||
$cropX = floor(($newXsize - $x) * 0.5);
|
$cropX = floor(($newXsize - $x) * 0.5);
|
||||||
$image->crop($cropX, 0, $x, $newYsize);
|
$image->crop($cropX, 0, $x, $newYsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($newYsize > $y) {
|
if ($newYsize > $y) {
|
||||||
$cropY = floor(($newYsize - $y) * 0.5);
|
$cropY = floor(($newYsize - $y) * 0.5);
|
||||||
$image->crop(0, $cropY, $newXsize, $y);
|
$image->crop(0, $cropY, $newXsize, $y);
|
||||||
}
|
}
|
||||||
|
|
||||||
$newXsize = (int) $image->width();
|
$newXsize = (int)$image->width();
|
||||||
$newYsize = (int) $image->height();
|
$newYsize = (int)$image->height();
|
||||||
|
|
||||||
//create transparent background layer
|
//create transparent background layer
|
||||||
$backgroundlayer = imagecreatetruecolor($x, $y);
|
$backgroundlayer = imagecreatetruecolor($x, $y);
|
||||||
|
@ -573,8 +587,8 @@ class Preview {
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function registerProvider($class, $options=array()) {
|
public static function registerProvider($class, $options = array()) {
|
||||||
self::$registeredProviders[]=array('class'=>$class, 'options'=>$options);
|
self::$registeredProviders[] = array('class' => $class, 'options' => $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -582,19 +596,19 @@ class Preview {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function initProviders() {
|
private static function initProviders() {
|
||||||
if(!\OC_Config::getValue('enable_previews', true)) {
|
if (!\OC_Config::getValue('enable_previews', true)) {
|
||||||
$provider = new Preview\Unknown(array());
|
$provider = new Preview\Unknown(array());
|
||||||
self::$providers = array($provider->getMimeType() => $provider);
|
self::$providers = array($provider->getMimeType() => $provider);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count(self::$providers)>0) {
|
if (count(self::$providers) > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(self::$registeredProviders as $provider) {
|
foreach (self::$registeredProviders as $provider) {
|
||||||
$class=$provider['class'];
|
$class = $provider['class'];
|
||||||
$options=$provider['options'];
|
$options = $provider['options'];
|
||||||
|
|
||||||
$object = new $class($options);
|
$object = new $class($options);
|
||||||
|
|
||||||
|
@ -611,7 +625,7 @@ class Preview {
|
||||||
|
|
||||||
public static function post_delete($args) {
|
public static function post_delete($args) {
|
||||||
$path = $args['path'];
|
$path = $args['path'];
|
||||||
if(substr($path, 0, 1) === '/') {
|
if (substr($path, 0, 1) === '/') {
|
||||||
$path = substr($path, 1);
|
$path = substr($path, 1);
|
||||||
}
|
}
|
||||||
$preview = new Preview(\OC_User::getUser(), 'files/', $path);
|
$preview = new Preview(\OC_User::getUser(), 'files/', $path);
|
||||||
|
@ -622,19 +636,19 @@ class Preview {
|
||||||
* @param string $mimetype
|
* @param string $mimetype
|
||||||
*/
|
*/
|
||||||
public static function isMimeSupported($mimetype) {
|
public static function isMimeSupported($mimetype) {
|
||||||
if(!\OC_Config::getValue('enable_previews', true)) {
|
if (!\OC_Config::getValue('enable_previews', true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if there are preview backends
|
//check if there are preview backends
|
||||||
if(empty(self::$providers)) {
|
if (empty(self::$providers)) {
|
||||||
self::initProviders();
|
self::initProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove last element because it has the mimetype *
|
//remove last element because it has the mimetype *
|
||||||
$providers = array_slice(self::$providers, 0, -1);
|
$providers = array_slice(self::$providers, 0, -1);
|
||||||
foreach($providers as $supportedMimetype => $provider) {
|
foreach ($providers as $supportedMimetype => $provider) {
|
||||||
if(preg_match($supportedMimetype, $mimetype)) {
|
if (preg_match($supportedMimetype, $mimetype)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
namespace OC\Preview;
|
namespace OC\Preview;
|
||||||
|
|
||||||
function findBinaryPath($program) {
|
function findBinaryPath($program) {
|
||||||
exec('which ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
|
exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
|
||||||
if ($returnCode === 0 && count($output) > 0) {
|
if ($returnCode === 0 && count($output) > 0) {
|
||||||
return escapeshellcmd($output[0]);
|
return escapeshellcmd($output[0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,12 +64,12 @@ if (!\OC_Util::runningOnWindows()) {
|
||||||
$cmd = \OC_Config::getValue('preview_libreoffice_path', null);
|
$cmd = \OC_Config::getValue('preview_libreoffice_path', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$whichLibreOffice = shell_exec('which libreoffice');
|
$whichLibreOffice = shell_exec('command -v libreoffice');
|
||||||
if($cmd === '' && !empty($whichLibreOffice)) {
|
if($cmd === '' && !empty($whichLibreOffice)) {
|
||||||
$cmd = 'libreoffice';
|
$cmd = 'libreoffice';
|
||||||
}
|
}
|
||||||
|
|
||||||
$whichOpenOffice = shell_exec('which openoffice');
|
$whichOpenOffice = shell_exec('command -v openoffice');
|
||||||
if($cmd === '' && !empty($whichOpenOffice)) {
|
if($cmd === '' && !empty($whichOpenOffice)) {
|
||||||
$cmd = 'openoffice';
|
$cmd = 'openoffice';
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1)
|
||||||
|
|
||||||
// LibreOffice preview is currently not supported on Windows
|
// LibreOffice preview is currently not supported on Windows
|
||||||
if (!\OC_Util::runningOnWindows()) {
|
if (!\OC_Util::runningOnWindows()) {
|
||||||
$whichLibreOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
|
$whichLibreOffice = ($isShellExecEnabled ? shell_exec('command -v libreoffice') : '');
|
||||||
$isLibreOfficeAvailable = !empty($whichLibreOffice);
|
$isLibreOfficeAvailable = !empty($whichLibreOffice);
|
||||||
$whichOpenOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
|
$whichOpenOffice = ($isShellExecEnabled ? shell_exec('command -v libreoffice') : '');
|
||||||
$isOpenOfficeAvailable = !empty($whichOpenOffice);
|
$isOpenOfficeAvailable = !empty($whichOpenOffice);
|
||||||
//let's see if there is libreoffice or openoffice on this machine
|
//let's see if there is libreoffice or openoffice on this machine
|
||||||
if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {
|
if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {
|
||||||
|
|
|
@ -147,7 +147,7 @@ class OC_Setup {
|
||||||
$content.= "RewriteRule ^.well-known/host-meta /public.php?service=host-meta [QSA,L]\n";
|
$content.= "RewriteRule ^.well-known/host-meta /public.php?service=host-meta [QSA,L]\n";
|
||||||
$content.= "RewriteRule ^.well-known/carddav /remote.php/carddav/ [R]\n";
|
$content.= "RewriteRule ^.well-known/carddav /remote.php/carddav/ [R]\n";
|
||||||
$content.= "RewriteRule ^.well-known/caldav /remote.php/caldav/ [R]\n";
|
$content.= "RewriteRule ^.well-known/caldav /remote.php/caldav/ [R]\n";
|
||||||
$content.= "RewriteRule ^apps/([^/]*)/(.*\.(css|php))$ index.php?app=$1&getfile=$2 [QSA,L]\n";
|
$content.= "RewriteRule ^apps/([^/]*)/(.*\.(php))$ index.php?app=$1&getfile=$2 [QSA,L]\n";
|
||||||
$content.= "RewriteRule ^remote/(.*) remote.php [QSA,L]\n";
|
$content.= "RewriteRule ^remote/(.*) remote.php [QSA,L]\n";
|
||||||
$content.= "</IfModule>\n";
|
$content.= "</IfModule>\n";
|
||||||
$content.= "<IfModule mod_mime.c>\n";
|
$content.= "<IfModule mod_mime.c>\n";
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Base {
|
||||||
/**
|
/**
|
||||||
* @brief Assign variables
|
* @brief Assign variables
|
||||||
* @param string $key key
|
* @param string $key key
|
||||||
* @param string $value value
|
* @param array|bool|integer|string $value value
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* This function assigns a variable. It can be accessed via $_[$key] in
|
* This function assigns a variable. It can be accessed via $_[$key] in
|
||||||
|
|
|
@ -1250,7 +1250,21 @@ class Share {
|
||||||
// Remove root from file source paths if retrieving own shared items
|
// Remove root from file source paths if retrieving own shared items
|
||||||
if (isset($uidOwner) && isset($row['path'])) {
|
if (isset($uidOwner) && isset($row['path'])) {
|
||||||
if (isset($row['parent'])) {
|
if (isset($row['parent'])) {
|
||||||
$row['path'] = '/Shared/'.basename($row['path']);
|
$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
|
||||||
|
$parentResult = $query->execute(array($row['parent']));
|
||||||
|
if (\OC_DB::isError($result)) {
|
||||||
|
\OC_Log::write('OCP\Share', 'Can\'t select parent: ' .
|
||||||
|
\OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where,
|
||||||
|
\OC_Log::ERROR);
|
||||||
|
} else {
|
||||||
|
$parentRow = $parentResult->fetchRow();
|
||||||
|
$splitPath = explode('/', $row['path']);
|
||||||
|
$tmpPath = '/Shared' . $parentRow['file_target'];
|
||||||
|
foreach (array_slice($splitPath, 2) as $pathPart) {
|
||||||
|
$tmpPath = $tmpPath . '/' . $pathPart;
|
||||||
|
}
|
||||||
|
$row['path'] = $tmpPath;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isset($mounts[$row['storage']])) {
|
if (!isset($mounts[$row['storage']])) {
|
||||||
$mountPoints = \OC\Files\Filesystem::getMountByNumericId($row['storage']);
|
$mountPoints = \OC\Files\Filesystem::getMountByNumericId($row['storage']);
|
||||||
|
|
|
@ -21,6 +21,16 @@ $entries=OC_Log_Owncloud::getEntries(3);
|
||||||
$entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3;
|
$entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3;
|
||||||
|
|
||||||
$tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 ));
|
$tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 ));
|
||||||
|
$tmpl->assign('mail_domain', OC_Config::getValue( "mail_domain", '' ));
|
||||||
|
$tmpl->assign('mail_from_address', OC_Config::getValue( "mail_from_address", '' ));
|
||||||
|
$tmpl->assign('mail_smtpmode', OC_Config::getValue( "mail_smtpmode", '' ));
|
||||||
|
$tmpl->assign('mail_smtpsecure', OC_Config::getValue( "mail_smtpsecure", '' ));
|
||||||
|
$tmpl->assign('mail_smtphost', OC_Config::getValue( "mail_smtphost", '' ));
|
||||||
|
$tmpl->assign('mail_smtpport', OC_Config::getValue( "mail_smtpport", '' ));
|
||||||
|
$tmpl->assign('mail_smtpauthtype', OC_Config::getValue( "mail_smtpauthtype", '' ));
|
||||||
|
$tmpl->assign('mail_smtpauth', OC_Config::getValue( "mail_smtpauth", false ));
|
||||||
|
$tmpl->assign('mail_smtpname', OC_Config::getValue( "mail_smtpname", '' ));
|
||||||
|
$tmpl->assign('mail_smtppassword', OC_Config::getValue( "mail_smtppassword", '' ));
|
||||||
$tmpl->assign('entries', $entries);
|
$tmpl->assign('entries', $entries);
|
||||||
$tmpl->assign('entriesremain', $entriesremain);
|
$tmpl->assign('entriesremain', $entriesremain);
|
||||||
$tmpl->assign('htaccessworking', $htaccessworking);
|
$tmpl->assign('htaccessworking', $htaccessworking);
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Joas Schilling
|
||||||
|
* @copyright 2014 Joas Schilling nickvergessen@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 OC\Settings\Admin;
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
/**
|
||||||
|
* Set mail settings
|
||||||
|
*/
|
||||||
|
public static function setMailSettings() {
|
||||||
|
\OC_Util::checkAdminUser();
|
||||||
|
\OCP\JSON::callCheck();
|
||||||
|
|
||||||
|
$l = \OC_L10N::get('settings');
|
||||||
|
|
||||||
|
$smtp_settings = array(
|
||||||
|
'mail_domain' => null,
|
||||||
|
'mail_from_address' => null,
|
||||||
|
'mail_smtpmode' => array('sendmail', 'smtp', 'qmail', 'php'),
|
||||||
|
'mail_smtpsecure' => array('', 'ssl', 'tls'),
|
||||||
|
'mail_smtphost' => null,
|
||||||
|
'mail_smtpport' => null,
|
||||||
|
'mail_smtpauthtype' => array('LOGIN', 'PLAIN', 'NTLM'),
|
||||||
|
'mail_smtpauth' => true,
|
||||||
|
'mail_smtpname' => null,
|
||||||
|
'mail_smtppassword' => null,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($smtp_settings as $setting => $validate) {
|
||||||
|
if (!$validate) {
|
||||||
|
if (!isset($_POST[$setting]) || $_POST[$setting] === '') {
|
||||||
|
\OC_Config::deleteKey( $setting );
|
||||||
|
} else {
|
||||||
|
\OC_Config::setValue( $setting, $_POST[$setting] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is_bool($validate)) {
|
||||||
|
if (!empty($_POST[$setting])) {
|
||||||
|
\OC_Config::setValue( $setting, (bool) $_POST[$setting] );
|
||||||
|
} else {
|
||||||
|
\OC_Config::deleteKey( $setting );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is_array($validate)) {
|
||||||
|
if (!isset($_POST[$setting]) || $_POST[$setting] === '') {
|
||||||
|
\OC_Config::deleteKey( $setting );
|
||||||
|
} else if (in_array($_POST[$setting], $validate)) {
|
||||||
|
\OC_Config::setValue( $setting, $_POST[$setting] );
|
||||||
|
} else {
|
||||||
|
$message = $l->t('Invalid value supplied for %s', array(self::getFieldname($setting, $l)));
|
||||||
|
\OC_JSON::error( array( "data" => array( "message" => $message)) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
\OC_JSON::success(array("data" => array( "message" => $l->t("Saved") )));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a mail to test the settings
|
||||||
|
*/
|
||||||
|
public static function sendTestMail() {
|
||||||
|
\OC_Util::checkAdminUser();
|
||||||
|
\OCP\JSON::callCheck();
|
||||||
|
|
||||||
|
$l = \OC_L10N::get('settings');
|
||||||
|
$email = \OC_Preferences::getValue(\OC_User::getUser(), 'settings', 'email', '');
|
||||||
|
if (!empty($email)) {
|
||||||
|
$defaults = new \OC_Defaults();
|
||||||
|
|
||||||
|
try {
|
||||||
|
\OC_Mail::send($email, $_POST['user'],
|
||||||
|
$l->t('test email settings'),
|
||||||
|
$l->t('If you received this email, the settings seem to be correct.'),
|
||||||
|
\OCP\Util::getDefaultEmailAddress('no-reply'), $defaults->getName());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$message = $l->t('A problem occurred while sending the e-mail. Please revisit your settings.');
|
||||||
|
\OC_JSON::error( array( "data" => array( "message" => $message)) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
\OC_JSON::success(array("data" => array( "message" => $l->t("Email sent") )));
|
||||||
|
} else {
|
||||||
|
$message = $l->t('You need to set your user email before being able to send test emails.');
|
||||||
|
\OC_JSON::error( array( "data" => array( "message" => $message)) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the field name to use it in error messages
|
||||||
|
*
|
||||||
|
* @param $setting string
|
||||||
|
* @param $l \OC_L10N
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getFieldname($setting, $l) {
|
||||||
|
switch ($setting) {
|
||||||
|
case 'mail_smtpmode':
|
||||||
|
return $l->t( 'Send mode' );
|
||||||
|
case 'mail_smtpsecure':
|
||||||
|
return $l->t( 'Encryption' );
|
||||||
|
case 'mail_smtpauthtype':
|
||||||
|
return $l->t( 'Authentification method' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,6 +24,8 @@ if ($result !== false) {
|
||||||
$successful = false;
|
$successful = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$util->closeEncryptionSession();
|
||||||
|
|
||||||
if ($successful === true) {
|
if ($successful === true) {
|
||||||
\OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully')));
|
\OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully')));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -61,7 +61,12 @@ td.remove { width:1em; padding-right:1em; }
|
||||||
tr:hover>td.password>span, tr:hover>td.displayName>span { margin:0; cursor:pointer; }
|
tr:hover>td.password>span, tr:hover>td.displayName>span { margin:0; cursor:pointer; }
|
||||||
tr:hover>td.remove>a, tr:hover>td.password>img,tr:hover>td.displayName>img, tr:hover>td.quota>img { visibility:visible; cursor:pointer; }
|
tr:hover>td.remove>a, tr:hover>td.password>img,tr:hover>td.displayName>img, tr:hover>td.quota>img { visibility:visible; cursor:pointer; }
|
||||||
tr:hover>td.remove>a { float:right; }
|
tr:hover>td.remove>a { float:right; }
|
||||||
li.selected { background-color:#ddd; }
|
|
||||||
|
li.selected,
|
||||||
|
#leftcontent li.selected {
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
table.grid { width:100%; }
|
table.grid { width:100%; }
|
||||||
#rightcontent { padding-left: 10px; }
|
#rightcontent { padding-left: 10px; }
|
||||||
div.quota {
|
div.quota {
|
||||||
|
@ -150,6 +155,18 @@ span.connectionwarning {color:#933; font-weight:bold; }
|
||||||
input[type=radio] { width:1em; }
|
input[type=radio] { width:1em; }
|
||||||
table.shareAPI td { padding-bottom: 0.8em; }
|
table.shareAPI td { padding-bottom: 0.8em; }
|
||||||
|
|
||||||
|
#mail_settings p label:first-child {
|
||||||
|
display: inline-block;
|
||||||
|
width: 300px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
#mail_settings p select:nth-child(2) {
|
||||||
|
width: 143px;
|
||||||
|
}
|
||||||
|
#mail_smtpport {
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
/* HELP */
|
/* HELP */
|
||||||
.pressed {background-color:#DDD;}
|
.pressed {background-color:#DDD;}
|
||||||
|
|
||||||
|
|
|
@ -34,4 +34,46 @@ $(document).ready(function(){
|
||||||
$('#security').change(function(){
|
$('#security').change(function(){
|
||||||
$.post(OC.filePath('settings','ajax','setsecurity.php'), { enforceHTTPS: $('#forcessl').val() },function(){} );
|
$.post(OC.filePath('settings','ajax','setsecurity.php'), { enforceHTTPS: $('#forcessl').val() },function(){} );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#mail_smtpauth').change(function() {
|
||||||
|
if (!this.checked) {
|
||||||
|
$('#mail_credentials').addClass('hidden');
|
||||||
|
} else {
|
||||||
|
$('#mail_credentials').removeClass('hidden');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#mail_smtpmode').change(function() {
|
||||||
|
if ($(this).val() !== 'smtp') {
|
||||||
|
$('#setting_smtpauth').addClass('hidden');
|
||||||
|
$('#setting_smtphost').addClass('hidden');
|
||||||
|
$('#mail_smtpsecure_label').addClass('hidden');
|
||||||
|
$('#mail_smtpsecure').addClass('hidden');
|
||||||
|
$('#mail_credentials').addClass('hidden');
|
||||||
|
} else {
|
||||||
|
$('#setting_smtpauth').removeClass('hidden');
|
||||||
|
$('#setting_smtphost').removeClass('hidden');
|
||||||
|
$('#mail_smtpsecure_label').removeClass('hidden');
|
||||||
|
$('#mail_smtpsecure').removeClass('hidden');
|
||||||
|
if ($('#mail_smtpauth').attr('checked')) {
|
||||||
|
$('#mail_credentials').removeClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#mail_settings').change(function(){
|
||||||
|
OC.msg.startSaving('#mail_settings_msg');
|
||||||
|
var post = $( "#mail_settings" ).serialize();
|
||||||
|
$.post(OC.Router.generate('settings_mail_settings'), post, function(data){
|
||||||
|
OC.msg.finishedSaving('#mail_settings_msg', data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#sendtestemail').click(function(){
|
||||||
|
OC.msg.startAction('#sendtestmail_msg', t('settings', 'Sending...'));
|
||||||
|
var post = $( "#sendtestemail" ).serialize();
|
||||||
|
$.post(OC.Router.generate('settings_admin_mail_test'), post, function(data){
|
||||||
|
OC.msg.finishedAction('#sendtestmail_msg', data);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -207,12 +207,24 @@ OC.Settings.Apps = OC.Settings.Apps || {
|
||||||
a.prepend(filename);
|
a.prepend(filename);
|
||||||
a.prepend(img);
|
a.prepend(img);
|
||||||
li.append(a);
|
li.append(a);
|
||||||
// append the new app as last item in the list (.push is from sticky footer)
|
|
||||||
|
// append the new app as last item in the list
|
||||||
|
// (.push is from sticky footer)
|
||||||
$('#apps .wrapper .push').before(li);
|
$('#apps .wrapper .push').before(li);
|
||||||
// scroll the app navigation down so the newly added app is seen
|
|
||||||
$('#navigation').animate({ scrollTop: $('#navigation').height() }, 'slow');
|
// scroll the app navigation down
|
||||||
// draw attention to the newly added app entry by flashing it twice
|
// so the newly added app is seen
|
||||||
container.children('li[data-id="'+entry.id+'"]').animate({opacity:.3}).animate({opacity:1}).animate({opacity:.3}).animate({opacity:1});
|
$('#navigation').animate({
|
||||||
|
scrollTop: $('#navigation').height()
|
||||||
|
}, 'slow');
|
||||||
|
|
||||||
|
// draw attention to the newly added app entry
|
||||||
|
// by flashing it twice
|
||||||
|
container.children('li[data-id="' + entry.id + '"]')
|
||||||
|
.animate({opacity: 0.3})
|
||||||
|
.animate({opacity: 1})
|
||||||
|
.animate({opacity: 0.3})
|
||||||
|
.animate({opacity: 1});
|
||||||
|
|
||||||
if (!SVGSupport() && entry.icon.match(/\.svg$/i)) {
|
if (!SVGSupport() && entry.icon.match(/\.svg$/i)) {
|
||||||
$(img).addClass('svg');
|
$(img).addClass('svg');
|
||||||
|
@ -248,6 +260,8 @@ $(document).ready(function(){
|
||||||
var item = tgt.is('li') ? $(tgt) : $(tgt).parent();
|
var item = tgt.is('li') ? $(tgt) : $(tgt).parent();
|
||||||
var app = item.data('app');
|
var app = item.data('app');
|
||||||
OC.Settings.Apps.loadApp(app);
|
OC.Settings.Apps.loadApp(app);
|
||||||
|
$('#leftcontent .selected').removeClass('selected');
|
||||||
|
item.addClass('selected');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -315,25 +315,3 @@ OC.Encryption.msg={
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
OC.msg={
|
|
||||||
startSaving:function(selector){
|
|
||||||
$(selector)
|
|
||||||
.html( t('settings', 'Saving...') )
|
|
||||||
.removeClass('success')
|
|
||||||
.removeClass('error')
|
|
||||||
.stop(true, true)
|
|
||||||
.show();
|
|
||||||
},
|
|
||||||
finishedSaving:function(selector, data){
|
|
||||||
if( data.status === "success" ){
|
|
||||||
$(selector).html( data.data.message )
|
|
||||||
.addClass('success')
|
|
||||||
.stop(true, true)
|
|
||||||
.delay(3000)
|
|
||||||
.fadeOut(900);
|
|
||||||
}else{
|
|
||||||
$(selector).html( data.data.message ).addClass('error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -70,5 +70,11 @@ $this->create('settings_ajax_getlog', '/settings/ajax/getlog.php')
|
||||||
->actionInclude('settings/ajax/getlog.php');
|
->actionInclude('settings/ajax/getlog.php');
|
||||||
$this->create('settings_ajax_setloglevel', '/settings/ajax/setloglevel.php')
|
$this->create('settings_ajax_setloglevel', '/settings/ajax/setloglevel.php')
|
||||||
->actionInclude('settings/ajax/setloglevel.php');
|
->actionInclude('settings/ajax/setloglevel.php');
|
||||||
|
$this->create('settings_mail_settings', '/settings/admin/mailsettings')
|
||||||
|
->post()
|
||||||
|
->action('OC\Settings\Admin\Controller', 'setMailSettings');
|
||||||
|
$this->create('settings_admin_mail_test', '/settings/admin/mailtest')
|
||||||
|
->post()
|
||||||
|
->action('OC\Settings\Admin\Controller', 'sendTestMail');
|
||||||
$this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php')
|
$this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php')
|
||||||
->actionInclude('settings/ajax/setsecurity.php');
|
->actionInclude('settings/ajax/setsecurity.php');
|
||||||
|
|
|
@ -11,6 +11,27 @@ $levelLabels = array(
|
||||||
$l->t( 'Errors and fatal issues' ),
|
$l->t( 'Errors and fatal issues' ),
|
||||||
$l->t( 'Fatal issues only' ),
|
$l->t( 'Fatal issues only' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$mail_smtpauthtype = array(
|
||||||
|
'' => $l->t('None'),
|
||||||
|
'LOGIN' => $l->t('Login'),
|
||||||
|
'PLAIN' => $l->t('Plain'),
|
||||||
|
'NTLM' => $l->t('NT LAN Manager'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$mail_smtpsecure = array(
|
||||||
|
'' => $l->t('None'),
|
||||||
|
'ssl' => $l->t('SSL'),
|
||||||
|
'tls' => $l->t('TLS'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$mail_smtpmode = array(
|
||||||
|
'sendmail',
|
||||||
|
'smtp',
|
||||||
|
'qmail',
|
||||||
|
'php',
|
||||||
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
@ -250,6 +271,88 @@ if (!$_['internetconnectionworking']) {
|
||||||
</table>
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset id="mail_settings" class="personalblock">
|
||||||
|
<h2><?php p($l->t('Email Server'));?> <span id="mail_settings_msg" class="msg"></span></h2>
|
||||||
|
|
||||||
|
<p><?php p($l->t('This is used for sending out notifications.')); ?></p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="mail_smtpmode"><?php p($l->t( 'Send mode' )); ?></label>
|
||||||
|
<select name='mail_smtpmode' id='mail_smtpmode'>
|
||||||
|
<?php foreach ($mail_smtpmode as $smtpmode):
|
||||||
|
$selected = '';
|
||||||
|
if ($smtpmode == $_['mail_smtpmode']):
|
||||||
|
$selected = 'selected="selected"';
|
||||||
|
endif; ?>
|
||||||
|
<option value='<?php p($smtpmode)?>' <?php p($selected) ?>><?php p($smtpmode) ?></option>
|
||||||
|
<?php endforeach;?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label id="mail_smtpsecure_label" for="mail_smtpsecure"
|
||||||
|
<?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
|
||||||
|
<?php p($l->t( 'Encryption' )); ?>
|
||||||
|
</label>
|
||||||
|
<select name="mail_smtpsecure" id="mail_smtpsecure"
|
||||||
|
<?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
|
||||||
|
<?php foreach ($mail_smtpsecure as $secure => $name):
|
||||||
|
$selected = '';
|
||||||
|
if ($secure == $_['mail_smtpsecure']):
|
||||||
|
$selected = 'selected="selected"';
|
||||||
|
endif; ?>
|
||||||
|
<option value='<?php p($secure)?>' <?php p($selected) ?>><?php p($name) ?></option>
|
||||||
|
<?php endforeach;?>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="mail_from_address"><?php p($l->t( 'From address' )); ?></label>
|
||||||
|
<input type="text" name='mail_from_address' id="mail_from_address" placeholder="<?php p('mail')?>"
|
||||||
|
value='<?php p($_['mail_from_address']) ?>' />
|
||||||
|
@
|
||||||
|
<input type="text" name='mail_domain' id="mail_domain" placeholder="<?php p('example.com')?>"
|
||||||
|
value='<?php p($_['mail_domain']) ?>' />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p id="setting_smtpauth" <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
|
||||||
|
<label for="mail_smtpauthtype"><?php p($l->t( 'Authentification method' )); ?></label>
|
||||||
|
<select name='mail_smtpauthtype' id='mail_smtpauthtype'>
|
||||||
|
<?php foreach ($mail_smtpauthtype as $authtype => $name):
|
||||||
|
$selected = '';
|
||||||
|
if ($authtype == $_['mail_smtpauthtype']):
|
||||||
|
$selected = 'selected="selected"';
|
||||||
|
endif; ?>
|
||||||
|
<option value='<?php p($authtype)?>' <?php p($selected) ?>><?php p($name) ?></option>
|
||||||
|
<?php endforeach;?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" value="1"
|
||||||
|
<?php if ($_['mail_smtpauth']) print_unescaped('checked="checked"'); ?> />
|
||||||
|
<label for="mail_smtpauth"><?php p($l->t( 'Authentication required' )); ?></label>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p id="setting_smtphost" <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
|
||||||
|
<label for="mail_smtphost"><?php p($l->t( 'Server address' )); ?></label>
|
||||||
|
<input type="text" name='mail_smtphost' id="mail_smtphost" placeholder="<?php p('smtp.example.com')?>"
|
||||||
|
value='<?php p($_['mail_smtphost']) ?>' />
|
||||||
|
:
|
||||||
|
<input type="text" name='mail_smtpport' id="mail_smtpport" placeholder="<?php p($l->t('Port'))?>"
|
||||||
|
value='<?php p($_['mail_smtpport']) ?>' />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p id="mail_credentials" <?php if (!$_['mail_smtpauth'] || $_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
|
||||||
|
<label for="mail_smtpname"><?php p($l->t( 'Credentials' )); ?></label>
|
||||||
|
<input type="text" name='mail_smtpname' id="mail_smtpname" placeholder="<?php p($l->t('SMTP Username'))?>"
|
||||||
|
value='<?php p($_['mail_smtpname']) ?>' />
|
||||||
|
<input type="password" name='mail_smtppassword' id="mail_smtppassword"
|
||||||
|
placeholder="<?php p($l->t('SMTP Password'))?>" value='<?php p($_['mail_smtppassword']) ?>' />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<em><?php p($l->t( 'Test email settings' )); ?></em>
|
||||||
|
<input type="submit" name="sendtestemail" id="sendtestemail" value="<?php p($l->t( 'Send email' )); ?>"/>
|
||||||
|
<span id="sendtestmail_msg" class="msg"></span>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="personalblock">
|
<fieldset class="personalblock">
|
||||||
<h2><?php p($l->t('Log'));?></h2>
|
<h2><?php p($l->t('Log'));?></h2>
|
||||||
<?php p($l->t('Log level'));?> <select name='loglevel' id='loglevel'>
|
<?php p($l->t('Log level'));?> <select name='loglevel' id='loglevel'>
|
||||||
|
|
|
@ -83,7 +83,7 @@ if($_['passwordChangeSupported']) {
|
||||||
placeholder="<?php p($l->t('Your email address'));?>"
|
placeholder="<?php p($l->t('Your email address'));?>"
|
||||||
autocomplete="on" autocapitalize="off" autocorrect="off" />
|
autocomplete="on" autocapitalize="off" autocorrect="off" />
|
||||||
<span class="msg"></span><br />
|
<span class="msg"></span><br />
|
||||||
<em><?php p($l->t('Fill in an email address to enable password recovery'));?></em>
|
<em><?php p($l->t('Fill in an email address to enable password recovery and receive notifications'));?></em>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
|
@ -108,7 +108,7 @@ if($_['passwordChangeSupported']) {
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div id="cropper" class="hidden">
|
<div id="cropper" class="hidden">
|
||||||
<div class="inlineblock button" id="abortcropperbutton"><?php p($l->t('Abort')); ?></div>
|
<div class="inlineblock button" id="abortcropperbutton"><?php p($l->t('Cancel')); ?></div>
|
||||||
<div class="inlineblock button primary" id="sendcropperbutton"><?php p($l->t('Choose as profile image')); ?></div>
|
<div class="inlineblock button primary" id="sendcropperbutton"><?php p($l->t('Choose as profile image')); ?></div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
@ -223,4 +223,19 @@
|
||||||
</declaration>
|
</declaration>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<name>*dbprefix*migratekeyword</name>
|
||||||
|
|
||||||
|
<declaration>
|
||||||
|
|
||||||
|
<field>
|
||||||
|
<name>select</name>
|
||||||
|
<type>text</type>
|
||||||
|
<default></default>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<length>255</length>
|
||||||
|
</field>
|
||||||
|
</declaration>
|
||||||
|
</table>
|
||||||
|
|
||||||
</database>
|
</database>
|
||||||
|
|
|
@ -119,4 +119,19 @@
|
||||||
</declaration>
|
</declaration>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<name>*dbprefix*migratekeyword</name>
|
||||||
|
|
||||||
|
<declaration>
|
||||||
|
|
||||||
|
<field>
|
||||||
|
<name>select</name>
|
||||||
|
<type>text</type>
|
||||||
|
<default></default>
|
||||||
|
<notnull>false</notnull>
|
||||||
|
<length>255</length>
|
||||||
|
</field>
|
||||||
|
</declaration>
|
||||||
|
</table>
|
||||||
|
|
||||||
</database>
|
</database>
|
||||||
|
|
|
@ -78,7 +78,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testGetEtag() {
|
public function testGetEtag() {
|
||||||
$this->childResponse->setEtag('hi');
|
$this->childResponse->setEtag('hi');
|
||||||
$this->assertEquals('hi', $this->childResponse->getEtag());
|
$this->assertSame('hi', $this->childResponse->getEtag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,13 +150,15 @@ class Scanner extends \PHPUnit_Framework_TestCase {
|
||||||
$this->cache->put('folder', array('mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder')));
|
$this->cache->put('folder', array('mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder')));
|
||||||
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE);
|
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE);
|
||||||
$newData = $this->cache->get('');
|
$newData = $this->cache->get('');
|
||||||
$this->assertNotEquals($oldData['etag'], $newData['etag']);
|
$this->assertInternalType('string', $oldData['etag']);
|
||||||
|
$this->assertInternalType('string', $newData['etag']);
|
||||||
|
$this->assertNotSame($oldData['etag'], $newData['etag']);
|
||||||
$this->assertEquals($oldData['size'], $newData['size']);
|
$this->assertEquals($oldData['size'], $newData['size']);
|
||||||
|
|
||||||
$oldData = $newData;
|
$oldData = $newData;
|
||||||
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG);
|
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG);
|
||||||
$newData = $this->cache->get('');
|
$newData = $this->cache->get('');
|
||||||
$this->assertEquals($oldData['etag'], $newData['etag']);
|
$this->assertSame($oldData['etag'], $newData['etag']);
|
||||||
$this->assertEquals(-1, $newData['size']);
|
$this->assertEquals(-1, $newData['size']);
|
||||||
|
|
||||||
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE);
|
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE);
|
||||||
|
@ -164,17 +166,17 @@ class Scanner extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertNotEquals(-1, $oldData['size']);
|
$this->assertNotEquals(-1, $oldData['size']);
|
||||||
$this->scanner->scanFile('', \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
|
$this->scanner->scanFile('', \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
|
||||||
$newData = $this->cache->get('');
|
$newData = $this->cache->get('');
|
||||||
$this->assertEquals($oldData['etag'], $newData['etag']);
|
$this->assertSame($oldData['etag'], $newData['etag']);
|
||||||
$this->assertEquals($oldData['size'], $newData['size']);
|
$this->assertEquals($oldData['size'], $newData['size']);
|
||||||
|
|
||||||
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
|
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
|
||||||
$newData = $this->cache->get('');
|
$newData = $this->cache->get('');
|
||||||
$this->assertEquals($oldData['etag'], $newData['etag']);
|
$this->assertSame($oldData['etag'], $newData['etag']);
|
||||||
$this->assertEquals($oldData['size'], $newData['size']);
|
$this->assertEquals($oldData['size'], $newData['size']);
|
||||||
|
|
||||||
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
|
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
|
||||||
$newData = $this->cache->get('');
|
$newData = $this->cache->get('');
|
||||||
$this->assertEquals($oldData['etag'], $newData['etag']);
|
$this->assertSame($oldData['etag'], $newData['etag']);
|
||||||
$this->assertEquals($oldData['size'], $newData['size']);
|
$this->assertEquals($oldData['size'], $newData['size']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,8 +219,11 @@ class Scanner extends \PHPUnit_Framework_TestCase {
|
||||||
// manipulate etag to simulate an empty etag
|
// manipulate etag to simulate an empty etag
|
||||||
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG);
|
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG);
|
||||||
$data0 = $this->cache->get('folder/bar.txt');
|
$data0 = $this->cache->get('folder/bar.txt');
|
||||||
|
$this->assertInternalType('string', $data0['etag']);
|
||||||
$data1 = $this->cache->get('folder');
|
$data1 = $this->cache->get('folder');
|
||||||
|
$this->assertInternalType('string', $data1['etag']);
|
||||||
$data2 = $this->cache->get('');
|
$data2 = $this->cache->get('');
|
||||||
|
$this->assertInternalType('string', $data2['etag']);
|
||||||
$data0['etag'] = '';
|
$data0['etag'] = '';
|
||||||
$this->cache->put('folder/bar.txt', $data0);
|
$this->cache->put('folder/bar.txt', $data0);
|
||||||
|
|
||||||
|
@ -227,10 +232,15 @@ class Scanner extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
// verify cache content
|
// verify cache content
|
||||||
$newData0 = $this->cache->get('folder/bar.txt');
|
$newData0 = $this->cache->get('folder/bar.txt');
|
||||||
$newData1 = $this->cache->get('folder');
|
$this->assertInternalType('string', $newData0['etag']);
|
||||||
$newData2 = $this->cache->get('');
|
|
||||||
$this->assertNotEmpty($newData0['etag']);
|
$this->assertNotEmpty($newData0['etag']);
|
||||||
$this->assertNotEquals($data1['etag'], $newData1['etag']);
|
|
||||||
$this->assertNotEquals($data2['etag'], $newData2['etag']);
|
$newData1 = $this->cache->get('folder');
|
||||||
|
$this->assertInternalType('string', $newData1['etag']);
|
||||||
|
$this->assertNotSame($data1['etag'], $newData1['etag']);
|
||||||
|
|
||||||
|
$newData2 = $this->cache->get('');
|
||||||
|
$this->assertInternalType('string', $newData2['etag']);
|
||||||
|
$this->assertNotSame($data2['etag'], $newData2['etag']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,10 +96,14 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
Filesystem::file_put_contents('foo.txt', 'asd');
|
Filesystem::file_put_contents('foo.txt', 'asd');
|
||||||
$cachedData = $this->cache->get('foo.txt');
|
$cachedData = $this->cache->get('foo.txt');
|
||||||
$this->assertEquals(3, $cachedData['size']);
|
$this->assertEquals(3, $cachedData['size']);
|
||||||
$this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $fooCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($fooCachedData['etag'], $cachedData['etag']);
|
||||||
$cachedData = $this->cache->get('');
|
$cachedData = $this->cache->get('');
|
||||||
$this->assertEquals(2 * $textSize + $imageSize + 3, $cachedData['size']);
|
$this->assertEquals(2 * $textSize + $imageSize + 3, $cachedData['size']);
|
||||||
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $rootCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
||||||
$rootCachedData = $cachedData;
|
$rootCachedData = $cachedData;
|
||||||
|
|
||||||
$this->assertFalse($this->cache->inCache('bar.txt'));
|
$this->assertFalse($this->cache->inCache('bar.txt'));
|
||||||
|
@ -110,12 +114,15 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$mtime = $cachedData['mtime'];
|
$mtime = $cachedData['mtime'];
|
||||||
$cachedData = $this->cache->get('');
|
$cachedData = $this->cache->get('');
|
||||||
$this->assertEquals(2 * $textSize + $imageSize + 2 * 3, $cachedData['size']);
|
$this->assertEquals(2 * $textSize + $imageSize + 2 * 3, $cachedData['size']);
|
||||||
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $rootCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $mtime);
|
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $mtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWriteWithMountPoints() {
|
public function testWriteWithMountPoints() {
|
||||||
$storage2 = new \OC\Files\Storage\Temporary(array());
|
$storage2 = new \OC\Files\Storage\Temporary(array());
|
||||||
|
$storage2->getScanner()->scan(''); //initialize etags
|
||||||
$cache2 = $storage2->getCache();
|
$cache2 = $storage2->getCache();
|
||||||
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
|
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
|
||||||
$folderCachedData = $this->cache->get('folder');
|
$folderCachedData = $this->cache->get('folder');
|
||||||
|
@ -127,11 +134,15 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$mtime = $cachedData['mtime'];
|
$mtime = $cachedData['mtime'];
|
||||||
|
|
||||||
$cachedData = $cache2->get('');
|
$cachedData = $cache2->get('');
|
||||||
$this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $substorageCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertEquals($mtime, $cachedData['mtime']);
|
$this->assertEquals($mtime, $cachedData['mtime']);
|
||||||
|
|
||||||
$cachedData = $this->cache->get('folder');
|
$cachedData = $this->cache->get('folder');
|
||||||
$this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $folderCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertEquals($mtime, $cachedData['mtime']);
|
$this->assertEquals($mtime, $cachedData['mtime']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,19 +157,25 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertFalse($this->cache->inCache('foo.txt'));
|
$this->assertFalse($this->cache->inCache('foo.txt'));
|
||||||
$cachedData = $this->cache->get('');
|
$cachedData = $this->cache->get('');
|
||||||
$this->assertEquals(2 * $textSize + $imageSize, $cachedData['size']);
|
$this->assertEquals(2 * $textSize + $imageSize, $cachedData['size']);
|
||||||
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $rootCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
||||||
$rootCachedData = $cachedData;
|
$rootCachedData = $cachedData;
|
||||||
|
|
||||||
Filesystem::mkdir('bar_folder');
|
Filesystem::mkdir('bar_folder');
|
||||||
$this->assertTrue($this->cache->inCache('bar_folder'));
|
$this->assertTrue($this->cache->inCache('bar_folder'));
|
||||||
$cachedData = $this->cache->get('');
|
$cachedData = $this->cache->get('');
|
||||||
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $rootCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
||||||
$rootCachedData = $cachedData;
|
$rootCachedData = $cachedData;
|
||||||
Filesystem::rmdir('bar_folder');
|
Filesystem::rmdir('bar_folder');
|
||||||
$this->assertFalse($this->cache->inCache('bar_folder'));
|
$this->assertFalse($this->cache->inCache('bar_folder'));
|
||||||
$cachedData = $this->cache->get('');
|
$cachedData = $this->cache->get('');
|
||||||
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $rootCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,11 +191,15 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertFalse($cache2->inCache('foo.txt'));
|
$this->assertFalse($cache2->inCache('foo.txt'));
|
||||||
|
|
||||||
$cachedData = $cache2->get('');
|
$cachedData = $cache2->get('');
|
||||||
$this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $substorageCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']);
|
$this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']);
|
||||||
|
|
||||||
$cachedData = $this->cache->get('folder');
|
$cachedData = $this->cache->get('folder');
|
||||||
$this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $folderCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertGreaterThanOrEqual($folderCachedData['mtime'], $cachedData['mtime']);
|
$this->assertGreaterThanOrEqual($folderCachedData['mtime'], $cachedData['mtime']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +220,9 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$mtime = $cachedData['mtime'];
|
$mtime = $cachedData['mtime'];
|
||||||
$cachedData = $this->cache->get('');
|
$cachedData = $this->cache->get('');
|
||||||
$this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
|
$this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
|
||||||
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $rootCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRenameExtension() {
|
public function testRenameExtension() {
|
||||||
|
@ -227,12 +250,16 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$mtime = $cachedData['mtime'];
|
$mtime = $cachedData['mtime'];
|
||||||
|
|
||||||
$cachedData = $cache2->get('');
|
$cachedData = $cache2->get('');
|
||||||
$this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $substorageCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
|
||||||
// rename can cause mtime change - invalid assert
|
// rename can cause mtime change - invalid assert
|
||||||
// $this->assertEquals($mtime, $cachedData['mtime']);
|
// $this->assertEquals($mtime, $cachedData['mtime']);
|
||||||
|
|
||||||
$cachedData = $this->cache->get('folder');
|
$cachedData = $this->cache->get('folder');
|
||||||
$this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $folderCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
|
||||||
// rename can cause mtime change - invalid assert
|
// rename can cause mtime change - invalid assert
|
||||||
// $this->assertEquals($mtime, $cachedData['mtime']);
|
// $this->assertEquals($mtime, $cachedData['mtime']);
|
||||||
}
|
}
|
||||||
|
@ -242,11 +269,15 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$fooCachedData = $this->cache->get('foo.txt');
|
$fooCachedData = $this->cache->get('foo.txt');
|
||||||
Filesystem::touch('foo.txt');
|
Filesystem::touch('foo.txt');
|
||||||
$cachedData = $this->cache->get('foo.txt');
|
$cachedData = $this->cache->get('foo.txt');
|
||||||
$this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $fooCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($fooCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertGreaterThanOrEqual($fooCachedData['mtime'], $cachedData['mtime']);
|
$this->assertGreaterThanOrEqual($fooCachedData['mtime'], $cachedData['mtime']);
|
||||||
|
|
||||||
$cachedData = $this->cache->get('');
|
$cachedData = $this->cache->get('');
|
||||||
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $rootCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
||||||
$rootCachedData = $cachedData;
|
$rootCachedData = $cachedData;
|
||||||
|
|
||||||
|
@ -255,14 +286,20 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$folderCachedData = $this->cache->get('folder');
|
$folderCachedData = $this->cache->get('folder');
|
||||||
Filesystem::touch('folder/bar.txt', $time);
|
Filesystem::touch('folder/bar.txt', $time);
|
||||||
$cachedData = $this->cache->get('folder/bar.txt');
|
$cachedData = $this->cache->get('folder/bar.txt');
|
||||||
$this->assertNotEquals($barCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $barCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($barCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertEquals($time, $cachedData['mtime']);
|
$this->assertEquals($time, $cachedData['mtime']);
|
||||||
|
|
||||||
$cachedData = $this->cache->get('folder');
|
$cachedData = $this->cache->get('folder');
|
||||||
$this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $folderCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
|
||||||
|
|
||||||
$cachedData = $this->cache->get('');
|
$cachedData = $this->cache->get('');
|
||||||
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $rootCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertEquals($time, $cachedData['mtime']);
|
$this->assertEquals($time, $cachedData['mtime']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,14 +316,20 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
||||||
$time = 1371006070;
|
$time = 1371006070;
|
||||||
Filesystem::touch('folder/substorage/foo.txt', $time);
|
Filesystem::touch('folder/substorage/foo.txt', $time);
|
||||||
$cachedData = $cache2->get('foo.txt');
|
$cachedData = $cache2->get('foo.txt');
|
||||||
$this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $fooCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($fooCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertEquals($time, $cachedData['mtime']);
|
$this->assertEquals($time, $cachedData['mtime']);
|
||||||
|
|
||||||
$cachedData = $cache2->get('');
|
$cachedData = $cache2->get('');
|
||||||
$this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $substorageCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
|
||||||
|
|
||||||
$cachedData = $this->cache->get('folder');
|
$cachedData = $this->cache->get('folder');
|
||||||
$this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
|
$this->assertInternalType('string', $folderCachedData['etag']);
|
||||||
|
$this->assertInternalType('string', $cachedData['etag']);
|
||||||
|
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
|
||||||
$this->assertEquals($time, $cachedData['mtime']);
|
$this->assertEquals($time, $cachedData['mtime']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,11 @@ class EtagTest extends \PHPUnit_Framework_TestCase {
|
||||||
$scanner = new \OC\Files\Utils\Scanner($user1);
|
$scanner = new \OC\Files\Utils\Scanner($user1);
|
||||||
$scanner->backgroundScan('/');
|
$scanner->backgroundScan('/');
|
||||||
|
|
||||||
$this->assertEquals($originalEtags, $this->getEtags($files));
|
$newEtags = $this->getEtags($files);
|
||||||
|
// loop over array and use assertSame over assertEquals to prevent false positives
|
||||||
|
foreach ($originalEtags as $file => $originalEtag) {
|
||||||
|
$this->assertSame($originalEtag, $newEtags[$file]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -563,6 +563,6 @@ class View extends \PHPUnit_Framework_TestCase {
|
||||||
$scanner->scanFile('test', \OC\Files\Cache\Scanner::REUSE_ETAG);
|
$scanner->scanFile('test', \OC\Files\Cache\Scanner::REUSE_ETAG);
|
||||||
|
|
||||||
$info2 = $view->getFileInfo('/test/test');
|
$info2 = $view->getFileInfo('/test/test');
|
||||||
$this->assertEquals($info['etag'], $info2['etag']);
|
$this->assertSame($info['etag'], $info2['etag']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue