From c814a7a8411d709efd56b884f0219a18c544fcc0 Mon Sep 17 00:00:00 2001 From: scambra Date: Wed, 26 Sep 2012 07:46:04 +0200 Subject: use interpolation for some translations in js --- core/js/share.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 7968edebb7a..de50e53a441 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -127,9 +127,9 @@ OC.Share={ var html = ''; + html += ''; } html += '
'; html += ''; @@ -349,13 +353,17 @@ OC.Share={ $('#linkPassText').attr('placeholder', t('core', 'Password protected')); } $('#expiration').show(); + $('#emailPrivateLink #email').show(); + $('#emailPrivateLink #emailButton').show(); }, hideLink:function() { $('#linkText').hide('blind'); $('#showPassword').hide(); $('#linkPass').hide(); - }, - dirname:function(path) { + $('#emailPrivateLink #email').hide(); + $('#emailPrivateLink #emailButton').hide(); + }, + dirname:function(path) { return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); }, showExpirationDate:function(date) { -- cgit v1.2.3 From 162a2c0fba6f7d7be3aa2372554e4a77a70a3e00 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Mon, 10 Dec 2012 23:22:42 +0100 Subject: moving sharing email code to core --- apps/files_sharing/ajax/email.php | 39 --------------------------------------- apps/files_sharing/js/share.js | 26 +------------------------- core/ajax/share.php | 36 ++++++++++++++++++++++++++++++++++++ core/js/share.js | 23 +++++++++++++++++++++++ 4 files changed, 60 insertions(+), 64 deletions(-) delete mode 100644 apps/files_sharing/ajax/email.php (limited to 'core/js/share.js') diff --git a/apps/files_sharing/ajax/email.php b/apps/files_sharing/ajax/email.php deleted file mode 100644 index 4ed4eef723a..00000000000 --- a/apps/files_sharing/ajax/email.php +++ /dev/null @@ -1,39 +0,0 @@ -t('User %s shared a file with you', $user); -if ($type === 'dir') - $subject = (string)$l->t('User %s shared a folder with you', $user); - -$text = (string)$l->t('User %s shared the file "%s" with you. It is available for download here: %s', array($user, $file, $link)); -if ($type === 'dir') - $text = (string)$l->t('User %s shared the folder "%s" with you. It is available for download here: %s', array($user, $file, $link)); - -// handle localhost installations -$server_host = OCP\Util::getServerHost(); -if ($server_host === 'localhost') - $server_host = "example.com"; - -$default_from = 'sharing-noreply@' . $server_host; -$from_address = OCP\Config::getUserValue($user, 'settings', 'email', $default_from ); - -// send it out now -try { - OCP\Util::sendMail($to_address, $to_address, $subject, $text, $from_address, $user); - OCP\JSON::success(); -} catch (Exception $exception) { - OCP\JSON::error(array('data' => array('message' => $exception->getMessage()))); -} diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index a83252867a9..8a546d62163 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -33,28 +33,4 @@ $(document).ready(function() { }); OC.Share.loadIcons('file'); } - - $('#emailPrivateLink').live('submit', function(event) { - event.preventDefault(); - var link = $('#linkText').val(); - var itemType = $('#dropdown').data('item-type'); - var itemSource = $('#dropdown').data('item-source'); - - var file = $('tr').filterAttr('data-id', String(itemSource)).data('file'); - var email = $('#email').val(); - if (email != '') { - $.post(OC.filePath('files_sharing', 'ajax', 'email.php'), { toaddress: email, link: link, type: itemType, file: file }, function(result) { - if (result && result.status == 'success') { - $('#email').css('font-weight', 'bold'); - $('#email').animate({ fontWeight: 'normal' }, 2000, function() { - $(this).val(''); - }).val('Email sent'); - } else { - OC.dialogs.alert(result.data.message, 'Error while sharing'); - } - }); - } - }); - - -}); \ No newline at end of file +}); diff --git a/core/ajax/share.php b/core/ajax/share.php index 41832a3c659..12206e0fd79 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -69,6 +69,42 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo ($return) ? OC_JSON::success() : OC_JSON::error(); } break; + case 'email': + // read post variables + $user = OCP\USER::getUser(); + $type = $_POST['itemType']; + $link = $_POST['link']; + $file = $_POST['file']; + $to_address = $_POST['toaddress']; + + // enable l10n support + $l = OC_L10N::get('core'); + + // setup the email + $subject = (string)$l->t('User %s shared a file with you', $user); + if ($type === 'dir') + $subject = (string)$l->t('User %s shared a folder with you', $user); + + $text = (string)$l->t('User %s shared the file "%s" with you. It is available for download here: %s', array($user, $file, $link)); + if ($type === 'dir') + $text = (string)$l->t('User %s shared the folder "%s" with you. It is available for download here: %s', array($user, $file, $link)); + + // handle localhost installations + $server_host = OCP\Util::getServerHost(); + if ($server_host === 'localhost') + $server_host = "example.com"; + + $default_from = 'sharing-noreply@' . $server_host; + $from_address = OCP\Config::getUserValue($user, 'settings', 'email', $default_from ); + + // send it out now + try { + OCP\Util::sendMail($to_address, $to_address, $subject, $text, $from_address, $user); + OCP\JSON::success(); + } catch (Exception $exception) { + OCP\JSON::error(array('data' => array('message' => $exception->getMessage()))); + } + break; } } else if (isset($_GET['fetch'])) { switch ($_GET['fetch']) { diff --git a/core/js/share.js b/core/js/share.js index 962983e2f35..9f71f1bb66b 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -555,4 +555,27 @@ $(document).ready(function() { }); }); + + $('#emailPrivateLink').live('submit', function(event) { + event.preventDefault(); + var link = $('#linkText').val(); + var itemType = $('#dropdown').data('item-type'); + var itemSource = $('#dropdown').data('item-source'); + var file = $('tr').filterAttr('data-id', String(itemSource)).data('file'); + var email = $('#email').val(); + if (email != '') { + $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file}, function(result) { + if (result && result.status == 'success') { + $('#email').css('font-weight', 'bold'); + $('#email').animate({ fontWeight: 'normal' }, 2000, function() { + $(this).val(''); + }).val(t('core','Email sent')); + } else { + OC.dialogs.alert(result.data.message, t('core', 'Error while sharing')); + } + }); + } + }); + + }); -- cgit v1.2.3 From c938a4f791182d86045a45bcffda37c1b6e651f8 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 12 Dec 2012 12:34:28 +0100 Subject: feedback to the user while request is being processed --- core/js/share.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 9f71f1bb66b..df5ebf008b4 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -170,7 +170,7 @@ OC.Share={ html += '
'; html += ''; } html += '
'; @@ -564,7 +564,14 @@ $(document).ready(function() { var file = $('tr').filterAttr('data-id', String(itemSource)).data('file'); var email = $('#email').val(); if (email != '') { - $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file}, function(result) { + $('#email').attr('disabled', "disabled"); + $('#email').val(t('core', 'Sending ...')); + $('#emailButton').attr('disabled', "disabled"); + + $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file}, + function(result) { + $('#email').attr('disabled', "false"); + $('#emailButton').attr('disabled', "false"); if (result && result.status == 'success') { $('#email').css('font-weight', 'bold'); $('#email').animate({ fontWeight: 'normal' }, 2000, function() { -- cgit v1.2.3 From 1dd79cc8e16f2972b8a8fea03f4e8ecfc1db5ac9 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Tue, 4 Dec 2012 14:06:44 +0100 Subject: set password for shared links when the user press enter and when he leaves the password field --- core/js/share.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index df5ebf008b4..984fce047b8 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -520,16 +520,26 @@ $(document).ready(function() { $('#linkPass').toggle('blind'); }); - $('#linkPassText').live('focusout', function(event) { - var itemType = $('#dropdown').data('item-type'); - var itemSource = $('#dropdown').data('item-source'); - OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $(this).val(), OC.PERMISSION_READ, function() { - $('#linkPassText').val(''); - $('#linkPassText').attr('placeholder', t('core', 'Password protected')); - }); - $('#linkPassText').attr('placeholder', t('core', 'Password protected')); + $('#linkPassText').live('focusout keyup', function(event) { + if ( event.type == 'focusout' || event.keyCode == 13 ) { + var itemType = $('#dropdown').data('item-type'); + var itemSource = $('#dropdown').data('item-source'); + if ( $('#linkPassText').attr('passwordChanged') == 'true' ) { + OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $(this).val(), OC.PERMISSION_READ, function() { + $('#linkPassText').val(''); + $('#linkPassText').attr('placeholder', t('core', 'Password protected')); + $('#linkPassText').attr('passwordChanged', 'false'); + }); + } + } }); + $('#linkPassText').live('focusout keyup', function(event) { + if ( event.keyCode != 13 ) { + $('#linkPassText').attr('passwordChanged', 'true'); + } + }); + $('#expirationCheckbox').live('click', function() { if (this.checked) { OC.Share.showExpirationDate(''); -- cgit v1.2.3 From c457e15b201632bec5f0ad0030f7e0259485b0e0 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Wed, 5 Dec 2012 14:17:21 +0100 Subject: some more usability improvements: merged pull request https://github.com/owncloud/core/pull/121 into this patch with fixes for all issues mentioned in 121 --- core/js/share.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 984fce047b8..c218c2c1233 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -161,9 +161,9 @@ OC.Share={ if (link) { html += ''; - html += ''; + html += ''; } html += '
'; html += ''; @@ -373,18 +373,18 @@ OC.Share={ $('#linkPassText').attr('placeholder', t('core', 'Password protected')); } $('#expiration').show(); - $('#emailPrivateLink #email').show(); - $('#emailPrivateLink #emailButton').show(); + $('#emailPrivateLink #email').show(); + $('#emailPrivateLink #emailButton').show(); }, hideLink:function() { $('#linkText').hide('blind'); $('#showPassword').hide(); $('#showPassword+label').hide(); $('#linkPass').hide(); - $('#emailPrivateLink #email').hide(); - $('#emailPrivateLink #emailButton').hide(); - }, - dirname:function(path) { + $('#emailPrivateLink #email').hide(); + $('#emailPrivateLink #emailButton').hide(); + }, + dirname:function(path) { return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); }, showExpirationDate:function(date) { @@ -401,16 +401,16 @@ OC.Share={ $(document).ready(function() { if(typeof monthNames != 'undefined'){ - $.datepicker.setDefaults({ - monthNames: monthNames, - monthNamesShort: $.map(monthNames, function(v) { return v.slice(0,3)+'.'; }), - dayNames: dayNames, - dayNamesMin: $.map(dayNames, function(v) { return v.slice(0,2); }), - dayNamesShort: $.map(dayNames, function(v) { return v.slice(0,3)+'.'; }), - firstDay: firstDay - }); - } - $('#fileList').on('click', 'a.share', function(event) { + $.datepicker.setDefaults({ + monthNames: monthNames, + monthNamesShort: $.map(monthNames, function(v) { return v.slice(0,3)+'.'; }), + dayNames: dayNames, + dayNamesMin: $.map(dayNames, function(v) { return v.slice(0,2); }), + dayNamesShort: $.map(dayNames, function(v) { return v.slice(0,3)+'.'; }), + firstDay: firstDay + }); + } + $(document).on('click', 'a.share', function(event) { event.stopPropagation(); if ($(this).data('item-type') !== undefined && $(this).data('item') !== undefined) { var itemType = $(this).data('item-type'); @@ -444,12 +444,12 @@ $(document).ready(function() { } }); - $('#fileList').on('mouseenter', '#dropdown #shareWithList li', function(event) { + $(document).on('mouseenter', '#dropdown #shareWithList li', function(event) { // Show permissions and unshare button $(':hidden', this).filter(':not(.cruds)').show(); }); - $('#fileList').on('mouseleave', '#dropdown #shareWithList li', function(event) { + $(document).on('mouseleave', '#dropdown #shareWithList li', function(event) { // Hide permissions and unshare button if (!$('.cruds', this).is(':visible')) { $('a', this).hide(); @@ -462,11 +462,11 @@ $(document).ready(function() { } }); - $('#fileList').on('click', '#dropdown .showCruds', function() { + $(document).on('click', '#dropdown .showCruds', function() { $(this).parent().find('.cruds').toggle(); }); - $('#fileList').on('click', '#dropdown .unshare', function() { + $(document).on('click', '#dropdown .unshare', function() { var li = $(this).parent(); var itemType = $('#dropdown').data('item-type'); var itemSource = $('#dropdown').data('item-source'); @@ -483,7 +483,7 @@ $(document).ready(function() { }); }); - $('#fileList').on('change', '#dropdown .permissions', function() { + $(document).on('change', '#dropdown .permissions', function() { if ($(this).attr('name') == 'edit') { var li = $(this).parent().parent() var checkboxes = $('.permissions', li); @@ -496,10 +496,17 @@ $(document).ready(function() { var li = $(this).parent().parent().parent(); var checkboxes = $('.permissions', li); // Uncheck Edit if Create, Update, and Delete are not checked - if (!$(this).is(':checked') && !$(checkboxes).filter('input[name="create"]').is(':checked') && !$(checkboxes).filter('input[name="update"]').is(':checked') && !$(checkboxes).filter('input[name="delete"]').is(':checked')) { + if (!$(this).is(':checked') + && !$(checkboxes).filter('input[name="create"]').is(':checked') + && !$(checkboxes).filter('input[name="update"]').is(':checked') + && !$(checkboxes).filter('input[name="delete"]').is(':checked')) + { $(checkboxes).filter('input[name="edit"]').attr('checked', false); // Check Edit if Create, Update, or Delete is checked - } else if (($(this).attr('name') == 'create' || $(this).attr('name') == 'update' || $(this).attr('name') == 'delete')) { + } else if (($(this).attr('name') == 'create' + || $(this).attr('name') == 'update' + || $(this).attr('name') == 'delete')) + { $(checkboxes).filter('input[name="edit"]').attr('checked', true); } } @@ -507,10 +514,14 @@ $(document).ready(function() { $(checkboxes).filter(':not(input[name="edit"])').filter(':checked').each(function(index, checkbox) { permissions |= $(checkbox).data('permissions'); }); - OC.Share.setPermissions($('#dropdown').data('item-type'), $('#dropdown').data('item-source'), $(li).data('share-type'), $(li).data('share-with'), permissions); + OC.Share.setPermissions($('#dropdown').data('item-type'), + $('#dropdown').data('item-source'), + $(li).data('share-type'), + $(li).data('share-with'), + permissions); }); - $('#fileList').on('change', '#dropdown #linkCheckbox', function() { + $(document).on('change', '#dropdown #linkCheckbox', function() { var itemType = $('#dropdown').data('item-type'); var itemSource = $('#dropdown').data('item-source'); if (this.checked) { @@ -532,12 +543,12 @@ $(document).ready(function() { } }); - $('#fileList').on('click', '#dropdown #linkText', function() { + $(document).on('click', '#dropdown #linkText', function() { $(this).focus(); $(this).select(); }); - $('#fileList').on('click', '#dropdown #showPassword', function() { + $(document).on('click', '#dropdown #showPassword', function() { $('#linkPass').toggle('blind'); if (!$('#showPassword').is(':checked') ) { var itemType = $('#dropdown').data('item-type'); @@ -548,7 +559,7 @@ $(document).ready(function() { } }); - $('#fileList').on('focusout keyup', '#dropdown #linkPassText', function(event) { + $(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'); @@ -560,7 +571,7 @@ $(document).ready(function() { } }); - $('#fileList').on('click', '#dropdown #expirationCheckbox', function() { + $(document).on('click', '#dropdown #expirationCheckbox', function() { if (this.checked) { OC.Share.showExpirationDate(''); } else { @@ -575,7 +586,7 @@ $(document).ready(function() { } }); - $('#fileList').on('change', '#dropdown #expirationDate', function() { + $(document).on('change', '#dropdown #expirationDate', function() { var itemType = $('#dropdown').data('item-type'); var itemSource = $('#dropdown').data('item-source'); $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setExpirationDate', itemType: itemType, itemSource: itemSource, date: $(this).val() }, function(result) { @@ -586,33 +597,33 @@ $(document).ready(function() { }); - $('#fileList').on('submit', '#dropdown #emailPrivateLink', function(event) { - event.preventDefault(); - var link = $('#linkText').val(); - var itemType = $('#dropdown').data('item-type'); - var itemSource = $('#dropdown').data('item-source'); - var file = $('tr').filterAttr('data-id', String(itemSource)).data('file'); - var email = $('#email').val(); - if (email != '') { - $('#email').attr('disabled', "disabled"); - $('#email').val(t('core', 'Sending ...')); - $('#emailButton').attr('disabled', "disabled"); + $(document).on('submit', '#dropdown #emailPrivateLink', function(event) { + event.preventDefault(); + var link = $('#linkText').val(); + var itemType = $('#dropdown').data('item-type'); + var itemSource = $('#dropdown').data('item-source'); + var file = $('tr').filterAttr('data-id', String(itemSource)).data('file'); + var email = $('#email').val(); + if (email != '') { + $('#email').attr('disabled', "disabled"); + $('#email').val(t('core', 'Sending ...')); + $('#emailButton').attr('disabled', "disabled"); - $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file}, - function(result) { - $('#email').attr('disabled', "false"); - $('#emailButton').attr('disabled', "false"); - if (result && result.status == 'success') { - $('#email').css('font-weight', 'bold'); - $('#email').animate({ fontWeight: 'normal' }, 2000, function() { - $(this).val(''); - }).val(t('core','Email sent')); - } else { - OC.dialogs.alert(result.data.message, t('core', 'Error while sharing')); - } - }); - } - }); + $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file}, + function(result) { + $('#email').attr('disabled', "false"); + $('#emailButton').attr('disabled', "false"); + if (result && result.status == 'success') { + $('#email').css('font-weight', 'bold'); + $('#email').animate({ fontWeight: 'normal' }, 2000, function() { + $(this).val(''); + }).val(t('core','Email sent')); + } else { + OC.dialogs.alert(result.data.message, t('core', 'Error while sharing')); + } + }); + } + }); }); -- cgit v1.2.3 From 45ed0c601003b1f2ebd9e5bb301080b37d43080e Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Mon, 11 Feb 2013 15:37:01 +0100 Subject: if you add/remove more than one user from the share dialog replacing 'Share' with 'Shared' will lead to a string with more and more trailing 'd's --- core/js/share.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 58cb787b6d1..6d1c3954044 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -26,7 +26,7 @@ OC.Share={ var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share'); action.find('img').attr('src', image); action.addClass('permanent'); - action.html(action.html().replace(t('core', 'Share'), t('core', 'Shared'))); + action.html(t('core', 'Shared')); } var dir = $('#dir').val(); if (dir.length > 1) { @@ -40,7 +40,7 @@ OC.Share={ if (img.attr('src') != OC.imagePath('core', 'actions/public')) { img.attr('src', image); action.addClass('permanent'); - action.html(action.html().replace(t('core', 'Share'), t('core', 'Shared'))); + action.html(t('core', 'Shared')); } } last = path; @@ -87,10 +87,10 @@ OC.Share={ action.find('img').attr('src', image); if (shares) { action.addClass('permanent'); - action.html(action.html().replace(t('core', 'Share'), t('core', 'Shared'))); + action.html(t('core', 'Shared')); } else { action.removeClass('permanent'); - action.html(action.html().replace(t('core', 'Shared'), t('core', 'Share'))); + action.html(t('core', 'Share')); } } if (shares) { -- cgit v1.2.3 From d8e8dab0066439414f282fa15dd1d9d3b851c310 Mon Sep 17 00:00:00 2001 From: raghunayyar Date: Wed, 20 Feb 2013 21:37:23 +0530 Subject: Fixes the Email Button and the email input Width. --- core/js/share.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 6d1c3954044..231d07cf3b9 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -186,8 +186,8 @@ OC.Share={ html += '
'; html += '
'; html += ''; } html += '
'; -- cgit v1.2.3 From 6ecc3d7ee1a7ae1a33b4906a0ffa1ecc3760c2e1 Mon Sep 17 00:00:00 2001 From: raghunayyar Date: Wed, 20 Feb 2013 23:08:21 +0530 Subject: Reduced email input width by 10% to increase space. --- core/js/share.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 231d07cf3b9..dc62dd2e04c 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -186,7 +186,7 @@ OC.Share={ html += '
'; html += ''; html += ''; } -- cgit v1.2.3 From aa2ea9e3de6002a8b58adf122a4562ed478c2a81 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Mon, 25 Feb 2013 20:20:29 -0500 Subject: Fix adding share icons to share action --- core/js/share.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 6d1c3954044..faa64103b7b 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -24,9 +24,9 @@ OC.Share={ var file = $('tr').filterAttr('data-file', OC.basename(item)); if (file.length > 0) { var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share'); - action.find('img').attr('src', image); + var img = action.find('img').attr('src', image); action.addClass('permanent'); - action.html(t('core', 'Shared')); + action.html(t('core', ' Shared')).prepend(img); } var dir = $('#dir').val(); if (dir.length > 1) { @@ -40,7 +40,7 @@ OC.Share={ if (img.attr('src') != OC.imagePath('core', 'actions/public')) { img.attr('src', image); action.addClass('permanent'); - action.html(t('core', 'Shared')); + action.html(t('core', ' Shared')).prepend(img); } } last = path; @@ -84,13 +84,13 @@ OC.Share={ $('a.share[data-item="'+itemSource+'"]').css('background', 'url('+image+') no-repeat center'); } else { var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share'); - action.find('img').attr('src', image); + var img = action.find('img').attr('src', image); if (shares) { action.addClass('permanent'); - action.html(t('core', 'Shared')); + action.html(t('core', ' Shared')).prepend(img); } else { action.removeClass('permanent'); - action.html(t('core', 'Share')); + action.html(t('core', ' Share')).prepend(img); } } if (shares) { -- cgit v1.2.3 From 5b732ac1eab641c02a376ec15ce7ada1aeb3e6b0 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Mon, 25 Feb 2013 20:52:01 -0500 Subject: Move space --- core/js/share.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index faa64103b7b..f8a8e0ee35a 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -26,7 +26,7 @@ OC.Share={ var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share'); var img = action.find('img').attr('src', image); action.addClass('permanent'); - action.html(t('core', ' Shared')).prepend(img); + action.html(' '+t('core', 'Shared')).prepend(img); } var dir = $('#dir').val(); if (dir.length > 1) { @@ -40,7 +40,7 @@ OC.Share={ if (img.attr('src') != OC.imagePath('core', 'actions/public')) { img.attr('src', image); action.addClass('permanent'); - action.html(t('core', ' Shared')).prepend(img); + action.html(' '+t('core', 'Shared')).prepend(img); } } last = path; @@ -87,10 +87,10 @@ OC.Share={ var img = action.find('img').attr('src', image); if (shares) { action.addClass('permanent'); - action.html(t('core', ' Shared')).prepend(img); + action.html(' '+t('core', 'Shared')).prepend(img); } else { action.removeClass('permanent'); - action.html(t('core', ' Share')).prepend(img); + action.html(' '+t('core', 'Share')).prepend(img); } } if (shares) { -- cgit v1.2.3 From e01ab04d2bb335dd8086d6b892fa106d38a80996 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Wed, 27 Feb 2013 17:57:40 +0100 Subject: reduce minimum length for username suggestions in share dialog, fix #1666 --- core/js/share.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 328d57928ec..145c31a86c8 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -213,7 +213,7 @@ OC.Share={ } }); } - $('#shareWith').autocomplete({minLength: 2, source: function(search, response) { + $('#shareWith').autocomplete({minLength: 1, source: function(search, response) { // if (cache[search.term]) { // response(cache[search.term]); // } else { -- cgit v1.2.3 From 577945bd338e3f9b1f30aa026c84247f2720ecb6 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Mon, 4 Mar 2013 00:54:21 +0100 Subject: Sanitize shareWith --- core/js/share.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 145c31a86c8..34f24da4df7 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -309,12 +309,12 @@ OC.Share={ if (permissions & OC.PERMISSION_SHARE) { shareChecked = 'checked="checked"'; } - var html = '
  • '; + var html = '
  • '; html += ''; if(shareWith.length > 14){ - html += shareWithDisplayName.substr(0,11) + '...'; + html += escapeHTML(shareWithDisplayName.substr(0,11) + '...'); }else{ - html += shareWithDisplayName; + html += escapeHTML(shareWithDisplayName); } if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) { if (editChecked == '') { -- cgit v1.2.3 From 6e5e8c6b46f24027ee86284844f43e744a3f5f4c Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Thu, 7 Mar 2013 22:30:12 -0500 Subject: Fix #2080 and fix #2141 --- core/js/share.js | 88 +++++++++++++++++++++------------------------------- lib/public/share.php | 25 +++++++++------ 2 files changed, 51 insertions(+), 62 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 34f24da4df7..0b6afda59c4 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -10,8 +10,9 @@ OC.Share={ // Load all share icons $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) { if (result && result.status === 'success') { - $.each(result.data, function(item, hasLink) { - OC.Share.statuses[item] = hasLink; + $.each(result.data, function(item, data) { + OC.Share.statuses[item] = data; + var hasLink = data['link']; // Links override shared in terms of icon display if (hasLink) { var image = OC.imagePath('core', 'actions/public'); @@ -21,30 +22,33 @@ OC.Share={ if (itemType != 'file' && itemType != 'folder') { $('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center'); } else { - var file = $('tr').filterAttr('data-file', OC.basename(item)); + var file = $('tr').filterAttr('data-id', item); if (file.length > 0) { var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share'); var img = action.find('img').attr('src', image); action.addClass('permanent'); action.html(' '+t('core', 'Shared')).prepend(img); - } - var dir = $('#dir').val(); - if (dir.length > 1) { - var last = ''; - var path = dir; - // Search for possible parent folders that are shared - while (path != last) { - if (path == item) { - var action = $('.fileactions .action').filterAttr('data-action', 'Share'); - var img = action.find('img'); - if (img.attr('src') != OC.imagePath('core', 'actions/public')) { - img.attr('src', image); - action.addClass('permanent'); - action.html(' '+t('core', 'Shared')).prepend(img); + } else { + var dir = $('#dir').val(); + if (dir.length > 1) { + var last = ''; + var path = dir; + // Search for possible parent folders that are shared + while (path != last) { + if (path == data['path']) { + var actions = $('.fileactions .action').filterAttr('data-action', 'Share'); + $.each(actions, function(index, action) { + var img = $(action).find('img'); + if (img.attr('src') != OC.imagePath('core', 'actions/public')) { + img.attr('src', image); + $(action).addClass('permanent'); + $(action).html(' '+t('core', 'Shared')).prepend(img); + } + }); } + last = path; + path = OC.Share.dirname(path); } - last = path; - path = OC.Share.dirname(path); } } } @@ -53,15 +57,6 @@ OC.Share={ }); }, updateIcon:function(itemType, itemSource) { - if (itemType == 'file' || itemType == 'folder') { - var file = $('tr').filterAttr('data-id', String(itemSource)); - var filename = file.data('file'); - if ($('#dir').val() == '/') { - itemSource = $('#dir').val() + filename; - } else { - itemSource = $('#dir').val() + '/' + filename; - } - } var shares = false; var link = false; var image = OC.imagePath('core', 'actions/share'); @@ -83,18 +78,21 @@ OC.Share={ if (itemType != 'file' && itemType != 'folder') { $('a.share[data-item="'+itemSource+'"]').css('background', 'url('+image+') no-repeat center'); } else { - var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share'); - var img = action.find('img').attr('src', image); - if (shares) { - action.addClass('permanent'); - action.html(' '+t('core', 'Shared')).prepend(img); - } else { - action.removeClass('permanent'); - action.html(' '+t('core', 'Share')).prepend(img); + var file = $('tr').filterAttr('data-id', String(itemSource)); + if (file.length > 0) { + var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share'); + var img = action.find('img').attr('src', image); + if (shares) { + action.addClass('permanent'); + action.html(' '+t('core', 'Shared')).prepend(img); + } else { + action.removeClass('permanent'); + action.html(' '+t('core', 'Share')).prepend(img); + } } } if (shares) { - OC.Share.statuses[itemSource] = link; + OC.Share.statuses[itemSource]['link'] = link; } else { delete OC.Share.statuses[itemSource]; } @@ -102,21 +100,7 @@ OC.Share={ loadItem:function(itemType, itemSource) { var data = ''; var checkReshare = true; - // Switch file sources to path to check if status is set - if (itemType == 'file' || itemType == 'folder') { - var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file'); - if ($('#dir').val() == '/') { - var item = $('#dir').val() + filename; - } else { - var item = $('#dir').val() + '/' + filename; - } - if (item.substring(0, 8) != '/Shared/') { - checkReshare = false; - } - } else { - var item = itemSource; - } - if (typeof OC.Share.statuses[item] === 'undefined') { + if (typeof OC.Share.statuses[itemSource] === 'undefined') { // NOTE: Check does not always work and misses some shares, fix later checkShares = true; } else { diff --git a/lib/public/share.php b/lib/public/share.php index 59f41a9bfd6..d1ae0312bf6 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -759,7 +759,7 @@ class Share { if ($format == self::FORMAT_STATUSES) { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' - .' `share_type`, `file_source`, `path`, `expiration`'; + .' `share_type`, `file_source`, `path`, `expiration`, `storage`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`'; } @@ -768,7 +768,7 @@ class Share { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' .' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,' - .' `expiration`, `token`'; + .' `expiration`, `token`, `storage`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,' .' `stime`, `file_source`, `expiration`, `token`'; @@ -804,6 +804,7 @@ class Share { $items = array(); $targets = array(); $switchedItems = array(); + $mounts = array(); while ($row = $result->fetchRow()) { // Filter out duplicate group shares for users with unique targets if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) { @@ -848,8 +849,13 @@ class Share { if (isset($row['parent'])) { $row['path'] = '/Shared/'.basename($row['path']); } else { - // Strip 'files' from path - $row['path'] = substr($row['path'], 5); + if (!isset($mounts[$row['storage']])) { + $mounts[$row['storage']] = \OC\Files\Mount::findByNumericId($row['storage']); + } + if ($mounts[$row['storage']]) { + $path = $mounts[$row['storage']]->getMountPoint().$row['path']; + $row['path'] = substr($path, $root); + } } } if (isset($row['expiration'])) { @@ -957,15 +963,14 @@ class Share { return $items; } else if ($format == self::FORMAT_STATUSES) { $statuses = array(); - // Switch column to path for files and folders, used for determining statuses inside of folders - if ($itemType == 'file' || $itemType == 'folder') { - $column = 'path'; - } foreach ($items as $item) { if ($item['share_type'] == self::SHARE_TYPE_LINK) { - $statuses[$item[$column]] = true; + $statuses[$item[$column]]['link'] = true; } else if (!isset($statuses[$item[$column]])) { - $statuses[$item[$column]] = false; + $statuses[$item[$column]]['link'] = false; + } + if ($itemType == 'file' || $itemType == 'folder') { + $statuses[$item[$column]]['path'] = $item['path']; } } return $statuses; -- cgit v1.2.3 From 9ad03b61a357fa1edb322ffd1aab4d62daa856e5 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Fri, 8 Mar 2013 17:29:05 +0100 Subject: Update share.js Added HTML escaping --- core/js/share.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 0b6afda59c4..8e767663f12 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -84,10 +84,10 @@ OC.Share={ var img = action.find('img').attr('src', image); if (shares) { action.addClass('permanent'); - action.html(' '+t('core', 'Shared')).prepend(img); + action.html(' '+ escapeHTML(t('core', 'Shared'))).prepend(img); } else { action.removeClass('permanent'); - action.html(' '+t('core', 'Share')).prepend(img); + action.html(' '+ escapeHTML(t('core', 'Share'))).prepend(img); } } } -- cgit v1.2.3