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

@ -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

View file

@ -2463,7 +2463,8 @@ Method to move an event down one position in display order
sub www_moveEventMetaFieldDown {
my $self = shift;
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;
}
@ -2478,7 +2479,8 @@ Method to move an event metdata field up one position in display order
sub www_moveEventMetaFieldUp {
my $self = shift;
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;
}

View file

@ -424,8 +424,6 @@ sub copyThingData {
return undef unless $self->canEditThingData($thingId, $thingDataId);
my $origCollateral = $self->getCollateral("Thingy_".$thingId, "thingDataId", $thingDataId);
use Data::Dumper;
$session->log->warn(Dumper $origCollateral);
$origCollateral->{thingDataId} = "new";
##Get all fields
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 $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;
}
@ -2588,9 +2586,6 @@ sub www_editThingDataSaveViaAjax {
}
my $thingProperties = $self->getThing($thingId);
use Data::Dumper;
warn $thingId;
warn Dumper $thingProperties;
if ($thingProperties->{thingId}){
return $session->privilege->insufficient() unless $self->canEditThingData($thingId, $thingDataId
,$thingProperties);

View file

@ -21,6 +21,7 @@ use WebGUI::Mail::Send;
use WebGUI::Storage;
use WebGUI::User;
use WebGUI::Form::Captcha;
use WebGUI::Macro;
use Encode ();
use Tie::IxHash;
@ -609,6 +610,13 @@ sub editUserSettingsForm {
-label => $i18n->get("password recovery template"),
-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(
-name => "webguiWelcomeMessageTemplate",
-value => $self->session->setting->get("webguiWelcomeMessageTemplate"),
@ -678,6 +686,8 @@ sub editUserSettingsFormSave {
$s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template"));
$s->set("webguiWelcomeMessageTemplate", $f->process("webguiWelcomeMessageTemplate","template"));
$s->set("webguiAccountActivationTemplate", $f->process("webguiAccountActivationTemplate","template"));
$s->set("webguiPasswordRecoveryTemplate", $f->process("webguiPasswordRecoveryTemplate","template"));
$s->set("webguiPasswordRecoveryEmailTemplate", $f->process("webguiPasswordRecoveryEmailTemplate","template"));
if (@errors) {
return \@errors;
@ -1107,7 +1117,6 @@ sub emailRecoverPasswordFinish {
# generate information necessry to proceed
my $recoveryGuid = $session->id->generate();
my $url = $session->url->getSiteURL;
my $userId = $user->userId; #get the user guid
$email = $user->profileField('email');
@ -1121,7 +1130,12 @@ sub emailRecoverPasswordFinish {
$self->update($authsettings);
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;
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 {
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);
if (! $self->{_richEdit}) {
my $richEdit = eval { WebGUI::Asset::RichEdit->newById($self->session, $self->get("richEditId")); };

View file

@ -129,6 +129,16 @@ our $HELP = {
related => []
},
'webgui authentication password recovery email template' => {
title => 'recovery email template title',
body => '',
variables => [
{ 'name' => 'recoverPasswordUrl', },
],
fields => [],
related => []
},
'webgui authentication password expiration template' => {
title => 'expired template title',
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::Font;
use List::Util;
use WebGUI::Pluggable;
our @ISA = qw(WebGUI::Image);
@ -544,11 +545,9 @@ sub load {
my $session = shift;
my $namespace = shift;
my $cmd = "use $namespace";
eval($cmd);
$cmd = $namespace.'->new($session)';
my $plugin = eval($cmd);
my $plugin = eval {
WebGUI::Pluggable::instanciate($namespace, 'new', [$session, ]);
};
return $plugin;
}

View file

@ -486,20 +486,13 @@ ibox.messageId, ibox.subject, ibox.sentBy, ibox.dateStamp,
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{
SELECT
$select
FROM inbox_messageState
JOIN inbox ibox USING (messageId)
JOIN users on users.userId = ibox.sentBy
JOIN userProfileData on userProfileData.userId = ibox.sentBy
LEFT OUTER JOIN users on users.userId = ibox.sentBy
LEFT OUTER JOIN userProfileData on userProfileData.userId = ibox.sentBy
WHERE inbox_messageState.messageId = ibox.messageId
AND inbox_messageState.userId = '$userId'
AND inbox_messageState.deleted = 0

View file

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

View file

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

View file

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

View file

@ -300,7 +300,7 @@ sub new {
my %data = (%{$main}, %{$sub});
for my $definition (reverse @{$class->definition($session)}) {
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};
}
}

View file

@ -19,6 +19,7 @@ use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::VersionTag;
use WebGUI::Inbox;
use WebGUI::Asset;
=head1 NAME
@ -71,8 +72,15 @@ sub definition {
label=> $i18n->get("notify message"),
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);
}
@ -95,11 +103,18 @@ sub execute {
my $asset = $versionTag->getAssets->[0];
$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 = {
status=>"completed",
subject=>$versionTag->get("name"),
message=>$self->get("message")."\n\n".$versionTag->get("comments").$urlOfSingleAsset,
};
message=>$message,
};
if ($self->get("who") eq "committer") {
$properties->{userId} = $versionTag->get("committedBy");
} elsif ($self->get("who") eq "creator") {

View file

@ -17,6 +17,7 @@ package WebGUI::Workflow::Activity::RequestApprovalForVersionTag;
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::Asset;
use WebGUI::VersionTag;
use WebGUI::Inbox;
use WebGUI::International;
@ -86,6 +87,13 @@ sub definition {
hoverHelp => $i18n->get("do on approve help"),
none => 1,
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
. ";tagId=" . $versionTag->getId
);
my $messageText
= join "\n\n",
$self->get("message"),
sprintf('<a href="%s">%s</a>', $approvalUrl, $approvalUrl,),
$versionTag->get("comments"),
;
my $var = {
message => $self->get('message'),
comments => $versionTag->get('comments'),
url => $approvalUrl,
};
my $template = WebGUI::Asset->newByDynamicClass($self->session, $self->get('templateId'));
my $messageText = $template->process($var);
for my $groupId ( @{ $self->getGroupToApprove } ) {
my $message
= $inbox->addMessage({

View file

@ -735,8 +735,9 @@ Settings screen, displayed as hoverhelp.|,
},
'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,
context => q|%s is the URL of the site|,
},
'recover password email text2' => {
@ -823,6 +824,31 @@ Settings screen, displayed as hoverhelp.|,
lastUpdated => 0,
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;

View file

@ -2,11 +2,48 @@ package WebGUI::i18n::English::Workflow_Activity_NotifyAboutVersionTag;
use strict;
our $I18N = {
'activityName' => {
message => q|Notify About Version Tag|,
context => q|The name of this workflow activity.|,
lastUpdated => 0,
},
'activityName' => {
message => q|Notify About Version Tag|,
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,
},
};