communigate: domain account defaults, RT#7083
authorivan <ivan>
Mon, 22 Feb 2010 09:18:10 +0000 (09:18 +0000)
committerivan <ivan>
Mon, 22 Feb 2010 09:18:10 +0000 (09:18 +0000)
FS/FS/svc_domain.pm
httemplate/edit/part_svc.cgi
httemplate/edit/process/svc_domain.cgi
httemplate/edit/svc_acct.cgi
httemplate/edit/svc_domain.cgi
httemplate/view/elements/tr.html [new file with mode: 0644]
httemplate/view/svc_acct/basics.html
httemplate/view/svc_domain.cgi
httemplate/view/svc_domain/acct_defaults.html [new file with mode: 0644]
httemplate/view/svc_domain/basics.html [new file with mode: 0644]
httemplate/view/svc_domain/dns.html [new file with mode: 0644]

index b928e26..d6eaf25 100644 (file)
@@ -144,9 +144,13 @@ sub table_info {
                            },
       'acct_def_password_selfchange' => { label => 'Acct. default Password modification',
                                  type  => 'checkbox',
+                            disable_inventory => 1,
+                            disable_select    => 1,
                                },
       'acct_def_password_recover'    => { label => 'Acct. default Password recovery',
                                  type  => 'checkbox',
+                            disable_inventory => 1,
+                            disable_select    => 1,
                                },
       'acct_def_cgp_deletemode' => { 
                             label => 'Acct. default Communigate message delete method',
index 6428960..80f61a1 100755 (executable)
@@ -266,6 +266,14 @@ that field.
 %                             'empty_label'  => 'Select inventory class',
 %                          );
 %
+%        } elsif ( $def->{type} eq 'checkbox' ) {
+%
+%          $html .= include('/elements/checkbox.html',
+%                             'field'      => $layer.'__'.$field,
+%                             'curr_value' => $value,
+%                             'value'      => 'Y',
+%                          );
+%
 %        } elsif ( $def->{type} eq 'select' ) {
 %
 %          $html .= qq!<SELECT NAME="${layer}__${field}" $disabled!;
index ea97918..381339b 100755 (executable)
@@ -27,6 +27,18 @@ unless ( $cgi->param('cgp_accessmodes') ) {
   );
 }
 
