diff options
-rw-r--r-- | apps/files_sharing/css/404.css | 12 | ||||
-rw-r--r-- | apps/files_sharing/public.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/templates/part.404.php | 12 | ||||
-rw-r--r-- | apps/files_trashbin/ajax/isEmpty.php | 14 | ||||
-rw-r--r-- | core/js/share.js | 30 | ||||
-rw-r--r-- | core/templates/404.php | 16 | ||||
-rw-r--r-- | lib/files/cache/cache.php | 2 | ||||
-rw-r--r-- | lib/public/share.php | 3 | ||||
-rwxr-xr-x | lib/util.php | 7 | ||||
-rw-r--r-- | tests/lib/util.php | 33 |
10 files changed, 111 insertions, 24 deletions
diff --git a/apps/files_sharing/css/404.css b/apps/files_sharing/css/404.css new file mode 100644 index 00000000000..2ed81df3b86 --- /dev/null +++ b/apps/files_sharing/css/404.css @@ -0,0 +1,12 @@ + +#body-login .error-broken-link{ + text-align:left;color:#fff; +} + +#body-login .error-broken-link ul{ + margin:10px 0 10px 0; +} + +#body-login .error-broken-link ul li{ + list-style: disc;list-style-position:inside;cursor:default; +} diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 3f8e29345a7..741ab145384 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -234,6 +234,12 @@ if (isset($path)) { } else { OCP\Util::writeLog('share', 'could not resolve linkItem', \OCP\Util::DEBUG); } + +$errorTemplate = new OCP\Template('files_sharing', 'part.404', ''); +$errorContent = $errorTemplate->fetchPage(); + header('HTTP/1.0 404 Not Found'); +OCP\Util::addStyle('files_sharing', '404'); $tmpl = new OCP\Template('', '404', 'guest'); +$tmpl->assign('content', $errorContent); $tmpl->printPage(); diff --git a/apps/files_sharing/templates/part.404.php b/apps/files_sharing/templates/part.404.php new file mode 100644 index 00000000000..b5152e1511a --- /dev/null +++ b/apps/files_sharing/templates/part.404.php @@ -0,0 +1,12 @@ +<ul> + <li class="error error-broken-link"> + <p><?php p($l->t('Sorry, this link doesn’t seem to work anymore.')) ?></p> + <p><?php p($l->t('Reasons might be:')); ?></p> + <ul> + <li><?php p($l->t('the item was removed')); ?></li> + <li><?php p($l->t('the link expired')); ?></li> + <li><?php p($l->t('sharing is disabled')); ?></li> + </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 diff --git a/apps/files_trashbin/ajax/isEmpty.php b/apps/files_trashbin/ajax/isEmpty.php new file mode 100644 index 00000000000..2e54c7e77b9 --- /dev/null +++ b/apps/files_trashbin/ajax/isEmpty.php @@ -0,0 +1,14 @@ +<?php + +/* + * Check if trash bin is empty to re-enable the deleted files button if needed + */ + +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$trashStatus = OCA\Files_Trashbin\Trashbin::isEmpty(OCP\User::getUser()); + +OCP\JSON::success(array("data" => array("isEmpty" => $trashStatus))); + + diff --git a/core/js/share.js b/core/js/share.js index e59669cbc2b..b4b5159b0b5 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -592,8 +592,7 @@ $(document).ready(function() { } // Update the share information - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, function(data) { - return; + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, function(data) { }); }); @@ -609,13 +608,26 @@ $(document).ready(function() { }); $(document).on('focusout keyup', '#dropdown #linkPassText', function(event) { - if ( $('#linkPassText').val() != '' && (event.type == 'focusout' || event.keyCode == 13) ) { - var itemType = $('#dropdown').data('item-type'); - var itemSource = $('#dropdown').data('item-source'); - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), OC.PERMISSION_READ, function() { - console.log("password set to: '" + $('#linkPassText').val() +"' by event: " + event.type); - $('#linkPassText').val(''); - $('#linkPassText').attr('placeholder', t('core', 'Password protected')); + var linkPassText = $('#linkPassText'); + if ( linkPassText.val() != '' && (event.type == 'focusout' || event.keyCode == 13) ) { + + var allowPublicUpload = $('#sharingDialogAllowPublicUpload').is(':checked'); + var dropDown = $('#dropdown'); + var itemType = dropDown.data('item-type'); + var itemSource = dropDown.data('item-source'); + var permissions = 0; + + // Calculate permissions + if (allowPublicUpload) { + permissions = OC.PERMISSION_UPDATE + OC.PERMISSION_CREATE + OC.PERMISSION_READ; + } else { + permissions = OC.PERMISSION_READ; + } + + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, function() { + console.log("password set to: '" + linkPassText.val() +"' by event: " + event.type); + linkPassText.val(''); + linkPassText.attr('placeholder', t('core', 'Password protected')); }); } }); diff --git a/core/templates/404.php b/core/templates/404.php index ee17f0de8e1..bf1e03e6bc9 100644 --- a/core/templates/404.php +++ b/core/templates/404.php @@ -7,9 +7,13 @@ if(!isset($_)) {//also provide standalone error page exit; } ?> -<ul> - <li class='error'> - <?php p($l->t( 'Cloud not found' )); ?><br/> - <p class='hint'><?php if(isset($_['file'])) p($_['file'])?></p> - </li> -</ul> +<?php if (isset($_['content'])): ?> + <?php print_unescaped($_['content']) ?> +<?php else: ?> + <ul> + <li class="error"> + <?php p($l->t( 'Cloud not found' )); ?><br/> + <p class='hint'><?php if(isset($_['file'])) p($_['file'])?></p> + </li> + </ul> +<?php endif; ?> diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index 3818fdbd840..5b8dc46b771 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -200,7 +200,7 @@ class Cache { $data['path'] = $file; $data['parent'] = $this->getParentId($file); - $data['name'] = basename($file); + $data['name'] = \OC_Util::basename($file); $data['encrypted'] = isset($data['encrypted']) ? ((int)$data['encrypted']) : 0; list($queryParts, $params) = $this->buildParts($data); diff --git a/lib/public/share.php b/lib/public/share.php index 596a729a47d..b349dd48776 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -454,6 +454,9 @@ class Share { $forcePortable = (CRYPT_BLOWFISH != 1); $hasher = new \PasswordHash(8, $forcePortable); $shareWith = $hasher->HashPassword($shareWith.\OC_Config::getValue('passwordsalt', '')); + } else { + // reuse the already set password + $shareWith = $checkExists['share_with']; } // Generate token diff --git a/lib/util.php b/lib/util.php index 1f666a5e37f..b7dc2207e6c 100755 --- a/lib/util.php +++ b/lib/util.php @@ -894,4 +894,11 @@ class OC_Util { return $value; } + + public static function basename($file) + { + $file = rtrim($file, '/'); + $t = explode('/', $file); + return array_pop($t); + } } diff --git a/tests/lib/util.php b/tests/lib/util.php index 9742d57ac7a..a038538d7ea 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -8,12 +8,9 @@ class Test_Util extends PHPUnit_Framework_TestCase { - // Constructor - function Test_Util() { + function testFormatDate() { date_default_timezone_set("UTC"); - } - function testFormatDate() { $result = OC_Util::formatDate(1350129205); $expected = 'October 13, 2012 11:53'; $this->assertEquals($expected, $result); @@ -61,8 +58,28 @@ class Test_Util extends PHPUnit_Framework_TestCase { OC_Config::deleteKey('mail_domain'); } - function testGetInstanceIdGeneratesValidId() { - OC_Config::deleteKey('instanceid'); - $this->assertStringStartsWith('oc', OC_Util::getInstanceId()); - } + function testGetInstanceIdGeneratesValidId() { + OC_Config::deleteKey('instanceid'); + $this->assertStringStartsWith('oc', OC_Util::getInstanceId()); + } + + /** + * @dataProvider baseNameProvider + */ + public function testBaseName($expected, $file) + { + $base = \OC_Util::basename($file); + $this->assertEquals($expected, $base); + } + + public function baseNameProvider() + { + return array( + array('public_html', '/home/user/public_html/'), + array('public_html', '/home/user/public_html'), + array('', '/'), + array('public_html', 'public_html'), + array('442aa682de2a64db1e010f50e60fd9c9', 'local::C:\Users\ADMINI~1\AppData\Local\Temp\2/442aa682de2a64db1e010f50e60fd9c9/') + ); + } } |