[Rt-devel] adding non-priviledged users to groups
Nicholas Clark
nick at ccl4.org
Wed May 16 10:24:42 EDT 2007
Here's a first stab at providing the interface to allow non-privileged users
to be added to groups.
I'm not sure how efficient it is, as it calls Privileged() on each user in
turn in turn when building the list, and Privileged appears to result in a
call on the database each time. I couldn't see how to get DBIx::SeachBuilder
to return the info all at once.
Also, there is cut&paste in the HTML looping, but I for just two categories
I think that it's preferable to a more general code, as that would be at
least as long, and feels like over-engineering.
Nicholas Clark
--- html/Admin/Elements/SelectNewGroupMembers~ Mon Jun 19 22:44:04 2006
+++ html/Admin/Elements/SelectNewGroupMembers Wed May 16 14:09:10 2007
@@ -46,8 +46,12 @@
% if ($Show ne 'Groups') {
<b><&|/l&>Users</&></b>
<select multiple name="<%$Name%>Users" size="10">
-%while (my $user = $users->Next) {
-%next if $SkipUsers->{$user->id};
+<optgroup label="Priviledged users">
+%foreach my $user (@priv) {
+<option value="User-<%$user->id%>"><%$user->Name%></option>
+%}
+<optgroup label="Unprivileged users">
+%foreach my $user (@unpriv) {
<option value="User-<%$user->id%>"><%$user->Name%></option>
%}
</select>
@@ -78,7 +82,19 @@
OPERATOR => '!=',
ENTRYAGGREGATOR => 'AND'
);
-$users->LimitToPrivileged();
+
+my (@priv, @unpriv);
+
+{
+ while (my $user = $users->Next) {
+ next if $SkipUsers->{$user->id};
+ if ($user->Privileged) {
+ push @priv, $user;
+ } else {
+ push @unpriv, $user;
+ }
+ }
+}
my $groups = new RT::Groups($session{'CurrentUser'});
More information about the Rt-devel
mailing list