[freeside-commits] freeside/FS/FS Schema.pm, 1.21,
1.22 part_referral.pm, 1.4, 1.5 Record.pm, 1.118,
1.119 AccessRight.pm, 1.4, 1.5 access_user.pm, 1.6, 1.7
Ivan,,,
ivan at wavetail.420.am
Thu Aug 10 04:55:52 PDT 2006
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv20579/FS/FS
Modified Files:
Schema.pm part_referral.pm Record.pm AccessRight.pm
access_user.pm
Log Message:
agent-virtualize advertising sources
Index: access_user.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/access_user.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- access_user.pm 7 Aug 2006 02:44:28 -0000 1.6
+++ access_user.pm 10 Aug 2006 11:55:50 -0000 1.7
@@ -106,6 +106,10 @@
sub htpasswd_kludge {
my $self = shift;
+
+ #awful kludge to skip setting htpasswd for fs_* users
+ return '' if $self->username =~ /^fs_/;
+
unshift @_, '-c' unless -e $htpasswd_file;
if (
system('htpasswd', '-b', @_,
@@ -297,6 +301,24 @@
' )';
}
+=item agentnum
+
+Returns true if the user can view the specified agent.
+
+=cut
+
+sub agentnum {
+ my( $self, $agentnum ) = @_;
+ my $sth = dbh->prepare(
+ "SELECT COUNT(*) FROM access_usergroup
+ JOIN access_groupagent USING ( groupnum )
+ WHERE usernum = ? AND agentnum = ?"
+ ) or die dbh->errstr;
+ $sth->execute($self->usernum, $agentnum) or die $sth->errstr;
+ $sth->fetchrow_arrayref->[0];
+}
+
+
=item access_right
Given a right name, returns true if this user has this right (currently via
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- Schema.pm 10 Aug 2006 03:10:00 -0000 1.21
+++ Schema.pm 10 Aug 2006 11:55:50 -0000 1.22
@@ -692,9 +692,10 @@
'part_referral' => {
'columns' => [
- 'refnum', 'serial', '', '', '', '',
- 'referral', 'varchar', '', $char_d, '', '',
- 'disabled', 'char', 'NULL', 1, '', '',
+ 'refnum', 'serial', '', '', '', '',
+ 'referral', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'refnum',
'unique' => [],
Index: part_referral.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_referral.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- part_referral.pm 10 Dec 2003 22:50:44 -0000 1.4
+++ part_referral.pm 10 Aug 2006 11:55:50 -0000 1.5
@@ -2,7 +2,8 @@
use strict;
use vars qw( @ISA );
-use FS::Record;
+use FS::Record qw(qsearchs);
+use FS::agent;
@ISA = qw( FS::Record );
@@ -40,6 +41,8 @@
=item disabled - Disabled flag, empty or 'Y'
+=item agentnum - Optional agentnum (see L<FS::agent>)
+
=back
=head1 NOTE
@@ -95,17 +98,26 @@
my $error = $self->ut_numbern('refnum')
|| $self->ut_text('referral')
+ || $self->ut_enum('disabled', [ '', 'Y' ] )
+ #|| $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum')
+ || $self->ut_agentnum_acl('agentnum', 'Edit global advertising sources')
;
return $error if $error;
- if ( $self->dbdef_table->column('disabled') ) {
- $error = $self->ut_enum('disabled', [ '', 'Y' ] );
- return $error if $error;
- }
-
$self->SUPER::check;
}
+=item agent
+
+Returns the associated agent for this referral, if any, as an FS::agent object.
+
+=cut
+
+sub agent {
+ my $self = shift;
+ qsearchs('agent', { 'agentnum' => $self->agentnum } );
+}
+
=back
=head1 BUGS
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- AccessRight.pm 12 Jul 2006 00:20:21 -0000 1.4
+++ AccessRight.pm 10 Aug 2006 11:55:50 -0000 1.5
@@ -136,8 +136,11 @@
'Import', #
'Export', #
- 'Configuration', #none of the configuraiton is agent-virtualized either
+ 'Edit advertising sources',
+ 'Edit global advertising sources',
+ 'Configuration', #most of the rest of the configuraiton is not
+ # agent-virtualized
);
sub rights {
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- Record.pm 12 Jul 2006 00:20:21 -0000 1.118
+++ Record.pm 10 Aug 2006 11:55:50 -0000 1.119
@@ -10,6 +10,7 @@
use DBI qw(:sql_types);
use DBIx::DBSchema 0.25;
use FS::UID qw(dbh getotaker datasrc driver_name);
+use FS::CurrentUser;
use FS::Schema qw(dbdef);
use FS::SearchCache;
use FS::Msgcat qw(gettext);
@@ -1620,6 +1621,36 @@
: '';
}
+=item ut_agentnum_acl
+
+Checks this column as an agentnum, taking into account the current users's
+ACLs.
+
+=cut
+
+sub ut_agentnum_acl {
+ my( $self, $field, $null_acl ) = @_;
+
+ my $error = $self->ut_foreign_keyn($field, 'agent', 'agentnum');
+ return "Illegal agentnum: $error" if $error;
+
+ my $curuser = $FS::CurrentUser::CurrentUser;
+
+ if ( $self->$field() ) {
+
+ return "Access deined"
+ unless $curuser->agentnum($self->$field());
+
+ } else {
+
+ return "Access denied"
+ unless $curuser->access_right($null_acl);
+
+ }
+
+ '';
+
+}
=item virtual_fields [ TABLE ]
More information about the freeside-commits
mailing list