communigate, RT#7083
authorivan <ivan>
Sun, 21 Feb 2010 03:16:02 +0000 (03:16 +0000)
committerivan <ivan>
Sun, 21 Feb 2010 03:16:02 +0000 (03:16 +0000)
FS/FS/part_export/communigate_pro.pm
FS/FS/part_svc.pm
FS/FS/svc_acct.pm
httemplate/edit/part_svc.cgi
httemplate/edit/process/svc_acct.cgi
httemplate/edit/svc_acct.cgi
httemplate/elements/communigate_pro-accessmodes.html [new file with mode: 0644]
httemplate/pref/pref-process.html
httemplate/pref/pref.html
httemplate/view/elements/svc_export_settings.html
httemplate/view/svc_acct/basics.html

index 90283d2..11cf88f 100644 (file)
@@ -152,10 +152,11 @@ sub _export_replace_svc_acct {
     if $old->finger ne $new->finger;
   $settings{$quotas{$_}} = $new->$_()
     foreach grep $old->$_() ne $new->$_(), keys %quotas;
     if $old->finger ne $new->finger;
   $settings{$quotas{$_}} = $new->$_()
     foreach grep $old->$_() ne $new->$_(), keys %quotas;
-  $settings{'AccessModes'} = $new->cgp_accessmodes
-    if $old->cgp_accessmodes ne $new->cgp_accessmodes;
   $settings{'accountType'} = $new->cgp_type
     if $old->cgp_type ne $new->cgp_type;
   $settings{'accountType'} = $new->cgp_type
     if $old->cgp_type ne $new->cgp_type;
+  $settings{'AccessModes'} = $new->cgp_accessmodes
+    if $old->cgp_accessmodes ne $new->cgp_accessmodes
+    || $old->cgp_type ne $new->cgp_type;
 
   #phase 2: pwdallowed, passwordrecovery, allowed mail rules,
   # RPOP modifications, accepts mail to all, add trailer to sent mail
 
   #phase 2: pwdallowed, passwordrecovery, allowed mail rules,
   # RPOP modifications, accepts mail to all, add trailer to sent mail
@@ -276,7 +277,8 @@ sub _export_unsuspend_svc_acct {
     $svc_acct->svcnum,
     'UpdateAccountSettings',
     $self->export_username($svc_acct),
     $svc_acct->svcnum,
     'UpdateAccountSettings',
     $self->export_username($svc_acct),
-    'AccessModes' => $self->option('AccessModes'),
+    'AccessModes' => ( $svc_acct->cgp_accessmodes
+                         || $self->option('AccessModes') ),
   );
 
 }
   );
 
 }
