[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 12e83f28f47df5d3d026f136ad987135b9c99a33
Mike Robinson
miker at 420.am
Mon Apr 30 07:42:06 PDT 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via 12e83f28f47df5d3d026f136ad987135b9c99a33 (commit)
from 94a130bf73d92bcafee05565f98510c7b441515e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 12e83f28f47df5d3d026f136ad987135b9c99a33
Author: Mike Robinson <miker at freeside.biz>
Date: Mon Apr 30 09:41:40 2012 -0500
Apply 14919 netsapiens-export and check_options routines.
diff --git a/FS/FS/option_Common.pm b/FS/FS/option_Common.pm
index 26bb7ca..23d3187 100644
--- a/FS/FS/option_Common.pm
+++ b/FS/FS/option_Common.pm
@@ -66,7 +66,15 @@ sub insert {
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- my $error = $self->SUPER::insert;
+ my $error;
+
+ $error = $self->check_options($options);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $error = $self->SUPER::insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
@@ -198,7 +206,17 @@ sub replace {
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- my $error = $self->SUPER::replace($old);
+ my $error;
+
+ if ($options_supplied) {
+ $error = $self->check_options($options);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ $error = $self->SUPER::replace($old);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
@@ -275,6 +293,21 @@ sub replace {
}
+=item check_options HASHREF
+
+This method is called by 'insert' and 'replace' to check the options that were supplied.
+
+Return error-message, or false.
+
+(In this class, this is a do-nothing routine that always returns false. Override as necessary. No need to call superclass.)
+
+=cut
+
+sub check_options {
+ my ($self, $options) = @_;
+ '';
+}
+
=item option_objects
Returns all options as FS::I<tablename>_option objects.
diff --git a/FS/FS/part_export/netsapiens.pm b/FS/FS/part_export/netsapiens.pm
index 867c19a..b30951d 100644
--- a/FS/FS/part_export/netsapiens.pm
+++ b/FS/FS/part_export/netsapiens.pm
@@ -5,6 +5,7 @@ use MIME::Base64;
use Tie::IxHash;
use FS::part_export;
use Date::Format qw( time2str );
+use Regexp::Common qw/URI/;
@ISA = qw(FS::part_export);
$me = '[FS::part_export::netsapiens]';
@@ -80,6 +81,22 @@ END
sub rebless { shift; }
+
+sub check_options {
+ my ($self, $options) = @_;
+
+ my $rex = qr/$RE{URI}{HTTP}{-scheme => qr|https?|}/; # match any "http:" or "https:" URL
+
+ for my $key (qw/url device_url/) {
+ if ($$options{$key} && ($$options{$key} !~ $rex)) {
+ return "Invalid (URL): " . $$options{$key};
+ }
+ }
+ return '';
+}
+
+
+
sub ns_command {
my $self = shift;
$self->_ns_command('', @_);
-----------------------------------------------------------------------
Summary of changes:
FS/FS/option_Common.pm | 37 +++++++++++++++++++++++++++++++++++--
FS/FS/part_export/netsapiens.pm | 17 +++++++++++++++++
2 files changed, 52 insertions(+), 2 deletions(-)
More information about the freeside-commits
mailing list