[freeside-commits] freeside/FS/FS part_pkg.pm, 1.47,
1.48 access_group.pm, 1.1, 1.2 access_groupagent.pm, 1.1,
1.2 m2name_Common.pm, NONE, 1.1 AccessRight.pm, 1.1, 1.2
Ivan,,,
ivan at wavetail.420.am
Sun Jun 18 05:54:51 PDT 2006
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv30582/FS/FS
Modified Files:
part_pkg.pm access_group.pm access_groupagent.pm
AccessRight.pm
Added Files:
m2name_Common.pm
Log Message:
ACLs: finish group edit (agents + rights) & browse
Index: part_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg.pm,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- part_pkg.pm 22 Apr 2006 00:58:40 -0000 1.47
+++ part_pkg.pm 18 Jun 2006 12:54:48 -0000 1.48
@@ -1,7 +1,7 @@
package FS::part_pkg;
use strict;
-use vars qw( @ISA %freq %plans $DEBUG );
+use vars qw( @ISA %plans $DEBUG );
use Carp qw(carp cluck confess);
use Tie::IxHash;
use FS::Conf;
@@ -571,6 +571,32 @@
}
}
+
+sub freqs_href {
+ #method, class method or sub? #my $self = shift;
+
+ tie my %freq, 'Tie::IxHash',
+ '0' => '(no recurring fee)',
+ '1h' => 'hourly',
+ '1d' => 'daily',
+ '1w' => 'weekly',
+ '2w' => 'biweekly (every 2 weeks)',
+ '1' => 'monthly',
+ '2' => 'bimonthly (every 2 months)',
+ '3' => 'quarterly (every 3 months)',
+ '6' => 'semiannually (every 6 months)',
+ '12' => 'annually',
+ '24' => 'biannually (every 2 years)',
+ '36' => 'triannually (every 3 years)',
+ '48' => '(every 4 years)',
+ '60' => '(every 5 years)',
+ '120' => '(every 10 years)',
+ ;
+
+ \%freq;
+
+}
+
=item freq_pretty
Returns an english representation of the I<freq> field, such as "monthly",
@@ -578,29 +604,14 @@
=cut
-tie %freq, 'Tie::IxHash',
- '0' => '(no recurring fee)',
- '1h' => 'hourly',
- '1d' => 'daily',
- '1w' => 'weekly',
- '2w' => 'biweekly (every 2 weeks)',
- '1' => 'monthly',
- '2' => 'bimonthly (every 2 months)',
- '3' => 'quarterly (every 3 months)',
- '6' => 'semiannually (every 6 months)',
- '12' => 'annually',
- '24' => 'biannually (every 2 years)',
- '36' => 'triannually (every 3 years)',
- '48' => '(every 4 years)',
- '60' => '(every 5 years)',
- '120' => '(every 10 years)',
-;
-
sub freq_pretty {
my $self = shift;
my $freq = $self->freq;
- if ( exists($freq{$freq}) ) {
- $freq{$freq};
+
+ my $freqs_href = $self->freqs_href;
+
+ if ( exists($freqs_href->{$freq}) ) {
+ $freqs_href->{$freq};
} else {
my $interval = 'month';
if ( $freq =~ /^(\d+)([hdw])$/ ) {
Index: access_group.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/access_group.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- access_group.pm 14 May 2006 16:47:31 -0000 1.1
+++ access_group.pm 18 Jun 2006 12:54:48 -0000 1.2
@@ -3,8 +3,11 @@
use strict;
use vars qw( @ISA );
use FS::Record qw( qsearch qsearchs );
+use FS::m2name_Common;
+use FS::access_groupagent;
+use FS::access_right;
- at ISA = qw(FS::Record);
+ at ISA = qw(FS::m2m_Common FS::m2name_Common FS::Record);
=head1 NAME
@@ -27,15 +30,14 @@
=head1 DESCRIPTION
-An FS::access_group object represents an example. FS::access_group inherits from
+An FS::access_group object represents an access group. FS::access_group inherits from
FS::Record. The following fields are currently supported:
=over 4
=item groupnum - primary key
-=item groupname -
-
+=item groupname - Access group name
=back
@@ -45,7 +47,7 @@
=item new HASHREF
-Creates a new example. To add the example to the database, see L<"insert">.
+Creates a new access group. To add the access group to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
@@ -84,7 +86,7 @@
=item check
-Checks all fields to make sure this is a valid example. If there is
+Checks all fields to make sure this is a valid access group. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
@@ -105,12 +107,51 @@
$self->SUPER::check;
}
+=item access_groupagent
+
+Returns all associated FS::access_groupagent records.
+
+=cut
+
+sub access_groupagent {
+ my $self = shift;
+ qsearch('access_groupagent', { 'groupnum' => $self->groupnum } );
+}
+
+=item access_rights
+
+Returns all associated FS::access_right records.
+
+=cut
+
+sub access_rights {
+ my $self = shift;
+ qsearch('access_right', { 'righttype' => 'FS::access_group',
+ 'rightobjnum' => $self->groupnum
+ }
+ );
+}
+
+=item access_right RIGHTNAME
+
+Returns the specified FS::access_right record. Can be used as a boolean, to
+test if this group has the given RIGHTNAME.
+
+=cut
+
+sub access_right {
+ my( $self, $name ) = shift;
+ qsearchs('access_right', { 'righttype' => 'FS::access_group',
+ 'rightobjnum' => $self->groupnum,
+ 'rightname' => $name,
+ }
+ );
+}
+
=back
=head1 BUGS
-The author forgot to customize this manpage.
-
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
--- NEW FILE: m2name_Common.pm ---
package FS::m2name_Common;
use strict;
use vars qw( @ISA $DEBUG );
use FS::Schema qw( dbdef );
use FS::Record qw( qsearch qsearchs ); #dbh );
@ISA = qw( FS::Record );
$DEBUG = 0;
=head1 NAME
FS::m2name_Common - Base class for tables with a related table listing names
=head1 SYNOPSIS
use FS::m2name_Common;
@ISA = qw( FS::m2name_Common );
=head1 DESCRIPTION
FS::m2name_Common is intended as a base class for classes which have a
related table that lists names.
=head1 METHODS
=over 4
=item process_m2name
=cut
sub process_m2name {
my( $self, %opt ) = @_;
my $self_pkey = $self->dbdef_table->primary_key;
my $link_sourcekey = $opt{'num_col'} || $self_pkey;
my $link_table = $self->_load_table($opt{'link_table'});
my $link_static = $opt{'link_static'} || {};
foreach my $name ( @{ $opt{'names_list'} } ) {
my $obj = qsearchs( $link_table, {
$link_sourcekey => $self->$self_pkey(),
$opt{'name_col'} => $name,
%$link_static,
});
if ( $obj && ! $opt{'params'}->{"$link_table.$name"} ) {
my $d_obj = $obj; #need to save $obj for below.
my $error = $d_obj->delete;
die "error deleting $d_obj for $link_table.$name: $error" if $error;
} elsif ( $opt{'params'}->{"$link_table.$name"} && ! $obj ) {
#ok to clobber it now (but bad form nonetheless?)
#$obj = new "FS::$link_table" ( {
$obj = "FS::$link_table"->new( {
$link_sourcekey => $self->$self_pkey(),
$opt{'name_col'} => $name,
%$link_static,
});
my $error = $obj->insert;
die "error inserting $obj for $link_table.$name: $error" if $error;
}
}
'';
}
sub _load_table {
my( $self, $table ) = @_;
eval "use FS::$table";
die $@ if $@;
$table;
}
=back
=head1 BUGS
=head1 SEE ALSO
L<FS::Record>
=cut
1;
Index: access_groupagent.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/access_groupagent.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- access_groupagent.pm 14 May 2006 16:47:31 -0000 1.1
+++ access_groupagent.pm 18 Jun 2006 12:54:48 -0000 1.2
@@ -3,6 +3,7 @@
use strict;
use vars qw( @ISA );
use FS::Record qw( qsearch qsearchs );
+use FS::agent;
@ISA = qw(FS::Record);
@@ -27,7 +28,7 @@
=head1 DESCRIPTION
-An FS::access_groupagent object represents an example. FS::access_groupagent inherits from
+An FS::access_groupagent object represents an group reseller virtualization. FS::access_groupagent inherits from
FS::Record. The following fields are currently supported:
=over 4
@@ -47,7 +48,7 @@
=item new HASHREF
-Creates a new example. To add the example to the database, see L<"insert">.
+Creates a new group reseller virtualization. To add the record to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
@@ -86,7 +87,7 @@
=item check
-Checks all fields to make sure this is a valid example. If there is
+Checks all fields to make sure this is a valid group reseller virtualization. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
@@ -100,20 +101,29 @@
my $error =
$self->ut_numbern('groupagentnum')
- || $self->ut_number('groupnum')
- || $self->ut_number('agentnum')
+ || $self->ut_foreign_key('groupnum', 'access_group', 'groupnum')
+ || $self->ut_foreign_key('agentnum', 'agent', 'agentnum')
;
return $error if $error;
$self->SUPER::check;
}
+=item agent
+
+Returns the associated FS::agent object.
+
+=cut
+
+sub agent {
+ my $self = shift;
+ qsearchs('agent', { 'agentnum' => $self->agentnum } );
+}
+
=back
=head1 BUGS
-The author forgot to customize this manpage.
-
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- AccessRight.pm 14 May 2006 16:47:31 -0000 1.1
+++ AccessRight.pm 18 Jun 2006 12:54:48 -0000 1.2
@@ -1,7 +1,7 @@
package FS::AccessRight;
use strict;
-user vars qw(@rights %rights);
+use vars qw(@rights); # %rights);
use Tie::IxHash;
=head1 NAME
@@ -19,59 +19,94 @@
=cut
- at rights = (
- 'Reports' => [
- '_desc' => 'Access to high-level reporting',
- ],
- 'Configuration' => [
- '_desc' => 'Access to configuration',
-
- 'Settings' => {},
-
- 'agent' => [
- '_desc' => 'Master access to reseller configuration',
- 'agent_type' => {},
- 'agent' => {},
- ],
-
- 'export_svc_pkg' => [
- '_desc' => 'Access to export, service and package configuration',
- 'part_export' => {},
- 'part_svc' => {},
- 'part_pkg' => {},
- 'pkg_class' => {},
- ],
-
- 'billing' => [
- '_desc' => 'Access to billing configuration',
- 'payment_gateway' => {},
- 'part_bill_event' => {},
- 'prepay_credit' => {},
- 'rate' => {},
- 'cust_main_county' => {},
- ],
+#@rights = (
+# 'Reports' => [
+# '_desc' => 'Access to high-level reporting',
+# ],
+# 'Configuration' => [
+# '_desc' => 'Access to configuration',
+#
+# 'Settings' => {},
+#
+# 'agent' => [
+# '_desc' => 'Master access to reseller configuration',
+# 'agent_type' => {},
+# 'agent' => {},
+# ],
+#
+# 'export_svc_pkg' => [
+# '_desc' => 'Access to export, service and package configuration',
+# 'part_export' => {},
+# 'part_svc' => {},
+# 'part_pkg' => {},
+# 'pkg_class' => {},
+# ],
+#
+# 'billing' => [
+# '_desc' => 'Access to billing configuration',
+# 'payment_gateway' => {},
+# 'part_bill_event' => {},
+# 'prepay_credit' => {},
+# 'rate' => {},
+# 'cust_main_county' => {},
+# ],
+#
+# 'dialup' => [
+# '_desc' => 'Access to dialup configuraiton',
+# 'svc_acct_pop' => {},
+# ],
+#
+# 'broadband' => [
+# '_desc' => 'Access to broadband configuration',
+# 'router' => {},
+# 'addr_block' => {},
+# ],
+#
+# 'misc' => [
+# 'part_referral' => {},
+# 'part_virtual_field' => {},
+# 'msgcat' => {},
+# 'inventory_class' => {},
+# ],
+#
+# },
+#
+#);
+#
+##turn it into a more hash-like structure, but ordered via IxHash
- 'dialup' => [
- '_desc' => 'Access to dialup configuraiton',
- 'svc_acct_pop' => {},
- ],
+#well, this is what we have for now. could be ordered better, could be lots of
+# things better, but this ACL system does 99% of what folks need and the UI
+# isn't *that* bad
+ at rights = (
+ 'New customer',
+ 'View customer',
+ #'View Customer | View tickets',
+ 'Edit customer',
+ 'Cancel customer',
+ 'Delete customer',
- 'broadband' => [
- '_desc' => 'Access to broadband configuration',
- 'router' => {},
- 'addr_block' => {},
- ],
+ 'Order customer package',
+ 'Change customer package',
+ 'Edit customer package dates',
+ 'Customize customer package',
+ 'Suspend customer package',
+ 'Unsuspend customer package',
+ 'Cancel customer package immediately',
+ 'Cancel customer package later',
- 'misc' => [
- 'part_referral' => {},
- 'part_virtual_field' => {},
- 'msgcat' => {},
- 'inventory_class' => {},
- ],
+ 'Provision service',
+ 'Unprovision service',
+ #legacy link stuff
- },
+ 'Post payment',
+ 'Process payment',
+ 'Post credit',
+ #more financial stuff
);
-#turn it into a more hash-like structure, but ordered via IxHash
+sub rights {
+ @rights;
+}
More information about the freeside-commits
mailing list