summaryrefslogtreecommitdiffstats
path: root/core/js/shareitemmodel.js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-09-12 17:02:03 +0200
committerVincent Petry <pvince81@owncloud.com>2015-09-16 07:23:28 +0200
commit9fe6d7c568221a77686de80634870e4a40e6ac29 (patch)
treec20cb643ed3b4c8ad3816d5826b296d68f414e48 /core/js/shareitemmodel.js
parent5dfaa0c82d93a075d063cc24ea4345a5943b0b1f (diff)
downloadnextcloud-server-9fe6d7c568221a77686de80634870e4a40e6ac29.tar.gz
nextcloud-server-9fe6d7c568221a77686de80634870e4a40e6ac29.zip
implements setting and removing password for link shares, including forced ones
Diffstat (limited to 'core/js/shareitemmodel.js')
-rw-r--r--core/js/shareitemmodel.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index 9e153dcb3e5..9e3f829e457 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -20,6 +20,7 @@
* @property {string} token
* @property {string|null} password
* @property {string} link
+ * @property {number} permissions
* @property {Date} expiration
* @property {number} stime share time
*/
@@ -89,12 +90,30 @@
linkShare: {}
},
- addLinkShare: function() {
+ addLinkShare: function(options) {
var model = this;
var expiration = this.configModel.getDefaultExpirationDateString();
var itemType = this.get('itemType');
var itemSource = this.get('itemSource');
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, this.fileInfoModel.get('name'), expiration, function(data) {
+
+ var options = options || {};
+ var requiredOptions = [
+ { name: 'password', defaultValue: '' },
+ { name: 'permissions', defaultValue: OC.PERMISSION_READ }
+ ];
+ _.each(requiredOptions, function(option) {
+ // a provided options overrides a present value of the link
+ // share. If neither is given, the default value is used.
+ if(_.isUndefined(options[option.name])) {
+ options[option.name] = option.defaultValue;
+ var currentValue = model.get('linkShare')[option.name];
+ if(!_.isUndefined(currentValue)) {
+ options[option.name] = currentValue;
+ }
+ }
+ });
+
+ OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, options.password, options.permissions, this.fileInfoModel.get('name'), expiration, function(data) {
model.fetch();
//FIXME: updateIcon belongs to view
OC.Share.updateIcon(itemType, itemSource);
@@ -512,6 +531,7 @@
token: share.token,
password: share.share_with,
link: link,
+ permissions: share.permissions,
// currently expiration is only effective for link shares.
expiration: share.expiration,
stime: share.stime