[Rt-commit] rt branch, rightsmatrix, updated. rt-3.8.8-612-g23162aa

Thomas Sibley trs at bestpractical.com
Thu Sep 2 13:47:59 EDT 2010


The branch, rightsmatrix has been updated
       via  23162aa0f996c7d763a5e051f3c1e9c3c9796781 (commit)
      from  c688bf7e5765a7f3f7364b0e5f3daca80a271abf (commit)

Summary of changes:
 share/html/Admin/Elements/EditRights               |    8 ++++
 .../Helpers/{TicketHistory => Autocomplete/Groups} |   37 +++++++++++++------
 2 files changed, 33 insertions(+), 12 deletions(-)
 copy share/html/Helpers/{TicketHistory => Autocomplete/Groups} (78%)

- Log -----------------------------------------------------------------
commit 23162aa0f996c7d763a5e051f3c1e9c3c9796781
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Sep 2 13:50:20 2010 -0400

    Add group autocomplete for the new rights editor

diff --git a/share/html/Admin/Elements/EditRights b/share/html/Admin/Elements/EditRights
index 8fb5bf0..0878f3b 100644
--- a/share/html/Admin/Elements/EditRights
+++ b/share/html/Admin/Elements/EditRights
@@ -6,6 +6,7 @@ $AddPrincipal => undef
 <%init>
 use Scalar::Util qw(blessed);
 
+# Try to detect if we want to include an add user/group box
 unless ( $AddPrincipal ) {
     my $last = $Principals->[-1];
     if ( $last->[0] =~ /Groups/i ) {
@@ -52,6 +53,13 @@ for my $category (@$Principals) {
         <input type="text" value=""
                name="AddPrincipalForRights-<% lc $AddPrincipal %>"
                id="AddPrincipalForRights-<% lc $AddPrincipal %>" />
+% if (lc $AddPrincipal eq 'group') {
+        <script type="text/javascript">
+            jQuery("#AddPrincipalForRights-<% lc $AddPrincipal %>").autocomplete({
+                source: "<% RT->Config->Get('WebPath')%>/Helpers/Autocomplete/Groups",
+            });
+        </script>
+% }
       </a>
     </li>
 % }
diff --git a/share/html/Helpers/Autocomplete/Groups b/share/html/Helpers/Autocomplete/Groups
new file mode 100644
index 0000000..0c932a7
--- /dev/null
+++ b/share/html/Helpers/Autocomplete/Groups
@@ -0,0 +1,80 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%# 
+%# COPYRIGHT:
+%# 
+%# This software is Copyright (c) 1996-2010 Best Practical Solutions, LLC
+%#                                          <jesse 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 }}}
+
+<% JSON::to_json( \@suggestions ) |n %>
+% $m->abort;
+<%ARGS>
+$term => undef
+$max => 10
+</%ARGS>
+<%INIT>
+require JSON;
+
+$m->abort unless defined $term
+             and length $term;
+
+my $CurrentUser = $session{'CurrentUser'};
+
+# Require privileged users
+$m->abort unless $CurrentUser->Privileged;
+
+my $groups = RT::Groups->new( $CurrentUser );
+$groups->RowsPerPage( $max );
+$groups->LimitToUserDefinedGroups();
+$groups->Limit(
+    FIELD           => 'Name',
+    OPERATOR        => 'LIKE',
+    VALUE           => $term,
+);
+
+my @suggestions;
+
+while ( my $group = $groups->Next ) {
+    push @suggestions, $group->Name;
+}
+</%INIT>

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


More information about the Rt-commit mailing list