+ $settings{$quotas{$_}} = $new->$_()
+ foreach grep $old->$_() ne $new->$_(), keys %quotas;
+ $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;
+
+ $settings{'PasswordRecovery'} = ( $new->password_recover ? 'YES':'NO' )
+ if $old->password_recover ne $new->password_recover;
+
+ $settings{'RulesAllowed'} = $new->cgp_rulesallowed
+ if $old->cgp_rulesallowed ne $new->cgp_rulesallowed;
+ $settings{'RPOPAllowed'} = ( $new->cgp_rpopallowed ? 'YES':'NO' )
+ if $old->cgp_rpopallowed ne $new->cgp_rpopallowed;
+ $settings{'MailToAll'} = ( $new->cgp_mailtoall ? 'YES':'NO' )
+ if $old->cgp_mailtoall ne $new->cgp_mailtoall;
+ $settings{'AddMailTrailer'} = ( $new->cgp_addmailtrailer ? 'YES':'NO' )
+ if $old->cgp_addmailtrailer ne $new->cgp_addmailtrailer;
+ $settings{'ArchiveMessagesAfter'} = $new->cgp_archiveafter
+ if $old->cgp_archiveafter ne $new->cgp_archiveafter;
+
+ #XXX phase 3: mailing lists
+
+ if ( keys %settings ) {
+ my $error = $self->communigate_pro_queue(
+ $new->svcnum,
+ 'UpdateAccountSettings',
+ $self->export_username($new),
+ %settings,
+ );
+ return $error if $error;
+ }
+
+ #preferences
+ my %prefs = ();
+ $prefs{'DeleteMode'} = $new->cgp_deletemode
+ if $old->cgp_deletemode ne $new->cgp_deletemode;
+ $prefs{'EmptyTrash'} = $new->cgp_emptytrash
+ if $old->cgp_emptytrash ne $new->cgp_emptytrash;
+ $prefs{'Language'} = $new->cgp_language
+ if $old->cgp_language ne $new->cgp_language;
+ $prefs{'TimeZone'} = $new->cgp_timezone
+ if $old->cgp_timezone ne $new->cgp_timezone;
+ $prefs{'SkinName'} = $new->cgp_skinname
+ if $old->cgp_skinname ne $new->cgp_skinname;
+ $prefs{'ProntoSkinName'} = $new->cgp_prontoskinname
+ if $old->cgp_prontoskinname ne $new->cgp_prontoskinname;
+ $prefs{'SendMDNMode'} = $new->cgp_sendmdnmode
+ if $old->cgp_sendmdnmode ne $new->cgp_sendmdnmode;
+ if ( keys %prefs ) {
+ my $pref_err = $self->communigate_pro_queue( $new->svcnum,
+ 'UpdateAccountPrefs',
+ $self->export_username($new),
+ %prefs,
+ );
+ warn "WARNING: error queueing UpdateAccountPrefs job: $pref_err"
+ if $pref_err;
+ }
+
+ if ( $old->cgp_aliases ne $new->cgp_aliases ) {
+ my $error = $self->communigate_pro_queue(
+ $new->svcnum,
+ 'SetAccountAliases',
+ $self->export_username($new),
+ [ split(/\s*[,\s]\s*/, $new->cgp_aliases) ],
+ );
+ return $error if $error;
+ }
+
+ my $rule_error = $self->communigate_pro_queue(
+ $new->svcnum,
+ 'SetAccountMailRules',
+ $self->export_username($new),
+ $new->cgp_rule_arrayref,
+ );
+ warn "WARNING: error queueing SetAccountMailRules job: $rule_error"
+ if $rule_error;
+
+ my $rpop_error = $self->communigate_pro_queue(
+ $new->svcnum,
+ 'SetAccountRPOPs',
+ $self->export_username($new),
+ $new->cgp_rpop_hashref,
+ );
+ warn "WARNING: error queueing SetAccountMailRPOPs job: $rpop_error"
+ if $rpop_error;
+
+ '';
+
+}
+
+sub _export_replace_svc_domain {
+ my( $self, $new, $old ) = (shift, shift, shift);
+
+ #let's just do the rename part realtime rather than trying to queue
+ #w/dependencies. we don't want FS winding up out-of-sync with the wrong
+ #username and a queued job anyway. right??
+ if ( $old->domain ne $new->domain ) {
+ eval { $self->communigate_pro_runcommand(
+ 'RenameDomain', $old->domain, $new->domain,
+ ) };
+ return $@ if $@;
+ }
+
+ my %settings = ();
+ $settings{'AccountsLimit'} = $new->max_accounts
+ if $old->max_accounts ne $new->max_accounts;
+ $settings{'TrailerText'} = $new->trailer
+ if $old->trailer ne $new->trailer;
+ $settings{'DomainAccessModes'} = $new->cgp_accessmodes
+ if $old->cgp_accessmodes ne $new->cgp_accessmodes;
+ $settings{'AdminDomainName'} =
+ $new->parent_svcnum ? $new->parent_svc_x->domain : ''
+ if $old->parent_svcnum != $new->parent_svcnum;
+ $settings{'CertificateType'} = $new->cgp_certificatetype
+ if $old->cgp_certificatetype ne $new->cgp_certificatetype;
+
+ if ( keys %settings ) {
+ my $error = $self->communigate_pro_queue( $new->svcnum,
+ 'UpdateDomainSettings',
+ $new->domain,
+ %settings,
+ );
+ return $error if $error;
+ }
+
+ if ( $old->cgp_aliases ne $new->cgp_aliases ) {
+ my $error = $self->communigate_pro_queue( $new->svcnum,
+ 'SetDomainAliases',
+ $new->domain,
+ split(/\s*[,\s]\s*/, $new->cgp_aliases),
+ );
+ return $error if $error;
+ }
+
+ #below this identical to insert... any value to doing an Update here?
+ #not seeing any big one... i guess it would be nice to avoid the update
+ #when things haven't changed
+
+ #account defaults
+ my $def_err = $self->communigate_pro_queue( $new->svcnum,
+ 'SetAccountDefaults',
+ $new->domain,
+ 'PWDAllowed' => ( $new->acct_def_password_selfchange ? 'YES' : 'NO' ),
+ 'PasswordRecovery' => ( $new->acct_def_password_recover ? 'YES' : 'NO' ),
+ 'AccessModes' => $new->acct_def_cgp_accessmodes,
+ 'MaxAccountSize' => $new->acct_def_quota,
+ 'MaxWebSize' => $new->acct_def_file_quota,
+ 'MaxWebFile' => $new->acct_def_file_maxnum,
+ 'MaxFileSize' => $new->acct_def_file_maxsize,
+ 'RulesAllowed' => $new->acct_def_cgp_rulesallowed,
+ 'RPOPAllowed' => ( $new->acct_def_cgp_rpopallowed ? 'YES' : 'NO' ),
+ 'MailToAll' => ( $new->acct_def_cgp_mailtoall ? 'YES' : 'NO' ),
+ 'AddMailTrailer' => ( $new->acct_def_cgp_addmailtrailer ? 'YES' : 'NO' ),
+ 'ArchiveMessagesAfter' => $new->acct_def_cgp_archiveafter,
+ );
+ warn "WARNING: error queueing SetAccountDefaults job: $def_err"
+ if $def_err;
+
+ #account defaults prefs
+ my $pref_err = $self->communigate_pro_queue( $new->svcnum,
+ 'SetAccountDefaultPrefs',
+ $new->domain,
+ 'DeleteMode' => $new->acct_def_cgp_deletemode,
+ 'EmptyTrash' => $new->acct_def_cgp_emptytrash,
+ 'Language' => $new->acct_def_cgp_language,
+ 'TimeZone' => $new->acct_def_cgp_timezone,
+ 'SkinName' => $new->acct_def_cgp_skinname,
+ 'ProntoSkinName' => $new->acct_def_cgp_prontoskinname,
+ 'SendMDNMode' => $new->acct_def_cgp_sendmdnmode,
+ );
+ warn "WARNING: error queueing SetAccountDefaultPrefs job: $pref_err"
+ if $pref_err;
+
+ my $rule_error = $self->communigate_pro_queue(
+ $new->svcnum,
+ 'SetDomainMailRules',
+ $new->domain,
+ $new->cgp_rule_arrayref,
+ );
+ warn "WARNING: error queueing SetDomainMailRules job: $rule_error"
+ if $rule_error;
+
+ '';
+}
+
+sub _export_replace_svc_forward {
+ my( $self, $new, $old ) = (shift, shift, shift);
+
+ my $osrc = $old->src || $old->srcsvc_acct->email;
+ my $nsrc = $new->src || $new->srcsvc_acct->email;
+ my $odst = $old->dst || $old->dstsvc_acct->email;
+ my $ndst = $new->dst || $new->dstsvc_acct->email;
+
+ if ( $odst ne $ndst ) {
+
+ #no change command, so delete and create (real-time)
+ eval { $self->communigate_pro_runcommand('DeleteForwarder', $osrc) };
+ return $@ if $@;
+ eval { $self->communigate_pro_runcommand('CreateForwarder', $nsrc, $ndst)};
+ return $@ if $@;
+
+ } elsif ( $osrc ne $nsrc ) {
+
+ #real-time here, presuming CGP does some dup detection?
+ eval { $self->communigate_pro_runcommand( 'RenameForwarder', $osrc, $nsrc)};
+ return $@ if $@;
+
+ } else {
+ warn "communigate replace called for svc_forward with no changes\n";#confess
+ }
+
+ '';
+}
+
+sub _export_replace_svc_mailinglist {
+ my( $self, $new, $old ) = (shift, shift, shift);
+
+ my $oldGroupName = $old->username.'@'.$old->domain;
+ my $newGroupName = $new->username.'@'.$new->domain;
+
+ if ( $oldGroupName ne $newGroupName ) {
+ eval { $self->communigate_pro_runcommand(
+ 'RenameGroup', $oldGroupName, $newGroupName ); };
+ return $@ if $@;
+ }