Merge branch 'master' of git@github.com:plainblack/webgui

Conflicts:
	docs/changelog/7.x.x.txt
	docs/upgrades/upgrade_7.7.19-7.8.0.pl
This commit is contained in:
Doug Bell 2009-09-09 17:26:55 -05:00
commit 65120a61cb
21 changed files with 354 additions and 57 deletions

View file

@ -25,6 +25,10 @@
- fixed #10925: Wrong message in i18n
- relabel Help in the Admin Console to Template Help
- fixed #10928: EMS Print Ticket -- Time not processed for timezone
- fixed #10889: Old Matrixs break for Admin users
- fixed #10939: Commit with Approval workflow does not show confirmation screen
- fixed #10862: Version tag contents page
- fixed #10943: ThingyRecord JS Broken
- added Subscribable AssetAspect to Wiki
7.7.19

View file

@ -34,6 +34,7 @@ my $session = start(); # this line required
reorganizeAdSpaceProperties($session);
fixTemplateSettingsFromShunt($session);
addSubscribableAspect( $session );
addMatrixColumnDefaults($session);
finish($session); # this line required
@ -79,6 +80,18 @@ sub reorganizeAdSpaceProperties {
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
sub addMatrixColumnDefaults {
my $session = shift;
print "\tUpdate existing Matrixes with default values for maxComparisons... " unless $quiet;
$session->db->write(q|UPDATE Matrix set maxComparisons=25 where maxComparisons IS NULL|);
$session->db->write(q|UPDATE Matrix set maxComparisonsGroup=25 where maxComparisonsGroup IS NULL|);
$session->db->write(q|UPDATE Matrix set maxComparisonsPrivileged=25 where maxComparisonsPrivileged IS NULL|);
# and here's our code
print "DONE!\n" unless $quiet;
}
sub fixTemplateSettingsFromShunt {
my $session = shift;
print "\tClear isPackage and set isDefault on recently imported templates... " unless $quiet;

View file

@ -346,6 +346,26 @@ sub checkView {
#-------------------------------------------------------------------
=head2 cloneFromDb ( )
Fetches a new fresh clone of this object from the database. Often used after
calling commit on version tags.
Returns the new Asset object.
=cut
sub cloneFromDb {
my $self = shift;
return WebGUI::Asset->new($self->session,
$self->getId,
$self->get('className'),
$self->get('revisionDate')
);
}
#-------------------------------------------------------------------
=head2 definition ( session, [ definition ] )
Basic definition of an Asset. Properties, default values. Returns an array reference containing tableName,className,properties
@ -2784,11 +2804,12 @@ sub www_editSave {
$object->updateHistory("edited");
# we handle auto commit assets here in case they didn't handle it themselves
$session->log->warn('pre object isa'. ref $object);
if ($object->getAutoCommitWorkflowId) {
$session->log->warn('got autocommit workflow id');
$object->requestAutoCommit;
#Since the version tag makes new objects, fetch a fresh one here.
#Note, this workaround can still fail, if WebGUI hands off back to spectre.
$object = WebGUI::Asset->new($session, $object->getId, $object->get('className'));
$object = $object->cloneFromDb;
}
# else, try to to auto commit
else {
@ -2804,9 +2825,10 @@ sub www_editSave {
elsif ($commitStatus eq 'commit') {
##Commit was successful. Update the local object cache so that it will no longer
##register as locked.
$self->{_properties}{isLockedBy} = $object->{_properties}{isLockedBy} = undef;
$object = $object->cloneFromDb;
}
}
$session->log->warn('post object isa'. ref $object);
# Handle "saveAndReturn" button
if ( $session->form->process( "saveAndReturn" ) ne "" ) {
@ -2814,23 +2836,23 @@ sub www_editSave {
}
# Handle "proceed" form parameter
my $proceed = $self->session->form->process('proceed');
my $proceed = $session->form->process('proceed');
if ($proceed eq "manageAssets") {
$self->session->asset($object->getParent);
return $self->session->asset->www_manageAssets;
$session->asset($object->getParent);
return $session->asset->www_manageAssets;
}
elsif ($proceed eq "viewParent") {
$self->session->asset($object->getParent);
return $self->session->asset->www_view;
$session->asset($object->getParent);
return $session->asset->www_view;
}
elsif ($proceed eq "goBackToPage" && $self->session->form->process('returnUrl')) {
$self->session->http->setRedirect($self->session->form->process("returnUrl"));
elsif ($proceed eq "goBackToPage" && $session->form->process('returnUrl')) {
$session->http->setRedirect($session->form->process("returnUrl"));
return undef;
}
elsif ($proceed ne "") {
my $method = "www_".$self->session->form->process("proceed");
$self->session->asset($object);
return $self->session->asset->$method();
my $method = "www_".$session->form->process("proceed");
$session->asset($object);
return $session->asset->$method();
}
$session->asset($object->getContainer);

View file

@ -206,7 +206,7 @@ sub drawEditFieldPrice {
my ( $self ) = @_;
my $fieldHtml = sprintf <<'ENDHTML', encode_entities( $self->get('fieldPrice') );
<div id="fieldPrice"></div><input type="hidden" name="fieldPrice" value="%s" />
<div id="fieldPrice"></div><input type="hidden" name="fieldPrice" value="%s" id="fieldPrice_formId"/>
ENDHTML
return $fieldHtml;

View file

@ -889,9 +889,9 @@ sub www_editDuplicate {
# Auto-commit our revision if necessary
# TODO: This needs to be handled automatically somehow...
my $status = WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
##Force the locked by tag
##get a fresh object from the database
if ($status eq 'commit') {
$newTemplate->{_properties}{isLockedBy} = undef;
$newTemplate = $newTemplate->cloneFromDb;
}
last DEF;
}

View file

@ -472,7 +472,8 @@ sub getCompareForm {
}
else{
$maxComparisons = $self->get('maxComparisonsPrivileged');
}
}
$maxComparisons += 0;
$form .= "\n<script type='text/javascript'>\n".
'var maxComparisons = '.$maxComparisons.";\n".
"var matrixUrl = '".$self->getUrl."';\n".
@ -664,6 +665,7 @@ sub view {
else{
$maxComparisons = $self->get('maxComparisonsPrivileged');
}
$maxComparisons += 0;
$var->{maxComparisons} = $maxComparisons;
if ($self->canEdit){
@ -912,6 +914,7 @@ sub www_compare {
else{
$maxComparisons = $self->get('maxComparisonsPrivileged');
}
$maxComparisons += 0;
foreach my $listingId (@listingIds){
my $listingId_safe = $listingId;

View file

@ -221,7 +221,7 @@ sub exportAssetCollateral {
my $printSession = WebGUI::Session->open(
$self->session->config->getWebguiRoot,
$self->session->config->getFilename,
$self->session->request,
undef,
undef,
$self->session->getId,
);

View file

@ -232,7 +232,7 @@ sub exportAssetCollateral {
my $exportSession = WebGUI::Session->open(
$self->session->config->getWebguiRoot,
$self->session->config->getFilename,
$self->session->request,
undef,
undef,
$self->session->getId,
);

View file

@ -267,7 +267,6 @@ sub exportAsHtml {
my $exportSession = WebGUI::Session->open(
$session->config->getWebguiRoot,
$session->config->getFilename,
$session->request,
);
my $esGuard = Scope::Guard->new(sub {
$exportSession->var->end;
@ -503,7 +502,6 @@ sub exportGetDescendants {
$session = WebGUI::Session->open(
$session->config->getWebguiRoot,
$session->config->getFilename,
$session->request,
);
$session->user( { userId => $user->userId } );
$sGuard = Scope::Guard->new(sub {

View file

@ -792,12 +792,12 @@ sub www_manageRevisionsInTag {
. '<tr>'
. '<td colspan="5">'
. $i18n->get("manageRevisionsInTag with selected")
. '<input type="submit" name="action" value="'. $i18n->get('manageRevisionsInTag purge') . '" class="red" />'
. '<input type="submit" name="action" value="'. $i18n->get("manageRevisionsInTag move") . '" />'
. WebGUI::Form::SelectBox( $session, {
name => 'moveToTagId',
options => \%moveToTagOptions,
} )
. '&nbsp;<input type="submit" name="action" value="'. $i18n->get('manageRevisionsInTag purge') . '" class="red" />'
. '</td>'
. '</tr>'
. '<tr>'

View file

@ -252,7 +252,7 @@ sub duplicate {
my $newSession = WebGUI::Session->open(
$self->config->getWebguiRoot,
$self->config->getFilename,
$self->request,
undef,
undef,
$self->getId,
);

View file

@ -395,8 +395,8 @@ sub getObject {
push @params, $self->session;
}
push @params, $self->get("parameters");
WebGUI::Pluggable::load($class);
return $self->{_object} = $class->$method(@params);
my $object = WebGUI::Pluggable::instanciate( $class, $method, \@params );
return $self->{_object} = $object;
}
#-------------------------------------------------------------------

View file

@ -153,7 +153,7 @@ $canViewMaker->prepare(
},
);
plan tests => 113
plan tests => 115
+ scalar(@fixIdTests)
+ scalar(@fixTitleTests)
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
@ -874,6 +874,20 @@ is($testVersionTag->get('isCommitted'),1,'parent asset is now committed');
$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
is($childVersionTag->get('isCommitted'),1,'child asset is now committed');
################################################################
#
# cloneFromDb
#
################################################################
my $assetToCommit = $defaultAsset->addChild({ className => 'WebGUI::Asset::Snippet', title => 'Snippet to commit and clone from db', });
my $cloneTag = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->tagsToRollback($cloneTag);
$cloneTag->commit;
is($assetToCommit->get('status'), 'pending', 'cloneFromDb: local asset is still pending');
$assetToCommit = $assetToCommit->cloneFromDb;
is($assetToCommit->get('status'), 'approved', '... returns fresh, commited asset from the db');
##Return an array of hashrefs. Each hashref describes a test
##for the fixId method.

View file

@ -74,9 +74,8 @@ if ( !$mech->success ) {
plan skip_all => "Cannot load URL '$baseUrl'. Will not test.";
}
if ( !$ENV{WEBGUI_LIVE}) {
plan skip_all => "Live tests not enabled";
}
plan skip_all => 'set WEBGUI_LIVE to enable this test'
unless $ENV{WEBGUI_LIVE};
plan tests => 8; # Increment this number for each test you create

40
t/Form/DynamicField.t Normal file
View file

@ -0,0 +1,40 @@
#-------------------------------------------------------------------
# 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::Form;
use WebGUI::Form::FieldType;
use WebGUI::Session;
#The goal of this test is to verify that Email form elements work.
#The Email form accepts and validates an email address.
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
# put your tests here
my $formClass = 'WebGUI::Form::DynamicField';
my $numTests = 1;
plan tests => $numTests;
my $form = WebGUI::Form::DynamicField->new($session,
fieldType => 'FormTest',
);
diag "Test loading a Form from a location outside of /data/WebGUI/lib/WebGUI";
isa_ok($form, 'WebGUI::Form::FormTest');

View file

@ -22,12 +22,10 @@ use Test::More;
use Test::Deep;
use Data::Dumper;
if (!$ENV{WEBGUI_LIVE}) {
plan skip_all => 'No website available';
}
else {
plan tests => 14; # increment this value for each test you create
}
plan skip_all => 'set WEBGUI_LIVE to enable this test'
unless $ENV{WEBGUI_LIVE};
plan tests => 14; # increment this value for each test you create
my $session = WebGUI::Test->session;

View file

@ -102,9 +102,7 @@ $post2mock->set_always('getId', $post2_id);
{
# simulate asset not found
local *WebGUI::Asset::newByDynamicClass = sub {
return undef;
};
WebGUI::Test->mockAssetId($post2_id, undef);
$getmock->set_series('getNextMessage', {
from => 'admin@localhost',
parts => ['parts'],
@ -114,12 +112,11 @@ $post2mock->set_always('getId', $post2_id);
});
$activity->execute($csmock);
is $parentAsset->getId, $cs_id, 'add as new thread to current cs if reply to nonexistant post';
WebGUI::Test->unmockAssetId($post2_id);
}
{
local *WebGUI::Asset::newByDynamicClass = sub {
return $post2mock;
};
WebGUI::Test->mockAssetId($post2_id, $post2mock);
$getmock->set_series('getNextMessage', {
from => 'admin@localhost',
parts => ['parts'],
@ -129,12 +126,11 @@ $post2mock->set_always('getId', $post2_id);
});
$activity->execute($csmock);
is $parentAsset->getId, $cs_id, 'add as new thread to current cs if reply to post in another CS';
WebGUI::Test->unmockAssetId($post2_id);
}
{
local *WebGUI::Asset::newByDynamicClass = sub {
return $postmock;
};
WebGUI::Test->mockAssetId($post_id, $postmock);
$getmock->set_series('getNextMessage', {
from => 'admin@localhost',
parts => ['parts'],
@ -144,6 +140,7 @@ $post2mock->set_always('getId', $post2_id);
});
$activity->execute($csmock);
is $parentAsset->getId, $post_id, 'add as reply to post if reply to post in current CS';
WebGUI::Test->unmockAssetId($post_id);
}
#----------------------------------------------------------------------------

View file

@ -17,6 +17,8 @@ use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use Test::Deep;
use Test::Exception;
use Scope::Guard;
use Test::MockObject;
my $mockSpectre = Test::MockObject->new();
@ -46,7 +48,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 32; # Increment this number for each test you create
plan tests => 34; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@ -181,6 +183,46 @@ my $wf2 = WebGUI::Workflow->create(
my $wf2Instance = WebGUI::Workflow::Instance->create($session, {workflowId => $wf2->getId});
cmp_deeply($wf2Instance->get('parameters'), {}, 'get returns {} for parameters when there are no parameters stored');
###############################################################################
#
# getObject
#
###############################################################################
{
my $return;
Test::MockObject->fake_module('WebGUI::Test::Workflow::Instance::TestObject',
new => sub {
return $return;
},
);
my $wf3 = WebGUI::Workflow->create(
$session,
{
title => 'WebGUI::Workflow::Instance Test',
description => 'getObject test',
type => 'WebGUI::Test::Workflow::Instance::TestObject',
}
);
my $wf3guard = Scope::Guard->new(sub {
$wf3->delete;
});
my $wf3Instance = WebGUI::Workflow::Instance->create( $session, {
workflowId => $wf3->getId,
className => 'WebGUI::Test::Workflow::Instance::TestObject',
methodName => 'new',
});
dies_ok { $wf3Instance->getObject } 'getObject throws when instanciation returns undef';
$return = Test::MockObject->new;
lives_and {
is $wf3Instance->getObject, $return;
} 'getObject is able to retrieve correct object';
}
#----------------------------------------------------------------------------
# Cleanup
END {

View file

@ -0,0 +1,52 @@
package WebGUI::Form::FormTest;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::International;
=head1 NAME
Package WebGUI::Form::FormTest
=head1 DESCRIPTION
Dummy Form plugin for testing dynamic loading of Forms from other locations.
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 getName ( session )
Returns the human readable name of this control.
=cut
sub getName {
my ($self, $session) = @_;
return 'FormTest';
}
1;

View file

@ -126,6 +126,24 @@ BEGIN {
push (@INC,$WEBGUI_LIB);
##Handle custom loaded library paths
warn $WEBGUI_ROOT;
my $customPreload = File::Spec->catdir( $WEBGUI_ROOT, 'sbin', 'preload.custom');
warn $customPreload;
if (-e $customPreload) {
open my $PRELOAD, '<', $customPreload or
croak "Unload to open $customPreload: $!\n";
LINE: while (my $line = <$PRELOAD>) {
$line =~ s/#.*//;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
next LINE if !$line;
warn $line;
push @INC, $line;
}
close $PRELOAD;
}
# http://thread.gmane.org/gmane.comp.apache.apreq/3378
# http://article.gmane.org/gmane.comp.apache.apreq/3388
if ( $^O eq 'darwin' && $Config::Config{osvers} lt '8.0.0' ) {
@ -246,6 +264,100 @@ END {
}
}
=head2 mockAssetId ( $assetId, $object )
Causes WebGUI::Asset->new* initializers to return the specified
object instead of retreiving it from the database for the given
asset ID.
=cut
my %mockedAssetIds;
sub mockAssetId {
my ($class, $assetId, $object) = @_;
_mockAssetInits();
$mockedAssetIds{$assetId} = $object;
}
=head2 unmockAssetId ( $assetId )
Removes a given asset ID from being mocked.
=cut
sub unmockAssetId {
my ($class, $assetId) = @_;
delete $mockedAssetIds{$assetId};
}
=head2 mockAssetUrl ( $url, $object )
Causes WebGUI::Asset->newByUrl to return the specified object instead
of retreiving it from the database for the given URL.
=cut
my %mockedAssetUrls;
sub mockAssetUrl {
my ($url, $object) = @_;
_mockAssetInits();
$mockedAssetUrls{$url} = $object;
}
=head2 unmockAssetUrl ( $url )
Removes a given asset URL from being mocked.
=cut
sub unmockAssetUrl {
my ($class, $url) = @_;
delete $mockedAssetUrls{$url};
}
my $mockedNew;
sub _mockAssetInits {
no warnings 'redefine';
return
if $mockedNew;
require WebGUI::Asset;
my $original_new = \&WebGUI::Asset::new;
*WebGUI::Asset::new = sub {
my ($class, $session, $assetId, $className, $revisionDate) = @_;
if ($mockedAssetIds{$assetId}) {
return $mockedAssetIds{$assetId};
}
goto $original_new;
};
my $original_newByDynamicClass = \&WebGUI::Asset::newByDynamicClass;
*WebGUI::Asset::newByDynamicClass = sub {
my ($class, $session, $assetId, $revisionDate) = @_;
if ($mockedAssetIds{$assetId}) {
return $mockedAssetIds{$assetId};
}
goto $original_newByDynamicClass;
};
my $original_newPending = \&WebGUI::Asset::newPending;
*WebGUI::Asset::newPending = sub {
my ($class, $session, $assetId, $revisionDate) = @_;
if ($mockedAssetIds{$assetId}) {
return $mockedAssetIds{$assetId};
}
goto $original_newPending;
};
my $original_newByUrl = \&WebGUI::Asset::newByUrl;
*WebGUI::Asset::newByUrl = sub {
my ($class, $session, $url, $revisionDate) = @_;
if ($mockedAssetUrls{$url}) {
return $mockedAssetUrls{$url};
}
goto $original_newByUrl;
};
$mockedNew = 1;
}
#----------------------------------------------------------------------------
=head2 interceptLogging

View file

@ -15,7 +15,7 @@ WebGUI.ThingyRecord.getThingFields
var callback = {
success : function (o) {
// Add fields to select list
var el = document.forms[0].elements['thingFields'];
var el = document.getElementById('thingFields_formId');
while ( el.options.length >= 1 )
el.remove(0);
var fields = YAHOO.lang.JSON.parse( o.responseText );
@ -38,16 +38,17 @@ WebGUI.ThingyRecord.getThingFields
WebGUI.ThingyRecord.updateFieldPrices
= function ( ) {
var form = document.forms[0];
var fieldList = form.elements["thingFields"];
var fieldList = document.getElementById( 'thingFields_formId' );
var selected = [];
var div = document.getElementById( 'fieldPrice' );
var fieldPrice = document.getElementById( 'fieldPrice_formId' );
var currentPrices = {};
try {
currentPrices = YAHOO.lang.JSON.parse( form.elements["fieldPrice"].value );
currentPrices = YAHOO.lang.JSON.parse( fieldPrice.value );
}
catch (e) {
// Initialize if there's a parse error
form.elements["fieldPrice"].value = "{}";
fieldPrice.value = "{}";
}
// Get the selected fields
@ -60,7 +61,7 @@ WebGUI.ThingyRecord.updateFieldPrices
currentPrices[ opt.value ] = 0;
}
}
form.elements['fieldPrice'].value = YAHOO.lang.JSON.stringify( currentPrices );
fieldPrice.value = YAHOO.lang.JSON.stringify( currentPrices );
// Clear out old records
while ( div.childNodes.length )
@ -78,9 +79,9 @@ WebGUI.ThingyRecord.updateFieldPrices
price.value = currentPrices[ opt.value ] ? currentPrices[ opt.value ] : "0.00";
YAHOO.util.Event.addListener( price, "change", function () {
var fieldName = this.name.substr( "fieldPrice_".length );
var json = YAHOO.lang.JSON.parse( form.elements["fieldPrice"].value );
var json = YAHOO.lang.JSON.parse( fieldPrice.value );
json[fieldName] = this.value;
form.elements["fieldPrice"].value = YAHOO.lang.JSON.stringify( json );
fieldPrice.value = YAHOO.lang.JSON.stringify( json );
} );
label.appendChild( price );
@ -93,19 +94,21 @@ WebGUI.ThingyRecord.updateFieldPrices
// Load the columns and field prices
YAHOO.util.Event.onDOMReady( function () {
var form = document.forms[0];
var form = document.forms[0];
var thingId = document.getElementById("thingId_formId");
var thingFields = document.getElementById("thingFields_formId")
// Add events to form fields
YAHOO.util.Event.addListener( form.elements["thingId"], "change", function () {
YAHOO.util.Event.addListener( thingId, "change", function () {
WebGUI.ThingyRecord.getThingFields( this.value );
} );
YAHOO.util.Event.addListener( form.elements['thingFields'], "change", function () {
YAHOO.util.Event.addListener( thingFields, "change", function () {
WebGUI.ThingyRecord.updateFieldPrices();
} );
// Populate the fields list if necessary
if ( form.elements[ "thingId" ].value ) {
WebGUI.ThingyRecord.getThingFields( form.elements[ "thingId"].value );
if ( thingId.value ) {
WebGUI.ThingyRecord.getThingFields( thingId.value );
}
} );