aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-09-04 13:55:49 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2013-09-04 14:11:40 +0200
commit4af5a8c483278eae2e8e38f5ea0a238072848b87 (patch)
treebeca3f5250e1a50eca58fa63eea056b69ab82e44 /apps/files_sharing
parent7c9d9992432839f2265b8f6b0f43ed15bfca9ff1 (diff)
parent09187f3b3b30e6f810c6afff7332615ed472154e (diff)
downloadnextcloud-server-4af5a8c483278eae2e8e38f5ea0a238072848b87.tar.gz
nextcloud-server-4af5a8c483278eae2e8e38f5ea0a238072848b87.zip
Merge branch 'master' into fix_3728_with_file_exists_dialog
Conflicts: apps/files/ajax/upload.php apps/files/js/file-upload.js apps/files/js/filelist.js apps/files/js/files.js apps/files/templates/part.list.php
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/ajax/publicpreview.php85
-rw-r--r--apps/files_sharing/appinfo/app.php2
-rw-r--r--apps/files_sharing/appinfo/routes.php5
-rw-r--r--apps/files_sharing/js/public.js8
-rw-r--r--apps/files_sharing/js/share.js5
-rw-r--r--apps/files_sharing/l10n/eu.php6
-rw-r--r--apps/files_sharing/l10n/fr.php6
-rw-r--r--apps/files_sharing/l10n/ru_RU.php5
-rw-r--r--apps/files_sharing/l10n/zh_CN.GB2312.php12
-rw-r--r--apps/files_sharing/l10n/zh_CN.php7
-rw-r--r--apps/files_sharing/l10n/zh_TW.php7
-rw-r--r--apps/files_sharing/lib/cache.php2
-rw-r--r--apps/files_sharing/lib/permissions.php2
-rw-r--r--apps/files_sharing/lib/sharedstorage.php12
-rw-r--r--apps/files_sharing/lib/watcher.php2
-rw-r--r--apps/files_sharing/public.php10
-rw-r--r--apps/files_sharing/templates/part.404.php2
-rw-r--r--apps/files_sharing/templates/public.php4
18 files changed, 148 insertions, 34 deletions
diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php
new file mode 100644
index 00000000000..41a1c178a48
--- /dev/null
+++ b/apps/files_sharing/ajax/publicpreview.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+if(!\OC_App::isEnabled('files_sharing')){
+ exit;
+}
+
+$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
+$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36';
+$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36';
+$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
+$token = array_key_exists('t', $_GET) ? (string) $_GET['t'] : '';
+
+if($token === ''){
+ \OC_Response::setStatus(400); //400 Bad Request
+ \OC_Log::write('core-preview', 'No token parameter was passed', \OC_Log::DEBUG);
+ exit;
+}
+
+$linkedItem = \OCP\Share::getShareByToken($token);
+if($linkedItem === false || ($linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder')) {
+ \OC_Response::setStatus(404);
+ \OC_Log::write('core-preview', 'Passed token parameter is not valid', \OC_Log::DEBUG);
+ exit;
+}
+
+if(!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
+ \OC_Response::setStatus(500);
+ \OC_Log::write('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OC_Log::WARN);
+ exit;
+}
+
+$userId = $linkedItem['uid_owner'];
+\OC_Util::setupFS($userId);
+
+$pathId = $linkedItem['file_source'];
+$path = \OC\Files\Filesystem::getPath($pathId);
+$pathInfo = \OC\Files\Filesystem::getFileInfo($path);
+$sharedFile = null;
+
+if($linkedItem['item_type'] === 'folder') {
+ $isvalid = \OC\Files\Filesystem::isValidPath($file);
+ if(!$isvalid) {
+ \OC_Response::setStatus(400); //400 Bad Request
+ \OC_Log::write('core-preview', 'Passed filename is not valid, might be malicious (file:"' . $file . '";ip:"' . $_SERVER['REMOTE_ADDR'] . '")', \OC_Log::WARN);
+ exit;
+ }
+ $sharedFile = \OC\Files\Filesystem::normalizePath($file);
+}
+
+if($linkedItem['item_type'] === 'file') {
+ $parent = $pathInfo['parent'];
+ $path = \OC\Files\Filesystem::getPath($parent);
+ $sharedFile = $pathInfo['name'];
+}
+
+$path = \OC\Files\Filesystem::normalizePath($path, false);
+if(substr($path, 0, 1) === '/') {
+ $path = substr($path, 1);
+}
+
+if($maxX === 0 || $maxY === 0) {
+ \OC_Response::setStatus(400); //400 Bad Request
+ \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
+ exit;
+}
+
+$root = 'files/' . $path;
+
+try{
+ $preview = new \OC\Preview($userId, $root);
+ $preview->setFile($sharedFile);
+ $preview->setMaxX($maxX);
+ $preview->setMaxY($maxY);
+ $preview->setScalingUp($scalingUp);
+
+ $preview->show();
+} 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/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 9363a5431fa..895d446a336 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -15,4 +15,4 @@ OCP\Util::addScript('files_sharing', 'share');
\OC_Hook::connect('OC_Filesystem', 'delete', '\OC\Files\Cache\Shared_Updater', 'deleteHook');
\OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Shared_Updater', 'renameHook');
\OC_Hook::connect('OCP\Share', 'post_shared', '\OC\Files\Cache\Shared_Updater', 'shareHook');
-\OC_Hook::connect('OCP\Share', 'pre_unshare', '\OC\Files\Cache\Shared_Updater', 'shareHook'); \ No newline at end of file
+\OC_Hook::connect('OCP\Share', 'pre_unshare', '\OC\Files\Cache\Shared_Updater', 'shareHook');
diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php
new file mode 100644
index 00000000000..02815b5eb42
--- /dev/null
+++ b/apps/files_sharing/appinfo/routes.php
@@ -0,0 +1,5 @@
+<?php
+$this->create('core_ajax_public_preview', '/publicpreview.png')->action(
+function() {
+ require_once __DIR__ . '/../ajax/publicpreview.php';
+}); \ No newline at end of file
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index a20b4ae636f..ac121fd08e2 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -16,7 +16,7 @@ $(document).ready(function() {
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') {
+ 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') {
@@ -31,19 +31,19 @@ $(document).ready(function() {
}
}
FileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function(filename) {
- var tr = $('tr').filterAttr('data-file', filename)
+ var tr = $('tr').filterAttr('data-file', filename);
if (tr.length > 0) {
window.location = $(tr).find('a.name').attr('href');
}
});
FileActions.register('file', 'Download', OC.PERMISSION_READ, '', function(filename) {
- var tr = $('tr').filterAttr('data-file', filename)
+ var tr = $('tr').filterAttr('data-file', filename);
if (tr.length > 0) {
window.location = $(tr).find('a.name').attr('href');
}
});
FileActions.register('dir', 'Download', OC.PERMISSION_READ, '', function(filename) {
- var tr = $('tr').filterAttr('data-file', filename)
+ var tr = $('tr').filterAttr('data-file', filename);
if (tr.length > 0) {
window.location = $(tr).find('a.name').attr('href')+'&download';
}
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index eb5a6e8cb7f..3be89a39fa0 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -4,6 +4,10 @@ $(document).ready(function() {
if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !disableSharing) {
+ $('#fileList').one('fileActionsReady',function(){
+ OC.Share.loadIcons('file');
+ });
+
FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) {
if ($('#dir').val() == '/') {
var item = $('#dir').val() + filename;
@@ -33,6 +37,5 @@ $(document).ready(function() {
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
}
});
- OC.Share.loadIcons('file');
}
});
diff --git a/apps/files_sharing/l10n/eu.php b/apps/files_sharing/l10n/eu.php
index 8e13c24a926..7b6a4b08b3c 100644
--- a/apps/files_sharing/l10n/eu.php
+++ b/apps/files_sharing/l10n/eu.php
@@ -3,6 +3,12 @@ $TRANSLATIONS = array(
"The password is wrong. Try again." => "Pasahitza ez da egokia. Saiatu berriro.",
"Password" => "Pasahitza",
"Submit" => "Bidali",
+"Sorry, this link doesn’t seem to work anymore." => "Barkatu, lotura ez dirudi eskuragarria dagoenik.",
+"Reasons might be:" => "Arrazoiak hurrengoak litezke:",
+"the item was removed" => "fitxategia ezbatua izan da",
+"the link expired" => "lotura iraungi da",
+"sharing is disabled" => "elkarbanatzea ez dago gaituta",
+"For more info, please ask the person who sent this link." => "Informazio gehiagorako, mesedez eskatu lotura hau bidali zuen pertsonari",
"%s shared the folder %s with you" => "%sk zurekin %s karpeta elkarbanatu du",
"%s shared the file %s with you" => "%sk zurekin %s fitxategia elkarbanatu du",
"Download" => "Deskargatu",
diff --git a/apps/files_sharing/l10n/fr.php b/apps/files_sharing/l10n/fr.php
index b263cd87959..c97a1db97e4 100644
--- a/apps/files_sharing/l10n/fr.php
+++ b/apps/files_sharing/l10n/fr.php
@@ -3,6 +3,12 @@ $TRANSLATIONS = array(
"The password is wrong. Try again." => "Le mot de passe est incorrect. Veuillez réessayer.",
"Password" => "Mot de passe",
"Submit" => "Envoyer",
+"Sorry, this link doesn’t seem to work anymore." => "Désolé, mais le lien semble ne plus fonctionner.",
+"Reasons might be:" => "Les raisons peuvent être :",
+"the item was removed" => "l'item a été supprimé",
+"the link expired" => "le lien a expiré",
+"sharing is disabled" => "le partage est désactivé",
+"For more info, please ask the person who sent this link." => "Pour plus d'informations, veuillez contacter la personne qui a envoyé ce lien.",
"%s shared the folder %s with you" => "%s a partagé le répertoire %s avec vous",
"%s shared the file %s with you" => "%s a partagé le fichier %s avec vous",
"Download" => "Télécharger",
diff --git a/apps/files_sharing/l10n/ru_RU.php b/apps/files_sharing/l10n/ru_RU.php
deleted file mode 100644
index 52a41b1f513..00000000000
--- a/apps/files_sharing/l10n/ru_RU.php
+++ /dev/null
@@ -1,5 +0,0 @@
-<?php
-$TRANSLATIONS = array(
-"Download" => "Загрузка"
-);
-$PLURAL_FORMS = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);";
diff --git a/apps/files_sharing/l10n/zh_CN.GB2312.php b/apps/files_sharing/l10n/zh_CN.GB2312.php
deleted file mode 100644
index 206e1921faf..00000000000
--- a/apps/files_sharing/l10n/zh_CN.GB2312.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-$TRANSLATIONS = array(
-"Password" => "密码",
-"Submit" => "提交",
-"%s shared the folder %s with you" => "%s 与您分享了文件夹 %s",
-"%s shared the file %s with you" => "%s 与您分享了文件 %s",
-"Download" => "下载",
-"Upload" => "上传",
-"Cancel upload" => "取消上传",
-"No preview available for" => "没有预览可用于"
-);
-$PLURAL_FORMS = "nplurals=1; plural=0;";
diff --git a/apps/files_sharing/l10n/zh_CN.php b/apps/files_sharing/l10n/zh_CN.php
index 37898a1cd00..f541d6c155a 100644
--- a/apps/files_sharing/l10n/zh_CN.php
+++ b/apps/files_sharing/l10n/zh_CN.php
@@ -1,7 +1,14 @@
<?php
$TRANSLATIONS = array(
+"The password is wrong. Try again." => "用户名或密码错误!请重试",
"Password" => "密码",
"Submit" => "提交",
+"Sorry, this link doesn’t seem to work anymore." => "抱歉,此链接已失效",
+"Reasons might be:" => "可能原因是:",
+"the item was removed" => "此项已移除",
+"the link expired" => "链接过期",
+"sharing is disabled" => "共享已禁用",
+"For more info, please ask the person who sent this link." => "欲知详情,请联系发给你链接的人。",
"%s shared the folder %s with you" => "%s与您共享了%s文件夹",
"%s shared the file %s with you" => "%s与您共享了%s文件",
"Download" => "下载",
diff --git a/apps/files_sharing/l10n/zh_TW.php b/apps/files_sharing/l10n/zh_TW.php
index b950cbf8c9e..5cc33fd3830 100644
--- a/apps/files_sharing/l10n/zh_TW.php
+++ b/apps/files_sharing/l10n/zh_TW.php
@@ -1,7 +1,14 @@
<?php
$TRANSLATIONS = array(
+"The password is wrong. Try again." => "請檢查您的密碼並再試一次",
"Password" => "密碼",
"Submit" => "送出",
+"Sorry, this link doesn’t seem to work anymore." => "抱歉,此連結已經失效",
+"Reasons might be:" => "可能的原因:",
+"the item was removed" => "項目已經移除",
+"the link expired" => "連結過期",
+"sharing is disabled" => "分享功能已停用",
+"For more info, please ask the person who sent this link." => "請詢問告訴您此連結的人以瞭解更多",
"%s shared the folder %s with you" => "%s 和您分享了資料夾 %s ",
"%s shared the file %s with you" => "%s 和您分享了檔案 %s",
"Download" => "下載",
diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 2160fe9a393..33cd1428899 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -288,4 +288,4 @@ class Shared_Cache extends Cache {
return false;
}
-} \ No newline at end of file
+}
diff --git a/apps/files_sharing/lib/permissions.php b/apps/files_sharing/lib/permissions.php
index b6638564cd8..e2978e12bfb 100644
--- a/apps/files_sharing/lib/permissions.php
+++ b/apps/files_sharing/lib/permissions.php
@@ -106,4 +106,4 @@ class Shared_Permissions extends Permissions {
// Not a valid action for Shared Permissions
}
-} \ No newline at end of file
+}
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 5c23a9eb0d0..d91acbbb2bd 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -362,9 +362,13 @@ class Shared extends \OC\Files\Storage\Common {
case 'xb':
case 'a':
case 'ab':
- if (!$this->isUpdatable($path)) {
- return false;
- }
+ $exists = $this->file_exists($path);
+ if ($exists && !$this->isUpdatable($path)) {
+ return false;
+ }
+ if (!$exists && !$this->isCreatable(dirname($path))) {
+ return false;
+ }
}
$info = array(
'target' => $this->sharedFolder.$path,
@@ -391,7 +395,7 @@ class Shared extends \OC\Files\Storage\Common {
public function free_space($path) {
if ($path == '') {
- return \OC\Files\FREE_SPACE_UNKNOWN;
+ return \OC\Files\SPACE_UNKNOWN;
}
$source = $this->getSourcePath($path);
if ($source) {
diff --git a/apps/files_sharing/lib/watcher.php b/apps/files_sharing/lib/watcher.php
index e67d1ee9086..6fdfc1db36d 100644
--- a/apps/files_sharing/lib/watcher.php
+++ b/apps/files_sharing/lib/watcher.php
@@ -48,4 +48,4 @@ class Shared_Watcher extends Watcher {
}
}
-} \ No newline at end of file
+}
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index 741ab145384..ec6b4e815f8 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -112,9 +112,9 @@ if (isset($path)) {
if ($files_list === NULL ) {
$files_list = array($files);
}
- OC_Files::get($path, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
+ OC_Files::get($path, $files_list, $_SERVER['REQUEST_METHOD'] == 'HEAD');
} else {
- OC_Files::get($dir, $file, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
+ OC_Files::get($dir, $file, $_SERVER['REQUEST_METHOD'] == 'HEAD');
}
exit();
} else {
@@ -133,7 +133,7 @@ if (isset($path)) {
$tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path));
$tmpl->assign('fileTarget', basename($linkItem['file_target']));
$tmpl->assign('dirToken', $linkItem['token']);
- $allowPublicUploadEnabled = (($linkItem['permissions'] & OCP\PERMISSION_CREATE) ? true : false );
+ $allowPublicUploadEnabled = (bool) ($linkItem['permissions'] & OCP\PERMISSION_CREATE);
if (\OCP\App::isEnabled('files_encryption')) {
$allowPublicUploadEnabled = false;
}
@@ -172,6 +172,7 @@ if (isset($path)) {
} else {
$i['extension'] = '';
}
+ $i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($i['mimetype']);
}
$i['directory'] = $getPath;
$i['permissions'] = OCP\PERMISSION_READ;
@@ -194,6 +195,9 @@ if (isset($path)) {
$list->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path=');
$list->assign('downloadURL',
OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=');
+ $list->assign('isPublic', true);
+ $list->assign('sharingtoken', $token);
+ $list->assign('sharingroot', $basePath);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path=');
diff --git a/apps/files_sharing/templates/part.404.php b/apps/files_sharing/templates/part.404.php
index b5152e1511a..3ef117d7524 100644
--- a/apps/files_sharing/templates/part.404.php
+++ b/apps/files_sharing/templates/part.404.php
@@ -9,4 +9,4 @@
</ul>
<p><?php p($l->t('For more info, please ask the person who sent this link.')); ?></p>
</li>
-</ul> \ No newline at end of file
+</ul>
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index 746a715f3cc..c164b3ea2b7 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -79,6 +79,10 @@
<source src="<?php p($_['downloadURL']); ?>" type="<?php p($_['mimetype']); ?>" />
</video>
</div>
+ <?php elseif (\OC\Preview::isMimeSupported($_['mimetype'])): ?>
+ <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"/>
+ </div>
<?php else: ?>
<ul id="noPreview">
<li class="error">