From 6c29334b4888309e7b60cbdf4defdac1c47195bf Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sat, 1 Sep 2012 18:53:48 -0400 Subject: Add support for share expiration --- core/js/share.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index 4c164f65b24..2f3b5c2fa50 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -143,6 +143,9 @@ OC.Share={ html += ''; html += ''; } + html += '
'; + html += ''; + html += ''; html += '
'; $(html).appendTo(appendTo); // Reset item shares @@ -422,6 +425,30 @@ $(document).ready(function() { } }); + $('#expirationCheckbox').live('change', function() { + if (this.checked) { + console.log('checked'); + $('#expirationDate').before('
'); + $('#expirationDate').show(); + $('#expirationDate').datepicker({ + dateFormat : 'dd-mm-yy' + }); + } else { + console.log('unchecled'); + $('#expirationDate').hide(); + } + }); + + $('#expirationDate').live('change', 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) { + if (!result || result.status !== 'success') { + OC.dialogs.alert('Error', 'Error setting expiration date'); + } + }); + }); + $('#emailPrivateLink').live('submit', function() { OC.Share.emailPrivateLink(); }); -- cgit v1.2.3 From 6c17a4cb77f50ce851ce8f3bc9a94f7f40967df0 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sun, 9 Sep 2012 14:44:08 -0400 Subject: Don't display actions for children in shared collections, show the parent collection the child is shared in --- core/js/share.js | 103 ++++++++++++++++++++++++++++++--------------------- lib/public/share.php | 7 +++- 2 files changed, 67 insertions(+), 43 deletions(-) (limited to 'core/js/share.js') diff --git a/core/js/share.js b/core/js/share.js index b5e8b0e6613..535ae6da995 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -71,7 +71,8 @@ OC.Share={ var item = itemSource; } if (typeof OC.Share.statuses[item] === 'undefined') { - checkShares = false; + // NOTE: Check doesn't always work and misses some shares, fix later + checkShares = true; } else { checkShares = true; } @@ -149,7 +150,11 @@ OC.Share={ if (share.share_type == OC.Share.SHARE_TYPE_LINK) { OC.Share.showLink(itemSource, share.share_with); } else { - OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions); + if (share.collection) { + OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions, share.collection); + } else { + OC.Share.addShareWith(share.share_type, share.share_with, share.permissions, possiblePermissions, false); + } } }); } @@ -213,56 +218,70 @@ OC.Share={ } }); }, - addShareWith:function(shareType, shareWith, permissions, possiblePermissions) { + addShareWith:function(shareType, shareWith, permissions, possiblePermissions, collection) { if (!OC.Share.itemShares[shareType]) { OC.Share.itemShares[shareType] = []; } OC.Share.itemShares[shareType].push(shareWith); - var editChecked = createChecked = updateChecked = deleteChecked = shareChecked = ''; - if (permissions & OC.PERMISSION_CREATE) { - createChecked = 'checked="checked"'; - editChecked = 'checked="checked"'; - } - if (permissions & OC.PERMISSION_UPDATE) { - updateChecked = 'checked="checked"'; - editChecked = 'checked="checked"'; - } - if (permissions & OC.PERMISSION_DELETE) { - deleteChecked = 'checked="checked"'; - editChecked = 'checked="checked"'; - } - if (permissions & OC.PERMISSION_SHARE) { - shareChecked = 'checked="checked"'; - } - var html = '
  • '; - html += shareWith; - if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) { - if (editChecked == '') { - html += '
  • Shared in '+item+' with '+shareWith+'
  • '; + $('#shareWithList').prepend(html); } - if (possiblePermissions & OC.PERMISSION_UPDATE) { - html += ''; + } else { + var editChecked = createChecked = updateChecked = deleteChecked = shareChecked = ''; + if (permissions & OC.PERMISSION_CREATE) { + createChecked = 'checked="checked"'; + editChecked = 'checked="checked"'; } - if (possiblePermissions & OC.PERMISSION_DELETE) { - html += ''; + if (permissions & OC.PERMISSION_UPDATE) { + updateChecked = 'checked="checked"'; + editChecked = 'checked="checked"'; } - if (possiblePermissions & OC.PERMISSION_SHARE) { - html += ''; + if (permissions & OC.PERMISSION_DELETE) { + deleteChecked = 'checked="checked"'; + editChecked = 'checked="checked"'; } - html += ''; - html += ''; - $(html).appendTo('#shareWithList'); - + if (permissions & OC.PERMISSION_SHARE) { + shareChecked = 'checked="checked"'; + } + var html = '
  • '; + html += shareWith; + if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) { + if (editChecked == '') { + html += '
  • '; + $(html).appendTo('#shareWithList'); + } }, showLink:function(itemSource, password) { $('#linkCheckbox').attr('checked', true); diff --git a/lib/public/share.php b/lib/public/share.php index 3e42e91d045..6186c2d1c17 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -695,7 +695,12 @@ class Share { if (isset($item) && $row['item_type'] == $itemType && $row[$column] == $item) { $collectionItems[] = $row; } else { - $row['collection'] = array('item_type' => $row['item_type'], $column => $row[$column]); + $collection = array(); + $collection['item_type'] = $row['item_type']; + if ($row['item_type'] == 'file' || $row['item_type'] == 'folder') { + $collection['path'] = basename($row['path']); + } + $row['collection'] = $collection; // Fetch all of the children sources $children = $collectionBackend->getChildren($row[$column]); foreach ($children as $child) { -- cgit v1.2.3 From 8f0354bcddb466006689f86369c9e27170ea691b Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 12 Sep 2012 00:23:45 -0400 Subject: Temporarily disable sharing with contacts and emails, will come in next release --- core/ajax/share.php | 34 +++++++++++++++++----------------- core/js/share.js | 10 +++++----- lib/public/share.php | 40 ++++++++++++++++++++-------------------- 3 files changed, 42 insertions(+), 42 deletions(-) (limited to 'core/js/share.js') diff --git a/core/ajax/share.php b/core/ajax/share.php index 5b6763c08e7..b8e88acec21 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -82,23 +82,23 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo case 'getShareWith': if (isset($_GET['search'])) { $shareWith = array(); - if (OC_App::isEnabled('contacts')) { - // TODO Add function to contacts to only get the 'fullname' column to improve performance - $ids = OC_Contacts_Addressbook::activeIds(); - foreach ($ids as $id) { - $vcards = OC_Contacts_VCard::all($id); - foreach ($vcards as $vcard) { - $contact = $vcard['fullname']; - if (stripos($contact, $_GET['search']) !== false - && (!isset($_GET['itemShares']) - || !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]) - || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]) - || !in_array($contact, $_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]))) { - $shareWith[] = array('label' => $contact, 'value' => array('shareType' => 5, 'shareWith' => $vcard['id'])); - } - } - } - } +// if (OC_App::isEnabled('contacts')) { +// // TODO Add function to contacts to only get the 'fullname' column to improve performance +// $ids = OC_Contacts_Addressbook::activeIds(); +// foreach ($ids as $id) { +// $vcards = OC_Contacts_VCard::all($id); +// foreach ($vcards as $vcard) { +// $contact = $vcard['fullname']; +// if (stripos($contact, $_GET['search']) !== false +// && (!isset($_GET['itemShares']) +// || !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]) +// || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]) +// || !in_array($contact, $_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]))) { +// $shareWith[] = array('label' => $contact, 'value' => array('shareType' => 5, 'shareWith' => $vcard['id'])); +// } +// } +// } +// } $count = 0; $users = array(); $limit = 0; diff --git a/core/js/share.js b/core/js/share.js index 535ae6da995..e85c134f825 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -167,12 +167,12 @@ OC.Share={ response(result.data); } else { // Suggest sharing via email if valid email address - var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i); - if (pattern.test(search.term)) { - response([{label: 'Share via email: '+search.term, value: {shareType: OC.Share.SHARE_TYPE_EMAIL, shareWith: search.term}}]); - } else { +// var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i); +// if (pattern.test(search.term)) { +// response([{label: 'Share via email: '+search.term, value: {shareType: OC.Share.SHARE_TYPE_EMAIL, shareWith: search.term}}]); +// } else { response(['No people found']); - } +// } } }); // } diff --git a/lib/public/share.php b/lib/public/share.php index ccb5a56ac74..9d2c98e4179 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -252,26 +252,26 @@ class Share { \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); return false; - } else if ($shareType === self::SHARE_TYPE_CONTACT) { - if (!\OC_App::isEnabled('contacts')) { - $message = 'Sharing '.$itemSource.' failed, because the contacts app is not enabled'; - \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); - return false; - } - $vcard = \OC_Contacts_App::getContactVCard($shareWith); - if (!isset($vcard)) { - $message = 'Sharing '.$itemSource.' failed, because the contact does not exist'; - \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); - throw new \Exception($message); - } - $details = \OC_Contacts_VCard::structureContact($vcard); - // TODO Add ownCloud user to contacts vcard - if (!isset($details['EMAIL'])) { - $message = 'Sharing '.$itemSource.' failed, because no email address is associated with the contact'; - \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); - throw new \Exception($message); - } - return self::shareItem($itemType, $itemSource, self::SHARE_TYPE_EMAIL, $details['EMAIL'], $permissions); +// } else if ($shareType === self::SHARE_TYPE_CONTACT) { +// if (!\OC_App::isEnabled('contacts')) { +// $message = 'Sharing '.$itemSource.' failed, because the contacts app is not enabled'; +// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); +// return false; +// } +// $vcard = \OC_Contacts_App::getContactVCard($shareWith); +// if (!isset($vcard)) { +// $message = 'Sharing '.$itemSource.' failed, because the contact does not exist'; +// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); +// throw new \Exception($message); +// } +// $details = \OC_Contacts_VCard::structureContact($vcard); +// // TODO Add ownCloud user to contacts vcard +// if (!isset($details['EMAIL'])) { +// $message = 'Sharing '.$itemSource.' failed, because no email address is associated with the contact'; +// \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); +// throw new \Exception($message); +// } +// return self::shareItem($itemType, $itemSource, self::SHARE_TYPE_EMAIL, $details['EMAIL'], $permissions); } else { // Future share types need to include their own conditions $message = 'Share type '.$shareType.' is not valid for '.$itemSource; -- cgit v1.2.3 From 54d4e556fe3302d1e580cb6d4abbfcd5699263a5 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 12 Sep 2012 00:57:01 -0400 Subject: Add lock and clock icon for sharing --- AUTHORS | 3 +++ core/img/actions/clock.png | Bin 0 -> 466 bytes core/img/actions/clock.svg | 20 ++++++++++++++++++++ core/img/actions/lock.png | Bin 0 -> 346 bytes core/img/actions/lock.svg | 8 ++++++++ core/js/share.js | 3 +-- 6 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 core/img/actions/clock.png create mode 100755 core/img/actions/clock.svg create mode 100644 core/img/actions/lock.png create mode 100755 core/img/actions/lock.svg (limited to 'core/js/share.js') diff --git a/AUTHORS b/AUTHORS index f618df9311d..f79733c2502 100644 --- a/AUTHORS +++ b/AUTHORS @@ -19,3 +19,6 @@ With help from many libraries and frameworks including: SabreDAV jQuery … + +"Lock” symbol from thenounproject.com collection +"Clock” symbol by Brandon Hopkins, from thenounproject.com collection \ No newline at end of file diff --git a/core/img/actions/clock.png b/core/img/actions/clock.png new file mode 100644 index 00000000000..671b3f4f0c1 Binary files /dev/null and b/core/img/actions/clock.png differ diff --git a/core/img/actions/clock.svg b/core/img/actions/clock.svg new file mode 100755 index 00000000000..1821f474df5 --- /dev/null +++ b/core/img/actions/clock.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/img/actions/lock.png b/core/img/actions/lock.png new file mode 100644 index 00000000000..511bfa615bb Binary files /dev/null and b/core/img/actions/lock.png differ diff --git a/core/img/actions/lock.svg b/core/img/actions/lock.svg new file mode 100755 index 00000000000..8fb039b9e3b --- /dev/null +++ b/core/img/actions/lock.svg @@ -0,0 +1,8 @@ + + + + + + diff --git a/core/js/share.js b/core/js/share.js index e85c134f825..3fe1f259617 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -132,8 +132,7 @@ OC.Share={ if (link) { html += '