last permission setting woes resolved
parent
ec95de9d2c
commit
286a5cb263
|
@ -618,8 +618,9 @@ Calendar={
|
||||||
var shareWith = selected.item.value.shareWith;
|
var shareWith = selected.item.value.shareWith;
|
||||||
$(this).val(shareWith);
|
$(this).val(shareWith);
|
||||||
var shareWithInput = $(this)
|
var shareWithInput = $(this)
|
||||||
// Default permissions are Read and Share
|
// getting the default permissions from data-permissions
|
||||||
var permissions = OC.PERMISSION_READ | OC.PERMISSION_SHARE;
|
// shouldn't it be OC.PERMISSION_READ | OC.PERMISSION_SHARE instead, as a sensible default?
|
||||||
|
var permissions = $(this).data('permissions')
|
||||||
OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, function(data) {
|
OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, function(data) {
|
||||||
console.log('PERMISSIONS: ' + permissions)
|
console.log('PERMISSIONS: ' + permissions)
|
||||||
// we need to "fix" the share-can-edit-ITEMPTYPE-ITEMSOURCE-0 checkbox and label
|
// we need to "fix" the share-can-edit-ITEMPTYPE-ITEMSOURCE-0 checkbox and label
|
||||||
|
@ -654,6 +655,9 @@ Calendar={
|
||||||
.find('.share-options input[name="share"]')
|
.find('.share-options input[name="share"]')
|
||||||
.prop('checked', permissions & OC.PERMISSION_SHARE)
|
.prop('checked', permissions & OC.PERMISSION_SHARE)
|
||||||
.end()
|
.end()
|
||||||
|
.find('.share-options input[name="edit"]')
|
||||||
|
.prop('checked', permissions & ( OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE | OC.PERMISSION_DELETE ) )
|
||||||
|
.end()
|
||||||
// handle the share-can-edit-ITEMPTYPE-ITEMSOURCE-0 checkbox and label
|
// handle the share-can-edit-ITEMPTYPE-ITEMSOURCE-0 checkbox and label
|
||||||
.find('#' + editCheckboxIdStub + '0')
|
.find('#' + editCheckboxIdStub + '0')
|
||||||
.prop('id', editCheckboxIdStub + curEditCheckboxId)
|
.prop('id', editCheckboxIdStub + curEditCheckboxId)
|
||||||
|
@ -680,32 +684,28 @@ Calendar={
|
||||||
$(document)
|
$(document)
|
||||||
.off('change', '.shared-with-entry-container input:checkbox[data-permissions]')
|
.off('change', '.shared-with-entry-container input:checkbox[data-permissions]')
|
||||||
.on('change', '.shared-with-entry-container input:checkbox[data-permissions]', function(){
|
.on('change', '.shared-with-entry-container input:checkbox[data-permissions]', function(){
|
||||||
|
|
||||||
console.log('PERMISSIONS!')
|
// get the data
|
||||||
var container = $(this).parents('li').first();
|
var container = $(this).parents('li').first();
|
||||||
var permissions = parseInt(container.data('permissions'));
|
var permissions = parseInt(container.attr('data-permissions'));
|
||||||
var itemType = container.data('item-type');
|
var itemType = container.data('item-type');
|
||||||
var shareType = container.data('share-type');
|
var shareType = container.data('share-type');
|
||||||
var itemSource = container.data('item');
|
var itemSource = container.data('item');
|
||||||
var shareWith = container.data('share-with');
|
var shareWith = container.data('share-with');
|
||||||
var permission = null;
|
var permission = $(this).data('permissions');
|
||||||
if($(this).hasClass('update')) {
|
|
||||||
permission = OC.PERMISSION_UPDATE;
|
// find the required perms
|
||||||
permission = OC.PERMISSION_DELETE;
|
|
||||||
} else if($(this).hasClass('share')) {
|
|
||||||
permission = OC.PERMISSION_SHARE;
|
|
||||||
}
|
|
||||||
// This is probably not the right way, but it works :-P
|
|
||||||
if($(this).is(':checked')) {
|
if($(this).is(':checked')) {
|
||||||
permissions += permission;
|
permissions |= permission;
|
||||||
} else {
|
} else {
|
||||||
permissions -= permission;
|
permissions &= ~permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
container.data('permissions',permissions);
|
// save current permissions on the container
|
||||||
console.log('setting permissions to: ' + permissions)
|
container.attr('data-permissions', permissions);
|
||||||
|
|
||||||
//OC.Share.setPermissions(itemType, itemSource, shareType, shareWith, permissions);
|
// run the request
|
||||||
|
OC.Share.setPermissions(itemType, itemSource, shareType, shareWith, permissions);
|
||||||
});
|
});
|
||||||
|
|
||||||
// using .off() to make sure the event is only attached once
|
// using .off() to make sure the event is only attached once
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
data-item-source="<?php p($_['item_id']); ?>"
|
data-item-source="<?php p($_['item_id']); ?>"
|
||||||
data-item-type="<?php p($_['item_type']); ?>"
|
data-item-type="<?php p($_['item_type']); ?>"
|
||||||
data-link="true"
|
data-link="true"
|
||||||
data-permissions="<?php p($_['permissions']) ?>"
|
data-permissions="<?php p($sharee['permissions']); ?>"
|
||||||
title="<?php p($sharee['share_with']); ?>"
|
title="<?php p($sharee['share_with']); ?>"
|
||||||
class="shared-with-entry-container <?php if($i === 0): ?>stub<?php endif; ?>">
|
class="shared-with-entry-container <?php if($i === 0): ?>stub<?php endif; ?>">
|
||||||
<!-- the username -->
|
<!-- the username -->
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
-->
|
-->
|
||||||
<input type="checkbox" class="permissions"
|
<input type="checkbox" class="permissions"
|
||||||
<?php if(empty($_['basic_edit_options'])): ?>
|
<?php if(empty($_['basic_edit_options'])): ?>
|
||||||
name="edit" checked="checked" disabled="disabled"
|
name="edit" <?php if ($sharee['permissions'] & (OCP\PERMISSION_UPDATE | OCP\PERMISSION_CREATE | OCP\PERMISSION_DELETE ) ): ?> checked="checked"<?php endif; ?> disabled="disabled"
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
name="update" data-permissions="2" <?php p(($sharee['permissions'] & OCP\PERMISSION_UPDATE?'checked="checked"':''))?> id="share-can-edit-<?php p($_['item_type']); ?>-<?php p($_['item_id']); ?>-<?php p($i); ?>"
|
name="update" data-permissions="2" <?php p(($sharee['permissions'] & OCP\PERMISSION_UPDATE?'checked="checked"':''))?> id="share-can-edit-<?php p($_['item_type']); ?>-<?php p($_['item_id']); ?>-<?php p($i); ?>"
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
Loading…
Reference in New Issue