[Rt-commit] rt branch, rightsmatrix, updated. rt-3.8.8-602-gc25dd8c

Thomas Sibley trs at bestpractical.com
Fri Aug 27 17:23:12 EDT 2010


The branch, rightsmatrix has been updated
       via  c25dd8c7ee5b5c142c16998b3c535ce0aac4dada (commit)
       via  91e7c76901e3eec304735ad8aee250b3d47e97e2 (commit)
       via  8433bae2b74f79f11714476d73dc23d48f6ef7f8 (commit)
      from  ec754151ebd8db5862d35062b1a4d27e47cdb326 (commit)

Summary of changes:
 lib/RT/GroupMember_Overlay.pm                      |    2 +-
 share/html/Admin/Elements/EditRights               |   95 +++++++++++++++++++
 share/html/Admin/Queues/GroupRights.html           |   99 +++++++-------------
 share/html/Admin/Queues/UserRights.html            |   56 ++++-------
 .../css/base/jquery-ui-1.8.4.custom.modified.css   |   18 ++++
 share/html/NoAuth/css/base/jquery-ui.css           |    2 +
 share/html/NoAuth/css/base/main.css                |    2 +
 share/html/NoAuth/css/base/misc.css                |    3 -
 share/html/NoAuth/css/base/rights-editor.css       |   59 ++++++++++++
 9 files changed, 229 insertions(+), 107 deletions(-)
 create mode 100644 share/html/Admin/Elements/EditRights
 create mode 100644 share/html/NoAuth/css/base/jquery-ui.css
 create mode 100644 share/html/NoAuth/css/base/rights-editor.css

- Log -----------------------------------------------------------------
commit 8433bae2b74f79f11714476d73dc23d48f6ef7f8
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Aug 27 10:54:47 2010 -0400

    Add the jQuery UI Tabs CSS that I forgot

