diff options
author | ivan <ivan> | 2010-02-21 07:32:21 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-02-21 07:32:21 +0000 |
commit | 6495ef2f0c495e55db9e182f5607d93a5c4adc20 (patch) | |
tree | d9f089d7257bc5c4f00fa47e715860091848abb5 | |
parent | 690f020eb7e2af7112793747f45b488aa0e24e03 (diff) |
communigate, RT#7083
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/part_export/communigate_pro.pm | 56 | ||||
-rw-r--r-- | FS/FS/svc_acct.pm | 1 | ||||
-rwxr-xr-x | httemplate/edit/svc_acct.cgi | 41 | ||||
-rw-r--r-- | httemplate/view/elements/svc_export_settings.html | 8 | ||||
-rw-r--r-- | httemplate/view/svc_acct/basics.html | 179 | ||||
-rw-r--r-- | httemplate/view/svc_acct/tr.html | 9 |
7 files changed, 152 insertions, 143 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 1edb0d28d..b2c49b3a6 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1487,6 +1487,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 ? "<B>$svcnum</B>" : " (NEW)" %><BR> %}else{ <INPUT TYPE="hidden" NAME="clear_password" VALUE="<% $password %>"> %} -<INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $password_encoding %>"> +<INPUT TYPE="hidden" NAME="_password_encoding" VALUE="<% $svc_acct->_password_encoding %>"> % %my $sec_phrase = $svc_acct->sec_phrase; %if ( $conf->exists('security_phrase') @@ -123,6 +123,19 @@ Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR> </TR> % } + +% if ( $communigate ) { + + <TR> + <TD ALIGN="right">Aliases</TD> + <TD><INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"></TD> + </TR> + +% } else { + <INPUT TYPE="text" NAME="cgp_aliases" VALUE="<% $svc_acct->cgp_aliases %>"> +% } + + <% include('/elements/tr-select-svc_pbx.html', 'curr_value' => $svc_acct->pbxsvc, 'part_svc' => $part_svc, @@ -251,7 +264,8 @@ Service # <% $svcnum ? "<B>$svcnum</B>" : " (NEW)" %><BR> <TD ALIGN="right">Mailbox type</TD> <TD> <SELECT NAME="cgp_type"> -% foreach my $option (qw( MultiMailbox TextMailbox MailDirMailbox )) { +% foreach my $option (qw( MultiMailbox TextMailbox MailDirMailbox +% AGrade BGrade CGrade )) { <OPTION VALUE="<% $option %>" <% $option eq $svc_acct->cgp_type() ? 'SELECTED' : '' %> ><% $option %> @@ -508,22 +522,17 @@ my $svc = $part_svc->getfield('svc'); my $otaker = getotaker; my $username = $svc_acct->username; -my $password; -my $password_encryption = $svc_acct->_password_encryption; -my $password_encoding = $svc_acct->_password_encoding; - -if($svcnum) { - if($password = $svc_acct->get_cleartext_password) { - if (! $conf->exists('showpasswords')) { - $password = '*HIDDEN*'; - } - } - elsif($svc_acct->_password and $password_encryption ne 'plain') { + +my $password = ''; +if ( $cgi->param('error') ) { + $password = $cgi->param('clear_password'); +} elsif ( $svcnum ) { + my $password_encryption = $svc_acct->_password_encryption; + if ( $password = $svc_acct->get_cleartext_password ) { + $password = '*HIDDEN*' unless $conf->exists('showpasswords'); + } elsif( $svc_acct->_password and $password_encryption ne 'plain' ) { $password = "(".uc($password_encryption)." encrypted)"; } - else { - $password = ''; - } } my $ulen = diff --git a/httemplate/view/elements/svc_export_settings.html b/httemplate/view/elements/svc_export_settings.html index a3c09110f..c5f2555bd 100644 --- a/httemplate/view/elements/svc_export_settings.html +++ b/httemplate/view/elements/svc_export_settings.html @@ -3,11 +3,15 @@ % my ( $settings, $defaults ) = $svc_x->export_getsettings; % if ( keys %$settings ) { -%# XXX a way to label this "Communigate pro settings".. just a config maybe +%# a way to label this "Communigate pro settings".. just a config maybe... eh, +%# its just for devel External settings <% ntable('#cccccc',2) %> -% foreach my $key ( keys %$settings ) { +% foreach my $key ( sort {$defaults->{$a} <=> $defaults->{$b} or $a cmp $b} +% keys %$settings +% ) +% { <TR> <TD ALIGN="right"><% $key |h %></TD> <TD BGCOLOR="<% $defaults->{$key} ? '#eeeeee' : '#ffffff' %>"> diff --git a/httemplate/view/svc_acct/basics.html b/httemplate/view/svc_acct/basics.html index 6eddd492d..2b05e78a6 100644 --- a/httemplate/view/svc_acct/basics.html +++ b/httemplate/view/svc_acct/basics.html @@ -1,149 +1,100 @@ <% &ntable("#cccccc") %><TR><TD><% &ntable("#cccccc",2) %> -<TR> - <TD ALIGN="right">Service</TD> - <TD BGCOLOR="#ffffff"><% $part_svc->svc %></TD> -</TR> +<% 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) %> -<TR> - <TD ALIGN="right">Username</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->username %></TD> -</TR> - -<TR> - <TD ALIGN="right">Domain</TD> - <TD BGCOLOR="#ffffff"><% $domain %></TD> -</TR> +% if ( $opt{'communigate'} ) { + <% include('tr.html', label=>'Aliases', value=>$svc_acct->cgp_aliases) %> +%} % if ( $svc_acct->pbxsvc ) { - <TR> - <TD ALIGN="right">PBX</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->pbx_title %></TD> - </TR> + <% include('tr.html', label=>'PBX', value=>$svc_acct->pbx_title) %> %} -<TR> - <TD ALIGN="right">Password</TD> - <TD BGCOLOR="#ffffff"> +% my $show_pw = ''; % my $password = $svc_acct->get_cleartext_password; % if ( $password =~ /^\*\w+\* (.*)$/ ) { -% $password = $1; - <I>(login disabled)</I> +% $password = $1; +% $show_pw .= '<I>(login disabled)</I> '; % } -% if ( !$password and -% $svc_acct->_password_encryption ne 'plain' and -% $svc_acct->_password ) { - <I>(<% uc($svc_acct->_password_encryption) %> encrypted)</I> +% if ( ! $password +% && $svc_acct->_password_encryption ne 'plain' +% && $svc_acct->_password +% ) +% { +% $show_pw .= '<I>('. uc($svc_acct->_password_encryption). ' encrypted)</I>'; % } elsif ( $conf->exists('showpasswords') ) { - <PRE><% encode_entities($password) %></PRE> +% $show_pw .= '<PRE>'. encode_entities($password). '</PRE>'; % } else { - <I>(hidden)</I> +% $show_pw .= '<I>(hidden)</I>'; % } - </TD> -</TR> % $password = ''; +<% include('tr.html', label=>'Password', value=>$show_pw) %> + % if ( $conf->exists('security_phrase') ) { -% my $sec_phrase = $svc_acct->sec_phrase; -% - <TR> - <TD ALIGN="right">Security phrase</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->sec_phrase %></TD> - </TR> + <%include('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}); - <TR> - <TD ALIGN="right">Access number</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct_pop->text %></TD> - </TR> +% my $svc_acct_pop = qsearchs('svc_acct_pop',{'popnum'=>$svc_acct->popnum}); + <% include('tr.html', label=>'Access number', value=>$svc_acct_pop->text) %> % } % if ($svc_acct->uid ne '') { - <TR> - <TD ALIGN="right">UID</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->uid %></TD> - </TR> + <% include('tr.html', label=>'UID', value=>$svc_acct->uid) %> % } % if ($svc_acct->gid ne '') { - <TR> - <TD ALIGN="right">GID</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->gid %></TD> - </TR> + <% include('tr.html', label=>'GID', value=>$svc_acct->gid) %> % } % if ($svc_acct->finger ne '') { - <TR> - <TD ALIGN="right">Real Name</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->finger %></TD> - </TR> + <% include('tr.html', label=>'Real Name', value=>$svc_acct->finger) %> % } % if ($svc_acct->dir ne '') { - <TR> - <TD ALIGN="right">Home directory</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->dir %></TD> - </TR> + <% include('tr.html', label=>'Home directory', value=>$svc_acct->dir) %> % } % if ($svc_acct->shell ne '') { - <TR> - <TD ALIGN="right">Shell</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->shell %></TD> - </TR> + <% include('tr.html', label=>'Shell', value=>$svc_acct->shell) %> % } % if ($svc_acct->quota ne '' && ! $opt{'communigate'} ) { - <TR> - <TD ALIGN="right">Quota</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->quota %></TD> - </TR> + + <% include('tr.html', label=>'Quota', value=>$svc_acct->quota) %> + % } elsif ( $opt{'communigate'} ) { - <TR> - <TD ALIGN="right">Mailbox type</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->cgp_type %></TD> - </TR> + <% include('tr.html', label=>'Mailbox type', value=>$svc_acct->cgp_type) %> - <TR> - <TD ALIGN="right">Enabled services</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->cgp_accessmodes |h %></TD> - </TR> + <% include('tr.html', label=>'Enabled services', + value=>$svc_acct->cgp_accessmodes ) %> - <TR> - <TD ALIGN="right">Mail storage limit</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->quota %></TD> - </TR> + <% include('tr.html', label=>'Mail storage limit', + value=>$svc_acct->quota ) %> - <TR> - <TD ALIGN="right">File storage limit</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->file_quota %></TD> - </TR> + <% include('tr.html', label=>'File storage limit', + value=>$svc_acct->file_quota ) %> - <TR> - <TD ALIGN="right">Number of files limit</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->file_maxnum %></TD> - </TR> + <% include('tr.html', label=>'Number of files limit', + value=>$svc_acct->file_maxnum ) %> - <TR> - <TD ALIGN="right">File size limit</TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->file_maxsize %></TD> - </TR> + <% include('tr.html', label=>'File size limit', + value=>$svc_acct->file_maxsize ) %> % } % if ($svc_acct->slipip) { - <TR> - <TD ALIGN="right">IP address</TD> - <TD BGCOLOR="#ffffff"> - <% ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) - ? "<I>(Dynamic)</I>" - : $svc_acct->slipip - %> - </TD> - </TR> + <% include('tr.html', + label=>'IP address', + value=> ( $svc_acct->slipip eq "0.0.0.0" || $svc_acct->slipip eq '0e0' ) + ? "<I>(Dynamic)</I>" + : $svc_acct->slipip + ) + %> % } <% include('usage.html', @@ -152,27 +103,25 @@ %> % foreach my $attribute ( grep /^radius_/, $svc_acct->fields ) { -% $attribute =~ /^radius_(.*)$/; -% my $pattribute = $FS::raddb::attrib{$1}; - <TR> - <TD ALIGN="right">Radius (reply) <% $pattribute %></TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->getfield($attribute) %></TD> - </TR> - +% $attribute =~ /^radius_(.*)$/; +% my $pattribute = $FS::raddb::attrib{$1}; + <% include('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}; - <TR> - <TD ALIGN="right">Radius (check) <% $pattribute %></TD> - <TD BGCOLOR="#ffffff"><% $svc_acct->getfield($attribute) %></TD> - </TR> +% $attribute =~ /^rc_(.*)$/; +% my $pattribute = $FS::raddb::attrib{$1}; + <% include('tr.html', label=>"Radius (check) $pattribute", + value=>$svc_acct->getfield($attribute) + ) + %> % } -<TR> - <TD ALIGN="right">RADIUS groups</TD> - <TD BGCOLOR="#ffffff"><% join('<BR>', $svc_acct->radius_groups) %></TD> -</TR> +<% include('tr.html', label=>'RADIUS groups', + value=>join('<BR>', $svc_acct->radius_groups) ) %> %# Can this be abstracted further? Maybe a library function like %# widget('HTML', 'view', $svc_acct) ? It would definitely make UI diff --git a/httemplate/view/svc_acct/tr.html b/httemplate/view/svc_acct/tr.html new file mode 100644 index 000000000..e2ec7d42f --- /dev/null +++ b/httemplate/view/svc_acct/tr.html @@ -0,0 +1,9 @@ +<TR> + <TD ALIGN="right"><% $opt{'label'} %></TD> + <TD BGCOLOR="#ffffff"><% $opt{'value'} %></TD> +</TR> +<%init> + +my %opt = @_; + +</%init> |