@@ -338,7 +340,7 @@ sub export_getsettings_svc_domain {
   {
     my $value = $effective_settings->{$key};
     if ( ref($value) eq 'ARRAY' ) {
   {
     my $value = $effective_settings->{$key};
     if ( ref($value) eq 'ARRAY' ) {
-      $effective_settings->{$key} = join(', ', @$value);
+      $effective_settings->{$key} = join(' ', @$value);
     } else {
       #XXX
       warn "serializing ". ref($value). " for table display not yet handled";
     } else {
       #XXX
       warn "serializing ". ref($value). " for table display not yet handled";
@@ -370,7 +372,28 @@ sub export_getsettings_svc_acct {
 
   delete($effective_settings->{'Password'});
 
 
   delete($effective_settings->{'Password'});
 
-  #XXX prefs/effectiveprefs too
+  #prefs/effectiveprefs too
+
+  my $prefs = eval { $self->communigate_pro_runcommand(
+    'GetAccountPrefs',
+    $svc_acct->email
+  ) };
+  return $@ if $@;
+
+  my $effective_prefs = eval { $self->communigate_pro_runcommand(
+    'GetAccountEffectivePrefs',
+    $svc_acct->email
+  ) };
+  return $@ if $@;
+
+  %$effective_settings = ( %$effective_settings,
+                           map { ("Pref $_" => $effective_prefs->{$_}); }
+                               keys(%$effective_prefs)
+                         );
+  %$settings = ( %$settings,
+                 map { ("Pref $_" => $prefs->{$_}); }
+                     keys(%$prefs)
+               );
 
   #false laziness w/above
 
 
   #false laziness w/above
 
@@ -382,7 +405,7 @@ sub export_getsettings_svc_acct {
   {
     my $value = $effective_settings->{$key};
     if ( ref($value) eq 'ARRAY' ) {
   {
     my $value = $effective_settings->{$key};
     if ( ref($value) eq 'ARRAY' ) {
-      $effective_settings->{$key} = join(', ', @$value);
+      $effective_settings->{$key} = join(' ', @$value);
     } else {
       #XXX
       warn "serializing ". ref($value). " for table display not yet handled";
     } else {
       #XXX
       warn "serializing ". ref($value). " for table display not yet handled";
index db39ea9..3ed153e 100644 (file)
@@ -724,7 +724,18 @@ sub process {
     ref($param->{'svc_acct__usergroup'})
       ? join(',', @{$param->{'svc_acct__usergroup'}} )
       : $param->{'svc_acct__usergroup'};
     ref($param->{'svc_acct__usergroup'})
       ? join(',', @{$param->{'svc_acct__usergroup'}} )
       : $param->{'svc_acct__usergroup'};
+
+  #unmunge cgp_accessmodes (falze laziness-ish w/edit/process/svc_acct.cgi)
+  $param->{'svc_acct__cgp_accessmodes'} ||=
+    join(' ', sort
+      grep { $_ !~ /^(flag|label)$/ }
+           map { /^svc_acct__cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; }
+               grep $param->{$_},
+                    grep /^svc_acct__cgp_accessmodes_([\w\/]+)$/,
+                         keys %$param
+        );
   
   
+
   my $new = new FS::part_svc ( {
     map {
       $_ => $param->{$_};
   my $new = new FS::part_svc ( {
     map {
       $_ => $param->{$_};
index 1816287..088ccd4 100644 (file)
@@ -271,8 +271,21 @@ sub table_info {
                          disable_fixed => 1,
                          disable_select => 1,
                        },
                          disable_fixed => 1,
                          disable_select => 1,
                        },
+        'cgp_type'=> { 
+                       label => 'Communigate account type',
+                       type => 'select',
+                       select_list => [ ],
+                       disable_inventory => 1,
+                       disable_select    => 1,
+                     },
+        'cgp_accessmodes' => { 
+                               label => 'Communigate enabled services',
+                               type  => 'communigate_pro-accessmodes',
+                               disable_inventory => 1,
+                               disable_select    => 1,
+                             },
         'quota'     => { 
         'quota'     => { 
-                         label => 'Quota',
+                         label => 'Quota', #Mail storage limit
                          type => 'text',
                          disable_inventory => 1,
                          disable_select => 1,
                          type => 'text',
                          disable_inventory => 1,
                          disable_select => 1,
@@ -1085,7 +1098,7 @@ sub check {
                                )
               || $self->ut_enum( 'password_selfchange', [ '', 'Y' ] )
               || $self->ut_enum( 'password_recover',    [ '', 'Y' ] )
                                )
               || $self->ut_enum( 'password_selfchange', [ '', 'Y' ] )
               || $self->ut_enum( 'password_recover',    [ '', 'Y' ] )
-              || $self->ut_alphasn( 'cgp_accessmodes' )
+              || $self->ut_textn( 'cgp_accessmodes' )
               || $self->ut_alphan( 'cgp_type' )
   ;
   return $error if $error;
               || $self->ut_alphan( 'cgp_type' )
   ;
   return $error if $error;
index d74e0f2..6428960 100755 (executable)
@@ -292,6 +292,7 @@ that field.
 %        } elsif ( $def->{type} eq 'select-svc_pbx.html' ) {
 %
 %          $html .= include('/elements/select-svc_pbx.html',
 %        } elsif ( $def->{type} eq 'select-svc_pbx.html' ) {
 %
 %          $html .= include('/elements/select-svc_pbx.html',
+%                             'curr_value'   => $value,
 %                             'element_name' => "${layer}__${field}",
 %                             'element_etc'  => $disabled,
 %                             'multiple'     => ($flag eq 'S'),
 %                             'element_name' => "${layer}__${field}",
 %                             'element_etc'  => $disabled,
 %                             'multiple'     => ($flag eq 'S'),
@@ -305,6 +306,14 @@ that field.
 %          $html .= FS::svc_acct::radius_usergroup_selector(
 %            [ split(',', $value) ], "${layer}__${field}" );
 %
 %          $html .= FS::svc_acct::radius_usergroup_selector(
 %            [ split(',', $value) ], "${layer}__${field}" );
 %
+%        } elsif ( $def->{type} eq 'communigate_pro-accessmodes' ) {
+%
+%          $html .= include('/elements/communigate_pro-accessmodes.html',
+%                             'element_name_prefix' => "${layer}__${field}_",
+%                             'curr_value'          => $value,
+%                             #doesn't work#'element_etc'  => $disabled,
+%                          );
+%
 %        } elsif ( $def->{type} eq 'disabled' ) {
 %
 %          $html .=
 %        } elsif ( $def->{type} eq 'disabled' ) {
 %
 %          $html .=
index 1712d51..a4c60ef 100755 (executable)
@@ -31,6 +31,18 @@ foreach (map { $_,$_."_threshold" } qw( upbytes downbytes totalbytes )) {
   $cgi->param($_, FS::UI::bytecount::parse_bytecount($cgi->param($_)) );
 }
 
   $cgi->param($_, FS::UI::bytecount::parse_bytecount($cgi->param($_)) );
 }
 
+#unmunge cgp_accessmodes (falze laziness-ish w/part_svc.pm::process)
+unless ( $cgi->param('cgp_accessmodes') ) {
+  $cgi->param('cgp_accessmodes', 
+    join(' ',
+      sort map { /^cgp_accessmodes_([\w\/]+)$/ or die "no way"; $1; }
+               grep $cgi->param($_),
+                    grep /^cgp_accessmodes_([\w\/]+)$/,
+                         $cgi->param()
+        )
+  );
+}
+
 my %hash = $svcnum ? $old->hash : ();
 map {
     $hash{$_} = scalar($cgi->param($_));
 my %hash = $svcnum ? $old->hash : ();
 map {
     $hash{$_} = scalar($cgi->param($_));
index 065ce70..0254ec1 100755 (executable)
@@ -243,7 +243,9 @@ Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR>
 % } 
 
 
 % } 
 
 
-% if ( $communigate ) {
+% if ( $communigate
+%      && $part_svc->part_svc_column('cgp_type')->columnflag ne 'F' )
+% {
 
   <TR>
     <TD ALIGN="right">Mailbox type</TD>
 
   <TR>
     <TD ALIGN="right">Mailbox type</TD>
@@ -258,17 +260,27 @@ Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR>
     </TD>
   </TR>
 
     </TD>
   </TR>
 
-    <TR>
+% } else {
+    <INPUT TYPE="hidden" NAME="cgp_type" VALUE="<% $svc_acct->cgp_type() %>">
+% }
+
+
+% if ( $communigate
+%      && $part_svc->part_svc_column('cgp_accessmodes')->columnflag ne 'F' )
+% {
+
   <TR>
   <TR>
-    <TD ALIGN="right">Mailbox type</TD>
-    <TD>XXX checkbox thingie!!
+    <TD ALIGN="right">Enabled services</TD>
+    <TD>
+      <% include( '/elements/communigate_pro-accessmodes.html',
+                    'curr_value' => $svc_acct->cgp_accessmodes,
+                )
+      %>
     </TD>
   </TR>
     </TD>
   </TR>
-   
 
 % } else {
 
 % } else {
-    <INPUT TYPE="hidden" NAME="cgp_type" VALUE="<% $svc_acct->cgp_type() %>">
-    <INPUT TYPE="hidden" NAME="cgp_accessmodes" VALUE="<% $svc_acct->cgp_accessmodes() %>">
+    <INPUT TYPE="hidden" NAME="cgp_accessmodes" VALUE="<% $svc_acct->cgp_accessmodes() |h %>">
 % }
 
 
 % }
 
 
diff --git a/httemplate/elements/communigate_pro-accessmodes.html b/httemplate/elements/communigate_pro-accessmodes.html
new file mode 100644 (file)
index 0000000..6ce9ca5
--- /dev/null
@@ -0,0 +1,30 @@
+<% include( 'checkboxes.html',
+              'element_name_prefix' => 'cgp_accessmodes_',
+              'names_list'          => \@names,
+              'checked_callback'    => $callback,
+              %opt,
+          )
+%>
+<%once>
+
+my @names = (qw(
+  Mail Relay Signal Mobile TLS POP IMAP MAPI
+  AirSync SIP XMPP WebMail XIMSS FTP ACAP PWD
+  LDAP RADIUS S/MIME WebCAL WebSite PBX HTTP
+));
+
+</%once>
+<%init>
+
+my %opt = @_;
+my $curr_value = $opt{'curr_value'};
+
+$curr_value = { map { $_=>1 } split(/\s+/, $curr_value) }
+  unless ref($curr_value);
+
+my $callback = sub {
+  my( $cgi, $name ) = @_;
+  $curr_value->{$name};
+};
+
+</%init>
index 2b6c969..708583d 100644 (file)
@@ -47,7 +47,7 @@ unless ( $error ) { # if ($access_user) {
                       email_address
                       snom-ip snom-username snom-password
                       vonage-fromnumber vonage-username vonage-password
                       email_address
                       snom-ip snom-username snom-password
                       vonage-fromnumber vonage-username vonage-password
-                      show_pkgnum show_confitem_counts
+                      show_pkgnum show_confitem_counts export_getsettings
                       show_db_profile save_db_profile
                       height width availHeight availWidth colorDepth
                     );
                       show_db_profile save_db_profile
                       height width availHeight availWidth colorDepth
                     );
index 5cd75e2..7ded183 100644 (file)
@@ -84,6 +84,10 @@ Development
     <TD><INPUT TYPE="checkbox" NAME="show_confitem_counts" VALUE="1" <% $curuser->option('show_confitem_counts') ? 'CHECKED' : '' %>></TD>
   </TR>
   <TR>
     <TD><INPUT TYPE="checkbox" NAME="show_confitem_counts" VALUE="1" <% $curuser->option('show_confitem_counts') ? 'CHECKED' : '' %>></TD>
   </TR>
   <TR>
+    <TH>Show export data on service view (when available): </TH>
+    <TD><INPUT TYPE="checkbox" NAME="export_getsettings" VALUE="1" <% $curuser->option('export_getsettings') ? 'CHECKED' : '' %>></TD>
+  </TR>
+  <TR>
     <TH>Show database profiling (when available): </TH>
     <TD><INPUT TYPE="checkbox" NAME="show_db_profile" VALUE="1" <% $curuser->option('show_db_profile') ? 'CHECKED' : '' %>></TD>
   </TR>
     <TH>Show database profiling (when available): </TH>
     <TD><INPUT TYPE="checkbox" NAME="show_db_profile" VALUE="1" <% $curuser->option('show_db_profile') ? 'CHECKED' : '' %>></TD>
   </TR>
index 0262805..a3c0911 100644 (file)
@@ -1,26 +1,28 @@
-% my ( $settings, $defaults ) = $svc_x->export_getsettings;
-% if ( keys %$settings ) {
+% if ( $FS::CurrentUser::CurrentUser->option('export_getsettings') ) {
+
+%   my ( $settings, $defaults ) = $svc_x->export_getsettings;
+%   if ( keys %$settings ) {
 
 %# XXX a way to label this "Communigate pro settings".. just a config maybe
 
 %# XXX a way to label this "Communigate pro settings".. just a config maybe
-  External settings
-  <% ntable('#cccccc',2) %>
+    External settings
+    <% ntable('#cccccc',2) %>
 
 
-%   foreach my $key ( keys %$settings ) {
-      <TR>
-        <TD ALIGN="right"><% $key |h %></TD>
-        <TD BGCOLOR="<% $defaults->{$key} ? '#eeeeee' : '#ffffff' %>">
-          <% $defaults->{$key} ? '<I>' : '<B>' %>
-          <% $settings->{$key} |h %>
-          <% $defaults->{$key} ? '</I>' : '</B>' %>
-        </TD>
-      </TR>
-%   }
+%     foreach my $key ( keys %$settings ) {
+        <TR>
+          <TD ALIGN="right"><% $key |h %></TD>
+          <TD BGCOLOR="<% $defaults->{$key} ? '#eeeeee' : '#ffffff' %>">
+            <% $defaults->{$key} ? '<I>' : '<B>' %>
+            <% $settings->{$key} |h %>
+            <% $defaults->{$key} ? '</I>' : '</B>' %>
+          </TD>
+        </TR>
+%     }
 
 
-  </TABLE>
-  <BR>
+    </TABLE>
+    <BR>
 
 
+%   }
 % }
 % }
-
 <%init>
 
 my $svc_x = shift;
 <%init>
 
 my $svc_x = shift;
index 752b483..6eddd49 100644 (file)
 
   <TR>
     <TD ALIGN="right">Enabled services</TD>
 
   <TR>
     <TD ALIGN="right">Enabled services</TD>
-    <TD BGCOLOR="#ffffff"><% $svc_acct->cgp_accessmodes %></TD>
+    <TD BGCOLOR="#ffffff"><% $svc_acct->cgp_accessmodes |h %></TD>
   </TR>
 
   <TR>
   </TR>
 
   <TR>