[Rt-devel] adding non-priviledged users to groups

Jesse Vincent jesse at bestpractical.com
Wed May 16 12:29:30 EDT 2007


On May 16, 2007, at 10:24 AM, Nicholas Clark wrote:

> 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.

I'd probably do two different user objects. One of which is - 
 >LimitToPrivileged, the other of which is LimitToUnprivileged.

-j


> 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'});
>
> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/ 
> rt-devel
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.bestpractical.com/pipermail/rt-devel/attachments/20070516/9f8538f3/PGP.pgp


More information about the Rt-devel mailing list