summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/domreg.cgi
diff options
context:
space:
mode:
authorcvs2git <cvs2git>2009-10-11 02:42:17 +0000
committercvs2git <cvs2git>2009-10-11 02:42:17 +0000
commita83a000a027d1272e813259d09230d701d84df64 (patch)
tree71500c957e6d7db3e1ad3d59e74ca7bbb14e44ff /httemplate/edit/process/domreg.cgi
parent097a12385d80ef52f37d4cc2bb93bc3f81e6f8e6 (diff)
parent0b69c091543b56a45f2ae6b8718fc67f381a6686 (diff)
This commit was manufactured by cvs2svn to create branchfreeside_1_9_1
'FREESIDE_1_9_BRANCH'.
Diffstat (limited to 'httemplate/edit/process/domreg.cgi')
-rwxr-xr-xhttemplate/edit/process/domreg.cgi62
1 files changed, 62 insertions, 0 deletions
diff --git a/httemplate/edit/process/domreg.cgi b/httemplate/edit/process/domreg.cgi
new file mode 100755
index 000000000..a95474e44
--- /dev/null
+++ b/httemplate/edit/process/domreg.cgi
@@ -0,0 +1,62 @@
+%if ($error) {
+% $cgi->param('error', $error);
+% errorpage($error);
+%} else {
+<% $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum") %>
+%}
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+$cgi->param('op') =~ /^(register|transfer|revoke|renew)$/ or die "Illegal operation";
+my $operation = $1;
+#my($query) = $cgi->keywords;
+#$query =~ /^(\d+)$/;
+$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
+my $svcnum = $1;
+my $svc_domain = qsearchs({
+ 'select' => 'svc_domain.*',
+ 'table' => 'svc_domain',
+ 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
+ ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
+ ' LEFT JOIN cust_main USING ( custnum ) ',
+ 'hashref' => {'svcnum'=>$svcnum},
+ 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
+});
+die "Unknown svcnum" unless $svc_domain;
+
+my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum});
+my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
+die "Unknown svcpart" unless $part_svc;
+
+my $error = '';
+
+my @exports = $part_svc->part_export();
+
+my $registrar;
+my $export;
+
+# Find the first export that does domain registration
+foreach (@exports) {
+ $export = $_ if $_->can('registrar');
+}
+
+my $period = 1; # Current OpenSRS export can only handle 1 year registrations
+
+# If we have a domain registration export, get the registrar object
+if ($export) {
+ if ($operation eq 'register') {
+ $error = $export->register( $svc_domain, $period );
+ } elsif ($operation eq 'transfer') {
+ $error = $export->transfer( $svc_domain );
+ } elsif ($operation eq 'revoke') {
+ $error = $export->revoke( $svc_domain );
+ } elsif ($operation eq 'renew') {
+ $cgi->param('period') =~ /^(\d+)$/ or die "Illegal renewal period!";
+ $period = $1;
+ $error = $export->renew( $svc_domain, $period );
+ }
+}
+
+</%init>