[freeside-commits] freeside/FS/FS AccessRight.pm, 1.2, 1.3 access_user.pm, 1.2, 1.3 cust_main.pm, 1.216, 1.217

Ivan,,, ivan at wavetail.420.am
Mon Jun 19 04:25:15 PDT 2006


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv15649/FS/FS

Modified Files:
	AccessRight.pm access_user.pm cust_main.pm 
Log Message:
ACLs, take three or four or something

Index: access_user.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/access_user.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- access_user.pm	19 Jun 2006 02:33:52 -0000	1.2
+++ access_user.pm	19 Jun 2006 11:25:13 -0000	1.3
@@ -192,6 +192,29 @@
   ' )';
 }
 
+=item access_right
+
+Given a right name, returns true if this user has this right (currently via
+group membership, eventually also via user overrides).
+
+=cut
+
+sub access_right {
+  my( $self, $rightname ) = @_;
+  my $sth = dbh->prepare("
+    SELECT groupnum FROM access_usergroup
+                    LEFT JOIN access_group USING ( groupnum )
+                    LEFT JOIN access_right
+                         ON ( access_group.groupnum = access_right.rightobjnum )
+      WHERE usernum = ?
+        AND righttype = 'FS::access_group'
+        AND rightname = ?
+  ") or die dbh->errstr;
+  $sth->execute($self->usernum, $rightname) or die $sth->errstr;
+  my $row = $sth->fetchrow_arrayref;
+  $row ? $row->[0] : '';
+}
+
 =back
 
 =head1 BUGS

Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- AccessRight.pm	18 Jun 2006 12:54:48 -0000	1.2
+++ AccessRight.pm	19 Jun 2006 11:25:13 -0000	1.3
@@ -84,10 +84,13 @@
   #'View Customer | View tickets',
   'Edit customer',
   'Cancel customer',
-  'Delete customer',
+  'Complimentary customer', #aka users-allow_comp 
+  '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.
 
   'Order customer package',
+  'One-time charge',
   'Change customer package',
+  'Bulk change customer packages',
   'Edit customer package dates',
   'Customize customer package',
   'Suspend customer package',
@@ -95,14 +98,43 @@
   'Cancel customer package immediately',
   'Cancel customer package later',
 
-  'Provision service',
-  'Unprovision service',
-  #legacy link stuff
+  'Provision customer service',
+  'Unprovision customer service',
+
+  'View/link unlinked services', #not agent-virtualizable without more work
+
+  'View invoices',
 
   'Post payment',
+  'Post payment batch',
+  'Unapply payment', #aka. unapplypayments Enable "unapplication" of unclosed payments.
   'Process payment',
+  'Refund payment',
+
+  '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.
+
   'Post credit',
-  #more financial stuff
+  #'Apply credit',
+  'Unapply credit', #aka unapplycredits Enable "unapplication" of unclosed credits.
+  '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.
+
+  'Credit card void', #aka. cc-void #Enable local-only voiding of echeck payments in addition to refunds against the payment gateway
+  'Echeck void', #aka. echeck-void #Enable local-only voiding of echeck payments in addition to refunds against the payment gateway
+  'Unvoid', #aka. unvoid #Enable unvoiding of voided payments
+
+  'List customers',
+  #'List zip codes',
+  'List invoices',
+  'List packages',
+  'List services',
+
+  'Financial reports',
+
+  'Job queue', # these are not currently agent-virtualized
+  'Import',    #
+  'Export',    #
+
+  'Configuration', #none of the configuraiton is agent-virtualized either
 
 );
 

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -d -r1.216 -r1.217
--- cust_main.pm	19 Jun 2006 02:33:52 -0000	1.216
+++ cust_main.pm	19 Jun 2006 11:25:13 -0000	1.217
@@ -944,10 +944,13 @@
     $old = qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
   }
 
-  if ( $self->payby eq 'COMP' && $self->payby ne $old->payby
-       && $conf->config('users-allow_comp')                  ) {
-    return "You are not permitted to create complimentary accounts."
-      unless grep { $_ eq getotaker } $conf->config('users-allow_comp');
+  my $curuser = $FS::CurrentUser::CurrentUser;
+  if (    $self->payby eq 'COMP'
+       && $self->payby ne $old->payby
+       && ! $curuser->access_right('Complimentary customer')
+     )
+  {
+    return "You are not permitted to create complimentary accounts.";
   }
 
   local($ignore_expired_card) = 1
@@ -1302,9 +1305,12 @@
 
   } elsif ( $self->payby eq 'COMP' ) {
 
-    if ( !$self->custnum && $conf->config('users-allow_comp') ) {
+    my $curuser = $FS::CurrentUser::CurrentUser;
+    if (    ! $self->custnum
+         && ! $curuser->access_right('Complimentary customer')
+       )
+    {
       return "You are not permitted to create complimentary accounts."
-        unless grep { $_ eq getotaker } $conf->config('users-allow_comp');
     }
 
     $error = $self->ut_textn('payinfo');



More information about the freeside-commits mailing list