To list,<br><br>I have implemented the "TimeWorkedReport" in our environment and it works well. However, I want to modify something that is a bit of a problem for us. The delivered code allows for a "SuperUser" to see the time reported by any other User. Our problem is that for our Group Managers to use this functionality, they would have to be "SuperUSers". We have over 110 Queues and our Group Managers (5 of them) just don't want to see such a HUGE list of Queues in the dropdown lists of Queues. They just want to see their own.<br>
<br>My answer to the problem was to modify the code to see if the user is a member of a group (called 'BS-Group Managers') instead of checking if they have "SuperUser" rights. I was thinking this would keep my code modifications to a minimum as the only code I would have to change would be where the "SuperUser" right is checked.<br>
<br>My biggest problem is I am in <i>NO WAY</i> a perl programmer. I get by by copying code and making small changes.<br><br>I've looked at other code in RT and found what <i>I thought</i> were good examples of the kind of code I need. Obviously, I need to identify the Group and the user. This is what I have so far:<br>
<br># Get the Group Objects<br> <br>my $GroupObj = new RT::Group($session{$RT::CurrentUser});<br>$GroupObj->LoadUserDefinedGroup('BS-Group Managers');<br>my $UserId = new RT::User($session{$RT::CurrentUser}); # part of second option<br>
#my $GrpMgr = $GroupObj->UserMemberObj->PrincipalId($session{$RT::CurrentUser}); # first option<br>my $GrpMgr = $GroupObj->UserMemberObj->PrincipalId($UserId); # second option<br> <br># Skip next code if user not in Mgr Group <br>
<br># if this person is not a member of the mgrs group, we should only show them the report for themselves <br># which means we should remove all keys from %stats except their own username<br> <br>unless ($GrpMgr) <br> {<br>
my %tempstats;<br> $tempstats{$session{CurrentUser}->Name} = $stats{$session{CurrentUser}->Name};<br> %stats = %tempstats;<br> }<br><br>Once I have the group identified, I tried to see if the <i>current user</i> is in it, then I modified the "check for SuperUser right" to check for that membership.<br>
<br>When I test using my first option "$session{$RT::CurrentUser}", I get this:<br><br>Can't locate object method "PrincipalId" via package "No object mapping
for field" (perhaps you forgot to load "No object mapping for field"?)
at /opt/rt3/local/html/Tools/Reports/TimeWorkedReport.html line 222, line 307.<br><br>
When I test using my second option "$UserId", I get this:<br><br>Can't locate object method "PrincipalId" via package "No object mapping
for field" (perhaps you forgot to load "No object mapping for field"?)
at /opt/rt3/local/html/Tools/Reports/TimeWorkedReport.html line 224, line 307.<br><br>I know it looks like I'm bumbling around with these objects and I AM! I've asked my boss to send me to a perl class and he has OK'd that, but until then, I just can't see why my code is wrong. I thought "PrincipalId" was kinda built-in when looking at users.<br>
<b>AND</b> I think I'm may be misunderstanding the code "new
RT::Group($session{$RT::CurrentUser})". I can't tell if it is the same
as this "RT::Group->new($RT::SystemUser);" (which I've used
successfully in other code) and I'm not sure if it actually gives an ID
or is temporaryily pointing to one.<br><br>So, If anyone can get me a little help so I can understand how to go about doing this, I'd be <b>REALLY</b> grateful.<br><br>Thanks.<br><br>Kenn<br>LBNL<br><br><br>