1 # {{{ BEGIN BPS TAGGED BLOCK
5 # This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC
6 # <jesse@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 # CONTRIBUTION SUBMISSION POLICY:
30 # (The following paragraph is not intended to limit the rights granted
31 # to you to modify and distribute this software under the terms of
32 # the GNU General Public License and is only of importance to you if
33 # you choose to contribute your changes and enhancements to the
34 # community by submitting them to Best Practical Solutions, LLC.)
36 # By intentionally submitting any modifications, corrections or
37 # derivatives to this work, or any other work intended for use with
38 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
39 # you are the copyright holder for those contributions and you grant
40 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
41 # royalty-free, perpetual, license to use, copy, create derivative
42 # works based on those contributions, and sublicense and distribute
43 # those contributions and any derivatives thereof.
45 # }}} END BPS TAGGED BLOCK
52 RT::System is a simple global object used as a focal point for things
55 It works sort of like an RT::Record, except it's really a single object that has
56 an id of "1" when instantiated.
58 This gets used by the ACL system so that you can have rights for the scope "RT::System"
60 In the future, there will probably be other API goodness encapsulated here.
66 use base qw /RT::Base/;
70 use vars qw/ $RIGHTS/;
72 # System rights are rights granted to the whole system
73 # XXX TODO Can't localize these outside of having an object around.
75 SuperUser => 'Do anything and everything', # loc_pair
76 AdminAllPersonalGroups =>
77 "Create, delete and modify the members of any user's personal groups"
79 AdminOwnPersonalGroups =>
80 'Create, delete and modify the members of personal groups', # loc_pair
81 AdminUsers => 'Create, delete and modify users', # loc_pair
82 ModifySelf => "Modify one's own RT account", # loc_pair
84 "Delegate specific rights which have been granted to you." # loc_pair
87 # Tell RT::ACE that this sort of object can get acls granted
88 $RT::ACE::OBJECT_TYPES{'RT::System'} = 1;
90 foreach my $right ( keys %{$RIGHTS} ) {
91 $RT::ACE::LOWERCASERIGHTNAMES{ lc $right } = $right;
95 =head2 AvailableRights
97 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
101 my $s = RT::System->new($RT::SystemUser);
102 my $rights = $s->AvailableRights;
103 ok ($rights, "Rights defined");
104 ok ($rights->{'AdminUsers'},"AdminUsers right found");
105 ok ($rights->{'CreateTicket'},"CreateTicket right found");
106 ok ($rights->{'AdminGroupMembership'},"ModifyGroupMembers right found");
107 ok (!$rights->{'CasdasdsreateTicket'},"bogus right not found");
116 sub AvailableRights {
119 my $queue = RT::Queue->new($RT::SystemUser);
120 my $group = RT::Group->new($RT::SystemUser);
122 my $qr =$queue->AvailableRights();
123 my $gr = $group->AvailableRights();
125 # Build a merged list of all system wide rights, queue rights and group rights.
126 my %rights = (%{$RIGHTS}, %{$gr}, %{$qr});
133 Create a new RT::System object. Really, you should be using $RT::System
140 my $class = ref($proto) || $proto;
142 bless( $self, $class );
150 Returns RT::System's id. It's 1.
156 my $sys = RT::System->new();
173 Since this object is pretending to be an RT::Record, we need a load method.
182 eval "require RT::System_Vendor";
183 die $@ if ($@ && $@ !~ qr{^Can't locate RT/System_Vendor.pm});
184 eval "require RT::System_Local";
185 die $@ if ($@ && $@ !~ qr{^Can't locate RT/System_Local.pm});