From decc85c7b2d45cf237513a09cc57007c8726dcf0 Mon Sep 17 00:00:00 2001 From: discoverygnoye Date: Tue, 15 Nov 2011 14:41:51 -0400 Subject: [PATCH] COLORADO-1203 Added in permission settings for adding streams to an object The "Add" button functionality is not availble to users that have 'add fedora datastreams' permissions set on their Drupal accounts. The changes made disable the "Add" button and do not install a click handler unless this permission is set for the user. --- ADRCollection.inc | 2 ++ js/Manage.js | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ADRCollection.inc b/ADRCollection.inc index 8efdc59..9c7d68e 100644 --- a/ADRCollection.inc +++ b/ADRCollection.inc @@ -98,6 +98,7 @@ class ADRCollection { $canEditObjects = user_access("edit fedora meta data"); $canEditPermissions = user_access("Edit XACML Policies"); $canEditChildPermissions = user_access("Edit XACML Policies"); + $canAddStream = user_access("add fedora datastreams"); $canDeleteObject = user_access("purge objects and datastreams"); $canDeleteStream = user_access("purge objects and datastreams"); $canEditStream = user_access("edit fedora meta data"); @@ -109,6 +110,7 @@ class ADRCollection { "UserCollectionPermissions.manage_canEditPermissions=" . ($canEditPermissions ? "true" : "false") . ";" . "UserCollectionPermissions.manage_canEditChildPermissions=" . ($canEditChildPermissions ? "true" : "false") . ";" . "UserCollectionPermissions.manage_canDeleteObject=" . ($canDeleteObject ? "true" : "false") . ";" . + "UserCollectionPermissions.datastream_canAddStream=" . ($canAddStream ? "true" : "false") . ";" . "UserCollectionPermissions.datastream_canEditStream=" . ($canEditStream ? "true" : "false") . ";" . "UserCollectionPermissions.datastream_canDeleteStream=" . ($canDeleteStream ? "true" : "false") . ";"; drupal_add_js($permissions_block, 'inline'); diff --git a/js/Manage.js b/js/Manage.js index 1eb8cc4..67067f0 100644 --- a/js/Manage.js +++ b/js/Manage.js @@ -73,6 +73,7 @@ Manage = Ext.extend(ManageUi, { }] }); + add.disable(); edit.disable(); remove.disable(); @@ -80,9 +81,12 @@ Manage = Ext.extend(ManageUi, { this.tpl.overwrite(this.body, record.data); } - add.addListener('click', function(button, event) { - gotoFilesIngestPage(ADRCollection.pid); - }); + if (UserCollectionPermissions.datastream_canAddStream) { + add.enable(); + add.addListener('click', function(button, event) { + gotoFilesIngestPage(ADRCollection.pid); + }); + } download.addListener('click', function(button, event) { var records = viewer.getSelectedRecords();