summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-02-05 13:36:55 +0100
committerRobin Appelman <icewind@owncloud.com>2014-02-05 13:36:55 +0100
commit1e79369338e8435952e2eda60a2cfc49bb6c4882 (patch)
tree12d3ac88978887f16e795c54873bbd6b99bb8ee5 /apps
parent3c1ab66edac1ba2f1b398c859cd933c410ea3d8d (diff)
parent3d88b10f201b7979f250b49b10360b3581030ec7 (diff)
downloadnextcloud-server-1e79369338e8435952e2eda60a2cfc49bb6c4882.tar.gz
nextcloud-server-1e79369338e8435952e2eda60a2cfc49bb6c4882.zip
merge master into storagestatistics-reuse
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/newfile.php9
-rw-r--r--apps/files/ajax/newfolder.php9
-rw-r--r--apps/files/ajax/upload.php6
-rw-r--r--apps/files/appinfo/remote.php1
-rw-r--r--apps/files/css/files.css34
-rw-r--r--apps/files/index.php8
-rw-r--r--apps/files/js/admin.js12
-rw-r--r--apps/files/js/file-upload.js37
-rw-r--r--apps/files/js/fileactions.js53
-rw-r--r--apps/files/js/filelist.js32
-rw-r--r--apps/files/js/files.js48
-rw-r--r--apps/files/js/upgrade.js11
-rw-r--r--apps/files/js/upload.js11
-rw-r--r--apps/files/lib/app.php14
-rw-r--r--apps/files/lib/helper.php1
-rw-r--r--apps/files/templates/index.php15
-rw-r--r--apps/files/tests/ajax_rename.php49
-rw-r--r--apps/files/tests/js/fileactionsSpec.js75
-rw-r--r--apps/files/tests/js/filelistSpec.js21
-rw-r--r--apps/files/tests/js/filesSpec.js8
-rw-r--r--apps/files_sharing/css/mobile.css49
-rw-r--r--apps/files_sharing/css/public.css70
-rw-r--r--apps/files_sharing/js/public.js40
-rw-r--r--apps/files_sharing/lib/api.php27
-rw-r--r--apps/files_sharing/public.php9
-rw-r--r--apps/files_sharing/templates/public.php83
-rw-r--r--apps/files_trashbin/ajax/preview.php14
-rw-r--r--apps/user_ldap/lib/connection.php2
28 files changed, 532 insertions, 216 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index ec5b716fb2a..1853098c507 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -64,6 +64,15 @@ if(strpos($filename, '/') !== false) {
exit();
}
+if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
+ $result['data'] = array('message' => (string)$l10n->t(
+ 'The target folder has been moved or deleted.'),
+ 'code' => 'targetnotfound'
+ );
+ OCP\JSON::error($result);
+ exit();
+}
+
//TODO why is stripslashes used on foldername in newfolder.php but not here?
$target = $dir.'/'.$filename;
diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php
index 2cbc8cfeba5..4cfcae3090d 100644
--- a/apps/files/ajax/newfolder.php
+++ b/apps/files/ajax/newfolder.php
@@ -29,6 +29,15 @@ if(strpos($foldername, '/') !== false) {
exit();
}
+if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
+ $result['data'] = array('message' => (string)$l10n->t(
+ 'The target folder has been moved or deleted.'),
+ 'code' => 'targetnotfound'
+ );
+ OCP\JSON::error($result);
+ exit();
+}
+
//TODO why is stripslashes used on foldername here but not in newfile.php?
$target = $dir . '/' . stripslashes($foldername);
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index bdaf6a77d14..8f6c42d6620 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -8,6 +8,7 @@ OCP\JSON::setContentTypeHeader('text/plain');
// If no token is sent along, rely on login only
$allowedPermissions = OCP\PERMISSION_ALL;
+$errorCode = null;
$l = OC_L10N::get('files');
if (empty($_POST['dirToken'])) {
@@ -125,7 +126,8 @@ if (strpos($dir, '..') === false) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
if ($meta === false) {
- $error = $l->t('Upload failed. Could not get file info.');
+ $error = $l->t('The target folder has been moved or deleted.');
+ $errorCode = 'targetnotfound';
} else {
$result[] = array('status' => 'success',
'mime' => $meta['mimetype'],
@@ -177,5 +179,5 @@ if ($error === false) {
OCP\JSON::encodedPrint($result);
exit();
} else {
- OCP\JSON::error(array(array('data' => array_merge(array('message' => $error), $storageStats))));
+ OCP\JSON::error(array(array('data' => array_merge(array('message' => $error, 'code' => $errorCode), $storageStats))));
}
diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php
index 9f290796205..ef22fe92188 100644
--- a/apps/files/appinfo/remote.php
+++ b/apps/files/appinfo/remote.php
@@ -52,6 +52,7 @@ $server->addPlugin(new OC_Connector_Sabre_FilesPlugin());
$server->addPlugin(new OC_Connector_Sabre_AbortedUploadDetectionPlugin());
$server->addPlugin(new OC_Connector_Sabre_QuotaPlugin());
$server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin());
+$server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('webdav'));
// And off we go!
$server->exec();
diff --git a/apps/files/css/files.css b/apps/files/css/files.css
index 16ee2b9bca0..5526abaf6e2 100644
--- a/apps/files/css/files.css
+++ b/apps/files/css/files.css
@@ -65,10 +65,15 @@
top: 44px;
width: 100%;
}
-#filestable tbody tr { background-color:#fff; height:40px; }
-#filestable, #controls {
- min-width: 680px;
+/* make sure there's enough room for the file actions */
+#body-user #filestable {
+ min-width: 750px;
+}
+#body-user #controls {
+ min-width: 600px;
}
+
+#filestable tbody tr { background-color:#fff; height:40px; }
#filestable tbody tr:hover, tbody tr:active {
background-color: rgb(240,240,240);
}
@@ -98,7 +103,7 @@ table td {
}
table th#headerName {
position: relative;
- width: 100em; /* not really sure why this works better than 100% … table styling */
+ width: 9999px; /* not really sure why this works better than 100% … table styling */
padding: 0;
}
#headerName-container {
@@ -114,7 +119,9 @@ table th#headerDate, table td.date {
-moz-box-sizing: border-box;
box-sizing: border-box;
position: relative;
+ /* this can not be just width, both need to be set … table styling */
min-width: 176px;
+ max-width: 176px;
}
/* Multiselect bar */
@@ -140,7 +147,7 @@ table.multiselect thead th {
}
table.multiselect #headerName {
position: relative;
- width: 100%;
+ width: 9999px; /* when we use 100%, the styling breaks on mobile … table styling */
}
table td.selection, table th.selection, table td.fileaction { width:32px; text-align:center; }
table td.filename a.name {
@@ -169,6 +176,15 @@ table td.filename .nametext, .uploadtext, .modified { float:left; padding:14px 0
}
.modified {
position: relative;
+ padding-left: 8px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ width: 90%;
+}
+/* ellipsize long modified dates to make room for showing delete button */
+#fileList tr:hover .modified,
+#fileList tr:focus .modified {
+ width: 75%;
}
/* TODO fix usability bug (accidental file/folder selection) */
@@ -242,7 +258,7 @@ table td.filename form { font-size:14px; margin-left:48px; margin-right:48px; }
#fileList tr td.filename a.name label {
position: absolute;
- width: 100%;
+ width: 80%;
height: 50px;
}
@@ -253,6 +269,7 @@ table td.filename form { font-size:14px; margin-left:48px; margin-right:48px; }
position: absolute;
top: 14px;
right: 0;
+ font-size: 11px;
}
#fileList img.move2trash { display:inline; margin:-8px 0; padding:16px 8px 16px 8px !important; float:right; }
@@ -261,6 +278,7 @@ table td.filename form { font-size:14px; margin-left:48px; margin-right:48px; }
right: 0;
padding: 28px 14px 19px !important;
}
+
a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; }
/* Actions for selected files */
@@ -290,6 +308,10 @@ a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; }
opacity: 0;
display:none;
}
+
+#fileList a.action[data-action="Rename"] {
+ padding:18px 14px !important;
+}
#fileList tr:hover a.action, #fileList a.action.permanent {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
diff --git a/apps/files/index.php b/apps/files/index.php
index 8f6838aa0d9..dd63f29bc28 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -63,7 +63,6 @@ $files = array();
$user = OC_User::getUser();
if (\OC\Files\Cache\Upgrade::needUpgrade($user)) { //dont load anything if we need to upgrade the cache
$needUpgrade = true;
- $freeSpace = 0;
} else {
if ($isIE8){
// after the redirect above, the URL will have a format
@@ -77,7 +76,6 @@ if (\OC\Files\Cache\Upgrade::needUpgrade($user)) { //dont load anything if we ne
else{
$files = \OCA\Files\Helper::getFiles($dir);
}
- $freeSpace = \OC\Files\Filesystem::free_space($dir);
$needUpgrade = false;
}
@@ -103,6 +101,8 @@ if ($needUpgrade) {
} else {
// information about storage capacities
$storageInfo=OC_Helper::getStorageInfo($dir);
+ $freeSpace=$storageInfo['free'];
+ $uploadLimit=OCP\Util::uploadLimit();
$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
$publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
// if the encryption app is disabled, than everything is fine (INIT_SUCCESSFUL status code)
@@ -134,8 +134,10 @@ if ($needUpgrade) {
$tmpl->assign('files', $files);
$tmpl->assign('trash', $trashEnabled);
$tmpl->assign('trashEmpty', $trashEmpty);
- $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
+ $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); // minimium of freeSpace and uploadLimit
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
+ $tmpl->assign('freeSpace', $freeSpace);
+ $tmpl->assign('uploadLimit', $uploadLimit); // PHP upload limit
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
$tmpl->assign('isPublic', false);
diff --git a/apps/files/js/admin.js b/apps/files/js/admin.js
index bfa96670635..f735079fcbe 100644
--- a/apps/files/js/admin.js
+++ b/apps/files/js/admin.js
@@ -1,3 +1,13 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
function switchPublicFolder()
{
var publicEnable = $('#publicEnable').is(':checked');
@@ -10,7 +20,7 @@ function switchPublicFolder()
$(document).ready(function(){
switchPublicFolder(); // Execute the function after loading DOM tree
$('#publicEnable').click(function(){
- switchPublicFolder(); // To get rid of onClick()
+ switchPublicFolder(); // To get rid of onClick()
});
$('#allowZipDownload').bind('change', function() {
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 225c3319107..f962a7044a8 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -1,3 +1,13 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
/**
* The file upload code uses several hooks to interact with blueimps jQuery file upload library:
* 1. the core upload handling hooks are added when initializing the plugin,
@@ -8,6 +18,8 @@
* - TODO music upload button
*/
+/* global OC, t, n */
+
/**
* Function that will allow us to know if Ajax uploads are supported
* @link https://github.com/New-Bamboo/example-ajax-upload/blob/master/public/index.html
@@ -241,10 +253,22 @@ $(document).ready(function() {
// add size
selection.totalBytes += file.size;
- //check max upload size
- if (selection.totalBytes > $('#max_upload').val()) {
+ // check PHP upload limit
+ if (selection.totalBytes > $('#upload_limit').val()) {
+ data.textStatus = 'sizeexceedlimit';
+ data.errorThrown = t('files', 'Total file size {size1} exceeds upload limit {size2}', {
+ 'size1': humanFileSize(selection.totalBytes),
+ 'size2': humanFileSize($('#upload_limit').val())
+ });
+ }
+
+ // check free space
+ if (selection.totalBytes > $('#free_space').val()) {
data.textStatus = 'notenoughspace';
- data.errorThrown = t('files', 'Not enough space available');
+ data.errorThrown = t('files', 'Not enough free space, you are uploading {size1} but only {size2} is left', {
+ 'size1': humanFileSize(selection.totalBytes),
+ 'size2': humanFileSize($('#free_space').val())
+ });
}
// end upload for whole selection on error
@@ -315,6 +339,13 @@ $(document).ready(function() {
} else {
// HTTP connection problem
OC.Notification.show(data.errorThrown);
+ if (data.result) {
+ var result = JSON.parse(data.result);
+ if (result && result[0] && result[0].data && result[0].data.code === 'targetnotfound') {
+ // abort upload of next files if any
+ OC.Upload.cancelUploads();
+ }
+ }
}
//hide notification after 10 sec
setTimeout(function() {
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index 74bb711ef3d..9a69d7b3688 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -1,3 +1,15 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+/* global OC, FileList */
+/* global trashBinApp */
var FileActions = {
actions: {},
defaults: {},
@@ -45,8 +57,9 @@ var FileActions = {
return filteredActions;
},
getDefault: function (mime, type, permissions) {
+ var mimePart;
if (mime) {
- var mimePart = mime.substr(0, mime.indexOf('/'));
+ mimePart = mime.substr(0, mime.indexOf('/'));
}
var name = false;
if (mime && FileActions.defaults[mime]) {
@@ -71,13 +84,15 @@ var FileActions = {
FileActions.currentFile = parent;
var actions = FileActions.get(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
var file = FileActions.getCurrentFile();
+ var nameLinks;
if (FileList.findFileEl(file).data('renaming')) {
return;
}
// recreate fileactions
- parent.children('a.name').find('.fileactions').remove();
- parent.children('a.name').append('<span class="fileactions" />');
+ nameLinks = parent.children('a.name');
+ nameLinks.find('.fileactions, .nametext .action').remove();
+ nameLinks.append('<span class="fileactions" />');
var defaultAction = FileActions.getDefault(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
var actionHandler = function (event) {
@@ -97,21 +112,30 @@ var FileActions = {
}
if ((name === 'Download' || action !== defaultAction) && name !== 'Delete') {
- var img = FileActions.icons[name];
+ var img = FileActions.icons[name],
+ actionText = t('files', name),
+ actionContainer = 'a.name>span.fileactions';
+
+ if (name === 'Rename') {
+ // rename has only an icon which appears behind
+ // the file name
+ actionText = '';
+ actionContainer = 'a.name span.nametext';
+ }
if (img.call) {
img = img(file);
}
var html = '<a href="#" class="action" data-action="' + name + '">';
if (img) {
- html += '<img class ="svg" src="' + img + '" /> ';
+ html += '<img class ="svg" src="' + img + '" />';
}
- html += t('files', name) + '</a>';
+ html += '<span> ' + actionText + '</span></a>';
var element = $(html);
element.data('action', name);
//alert(element);
element.on('click', {a: null, elem: parent, actionFunc: actions[name]}, actionHandler);
- parent.find('a.name>span.fileactions').append(element);
+ parent.find(actionContainer).append(element);
}
};
@@ -130,13 +154,14 @@ var FileActions = {
parent.parent().children().last().find('.action.delete').remove();
if (actions['Delete']) {
var img = FileActions.icons['Delete'];
+ var html;
if (img.call) {
img = img(file);
}
if (typeof trashBinApp !== 'undefined' && trashBinApp) {
- var html = '<a href="#" original-title="' + t('files', 'Delete permanently') + '" class="action delete delete-icon" />';
+ html = '<a href="#" original-title="' + t('files', 'Delete permanently') + '" class="action delete delete-icon" />';
} else {
- var html = '<a href="#" class="action delete delete-icon" />';
+ html = '<a href="#" class="action delete delete-icon" />';
}
var element = $(html);
element.data('action', actions['Delete']);
@@ -163,17 +188,21 @@ var FileActions = {
};
$(document).ready(function () {
+ var downloadScope;
if ($('#allowZipDownload').val() == 1) {
- var downloadScope = 'all';
+ downloadScope = 'all';
} else {
- var downloadScope = 'file';
+ downloadScope = 'file';
}
if (typeof disableDownloadActions == 'undefined' || !disableDownloadActions) {
FileActions.register(downloadScope, 'Download', OC.PERMISSION_READ, function () {
return OC.imagePath('core', 'actions/download');
}, function (filename) {
- window.location = OC.filePath('files', 'ajax', 'download.php') + '?files=' + encodeURIComponent(filename) + '&dir=' + encodeURIComponent($('#dir').val());
+ var url = FileList.getDownloadUrl(filename);
+ if (url) {
+ OC.redirect(url);
+ }
});
}
$('#fileList tr').each(function () {
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 66968ab54c7..81c52e2a863 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1,4 +1,16 @@
-var FileList={
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+/* global OC, t, n, FileList, FileActions, Files */
+/* global procesSelection, dragOptions, SVGSupport, replaceSVG */
+window.FileList={
useUndo:true,
postProcessList: function() {
$('#fileList tr').each(function() {
@@ -191,6 +203,7 @@ var FileList={
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
},
setCurrentDir: function(targetDir, changeUrl) {
+ var url;
$('#dir').val(targetDir);
if (changeUrl !== false) {
if (window.history.pushState && changeUrl !== false) {
@@ -477,6 +490,7 @@ var FileList={
td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.')));
}
form.remove();
+ FileActions.display( tr.find('td.filename'), true);
td.children('a.name').show();
} catch (error) {
input.attr('title', error);
@@ -780,6 +794,20 @@ var FileList={
$('#fileList tr.searchresult').each(function(i,e) {
$(e).removeClass("searchresult");
});
+ },
+
+ /**
+ * Returns the download URL of the given file
+ * @param filename file name of the file
+ * @param dir optional directory in which the file name is, defaults to the current directory
+ */
+ getDownloadUrl: function(filename, dir) {
+ var params = {
+ files: filename,
+ dir: dir || FileList.getCurrentDirectory(),
+ download: null
+ };
+ return OC.filePath('files', 'ajax', 'download.php') + '?' + OC.buildQueryString(params);
}
};
@@ -819,7 +847,7 @@ $(document).ready(function() {
{name: 'requesttoken', value: oc_requesttoken}
];
};
- }
+ }
});
file_upload_start.on('fileuploadadd', function(e, data) {
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 2fe4ab464c8..a535700c1b3 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -1,4 +1,16 @@
-Files={
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+/* global OC, t, n, FileList, FileActions */
+/* global getURLParameter, isPublic */
+var Files = {
// file space size sync
_updateStorageStatistics: function() {
Files._updateStorageStatisticsTimeout = null;
@@ -41,6 +53,7 @@ Files={
}
if (response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
$('#max_upload').val(response.data.uploadMaxFilesize);
+ $('#free_space').val(response.data.freeSpace);
$('#upload.button').attr('original-title', response.data.maxHumanFilesize);
$('#usedSpacePercent').val(response.data.usedSpacePercent);
Files.displayStorageWarnings();
@@ -67,17 +80,25 @@ Files={
return fileName;
},
- isFileNameValid:function (name) {
- if (name === '.') {
- throw t('files', '\'.\' is an invalid file name.');
- } else if (name.length === 0) {
+ /**
+ * Checks whether the given file name is valid.
+ * @param name file name to check
+ * @return true if the file name is valid.
+ * Throws a string exception with an error message if
+ * the file name is not valid
+ */
+ isFileNameValid: function (name) {
+ var trimmedName = name.trim();
+ if (trimmedName === '.' || trimmedName === '..') {
+ throw t('files', '"{name}" is an invalid file name.', {name: name});
+ } else if (trimmedName.length === 0) {
throw t('files', 'File name cannot be empty.');
}
-
// check for invalid characters
- var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
+ var invalid_characters =
+ ['\\', '/', '<', '>', ':', '"', '|', '?', '*', '\n'];
for (var i = 0; i < invalid_characters.length; i++) {
- if (name.indexOf(invalid_characters[i]) !== -1) {
+ if (trimmedName.indexOf(invalid_characters[i]) !== -1) {
throw t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.");
}
}
@@ -654,10 +675,10 @@ function procesSelection() {
var totalSize = 0;
for(var i=0; i<selectedFiles.length; i++) {
totalSize+=selectedFiles[i].size;
- };
+ }
for(var i=0; i<selectedFolders.length; i++) {
totalSize+=selectedFolders[i].size;
- };
+ }
$('#headerSize').text(humanFileSize(totalSize));
var selection = '';
if (selectedFolders.length > 0) {
@@ -751,7 +772,7 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
console.warn('Files.lazyLoadPreview(): missing etag argument');
}
- if ( $('#public_upload').length ) {
+ if ( $('#isPublic').length ) {
urlSpec.t = $('#dirToken').val();
previewURL = OC.Router.generate('core_ajax_public_preview', urlSpec);
} else {
@@ -769,10 +790,11 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
}
img.src = previewURL;
});
-}
+};
function getUniqueName(name) {
if (FileList.findFileEl(name).exists()) {
+ var numMatch;
var parts=name.split('.');
var extension = "";
if (parts.length > 1) {
@@ -806,7 +828,7 @@ function checkTrashStatus() {
function onClickBreadcrumb(e) {
var $el = $(e.target).closest('.crumb'),
- $targetDir = $el.data('dir');
+ $targetDir = $el.data('dir'),
isPublic = !!$('#isPublic').val();
if ($targetDir !== undefined && !isPublic) {
diff --git a/apps/files/js/upgrade.js b/apps/files/js/upgrade.js
index 02d57fc9e6c..714adf824a1 100644
--- a/apps/files/js/upgrade.js
+++ b/apps/files/js/upgrade.js
@@ -1,3 +1,14 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+/* global OC */
$(document).ready(function () {
var eventSource, total, bar = $('#progressbar');
console.log('start');
diff --git a/apps/files/js/upload.js b/apps/files/js/upload.js
index 9d9f61f600e..617cf4b1c1d 100644
--- a/apps/files/js/upload.js
+++ b/apps/files/js/upload.js
@@ -1,3 +1,14 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
+/* global OC */
function Upload(fileSelector) {
if ($.support.xhrFileUpload) {
return new XHRUpload(fileSelector.target.files);
diff --git a/apps/files/lib/app.php b/apps/files/lib/app.php
index e04ac173d55..fea88faa92a 100644
--- a/apps/files/lib/app.php
+++ b/apps/files/lib/app.php
@@ -59,6 +59,13 @@ class App {
$result['data'] = array(
'message' => $this->l10n->t("Invalid folder name. Usage of 'Shared' is reserved.")
);
+ // rename to non-existing folder is denied
+ } else if (!$this->view->file_exists($dir)) {
+ $result['data'] = array('message' => (string)$this->l10n->t(
+ 'The target folder has been moved or deleted.',
+ array($dir)),
+ 'code' => 'targetnotfound'
+ );
// rename to existing file is denied
} else if ($this->view->file_exists($dir . '/' . $newname)) {
@@ -83,14 +90,17 @@ class App {
else {
$meta['type'] = 'file';
}
+ // these need to be set for determineIcon()
+ $meta['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($meta['mimetype']);
+ $meta['directory'] = $dir;
$fileinfo = array(
'id' => $meta['fileid'],
'mime' => $meta['mimetype'],
'size' => $meta['size'],
'etag' => $meta['etag'],
- 'directory' => $dir,
+ 'directory' => $meta['directory'],
'name' => $newname,
- 'isPreviewAvailable' => \OC::$server->getPreviewManager()->isMimeSupported($meta['mimetype']),
+ 'isPreviewAvailable' => $meta['isPreviewAvailable'],
'icon' => \OCA\Files\Helper::determineIcon($meta)
);
$result['success'] = true;
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php
index 87939d26921..01fc65d76b7 100644
--- a/apps/files/lib/helper.php
+++ b/apps/files/lib/helper.php
@@ -15,6 +15,7 @@ class Helper
return array('uploadMaxFilesize' => $maxUploadFilesize,
'maxHumanFilesize' => $maxHumanFilesize,
+ 'freeSpace' => $storageInfo['free'],
'usedSpacePercent' => (int)$storageInfo['relative']);
}
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index 5ed1ee0c7a0..939043b2c9f 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -1,6 +1,7 @@
<div id="controls">
<?php print_unescaped($_['breadcrumb']); ?>
<div class="actions creatable <?php if (!$_['isCreatable']):?>hidden<?php endif; ?>">
+ <?php if(!isset($_['dirToken'])):?>
<div id="new" class="button">
<a><?php p($l->t('New'));?></a>
<ul>
@@ -12,11 +13,17 @@
data-type='web'><p><?php p($l->t('From link'));?></p></li>
</ul>
</div>
+ <?php endif;?>
<div id="upload" class="button"
title="<?php p($l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize']) ?>">
<?php if($_['uploadMaxFilesize'] >= 0):?>
- <input type="hidden" name="MAX_FILE_SIZE" id="max_upload"
- value="<?php p($_['uploadMaxFilesize']) ?>">
+ <input type="hidden" id="max_upload" name="MAX_FILE_SIZE" value="<?php p($_['uploadMaxFilesize']) ?>">
+ <?php endif;?>
+ <input type="hidden" id="upload_limit" value="<?php p($_['uploadLimit']) ?>">
+ <input type="hidden" id="free_space" value="<?php p($_['freeSpace']) ?>">
+ <?php if(isset($_['dirToken'])):?>
+ <input type="hidden" id="publicUploadRequestToken" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
+ <input type="hidden" id="dirToken" name="dirToken" value="<?php p($_['dirToken']) ?>" />
<?php endif;?>
<input type="hidden" class="max_human_file_size"
value="(max <?php p($_['uploadMaxHumanFilesize']); ?>)">
@@ -26,7 +33,7 @@
<a href="#" class="svg icon icon-upload"></a>
</div>
<?php if ($_['trash']): ?>
- <input id="trash" type="button" value="<?php p($l->t('Deleted files'));?>" class="button" <?php $_['trashEmpty'] ? p('disabled') : '' ?>></input>
+ <input id="trash" type="button" value="<?php p($l->t('Deleted files'));?>" class="button" <?php $_['trashEmpty'] ? p('disabled') : '' ?> />
<?php endif; ?>
<div id="uploadprogresswrapper">
<div id="uploadprogressbar"></div>
@@ -44,7 +51,7 @@
<div id="emptycontent" <?php if (!$_['emptyContent']):?>class="hidden"<?php endif; ?>><?php p($l->t('Nothing in here. Upload something!'))?></div>
-<input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>"></input>
+<input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>" />
<table id="filestable" data-allow-public-upload="<?php p($_['publicUploadEnabled'])?>" data-preview-x="36" data-preview-y="36">
<thead>
diff --git a/apps/files/tests/ajax_rename.php b/apps/files/tests/ajax_rename.php
index 350ff5d3687..a1a5c8983ba 100644
--- a/apps/files/tests/ajax_rename.php
+++ b/apps/files/tests/ajax_rename.php
@@ -38,7 +38,7 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$l10nMock->expects($this->any())
->method('t')
->will($this->returnArgument(0));
- $viewMock = $this->getMock('\OC\Files\View', array('rename', 'normalizePath', 'getFileInfo'), array(), '', false);
+ $viewMock = $this->getMock('\OC\Files\View', array('rename', 'normalizePath', 'getFileInfo', 'file_exists'), array(), '', false);
$viewMock->expects($this->any())
->method('normalizePath')
->will($this->returnArgument(0));
@@ -63,6 +63,11 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$oldname = 'Shared';
$newname = 'new_name';
+ $this->viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->with('/')
+ ->will($this->returnValue(true));
+
$result = $this->files->rename($dir, $oldname, $newname);
$expected = array(
'success' => false,
@@ -80,6 +85,11 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$oldname = 'Shared';
$newname = 'new_name';
+ $this->viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->with('/test')
+ ->will($this->returnValue(true));
+
$this->viewMock->expects($this->any())
->method('getFileInfo')
->will($this->returnValue(array(
@@ -129,6 +139,11 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$oldname = 'oldname';
$newname = 'newname';
+ $this->viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->with('/')
+ ->will($this->returnValue(true));
+
$this->viewMock->expects($this->any())
->method('getFileInfo')
->will($this->returnValue(array(
@@ -141,7 +156,6 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
'name' => 'new_name',
)));
-
$result = $this->files->rename($dir, $oldname, $newname);
$this->assertTrue($result['success']);
@@ -154,4 +168,35 @@ class Test_OC_Files_App_Rename extends \PHPUnit_Framework_TestCase {
$this->assertEquals(\OC_Helper::mimetypeIcon('dir'), $result['data']['icon']);
$this->assertFalse($result['data']['isPreviewAvailable']);
}
+
+ /**
+ * Test rename inside a folder that doesn't exist any more
+ */
+ function testRenameInNonExistingFolder() {
+ $dir = '/unexist';
+ $oldname = 'oldname';
+ $newname = 'newname';
+
+ $this->viewMock->expects($this->at(0))
+ ->method('file_exists')
+ ->with('/unexist')
+ ->will($this->returnValue(false));
+
+ $this->viewMock->expects($this->any())
+ ->method('getFileInfo')
+ ->will($this->returnValue(array(
+ 'fileid' => 123,
+ 'type' => 'dir',
+ 'mimetype' => 'httpd/unix-directory',
+ 'size' => 18,
+ 'etag' => 'abcdef',
+ 'directory' => '/unexist',
+ 'name' => 'new_name',
+ )));
+
+ $result = $this->files->rename($dir, $oldname, $newname);
+
+ $this->assertFalse($result['success']);
+ $this->assertEquals('targetnotfound', $result['data']['code']);
+ }
}
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js
new file mode 100644
index 00000000000..8bbc1d3d141
--- /dev/null
+++ b/apps/files/tests/js/fileactionsSpec.js
@@ -0,0 +1,75 @@
+/**
+* ownCloud
+*
+* @author Vincent Petry
+* @copyright 2014 Vincent Petry <pvince81@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/>.
+*
+*/
+
+/* global OC, FileActions, FileList */
+describe('FileActions tests', function() {
+ var $filesTable;
+ beforeEach(function() {
+ // init horrible parameters
+ var $body = $('body');
+ $body.append('<input type="hidden" id="dir" value="/subdir"></input>');
+ $body.append('<input type="hidden" id="permissions" value="31"></input>');
+ // dummy files table
+ $filesTable = $body.append('<table id="filestable"></table>');
+ });
+ afterEach(function() {
+ $('#dir, #permissions, #filestable').remove();
+ });
+ it('calling display() sets file actions', function() {
+ // note: download_url is actually the link target, not the actual download URL...
+ var $tr = FileList.addFile('testName.txt', 1234, new Date(), false, false, {download_url: 'test/download/url'});
+
+ // no actions before call
+ expect($tr.find('.action[data-action=Download]').length).toEqual(0);
+ expect($tr.find('.action[data-action=Rename]').length).toEqual(0);
+ expect($tr.find('.action.delete').length).toEqual(0);
+
+ FileActions.display($tr.find('td.filename'), true);
+
+ // actions defined after cal
+ expect($tr.find('.action[data-action=Download]').length).toEqual(1);
+ expect($tr.find('.nametext .action[data-action=Rename]').length).toEqual(1);
+ expect($tr.find('.action.delete').length).toEqual(1);
+ });
+ it('calling display() twice correctly replaces file actions', function() {
+ var $tr = FileList.addFile('testName.txt', 1234, new Date(), false, false, {download_url: 'test/download/url'});
+
+ FileActions.display($tr.find('td.filename'), true);
+ FileActions.display($tr.find('td.filename'), true);
+
+ // actions defined after cal
+ expect($tr.find('.action[data-action=Download]').length).toEqual(1);
+ expect($tr.find('.nametext .action[data-action=Rename]').length).toEqual(1);
+ expect($tr.find('.action.delete').length).toEqual(1);
+ });
+ it('redirects to download URL when clicking download', function() {
+ var redirectStub = sinon.stub(OC, 'redirect');
+ // note: download_url is actually the link target, not the actual download URL...
+ var $tr = FileList.addFile('test download File.txt', 1234, new Date(), false, false, {download_url: 'test/download/url'});
+ FileActions.display($tr.find('td.filename'), true);
+
+ $tr.find('.action[data-action=Download]').click();
+
+ expect(redirectStub.calledOnce).toEqual(true);
+ expect(redirectStub.getCall(0).args[0]).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?files=test%20download%20File.txt&dir=%2Fsubdir&download');
+ redirectStub.restore();
+ });
+});
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 6b28a02989e..c26e65fc4de 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -18,25 +18,32 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
+/* global OC, FileList */
describe('FileList tests', function() {
beforeEach(function() {
// init horrible parameters
- $('<input type="hidden" id="dir" value="/subdir"></input>').append('body');
- $('<input type="hidden" id="permissions" value="31"></input>').append('body');
+ var $body = $('body');
+ $body.append('<input type="hidden" id="dir" value="/subdir"></input>');
+ $body.append('<input type="hidden" id="permissions" value="31"></input>');
+ // dummy files table
+ $body.append('<table id="filestable"></table>');
});
afterEach(function() {
- $('#dir, #permissions').remove();
+ $('#dir, #permissions, #filestable').remove();
});
it('generates file element with correct attributes when calling addFile', function() {
var lastMod = new Date(10000);
+ // note: download_url is actually the link target, not the actual download URL...
var $tr = FileList.addFile('testName.txt', 1234, lastMod, false, false, {download_url: 'test/download/url'});
expect($tr).toBeDefined();
expect($tr[0].tagName.toLowerCase()).toEqual('tr');
+ expect($tr.find('a:first').attr('href')).toEqual('test/download/url');
expect($tr.attr('data-type')).toEqual('file');
expect($tr.attr('data-file')).toEqual('testName.txt');
expect($tr.attr('data-size')).toEqual('1234');
- //expect($tr.attr('data-permissions')).toEqual('31');
+ expect($tr.attr('data-permissions')).toEqual('31');
//expect($tr.attr('data-mime')).toEqual('plain/text');
});
it('generates dir element with correct attributes when calling addDir', function() {
@@ -48,7 +55,11 @@ describe('FileList tests', function() {
expect($tr.attr('data-type')).toEqual('dir');
expect($tr.attr('data-file')).toEqual('testFolder');
expect($tr.attr('data-size')).toEqual('1234');
- //expect($tr.attr('data-permissions')).toEqual('31');
+ expect($tr.attr('data-permissions')).toEqual('31');
//expect($tr.attr('data-mime')).toEqual('httpd/unix-directory');
});
+ it('returns correct download URL', function() {
+ expect(FileList.getDownloadUrl('some file.txt')).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?files=some%20file.txt&dir=%2Fsubdir&download');
+ expect(FileList.getDownloadUrl('some file.txt', '/anotherpath/abc')).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?files=some%20file.txt&dir=%2Fanotherpath%2Fabc&download');
+ });
});
diff --git a/apps/files/tests/js/filesSpec.js b/apps/files/tests/js/filesSpec.js
index 9d0a2e4f9d7..018c8ef0f3c 100644
--- a/apps/files/tests/js/filesSpec.js
+++ b/apps/files/tests/js/filesSpec.js
@@ -18,6 +18,8 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
+/* global Files */
describe('Files tests', function() {
describe('File name validation', function() {
it('Validates correct file names', function() {
@@ -36,12 +38,14 @@ describe('Files tests', function() {
'und Ümläüte sind auch willkommen'
];
for ( var i = 0; i < fileNames.length; i++ ) {
+ var error = false;
try {
expect(Files.isFileNameValid(fileNames[i])).toEqual(true);
}
catch (e) {
- fail();
+ error = e;
}
+ expect(error).toEqual(false);
}
});
it('Detects invalid file names', function() {
@@ -69,7 +73,7 @@ describe('Files tests', function() {
var threwException = false;
try {
Files.isFileNameValid(fileNames[i]);
- fail();
+ console.error('Invalid file name not detected:', fileNames[i]);
}
catch (e) {
threwException = true;
diff --git a/apps/files_sharing/css/mobile.css b/apps/files_sharing/css/mobile.css
new file mode 100644
index 00000000000..7d2116d190d
--- /dev/null
+++ b/apps/files_sharing/css/mobile.css
@@ -0,0 +1,49 @@
+@media only screen and (max-width: 600px) {
+
+/* make header scroll up for single shares, more view of content on small screens */
+#header.share-file {
+ position: absolute !important;
+}
+
+/* hide size and date columns */
+table th#headerSize,
+table td.filesize,
+table th#headerDate,
+table td.date {
+ display: none;
+}
+
+/* restrict length of displayed filename to prevent overflow */
+table td.filename .nametext {
+ max-width: 75% !important;
+}
+
+/* on mobile, show single shared image at full width without margin */
+#imgframe {
+ width: 100%;
+ padding: 0;
+ margin-bottom: 35px;
+}
+/* some margin for the file type icon */
+#imgframe .publicpreview {
+ margin-top: 32px;
+}
+
+/* always show actions on mobile */
+#fileList a.action {
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)" !important;
+ filter: alpha(opacity=20) !important;
+ opacity: .2 !important;
+ display: inline !important;
+}
+/* some padding for better clickability */
+#fileList a.action img {
+ padding: 0 6px 0 12px;
+}
+/* hide text of the actions on mobile */
+#fileList a.action span {
+ display: none;
+}
+
+
+}
diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css
index 6e0c6eb75b9..21f0c82b829 100644
--- a/apps/files_sharing/css/public.css
+++ b/apps/files_sharing/css/public.css
@@ -14,39 +14,17 @@ body {
padding:7px;
}
-#details {
- color:#fff;
- float: left;
-}
-
-#public_upload,
-#download {
- font-weight:700;
- margin: 0 0 0 6px;
- padding: 0 5px;
- height: 32px;
- float: left;
-
-}
-
-.header-right #details {
- margin-right: 28px;
-}
-
.header-right {
padding: 0;
height: 32px;
}
-#public_upload {
- margin-left: 5px;
-}
-
-#public_upload img,
-#download img {
- padding-left:2px;
- padding-right:5px;
- vertical-align:text-bottom;
+#details {
+ color:#fff;
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
+ filter: alpha(opacity=50);
+ opacity: .5;
+ padding-right: 5px;
}
#controls {
@@ -71,9 +49,8 @@ footer {
p.info {
color: #777;
text-align: center;
- width: 352px;
margin: 0 auto;
- padding: 20px;
+ padding: 20px 0;
}
p.info a {
@@ -94,9 +71,13 @@ p.info a {
max-width:100%;
}
-thead{
- background-color: white;
- padding-left:0 !important; /* fixes multiselect bar offset on shared page */
+/* some margin for the file type icon */
+#imgframe .publicpreview {
+ margin-top: 10%;
+}
+
+thead {
+ padding-left: 0 !important; /* fixes multiselect bar offset on shared page */
}
#data-upload-form {
@@ -110,27 +91,20 @@ thead{
margin: 0;
}
-#file_upload_start {
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
- filter: alpha(opacity=0);
- opacity: 0;
- z-index: 20;
- position: absolute !important;
- top: 0;
- left: 0;
- width: 100% !important;
-}
-
+.directDownload,
.directLink {
margin-bottom: 20px;
}
+.directDownload .button img {
+ vertical-align: text-bottom;
+}
.directLink label {
font-weight: normal;
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
+ filter: alpha(opacity=50);
+ opacity: .5;
}
.directLink input {
- margin-left: 10px;
+ margin-left: 5px;
width: 300px;
}
-.public_actions {
- padding: 4px;
-}
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 4c0b0ad9d48..c1b7eee3fb7 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -9,22 +9,13 @@ function fileDownloadPath(dir, file) {
$(document).ready(function() {
- $('#data-upload-form').tipsy({gravity:'ne', fade:true});
-
if (typeof FileActions !== 'undefined') {
var mimetype = $('#mimetype').val();
// Show file preview if previewer is available, images are already handled by the template
if (mimetype.substr(0, mimetype.indexOf('/')) != 'image' && $('.publicpreview').length === 0) {
// Trigger default action if not download TODO
var action = FileActions.getDefault(mimetype, 'file', OC.PERMISSION_READ);
- if (typeof action === 'undefined') {
- $('#noPreview').show();
- if (mimetype != 'httpd/unix-directory') {
- // NOTE: Remove when a better file previewer solution exists
- $('#content').remove();
- $('table').remove();
- }
- } else {
+ if (typeof action !== 'undefined') {
action($('#filename').val());
}
}
@@ -34,18 +25,16 @@ $(document).ready(function() {
window.location = $(tr).find('a.name').attr('href');
}
});
- FileActions.register('file', 'Download', OC.PERMISSION_READ, '', function(filename) {
- var tr = FileList.findFileEl(filename);
- if (tr.length > 0) {
- window.location = $(tr).find('a.name').attr('href');
- }
- });
- FileActions.register('dir', 'Download', OC.PERMISSION_READ, '', function(filename) {
+
+ // override since the format is different
+ FileList.getDownloadUrl = function(filename, dir) {
+ // we use this because we need the service and token attributes
var tr = FileList.findFileEl(filename);
if (tr.length > 0) {
- window.location = $(tr).find('a.name').attr('href')+'&download';
+ return $(tr).find('a.name').attr('href') + '&download';
}
- });
+ return null;
+ };
}
var file_upload_start = $('#file_upload_start');
@@ -58,16 +47,9 @@ $(document).ready(function() {
};
});
- // Add Uploadprogress Wrapper to controls bar
- $('#controls').append($('#controls .actions div#uploadprogresswrapper'));
- $('#uploadprogresswrapper').addClass('public_actions');
-
- // Cancel upload trigger
- $('#cancel_upload_button').click(function() {
- OC.Upload.cancelUploads();
- procesSelection();
+ $(document).on('click', '#directLink', function() {
+ $(this).focus();
+ $(this).select();
});
- $('#directLink').focus();
-
});
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php
index 84e90c71681..061e60ad8ed 100644
--- a/apps/files_sharing/lib/api.php
+++ b/apps/files_sharing/lib/api.php
@@ -162,7 +162,7 @@ class Api {
$view = new \OC\Files\View('/'.\OCP\User::getUser().'/files');
if(!$view->is_dir($path)) {
- return new \OC_OCS_Result(null, 404, "not a directory");
+ return new \OC_OCS_Result(null, 400, "not a directory");
}
$content = $view->getDirectoryContent($path);
@@ -178,8 +178,7 @@ class Api {
$share['received_from_displayname'] = \OCP\User::getDisplayName($receivedFrom['uid_owner']);
}
if ($share) {
- $share['filename'] = $file['name'];
- $result[] = $share;
+ $result = array_merge($result, $share);
}
}
@@ -220,10 +219,8 @@ class Api {
$shareWith = isset($_POST['password']) ? $_POST['password'] : null;
//check public link share
$publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
- $encryptionEnabled = \OC_App::isEnabled('files_encryption');
- if(isset($_POST['publicUpload']) &&
- ($encryptionEnabled || $publicUploadEnabled !== 'yes')) {
- return new \OC_OCS_Result(null, 404, "public upload disabled by the administrator");
+ if(isset($_POST['publicUpload']) && $publicUploadEnabled !== 'yes') {
+ return new \OC_OCS_Result(null, 403, "public upload disabled by the administrator");
}
$publicUpload = isset($_POST['publicUpload']) ? $_POST['publicUpload'] : 'false';
// read, create, update (7) if public upload is enabled or
@@ -231,7 +228,7 @@ class Api {
$permissions = $publicUpload === 'true' ? 7 : 1;
break;
default:
- return new \OC_OCS_Result(null, 404, "unknown share type");
+ return new \OC_OCS_Result(null, 400, "unknown share type");
}
try {
@@ -243,7 +240,7 @@ class Api {
$permissions
);
} catch (\Exception $e) {
- return new \OC_OCS_Result(null, 404, $e->getMessage());
+ return new \OC_OCS_Result(null, 403, $e->getMessage());
}
if ($token) {
@@ -321,11 +318,8 @@ class Api {
$permissions = isset($params['_put']['permissions']) ? (int)$params['_put']['permissions'] : null;
$publicUploadStatus = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
- $encryptionEnabled = \OC_App::isEnabled('files_encryption');
- $publicUploadEnabled = false;
- if(!$encryptionEnabled && $publicUploadStatus === 'yes') {
- $publicUploadEnabled = true;
- }
+ $publicUploadEnabled = ($publicUploadStatus === 'yes') ? true : false;
+
// only change permissions for public shares if public upload is enabled
// and we want to set permissions to 1 (read only) or 7 (allow upload)
@@ -363,9 +357,8 @@ class Api {
private static function updatePublicUpload($share, $params) {
$publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
- $encryptionEnabled = \OC_App::isEnabled('files_encryption');
- if($encryptionEnabled || $publicUploadEnabled !== 'yes') {
- return new \OC_OCS_Result(null, 404, "public upload disabled by the administrator");
+ if($publicUploadEnabled !== 'yes') {
+ return new \OC_OCS_Result(null, 403, "public upload disabled by the administrator");
}
if ($share['item_type'] !== 'folder' ||
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index 4a81e482970..b187da41324 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -137,11 +137,14 @@ if (isset($path)) {
} else {
OCP\Util::addScript('files', 'file-upload');
OCP\Util::addStyle('files_sharing', 'public');
+ OCP\Util::addStyle('files_sharing', 'mobile');
OCP\Util::addScript('files_sharing', 'public');
OCP\Util::addScript('files', 'fileactions');
OCP\Util::addScript('files', 'jquery.iframe-transport');
OCP\Util::addScript('files', 'jquery.fileupload');
$maxUploadFilesize=OCP\Util::maxUploadFilesize($path);
+ $freeSpace=OCP\Util::freeSpace($dir);
+ $uploadLimit=OCP\Util::uploadLimit();
$tmpl = new OCP\Template('files_sharing', 'public', 'base');
$tmpl->assign('uidOwner', $shareOwner);
$tmpl->assign('displayName', \OCP\User::getDisplayName($shareOwner));
@@ -159,9 +162,10 @@ if (isset($path)) {
if ($linkItem['item_type'] !== 'folder') {
$allowPublicUploadEnabled = false;
}
- $tmpl->assign('allowPublicUploadEnabled', $allowPublicUploadEnabled);
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
+ $tmpl->assign('freeSpace', $freeSpace);
+ $tmpl->assign('uploadLimit', $uploadLimit); // PHP upload limit
$urlLinkIdentifiers= (isset($token)?'&t='.$token:'')
.(isset($_GET['dir'])?'&dir='.$_GET['dir']:'')
@@ -226,7 +230,8 @@ if (isset($path)) {
$folder->assign('fileList', $list->fetchPage());
$folder->assign('breadcrumb', $breadcrumbNav->fetchPage());
$folder->assign('dir', $getPath);
- $folder->assign('isCreatable', false);
+ $folder->assign('isCreatable', $allowPublicUploadEnabled);
+ $folder->assign('dirToken', $linkItem['token']);
$folder->assign('permissions', OCP\PERMISSION_READ);
$folder->assign('isPublic',true);
$folder->assign('publicUploadEnabled', 'no');
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index e1132142eff..3ddaf4446df 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -9,54 +9,14 @@
<input type="hidden" name="sharingToken" value="<?php p($_['sharingToken']) ?>" id="sharingToken">
<input type="hidden" name="filename" value="<?php p($_['filename']) ?>" id="filename">
<input type="hidden" name="mimetype" value="<?php p($_['mimetype']) ?>" id="mimetype">
-<header><div id="header" class="icon icon-noise">
+<header><div id="header" class="icon icon-noise <?php p((isset($_['folder']) ? 'share-folder' : 'share-file')) ?>">
<a href="<?php print_unescaped(link_to('', 'index.php')); ?>" title="" id="owncloud"><img class="svg"
src="<?php print_unescaped(image_path('', 'logo-wide.svg')); ?>" alt="<?php p($theme->getName()); ?>" /></a>
<div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div>
<div class="header-right">
- <?php if (isset($_['folder'])): ?>
- <span id="details"><?php p($l->t('%s shared the folder %s with you',
- array($_['displayName'], $_['filename']))) ?></span>
- <?php else: ?>
- <span id="details"><?php p($l->t('%s shared the file %s with you',
- array($_['displayName'], $_['filename']))) ?></span>
- <?php endif; ?>
-
-
- <?php if (!isset($_['folder']) || $_['allowZipDownload']): ?>
- <a href="<?php p($_['downloadURL']); ?>" class="button" id="download">
- <img class="svg" alt="Download" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>" />
- <span><?php p($l->t('Download'))?></span>
- </a>
- <?php endif; ?>
-
- <?php if ($_['allowPublicUploadEnabled']):?>
-
-
- <input type="hidden" id="publicUploadRequestToken" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
- <input type="hidden" id="dirToken" name="dirToken" value="<?php p($_['dirToken']) ?>" />
- <input type="hidden" id="uploadMaxFilesize" name="uploadMaxFilesize" value="<?php p($_['uploadMaxFilesize']) ?>" />
- <input type="hidden" id="uploadMaxHumanFilesize" name="uploadMaxHumanFilesize" value="<?php p($_['uploadMaxHumanFilesize']) ?>" />
- <input type="hidden" id="directory_path" name="directory_path" value="<?php p($_['directory_path']) ?>" />
- <?php if($_['uploadMaxFilesize'] >= 0):?>
- <input type="hidden" name="MAX_FILE_SIZE" id="max_upload"
- value="<?php p($_['uploadMaxFilesize']) ?>">
- <?php endif;?>
-
-
- <div id="data-upload-form" title="<?php p($l->t('Upload') . ' max. '.$_['uploadMaxHumanFilesize']) ?>">
- <input id="file_upload_start" type="file" name="files[]" data-url="<?php print_unescaped(OCP\Util::linkTo('files', 'ajax/upload.php')); ?>" multiple>
- <a href="#" id="public_upload" class="button">
- <img class="svg" alt="Upload" src="<?php print_unescaped(OCP\image_path("core", "actions/upload.svg")); ?>" />
- <span><?php p($l->t('Upload'))?></span>
- </a>
- </div>
-
- </div>
- <div>
- <?php endif; ?>
+ <span id="details"><?php p($l->t('shared by %s', array($_['displayName']))) ?></span>
</div>
- </div></header>
+</div></header>
<div id="content">
<div id="preview">
<?php if (isset($_['folder'])): ?>
@@ -72,25 +32,28 @@
<source src="<?php p($_['downloadURL']); ?>" type="<?php p($_['mimetype']); ?>" />
</video>
</div>
- <?php elseif (\OC\Preview::isMimeSupported($_['mimetype'])): ?>
+ <?php else: ?>
<div id="imgframe">
- <img src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => 500, 'y' => 500, 'file' => urlencode($_['directory_path']), 't' => $_['dirToken']))); ?>" class="publicpreview"/>
+ <?php $size = \OC\Preview::isMimeSupported($_['mimetype']) ? 500 : 128 ?>
+ <img src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => $size, 'y' => $size, 'file' => urlencode($_['directory_path']), 't' => $_['dirToken']))); ?>" class="publicpreview"/>
</div>
- <?php else: ?>
- <ul id="noPreview">
- <li class="error">
- <?php p($l->t('No preview available for').' '.$_['filename']); ?><br />
- <a href="<?php p($_['downloadURL']); ?>" id="download"><img class="svg" alt="Download"
- src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"
- /><?php p($l->t('Download'))?></a>
- </li>
- </ul>
<?php endif; ?>
- <div class="directLink"><label for="directLink"><?php p($l->t('Direct link')) ?></label><input id="directLink" type="text" readonly value="<?php p($_['downloadURL']); ?>"></input></div>
+ <div class="directDownload">
+ <a href="<?php p($_['downloadURL']); ?>" id="download" class="button">
+ <img class="svg" alt="" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"/>
+ <?php p($l->t('Download %s', array($_['filename'])))?>
+ </a>
+ </div>
+ <div class="directLink">
+ <label for="directLink"><?php p($l->t('Direct link')) ?></label>
+ <input id="directLink" type="text" readonly value="<?php p($_['downloadURL']); ?>">
+ </div>
<?php endif; ?>
</div>
- <footer>
- <p class="info">
- <?php print_unescaped($theme->getLongFooter()); ?>
- </p>
- </footer>
+
+</div>
+<footer>
+ <p class="info">
+ <?php print_unescaped($theme->getLongFooter()); ?>
+ </p>
+</footer>
diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php
index ce432f4d14e..44738734b19 100644
--- a/apps/files_trashbin/ajax/preview.php
+++ b/apps/files_trashbin/ajax/preview.php
@@ -34,7 +34,17 @@ try{
if ($view->is_dir($file)) {
$mimetype = 'httpd/unix-directory';
} else {
- $mimetype = \OC_Helper::getFileNameMimeType(pathinfo($file, PATHINFO_FILENAME));
+ $pathInfo = pathinfo($file);
+ $fileName = $pathInfo['basename'];
+ // if in root dir
+ if ($pathInfo['dirname'] === '.') {
+ // cut off the .d* suffix
+ $i = strrpos($fileName, '.');
+ if ($i !== false) {
+ $fileName = substr($fileName, 0, $i);
+ }
+ }
+ $mimetype = \OC_Helper::getFileNameMimeType($fileName);
}
$preview->setMimetype($mimetype);
$preview->setMaxX($maxX);
@@ -45,4 +55,4 @@ try{
}catch(\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
-} \ No newline at end of file
+}
diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index c4e4efd0483..7fbabda7106 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -52,7 +52,7 @@ class Connection extends LDAPUtility {
$this->configID = $configID;
$this->configuration = new Configuration($configPrefix,
!is_null($configID));
- $memcache = new \OC\Memcache\Factory();
+ $memcache = \OC::$server->getMemCacheFactory();
if($memcache->isAvailable()) {
$this->cache = $memcache->create();
} else {