3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 # (Except where explictly superceded by other copyright notices)
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
30 RT::System is a simple global object used as a focal point for things
33 It works sort of like an RT::Record, except it's really a single object that has
34 an id of "1" when instantiated.
36 This gets used by the ACL system so that you can have rights for the scope "RT::System"
38 In the future, there will probably be other API goodness encapsulated here.
44 use base qw /RT::Base/;
48 use vars qw/ $RIGHTS/;
50 # System rights are rights granted to the whole system
51 # XXX TODO Can't localize these outside of having an object around.
53 SuperUser => 'Do anything and everything', # loc_pair
54 AdminAllPersonalGroups =>
55 "Create, delete and modify the members of any user's personal groups"
57 AdminOwnPersonalGroups =>
58 'Create, delete and modify the members of personal groups', # loc_pair
59 AdminUsers => 'Create, delete and modify users', # loc_pair
60 ModifySelf => "Modify one's own RT account", # loc_pair
62 "Delegate specific rights which have been granted to you." # loc_pair
65 # Tell RT::ACE that this sort of object can get acls granted
66 $RT::ACE::OBJECT_TYPES{'RT::System'} = 1;
68 foreach my $right ( keys %{$RIGHTS} ) {
69 $RT::ACE::LOWERCASERIGHTNAMES{ lc $right } = $right;
73 =head2 AvailableRights
75 Returns a hash of available rights for this object. The keys are the right names and the values are a description of what the rights do
79 my $s = RT::System->new($RT::SystemUser);
80 my $rights = $s->AvailableRights;
81 ok ($rights, "Rights defined");
82 ok ($rights->{'AdminUsers'},"AdminUsers right found");
83 ok ($rights->{'CreateTicket'},"CreateTicket right found");
84 ok ($rights->{'AdminGroupMembership'},"ModifyGroupMembers right found");
85 ok (!$rights->{'CasdasdsreateTicket'},"bogus right not found");
97 my $queue = RT::Queue->new($RT::SystemUser);
98 my $group = RT::Group->new($RT::SystemUser);
100 my $qr =$queue->AvailableRights();
101 my $gr = $group->AvailableRights();
103 # Build a merged list of all system wide rights, queue rights and group rights.
104 my %rights = (%{$RIGHTS}, %{$gr}, %{$qr});
111 Create a new RT::System object. Really, you should be using $RT::System
118 my $class = ref($proto) || $proto;
120 bless( $self, $class );
128 Returns RT::System's id. It's 1.
134 my $sys = RT::System->new();
151 Since this object is pretending to be an RT::Record, we need a load method.
160 eval "require RT::System_Vendor";
161 die $@ if ($@ && $@ !~ qr{^Can't locate RT/System_Vendor.pm});
162 eval "require RT::System_Local";
163 die $@ if ($@ && $@ !~ qr{^Can't locate RT/System_Local.pm});