Merge commit 'bfe9780ce0' into WebGUI8. Merged up to 7.10.3

This commit is contained in:
Colin Kuskie 2010-11-02 14:49:33 -07:00
commit a90eadda7c
37 changed files with 537 additions and 92 deletions

View file

@ -1,3 +1,22 @@
7.10.3
- fixed #11903: Unnecessary debug in Thingy
- fixed #11908: Inbox messages linger after deleting a user
- fixed #11909: Wrong message count in the inbox
- fixed #11773: Form injection in the EMS event ordering code.
- fixed #11773: SQL injection vulnerability in Edit Thing form processing code.
- fixed #11906: Carousel slide height problems
- fixed #11900: Request Approval for Version Tag Workflow activity can't select --Continue with this workflow
- fixed #11898: String eval used in Image::Graph
- fixed #11913: Editing the survey doesn't work
- fixed #11915: Date macro returns hour value w/ leading space
- fixed #11901: NotifyAboutVersionTag includes URL, even when inappropriate
- fixed #11902: forums bug
- fixed #11912: Corrupt cookie causes server 500 errors
- fixed #11919: Survey rendering with section text
- fixed #11916: Collaboration System security
- fixed #11918: Make password recovery email templatable
- fixed #11905: CrystalX nav breaks with 3rd level assets
7.10.2 7.10.2
- fixed #11884: Editing Templates impossible / Code editor not loaded - fixed #11884: Editing Templates impossible / Code editor not loaded
- recommitted ukplayer. Removal broke Matrix. Licencing information was available but overlooked. - recommitted ukplayer. Removal broke Matrix. Licencing information was available but overlooked.

View file

@ -7,7 +7,8 @@ The following people/companies are responsible for WebGUI:
WebGUI Core..........................JT Smith / Plain Black WebGUI Core..........................JT Smith / Plain Black
Contributing Developers..............Meg O'Keefe Andrea / Plain Black Contributing Developers..............C.J. Adams-Collier / <cjac@colliertech.org>
Meg O'Keefe Andrea / Plain Black
Lucas Bartholemy Lucas Bartholemy
Peter Beardsley / Appropriate Solutions Peter Beardsley / Appropriate Solutions
Doug Bell / Plain Black Doug Bell / Plain Black

View file

@ -21,6 +21,14 @@ save you many hours of grief.
Account Macro template Account Macro template
Admin Toggle Macro template Admin Toggle Macro template
7.10.3
--------------------------------------------------------------------
* In the Collaboration System, previously the Group to Post group
was also allowed to view the CS. This made it difficult to
make the CS not viewable to regular users, so the behavior was
removed in 7.10.3. If your site depended on the Group To Post being
able to view the CS, then make the it a sub-group of Group To View.
7.10.2 7.10.2
-------------------------------------------------------------------- --------------------------------------------------------------------
* The URL used by Display Message on Login always returns the user to * The URL used by Display Message on Login always returns the user to

View file

