[Rt-commit] rt branch 5.0/fix-selfservice-helpers-autocomplete-principals created. rt-5.0.3-247-ge614796e51

BPS Git Server git at git.bestpractical.com
Wed Jun 21 18:58:16 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/fix-selfservice-helpers-autocomplete-principals has been created
        at  e614796e51ab66a73de3a91367b12d33f272995b (commit)

- Log -----------------------------------------------------------------
commit e614796e51ab66a73de3a91367b12d33f272995b
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Wed Jun 21 15:53:05 2023 -0300

    Fix autocomplete for Principals in SelfService
    
    Autocomplete in SelfService Create.html was broken because of the missing
    Principals helper.
    
    Also added the AllowGroupAutocompleteForUnprivileged config option that
    was described in RT documentation but was not implemented.

diff --git a/share/html/Helpers/Autocomplete/Principals b/share/html/Helpers/Autocomplete/Principals
index 435f268bd6..c1f0f2bd32 100644
--- a/share/html/Helpers/Autocomplete/Principals
+++ b/share/html/Helpers/Autocomplete/Principals
@@ -104,24 +104,6 @@ $users->SimpleSearch( Privileged => $privileged,
 $m->callback( CallbackName => "ModifyUsersLimit", Users => $users, Term => $term, ARGSRef => \%ARGS, CallbackPage => '/Helpers/Autocomplete/Users' );
 $m->callback( CallbackName => "ModifyUsersLimit", Users => $users, Term => $term, ARGSRef => \%ARGS );
 
-(my $group_term = $term) =~ s/^\s*group\s*:\s*//i;
-my $groups = RT::Groups->new( $CurrentUser );
-$groups->RowsPerPage( $max );
-$groups->LimitToUserDefinedGroups();
-$groups->Limit(
-    FIELD           => 'Name',
-    OPERATOR        => 'STARTSWITH',
-    VALUE           => $group_term,
-    CASESENSITIVE   => 0,
-);
-
-# Exclude groups we don't want
-foreach (@exclude) {
-    $groups->Limit(FIELD => 'id', VALUE => $_, OPERATOR => '!=', ENTRYAGGREGATOR => 'AND');
-}
-$m->callback( CallbackName => "ModifyGroupsLimit", Groups => $groups, Term => $term, ARGSRef => \%ARGS, CallbackPage => '/Helpers/Autocomplete/Groups' );
-$m->callback( CallbackName => "ModifyGroupsLimit", Groups => $groups, Term => $term, ARGSRef => \%ARGS );
-
 my @suggestions;
 
 while ( my $user = $users->Next ) {
@@ -135,24 +117,43 @@ while ( my $user = $users->Next ) {
     $m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, user => $user );
     push @suggestions, $suggestion;
 }
-
-while ( my $group = $groups->Next ) {
-    my $label = 'group:' . $group->Name;
-
-    # if group name contains, say, a comma, then use its id instead to avoid
-    # parsing problems
-    my $value = $delim && $label =~ $delim ? 'group:' . $group->id : $label;
-
-    my $suggestion = { id => $group->id, label => $label, value => $value, text => $term };
-    $m->callback(
-        CallbackName => "ModifySuggestion",
-        suggestion   => $suggestion,
-        group        => $group,
-        CallbackPage => '/Helpers/Autocomplete/Groups',
+if ( $CurrentUser->Privileged || RT->Config->Get('AllowGroupAutocompleteForUnprivileged')  ) {
+    (my $group_term = $term) =~ s/^\s*group\s*:\s*//i;
+    my $groups = RT::Groups->new( $CurrentUser );
+    $groups->RowsPerPage( $max );
+    $groups->LimitToUserDefinedGroups();
+    $groups->Limit(
+        FIELD           => 'Name',
+        OPERATOR        => 'STARTSWITH',
+        VALUE           => $group_term,
+        CASESENSITIVE   => 0,
     );
-    $m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, group => $group );
-    push @suggestions, $suggestion;
 
-    last if @suggestions >= $max;
+    # Exclude groups we don't want
+    foreach (@exclude) {
+        $groups->Limit(FIELD => 'id', VALUE => $_, OPERATOR => '!=', ENTRYAGGREGATOR => 'AND');
+    }
+    $m->callback( CallbackName => "ModifyGroupsLimit", Groups => $groups, Term => $term, ARGSRef => \%ARGS, CallbackPage => '/Helpers/Autocomplete/Groups' );
+    $m->callback( CallbackName => "ModifyGroupsLimit", Groups => $groups, Term => $term, ARGSRef => \%ARGS );
+
+    while ( my $group = $groups->Next ) {
+        my $label = 'group:' . $group->Name;
+
+        # if group name contains, say, a comma, then use its id instead to avoid
+        # parsing problems
+        my $value = $delim && $label =~ $delim ? 'group:' . $group->id : $label;
+
+        my $suggestion = { id => $group->id, label => $label, value => $value, text => $term };
+        $m->callback(
+            CallbackName => "ModifySuggestion",
+            suggestion   => $suggestion,
+            group        => $group,
+            CallbackPage => '/Helpers/Autocomplete/Groups',
+        );
+        $m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, group => $group );
+        push @suggestions, $suggestion;
+
+        last if @suggestions >= $max;
+    }
 }
 </%INIT>
diff --git a/share/html/SelfService/Helpers/Autocomplete/Principals b/share/html/SelfService/Helpers/Autocomplete/Principals
new file mode 100644
index 0000000000..d794f24208
--- /dev/null
+++ b/share/html/SelfService/Helpers/Autocomplete/Principals
@@ -0,0 +1,48 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2022 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+% $m->comp('/Helpers/Autocomplete/Principals', %ARGS);

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list