diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 173e1ec32..fcd706631 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,7 @@ - fixed: unable to purge trash - fixed: EMS not displaying all users with a badge - fixed: ems 2.0: ticket import/export borked + - Exposed user and url fields to shop vendors. - fixed: ems 2.0: code cleanup - fixed: WebGUI::Search - joinClass not documented - fixed: thingy's checkbox field diff --git a/docs/upgrades/upgrade_7.5.18-7.5.19.pl b/docs/upgrades/upgrade_7.5.18-7.5.19.pl index d598cf620..8faeac07d 100644 --- a/docs/upgrades/upgrade_7.5.18-7.5.19.pl +++ b/docs/upgrades/upgrade_7.5.18-7.5.19.pl @@ -35,17 +35,17 @@ updateAddressTable( $session ); addProductShipping( $session ); addGalleryImageDensity( $session ); updatePaymentDrivers( $session ); +extendVendors($session); finish($session); # this line required #---------------------------------------------------------------------------- -# Describe what our function does -#sub exampleFunction { -# my $session = shift; -# print "\tWe're doing some stuff here that you should know about... " unless $quiet; -# # and here's our code -# print "DONE!\n" unless $quiet; -#} +sub extendVendors { + my $session = shift; + print "\tExtending vendor properties..." unless $quiet; + $session->db->write("alter table vendor add column url text"); + print "DONE!\n" unless $quiet; +} # Rename Thingy_fields subtext column sub renameThingyFieldsSubtextColumn { diff --git a/lib/WebGUI/Form/Url.pm b/lib/WebGUI/Form/Url.pm index 558d9b69c..fe47b686a 100644 --- a/lib/WebGUI/Form/Url.pm +++ b/lib/WebGUI/Form/Url.pm @@ -90,16 +90,24 @@ sub getValue { my $self = shift; my $value = $self->SUPER::getValue(@_); $value =~ tr/\r\n//d; - if ($value =~ /mailto:/) { - return $value; - } - elsif ($value =~ /^([A-Z0-9]+[._+-]?){1,}([A-Z0-9]+[_+-]?)+\@(([A-Z0-9]+[._-]?){1,}[A-Z0-9]+\.){1,}[A-Z]{2,4}$/i) { - return "mailto:".$value; - } - elsif ($value =~ /^\// || $value =~ /:\/\// || $value =~ /^\^/) { - return $value; - } - return "http://".$value; + # empty + if ($value eq "" || $value =~ m{^http://$}i) { + return undef; + } + # proper email url + elsif ($value =~ /mailto:/) { + return $value; + } + # improper email url + elsif ($value =~ /^([A-Z0-9]+[._+-]?){1,}([A-Z0-9]+[_+-]?)+\@(([A-Z0-9]+[._-]?){1,}[A-Z0-9]+\.){1,}[A-Z]{2,4}$/i) { + return "mailto:".$value; + } + # proper web url + elsif ($value =~ /^\// || $value =~ /:\/\// || $value =~ /^\^/) { + return $value; + } + # improper web url + return "http://".$value; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Shop/Vendor.pm b/lib/WebGUI/Shop/Vendor.pm index 2b3e3213d..2f816388b 100644 --- a/lib/WebGUI/Shop/Vendor.pm +++ b/lib/WebGUI/Shop/Vendor.pm @@ -200,7 +200,7 @@ The name of the vendor. sub update { my ($self, $newProperties) = @_; my $id = id $self; - my @fields = (qw(name)); + my @fields = (qw(name userId url)); foreach my $field (@fields) { $properties{$id}{$field} = (exists $newProperties->{$field}) ? $newProperties->{$field} : $properties{$id}{$field}; } @@ -253,7 +253,9 @@ sub www_edit { $f->hidden(name=>'method',value=>'editSave'); $f->hidden(name=>'vendorId',value=>$properties->{vendorId}); $f->readOnly(label=>$i18n->get('date created'),value=>$properties->{dateCreated}); - $f->text(name=>'name', label=>$i18n->get('name'),defaultValue=>$properties->{name}); + $f->text(name=>'name', label=>$i18n->get('name'),value=>$properties->{name}); + $f->user(name=>'userId',label=>$i18n->get('username'),value=>$properties->{userId},defaultValue=>3); + $f->url(name=>'url', label=>$i18n->get('company url'),value=>$properties->{url}); $f->submit(); # Wrap in admin console @@ -276,6 +278,8 @@ sub www_editSave { my $form = $session->form; my $properties = { name => $form->get("name","text"), + userId => $form->get("userId","user",'3'), + url => $form->get("url","url"), }; my $self = eval{$class->new($session, $form->get("vendorId"))}; if (!WebGUI::Error->caught && defined $self) { diff --git a/lib/WebGUI/i18n/English/Shop.pm b/lib/WebGUI/i18n/English/Shop.pm index a3bf606b7..704e109bf 100644 --- a/lib/WebGUI/i18n/English/Shop.pm +++ b/lib/WebGUI/i18n/English/Shop.pm @@ -831,6 +831,12 @@ our $I18N = { context => q|a button a user clicks on to remove an item from the cart| }, + 'company url' => { + message => q|Company URL|, + lastUpdated => 0, + context => q|a field in the vendor screen| + }, + 'checkout button' => { message => q|Checkout|, lastUpdated => 0,