summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Record.pm11
-rw-r--r--FS/FS/part_pkg.pm8
2 files changed, 14 insertions, 5 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index b53c333ce..b856aea10 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -2326,15 +2326,18 @@ sub ut_foreign_keyn {
: '';
}
-=item ut_agentnum_acl
+=item ut_agentnum_acl COLUMN [ NULL_RIGHT | NULL_RIGHT_LISTREF ]
Checks this column as an agentnum, taking into account the current users's
-ACLs.
+ACLs. NULL_RIGHT or NULL_RIGHT_LISTREF, if specified, indicates the access
+right or rights allowing no agentnum.
=cut
sub ut_agentnum_acl {
- my( $self, $field, $null_acl ) = @_;
+ my( $self, $field ) = (shift, shift);
+ my $null_acl = scalar(@_) ? shift : [];
+ $null_acl = [ $null_acl ] unless ref($null_acl);
my $error = $self->ut_foreign_keyn($field, 'agent', 'agentnum');
return "Illegal agentnum: $error" if $error;
@@ -2349,7 +2352,7 @@ sub ut_agentnum_acl {
} else {
return "Access denied"
- unless $curuser->access_right($null_acl);
+ unless grep $curuser->access_right($_), @$null_acl;
}
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 38fc03e42..563a5cfc5 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -432,6 +432,12 @@ sub check {
$self->freq($1);
}
+ my @null_agentnum_right = ( 'Edit global package definitions' );
+ push @null_agentnum_right, 'One-time charge'
+ if $self->freq =~ /^0/;
+ push @null_agentnum_right, 'Customize customer package'
+ if $self->disabled eq 'Y'; #good enough
+
my $error = $self->ut_numbern('pkgpart')
|| $self->ut_text('pkg')
|| $self->ut_text('comment')
@@ -448,7 +454,7 @@ sub check {
'part_pkg_taxproduct',
'taxproductnum'
)
- || $self->ut_agentnum_acl('agentnum', 'Edit global package definitions')
+ || $self->ut_agentnum_acl('agentnum', \@null_agentnum_right)
|| $self->SUPER::check
;
return $error if $error;