Merge branch 'master' of github.com:owncloud/core into fix-unlogged-session-error
This commit is contained in:
commit
14617682c8
13 changed files with 131 additions and 39 deletions
|
@ -110,30 +110,35 @@ if (strpos($dir, '..') === false) {
|
|||
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
|
||||
) {
|
||||
// upload and overwrite file
|
||||
if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
||||
|
||||
// updated max file size after upload
|
||||
$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
|
||||
|
||||
$meta = \OC\Files\Filesystem::getFileInfo($target);
|
||||
if ($meta === false) {
|
||||
$error = $l->t('Upload failed. Could not get file info.');
|
||||
try
|
||||
{
|
||||
if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
||||
|
||||
// updated max file size after upload
|
||||
$storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir);
|
||||
|
||||
$meta = \OC\Files\Filesystem::getFileInfo($target);
|
||||
if ($meta === false) {
|
||||
$error = $l->t('Upload failed. Could not get file info.');
|
||||
} else {
|
||||
$result[] = array('status' => 'success',
|
||||
'mime' => $meta['mimetype'],
|
||||
'mtime' => $meta['mtime'],
|
||||
'size' => $meta['size'],
|
||||
'id' => $meta['fileid'],
|
||||
'name' => basename($target),
|
||||
'originalname' => $files['tmp_name'][$i],
|
||||
'uploadMaxFilesize' => $maxUploadFileSize,
|
||||
'maxHumanFilesize' => $maxHumanFileSize,
|
||||
'permissions' => $meta['permissions'],
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
$result[] = array('status' => 'success',
|
||||
'mime' => $meta['mimetype'],
|
||||
'mtime' => $meta['mtime'],
|
||||
'size' => $meta['size'],
|
||||
'id' => $meta['fileid'],
|
||||
'name' => basename($target),
|
||||
'originalname' => $files['tmp_name'][$i],
|
||||
'uploadMaxFilesize' => $maxUploadFileSize,
|
||||
'maxHumanFilesize' => $maxHumanFileSize,
|
||||
'permissions' => $meta['permissions'],
|
||||
);
|
||||
$error = $l->t('Upload failed. Could not find uploaded file');
|
||||
}
|
||||
|
||||
} else {
|
||||
$error = $l->t('Upload failed. Could not find uploaded file');
|
||||
} catch(Exception $ex) {
|
||||
$error = $ex->getMessage();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -164,5 +169,5 @@ if ($error === false) {
|
|||
OCP\JSON::encodedPrint($result);
|
||||
exit();
|
||||
} else {
|
||||
OCP\JSON::error(array('data' => array_merge(array('message' => $error), $storageStats)));
|
||||
OCP\JSON::error(array(array('data' => array_merge(array('message' => $error), $storageStats))));
|
||||
}
|
||||
|
|
|
@ -174,6 +174,9 @@ table td.filename .nametext {
|
|||
table td.filename .uploadtext { font-weight:normal; margin-left:.5em; }
|
||||
table td.filename form { font-size:.85em; margin-left:3em; margin-right:3em; }
|
||||
|
||||
.ie8 input[type="checkbox"]{
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* File checkboxes */
|
||||
#fileList tr td.filename>input[type="checkbox"]:first-child {
|
||||
|
@ -249,9 +252,7 @@ table td.filename form { font-size:.85em; margin-left:3em; margin-right:3em; }
|
|||
#fileList a.action.delete {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
margin: 0;
|
||||
padding: 15px 14px 19px !important;
|
||||
padding: 9px 14px 19px !important;
|
||||
}
|
||||
a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; }
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ $(document).ready(function() {
|
|||
} else if (result[0].status !== 'success') {
|
||||
//delete data.jqXHR;
|
||||
data.textStatus = 'servererror';
|
||||
data.errorThrown = result.data.message; // error message has been translated on server
|
||||
data.errorThrown = result[0].data.message; // error message has been translated on server
|
||||
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
||||
fu._trigger('fail', e, data);
|
||||
}
|
||||
|
@ -523,8 +523,10 @@ $(document).ready(function() {
|
|||
function(result){
|
||||
if (result.status == 'success') {
|
||||
var date=new Date();
|
||||
FileList.addFile(name,0,date,false,hidden);
|
||||
var tr=$('tr').filterAttr('data-file',name);
|
||||
// TODO: ideally addFile should be able to receive
|
||||
// all attributes and set them automatically,
|
||||
// and also auto-load the preview
|
||||
var tr = FileList.addFile(name,0,date,false,hidden);
|
||||
tr.attr('data-size',result.data.size);
|
||||
tr.attr('data-mime',result.data.mime);
|
||||
tr.attr('data-id', result.data.id);
|
||||
|
@ -533,6 +535,7 @@ $(document).ready(function() {
|
|||
lazyLoadPreview(path, result.data.mime, function(previewpath){
|
||||
tr.find('td.filename').attr('style','background-image:url('+previewpath+')');
|
||||
});
|
||||
FileActions.display(tr.find('td.filename'));
|
||||
} else {
|
||||
OC.dialogs.alert(result.data.message, t('core', 'Error'));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<!--[if IE 8]><style>input[type="checkbox"]{padding:0;}table td{position:static !important;}</style><![endif]-->
|
||||
<div id="controls">
|
||||
<?php print_unescaped($_['breadcrumb']); ?>
|
||||
<div class="actions creatable <?php if (!$_['isCreatable']):?>hidden<?php endif; ?> <?php if (isset($_['files']) and count($_['files'])==0):?>emptycontent<?php endif; ?>">
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<!--[if IE 8]><style>input[type="checkbox"]{padding:0;}table td{position:static !important;}</style><![endif]-->
|
||||
<div id="controls">
|
||||
<?php print_unescaped($_['breadcrumb']); ?>
|
||||
<div id="file_action_panel"></div>
|
||||
|
|
22
lib/private/connector/sabre/exception/entitytoolarge.php
Normal file
22
lib/private/connector/sabre/exception/entitytoolarge.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Entity Too Large
|
||||
*
|
||||
* This exception is thrown whenever a user tries to upload a file which exceeds hard limitations
|
||||
*
|
||||
*/
|
||||
class OC_Connector_Sabre_Exception_EntityTooLarge extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP status code for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
return 413;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Unsupported Media Type
|
||||
*
|
||||
* This exception is thrown whenever a user tries to upload a file which holds content which is not allowed
|
||||
*
|
||||
*/
|
||||
class OC_Connector_Sabre_Exception_UnsupportedMediaType extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP status code for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
return 415;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -98,7 +98,21 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
|
|||
throw new Sabre_DAV_Exception();
|
||||
}
|
||||
} catch (\OCP\Files\NotPermittedException $e) {
|
||||
throw new Sabre_DAV_Exception_Forbidden();
|
||||
// a more general case - due to whatever reason the content could not be written
|
||||
throw new Sabre_DAV_Exception_Forbidden($e->getMessage());
|
||||
|
||||
} catch (\OCP\Files\EntityTooLargeException $e) {
|
||||
// the file is too big to be stored
|
||||
throw new OC_Connector_Sabre_Exception_EntityTooLarge($e->getMessage());
|
||||
|
||||
} catch (\OCP\Files\InvalidContentException $e) {
|
||||
// the file content is not permitted
|
||||
throw new OC_Connector_Sabre_Exception_UnsupportedMediaType($e->getMessage());
|
||||
|
||||
} catch (\OCP\Files\InvalidPathException $e) {
|
||||
// the path for the file was not valid
|
||||
// TODO: find proper http status code for this case
|
||||
throw new Sabre_DAV_Exception_Forbidden($e->getMessage());
|
||||
}
|
||||
|
||||
// rename to correct path
|
||||
|
|
11
lib/public/files/entitytoolargeexception.php
Normal file
11
lib/public/files/entitytoolargeexception.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2013 Thomas Müller <thomas.mueller@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OCP\Files;
|
||||
|
||||
class EntityTooLargeException extends \Exception {}
|
11
lib/public/files/invalidcontentexception.php
Normal file
11
lib/public/files/invalidcontentexception.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2013 Thomas Müller <thomas.mueller@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OCP\Files;
|
||||
|
||||
class InvalidContentException extends \Exception {}
|
11
lib/public/files/invalidpathexception.php
Normal file
11
lib/public/files/invalidpathexception.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2013 Thomas Müller <thomas.mueller@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OCP\Files;
|
||||
|
||||
class InvalidPathException extends \Exception {}
|
|
@ -171,10 +171,6 @@ $(document).ready(function(){
|
|||
}
|
||||
});
|
||||
|
||||
// Show only the not selectable optgroup
|
||||
// Choosen only shows optgroup-labels if there are options in the optgroup
|
||||
$(".languagedivider").hide();
|
||||
|
||||
$("#languageinput").change( function(){
|
||||
// Serialize the data
|
||||
var post = $( "#languageinput" ).serialize();
|
||||
|
|
|
@ -113,9 +113,7 @@ if($_['passwordChangeSupported']) {
|
|||
<?php p($language['name']);?>
|
||||
</option>
|
||||
<?php endforeach;?>
|
||||
<optgroup label="––––––––––">
|
||||
<option class="languagedivider">-</option>
|
||||
</optgroup>
|
||||
<optgroup label="––––––––––"></optgroup>
|
||||
<?php foreach($_['languages'] as $language):?>
|
||||
<option value="<?php p($language['code']);?>">
|
||||
<?php p($language['name']);?>
|
||||
|
|
Loading…
Reference in a new issue