[freeside-commits] freeside/httemplate/edit/process/addr_block add.cgi, 1.3, 1.4 allocate.cgi, 1.3, 1.4 deallocate.cgi, 1.3, 1.4 split.cgi, 1.3, 1.4
Jeff Finucane,420,,
jeff at wavetail.420.am
Sat Jun 28 12:25:26 PDT 2008
Update of /home/cvs/cvsroot/freeside/httemplate/edit/process/addr_block
In directory wavetail.420.am:/tmp/cvs-serv20117/httemplate/edit/process/addr_block
Modified Files:
add.cgi allocate.cgi deallocate.cgi split.cgi
Log Message:
agent virtualize address blocks and routers
Index: allocate.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/addr_block/allocate.cgi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- allocate.cgi 18 Apr 2008 03:29:59 -0000 1.3
+++ allocate.cgi 28 Jun 2008 19:25:24 -0000 1.4
@@ -8,7 +8,9 @@
<%init>
my $conf = new FS::Conf;
+my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ unless $curuser->access_right('Engineering configuration')
+ || $curuser->access_right('Engineering global configuration');
</%init>
Index: deallocate.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/addr_block/deallocate.cgi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- deallocate.cgi 18 Apr 2008 03:29:59 -0000 1.3
+++ deallocate.cgi 28 Jun 2008 19:25:24 -0000 1.4
@@ -1,32 +1,20 @@
-%
-%my $error = '';
-%my $blocknum = $cgi->param('blocknum');
-%
-%my $addr_block = qsearchs('addr_block', { blocknum => $blocknum });
-%
-%if($addr_block) {
-% my $router = $addr_block->router;
-% if ($router) {
-% $error = $addr_block->deallocate($router);
-% } else {
-% $error = "Block is not allocated to a router";
-% }
-%} else {
-% $error = "Cannot find block with blocknum $blocknum";
-%}
-%
-%if ( $error ) {
-% $cgi->param('error', $error);
-% print $cgi->redirect(popurl(4). "browse/addr_block.cgi?" . $cgi->query_string);
-%} else {
-% print $cgi->redirect(popurl(4). "browse/addr_block.cgi");
-%}
-%
-
+<% include( '../elements/process.html',
+ 'table' => 'addr_block',
+ 'copy_on_empty' => [ grep { $_ ne 'routernum' }
+ fields 'addr_block' ],
+ 'redirect' => popurl(4). 'browse/addr_block.cgi?',
+ 'error_redirect' => popurl(4). 'browse/addr_block.cgi?',
+ 'agent_virt' => 1,
+ 'agent_null_right' => 'Engineering global configuration',
+ )
+%>
<%init>
my $conf = new FS::Conf;
+my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ unless $curuser->access_right('Engineering configuration')
+ || $curuser->access_right('Engineering global configuration');
+$cgi->param('routernum', 0); # just to be explicit about what we are doing
</%init>
Index: split.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/addr_block/split.cgi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- split.cgi 18 Apr 2008 03:29:59 -0000 1.3
+++ split.cgi 28 Jun 2008 19:25:24 -0000 1.4
@@ -1,27 +1,27 @@
-%
-%my $error = '';
-%my $blocknum = $cgi->param('blocknum');
-%my $addr_block = qsearchs('addr_block', { blocknum => $blocknum });
-%
-%if ( $addr_block) {
-% $error = $addr_block->split_block;
-%} else {
-% $error = "Unknown blocknum: $blocknum";
-%}
-%
-%
-%if ( $error ) {
-% $cgi->param('error', $error);
-% print $cgi->redirect(popurl(4). "browse/addr_block.cgi?". $cgi->query_string );
-%} else {
-% print $cgi->redirect(popurl(4). "browse/addr_block.cgi");
-%}
-%
-
+<% $cgi->redirect(popurl(4). "browse/addr_block.cgi?". $cgi->query_string ) %>
<%init>
-my $conf = new FS::Conf;
+my $curuser = $FS::CurrentUser::CurrentUser;
+
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ unless $curuser->access_right('Engineering configuration')
+ || $curuser->access_right('Engineering global configuration');
+
+my $error = '';
+$cgi->param('blocknum') =~ /^(\d+)$/ or die "invalid blocknum";
+my $blocknum = $1;
+
+my $addr_block = qsearchs({ 'table' => 'addr_block',
+ 'hashref' => { blocknum => $blocknum },
+ 'extra_sql' => ' AND '. $curuser->agentnums_sql(
+ 'null_right' => 'Engineering global configuration'
+ ),
+ })
+ or $error = "Unknown blocknum: $blocknum";
+
+$error ||= $addr_block->split_block;
+
+$cgi->param('error', $error)
+ if $error;
</%init>
Index: add.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/addr_block/add.cgi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- add.cgi 18 Apr 2008 03:29:59 -0000 1.3
+++ add.cgi 28 Jun 2008 19:25:24 -0000 1.4
@@ -1,28 +1,20 @@
-%
-%
-%my $error = '';
-%my $ip_gateway = $cgi->param('ip_gateway');
-%my $ip_netmask = $cgi->param('ip_netmask');
-%
-%my $new = new FS::addr_block {
-% ip_gateway => $ip_gateway,
-% ip_netmask => $ip_netmask,
-% routernum => 0 };
-%
-%$error = $new->insert;
-%
-%if ( $error ) {
-% $cgi->param('error', $error);
-% print $cgi->redirect(popurl(4). "browse/addr_block.cgi?". $cgi->query_string );
-%} else {
-% print $cgi->redirect(popurl(4). "browse/addr_block.cgi");
-%}
-%
+<% include( '../elements/process.html',
+ 'table' => 'addr_block',
+ 'redirect' => popurl(4). 'browse/addr_block.cgi?dummy=',
+ 'error_redirect' => popurl(4). 'browse/addr_block.cgi?',
+ 'agent_virt' => 1,
+ 'agent_null_right' => 'Engineering global configuration',
+ )
+%>
<%init>
-my $conf = new FS::Conf;
+my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+ unless $curuser->access_right('Engineering configuration')
+ || $curuser->access_right('Engineering global configuration');
+
+$cgi->param('routernum', 0) # in FS::addr_block::check instead?
+ unless $cgi->param('routernum');
</%init>
More information about the freeside-commits
mailing list