+#unmunge acct_def_cgp_accessmodes (falze laziness-ahoy)
+unless ( $cgi->param('acct_def_cgp_accessmodes') ) {
+  $cgi->param('acct_def_cgp_accessmodes', 
+    join(' ',
+      sort map { /^acct_def_cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; }
+               grep $cgi->param($_),
+                    grep /^acct_def_cgp_accessmodes_([\w\/]+)$/,
+                         $cgi->param()
+        )
+  );
+}
+
 my $new = new FS::svc_domain ( {
   map {
     $_, scalar($cgi->param($_));
index c842b1b..99e4b74 100755 (executable)
@@ -279,6 +279,7 @@ Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR>
 % }
 
 
+% #false laziness w/svc_domain
 % if ( $communigate
 %      && $part_svc->part_svc_column('cgp_accessmodes')->columnflag ne 'F' )
 % {
@@ -330,6 +331,7 @@ Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR>
 
 % if ( $communigate ) {
 
+%# false laziness w/svc_domain acct_def
   <TR>
     <TD ALIGN="right">Message delete method</TD>
     <TD>
index a3589c4..78faf12 100755 (executable)
@@ -96,8 +96,98 @@ Available top-level domains: <% $export->option('tlds') %>
 % }
 
 </TABLE>
+<BR>
+
+% if ( $communigate ) {
 
+Account defaults
+<% ntable("#cccccc",2) %>
+
+  <% include('/elements/tr-checkbox.html',
+               'label'      =>'Password modification',
+               'field'      => 'acct_def_password_selfchange',
+               'curr_value' => $svc_domain->acct_def_password_selfchange,
+               'value'      => 'Y',
+            )
+  %>
+  <% include('/elements/tr-checkbox.html',
+               'label'      =>'Password recovery',
+               'field'      => 'acct_def_password_recover',
+               'curr_value' => $svc_domain->acct_def_password_recover,
+               'value'      => 'Y',
+            )
+  %>
+
+  <TR>
+    <TD ALIGN="right">Enabled services
+    </TD>
+    <TD><% include('/elements/communigate_pro-accessmodes.html',
+                     'element_name_prefix' => 'acct_def_cgp_accessmodes_',
+                     'curr_value' => $svc_domain->acct_def_cgp_accessmodes,
+                  )
+        %>
+    </TD>
+  </TR>
+
+  <% include('/elements/tr-input-text.html',
+               'label'      => 'Mail storage limit',
+               'field'      => 'acct_def_quota',
+               'curr_value' => $svc_domain->acct_def_quota,
+            )
+  %>
+  <% include('/elements/tr-input-text.html',
+               'label'      => 'File storage limit',
+               'field'      => 'acct_def_file_quota',
+               'curr_value' => $svc_domain->acct_def_file_quota,
+            )
+  %>
+  <% include('/elements/tr-input-text.html',
+               'label'      => 'Files limit',
+               'field'      => 'acct_def_file_maxnum',
+               'curr_value' => $svc_domain->acct_def_file_maxnum,
+            )
+  %>
+  <% include('/elements/tr-input-text.html',
+               'label'      => 'File size limit',
+               'field'      => 'acct_def_file_maxsize',
+               'curr_value' => $svc_domain->acct_def_file_maxsize,
+            )
+  %>
+
+%# false laziness w/svc_acct acct_def
+  <TR>
+    <TD ALIGN="right">Message delete method</TD>
+    <TD>
+      <SELECT NAME="acct_def_cgp_deletemode">
+%       for ( 'Move To Trash', 'Immediately', 'Mark' ) {
+          <OPTION VALUE="<% $_ %>"
+                  <% $_ eq $svc_domain->acct_def_cgp_deletemode ? 'SELECTED' : '' %>
+          ><% $_ %>
+%       }
+      </SELECT>
+    </TD>
+  </TR>
+
+  <% include('/elements/tr-input-text.html',
+               'label'      => 'On logout remove trash',
+               'curr_value' => $svc_domain->acct_def_cgp_emptytrash,
+            )
+  %>
+
+</TABLE>
 <BR>
+
+% } else {
+
+%   foreach my $f (qw( password_selfchange password_recover cgp_accessmodes
+%                      quota file_quota file_maxnum file_maxsize
+%                      cgp_deletemode cgp_emptytrash
+%                 )) {
+      <INPUT TYPE="hidden" NAME="acct_def_<%$f%>" VALUE="<% $svc_domain->get("acct_def_$f") %>">
+%   }
+
+% }
+
 <INPUT TYPE="submit" VALUE="Submit">
 
 </FORM>
diff --git a/httemplate/view/elements/tr.html b/httemplate/view/elements/tr.html
new file mode 100644 (file)
index 0000000..e2ec7d4
--- /dev/null
@@ -0,0 +1,9 @@
+<TR>
+  <TD ALIGN="right"><% $opt{'label'} %></TD>
+  <TD BGCOLOR="#ffffff"><% $opt{'value'} %></TD>
+</TR>
+<%init>
+
+my %opt = @_;
+
+</%init>
index 0159a7e..92b9ad7 100644 (file)
@@ -1,15 +1,15 @@
 <% &ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %>
 
-<% include('tr.html', label=>'Service',  value=>$part_svc->svc) %>
-<% include('tr.html', label=>'Username', value=>$svc_acct->username) %>
-<% include('tr.html', label=>'Domain',   value=>$domain) %>
+<% include('/view/elements/tr.html', label=>'Service',  value=>$part_svc->svc) %>
+<% include('/view/elements/tr.html', label=>'Username', value=>$svc_acct->username) %>
+<% include('/view/elements/tr.html', label=>'Domain',   value=>$domain) %>
 
 % if ( $opt{'communigate'} ) {
-  <% include('tr.html', label=>'Aliases', value=>$svc_acct->cgp_aliases) %>
+  <% include('/view/elements/tr.html', label=>'Aliases', value=>$svc_acct->cgp_aliases) %>
 %}
 
 % if ( $svc_acct->pbxsvc ) {
-  <% include('tr.html', label=>'PBX', value=>$svc_acct->pbx_title) %>
+  <% include('/view/elements/tr.html', label=>'PBX', value=>$svc_acct->pbx_title) %>
 %}
 
 % my $show_pw = '';
 %   $show_pw .= '<I>(hidden)</I>';
 % } 
 % $password = ''; 
-<% include('tr.html', label=>'Password', value=>$show_pw) %>
+<% include('/view/elements/tr.html', label=>'Password', value=>$show_pw) %>
 
 
 % if ( $conf->exists('security_phrase') ) {
-  <%include('tr.html', label=>'Security phrase', value=>$svc_acct->sec_phrase)%>
+  <%include('/view/elements/tr.html', label=>'Security phrase', value=>$svc_acct->sec_phrase)%>
 % } 
 
 % if ( $svc_acct->popnum ) {
 %   my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum});
-    <% include('tr.html', label=>'Access number', value=>$svc_acct_pop->text) %>
+    <% include('/view/elements/tr.html', label=>'Access number', value=>$svc_acct_pop->text) %>
 % } 
 
 % if ($svc_acct->uid ne '') { 
-  <% include('tr.html', label=>'UID', value=>$svc_acct->uid) %>
+  <% include('/view/elements/tr.html', label=>'UID', value=>$svc_acct->uid) %>
 % } 
 
 % if ($svc_acct->gid ne '') { 
-  <% include('tr.html', label=>'GID', value=>$svc_acct->gid) %>
+  <% include('/view/elements/tr.html', label=>'GID', value=>$svc_acct->gid) %>
 % } 
 
 % if ($svc_acct->finger ne '') { 
-  <% include('tr.html', label=>'Real Name', value=>$svc_acct->finger) %>
+  <% include('/view/elements/tr.html', label=>'Real Name', value=>$svc_acct->finger) %>
 % } 
 
 % if ($svc_acct->dir ne '') { 
-  <% include('tr.html', label=>'Home directory', value=>$svc_acct->dir) %>
+  <% include('/view/elements/tr.html', label=>'Home directory', value=>$svc_acct->dir) %>
 % } 
 
 % if ($svc_acct->shell ne '') { 
-  <% include('tr.html', label=>'Shell', value=>$svc_acct->shell) %>
+  <% include('/view/elements/tr.html', label=>'Shell', value=>$svc_acct->shell) %>
 % } 
 
 % if ($svc_acct->quota ne '' && ! $opt{'communigate'} ) { 
 
-  <% include('tr.html', label=>'Quota', value=>$svc_acct->quota) %>
+  <% include('/view/elements/tr.html', label=>'Quota', value=>$svc_acct->quota) %>
 
 % } elsif ( $opt{'communigate'} ) {
 
-  <% include('tr.html', label=>'Mailbox type', value=>$svc_acct->cgp_type) %>
+  <% include('/view/elements/tr.html', label=>'Mailbox type', value=>$svc_acct->cgp_type) %>
 
-  <% include('tr.html', label=>'Enabled services',
+  <% include('/view/elements/tr.html', label=>'Enabled services',
                         value=>$svc_acct->cgp_accessmodes ) %>
 
-  <% include('tr.html', label=>'Mail storage limit',
+  <% include('/view/elements/tr.html', label=>'Mail storage limit',
                         value=>$svc_acct->quota ) %>
 
-  <% include('tr.html', label=>'File storage limit',
+  <% include('/view/elements/tr.html', label=>'File storage limit',
                         value=>$svc_acct->file_quota ) %>
 
-  <% include('tr.html', label=>'Number of files limit',
+  <% include('/view/elements/tr.html', label=>'Number of files limit',
                         value=>$svc_acct->file_maxnum ) %>
 
-  <% include('tr.html', label=>'File size limit',
+  <% include('/view/elements/tr.html', label=>'File size limit',
                         value=>$svc_acct->file_maxsize ) %>
 
-  <% include('tr.html', label=>'Message delete method',
+  <% include('/view/elements/tr.html', label=>'Message delete method',
                         value=>$svc_acct->cgp_deletemode ) %>
 
-  <% include('tr.html', label=>'On logout remove trash',
+  <% include('/view/elements/tr.html', label=>'On logout remove trash',
                         value=>$svc_acct->cgp_emptytrash ) %>
 
 
 % }
 
 % if ($svc_acct->slipip) { 
-  <% include('tr.html',
+  <% include('/view/elements/tr.html',
        label=>'IP address',
        value=> ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' )
                  ? "<I>(Dynamic)</I>"
 % foreach my $attribute ( grep /^radius_/, $svc_acct->fields ) {
 %   $attribute =~ /^radius_(.*)$/;
 %   my $pattribute = $FS::raddb::attrib{$1};
-    <% include('tr.html', label=>"Radius (reply) $pattribute",
+    <% include('/view/elements/tr.html', label=>"Radius (reply) $pattribute",
                           value=>$svc_acct->getfield($attribute)
               )
     %>
 % foreach my $attribute ( grep /^rc_/, $svc_acct->fields ) {
 %   $attribute =~ /^rc_(.*)$/;
 %   my $pattribute = $FS::raddb::attrib{$1};
-    <% include('tr.html', label=>"Radius (check) $pattribute",
+    <% include('/view/elements/tr.html', label=>"Radius (check) $pattribute",
                           value=>$svc_acct->getfield($attribute)
               )
     %>
 % } 
 
-<% include('tr.html', label=>'RADIUS groups',
+<% include('/view/elements/tr.html', label=>'RADIUS groups',
                       value=>join('<BR>', $svc_acct->radius_groups) ) %>
 
 %# Can this be abstracted further?  Maybe a library function like
index 3fd898b..3938a34 100755 (executable)
 
 <% include('/elements/error.html') %>
 
-Service #<B><% $svcnum %></B>
-% #if ( $conf->exists('svc_domain-edit_domain') ) {
-  | <A HREF="<%$p%>edit/svc_domain.cgi?<%$svcnum%>">Edit this domain</A>
-% #}
-
-<% &ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %>
-
-<TR>
-  <TD ALIGN="right">Service</TD>
-  <TD BGCOLOR="#ffffff"><% $part_svc->svc %></TD>
-</TR>
-
-<TR>
-  <TD ALIGN="right">Domain</TD>
-  <TD BGCOLOR="#ffffff">
-    <B><% $domain %></B>
-    <A HREF="<% ${p} %>misc/whois.cgi?custnum=<%$custnum%>;svcnum=<%$svcnum%>;domain=<%$domain%>">(view whois information)</A>
-  </TD>
-</TR>
-
-% if ($export) {
-  <TR>
-    <TD ALIGN="right">Registration status</TD>
-    <TD BGCOLOR="#ffffff"><B><% $status %></B>
-
-%   if ( $FS::CurrentUser::CurrentUser->access_right('Manage domain registration') ) {
-%     if ( defined($ops{'register'}) ) {
-    <A HREF="<% ${p} %>edit/process/domreg.cgi?op=register&svcnum=<% $svcnum %>">Register at <% $registrar->{'name'} %></A>&nbsp;
-%     }
-%     if ( defined($ops{'transfer'}) ) {
-    <A HREF="<% ${p} %>edit/process/domreg.cgi?op=transfer&svcnum=<% $svcnum %>">Transfer to <% $registrar->{'name'} %></A>&nbsp;
-%     }
-%     if ( defined($ops{'renew'}) ) {
-    <A HREF="<% ${p} %>edit/process/domreg.cgi?op=renew&svcnum=<% $svcnum %>&period=1">Renew at <% $registrar->{'name'} %></A>&nbsp;
-%     }
-%     if ( defined($ops{'revoke'}) ) {
-    <A HREF="<% ${p} %>edit/process/domreg.cgi?op=revoke&svcnum=<% $svcnum %>">Revoke</A>
-%     }
-%   }
-
-    </TD>
-  </TR>
-% }
-
-% if ( $communigate ) {
-
-  <TR>
-    <TD ALIGN="right">Administrator domain</TD>
-    <TD BGCOLOR="#ffffff">
-%     if ( $svc_domain->parent_svcnum ) {
-% #XXX agent-virt aware the link
-        <A HREF="svc_domain.cgi?<% $svc_domain->parent_svcnum %>"><% $svc_domain->parent_svc_x->domain %></A>
-%     } else {
-        <I>(none)</I>
-%     }
-    </TD>
-  </TR>
-
-  <TR>
-    <TD ALIGN="right">Aliases</TD>
-    <TD BGCOLOR="#ffffff"><% $svc_domain->cgp_aliases %></TD>
-  </TR>
-
-% }
-
-% if ( $communigate && $svc_domain->max_accounts ) {
-  <TR>
-    <TD ALIGN="right">Maximum number of Accounts</TD>
-    <TD BGCOLOR="#ffffff"><% $svc_domain->max_accounts %></TD>
-  </TR>
-% }
-
-<TR>
-  <TD ALIGN="right">Catch all email</TD>
-  <TD BGCOLOR="#ffffff"><% $email ? "<B>$email</B>" : '<I>(none)</I>' %>
-% if ( $FS::CurrentUser::CurrentUser->access_right('Edit domain catchall') ) {
-     <A HREF="<% ${p} %>misc/catchall.cgi?<% $svcnum %>">(change)</A>
-% }
-  </TD>
-</TR>
-
-<TR>
-  <TD ALIGN="right">Enabled services</TD>
-  <TD BGCOLOR="#ffffff"><% $svc_domain->cgp_accessmodes %></TD>
-</TR>
-
-</TABLE></TD></TR></TABLE>
+<% include('svc_domain/basics.html', $svc_domain,
+             'part_svc' => $part_svc,
+             'custnum'  => $custnum,
+          )
+%>
 <BR>
 
-<SCRIPT>
-  function areyousure(href, message) {
-    if ( confirm(message) == true )
-      window.location.href = href;
-  }
-  function slave_areyousure() {
-    return confirm("Remove all records and slave from " + document.SlaveForm.recdata.value + "?");
-  }
-</SCRIPT>
-
-DNS records
-% my @records; if ( @records = $svc_domain->domain_record ) { 
-
-  <% include('/elements/table-grid.html') %>
-
-% my $bgcolor1 = '#eeeeee';
-%     my $bgcolor2 = '#ffffff';
-%     my $bgcolor = $bgcolor2;
-
-  <tr>
-    <th CLASS="grid" BGCOLOR="#cccccc">Zone</th>
-    <th CLASS="grid" BGCOLOR="#cccccc">Type</th>
-    <th CLASS="grid" BGCOLOR="#cccccc">Data</th>
-  </tr>
-
-% foreach my $domain_record ( @records ) {
-%       my $type = $domain_record->rectype eq '_mstr'
-%                    ? "(slave)"
-%                    : $domain_record->recaf. ' '. $domain_record->rectype;
-
-
-    <tr>
-      <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $domain_record->reczone %></td>
-      <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $type %></td>
-      <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $domain_record->recdata %>
-
-% unless ( $domain_record->rectype eq 'SOA'
-%          || ! $FS::CurrentUser::CurrentUser->access_right('Edit domain nameservice')
-%        ) { 
-%   ( my $recdata = $domain_record->recdata ) =~ s/"/\\'\\'/g;
-      (<A HREF="javascript:areyousure('<%$p%>misc/delete-domain_record.cgi?<%$domain_record->recnum%>', 'Delete \'<% $domain_record->reczone %> <% $type %> <% $recdata %>\' ?' )">delete</A>)
-% }
-      </td>
-    </tr>
-
-
-%   if ( $bgcolor eq $bgcolor1 ) {
-%      $bgcolor = $bgcolor2;
-%    } else {
-%      $bgcolor = $bgcolor1;
-%    }
-
-% } 
-
-  </table>
-% } 
-
-% if ( $FS::CurrentUser::CurrentUser->access_right('Edit domain nameservice') ) {
-    <FORM METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi">
-      <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
-      <INPUT TYPE="text" NAME="reczone"> 
-      <INPUT TYPE="hidden" NAME="recaf" VALUE="IN"> IN 
-      <SELECT NAME="rectype">
-%       foreach (qw( A NS CNAME MX PTR TXT) ) { 
-          <OPTION VALUE="<%$_%>"><%$_%></OPTION>
-%       } 
-      </SELECT>
-      <INPUT TYPE="text" NAME="recdata">
-      <INPUT TYPE="submit" VALUE="Add record">
-    </FORM>
-
-    <FORM NAME="SlaveForm" METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi">
-      <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
-%     if ( @records ) { 
-         Delete all records and 
-%     } 
-      Or slave from nameserver IP 
-      <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
-      <INPUT TYPE="hidden" NAME="reczone" VALUE="@"> 
-      <INPUT TYPE="hidden" NAME="recaf" VALUE="IN">
-      <INPUT TYPE="hidden" NAME="rectype" VALUE="_mstr">
-      <INPUT TYPE="text" NAME="recdata">
-      <INPUT TYPE="submit" VALUE="Slave domain" onClick="return slave_areyousure()">
-    </FORM>
+<% include('svc_domain/acct_defaults.html', $svc_domain,
+             'part_svc' => $part_svc,
+          )
+%>
+<BR>
 
-% }
+<% include('svc_domain/dns.html', $svc_domain ) %>
 <BR>
 
 <% include('elements/svc_export_settings.html', $svc_domain) %>
@@ -238,43 +77,6 @@ if ($pkgnum) {
 my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
 die "Unknown svcpart" unless $part_svc;
 
-my $email = '';
-if ($svc_domain->catchall) {
-  my $svc_acct = qsearchs('svc_acct',{'svcnum'=> $svc_domain->catchall } );
-  die "Unknown svcpart" unless $svc_acct;
-  $email = $svc_acct->email;
-}
-
 my $domain = $svc_domain->domain;
 
-my $communigate = scalar($part_svc->part_export('communigate_pro'));
-                # || scalar($part_svc->part_export('communigate_pro_singledomain'));
-
-# Find the first export that does domain registration
-my @exports = grep $_->can('registrar'), $part_svc->part_export;
-my $export = $exports[0];
-# If we have a domain registration export, get the registrar object
-my $registrar;
-my $status = 'Unknown';
-my %ops = ();
-if ($export) {
-       $registrar = $export->registrar;
-       my $domstat = $export->get_status( $svc_domain );
-       if (defined($domstat->{'message'})) {
-               $status = $domstat->{'message'};
-       } elsif (defined($domstat->{'unregistered'})) {
-               $status = 'Not registered';
-               $ops{'register'} = "Register";
-       } elsif (defined($domstat->{'status'})) {
-               $status = $domstat->{'status'} . ' ' . $domstat->{'contact_email'} . ' ' . $domstat->{'last_update_time'};
-       } elsif (defined($domstat->{'expdate'})) {
-               $status = "Expires " . $domstat->{'expdate'};
-               $ops{'renew'} = "Renew";
-               $ops{'revoke'} = "Revoke";
-       } else {
-               $status = $domstat->{'reason'};
-               $ops{'transfer'} = "Transfer";
-       }
-}
-
 </%init>
diff --git a/httemplate/view/svc_domain/acct_defaults.html b/httemplate/view/svc_domain/acct_defaults.html
new file mode 100644 (file)
index 0000000..0c072bf
--- /dev/null
@@ -0,0 +1,71 @@
+% if ( $communigate ) {
+
+  Account defaults
+  <% &ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %>
+
+  <% include('/view/elements/tr.html',
+               label=>'Password modification',
+               value=>$svc_domain->acct_def_password_selfchange ? 'YES' : 'NO',
+            )
+  %>
+   <% include('/view/elements/tr.html',
+               label=>'Password recovery',
+               value=>$svc_domain->acct_def_password_recover ? 'YES' : 'NO',
+            )
+  %>
+    
+  <% include('/view/elements/tr.html',
+               label=>'Enabled services',
+               value=>$svc_domain->acct_def_cgp_accessmodes,
+            )
+  %>
+    
+  <% include('/view/elements/tr.html',
+               label=>'Mail storage limit',
+               value=>$svc_domain->acct_def_quota,
+            )
+  %>
+    
+  <% include('/view/elements/tr.html',
+               label=>'File storage limit',
+               value=>$svc_domain->acct_def_file_quota,
+            )
+  %>
+    
+  <% include('/view/elements/tr.html',
+               label=>'Files limt',
+               value=>$svc_domain->acct_def_file_maxnum,
+            )
+  %>
+    
+  <% include('/view/elements/tr.html',
+               label=>'File size limit',
+               value=>$svc_domain->acct_def_file_maxsize,
+            )
+  %>
+    
+  <% include('/view/elements/tr.html',
+               label=>'Message delete method',
+               value=>$svc_domain->acct_def_cgp_deletemode,
+            )
+  %>
+    
+  <% include('/view/elements/tr.html',
+               label=>'On logout remove trash',
+               value=>$svc_domain->acct_def_cgp_emptytrash,
+            )
+  %>
+
+  </TABLE></TD></TR></TABLE>
+
+% }
+<%init>
+
+my($svc_domain, %opt) = @_;
+
+my $part_svc = $opt{'part_svc'};
+
+my $communigate = scalar($part_svc->part_export('communigate_pro'));
+                # || scalar($part_svc->part_export('communigate_pro_singledomain'));
+
+</%init>
diff --git a/httemplate/view/svc_domain/basics.html b/httemplate/view/svc_domain/basics.html
new file mode 100644 (file)
index 0000000..db4fac1
--- /dev/null
@@ -0,0 +1,134 @@
+Service #<B><% $svcnum %></B>
+% #if ( $conf->exists('svc_domain-edit_domain') ) {
+  | <A HREF="<%$p%>edit/svc_domain.cgi?<%$svcnum%>">Edit this domain</A>
+% #}
+
+<% &ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %>
+
+<TR>
+  <TD ALIGN="right">Service</TD>
+  <TD BGCOLOR="#ffffff"><% $part_svc->svc %></TD>
+</TR>
+
+<TR>
+  <TD ALIGN="right">Domain</TD>
+  <TD BGCOLOR="#ffffff">
+    <B><% $domain %></B>
+    <A HREF="<% ${p} %>misc/whois.cgi?custnum=<%$custnum%>;svcnum=<%$svcnum%>;domain=<%$domain%>">(view whois information)</A>
+  </TD>
+</TR>
+
+% if ($export) {
+  <TR>
+    <TD ALIGN="right">Registration status</TD>
+    <TD BGCOLOR="#ffffff"><B><% $status %></B>
+
+%   if ( $FS::CurrentUser::CurrentUser->access_right('Manage domain registration') ) {
+%     if ( defined($ops{'register'}) ) {
+    <A HREF="<% ${p} %>edit/process/domreg.cgi?op=register&svcnum=<% $svcnum %>">Register at <% $registrar->{'name'} %></A>&nbsp;
+%     }
+%     if ( defined($ops{'transfer'}) ) {
+    <A HREF="<% ${p} %>edit/process/domreg.cgi?op=transfer&svcnum=<% $svcnum %>">Transfer to <% $registrar->{'name'} %></A>&nbsp;
+%     }
+%     if ( defined($ops{'renew'}) ) {
+    <A HREF="<% ${p} %>edit/process/domreg.cgi?op=renew&svcnum=<% $svcnum %>&period=1">Renew at <% $registrar->{'name'} %></A>&nbsp;
+%     }
+%     if ( defined($ops{'revoke'}) ) {
+    <A HREF="<% ${p} %>edit/process/domreg.cgi?op=revoke&svcnum=<% $svcnum %>">Revoke</A>
+%     }
+%   }
+
+    </TD>
+  </TR>
+% }
+
+% if ( $communigate ) {
+
+  <TR>
+    <TD ALIGN="right">Administrator domain</TD>
+    <TD BGCOLOR="#ffffff">
+%     if ( $svc_domain->parent_svcnum ) {
+% #XXX agent-virt aware the link
+        <A HREF="svc_domain.cgi?<% $svc_domain->parent_svcnum %>"><% $svc_domain->parent_svc_x->domain %></A>
+%     } else {
+        <I>(none)</I>
+%     }
+    </TD>
+  </TR>
+
+  <TR>
+    <TD ALIGN="right">Aliases</TD>
+    <TD BGCOLOR="#ffffff"><% $svc_domain->cgp_aliases %></TD>
+  </TR>
+
+% }
+
+% if ( $communigate && $svc_domain->max_accounts ) {
+  <TR>
+    <TD ALIGN="right">Maximum number of Accounts</TD>
+    <TD BGCOLOR="#ffffff"><% $svc_domain->max_accounts %></TD>
+  </TR>
+% }
+
+<TR>
+  <TD ALIGN="right">Catch all email</TD>
+  <TD BGCOLOR="#ffffff"><% $email ? "<B>$email</B>" : '<I>(none)</I>' %>
+% if ( $FS::CurrentUser::CurrentUser->access_right('Edit domain catchall') ) {
+     <A HREF="<% ${p} %>misc/catchall.cgi?<% $svcnum %>">(change)</A>
+% }
+  </TD>
+</TR>
+
+<TR>
+  <TD ALIGN="right">Enabled services</TD>
+  <TD BGCOLOR="#ffffff"><% $svc_domain->cgp_accessmodes %></TD>
+</TR>
+
+</TABLE></TD></TR></TABLE>
+
+<%init>
+
+my($svc_domain, %opt) = @_;
+my $svcnum = $svc_domain->svcnum;
+my $domain = $svc_domain->domain;
+my $custnum = $opt{'custnum'};
+my $part_svc = $opt{'part_svc'};
+
+my $communigate = scalar($part_svc->part_export('communigate_pro'));
+                # || scalar($part_svc->part_export('communigate_pro_singledomain'));
+
+my $email = '';
+if ($svc_domain->catchall) {
+  my $svc_acct = qsearchs('svc_acct',{'svcnum'=> $svc_domain->catchall } );
+  die "Unknown svcpart" unless $svc_acct;
+  $email = $svc_acct->email;
+}
+
+# Find the first export that does domain registration
+my @exports = grep $_->can('registrar'), $part_svc->part_export;
+my $export = $exports[0];
+# If we have a domain registration export, get the registrar object
+my $registrar;
+my $status = 'Unknown';
+my %ops = ();
+if ($export) {
+       $registrar = $export->registrar;
+       my $domstat = $export->get_status( $svc_domain );
+       if (defined($domstat->{'message'})) {
+               $status = $domstat->{'message'};
+       } elsif (defined($domstat->{'unregistered'})) {
+               $status = 'Not registered';
+               $ops{'register'} = "Register";
+       } elsif (defined($domstat->{'status'})) {
+               $status = $domstat->{'status'} . ' ' . $domstat->{'contact_email'} . ' ' . $domstat->{'last_update_time'};
+       } elsif (defined($domstat->{'expdate'})) {
+               $status = "Expires " . $domstat->{'expdate'};
+               $ops{'renew'} = "Renew";
+               $ops{'revoke'} = "Revoke";
+       } else {
+               $status = $domstat->{'reason'};
+               $ops{'transfer'} = "Transfer";
+       }
+}
+
+</%init>
diff --git a/httemplate/view/svc_domain/dns.html b/httemplate/view/svc_domain/dns.html
new file mode 100644 (file)
index 0000000..f6f8c71
--- /dev/null
@@ -0,0 +1,94 @@
+<SCRIPT>
+  function areyousure(href, message) {
+    if ( confirm(message) == true )
+      window.location.href = href;
+  }
+  function slave_areyousure() {
+    return confirm("Remove all records and slave from " + document.SlaveForm.recdata.value + "?");
+  }
+</SCRIPT>
+
+DNS records
+% my @records; if ( @records = $svc_domain->domain_record ) { 
+
+  <% include('/elements/table-grid.html') %>
+
+% my $bgcolor1 = '#eeeeee';
+%     my $bgcolor2 = '#ffffff';
+%     my $bgcolor = $bgcolor2;
+
+  <tr>
+    <th CLASS="grid" BGCOLOR="#cccccc">Zone</th>
+    <th CLASS="grid" BGCOLOR="#cccccc">Type</th>
+    <th CLASS="grid" BGCOLOR="#cccccc">Data</th>
+  </tr>
+
+% foreach my $domain_record ( @records ) {
+%       my $type = $domain_record->rectype eq '_mstr'
+%                    ? "(slave)"
+%                    : $domain_record->recaf. ' '. $domain_record->rectype;
+
+
+    <tr>
+      <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $domain_record->reczone %></td>
+      <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $type %></td>
+      <td CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $domain_record->recdata %>
+
+% unless ( $domain_record->rectype eq 'SOA'
+%          || ! $FS::CurrentUser::CurrentUser->access_right('Edit domain nameservice')
+%        ) { 
+%   ( my $recdata = $domain_record->recdata ) =~ s/"/\\'\\'/g;
+      (<A HREF="javascript:areyousure('<%$p%>misc/delete-domain_record.cgi?<%$domain_record->recnum%>', 'Delete \'<% $domain_record->reczone %> <% $type %> <% $recdata %>\' ?' )">delete</A>)
+% }
+      </td>
+    </tr>
+
+
+%   if ( $bgcolor eq $bgcolor1 ) {
+%      $bgcolor = $bgcolor2;
+%    } else {
+%      $bgcolor = $bgcolor1;
+%    }
+
+% } 
+
+  </table>
+% } 
+
+% if ( $FS::CurrentUser::CurrentUser->access_right('Edit domain nameservice') ) {
+    <FORM METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi">
+      <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
+      <INPUT TYPE="text" NAME="reczone"> 
+      <INPUT TYPE="hidden" NAME="recaf" VALUE="IN"> IN 
+      <SELECT NAME="rectype">
+%       foreach (qw( A NS CNAME MX PTR TXT) ) { 
+          <OPTION VALUE="<%$_%>"><%$_%></OPTION>
+%       } 
+      </SELECT>
+      <INPUT TYPE="text" NAME="recdata">
+      <INPUT TYPE="submit" VALUE="Add record">
+    </FORM>
+
+    <FORM NAME="SlaveForm" METHOD="POST" ACTION="<%$p%>edit/process/domain_record.cgi">
+      <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
+%     if ( @records ) { 
+         Delete all records and 
+%     } 
+      Or slave from nameserver IP 
+      <INPUT TYPE="hidden" NAME="svcnum" VALUE="<%$svcnum%>">
+      <INPUT TYPE="hidden" NAME="reczone" VALUE="@"> 
+      <INPUT TYPE="hidden" NAME="recaf" VALUE="IN">
+      <INPUT TYPE="hidden" NAME="rectype" VALUE="_mstr">
+      <INPUT TYPE="text" NAME="recdata">
+      <INPUT TYPE="submit" VALUE="Slave domain" onClick="return slave_areyousure()">
+    </FORM>
+
+% }
+
+<%init>
+
+my($svc_domain, %opt) = @_;
+my $svcnum = $svc_domain->svcnum;
+
+</%init>
+