Open Bug 628335 Opened 15 years ago Updated 2 years ago

userAutocomplete should highlight suggested users which do not have Group Privileges to access the Bug in question.

Categories

(Bugzilla :: Creating/Changing Bugs, enhancement, P4)

x86_64
Linux
enhancement

Tracking

()

People

(Reporter: shadarap, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 Build Identifier: 4.0rc1 Release When editing the "Assigned To", "QA Contact" or CC lists, the userAutocomplete javascript/JSON fetches a list of users which match the inputted text. The problem is that some of the users listed might not have Group Privileges to access the Bug in question, and accidentally adding one of these users to the "Assigned To", CC, or "QA Contact" fields will then grant them access to the Bug. These mixup's can easily happen especially in work places where usernames are <lastname><first-initial>@domain.com and the workplace has several people with the same lastname. In my particular environment, some of our Bugs belong to products which are "Controlled Goods", meaning that it is the law that only authorized users can see certain chunks of information. I have implemented a solution where all users in the user list generated by the JSON call appear in a Red font if they do not have Group Privileges to the Bug/Product. The following indicate the changes made to make this work (Note: I used my own local repository): Index: template/en/default/global/userselect.html.tmpl =================================================================== --- template/en/default/global/userselect.html.tmpl (revision 239) +++ template/en/default/global/userselect.html.tmpl (working copy) @@ -30,6 +30,7 @@ # multiple: optional, do multiselect box, value is size (height) of box # custom_userlist: optional, specify a limited list of users to use # title: optional, extra information to display as a tooltip + # product_name: optional, name of product this field is being utilized in #%] [% IF Param("usemenuforusers") %] @@ -86,6 +87,7 @@ <input name="[% name FILTER html %]" value="[% value FILTER html %]" + onFocus="[% id FILTER js %]_autocomplete_set();" [% IF classes %] class="[% classes.join(' ') FILTER html %]" [% END %] [% IF onchange %] onchange="[% onchange FILTER html %]" [% END %] [% IF disabled %] disabled="[% disabled FILTER html %]" [% END %] @@ -98,12 +100,16 @@ <div id="[% id FILTER html %]_autocomplete_container"></div> </div> <script type="text/javascript"> + function [% id FILTER html %]_autocomplete_set(){ + YAHOO.bugzilla.userAutocomplete.set_dynamic("[% product_name %]"); + } if( typeof(YAHOO.bugzilla.userAutocomplete) !== 'undefined' && YAHOO.bugzilla.userAutocomplete != null){ YAHOO.bugzilla.userAutocomplete.init( "[% id FILTER js %]", "[% id FILTER js %]_autocomplete_container" - [% IF multiple %], true[% END%]); + [% IF multiple %], true[% END %]); } + </script> [% END %] [% END %] Index: Bugzilla/WebService/User.pm =================================================================== --- Bugzilla/WebService/User.pm (revision 239) +++ Bugzilla/WebService/User.pm (working copy) @@ -202,7 +202,7 @@ } } } - + my $product_name = $params->{'product_name'}; my $in_group = $self->_filter_users_by_group( \@user_objects, $params); if (Bugzilla->user->in_group('editusers')) { @@ -213,6 +213,7 @@ name => $self->type('string', $_->login), email => $self->type('string', $_->email), can_login => $self->type('boolean', $_->is_disabled ? 0 : 1), + can_access_product => $self->type('boolean', $_->can_access_product($product_name)), email_enabled => $self->type('boolean', $_->email_enabled), login_denied_text => $self->type('string', $_->disabledtext), }} @$in_group; @@ -226,6 +227,7 @@ name => $self->type('string', $_->login), email => $self->type('string', $_->email), can_login => $self->type('boolean', $_->is_disabled ? 0 : 1), + can_access_product => $self->type('boolean', $_->can_access_product($product_name)), }} @$in_group; } Index: skins/standard/global.css =================================================================== --- skins/standard/global.css (revision 239) +++ skins/standard/global.css (working copy) @@ -522,6 +522,9 @@ overflow: auto; overflow-x: hidden; } +.yui-ac-content-text-warn { + color: red +} #keyword_container { padding-top: .2em; Index: js/field.js =================================================================== --- js/field.js (revision 239) +++ js/field.js (working copy) @@ -648,6 +648,7 @@ YAHOO.bugzilla.userAutocomplete = { counter : 0, dataSource : null, + product_name : null, generateRequest : function ( enteredText ){ YAHOO.bugzilla.userAutocomplete.counter = YAHOO.bugzilla.userAutocomplete.counter + 1; @@ -657,7 +658,8 @@ id : YAHOO.bugzilla.userAutocomplete.counter, params : [ { match : [ decodeURIComponent(enteredText) ], - include_fields : [ "email", "real_name" ] + include_fields : [ "email", "real_name", "can_access_product" ], + product_name : YAHOO.bugzilla.userAutocomplete.product_name } ] }; var stringified = YAHOO.lang.JSON.stringify(json_object); @@ -667,7 +669,12 @@ return stringified; }, resultListFormat : function(oResultData, enteredText, sResultMatch) { - return ( oResultData.real_name + " (" + oResultData.email + ")"); + if ( oResultData.can_access_product) { + return ( oResultData.real_name + " (" + oResultData.email + ")"); + } + else { + return ("<div class='yui-ac-content-text-warn'>" + oResultData.real_name + " (" + oResultData.email + ")</div>"); + } }, debug_helper : function ( ){ /* used to help debug any errors that might happen */ @@ -687,10 +694,14 @@ metaFields : { error: "error", jsonRpcId: "id"}, fields : [ { key : "email" }, - { key : "real_name"} + { key : "real_name" }, + { key : "can_access_product" } ] }; }, + set_dynamic : function( product ) { + YAHOO.bugzilla.userAutocomplete.product_name = product; + }, init : function( field, container, multiple ) { if( this.dataSource == null ){ this.init_ds(); Index: template/en/default/bug/edit.html.tmpl =================================================================== --- template/en/default/bug/edit.html.tmpl (revision 239) +++ template/en/default/bug/edit.html.tmpl (working copy) @@ -482,6 +482,7 @@ id => "assigned_to" name => "assigned_to" value => bug.assigned_to.login + product_name => bug.product classes => ["bz_userfield"] size => 30 %] @@ -524,6 +525,7 @@ id => "qa_contact" name => "qa_contact" value => bug.qa_contact.login + product_name => bug.product size => 30 classes => ["bz_userfield"] emptyok => 1 @@ -824,6 +826,7 @@ id => "newcc" name => "newcc" value => "" + product_name => bug.product size => 30 classes => ["bz_userfield"] multiple => 5 Explanations: js/field.js YAHOO.bugzilla.userAutocomplete: - In here I created a function called set_dynamic, which for now only takes the variable 'product'. This was created in order to work around some limitations. I thought about setting it in the init() function, but this value would then continually get over written by proceeding calls to the init() function. IE: When I would call init from userselect.html.tmpl like so: YAHOO.bugzilla.userAutocomplete.init( "[% id FILTER js %]", "[% id FILTER js %]_autocomplete_container", "[% product_name FILTER js %]", [% IF multiple %], true[% END%]); then the last INCLUDE of userselect.html.tmpl had its 'product_name' for all of the previous INCLUDE's. This is problematic as you may only want this new "feature" on some fields but not on others. By not setting this variable the feature would not be utilized, but using this method, not setting the variable on the last call to [% INCLUDE global/userselect.html.tmpl %] would make it so it was not set on all other previous INCLUDE's. I will attach a screen shot of the changed appearance. Cheers, Randy Reproducible: Always Actual Results: Users who do not have Group Privileges to the Product are highlighted in Red
Here is a snapshot of the change in action. I have blurred out some information using blue marks.
Hey Randy! Thanks for the patch. If you would like us to review it, you will want to attach it as an attachment and request review. For more details, see our development process here: http://wiki.mozilla.org/Bugzilla:Developers I'm not completely sure that we want this--I'd like to see more users say that this is important to them and that they would clearly understand the highlighting, before we would do this.
Priority: -- → P4
I could see this being very useful for BMO.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attachment #9385509 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: