From: ivan Date: Sun, 21 Feb 2010 03:16:02 +0000 (+0000) Subject: communigate, RT#7083 X-Git-Tag: root_of_svc_elec_features~457 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=259eacca8b815b2bf159e7ee14385e2ac28ed9ee communigate, RT#7083 --- diff --git a/FS/FS/part_export/communigate_pro.pm b/FS/FS/part_export/communigate_pro.pm index 90283d2ae..11cf88f54 100644 --- a/FS/FS/part_export/communigate_pro.pm +++ b/FS/FS/part_export/communigate_pro.pm @@ -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; - $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{'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 @@ -276,7 +277,8 @@ sub _export_unsuspend_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' ) { - $effective_settings->{$key} = join(', ', @$value); + $effective_settings->{$key} = join(' ', @$value); } 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'}); - #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 @@ -382,7 +405,7 @@ sub export_getsettings_svc_acct { { 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"; diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index db39ea9ae..3ed153e0c 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -724,7 +724,18 @@ sub process { 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->{$_}; diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 181628715..088ccd472 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -271,8 +271,21 @@ sub table_info { 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' => { - label => 'Quota', + label => 'Quota', #Mail storage limit 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_alphasn( 'cgp_accessmodes' ) + || $self->ut_textn( 'cgp_accessmodes' ) || $self->ut_alphan( 'cgp_type' ) ; return $error if $error; diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index d74e0f20d..6428960dd 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -292,6 +292,7 @@ that field. % } 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'), @@ -305,6 +306,14 @@ that 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 .= diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index 1712d51a8..a4c60ef9e 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -31,6 +31,18 @@ foreach (map { $_,$_."_threshold" } qw( upbytes downbytes totalbytes )) { $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($_)); diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 065ce701d..0254ec186 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -243,7 +243,9 @@ Service # <% $svcnum ? "$svcnum" : " (NEW)" %>
% } -% if ( $communigate ) { +% if ( $communigate +% && $part_svc->part_svc_column('cgp_type')->columnflag ne 'F' ) +% { Mailbox type @@ -258,17 +260,27 @@ Service # <% $svcnum ? "$svcnum" : " (NEW)" %>
- +% } else { + +% } + + +% if ( $communigate +% && $part_svc->part_svc_column('cgp_accessmodes')->columnflag ne 'F' ) +% { + - Mailbox type - XXX checkbox thingie!! + Enabled services + + <% include( '/elements/communigate_pro-accessmodes.html', + 'curr_value' => $svc_acct->cgp_accessmodes, + ) + %> - % } else { - - + % } diff --git a/httemplate/elements/communigate_pro-accessmodes.html b/httemplate/elements/communigate_pro-accessmodes.html new file mode 100644 index 000000000..6ce9ca587 --- /dev/null +++ b/httemplate/elements/communigate_pro-accessmodes.html @@ -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 +)); + + +<%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}; +}; + + diff --git a/httemplate/pref/pref-process.html b/httemplate/pref/pref-process.html index 2b6c969f8..708583df5 100644 --- a/httemplate/pref/pref-process.html +++ b/httemplate/pref/pref-process.html @@ -47,7 +47,7 @@ unless ( $error ) { # if ($access_user) { 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 ); diff --git a/httemplate/pref/pref.html b/httemplate/pref/pref.html index 5cd75e26c..7ded18377 100644 --- a/httemplate/pref/pref.html +++ b/httemplate/pref/pref.html @@ -84,6 +84,10 @@ Development option('show_confitem_counts') ? 'CHECKED' : '' %>> + Show export data on service view (when available): + option('export_getsettings') ? 'CHECKED' : '' %>> + + Show database profiling (when available): option('show_db_profile') ? 'CHECKED' : '' %>> diff --git a/httemplate/view/elements/svc_export_settings.html b/httemplate/view/elements/svc_export_settings.html index 026280546..a3c09110f 100644 --- a/httemplate/view/elements/svc_export_settings.html +++ b/httemplate/view/elements/svc_export_settings.html @@ -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 - External settings - <% ntable('#cccccc',2) %> + External settings + <% ntable('#cccccc',2) %> -% foreach my $key ( keys %$settings ) { - - <% $key |h %> - - <% $defaults->{$key} ? '' : '' %> - <% $settings->{$key} |h %> - <% $defaults->{$key} ? '' : '' %> - - -% } +% foreach my $key ( keys %$settings ) { + + <% $key |h %> + + <% $defaults->{$key} ? '' : '' %> + <% $settings->{$key} |h %> + <% $defaults->{$key} ? '' : '' %> + + +% } - -
+ +
+% } % } - <%init> my $svc_x = shift; diff --git a/httemplate/view/svc_acct/basics.html b/httemplate/view/svc_acct/basics.html index 752b4833a..6eddd492d 100644 --- a/httemplate/view/svc_acct/basics.html +++ b/httemplate/view/svc_acct/basics.html @@ -109,7 +109,7 @@ Enabled services - <% $svc_acct->cgp_accessmodes %> + <% $svc_acct->cgp_accessmodes |h %>