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

Jesse Vincent jesse at bestpractical.com
Thu May 17 15:24:53 EDT 2007


I think I'm happy with this for 3.7.

Ruz/anybody else: feelings?
-j

On May 17, 2007, at 4:58 AM, Nicholas Clark wrote:

> On Wed, May 16, 2007 at 01:01:48PM -0400, Jesse Vincent wrote:
>
>> Getting there. A nuance of mason:  It's one namespace for all mason
>> pages. So sub definitions are...not what you want. An anon sub is
>> better.
>
> Ah. I did it with a foreach instead. It seemed less clunky that  
> creating then
> calling an anonymous sub.
>
>> I'd also put the label on the optgroup inside  <%loc("")%> so that it
>> gets localized.
>
> Is that the same as <&|/l&> ?
>
> If so, the appended should do it.
>
> Nicholas Clark
>
> --- html/Admin/Elements/SelectNewGroupMembers~	Mon Jun 19 22:44:04  
> 2006
> +++ html/Admin/Elements/SelectNewGroupMembers	Thu May 17 08:47:18 2007
> @@ -46,7 +46,13 @@
>  % if ($Show ne 'Groups') {
>  <b><&|/l&>Users</&></b>
>  <select multiple name="<%$Name%>Users"  size="10">
> -%while (my $user = $users->Next) {
> +<optgroup label="<&|/l&>Privileged users</&>">
> +%while (my $user = $p_users->Next) {
> +%next if $SkipUsers->{$user->id};
> +<option value="User-<%$user->id%>"><%$user->Name%></option>
> +%}
> +<optgroup label="<&|/l&>Unprivileged users</&>">
> +%while (my $user = $u_users->Next) {
>  %next if $SkipUsers->{$user->id};
>  <option value="User-<%$user->id%>"><%$user->Name%></option>
>  %}
> @@ -64,21 +70,30 @@
>  % }
>
>  <%INIT>
> -my $users = new RT::Users($session{'CurrentUser'});
>
> -$users->Limit(
> +# It's one namespace for all mason pages, so the "logical" way of  
> doing this,
> +# a subroutine definition, is not the best way. Hence the foreach  
> to initialize
> +
> +my ($p_users, $u_users);
> +foreach my $users ($p_users, $u_users) {
> +  $users = new RT::Users($session{'CurrentUser'});
> +
> +  $users->Limit(
>      FIELD           => 'id',
>      VALUE           => $RT::SystemUser->id,
>      OPERATOR        => '!=',
>      ENTRYAGGREGATOR => 'AND'
> -);
> -$users->Limit(
> +  );
> +  $users->Limit(
>      FIELD           => 'id',
>      VALUE           => $RT::Nobody->id,
>      OPERATOR        => '!=',
>      ENTRYAGGREGATOR => 'AND'
> -);
> -$users->LimitToPrivileged();
> +  );
> +}
> +
> +$p_users->LimitToPrivileged();
> +$u_users->LimitToUnprivileged();
>
>  my $groups = new RT::Groups($session{'CurrentUser'});
>
> --- lib/RT/Users_Overlay.pm~	Tue Sep 26 15:06:31 2006
> +++ lib/RT/Users_Overlay.pm	Thu May 17 08:54:06 2007
> @@ -226,6 +226,27 @@
>
>  # }}}
>
> +# {{{ LimitToUnprivileged
> +
> +=head2 LimitToUnprivileged
> +
> +Limits to users who can not be made members of ACLs and groups
> +
> +=cut
> +
> +sub LimitToUnprivileged {
> +    my $self = shift;
> +
> +    my $priv = RT::Group->new( $self->CurrentUser );
> +    $priv->LoadSystemInternalGroup('Unprivileged');
> +    unless ( $priv->Id ) {
> +        $RT::Logger->crit("Couldn't find a unprivileged users  
> group");
> +    }
> +    $self->MemberOfGroup( $priv->PrincipalId );
> +}
> +
> +# }}}
> +
>  # {{{ WhoHaveRight
>
>  =head2 WhoHaveRight { Right => 'name', Object => $rt_object ,  
> IncludeSuperusers => undef, IncludeSubgroupMembers => undef,  
> IncludeSystemRights => undef, EquivObjects => [ ] }
>

-------------- 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/20070517/63b6845c/PGP.pgp


More information about the Rt-devel mailing list