From 9a785ed91c057a766f4dba71318130c6cdf11816 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Fri, 5 Nov 2010 13:11:56 -0400 Subject: rights check if the field does not have a 'w' for writable in its rights, disable it. Merged with the HBAC/Widget changes add and remove links are managed via permissions now --- install/static/details.js | 62 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 20 deletions(-) (limited to 'install/static/details.js') diff --git a/install/static/details.js b/install/static/details.js index e69a5dac..9301f310 100644 --- a/install/static/details.js +++ b/install/static/details.js @@ -26,6 +26,13 @@ var ipa_details_cache = {}; +IPA.is_field_writable = function(rights){ + if (!rights){ + alert('no right'); + } + return rights.indexOf('w') > -1; +} + function ipa_details_field(spec) { spec = spec || {}; @@ -80,34 +87,41 @@ function ipa_details_field(spec) { } var value = result[that.name]; + var rights = 'rsc'; + if (result.attributelevelrights){ + rights = result.attributelevelrights[this.name] || rights ; + } if (value) { dd = ipa_create_first_dd( - that.name, ipa_create_input(that.entity_name, that.name, value[0],hint_span) + that.name,ipa_create_input( + that.entity_name, that.name, value[0],hint_span,rights) ); dt.after(dd); var last_dd = dd; for (var i = 1; i < value.length; ++i) { dd = ipa_create_other_dd( - that.name, ipa_create_input(that.entity_name, that.name, value[i],hint_span) + that.name, ipa_create_input(that.entity_name, that.name, + value[i],hint_span,rights) ); last_dd.after(dd); last_dd = dd; } - if (multivalue) { + if (multivalue && IPA.is_field_writable(rights) ) { dd = ipa_create_other_dd( that.name, _ipa_a_add_template.replace('A', that.name) ); last_dd.after(dd); } } else { - if (multivalue) { + if (multivalue && IPA.is_field_writable(rights)) { dd = ipa_create_first_dd( - that.name, _ipa_a_add_template.replace('A', that.name) /*.append(hint_span)*/ + that.name, _ipa_a_add_template.replace('A', that.name) ); dt.after(dd); } else { dd = ipa_create_first_dd( - that.name, ipa_create_input(that.entity_name, that.name, '') /*.append(hint_span)*/ + that.name, ipa_create_input( + that.entity_name, that.name,'',hint_span,rights) ); dt.after(dd); } @@ -334,7 +348,7 @@ function ipa_details_setup(container, unspecified) { if (facet.pkey) params.push(facet.pkey); ipa_cmd( - 'show', params, {all: true}, on_success, on_failure, facet.entity_name + 'show', params, {all: true, rights: true}, on_success, on_failure, facet.entity_name ); } @@ -473,7 +487,7 @@ function ipa_details_update(container, pkey, on_win, on_fail) return; var values; - var modlist = {'all': true, 'setattr': [], 'addattr': []}; + var modlist = {'all': true, 'setattr': [], 'addattr': [], 'rights': true}; var attrs_wo_option = {}; var facet = ipa_entity_get_details_facet(obj_name); @@ -599,13 +613,13 @@ var _ipa_param_type_2_handler_map = { * arguments: * attr - LDAP attribute name * value - the attributes value */ -function ipa_create_input(entity_name, attr, value,hint) +function ipa_create_input(entity_name, attr, value,hint,rights) { var input = $("