[freeside-commits] freeside/FS/FS access_user.pm, 1.20, 1.21 cust_pkg.pm, 1.111, 1.112
Ivan,,,
ivan at wavetail.420.am
Sat Feb 7 18:05:26 PST 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv1782/FS/FS
Modified Files:
access_user.pm cust_pkg.pm
Log Message:
further work on agents editing own packages: allow them to see (but not edit) global packages for their type, RT#1331
Index: access_user.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/access_user.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- access_user.pm 31 Jan 2009 09:53:13 -0000 1.20
+++ access_user.pm 8 Feb 2009 02:05:24 -0000 1.21
@@ -7,6 +7,7 @@
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;
@@ -353,7 +354,9 @@
my $agentnum = $opt{'table'} ? $opt{'table'}.'.agentnum' : 'agentnum';
- my @agentnums = map { "$agentnum = $_" } $self->agentnums;
+# my @agentnums = map { "$agentnum = $_" } $self->agentnums;
+ my @agentnums = ();
+ push @agentnums, "$agentnum IN (". join(',', $self->agentnums). ')';
push @agentnums, "$agentnum IS NULL"
if $opt{'null'}
@@ -361,6 +364,7 @@
return ' 1 = 0 ' unless scalar(@agentnums);
'( '. join( ' OR ', @agentnums ). ' )';
+
}
=item agentnum
@@ -396,26 +400,37 @@
});
}
-=item access_right
+=item access_right RIGHTNAME | LISTREF
-Given a right name, returns true if this user has this right (currently via
-group membership, eventually also via user overrides).
+Given a right name or a list reference of right names, returns true if this
+user has this right, or, for a list, one of the rights (currently via group
+membership, eventually also via user overrides).
=cut
sub access_right {
my( $self, $rightname ) = @_;
+ $rightname = [ $rightname ] unless ref($rightname);
+
#some caching of ACL requests for low-hanging fruit perf improvement
#since we get a new $CurrentUser object each page view there shouldn't be any
#issues with stickiness
if ( $self->{_ACLcache} ) {
- return $self->{_ACLcache}{$rightname}
- if exists($self->{_ACLcache}{$rightname});
+
+ return grep $self->{_ACLcache}{$_}, @$rightname
+ unless grep !exists($self->{_ACLcache}{$_}), @$rightname;
+
} else {
$self->{_ACLcache} = {};
}
+ my $has_right = ' ( '. join(' OR ',
+ map { 'rightname = '. dbh->quote($_) }
+ @$rightname
+ ).
+ ' ) ';
+
my $sth = dbh->prepare("
SELECT groupnum FROM access_usergroup
LEFT JOIN access_group USING ( groupnum )
@@ -423,10 +438,10 @@
ON ( access_group.groupnum = access_right.rightobjnum )
WHERE usernum = ?
AND righttype = 'FS::access_group'
- AND rightname = ?
+ AND $has_right
LIMIT 1
") or die dbh->errstr;
- $sth->execute($self->usernum, $rightname) or die $sth->errstr;
+ $sth->execute($self->usernum) or die $sth->errstr;
my $row = $sth->fetchrow_arrayref;
#$row ? $row->[0] : '';
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- cust_pkg.pm 29 Jan 2009 19:21:21 -0000 1.111
+++ cust_pkg.pm 8 Feb 2009 02:05:24 -0000 1.112
@@ -14,7 +14,6 @@
use FS::part_pkg;
use FS::cust_main;
use FS::cust_location;
-use FS::type_pkgs;
use FS::pkg_svc;
use FS::cust_bill_pkg;
use FS::cust_pkg_detail;
More information about the freeside-commits
mailing list