[Rt-commit] rt branch 4.4/fix-missing-principals-autocomplete-on-selfservice created. rt-4.4.6-68-g7b46819155

BPS Git Server git at git.bestpractical.com
Thu Jun 22 09:33:30 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, 4.4/fix-missing-principals-autocomplete-on-selfservice has been created
        at  7b4681915549abf0c671da8f4640a90eb707a57d (commit)

- Log -----------------------------------------------------------------
commit 7b4681915549abf0c671da8f4640a90eb707a57d
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Jun 22 06:31:01 2023 -0300

    Implement AllowGroupAutocompleteForUnprivileged
    
    AllowGroupAutocompleteForUnprivileged config option was described in
    RT documentation but was not implemented so we added it to the
    Principals autocomplete helper.

diff --git a/share/html/Helpers/Autocomplete/Principals b/share/html/Helpers/Autocomplete/Principals
index b8096268f8..0c00885a92 100644
--- a/share/html/Helpers/Autocomplete/Principals
+++ b/share/html/Helpers/Autocomplete/Principals
@@ -118,41 +118,43 @@ while ( my $user = $users->Next ) {
     push @suggestions, $suggestion;
 }
 
-(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 );
-
-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 };
-    $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 };
+        $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>

commit e9392c18ba60d8fb7504b7c89aa467e280b006b3
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Jun 22 06:27:21 2023 -0300

    Move users loop to the top on Principals autocomplete helper
    
    This will make easier to add more types of principals in the future and
    control the access privileges for each type (users and groups).

diff --git a/share/html/Helpers/Autocomplete/Principals b/share/html/Helpers/Autocomplete/Principals
index c403b39a1f..b8096268f8 100644
--- a/share/html/Helpers/Autocomplete/Principals
+++ b/share/html/Helpers/Autocomplete/Principals
@@ -104,6 +104,20 @@ $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 @suggestions;
+
+while ( my $user = $users->Next ) {
+    my $suggestion = { id => $user->id, label => $user->Format, value => $user->EmailAddress || $user->Name };
+    $m->callback(
+        CallbackName => "ModifySuggestion",
+        suggestion   => $suggestion,
+        user         => $user,
+        CallbackPage => '/Helpers/Autocomplete/Users',
+    );
+    $m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, user => $user );
+    push @suggestions, $suggestion;
+}
+
 (my $group_term = $term) =~ s/^\s*group\s*:\s*//i;
 my $groups = RT::Groups->new( $CurrentUser );
 $groups->RowsPerPage( $max );
@@ -122,20 +136,6 @@ foreach (@exclude) {
 $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 ) {
-    my $suggestion = { id => $user->id, label => $user->Format, value => $user->EmailAddress || $user->Name };
-    $m->callback(
-        CallbackName => "ModifySuggestion",
-        suggestion   => $suggestion,
-        user         => $user,
-        CallbackPage => '/Helpers/Autocomplete/Users',
-    );
-    $m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, user => $user );
-    push @suggestions, $suggestion;
-}
-
 while ( my $group = $groups->Next ) {
     my $label = 'group:' . $group->Name;
 

commit 56c3075bbaa7c791208a6832c93c69ca21638947
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Jun 22 06:26:10 2023 -0300

    Fix autocomplete for Principals in SelfService
    
    Autocomplete in SelfService Create.html was broken because of the missing
    Principals helper.

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