[rt-devel] Understanding RT:Users

Jesse Vincent jesse at bestpractical.com
Fri Sep 21 15:08:34 EDT 2001


Er. How about $RT::SystemUser.  
you need to be sure you have an RT::User or RT::CurrentUser object to work with
any objects in the system or the ACL system won't be happy.




On Fri, Sep 21, 2001 at 12:06:10PM -0700, matthew zeier wrote:
> >
> > You want something like this
> >
> >
> >  CleanEnv();
> >  LoadConfig();
> >  DBConnect();
> >
> >  my $users_obj    = new RT::Users($RT::System);
> >   #new takes an RT::User or RT::CurrentUser, not a username
> >  $users_obj->MemberOfGroup('6');
> >
> >  while (my $user = $users_obj->Next) {
> >
> >      dumpValue($user);
> >
> >  }
> >  $RT::Handle->Disconnect();
> >
> 
> Hurm.  That still generates a similiar error - help?
> 
> RT::Users=HASH(0x576364) was created without a CurrentUser at
> /opt/rt2/lib/RT/EasySearch.pm line 27
>         RT::EasySearch::_Init('RT::Users=HASH(0x576364)', undef) called at
> /opt/rt2/lib/RT/Users.pm line 37
>         RT::Users::_Init('RT::Users=HASH(0x576364)', undef) called at
> /usr/local/lib/perl5/site_perl/5.6.0/DBIx/SearchBuilder.pm line 37
>         DBIx::SearchBuilder::new('RT::Users', undef) called at ii line 23
> 
> 
> 
> The exact script is:
> 
> #!/usr/bin/perl -w
> 
> 
> use strict;
> use Carp;
> 
> use lib "/opt/rt2/lib";
> use lib "/opt/rt2/etc";
> 
> use RT::Interface::CLI  qw(CleanEnv LoadConfig DBConnect
>                GetCurrentUser GetMessageContent);
> 
> CleanEnv();
> LoadConfig();
> DBConnect();
> 
> use RT::Date;
> use RT::Queue;
> use RT::Tickets;
> use RT::Users;
> 
> 
> my $users_obj    = new RT::Users($RT::System);
> #new takes an RT::User or RT::CurrentUser, not a username
> $users_obj->MemberOfGroup('6');
> 
>     while (my $user = $users_obj->Next) {
> 
>         dumpValue($user);
> 
>     }
> 
> $RT::Handle->Disconnect();
> 
> 
> 

-- 
http://www.bestpractical.com/products/rt  -- Trouble Ticketing. Free.




More information about the Rt-devel mailing list