delete invoices, RT#4048
[freeside.git] / FS / FS / AccessRight.pm
1 package FS::AccessRight;
2
3 use strict;
4 use vars qw(@rights); # %rights);
5 use Tie::IxHash;
6
7 =head1 NAME
8
9 FS::AccessRight - Access control rights.
10
11 =head1 SYNOPSIS
12
13   use FS::AccessRight;
14
15 =head1 DESCRIPTION
16
17 Access control rights - Permission to perform specific actions that can be
18 assigned to users and/or groups.
19
20 =cut
21
22 #@rights = (
23 #  'Reports' => [
24 #    '_desc' => 'Access to high-level reporting',
25 #  ],
26 #  'Configuration' => [
27 #    '_desc' => 'Access to configuration',
28 #
29 #    'Settings' => {},
30 #
31 #    'agent' => [
32 #      '_desc' => 'Master access to reseller configuration',
33 #      'agent_type'  => {},
34 #      'agent'       => {},
35 #    ],
36 #
37 #    'export_svc_pkg' => [
38 #      '_desc' => 'Access to export, service and package configuration',
39 #      'part_export' => {},
40 #      'part_svc'    => {},
41 #      'part_pkg'    => {},
42 #      'pkg_class'   => {},
43 #    ],
44 #
45 #    'billing' => [
46 #      '_desc' => 'Access to billing configuration',
47 #      'payment_gateway'  => {},
48 #      'part_bill_event'  => {},
49 #      'prepay_credit'    => {},
50 #      'rate'             => {},
51 #      'cust_main_county' => {},
52 #    ],
53 #
54 #    'dialup' => [
55 #      '_desc' => 'Access to dialup configuraiton',
56 #      'svc_acct_pop' => {},
57 #    ],
58 #
59 #    'broadband' => [
60 #      '_desc' => 'Access to broadband configuration',
61 #      'router'     => {},
62 #      'addr_block' => {},
63 #    ],
64 #
65 #    'misc' => [
66 #      'part_referral'      => {},
67 #      'part_virtual_field' => {},
68 #      'msgcat'             => {},
69 #      'inventory_class'    => {},
70 #    ],
71 #
72 #  },
73 #
74 #);
75 #
76 ##turn it into a more hash-like structure, but ordered via IxHash
77
78 #well, this is what we have for now.  could be ordered better, could be lots of
79 # things better, but this ACL system does 99% of what folks need and the UI
80 # isn't *that* bad
81
82 # okay, well it *really* needs some catgorization in the UI.  badly.
83 @rights = (
84
85 ##
86 # basic customer rights
87 ##
88   'New customer',
89   'View customer',
90   #'View Customer | View tickets',
91   'Edit customer',
92   'Cancel customer',
93   'Complimentary customer', #aka users-allow_comp 
94   'Delete customer', #aka. deletecustomers #Enable customer deletions. Be very careful! Deleting a customer will remove all traces that this customer ever existed! It should probably only be used when auditing a legacy database. Normally, you cancel all of a customers' packages if they cancel service.
95   'Add customer note', #NEW
96   'Edit customer note', #NEW
97   'Bill customer now', #NEW
98   'Bulk send customer notices', #NEW
99
100 ###
101 # customer package rights
102 ###
103   'View customer packages', #NEW
104   'Order customer package',
105   'One-time charge',
106   'Change customer package',
107   'Bulk change customer packages',
108   'Edit customer package dates',
109   'Customize customer package',
110   'Suspend customer package',
111   'Suspend customer package later',
112   'Unsuspend customer package',
113   'Cancel customer package immediately',
114   'Cancel customer package later',
115   'Delay suspension events',
116   'Add on-the-fly cancel reason', #NEW
117   'Add on-the-fly suspend reason', #NEW
118   'Edit customer package invoice details', #NEW
119   'Edit customer package comments', #NEW
120
121 ###
122 # customer service rights
123 ###
124   'Edit usage', #NEW
125   'Edit home dir', #NEW
126   'Edit www config', #NEW
127   'Edit domain catchall', #NEW
128   'Edit domain nameservice', #NEW
129   'View customer services', #NEW
130   'Provision customer service',
131   'Recharge customer service', #NEW
132   'Unprovision customer service',
133   'Change customer service', #NEWNEW
134
135   'View/link unlinked services', #not agent-virtualizable without more work
136
137 ###
138 # customer invoice/financial info rights
139 ###
140   'View invoices',
141   'Resend invoices', #NEWNEW
142   'Delete invoices', #new, but no need to phase in
143   'View customer tax exemptions', #yow
144   'View customer batched payments', #NEW
145
146 ###
147 # customer payment rights
148 ###
149   'Post payment',
150   'Post payment batch',
151   'Apply payment', #NEWNEW
152   'Unapply payment', #aka. unapplypayments Enable "unapplication" of unclosed payments.
153   'Process payment',
154   'Refund payment',
155
156   'Delete payment', #aka. deletepayments - Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.
157
158   'Delete refund', #NEW
159
160 ###
161 # customer credit rights
162 ###
163   'Post credit',
164   'Apply credit', #NEWNEW
165   'Unapply credit', #aka unapplycredits Enable "unapplication" of unclosed credits.
166   'Delete credit', #aka. deletecredits Enable deletion of unclosed credits. Be very careful! Only delete credits that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a credit is deleted.
167   'Post refund',
168 #  'Process refund',
169   'Add on-the-fly credit reason', #NEW
170
171 ###
172 # customer voiding rights..
173 ###
174   'Credit card void', #aka. cc-void #Enable local-only voiding of echeck payments in addition to refunds against the payment gateway
175   'Echeck void', #aka. echeck-void #Enable local-only voiding of echeck payments in addition to refunds against the payment gateway
176   'Regular void',
177   'Unvoid', #aka. unvoid #Enable unvoiding of voided payments
178
179 ###
180 # report/listing rights...
181 ###
182   'List customers',
183   'List zip codes', #NEW
184   'List invoices',
185   'List packages',
186   'List services',
187
188   'List rating data',  # 'Usage reports',
189   'Billing event reports',
190   'Financial reports',
191
192 ###
193 # misc rights
194 ###
195   'Job queue',         # these are not currently agent-virtualized
196   'Process batches',   # NEW
197   'Reprocess batches', # NEW
198   'Import',            #
199   'Export',            #
200
201 ###
202 # misc misc rights
203 ###
204   'Raw SQL', #NEW
205
206 ###
207 # setup/config rights
208 ###
209   'Edit advertising sources',
210   'Edit global advertising sources',
211
212   'Configuration', #most of the rest of the configuraiton is not
213                    # agent-virtualized
214 );
215
216 sub rights {
217   @rights;
218 }
219
220 sub default_superuser_rights {
221   my $class = shift;
222   my %omit = map { $_=>1 } (
223     'Delete customer',
224     'Delete invoices',
225     'Delete payment',
226     'Delete credit', #?
227     'Delete refund', #?
228     'Raw SQL',
229   );
230
231   no warnings 'uninitialized';
232   grep { ! $omit{$_} } $class->rights;
233 }
234
235 1;