@ -1,6 +1,7 @@
This is a running list of template changes made during upgrades. If you have copied the default This is a running list of template changes made during upgrades. If you have copied the default
templates, you will need to apply these changes manually to your copies. templates, you will need to apply these changes manually to your copies.
7.8.0 7.8.0
* Account Macro template variables renamed: * Account Macro template variables renamed:
@ -11,6 +12,21 @@ templates, you will need to apply these changes manually to your copies.
toggle.url => toggle_url toggle.url => toggle_url
toggle.text => toggle_text toggle.text => toggle_text
7.10.3
* Carousel Default Template - root/import/carousel/carousel-default
Add a height parameter to the template.
* survey.css
Removed relative positioning and offset from top.
* root/import/survey/surveyedit.css
Reexported the package from the default content due to potential issues with earlier upgrades
not installing correctly.
* root/import/workflow-activity-templates
Added a folder to hold the assorted Workflow Activity templates.
7.10.2 7.10.2
* The Make Page Printable template has changed (as per bug #11857). The HTML * The Make Page Printable template has changed (as per bug #11857). The HTML

Binary file not shown.

Binary file not shown.

View file

@ -22,6 +22,7 @@ use Getopt::Long;
use WebGUI::Session; use WebGUI::Session;
use WebGUI::Storage; use WebGUI::Storage;
use WebGUI::Asset; use WebGUI::Asset;
use WebGUI::Inbox;
my $toVersion = '7.10.2'; my $toVersion = '7.10.2';

View file

@ -0,0 +1,172 @@
#!/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.3';
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
pruneInboxMessagesFromDeletedUsers($session);
addTemplateToNotifyAboutVersionTag($session);
addPasswordRecoveryEmailTemplate($session);
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
sub pruneInboxMessagesFromDeletedUsers {
my $session = shift;
print "\tPruning inbox messages from deleted users. This may take a while... " unless $quiet;
my $sth = $session->db->prepare(<<EOSQL);
select messageId, inbox.userId
from inbox_messageState
join inbox using (messageId)
left outer join users on inbox.userId=users.userId
where users.userId IS NULL
EOSQL
$sth->execute([]);
use WebGUI::Inbox;
my $inbox = WebGUI::Inbox->new($session);
while (my ($messageId, $userId) = $sth->array) {
my $message = $inbox->getMessage($messageId, $userId);
if ($message) {
$message->delete;
}
}
print "...DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
sub addTemplateToNotifyAboutVersionTag {
my $session = shift;
print "\tAdd template to Notify About Version Tag workflow activities." unless $quiet;
use WebGUI::Workflow::Activity;
use WebGUI::Workflow::Activity::NotifyAboutVersionTag;
my $templateId = WebGUI::Workflow::Activity::NotifyAboutVersionTag->definition($session)->[0]->{properties}->{templateId}->{defaultValue};
my $activityList = $session->db->read(q|select activityId from WorkflowActivity|);
while (my ($activityId) = $activityList->array) {
my $activity = WebGUI::Workflow::Activity->new($session, $activityId);
next unless $activity;
next unless $activity->isa('WebGUI::Workflow::Activity::NotifyAboutVersionTag')
|| $activity->isa('WebGUI::Workflow::Activity::RequestApprovalForVersionTag')
;
$activity->set('templateId', $templateId);
}
print "...DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Describe what our function does
sub addPasswordRecoveryEmailTemplate {
my $session = shift;
print "\tAdd a template for the password recovery email." unless $quiet;
$session->setting->add('webguiPasswordRecoveryEmailTemplate', 'sK_0zVw4kwdJ1sqREIsSzA');
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

@ -22,6 +22,7 @@ our $STATUS = 'beta';
use strict; use strict;
use Moose; use Moose;
use MooseX::NonMoose; use MooseX::NonMoose;
use Scalar::Util qw/blessed/;
use WebGUI::Config; use WebGUI::Config;
use WebGUI::Pluggable; use WebGUI::Pluggable;
use WebGUI::Paths; use WebGUI::Paths;

View file

@ -857,25 +857,6 @@ sub canStartThread {
} }
#-------------------------------------------------------------------
=head2 canView ( [ $userId ] )
Extends the base method to also allow users who canPost to the CS.
=head3 $userId
A userId to check for edit permissions. If $userId is false, then it checks
the current session user.
=cut
sub canView {
my $self = shift;
my $userId = shift || $self->session->user->userId;
return $self->next::method( $userId ) || $self->canPost( $userId );
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 commit =head2 commit

View file

@ -2463,7 +2463,8 @@ Method to move an event down one position in display order
sub www_moveEventMetaFieldDown { sub www_moveEventMetaFieldDown {
my $self = shift; my $self = shift;
return $self->session->privilege->insufficient unless ($self->canEdit); return $self->session->privilege->insufficient unless ($self->canEdit);
$self->moveCollateralDown('EMSEventMetaField', 'fieldId', $self->session->form->get("fieldId")); my $fieldId = $self->session->form->get("fieldId");
$self->moveCollateralDown('EMSEventMetaField', 'fieldId', $fieldId);
return $self->www_manageEventMetaFields; return $self->www_manageEventMetaFields;
} }
@ -2478,7 +2479,8 @@ Method to move an event metdata field up one position in display order
sub www_moveEventMetaFieldUp { sub www_moveEventMetaFieldUp {
my $self = shift; my $self = shift;
return $self->session->privilege->insufficient unless ($self->canEdit); return $self->session->privilege->insufficient unless ($self->canEdit);
$self->moveCollateralUp('EMSEventMetaField', 'fieldId', $self->session->form->get("fieldId")); my $fieldId = $self->session->form->get("fieldId");
$self->moveCollateralUp('EMSEventMetaField', 'fieldId', $fieldId);
return $self->www_manageEventMetaFields; return $self->www_manageEventMetaFields;
} }

View file

@ -424,8 +424,6 @@ sub copyThingData {
return undef unless $self->canEditThingData($thingId, $thingDataId); return undef unless $self->canEditThingData($thingId, $thingDataId);
my $origCollateral = $self->getCollateral("Thingy_".$thingId, "thingDataId", $thingDataId); my $origCollateral = $self->getCollateral("Thingy_".$thingId, "thingDataId", $thingDataId);
use Data::Dumper;
$session->log->warn(Dumper $origCollateral);
$origCollateral->{thingDataId} = "new"; $origCollateral->{thingDataId} = "new";
##Get all fields ##Get all fields
my $fields = $db->buildArrayRefOfHashRefs('select * from Thingy_fields where assetId=? and thingId=?' my $fields = $db->buildArrayRefOfHashRefs('select * from Thingy_fields where assetId=? and thingId=?'
@ -2147,7 +2145,7 @@ sub www_editThingSave {
my $displayInSearch = $self->session->form->process("displayInSearch_".$field->{fieldId}) || 0; my $displayInSearch = $self->session->form->process("displayInSearch_".$field->{fieldId}) || 0;
my $searchIn = $self->session->form->process("searchIn_".$field->{fieldId}) || 0; my $searchIn = $self->session->form->process("searchIn_".$field->{fieldId}) || 0;
$self->session->db->write("update Thingy_fields set display = ".$display.", viewScreenTitle = ".$viewScreenTitle.", displayinSearch = ".$displayInSearch.", searchIn = ".$searchIn." where fieldId = ".$self->session->db->quote($field->{fieldId})." and thingId = ".$self->session->db->quote($thingId)); $self->session->db->write("update Thingy_fields set display = ?, viewScreenTitle = ?, displayinSearch = ?, searchIn = ? where fieldId = ? and thingId = ?",[$display, $viewScreenTitle, $displayInSearch, $searchIn, $field->{fieldId}, $thingId]);
} }
return $self->www_manage; return $self->www_manage;
} }
@ -2588,9 +2586,6 @@ sub www_editThingDataSaveViaAjax {
} }
my $thingProperties = $self->getThing($thingId); my $thingProperties = $self->getThing($thingId);
use Data::Dumper;
warn $thingId;
warn Dumper $thingProperties;
if ($thingProperties->{thingId}){ if ($thingProperties->{thingId}){
return $session->privilege->insufficient() unless $self->canEditThingData($thingId, $thingDataId return $session->privilege->insufficient() unless $self->canEditThingData($thingId, $thingDataId
,$thingProperties); ,$thingProperties);

View file

@ -21,6 +21,7 @@ use WebGUI::Mail::Send;
use WebGUI::Storage; use WebGUI::Storage;
use WebGUI::User; use WebGUI::User;
use WebGUI::Form::Captcha; use WebGUI::Form::Captcha;
use WebGUI::Macro;
use Encode (); use Encode ();
use Tie::IxHash; use Tie::IxHash;
@ -609,6 +610,13 @@ sub editUserSettingsForm {
-label => $i18n->get("password recovery template"), -label => $i18n->get("password recovery template"),
-hoverHelp => $i18n->get("password recovery template help") -hoverHelp => $i18n->get("password recovery template help")
); );
$f->template(
-name => "webguiPasswordRecoveryEmailTemplate",
-value => $self->session->setting->get('webguiPasswordRecoveryEmailTemplate'),
-label => $i18n->get('Password Recovery Email Template'),
-hoverHelp => $i18n->get("password recovery email template help"),
-namespace => "Auth/WebGUI/RecoveryEmail",
);
$f->template( $f->template(
-name => "webguiWelcomeMessageTemplate", -name => "webguiWelcomeMessageTemplate",
-value => $self->session->setting->get("webguiWelcomeMessageTemplate"), -value => $self->session->setting->get("webguiWelcomeMessageTemplate"),
@ -678,6 +686,8 @@ sub editUserSettingsFormSave {
$s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template")); $s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template"));
$s->set("webguiWelcomeMessageTemplate", $f->process("webguiWelcomeMessageTemplate","template")); $s->set("webguiWelcomeMessageTemplate", $f->process("webguiWelcomeMessageTemplate","template"));
$s->set("webguiAccountActivationTemplate", $f->process("webguiAccountActivationTemplate","template")); $s->set("webguiAccountActivationTemplate", $f->process("webguiAccountActivationTemplate","template"));
$s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template"));
$s->set("webguiPasswordRecoveryEmailTemplate", $f->process("webguiPasswordRecoveryEmailTemplate","template"));
if (@errors) { if (@errors) {
return \@errors; return \@errors;
@ -1107,7 +1117,6 @@ sub emailRecoverPasswordFinish {
# generate information necessry to proceed # generate information necessry to proceed
my $recoveryGuid = $session->id->generate(); my $recoveryGuid = $session->id->generate();
my $url = $session->url->getSiteURL;
my $userId = $user->userId; #get the user guid my $userId = $user->userId; #get the user guid
$email = $user->profileField('email'); $email = $user->profileField('email');
@ -1121,7 +1130,12 @@ sub emailRecoverPasswordFinish {
$self->update($authsettings); $self->update($authsettings);
my $mail = WebGUI::Mail::Send->create($session, { to=>$email, subject=>$i18n->get('WebGUI password recovery')}); my $mail = WebGUI::Mail::Send->create($session, { to=>$email, subject=>$i18n->get('WebGUI password recovery')});
$mail->addText($i18n->get('recover password email text1', 'AuthWebGUI') . $url. ". \n\n".$i18n->get('recover password email text2', 'AuthWebGUI')." \n\n ".$url."?op=auth;method=emailResetPassword;token=$recoveryGuid"."\n\n ". $i18n->get('recover password email text3', 'AuthWebGUI')); my $vars = { };
$vars->{recoverPasswordUrl} = $session->url->append($session->url->getSiteURL,'?op=auth;method=emailResetPassword;token='.$recoveryGuid);
my $template = WebGUI::Asset->newByDynamicClass($session, $session->setting->get('webguiPasswordRecoveryEmailTemplate'));
my $emailText = $template->process($vars);
WebGUI::Macro::process($session, \$emailText);
$mail->addText($emailText);
$mail->queue; $mail->queue;
return "<h1>". $i18n->get('recover password banner', 'AuthWebGUI')." </h1> <br> <br> <h3>". $i18n->get('email recover password finish message', 'AuthWebGUI') . "</h3>"; return "<h1>". $i18n->get('recover password banner', 'AuthWebGUI')." </h1> <br> <br> <h3>". $i18n->get('email recover password finish message', 'AuthWebGUI') . "</h3>";
} }

View file

@ -186,6 +186,10 @@ Renders an HTML area field.
sub toHtml { sub toHtml {
my $self = shift; my $self = shift;
##Do not display a rich editor on any mobile browser.
if ($self->session->style->useMobileStyle) {
return $self->SUPER::toHtml;
}
my $i18n = WebGUI::International->new($self->session); my $i18n = WebGUI::International->new($self->session);
if (! $self->{_richEdit}) { if (! $self->{_richEdit}) {
my $richEdit = eval { WebGUI::Asset::RichEdit->newById($self->session, $self->get("richEditId")); }; my $richEdit = eval { WebGUI::Asset::RichEdit->newById($self->session, $self->get("richEditId")); };

View file

@ -129,6 +129,16 @@ our $HELP = {
related => [] related => []
}, },
'webgui authentication password recovery email template' => {
title => 'recovery email template title',
body => '',
variables => [
{ 'name' => 'recoverPasswordUrl', },
],
fields => [],
related => []
},
'webgui authentication password expiration template' => { 'webgui authentication password expiration template' => {
title => 'expired template title', title => 'expired template title',
body => '', body => '',

View file

@ -0,0 +1,20 @@
package WebGUI::Help::Workflow_Activity_NotifyAboutVersionTag;
use strict;
our $HELP = {
'email template' => {
title => 'email template title',
body => '',
variables => [
{ 'name' => 'message' },
{ 'name' => 'comments' },
{ 'name' => 'url' },
],
fields => [],
related => [],
},
};
1;

View file

@ -5,6 +5,7 @@ use WebGUI::Image;
use WebGUI::Image::Palette; use WebGUI::Image::Palette;
use WebGUI::Image::Font; use WebGUI::Image::Font;
use List::Util; use List::Util;
use WebGUI::Pluggable;
our @ISA = qw(WebGUI::Image); our @ISA = qw(WebGUI::Image);
@ -544,11 +545,9 @@ sub load {
my $session = shift; my $session = shift;
my $namespace = shift; my $namespace = shift;
my $cmd = "use $namespace"; my $plugin = eval {
eval($cmd); WebGUI::Pluggable::instanciate($namespace, 'new', [$session, ]);
};
$cmd = $namespace.'->new($session)';
my $plugin = eval($cmd);
return $plugin; return $plugin;
} }

View file

@ -486,20 +486,13 @@ ibox.messageId, ibox.subject, ibox.sentBy, ibox.dateStamp,
SELECT SELECT
} }
my $messageLimit = 20_000;
my $limitHalf = $messageLimit / 2;
my $limitQuarter = $messageLimit / 4;
my $userGroups = $session->db->quoteAndJoin( $user->getGroupIdsRecursive );
$userGroups = "''" if $userGroups eq "";
# for performance purposes don't use datasets larger than 20000 no matter how man messages are in the inbox
my $sql = qq{ my $sql = qq{
SELECT SELECT
$select $select
FROM inbox_messageState FROM inbox_messageState
JOIN inbox ibox USING (messageId) JOIN inbox ibox USING (messageId)
JOIN users on users.userId = ibox.sentBy LEFT OUTER JOIN users on users.userId = ibox.sentBy
JOIN userProfileData on userProfileData.userId = ibox.sentBy LEFT OUTER JOIN userProfileData on userProfileData.userId = ibox.sentBy
WHERE inbox_messageState.messageId = ibox.messageId WHERE inbox_messageState.messageId = ibox.messageId
AND inbox_messageState.userId = '$userId' AND inbox_messageState.userId = '$userId'
AND inbox_messageState.deleted = 0 AND inbox_messageState.deleted = 0

View file

@ -416,14 +416,15 @@ sub new {
return undef unless $messageId; return undef unless $messageId;
my $inbox = $session->db->getRow("inbox","messageId",$messageId); my $inbox = $session->db->getRow("inbox","messageId",$messageId);
#Don't return messages that don't exist
return undef unless (scalar(keys %{$inbox}));
my $statusValues = $session->db->quickHashRef( my $statusValues = $session->db->quickHashRef(
q{ select isRead, repliedTo, deleted from inbox_messageState where messageId=? and userId=? }, q{ select isRead, repliedTo, deleted from inbox_messageState where messageId=? and userId=? },
[$messageId,$userId] [$messageId,$userId]
); );
#Don't return messages that don't exist
return undef unless (scalar(keys %{$inbox}));
#Don't return deleted messages #Don't return deleted messages
return undef if($statusValues->{deleted}); return undef if($statusValues->{deleted});

View file

@ -312,7 +312,7 @@ sub epochToHuman {
"d" => "d", "d" => "d",
"D" => "_varday_", "D" => "_varday_",
"h" => "I", "h" => "I",
"H" => "l", "H" => "_varhour_",
"j" => "H", "j" => "H",
"J" => "k", "J" => "k",
"m" => "m", "m" => "m",
@ -338,11 +338,15 @@ sub epochToHuman {
$output = $dt->strftime($output); $output = $dt->strftime($output);
#--- %M #--- %M
$temp = int($dt->month); $temp = $dt->month;
$output =~ s/\%_varmonth_/$temp/g; $output =~ s/\%_varmonth_/$temp/g;
#-- %D #-- %D
$temp = int($dt->day); $temp = $dt->day;
$output =~ s/\%_varday_/$temp/g; $output =~ s/\%_varday_/$temp/g;
#-- %H, variable digit hour, 12 hour clock
$temp = $dt->hour;
$temp -= 12 if ($temp > 12);
$output =~ s/\%_varhour_/$temp/g;
#--- return #--- return
return $output; return $output;
} }

View file

@ -16,7 +16,7 @@ package WebGUI::Session::Http;
use strict; use strict;
use Scalar::Util qw(weaken); use Scalar::Util qw( weaken blessed );
use HTTP::Date (); use HTTP::Date ();
sub _deprecated { sub _deprecated {

View file

@ -300,7 +300,7 @@ sub new {
my %data = (%{$main}, %{$sub}); my %data = (%{$main}, %{$sub});
for my $definition (reverse @{$class->definition($session)}) { for my $definition (reverse @{$class->definition($session)}) {
for my $property (keys %{$definition->{properties}}) { for my $property (keys %{$definition->{properties}}) {
if(!defined $data{$property} || $data{$property} eq '' && $definition->{properties}{$property}{defaultValue}) { if(!defined $data{$property}) {
$data{$property} = $definition->{properties}{$property}{defaultValue}; $data{$property} = $definition->{properties}{$property}{defaultValue};
} }
} }

View file

@ -19,6 +19,7 @@ use strict;
use base 'WebGUI::Workflow::Activity'; use base 'WebGUI::Workflow::Activity';
use WebGUI::VersionTag; use WebGUI::VersionTag;
use WebGUI::Inbox; use WebGUI::Inbox;
use WebGUI::Asset;
=head1 NAME =head1 NAME
@ -71,8 +72,15 @@ sub definition {
label=> $i18n->get("notify message"), label=> $i18n->get("notify message"),
hoverHelp => $i18n->get("notify message help") hoverHelp => $i18n->get("notify message help")
}, },
} templateId => {
}); fieldType =>"template",
defaultValue => "lYhMheuuLROK_iNjaQuPKg",
namespace => 'NotifyAboutVersionTag',
label => $i18n->get("email template", 'Workflow_Activity_NotifyAboutVersionTag'),
hoverHelp => $i18n->get("email template help", 'Workflow_Activity_NotifyAboutVersionTag')
},
}
});
return $class->SUPER::definition($session,$definition); return $class->SUPER::definition($session,$definition);
} }
@ -95,11 +103,18 @@ sub execute {
my $asset = $versionTag->getAssets->[0]; my $asset = $versionTag->getAssets->[0];
$urlOfSingleAsset = "\n\n".$self->session->url->getSiteURL().$asset->getUrl("func=view;revision=".$asset->get("revisionDate")); $urlOfSingleAsset = "\n\n".$self->session->url->getSiteURL().$asset->getUrl("func=view;revision=".$asset->get("revisionDate"));
} }
my $var = {
message => $self->get('message'),
comments => $versionTag->get('comments'),
url => $urlOfSingleAsset,
};
my $template = WebGUI::Asset->newByDynamicClass($self->session, $self->get('templateId'));
my $message = $template->process($var);
my $properties = { my $properties = {
status=>"completed", status=>"completed",
subject=>$versionTag->get("name"), subject=>$versionTag->get("name"),
message=>$self->get("message")."\n\n".$versionTag->get("comments").$urlOfSingleAsset, message=>$message,
}; };
if ($self->get("who") eq "committer") { if ($self->get("who") eq "committer") {
$properties->{userId} = $versionTag->get("committedBy"); $properties->{userId} = $versionTag->get("committedBy");
} elsif ($self->get("who") eq "creator") { } elsif ($self->get("who") eq "creator") {

View file

@ -17,6 +17,7 @@ package WebGUI::Workflow::Activity::RequestApprovalForVersionTag;
use strict; use strict;
use base 'WebGUI::Workflow::Activity'; use base 'WebGUI::Workflow::Activity';
use WebGUI::Asset;
use WebGUI::VersionTag; use WebGUI::VersionTag;
use WebGUI::Inbox; use WebGUI::Inbox;
use WebGUI::International; use WebGUI::International;
@ -86,6 +87,13 @@ sub definition {
hoverHelp => $i18n->get("do on approve help"), hoverHelp => $i18n->get("do on approve help"),
none => 1, none => 1,
noneLabel => $i18n->get('continue with workflow'), noneLabel => $i18n->get('continue with workflow'),
},
templateId => {
fieldType =>"template",
defaultValue => "lYhMheuuLROK_iNjaQuPKg",
namespace => 'NotifyAboutVersionTag',
label => $i18n->get("email template", 'Workflow_Activity_NotifyAboutVersionTag'),
hoverHelp => $i18n->get("email template help", 'Workflow_Activity_NotifyAboutVersionTag')
}, },
}, },
}; };
@ -265,13 +273,13 @@ sub sendMessage {
"op=manageRevisionsInTag;workflowInstanceId=" . $instance->getId "op=manageRevisionsInTag;workflowInstanceId=" . $instance->getId
. ";tagId=" . $versionTag->getId . ";tagId=" . $versionTag->getId
); );
my $messageText my $var = {
= join "\n\n", message => $self->get('message'),
$self->get("message"), comments => $versionTag->get('comments'),
sprintf('<a href="%s">%s</a>', $approvalUrl, $approvalUrl,), url => $approvalUrl,
$versionTag->get("comments"), };
; my $template = WebGUI::Asset->newByDynamicClass($self->session, $self->get('templateId'));
my $messageText = $template->process($var);
for my $groupId ( @{ $self->getGroupToApprove } ) { for my $groupId ( @{ $self->getGroupToApprove } ) {
my $message my $message
= $inbox->addMessage({ = $inbox->addMessage({

View file

@ -735,8 +735,9 @@ Settings screen, displayed as hoverhelp.|,
}, },
'recover password email text1' => { 'recover password email text1' => {
message => q|We have received your request to change the password for |, message => q|We have received your request to change the password for %s.|,
lastUpdated => 1189780432, lastUpdated => 1189780432,
context => q|%s is the URL of the site|,
}, },
'recover password email text2' => { 'recover password email text2' => {
@ -823,6 +824,31 @@ Settings screen, displayed as hoverhelp.|,
lastUpdated => 0, lastUpdated => 0,
context => q|Description of the webguiUseEmailAsUsername field, used as hoverhelp on the Auth tab of the Edit Settings screen.|, context => q|Description of the webguiUseEmailAsUsername field, used as hoverhelp on the Auth tab of the Edit Settings screen.|,
}, },
'Password Recovery Email Template' => {
message => 'Password Recovery Email Template',
lastUpdated => 0,
context => q|Label in the auth settings|,
},
'password recovery email template help' => {
message => 'Choose a template to style the emails sent out for recovering passwords',
lastUpdated => 0,
context => q|Label in the auth settings|,
},
'recovery email template title' => {
message => 'WebGUI Authentication Password Recovery Email Template',
lastUpdated => 0,
context => q|template help|,
},
'recoverPasswordUrl' => {
message => 'The URL for the user to visit to reset their password.',
lastUpdated => 0,
context => q|template help|,
},
}; };
1; 1;

View file

@ -2,11 +2,48 @@ package WebGUI::i18n::English::Workflow_Activity_NotifyAboutVersionTag;
use strict; use strict;
our $I18N = { our $I18N = {
'activityName' => {
message => q|Notify About Version Tag|, 'activityName' => {
context => q|The name of this workflow activity.|, message => q|Notify About Version Tag|,
lastUpdated => 0, context => q|The name of this workflow activity.|,
}, lastUpdated => 0,
},
'email template' => {
message => q|Email Template|,
context => q|Label in the edit form. A template for an email.|,
lastUpdated => 0,
},
'email template help' => {
message => q|Select a template for the email that is sent out.|,
context => q|Hoverhelp.|,
lastUpdated => 0,
},
'email template title' => {
message => q|Notify About Version Tag Email Template|,
context => q|Title of the template variable page.|,
lastUpdated => 0,
},
'message' => {
message => q|The message from the Workflow Activity settings|,
context => q|Title of the template variable page.|,
lastUpdated => 0,
},
'comments' => {
message => q|Comments from the version tag, when it was committed. These could be blank if no comments were entered, or if comments are not required on the site.|,
context => q|Title of the template variable page.|,
lastUpdated => 0,
},
'url' => {
message => q|The complete URL to work on the version tag. It is a bare URL, with no HTML wrapped around it.|,
context => q|Title of the template variable page.|,
lastUpdated => 0,
},
}; };

View file

@ -68,6 +68,7 @@ checkModule("Test::More", 0.82, 2 );
checkModule("Test::MockObject", 1.02, 2 ); checkModule("Test::MockObject", 1.02, 2 );
checkModule("Test::Deep", 0.095, ); checkModule("Test::Deep", 0.095, );
checkModule("Test::Exception", 0.27, 2 ); checkModule("Test::Exception", 0.27, 2 );
checkModule("Test::Differences", 0.5, 2 );
checkModule("Test::Class", 0.31, 2 ); checkModule("Test::Class", 0.31, 2 );
checkModule("Pod::Coverage", 0.19, 2 ); checkModule("Pod::Coverage", 0.19, 2 );
checkModule("Text::Balanced", 2.00, 2 ); checkModule("Text::Balanced", 2.00, 2 );
@ -150,8 +151,10 @@ checkModule("Business::PayPal::API", "0.62" );
checkModule("Locales", "0.10" ); checkModule("Locales", "0.10" );
checkModule("Test::Harness", "3.17" ); checkModule("Test::Harness", "3.17" );
checkModule("DateTime::Event::ICal", "0.10" ); checkModule("DateTime::Event::ICal", "0.10" );
checkModule( "CHI", ); checkModule("Cache::FastMmap", "1.35" );
checkModule( "Cache::FastMmap", ); checkModule("Test::Tester", "0" );
checkModule("Test::Log::Dispatch", "0" );
checkModule("CHI", "0.34" );
checkModule('IO::Socket::SSL', ); checkModule('IO::Socket::SSL', );
checkModule('Package::Stash', ); checkModule('Package::Stash', );
checkModule('HTTP::Exception', ); checkModule('HTTP::Exception', );

File diff suppressed because one or more lines are too long

View file

@ -128,7 +128,7 @@ is(
); );
$date2 = WebGUI::Form::DateTime->new($session, {defaultValue => -1}); $date2 = WebGUI::Form::DateTime->new($session, {defaultValue => -1});
is($date2->getValueAsHtml(), '12/31/1969 5:59 pm', "getValueAsHtml: defaultValue as negative epoch, returns as user's format"); is($date2->getValueAsHtml(), '12/31/1969 5:59 pm', "getValueAsHtml: defaultValue as negative epoch, returns as user's format");
is( is(
getValueFromForm($session, $date2->toHtmlAsHidden), getValueFromForm($session, $date2->toHtmlAsHidden),
'1969-12-31 17:59:59', '1969-12-31 17:59:59',
@ -156,7 +156,7 @@ is(
$date2 = WebGUI::Form::DateTime->new($session, {defaultValue => '2008-08-01 11:34:26', value => $bday, }); $date2 = WebGUI::Form::DateTime->new($session, {defaultValue => '2008-08-01 11:34:26', value => $bday, });
is($date2->getValueAsHtml(), '8/16/2001 8:00 am', "getValueAsHtml: defaultValue in mysql format, value as epoch returns value in user's format"); is($date2->getValueAsHtml(), '8/16/2001 8:00 am', "getValueAsHtml: defaultValue in mysql format, value as epoch returns value in user's format");
is( is(
getValueFromForm($session, $date2->toHtmlAsHidden), getValueFromForm($session, $date2->toHtmlAsHidden),
'2001-08-16 08:00:00', '2001-08-16 08:00:00',

88
t/Form/Workflow.t Normal file
View file

@ -0,0 +1,88 @@
#-------------------------------------------------------------------
# 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::Workflow;
use WebGUI::Session;
use HTML::Form;
use WebGUI::Form_Checking;
#The goal of this test is to verify that SelectBox form elements work
use Test::More;
use Test::Deep;
my $session = WebGUI::Test->session;
# put your tests here
plan tests => 5;
my $plugin = WebGUI::Form::Workflow->new($session,{
name => 'Workflowage',
none => 1,
noneLabel => 'none',
#defaultValue => 'pbworkflow000000000006',
defaultValue => '',
type => 'WebGUI::VersionTag',
value => '',
});
is $plugin->getOriginalValue, '', 'value set to empty string';
is $plugin->getDefaultValue, '', 'default value set to a valid workflow';
my ($header, $footer) = (WebGUI::Form::formHeader($session), WebGUI::Form::formFooter($session));
my $html = join "\n",
$header,
$plugin->toHtml;
$footer;
diag $html;
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];
#use Data::Dumper;
my @inputs = $form->inputs;
is(scalar @inputs, 2, 'The form has 2 inputs');
my $input = $form->find_input('Workflowage');
is($form->param('Workflowage'), '', 'Empty string is the default');
###Test Form Output parsing
#
#WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
#
## test that we can process non-POST values correctly
#my $cntl = WebGUI::Form::SelectBox->new($session,{ defaultValue => 4242 });
#is($cntl->getValue('text'), 'text', 'getValue(text)');
#is($cntl->getValue(42), 42, 'getValue(int)');
#is($cntl->getValue(0), 0, 'zero');
#is($cntl->getValue(''), '', '""');
#is($cntl->getValue(1,2,3), 1, 'list returns first item');
#is($session->form->selectBox(undef,'text'), 'text', 'text');
#is($session->form->selectBox(undef,42), 42, 'int');
#is($session->form->selectBox(undef,0), 0, 'zero');
#is($session->form->selectBox(undef,undef), 0, 'undef returns 0');
#is($session->form->selectBox(undef,''), '', '""');
#is($session->form->selectBox(undef,1,2,3), 1, 'list returns first item');

View file

@ -15,13 +15,13 @@ use WebGUI::Session;
use WebGUI::Inbox; use WebGUI::Inbox;
use WebGUI::User; use WebGUI::User;
use Test::More tests => 15; # increment this value for each test you create use Test::More tests => 20; # increment this value for each test you create
my $session = WebGUI::Test->session; my $session = WebGUI::Test->session;
# get a user so we can test retrieving messages for a specific user # get a user so we can test retrieving messages for a specific user
my $admin = WebGUI::User->new($session, 3); my $admin = WebGUI::User->new($session, 3);
WebGUI::Test->addToCleanup(sub { WebGUI::Test->cleanupAdminInbox; }); WebGUI::Test->addToCleanup(sub { WebGUI::Test->cleanupAdminInbox($session); });
# Begin tests by getting an inbox object # Begin tests by getting an inbox object
my $inbox = WebGUI::Inbox->new($session); my $inbox = WebGUI::Inbox->new($session);
@ -130,4 +130,25 @@ my $messages = $inbox->getMessagesForUser($admin);
$messages->[0]->setRead($admin->userId); $messages->[0]->setRead($admin->userId);
is($inbox->getUnreadMessageCount($admin->userId), 3, '... really tracks unread messages'); is($inbox->getUnreadMessageCount($admin->userId), 3, '... really tracks unread messages');
is(scalar @{ $inbox->getMessagesForUser($admin) }, 4, 'Four messages in the inbox');
$inbox->deleteMessagesForUser($admin);
is(scalar @{ $inbox->getMessagesForUser($admin) }, 0, 'deleteMessagesForUser removed all messages');
my $dead_user = WebGUI::User->create($session);
WebGUI::Test->addToCleanup($dead_user);
$inbox->addMessage({
message => "This method should be removed",
userId => 3,
sentBy => $dead_user->userId,
status => 'unread',
},{
no_email => 1,
});
is(scalar @{ $inbox->getMessagesForUser($admin) }, 1, 'one message from dead_user in the inbox');
$dead_user->delete;
is(scalar @{ $inbox->getMessagesForUser($admin) }, 1, '... after deleting the user, still 1 message');
$inbox->deleteMessagesForUser($admin);
is(scalar @{ $inbox->getMessagesForUser($admin) }, 0, '... after deleteMessagesForUser, all messages gone again');
#vim:ft=perl #vim:ft=perl

View file

@ -27,7 +27,7 @@ my @testSets = (
}, },
{ {
format => '', format => '',
output =>'8/16/2001 8:00 am', output =>'8/16/2001 8:00 am',
}, },
); );
@ -59,7 +59,7 @@ is($output, $session->datetime->epochToHuman($time1), 'checking default time and
##Checking for edge case, time=0 ##Checking for edge case, time=0
is WebGUI::Macro::D_date::process($session, '', 0), is WebGUI::Macro::D_date::process($session, '', 0),
'12/31/1969 6:00 pm', '12/31/1969 6:00 pm',
'...checking for handling time=0'; '...checking for handling time=0';
lives_ok { WebGUI::Macro::D_date::process($session, '', ' 0') } lives_ok { WebGUI::Macro::D_date::process($session, '', ' 0') }

View file

@ -15,7 +15,7 @@ use File::Spec;
use WebGUI::Test; use WebGUI::Test;
use WebGUI::Session; use WebGUI::Session;
use Test::More tests => 92; # increment this value for each test you create use Test::More tests => 95; # increment this value for each test you create
local @INC = @INC; local @INC = @INC;
unshift @INC, File::Spec->catdir( WebGUI::Test->getTestCollateralPath, 'Session-DateTime', 'lib' ); unshift @INC, File::Spec->catdir( WebGUI::Test->getTestCollateralPath, 'Session-DateTime', 'lib' );
@ -298,7 +298,13 @@ cmp_ok(
$dude->profileField('language', 'BadLocale'); $dude->profileField('language', 'BadLocale');
$session->user({user => $dude}); $session->user({user => $dude});
is($dt->epochToHuman($wgbday), '8/16/2001 9:00 pm', 'epochToHuman: constructs a default locale if the language does not provide one.'); is($dt->epochToHuman($wgbday), '8/16/2001 9:00 pm', 'epochToHuman: constructs a default locale if the language does not provide one.');
$session->user({userId => 1}); $session->user({userId => 1});
##Variable digit days, months and hours
is($dt->epochToHuman($wgbday,'%M'), '8', '... single digit month');
my $dayEpoch = DateTime->from_epoch(epoch => $wgbday)->subtract(days => 10)->epoch;
is($dt->epochToHuman($dayEpoch,'%D'), '6', '... single digit day');
is($dt->epochToHuman($dayEpoch,'%H'), '8', '... single digit hour');
#vim:ft=perl #vim:ft=perl