summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2010-06-17 02:08:53 +0000
committerivan <ivan>2010-06-17 02:08:53 +0000
commit8966833a87b9a002c9d72c56832e35b55628dc81 (patch)
tree5ebe5128d453eb940580b1876b2218d1db8d87be
parent259921ee5e89a68fc79b2a358643c558ebb4fdaa (diff)
Add "View customers of all agents" access rights, RT#7010
-rw-r--r--FS/FS/AccessRight.pm6
-rw-r--r--FS/FS/access_user.pm30
-rw-r--r--httemplate/browse/part_event.html3
-rwxr-xr-xhttemplate/browse/part_pkg.cgi4
-rw-r--r--httemplate/edit/process/elements/process.html1
-rw-r--r--httemplate/edit/prospect_main.html2
-rw-r--r--httemplate/view/cust_main/misc.html3
-rw-r--r--httemplate/view/prospect_main.html3
-rw-r--r--httemplate/view/svc_acct/tr.html9
9 files changed, 34 insertions, 27 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 08d31d263..1e1b9ead3 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -115,6 +115,7 @@ tie my %rights, 'Tie::IxHash',
{ rightname=>'Delete customer', desc=>"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 customer's packages if they cancel service." }, #aka. deletecustomers
'Bill customer now', #NEW
'Bulk send customer notices', #NEW
+ { rightname=>'View customers of all agents', global=>1 },
],
###
@@ -249,6 +250,8 @@ tie my %rights, 'Tie::IxHash',
'Billing event reports',
'Receivables report',
'Financial reports',
+
+ #{ rightname => 'List customers of all agents', global=>1 },
],
###
@@ -294,6 +297,9 @@ tie my %rights, 'Tie::IxHash',
{ rightname=>'Broadband configuration' },
{ rightname=>'Broadband global configuration', global=>1 },
+ #{ rightname=>'Edit employees', global=>1, },
+ #{ rightname=>'Edit employee groupss', global=>1, },
+
{ rightname=>'Configuration', global=>1 }, #most of the rest of the configuraiton is not agent-virtualized
{ rightname=>'Configuration download', }, #description of how it affects
diff --git a/FS/FS/access_user.pm b/FS/FS/access_user.pm
index 1bf6e9387..25aa8af01 100644
--- a/FS/FS/access_user.pm
+++ b/FS/FS/access_user.pm
@@ -1,20 +1,16 @@
package FS::access_user;
use strict;
-use vars qw( @ISA $DEBUG $me $conf $htpasswd_file );
+use base qw( FS::m2m_Common FS::option_Common );
+use vars qw( $DEBUG $me $conf $htpasswd_file );
use FS::UID;
use FS::Conf;
use FS::Record qw( qsearch qsearchs dbh );
-use FS::m2m_Common;
-use FS::option_Common;
use FS::access_user_pref;
use FS::access_usergroup;
use FS::agent;
use FS::cust_main;
-@ISA = qw( FS::m2m_Common FS::option_Common FS::Record );
-#@ISA = qw( FS::m2m_Common FS::option_Common );
-
$DEBUG = 0;
$me = '[FS::access_user]';
@@ -367,6 +363,11 @@ user has the provided access right
Optional table name in which agentnum is being checked. Sometimes required to
resolve 'column reference "agentnum" is ambiguous' errors.
+=item viewall_right
+
+All agents will be viewable if the current user has the provided access right.
+Defaults to 'View customers of all agents'.
+
=back
=cut
@@ -377,16 +378,21 @@ sub agentnums_sql {
my $agentnum = $opt{'table'} ? $opt{'table'}.'.agentnum' : 'agentnum';
-# my @agentnums = map { "$agentnum = $_" } $self->agentnums;
- my @agentnums = ();
- push @agentnums, "$agentnum IN (". join(',', $self->agentnums). ')';
+ my @or = ();
+
+ my $viewall_right = $opt{'viewall_right'} || 'View customers of all agents';
+ if ( $self->access_right($viewall_right) ) {
+ push @or, "$agentnum IS NOT NULL";
+ } else {
+ push @or, "$agentnum IN (". join(',', $self->agentnums). ')';
+ }
- push @agentnums, "$agentnum IS NULL"
+ push @or, "$agentnum IS NULL"
if $opt{'null'}
|| ( $opt{'null_right'} && $self->access_right($opt{'null_right'}) );
- return ' 1 = 0 ' unless scalar(@agentnums);
- '( '. join( ' OR ', @agentnums ). ' )';
+ return ' 1 = 0 ' unless scalar(@or);
+ '( '. join( ' OR ', @or ). ' )';
}
diff --git a/httemplate/browse/part_event.html b/httemplate/browse/part_event.html
index 674004bc7..3d7c245ac 100644
--- a/httemplate/browse/part_event.html
+++ b/httemplate/browse/part_event.html
@@ -158,7 +158,8 @@ $html_init .= '</SELECT><INPUT TYPE="submit" VALUE="Clone existing event">'.
my $count_query = 'SELECT COUNT(*) FROM part_event WHERE '.
$FS::CurrentUser::CurrentUser->agentnums_sql(
- 'null_right' => 'Edit global billing events',
+ 'null_right' => 'Edit global billing events',
+ 'viewall_right' => 'None',
);
my $join_conditions = FS::part_event_condition->join_conditions_sql;
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index e226ce13e..42eb5dfcb 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -84,11 +84,11 @@ my $extra_sql = scalar(@where)
join( 'AND ', @where)
: '';
-my $agentnums = join(',', $curuser->agentnums);
+my $agentnums_sql = $curuser->agentnums_sql( 'table'=>'cust_main' );
my $count_cust_pkg = "
SELECT COUNT(*) FROM cust_pkg LEFT JOIN cust_main USING ( custnum )
WHERE cust_pkg.pkgpart = part_pkg.pkgpart
- AND cust_main.agentnum IN ($agentnums)
+ AND $agentnums_sql
";
$select = "
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index ebbc2f778..53419cde0 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -207,6 +207,7 @@ if ( $opt{'agent_virt'} ) {
die "illegal agentnum"
unless $curuser->agentnums_href->{$new->agentnum}
+ or $curuser->access_right('View customers of all agents')
or $opt{'agent_null_right'}
&& ! $new->agentnum
&& $curuser->access_right($opt{'agent_null_right'});
diff --git a/httemplate/edit/prospect_main.html b/httemplate/edit/prospect_main.html
index 90f971a91..e867907ed 100644
--- a/httemplate/edit/prospect_main.html
+++ b/httemplate/edit/prospect_main.html
@@ -109,6 +109,6 @@ my $m2_error_callback = sub {
$cgi->param;
};
-my @agentnums = $FS::CurrentUser::CurrentUser->agentnums;
+#my @agentnums = $FS::CurrentUser::CurrentUser->agentnums;
</%init>
diff --git a/httemplate/view/cust_main/misc.html b/httemplate/view/cust_main/misc.html
index b98e9dc3e..8bcab0df5 100644
--- a/httemplate/view/cust_main/misc.html
+++ b/httemplate/view/cust_main/misc.html
@@ -10,7 +10,8 @@
<TD BGCOLOR="#ffffff"><FONT COLOR="#<% $cust_main->statuscolor %>"><B><% ucfirst($cust_main->status) %></B></FONT></TD>
</TR>
-%unless ( scalar(@agentnums) == 1 ) {
+%unless ( scalar(@agentnums) == 1
+% && !$curuser->access_right('View customers of all agents') ) {
% my $agent = qsearchs('agent',{ 'agentnum' => $cust_main->agentnum } );
<TR>
<TD ALIGN="right">Agent</TD>
diff --git a/httemplate/view/prospect_main.html b/httemplate/view/prospect_main.html
index 9883e6766..9517e3920 100644
--- a/httemplate/view/prospect_main.html
+++ b/httemplate/view/prospect_main.html
@@ -14,7 +14,8 @@
<TD BGCOLOR="#FFFFFF"><B><% $prospectnum %></B></TD>
</TR>
-%unless ( scalar(@agentnums) == 1 ) {
+%unless ( scalar(@agentnums) == 1
+% && !$curuser->access_right('View customers of all agents') ) {
% my $agent = qsearchs('agent',{ 'agentnum' => $prospect_main->agentnum } );
<TR>
<TD ALIGN="right">Agent</TD>
diff --git a/httemplate/view/svc_acct/tr.html b/httemplate/view/svc_acct/tr.html
deleted file mode 100644
index e2ec7d42f..000000000
--- a/httemplate/view/svc_acct/tr.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<TR>
- <TD ALIGN="right"><% $opt{'label'} %></TD>
- <TD BGCOLOR="#ffffff"><% $opt{'value'} %></TD>
-</TR>
-<%init>
-
-my %opt = @_;
-
-</%init>