X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Faccess_right.pm;h=ef8cc6cd800400e52e5a3489e103498a7b7e48c9;hb=3c54c844c665ed108c7892a154fd3972fab1f3e5;hp=cf9730d7e2294baebca632fc209efdb5c10d58c5;hpb=5e05724a635a22776f1b973f5d7e77989da4e048;p=freeside.git diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index cf9730d7e..ef8cc6cd8 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -111,12 +111,83 @@ sub check { $self->SUPER::check; } +# _upgrade_data +# +# Used by FS::Upgrade to migrate to a new database. + +sub _upgrade_data { # class method + my ($class, %opts) = @_; + + my @unmigrated = ( qsearch( 'access_right', + { 'righttype'=>'FS::access_group', + 'rightname'=>'Engineering configuration', + } + ), + qsearch( 'access_right', + { 'righttype'=>'FS::access_group', + 'rightname'=>'Engineering global configuration', + } + ) + ); + foreach ( @unmigrated ) { + my $rightname = $_->rightname; + $rightname =~ s/Engineering/Dialup/; + $_->rightname($rightname); + my $error = $_->replace; + die "Failed to update access right: $error" + if $error; + my $broadband = new FS::access_right { $_->hash }; + $rightname =~ s/Dialup/Broadband/; + $broadband->rightnum(''); + $broadband->rightname($rightname); + $error = $broadband->insert; + die "Failed to insert access right: $error" + if $error; + } + + my %migrate = ( + 'Post payment' => [ 'Post check payment', 'Post cash payment' ], + 'Process payment' => [ 'Process credit card payment', 'Process Echeck payment' ], + 'Post refund' => [ 'Post check refund', 'Post cash refund' ], + 'Refund payment' => [ 'Refund credit card payment', 'Refund Echeck payment' ], + ); + + foreach my $oldright (keys %migrate) { + my @old = qsearch('access_right', { 'righttype'=>'FS::access_group', + 'rightname'=>$oldright, + } + ); + + foreach my $old ( @old ) { + + foreach my $newright ( @{ $migrate{$oldright} } ) { + my %hash = ( + 'righttype' => 'FS::access_group', + 'rightobjnum' => $old->rightobjnum, + 'rightname' => $newright, + ); + next if qsearchs('access_right', \%hash); + my $access_right = new FS::access_right \%hash; + my $error = $access_right->insert; + die $error if $error; + } + + #after the WEST stuff is sorted, etc. + #my $error = $old->delete; + #die $error if $error; + + } + + } + + ''; + +} + =back =head1 BUGS -The author forgot to customize this manpage. - =head1 SEE ALSO L, schema.html from the base documentation.