Merge commit 'v7.10.20' into WebGUI8

This commit is contained in:
Colin Kuskie 2011-10-26 15:02:51 -07:00
commit fdb979ca8a
72 changed files with 830 additions and 224 deletions

View file

@ -1,3 +1,19 @@
7.10.20
- fixed: Do not call group methods on an undefined value.
- fixed #12178: random deletion of columns may happen when a schema is saved (Amir Plivatsky)
- fixed #12179: DataTable Field types get reset to "Text" in Edit Schema (Amir Plivatsky)
- added: FormField macro for rendering Form objects directly from templates
- fixed: Generic Tax driver does not like spaces around commas
- fixed: Date formatting with WebGUI::DateTime has extra spaces for single digit months and days.
- fixed #12165: Default date in Thingy doesn't work
- fixed #12188: Thingy broken after upgrade to 7.9.32-stable
- fixed #12184: Apache error in modperl.error.log (William McKee, Knowmad Technologies)
- fixed #12186: keywords template variable not working properly in Article
- fixed #12190: List type form plugins that do not override getOptions show no value when getValueAsHtml is called
- fixed #12135: Geo::Coder::Googlev3 needs common sense
- fixed #12183: Posts do not disqualify themselves when purged
- fixed #12189: installClass ignores preload.custom
7.10.19
- fixed #12169: extras uploads symlink export
- Added ability to pass caller assetId to RenderThingMacro

View file

@ -55,6 +55,7 @@ Contributing Developers..............C.J. Adams-Collier / <cjac@colliertech.org>
Ernesto Hernández-Novich / itverx C.A.
Stephen Opal / Plain Black
Tavis Parker / Plain Black
Amir Plivatsky
Daniel Quinlan
Jukka Raimovaara / Mentalhouse Oy
Alan Ritari / DonorWare

View file

