X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Faccess_right.pm;h=bc6dd5d841aa6f44f3ffb04f4871e12847efd7d5;hp=67200f2451be0de251d1ee32f300690dc1e00923;hb=74a3083375ccc3a0dc8b74f9b39392989d088656;hpb=9509e5bfb7f9331303153cac24d7bfecbe2ea9f1 diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index 67200f245..bc6dd5d84 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -27,8 +27,8 @@ FS::access_right - Object methods for access_right records =head1 DESCRIPTION -An FS::access_right object represents an example. FS::access_right inherits from -FS::Record. The following fields are currently supported: +An FS::access_right object represents a granted access right. FS::access_right +inherits from FS::Record. The following fields are currently supported: =over 4 @@ -49,7 +49,7 @@ FS::Record. The following fields are currently supported: =item new HASHREF -Creates a new example. To add the example to the database, see L<"insert">. +Creates a new right. To add the right to the database, see L<"insert">. Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the I method. @@ -88,7 +88,7 @@ returns the error, otherwise returns false. =item check -Checks all fields to make sure this is a valid example. If there is +Checks all fields to make sure this is a valid right. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods. @@ -111,12 +111,48 @@ 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; + } + + ''; + +} + =back =head1 BUGS -The author forgot to customize this manpage. - =head1 SEE ALSO L, schema.html from the base documentation.