From f696f5c9b8ec55b83285a6d159711889cc796619 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 21 Feb 2010 07:32:20 +0000 Subject: [PATCH] communigate, RT#7083 --- FS/FS/Schema.pm | 1 + FS/FS/part_export/communigate_pro.pm | 56 +++++-- FS/FS/svc_acct.pm | 1 + httemplate/edit/svc_acct.cgi | 41 +++-- httemplate/view/elements/svc_export_settings.html | 8 +- httemplate/view/svc_acct/basics.html | 179 ++++++++-------------- httemplate/view/svc_acct/tr.html | 9 ++ 7 files changed, 152 insertions(+), 143 deletions(-) create mode 100644 httemplate/view/svc_acct/tr.html diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 3c6289fc6..9847a987a 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1641,6 +1641,7 @@ sub tables_hashref { 'password_selfchange','char', 'NULL', 1, '', '', 'password_recover', 'char', 'NULL', 1, '', '', 'cgp_type', 'varchar', 'NULL', $char_d, '', '', #AccountType + 'cgp_aliases', 'varchar', 'NULL', 255, '', '', #AccountType ], 'primary_key' => 'svcnum', #'unique' => [ [ 'username', 'domsvc' ] ], diff --git a/FS/FS/part_export/communigate_pro.pm b/FS/FS/part_export/communigate_pro.pm index 11cf88f54..c31aea385 100644 --- a/FS/FS/part_export/communigate_pro.pm +++ b/FS/FS/part_export/communigate_pro.pm @@ -17,7 +17,7 @@ tie %options, 'Tie::IxHash', 'password' => { label =>'The administrator account password.', }, 'accountType' => { label => 'Type for newly-created accounts (default when not specified in service)', type => 'select', - options => [qw(MultiMailbox TextMailbox MailDirMailbox)], + options => [qw(MultiMailbox TextMailbox MailDirMailbox AGrade BGrade CGrade)], default => 'MultiMailbox', }, 'externalFlag' => { label => 'Create accounts with an external (visible for legacy mailers) INBOX.', @@ -70,30 +70,45 @@ sub _export_insert { sub _export_insert_svc_acct { my( $self, $svc_acct ) = (shift, shift); - my @options = ( $svc_acct->svcnum, 'CreateAccount', - 'accountName' => $self->export_username($svc_acct), - 'accountType' => ( $svc_acct->cgp_type - || $self->option('accountType') ), + my %settings = ( 'AccessModes' => ( $svc_acct->cgp_accessmodes || $self->option('AccessModes') ), 'RealName' => $svc_acct->finger, 'Password' => $svc_acct->_password, + map { $quotas{$_} => $svc_acct->$_() } + grep $svc_acct->$_(), keys %quotas ); - push @options, $quotas{$_} => $svc_acct->$_() - foreach grep $svc_acct->$_(), keys %quotas; + #XXX preferences phase 1: message delete method, on logout remove trash + #phase 2: language, time zone, layout, pronto style, send read receipts #phase 2: pwdallowed, passwordrecovery, allowed mail rules, # RPOP modifications, accepts mail to all, add trailer to sent mail #phase 3: archive messages, mailing lists + my @options = ( 'CreateAccount', + 'accountName' => $self->export_username($svc_acct), + 'accountType' => ( $svc_acct->cgp_type + || $self->option('accountType') ), + 'settings' => \%settings + ); + push @options, 'externalFlag' => $self->option('externalFlag') if $self->option('externalFlag'); - #XXX preferences phase 1: message delete method, on logout remove trash - #phase 2: language, time zone, layout, pronto style, send read receipts + #let's do the create realtime too, for much the same reasons, and to avoid + #pain of trying to queue w/dep the aliases + #my $r= + eval { $self->communigate_pro_runcommand( @options ) }; + return $@ if $@; - $self->communigate_pro_queue( @options ); + my $err= $self->communigate_pro_queue( $svc_acct->svcnum, 'SetAccountAliases', + $self->export_username($svc_acct), + [ split(/\s*,\s*/, $svc_acct->cgp_aliases) ], + ); + warn "WARNING: error queueing SetAccountAliases job: $err" if $err; + + ''; } @@ -172,6 +187,16 @@ sub _export_replace_svc_acct { return $error if $error; } + if ( $old->cgp_aliases ne $new->cgp_aliases ) { + my $error = $self->communigate_pro_queue( + $new->svcnum, + 'SetAccountAliases', + $self->export_username($new), + [ split(/\s*,\s*/, $new->cgp_aliases) ], + ); + return $error if $error; + } + #XXX preferences phase 1: message delete method, on logout remove trash #phase 2: language, time zone, layout, pronto style, send read receipts @@ -395,6 +420,17 @@ sub export_getsettings_svc_acct { keys(%$prefs) ); + #aliases too + + my $aliases = eval { $self->communigate_pro_runcommand( + 'GetAccountAliases', + $svc_acct->email + ) }; + return $@ if $@; + + $effective_settings->{'Aliases'} = join(', ', @$aliases); + $settings->{'Aliases'} = join(', ', @$aliases); + #false laziness w/above my %defaults = map { $_ => 1 } diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 088ccd472..54d443c80 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -1100,6 +1100,7 @@ sub check { || $self->ut_enum( 'password_recover', [ '', 'Y' ] ) || $self->ut_textn( 'cgp_accessmodes' ) || $self->ut_alphan( 'cgp_type' ) + || $self->ut_textn( 'cgp_aliases' ) #well ; return $error if $error; diff --git a/httemplate/edit/svc_acct.cgi b/httemplate/edit/svc_acct.cgi index 0254ec186..f44147ff4 100755 --- a/httemplate/edit/svc_acct.cgi +++ b/httemplate/edit/svc_acct.cgi @@ -54,7 +54,7 @@ Service # <% $svcnum ? "$svcnum" : " (NEW)" %>
%}else{ %} - + % %my $sec_phrase = $svc_acct->sec_phrase; %if ( $conf->exists('security_phrase') @@ -123,6 +123,19 @@ Service # <% $svcnum ? "$svcnum" : " (NEW)" %>
% } + +% if ( $communigate ) { + + + Aliases + + + +% } else { + +% } + + <% include('/elements/tr-select-svc_pbx.html', 'curr_value' => $svc_acct->pbxsvc, 'part_svc' => $part_svc, @@ -251,7 +264,8 @@ Service # <% $svcnum ? "$svcnum" : " (NEW)" %>
Mailbox type