@ -49,7 +49,7 @@ finish($session); # this line required
# print "DONE!\n" unless $quiet;
#}
#----------------------------------------------------------------------------
# Fix calendar feed urls that had adminId attached to them until they blew up
sub fixBrokenCalendarFeedUrls {
my $session = shift;

View file

@ -0,0 +1,147 @@
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
my $toVersion = '7.10.20';
my $quiet; # this line required
my $session = start(); # this line required
addFormFieldMacroToConfig();
# upgrade functions go here
fixSpacesInTaxInfo ( $session );
sub addFormFieldMacroToConfig {
print "\tAdd FormField macro to config... " unless $quiet;
$session->config->addToHash( 'macros', FormField => 'FormField' );
print "DONE!\n" unless $quiet;
}
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;
#}
#----------------------------------------------------------------------------
# Fix calendar feed urls that had adminId attached to them until they blew up
sub fixSpacesInTaxInfo {
my $session = shift;
print "\tRemoving spaces around commas in generic tax rate information... " unless $quiet;
use WebGUI::Shop::TaxDriver::Generic;
my $taxer = WebGUI::Shop::TaxDriver::Generic->new($session);
my $taxIterator = $taxer->getItems;
while (my $taxInfo = $taxIterator->hashRef) {
my $taxId = $taxInfo->{taxId};
$taxer->add($taxInfo); ##Automatically removes spaces now.
$taxer->delete({taxId => $taxId});
}
print "DONE!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
print "\tUpgrading package $file\n" unless $quiet;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = eval {
my $node = WebGUI::Asset->getImportNode($session);
$node->importPackage( $storage, {
overwriteLatest => 1,
clearPackageFlag => 1,
setDefaultTemplate => 1,
} );
};
if ($package eq 'corrupt') {
die "Corrupt package found in $file. Stopping upgrade.\n";
}
if ($@ || !defined $package) {
die "Error during package import on $file: $@\nStopping upgrade\n.";
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl

View file

@ -847,6 +847,7 @@
"FetchMimeType" : "FetchMimeType",
"FilePump" : "FilePump",
"FileUrl" : "FileUrl",
"FormField" : "FormField",
"GroupAdd" : "GroupAdd",
"GroupDelete" : "GroupDelete",
"GroupText" : "GroupText",

View file

@ -2395,6 +2395,7 @@ sub processTemplate {
%{$self->get},
'title' => $self->getTitle,
'menuTitle' => $self->getMenuTitle,
'keywords' => $self->get('keywords'),
%{$var},
);
return $template->process(\%vars);

View file

@ -1516,12 +1516,16 @@ Extend the base method to handle cleaning up storage locations.
override purge => sub {
my $self = shift;
my $sth = $self->session->db->read("select storageId from Post where assetId=".$self->session->db->quote($self->getId));
while (my ($storageId) = $sth->array) {
my $storage = WebGUI::Storage->get($self->session, $storageId);
$storage->delete if defined $storage;
my $purged = super();
if ($purged) {
my $sth = $self->session->db->read("select storageId from Post where assetId=?",[$self->getId]);
while (my ($storageId) = $sth->array) {
my $storage = WebGUI::Storage->get($self->session, $storageId);
$storage->delete if defined $storage;
}
$sth->finish;
$self->disqualifyAsLastPost;
}
$sth->finish;
return super();
};

View file

@ -1037,18 +1037,22 @@ sub getFieldValue {
my $dateFormat = shift || "%z";
my $dateTimeFormat = shift;
my $processedValue = $value;
my $dbh = $self->session->db->dbh;
my $session = $self->session;
my $dbh = $session->db->dbh;
if (lc $field->{fieldType} eq "date"){
$processedValue = $self->session->datetime->epochToHuman($value,$dateFormat);
my $fieldType = lc $field->{fieldType};
if ($fieldType eq "date"){
my $dt = WebGUI::DateTime->new($session, $value);
$processedValue = $dt->webguiDate($dateFormat);
}
elsif (lc $field->{fieldType} eq "datetime"){
$processedValue = $self->session->datetime->epochToHuman($value,$dateTimeFormat);
elsif ($fieldType eq "datetime"){
my $dt = WebGUI::DateTime->new($session, $value);
$processedValue = $dt->webguiDate($dateTimeFormat);
}
# TODO: The otherThing field type is probably also handled by getFormPlugin, so the elsif below can probably be
# safely removed. However, this requires more testing than I can provide right now, so for now this stays the
# way it was.
elsif ($field->{fieldType} =~ m/^otherThing/x) {
elsif ($field->{fieldType} =~ m/^otherthing/x) {
my $otherThingId = $field->{fieldType};
$otherThingId =~ s/^otherThing_//x;
my $tableName = 'Thingy_'.$otherThingId;

View file

@ -491,7 +491,9 @@ sub session {
Change a WebGUI format into a Strftime format.
NOTE: %M in WebGUI's format has no equivalent in strftime format, so it will
be replaced with "_varmonth_". Do something with it.
be replaced with "{month}". Single digit hours are handled similarly. DateTime's
strftime will use {method} to call a method on the object to fill in that part of
the format.
=cut
@ -514,13 +516,13 @@ sub webguiToStrftime {
"c" => "B",
"C" => "b",
"d" => "d",
"D" => "e",
"D" => "{day}",
"h" => "I",
"H" => "l",
"j" => "H",
"J" => "k",
"m" => "m",
"M" => "_varmonth_",
"M" => "{month}",
"n" => "M",
"t" => "Z",
"O" => "z",
@ -587,12 +589,7 @@ sub webguiDate {
my $format = $self->webguiToStrftime( shift || "%z %Z" );
#--- %M
my $datestr = $self->strftime($format);
my $temp = int($self->month);
$datestr =~ s/\%_varmonth_/$temp/g;
#--- return
return $datestr;
}
#######################################################################

View file

@ -17,6 +17,7 @@ package WebGUI::Form::AdSpace;
use strict;
use base 'WebGUI::Form::SelectBox';
use WebGUI::International;
use WebGUI::AdSpace;
=head1 NAME
@ -137,34 +138,19 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Returns a group pull-down field. A group pull down provides a select list that provides name value pairs for all the groups in the WebGUI system.
Extend the base "new" to set options and the default value.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $options = { map { $_->getId => $_->get('name') } ( @{ WebGUI::AdSpace->getAdSpaces($self->session) } ) };
$self->set('defaultValue', ( keys %{$options} )[0] );
$self->set('options', $options );
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
my $options = { map { $_->getId => $_->get('name') } ( @{ WebGUI::AdSpace->getAdSpaces($self->session) } ) };
$self->set('defaultValue', ( keys %{$options} )[0] );
$self->set('options', $options );
return $self->SUPER::toHtmlAsHidden();
return $self;
}
#-------------------------------------------------------------------

View file

@ -118,29 +118,33 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a select list form control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
my %types;
my $i18n = WebGUI::International->new($self->session);
foreach my $type (@{ $self->get('types') }) {
if ($type eq "text") {
$types{text} = $i18n->get(1010);
} elsif ($type eq "mixed") {
$types{mixed} = $i18n->get(1008);
} elsif ($type eq "code") {
$types{code} = $i18n->get(1011);
} elsif ($type eq "html") {
$types{html} = $i18n->get(1009);
}
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my %types;
my $i18n = WebGUI::International->new($self->session);
foreach my $type (@{ $self->get('types') }) {
if ($type eq "text") {
$types{text} = $i18n->get(1010);
}
$self->set("options", \%types);
return $self->SUPER::toHtml();
elsif ($type eq "mixed") {
$types{mixed} = $i18n->get(1008);
}
elsif ($type eq "code") {
$types{code} = $i18n->get(1011);
}
elsif ($type eq "html") {
$types{html} = $i18n->get(1009);
}
}
$self->set("options", \%types);
return $self;
}
1;

View file

@ -245,20 +245,20 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a country picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my %countries;
tie %countries, 'Tie::IxHash';
%countries = map {$_ => $_} getCountries();
$self->set("options", \%countries);
return $self->SUPER::toHtml();
$self->set('options', \%countries);
return $self;
}
1;

View file

@ -145,16 +145,17 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a database connection picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set("options", WebGUI::DatabaseLink->getList($self->session));
return $self->SUPER::toHtml();
return $self;
}
#-------------------------------------------------------------------

View file

@ -144,26 +144,27 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Returns a select list containing the content filter options. This is for use with WebGUI::HTML::filter().
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $i18n = WebGUI::International->new($self->session);
my %filter;
tie %filter, 'Tie::IxHash';
%filter = (
'none'=>$i18n->get(420),
'macros'=>$i18n->get(891),
'javascript'=>$i18n->get(526),
'most'=>$i18n->get(421),
'all'=>$i18n->get(419)
);
my %filter;
tie %filter, 'Tie::IxHash';
%filter = (
'none' => $i18n->get(420),
'macros' => $i18n->get(891),
'javascript' => $i18n->get(526),
'most' => $i18n->get(421),
'all' => $i18n->get(419),
);
$self->set("options", \%filter);
return $self->SUPER::toHtml();
return $self;
}
1;

View file

@ -186,34 +186,21 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Returns a group pull-down field. A group pull down provides a select list that provides name value pairs for all the groups in the WebGUI system.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $where = '';
if (($self->get('excludeGroups')->[0]||'') ne "") {
$where = "and groupId not in (".$self->session->db->quoteAndJoin($self->get("excludeGroups")).")";
}
$self->set('options', $self->session->db->buildHashRef("select groupId,groupName from groups where showInForms=1 $where order by groupName"));
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
$self->set("options", $self->session->db->buildHashRef("select groupId,groupName from groups"));
return $self->SUPER::toHtmlAsHidden();
return $self;
}
#-------------------------------------------------------------------

View file

@ -152,30 +152,17 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a database connection picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set("options", WebGUI::LDAPLink->getList($self->session));
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
$self->set("options", WebGUI::LDAPLink->getList($self->session));
return $self->SUPER::toHtmlAsHidden();
return $self;
}
#-------------------------------------------------------------------

View file

@ -122,15 +122,7 @@ Shows either Yes or No.
sub getValueAsHtml {
my $self = shift;
my $i18n = WebGUI::International->new($self->session,'Form_MatrixCompare');
my %options = (
0 => $i18n->get('no'),
1 => $i18n->get('limited'),
2 => $i18n->get('costs extra'),
3 => $i18n->get('free add on'),
4 => $i18n->get('yes'),
);
return $options{$self->getOriginalValue};
return $self->get('options')->{$self->getOriginalValue};
}
#-------------------------------------------------------------------
@ -147,14 +139,15 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a fieldType selector.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $i18n = WebGUI::International->new($self->session,'Form_MatrixCompare');
my %options;
tie %options, "Tie::IxHash";
@ -167,10 +160,7 @@ sub toHtml {
);
$self->set('options', \%options);
$self->set('defaultValue',0);
return $self->SUPER::toHtml();
return $self;
}
1;

View file

@ -126,27 +126,25 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a fieldType selector.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
my %options;
tie %options, "Tie::IxHash";
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my %options;
tie %options, "Tie::IxHash";
%options = (
MatrixCompare => WebGUI::Pluggable::instanciate('WebGUI::Form::MatrixCompare', 'getName',[$self->session]),
SelectBox => WebGUI::Pluggable::instanciate('WebGUI::Form::SelectBox', 'getName',[$self->session]),
Combo => WebGUI::Pluggable::instanciate('WebGUI::Form::Combo', 'getName',[$self->session]),
SelectBox => WebGUI::Pluggable::instanciate('WebGUI::Form::SelectBox', 'getName',[$self->session]),
Combo => WebGUI::Pluggable::instanciate('WebGUI::Form::Combo', 'getName',[$self->session]),
);
$self->set('options', \%options);
$self->set('defaultValue','MatrixCompare');
return $self->SUPER::toHtml();
return $self;
}
1;

View file

@ -38,6 +38,18 @@ The following methods are specifically available from this class. Check the supe
#-------------------------------------------------------------------
=head2 areOptionsSettable ( )
Returns 0.
=cut
sub areOptionsSettable {
return 0;
}
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
@ -92,24 +104,24 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a database connection picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
my $mimeTypes;
foreach ('text/html','text/css','text/javascript','text/plain','text/xml','application/xml') {
$mimeTypes->{$_}=$_;
}
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $mimeTypes;
foreach ('text/html','text/css','text/javascript','text/plain','text/xml','application/xml') {
$mimeTypes->{$_}=$_;
}
##Handle the combo box
my $value = $self->getOriginalValue();
$mimeTypes->{$value} = $value;
$self->set("options", $mimeTypes);
return $self->SUPER::toHtml();
$self->set("options", $mimeTypes);
return $self;
}
1;

View file

@ -110,24 +110,8 @@ sub new {
my $defaultValue = $self->get('defaultValue');
$defaultValue =~ tr/ /_/;
$self->set('defaultValue', $defaultValue);
$self->set("options", $self->session->datetime->getTimeZones());
return $self;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a database connection picker control.
=cut
sub toHtml {
my $self = shift;
$self->set("options", $self->session->datetime->getTimeZones());
return $self->SUPER::toHtml();
}
1;

View file

@ -141,30 +141,17 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Returns a group pull-down field. A group pull down provides a select list that provides name value pairs for all the vendors in the WebGUI system.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->set('options', WebGUI::Shop::Vendor->getVendors($self->session, {asHashRef=>1}));
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------
=head2 toHtmlAsHidden ( )
Creates a series of hidden fields representing the data in the list.
=cut
sub toHtmlAsHidden {
my $self = shift;
$self->set("options", WebGUI::Shop::Vendor->getVendors($self->session, {asHashRef=>1}));
return $self->SUPER::toHtmlAsHidden();
return $self;
}
#-------------------------------------------------------------------

View file

@ -141,14 +141,15 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 toHtml ( )
=head2 new ( )
Renders a template picker control.
Extend the base "new" to set options.
=cut
sub toHtml {
my $self = shift;
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $workflowList = WebGUI::Workflow->getList($self->session, $self->get("type"));
if ( $self->get("none") ) {
@ -157,7 +158,7 @@ sub toHtml {
}
$self->set("options", $workflowList);
return $self->SUPER::toHtml();
return $self;
}
#-------------------------------------------------------------------

View file

@ -0,0 +1,64 @@
package WebGUI::Macro::FormField;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
=head1 NAME
Package WebGUI::Macro::FormField
=head1 DESCRIPTION
Renders an instance of a Form object.
=head2 process( $session, $type, $field_name [, $default_value, @form_constructor_arguments ] )
C<$type> is one of the L<WebGUI::Form::Control> subclasses in L<WebGUI::Form>.
C<$field_name> is the name the field will be given in the HTML "name" attribute.
C<$default_value> is the currently selected value to use for the form field if no GET/POST parameter or field of the
current asset of the same name has a value.
A form posted form parameter of the same name as the C<$field_name>, if present, will be used instead of the default.
Failing that, an attribute of the current asset of the same name, if present, will be used instead of the default value.
C<@form_constructor_arguments> get passed to the L<WebGUI::Form> subclass constructor.
=cut
sub process {
my $session = shift;
my $type = shift;
my $name = shift;
my $default_value = shift || '';
my @extras = @_;
my $form_class = "WebGUI::Form::" . ucfirst $type;
my $value = $session->form->get($name);
$value ||= $session->asset->get($name) if $session->asset;
$value ||= $default_value;
my $control = eval { WebGUI::Pluggable::instanciate($form_class, 'new', [ $session, { name => $name, value => $value, @extras } ]) };
if ($@) {
$session->log->warn("FormField Macro could not load class ``$form_class'': $@");
return '';
}
return $control->toHtml;
}
1;

View file

@ -86,6 +86,10 @@ sub add {
unless exists($params->{taxRate}) and defined $params->{taxRate};
$params->{taxId} = 'new';
##Remove spaces around commas, which will break tax lookups
foreach my $param (qw/country city state code/) {
$params->{$param} =~ s/\s*,\s*/,/g;
}
my $id = $self->session->db->setRow('tax_generic_rates', 'taxId', $params);
return $id;
}
@ -213,6 +217,24 @@ sub getAllItems {
#-------------------------------------------------------------------
=head2 getItem ( $taxId )
Returns all data for one tax item as a hash reference.
=head3 $taxId
The identifier for the row of tax data to return.
=cut
sub getItem {
my $self = shift;
my $result = $self->session->db->quickHashRef('select * from tax_generic_rates where taxId=?',[shift]);
return $result;
}
#-------------------------------------------------------------------
=head2 getItems ( )
Returns a WebGUI::SQL::Result object for accessing all of the data in the tax table. This

View file

@ -711,8 +711,9 @@ sub getGroupIdsRecursive {
my $self = shift;
my $groupingIds = $self->getGroups( "withoutExpired" );
my %groupIds = map { $_ => 1 } @{ $groupingIds };
while ( my $groupingId = shift @{ $groupingIds } ) {
GROUPINGID: while ( my $groupingId = shift @{ $groupingIds } ) {
my $group = WebGUI::Group->new( $self->session, $groupingId );
next GROUPINGID unless $group;
for my $groupGroupingId ( @{ $group->getGroupsFor } ) {
if ( !$groupIds{ $groupGroupingId } ) {
push @{ $groupingIds }, $groupGroupingId;

View file

@ -456,8 +456,8 @@ ipAddress etc?|,
'default value description' => {
message => q|Enter the default value (if any) for the field. If you have defined the possible values for
this field using a hash, then the default value has to be a key in that hash, and not a value. For Yes/No fields, enter "yes" to select "Yes" and "no" to select "No".|,
lastUpdated => 1223372150,
this field using a hash, then the default value has to be a key in that hash, and not a value. For Yes/No fields, enter "yes" to select "Yes" and "no" to select "No". For Date and Date/Time fields, enter an epoch date, or a date in YYYY-MM-DD HH:MM:SS, the ISO 9601 format with optional time|,
lastUpdated => 1309814047,
},
'default value subtext' => {

View file

@ -56,6 +56,15 @@ pod2usage("$0: Must specify a configFile")
die "Config file '$configFile' does not exist!\n"
if !-f WebGUI::Paths->configBase . '/' . $configFile;
foreach my $libDir ( readLines( "preload.custom" ) ) {
if ( !-d $libDir ) {
warn "WARNING: Not adding lib directory '$libDir' from preload.custom: Directory does not exist.\n";
next;
}
unshift @INC, $libDir;
}
# Open the session
my $session = WebGUI::Session->open( $configFile );
$session->user( { userId => 3 } );
@ -96,6 +105,24 @@ else {
$session->var->end;
$session->close;
#-------------------------------------------------
sub readLines {
my $file = shift;
my @lines;
if (open(my $fh, '<', $file)) {
while (my $line = <$fh>) {
$line =~ s/#.*//;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
next if !$line;
push @lines, $line;
}
close $fh;
}
return @lines;
}
__END__
=head1 NAME

View file

@ -177,6 +177,7 @@ checkModule('App::Cmd', '0.311' );
checkModule('Devel::StackTrace', '1.27' );
checkModule('Devel::StackTrace::WithLexicals', '0.03' );
checkModule('Data::ICal', '0.16' );
checkModule('common::sense', '3.2' );
checkModule('Geo::Coder::Googlev3', '0.07' );
checkModule('IO::File::WithPath', );

File diff suppressed because one or more lines are too long

107
t/Asset/Post/purging.t Normal file
View file

@ -0,0 +1,107 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
## Test that archiving a post works, and checking side effects like updating
## lastPost information in the Thread, and CS.
use FindBin;
use strict;
use lib "$FindBin::Bin/../../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 7; # increment this value for each test you create
use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post;
use WebGUI::Asset::Post::Thread;
my $session = WebGUI::Test->session;
# Do our work in the import node
my $node = WebGUI::Asset->getImportNode($session);
# Grab a named version tag
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Collab setup"});
# Need to create a Collaboration system in which the post lives.
my @addArgs = ( undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1 } );
my $collab = $node->addChild({className => 'WebGUI::Asset::Wobject::Collaboration'}, @addArgs);
# finally, add posts and threads to the collaboration system
my $first_thread = $collab->addChild(
{ className => 'WebGUI::Asset::Post::Thread', },
undef,
WebGUI::Test->webguiBirthday,
{ skipAutoCommitWorkflows => 1, skipNotification => 1 }
);
my $second_thread = $collab->addChild(
{ className => 'WebGUI::Asset::Post::Thread', },
undef,
WebGUI::Test->webguiBirthday,
{ skipAutoCommitWorkflows => 1, skipNotification => 1 }
);
##Thread 1, Post 1 => t1p1
my $t1p1 = $first_thread->addChild(
{ className => 'WebGUI::Asset::Post', },
undef,
WebGUI::Test->webguiBirthday,
{ skipAutoCommitWorkflows => 1, skipNotification => 1 }
);
my $t1p2 = $first_thread->addChild(
{ className => 'WebGUI::Asset::Post', },
undef,
WebGUI::Test->webguiBirthday + 1,
{ skipAutoCommitWorkflows => 1, skipNotification => 1 }
);
my $past = time()-15;
my $t2p1 = $second_thread->addChild(
{ className => 'WebGUI::Asset::Post', },
undef,
$past,
{ skipAutoCommitWorkflows => 1, skipNotification => 1 }
);
my $t2p2 = $second_thread->addChild(
{ className => 'WebGUI::Asset::Post', },
undef,
undef,
{ skipAutoCommitWorkflows => 1, skipNotification => 1 }
);
$versionTag->commit();
WebGUI::Test->addToCleanup($versionTag);
foreach my $asset ($collab, $t1p1, $t1p2, $t2p1, $t2p2, $first_thread, $second_thread, ) {
$asset = $asset->cloneFromDb;
}
is $collab->getChildCount, 2, 'collab has correct number of children';
is $collab->get('lastPostId'), $t2p2->getId, 'lastPostId set in collab';
is $collab->get('lastPostDate'), $t2p2->get('creationDate'), 'lastPostDate, too';
$t2p2->purge;
$second_thread = $second_thread->cloneFromDb;
is $second_thread->get('lastPostId'), $t2p1->getId, '.. updated lastPostId in the thread';
is $second_thread->get('lastPostDate'), $t2p1->get('creationDate'), '... lastPostDate, too';
$collab = $collab->cloneFromDb;
is $collab->get('lastPostId'), $t2p1->getId, '.. updated lastPostId in the CS';
is $collab->get('lastPostDate'), $t2p1->get('creationDate'), '... lastPostDate, too';
#vim:ft=perl

View file

@ -334,6 +334,7 @@ is($printRemainingTicketsTemplateId, "hreA_bgxiTX-EzWCSZCZJw", 'Default print re
'uiLevel' => ignore(),
'tickets_loop' => \@ticketArray,
controls => ignore(),
keywords => ignore(),
},
"www_printRemainingTickets: template variables valid"
);

View file

@ -0,0 +1,84 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../../../lib";
##The goal of this test is to test editThingDataSave, particularly those things not tested in Thingy.t
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 2; # increment this value for each test you create
use Test::Deep;
use JSON;
use WebGUI::Asset::Wobject::Thingy;
use WebGUI::Search;
use WebGUI::Search::Index;
use Data::Dumper;
my $session = WebGUI::Test->session;
# Do our work in the import node
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Thingy Test"});
WebGUI::Test->addToCleanup($versionTag);
my $thingy = $node->addChild({
className => 'WebGUI::Asset::Wobject::Thingy',
groupIdView => 7,
url => 'some_thing',
});
$versionTag->commit;
$thingy = $thingy->cloneFromDb;
# Test indexThing, without needing a real thing
my $groupIdEdit = $thingy->get("groupIdEdit");
my %thingProperties = (
thingId => "THING_RECORD",
label => 'Label',
editScreenTitle => 'Edit',
editInstructions => 'instruction_edit',
groupIdAdd => $groupIdEdit,
groupIdEdit => $groupIdEdit,
saveButtonLabel => 'save',
afterSave => 'searchThisThing',
editTemplateId => "ThingyTmpl000000000003",
groupIdView => '2',
viewTemplateId => "ThingyTmpl000000000002",
defaultView => 'searchThing',
searchScreenTitle => 'Search',
searchDescription => 'description_search',
groupIdSearch => $groupIdEdit,
groupIdExport => $groupIdEdit,
groupIdImport => $groupIdEdit,
searchTemplateId => "ThingyTmpl000000000004",
thingsPerPage => 25,
);
my $thingId = $thingy->addThing(\%thingProperties);
%thingProperties = %{ $thingy->getThing($thingId) };
my $field1Id = $thingy->addField({
thingId => $thingId,
fieldId => "new",
label => "dated",
dateCreated => time(),
fieldType => "Date",
defaultValue => '2011-07-04',
status => "editable",
display => 1,
}, 0);
my $field1 = $thingy->getFields($thingId)->hashRef;
note 'getFieldValue';
is $thingy->getFieldValue(WebGUI::Test->webguiBirthday, $field1), '8/16/2001', 'with epoch as default';
is $thingy->getFieldValue('2011-07-04', $field1), '7/4/2011', 'with mysql date as default';

51
t/Asset/processTemplate.t Normal file
View file

@ -0,0 +1,51 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Test::MockAsset;
use WebGUI::Session;
use WebGUI::Asset;
use Test::More;
use Test::Deep;
use Clone qw/clone/;
plan tests => 1;
my $session = WebGUI::Test->session;
my $rootAsset = WebGUI::Asset->getRoot($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->addToCleanup($versionTag);
my $snippet = $rootAsset->addChild({keywords => 'one,two,three,four', className=>'WebGUI::Asset::Snippet'});
$versionTag->commit;
$snippet = $snippet->cloneFromDb;
##Override the user function style template so we can examine its output easily
#1234567890123456789012#
my $templateId = 'USER_STYLE_OVERRIDE___';
my $templateMock = WebGUI::Test::MockAsset->new('WebGUI::Asset::Template');
$templateMock->mock_id($templateId);
my $templateVars;
$templateMock->mock('process', sub { $templateVars = clone($_[1]); } );
{
$snippet->processTemplate({}, $templateId);
use WebGUI::Keyword;
my $keywords = WebGUI::Keyword::string2list($templateVars->{keywords});
cmp_bag($keywords, [qw/one two three four/], 'Keywords are available when running processTemplate');
}

View file

@ -24,7 +24,7 @@ my $session = WebGUI::Test->session;
# put your tests here
plan tests => 30;
plan tests => 32;
my $timeZoneUser = addUser($session);
@ -96,11 +96,15 @@ is( $nowDt->webguiToStrftime('%y-%m-%d'), '%Y-%m-%d', 'webgui to strftime conver
$timeZoneUser->update({ 'dateFormat' => '%y-%M-%D' });
$timeZoneUser->update({ 'timeFormat' => '%H:%n %p' });
is( $nowDt->webguiToStrftime, '%Y-%_varmonth_-%e %l:%M %P', 'default datetime string' );
is( $nowDt->webguiToStrftime, '%Y-%{month}-%{day} %l:%M %P', 'default datetime string' );
my $single_digit = WebGUI::DateTime->new($session, '2011-07-04 15:00:00');
is $single_digit->webguiDate("%z"), '2011-7-4', 'single digit month and day check';
is $single_digit->webguiDate("%z"), $session->datetime->epochToHuman($single_digit->epoch, '%z'), 'webguiDate, an exact match to session->datetime';
sub addUser {
my $session = shift;
my $user = WebGUI::User->new($session, "new");
##From my research, this particular time zone does NOT follow daylight savings,

View file

@ -50,8 +50,6 @@ my $html = join "\n",
$plugin->toHtml;
$footer;
diag $html;
my @forms = HTML::Form->parse($html, 'http://www.webgui.org');
##Test Form Generation

111
t/Macro/FormField.t Normal file
View file

@ -0,0 +1,111 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2011 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use HTML::TokeParser;
use HTML::Form;
use Tie::IxHash;
use WebGUI::Form_Checking;
use WebGUI::Macro::FormField;
use Test::More; # increment this value for each test you create
use Test::Deep;
use Data::Dumper;
my $session = WebGUI::Test->session;
# taken from t/Form/SelectList.t
my $testBlock = [
{
key => 'List1',
testValue => [qw/a/],
expected => 'a',
comment => 'single element array, scalar',
dataType => 'SCALAR'
},
{
key => 'List2',
testValue => [qw/a/],
expected => 'EQUAL',
comment => 'single element array, array',
dataType => 'ARRAY'
},
{
key => 'List3',
testValue => [qw/a b c/],
expected => "a\nb\nc",
comment => 'multi element array, scalar',
dataType => 'SCALAR'
},
{
key => 'List4',
testValue => [qw/a b c/],
expected => 'EQUAL',
comment => 'multi element array, array',
dataType => 'ARRAY'
},
];
my $formType = 'SelectList';
my $output;
$output = WebGUI::Macro::FormField::process(
$session, 'SelectList', 'ListMultiple', [ qw(a c e), ''], # args to macro
# args to particular Form subclass
options => { a=>'aa', b=>'bb', c=>'cc', d=>'dd', e=>'ee', ''=>'Empty' },
value => [ qw(a c e), ''],
sortByValue => 1,
);
#my $numTests = 11 + scalar @{ $testBlock } + 1;
my $numTests = 8;
plan tests => $numTests;
my ($header, $footer) = (WebGUI::Form::formHeader($session), WebGUI::Form::formFooter($session));
my $html = join "\n", $header, $output, $footer;
my @forms = HTML::Form->parse($html, 'http://www.webgui.org');
##Test Form Generation
is(scalar @forms, 1, '1 form was parsed');
my $form = $forms[0];
my @inputs = $form->inputs;
is(scalar @inputs, 8, 'The form has 8 inputs');
#Basic tests
my @options = $form->find_input('ListMultiple');
is( scalar(grep {$_->type ne 'option'} @options), 0, 'All inputs are of type option');
is( scalar(grep {$_->{multiple} ne 'multiple'} @options), 0, 'All inputs have multiple');
my @names = map { $_->name } @options;
cmp_deeply( [@names], bag(('ListMultiple')x6), 'correct number of names and names');
cmp_set([ $form->param('ListMultiple') ], [qw(a c e), ''], 'preselected values in order');
my @values = map { $_->possible_values } @options;
cmp_bag([ @values ], [qw(a b c d e), '', (undef)x6], 'list of all options');
my @value_names = map { $_->value_names } @options;
cmp_bag([ @value_names ], [qw(aa bb cc dd ee Empty), ('off')x6], 'list of all displayed value names');

View file

@ -36,9 +36,6 @@ $session->user({userId => 3});
my $addExceptions = getAddExceptions($session);
my $tests = 80 + 2*scalar(@{$addExceptions});
plan tests => $tests;
WebGUI::Test->addToCleanup(SQL => 'delete from tax_generic_rates');
#----------------------------------------------------------------------------
@ -145,6 +142,30 @@ my $dupId = $taxer->add($taxData);
$taxIterator = $taxer->getItems;
is($taxIterator->rows, 3, 'add permits adding duplicate information.');
my $spaceId = $taxer->add({
country => 'USA, United States , United States Of America ,U.S.A',
state => 'Wisconsin, WI',
city => 'MADCITY, madcity, Madison , WebGUIVille',
code => '77575, 54703 , 97424',
taxRate => '7.77',
});
my $no_spaces = $taxer->getItem($spaceId);
cmp_deeply (
$no_spaces,
{
country => 'USA,United States,United States Of America,U.S.A',
state => 'Wisconsin,WI',
city => 'MADCITY,madcity,Madison,WebGUIVille',
taxRate => '7.77',
taxId => $spaceId,
code => '77575,54703,97424',
},
'Spaces removed from content when adding'
);
$taxer->delete({taxId => $spaceId});
##Madison zip codes:
##53701-53709
##city rate: 0.5%
@ -680,4 +701,6 @@ sub getAddExceptions {
},
];
}
done_testing;
#vim:ft=perl

View file

@ -1,4 +1,5 @@
/*global WebGUI*/
// Initialize namespace
if (typeof WebGUI == "undefined") {
var WebGUI = {};
@ -49,7 +50,7 @@ WebGUI.Form.DataTable
data = {};
var columns = this.dataTable.getColumnSet().getDefinitions();
for ( var i = 0; i < columns.length; i++ ) {
data[ columns[ i ].key ] = columns[i].formatter == "date" ? new Date : "";
data[ columns[ i ].key ] = columns[i].formatter == "date" ? new Date() : "";
}
}
this.dataTable.addRow( data );
@ -85,7 +86,7 @@ WebGUI.Form.DataTable
// Get the columns
var cols = this.dataTable.getColumnSet().getDefinitions();
for ( var i = 0; i < cols.length; i++ ) {
for ( i = 0; i < cols.length; i++ ) {
data.columns[ i ] = cols[i];
delete data.columns[ i ].editor;
delete data.columns[ i ].editorOptions;
@ -459,10 +460,12 @@ WebGUI.Form.DataTable
format.name = "format_" + i;
for ( var x = 0; x < availableFormats.length; x++ ) {
var selected = cols[i].formatter == availableFormats[x].value;
var opt = new Option(
availableFormats[x].label,
availableFormats[x].value,
cols[i].formatter == availableFormats[x].value
selected,
selected
);
format.appendChild( opt );
}
@ -606,7 +609,7 @@ WebGUI.Form.DataTable
var oldKey = data[ "oldKey_" + i ];
var newKey = data[ "newKey_" + i ];
var format = data[ "format_" + i ][0];
var col = this.dataTable.getColumn( oldKey );
col = this.dataTable.getColumn( oldKey );
// Don't allow adding multiple columns with same key
if ( oldKey != newKey && this.dataTable.getColumn( newKey ) ) {
@ -618,9 +621,9 @@ WebGUI.Form.DataTable
// If the key has changed, update the row data
if ( col && col.key != newKey ) {
var rows = this.dataTable.getRecordSet().getRecords();
for ( var i = 0; i < rows.length; i++ ) {
rows[ i ].setData( newKey, rows[ i ].getData( oldKey ) );
rows[ i ].setData( oldKey, undefined );
for ( var r = 0; r < rows.length; r++ ) {
rows[ r ].setData( newKey, rows[ r ].getData( oldKey ) );
rows[ r ].setData( oldKey, undefined );
}
}
@ -655,7 +658,7 @@ WebGUI.Form.DataTable
var numRecords = allRecords.length;
for (j=0; j < numRecords; j++) {
if (format == "date") {
allRecords[j].setData(newKey, new Date);
allRecords[j].setData(newKey, new Date());
} else {
allRecords[j].setData(newKey, '');
}