diff --git a/share/html/NoAuth/css/base/jquery-ui-1.8.4.custom.modified.css b/share/html/NoAuth/css/base/jquery-ui-1.8.4.custom.modified.css
index 25d7b74..973d812 100755
--- a/share/html/NoAuth/css/base/jquery-ui-1.8.4.custom.modified.css
+++ b/share/html/NoAuth/css/base/jquery-ui-1.8.4.custom.modified.css
@@ -346,6 +346,24 @@
 	margin: -1px;
 }
 /*
+ * jQuery UI Tabs @VERSION
+ *
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Tabs#theming
+ */
+.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
+.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
+.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; }
+.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
+.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; }
+.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; }
+.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
+.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
+.ui-tabs .ui-tabs-hide { display: none !important; }
+/*
  * jQuery UI Datepicker @VERSION
  *
  * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)

commit 91e7c76901e3eec304735ad8aee250b3d47e97e2
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Aug 27 16:51:14 2010 -0400

    Fix doc reference to column name

diff --git a/lib/RT/GroupMember_Overlay.pm b/lib/RT/GroupMember_Overlay.pm
index 626a59b..50b0c0f 100755
--- a/lib/RT/GroupMember_Overlay.pm
+++ b/lib/RT/GroupMember_Overlay.pm
@@ -359,7 +359,7 @@ sub Delete {
 
 =head2 MemberObj
 
-Returns an RT::Principal object for the Principal specified by $self->PrincipalId
+Returns an RT::Principal object for the Principal specified by $self->MemberId
 
 =cut
 

commit c25dd8c7ee5b5c142c16998b3c535ce0aac4dada
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Aug 27 17:19:07 2010 -0400

    Checkpoint of the new rights editor /Admin/Elements/EditRights
    
    I replaced the old queue rights pages with the new editor, but they
    aren't completely functioning yet.  Fitting it into the other rights
    pages should be simple from here out though.
    
    TODO
      - Rights need to be split into categories
      - ProcessACLChanges needs to be updated to understand the checkbox format
      - User/group object lists need to be limited to only those with rights granted
      - Add ability to add a user/group using autocomplete textbox

diff --git a/share/html/Admin/Elements/EditRights b/share/html/Admin/Elements/EditRights
new file mode 100644
index 0000000..25d5586
--- /dev/null
+++ b/share/html/Admin/Elements/EditRights
@@ -0,0 +1,95 @@
+<%args>
+$Context
+$Principals
+</%args>
+<%init>
+use Scalar::Util qw(blessed);
+</%init>
+%# Principals is an array of arrays, where the inner arrays are like:
+%#      [ 'Category name' => $CollectionObj => 'DisplayColumn' => 1 ]
+%# The last value is a boolen determining if the value of DisplayColumn
+%# should be loc()-ed before display.
+
+<script type="text/javascript">
+  jQuery(function() {
+      jQuery(".rights-editor").tabs();
+  });
+</script>
+
+<div class="rights-editor clearfix">
+  <ul>
+<%perl>
+for my $category (@$Principals) {
+    my ($name, $collection, $col, $loc) = @$category;
+</%perl>
+<li class="category"><% $name %></li>
+<%perl>
+    while ( my $obj = $collection->Next ) {
+        my $display = ref $col eq 'CODE' ? $col->($obj) : $obj->$col;
+        my $id = "acl-$name-" . $obj->PrincipalId;
+        $id =~ s/[^a-zA-Z0-9\-]/_/g;
+</%perl>
+<li><a href="#<% $id %>"><% $loc ? loc($display) : $display %></a></li>
+<%perl>
+    }
+}
+</%perl>
+  </ul>
+
+<%perl>
+# Find all our available rights
+my %available_rights;
+if ( blessed($Context) and $Context->can('AvailableRights') ) { 
+    %available_rights = %{$Context->AvailableRights};
+}
+else {
+    %available_rights = ( loc('System Error') => loc("No rights found") );
+}
+
+# Find all the current rights
+my %current_rights;
+for my $collection (map { $_->[1] } @$Principals) {
+    while (my $group = $collection->Next) {
+        my $acls = RT::ACL->new($session{'CurrentUser'});
+        $acls->LimitToObject( $Context );
+        $acls->LimitToPrincipal( Id => $group->PrincipalId );
+        $acls->OrderBy( FIELD => 'RightName' ); 
+
+        while ( my $ace = $acls->Next ) {
+            my $right = $ace->RightName;
+            $current_rights{$group->PrincipalId}->{$right} = 1;
+        }
+    }
+}
+
+# Now generate our rights panels for each principal
+for my $category (@$Principals) {
+    my ($name, $collection, $col, $loc) = @$category;
+    while ( my $obj = $collection->Next ) {
+        my $display = ref $col eq 'CODE' ? $col->($obj) : $obj->$col;
+        my $acldesc = join '-', $obj->PrincipalId, ref($Context), $Context->Id;
+        my $id = "acl-$name-" . $obj->PrincipalId;
+        $id =~ s/[^a-zA-Z0-9\-]/_/g;
+</%perl>
+  <div id="<% $id %>">
+    <h3>Rights for <% $loc ? loc($display) : $display %></h3>
+    <ul class="rights-list">
+% for my $right (keys %available_rights) {
+      <li>
+        <input type="checkbox" class="checkbox"
+               name="GrantRight-<% $acldesc %>"
+               id="GrantRight-<% $acldesc %>-<% $right %>"
+               value="<% $right %>"
+               <% $current_rights{$obj->PrincipalId}->{$right} ? 'checked' : '' %> />
+        <label for="GrantRight-<% $acldesc %>-<% $right %>">
+          <% loc($available_rights{$right}) %>
+        </label>
+      </li>
+% }
+    </ul>
+  </div>
+<%perl>
+    }
+}
+</%perl>
+</div>
diff --git a/share/html/Admin/Queues/GroupRights.html b/share/html/Admin/Queues/GroupRights.html
index 3cbb105..2f5824f 100755
--- a/share/html/Admin/Queues/GroupRights.html
+++ b/share/html/Admin/Queues/GroupRights.html
@@ -47,74 +47,25 @@
 %# END BPS TAGGED BLOCK }}}
 <& /Admin/Elements/Header, Title => loc('Modify group rights for queue [_1]', $QueueObj->Name) &>
 <& /Admin/Elements/QueueTabs, id => $id, 
-    QueueObj => $QueueObj,                                                      
+    QueueObj => $QueueObj,
     current_tab => $current_tab, 
     Title => loc('Modify group rights for queue [_1]', $QueueObj->Name) &>
 <& /Elements/ListActions, actions => \@results &>
 
-  <form method="post" action="GroupRights.html">
-    <input type="hidden" class="hidden" name="id" value="<% $QueueObj->id %>" />
-      
-      
-<h1><&|/l&>System groups</&></h1>
-<table>
+<form method="post" action="GroupRights.html">
+  <input type="hidden" class="hidden" name="id" value="<% $QueueObj->id %>" />
+
+%# XXX TODO: this was just after the opening table tag, put it somewhere reasonable    
 % $m->callback( %ARGS, QueueObj => $QueueObj, results => \@results );
-% $Groups = RT::Groups->new($session{'CurrentUser'});
-% $Groups->LimitToSystemInternalGroups();
-%	while (my $Group = $Groups->Next()) {
-  <tr align="right"> 
-	<td valign="top">
-	    <% loc($Group->Type) %>
-		  </td>
-	  <td>
-	    <& /Admin/Elements/SelectRights, PrincipalId => $Group->PrincipalId,
-        Object => $QueueObj  &>
-	  </td>
-	</tr>
-% }
-</table>
-<h1><&|/l&>Roles</&></h1>
-<table>
-% $Groups = RT::Groups->new($session{'CurrentUser'});
-% $Groups->LimitToRolesForQueue($QueueObj->Id);
-%	while (my $Group = $Groups->Next()) {
-  <tr align="right"> 
-	<td valign="top">
-	    <% loc($Group->Type) %>
-		  </td>
-	  <td>
-	    <& /Admin/Elements/SelectRights, PrincipalId => $Group->PrincipalId,
-        Object => $QueueObj  &>
-	  </td>
-	</tr>
-% }
-</table>
-<h1><&|/l&>User defined groups</&></h1>
-<table>
-% $Groups = RT::Groups->new($session{'CurrentUser'});
-% $Groups->LimitToUserDefinedGroups();    
-%	while (my $Group = $Groups->Next()) {
-  <tr align="right"> 
-	<td valign="top">
-	    <% $Group->Name %>
-		  </td>
-	  <td>
-	    <& /Admin/Elements/SelectRights, PrincipalId => $Group->PrincipalId,
-        Object => $QueueObj  &>
-	  </td>
-	</tr>
-% }
-</table>
-            
-      <& /Elements/Submit, Label => loc('Modify Group Rights'), Reset => 1 &>
-      
-  </form>
-  
-<%INIT>
- 
-  #Update the acls.
-  my @results =  ProcessACLChanges(\%ARGS);
 
+  <& /Admin/Elements/EditRights, Context => $QueueObj, Principals => \@principals &>
+
+  <& /Elements/Submit, Label => loc('Modify Group Rights'), Reset => 1 &>
+</form>
+
+<%INIT>
+# Update the acls.
+my @results =  ProcessACLChanges(\%ARGS);
 
 if (!defined $id) {
     Abort(loc("No Queue defined"));
@@ -123,12 +74,26 @@ if (!defined $id) {
 my $QueueObj = RT::Queue->new($session{'CurrentUser'});
 $QueueObj->Load($id) || Abort(loc("Couldn't load queue [_1]",$id));
 
-my $Groups;
-my $current_tab;
-$current_tab = 'Admin/Queues/GroupRights.html?id='.$QueueObj->id;
-    
-</%INIT>
+my $current_tab = 'Admin/Queues/GroupRights.html?id='.$QueueObj->id;
+
+# Principal collections
+my $system = RT::Groups->new($session{'CurrentUser'});
+$system->LimitToSystemInternalGroups();
+
+my $roles = RT::Groups->new($session{'CurrentUser'});
+$roles->LimitToRolesForQueue($QueueObj->Id);
 
+my $groups = RT::Groups->new($session{'CurrentUser'});
+$groups->LimitToUserDefinedGroups();
+# XXX TODO: only find those user groups with rights granted
+
+my @principals = (
+    # Category        collection   column    loc?
+    ['System'      => $system   => 'Type' => 1],
+    ['Roles'       => $roles    => 'Type' => 1],
+    ['User Groups' => $groups   => 'Name' => 0],
+);
+</%INIT>
 <%ARGS>
 $id => undef
 </%ARGS>
diff --git a/share/html/Admin/Queues/UserRights.html b/share/html/Admin/Queues/UserRights.html
index ecfac9d..757991f 100755
--- a/share/html/Admin/Queues/UserRights.html
+++ b/share/html/Admin/Queues/UserRights.html
@@ -47,43 +47,26 @@
 %# END BPS TAGGED BLOCK }}}
 <& /Admin/Elements/Header, Title => loc('Modify user rights for queue [_1]', $QueueObj->Name) &>
 <& /Admin/Elements/QueueTabs, id => $id,
-    QueueObj => $QueueObj,                                                      
+    QueueObj => $QueueObj,
     current_tab => $current_tab, 
     Title => loc('Modify user rights for queue [_1]', $QueueObj->Name) &>
 <& /Elements/ListActions, actions => \@results &>
 
-  <form method="post" action="UserRights.html">
-    <input type="hidden" class="hidden" name="id" value="<% $QueueObj->id %>" />
-      
-      
-<table>
+<form method="post" action="UserRights.html">
+  <input type="hidden" class="hidden" name="id" value="<% $QueueObj->id %>" />
+
+%# XXX TODO put this somewhere more reasonable      
 % $m->callback( %ARGS, QueueObj => $QueueObj, results => \@results );
-%	while (my $Member = $Users->Next()) {
-% my $UserObj = $Member->MemberObj->Object();
-% my $group = RT::Group->new($session{'CurrentUser'});
-% $group->LoadACLEquivalenceGroup($Member->MemberObj);
-  <tr align="right"> 
-	<td valign="top"><& /Elements/ShowUser, User => $UserObj &></td>
-	  <td>
-	    <& /Admin/Elements/SelectRights, PrincipalId=> $group->PrincipalId,
-        Object => $QueueObj  &>
-	  </td>
-	</tr>
-% }
-      </table>
-            
-      <& /Elements/Submit, Label => loc('Modify User Rights'), Reset => 1 &>
-      
-  </form>
-  
-<%INIT>
- 
-  #Update the acls.
-  my @results =  ProcessACLChanges(\%ARGS);
 
-# {{{ Deal with setting up the display of current rights.
+  <& /Admin/Elements/EditRights, Context => $QueueObj, Principals => \@principals &>
+ 
+  <& /Elements/Submit, Label => loc('Modify User Rights'), Reset => 1 &>
 
+</form>
 
+<%INIT>
+# Update the acls.
+my @results =  ProcessACLChanges(\%ARGS);
 
 if (!defined $id) {
     Abort(loc("No Queue defined"));
@@ -92,16 +75,17 @@ if (!defined $id) {
 my $QueueObj = RT::Queue->new($session{'CurrentUser'});
 $QueueObj->Load($id) || Abort(loc("Couldn't load queue [_1]",$id));
 
-# Find out which users we want to display ACL selects for
+# Find out which users we want to display ACLs for
 my $Privileged = RT::Group->new($session{'CurrentUser'});
 $Privileged->LoadSystemInternalGroup('Privileged');
-my $Users = $Privileged->MembersObj();
+my $Users = $Privileged->UserMembersObj();
+
+my $display = sub {
+    $m->scomp('/Elements/ShowUser', User => $_[0], NoEscape => 1)
+};
+my @principals = (['Users' => $Users => $display => 0]);
 
-    
-  
-# }}}
-my $current_tab;
-$current_tab = 'Admin/Queues/UserRights.html?id='.$QueueObj->id;
+my $current_tab = 'Admin/Queues/UserRights.html?id='.$QueueObj->id;
 </%INIT>
 
 <%ARGS>
diff --git a/share/html/NoAuth/css/base/jquery-ui.css b/share/html/NoAuth/css/base/jquery-ui.css
new file mode 100644
index 0000000..b59e22a
--- /dev/null
+++ b/share/html/NoAuth/css/base/jquery-ui.css
@@ -0,0 +1,2 @@
+ at import "jquery-ui-1.8.4.custom.modified.css";
+ at import "ui.timepickr.css";
diff --git a/share/html/NoAuth/css/base/main.css b/share/html/NoAuth/css/base/main.css
index 753c39f..76a4b15 100644
--- a/share/html/NoAuth/css/base/main.css
+++ b/share/html/NoAuth/css/base/main.css
@@ -47,8 +47,10 @@
 %# END BPS TAGGED BLOCK }}}
 % $m->callback(CallbackName => 'Begin');
 
+ at import "jquery-ui.css";
 @import "misc.css";
 @import "ticket-form.css";
+ at import "rights-editor.css";
 
 % $m->callback(CallbackName => 'End');
 
diff --git a/share/html/NoAuth/css/base/misc.css b/share/html/NoAuth/css/base/misc.css
index 3281c31..383dc04 100644
--- a/share/html/NoAuth/css/base/misc.css
+++ b/share/html/NoAuth/css/base/misc.css
@@ -45,9 +45,6 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
- at import "jquery-ui-1.8.4.custom.modified.css";
- at import "ui.timepickr.css";
-
 .hide, .hidden { display: none !important; }
 
 .clear { clear: both; }
diff --git a/share/html/NoAuth/css/base/rights-editor.css b/share/html/NoAuth/css/base/rights-editor.css
new file mode 100644
index 0000000..82d7a56
--- /dev/null
+++ b/share/html/NoAuth/css/base/rights-editor.css
@@ -0,0 +1,59 @@
+/* This selector is very heavy handed, but the jQuery UI theme is tenacious */
+.rights-editor, .rights-editor * {
+    font-family: arial, helvetica, sans-serif !important;
+}
+
+/* Styles for putting jQuery UI tabs on the left */
+.rights-editor {
+    border: none;
+    background: transparent;
+}
+
+/* Position and style the left tabs */
+.rights-editor > .ui-tabs-nav {
+    float: left;
+    background: transparent;
+    border: none;
+    color: black;
+}
+
+.rights-editor > .ui-tabs-nav li {
+    float: none;
+    display: block;
+    border: none;
+    background: transparent;
+}
+
+.rights-editor > .ui-tabs-nav li a {
+    float: none;
+    display: block;
+    padding: 0 0 0.2em 1em;
+    overflow: hidden;
+    text-overflow: ellipsis;
+}
+
+.rights-editor .ui-tabs-nav li.category {
+    text-transform: uppercase;
+}
+
+li.category ~ li.category {
+    margin-top: 1em;
+}
+
+/* Position the outer-most panel */
+.rights-editor > .ui-tabs-panel {
+    position: static;
+    float: right;
+}
+
+.rights-editor .ui-tabs-panel {
+    padding: 2px;
+}
+
+.rights-editor .ui-tabs-panel h3 {
+    margin-top: 0;
+}
+
+.rights-editor ul.rights-list {
+    list-style: none;
+}

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


More information about the Rt-commit mailing list