Merge commit '17ce3572bf' into WebGUI8. All tests passing.

This commit is contained in:
Colin Kuskie 2010-06-30 18:43:27 -07:00
commit 5e502fee53
117 changed files with 2012 additions and 1027 deletions

View file

@ -180,8 +180,9 @@ sub www_view {
'WebGUI::Asset::WikiPage',
'WebGUI::Asset::Post::Thread',
],
whereClause => "asset.createdBy = '$userId' or assetData.ownerUserId = '$userId'",
orderByClause => "$sortBy $sortDir"
statusToInclude => [ qw/approved archived/ ],
whereClause => "asset.createdBy = '$userId' or assetData.ownerUserId = '$userId'",
orderByClause => "$sortBy $sortDir"
}
);
@ -204,12 +205,6 @@ sub www_view {
}
my $props = $asset->get;
$props->{url} = $asset->getUrl;
if (ref $asset eq "WebGUI::Asset::Post") {
$asset = $asset->getThread;
$props = $asset->get;
$props->{className} = "WebGUI::Asset::Post";
}
push(@contribs,$props);
}
my $contribsCount = $p->getRowCount;

View file

@ -2781,6 +2781,10 @@ sub www_editSave {
$session->asset($object->getParent);
return $session->asset->www_view;
}
elsif ($proceed eq "editParent") {
$session->asset($object->getParent);
return $session->asset->www_edit;
}
elsif ($proceed eq "goBackToPage" && $session->form->process('returnUrl')) {
$session->http->setRedirect($session->form->process("returnUrl"));
return undef;

View file

@ -108,8 +108,7 @@ override applyConstraints => sub {
$storage->resize( $file, undef, undef, $gallery->imageDensity );
$storage->adjustMaxImageSize($file, $maxImageSize);
$self->generateThumbnail;
$self->setSize;
$self->generateThumbnail;
$self->updateExifDataFromFile;
super();
};
@ -229,10 +228,11 @@ sub getEditFormUploadControl {
}
# Control to upload a new file
$html .= WebGUI::Form::file( $session, {
name => 'newFile',
label => $i18n->get('new file'),
hoverHelp => $i18n->get('new file description'),
$html .= WebGUI::Form::image( $session, {
name => 'newFile',
label => $i18n->get('new file'),
hoverHelp => $i18n->get('new file description'),
forceImageOnly => 1,
});
return $html;
@ -378,11 +378,19 @@ contained in.
sub makeResolutions {
my $self = shift;
my $resolutions = shift;
my $session = $self->session;
my $error;
croak "Photo->makeResolutions: resolutions must be an array reference"
if $resolutions && ref $resolutions ne "ARRAY";
# # Return immediately if no image is available
# if ( $self->get("filename") eq '' )
# {
# $session->log->error("makeResolutions skipped since no image available");
# return;
# }
# Get default if necessary
$resolutions ||= $self->getGallery->getImageResolutions;
@ -413,13 +421,20 @@ Make the default title into the file name minus the extention.
override processPropertiesFromFormPost => sub {
my $self = shift;
my $i18n = WebGUI::International->new( $self->session,'Asset_Photo' );
my $form = $self->session->form;
my $errors = super() || [];
# Make sure there is an image file attached to this asset.
if ( !$self->get('filename') ) {
push @{ $errors }, $i18n->get('error no image');
}
# Return if errors
return $errors if @$errors;
### Passes all checks
# If no title was given, make it the file name
if ( !$form->get('title') ) {
my $title = $self->filename;
@ -586,6 +601,7 @@ sub www_edit {
$var->{ form_start }
= WebGUI::Form::formHeader( $session, {
action => $self->getParent->getUrl('func=editSave;assetId=new;class='.__PACKAGE__),
extras => 'name="photoAdd"',
})
. WebGUI::Form::hidden( $session, {
name => 'ownerUserId',
@ -597,6 +613,7 @@ sub www_edit {
$var->{ form_start }
= WebGUI::Form::formHeader( $session, {
action => $self->getUrl('func=editSave'),
extras => 'name="photoEdit"',
})
. WebGUI::Form::hidden( $session, {
name => 'ownerUserId',
@ -607,7 +624,7 @@ sub www_edit {
$var->{ form_start }
.= WebGUI::Form::hidden( $session, {
name => "proceed",
value => "showConfirmation",
value => $form->get('proceed') || "showConfirmation",
});
$var->{ form_end } = WebGUI::Form::formFooter( $session );

View file

@ -119,8 +119,8 @@ sub _fixReplyCount {
isa => 'WebGUI::Asset::Post',
orderByClause => 'assetData.revisionDate desc',
} )->[0];
if (my $lastPost = WebGUI::Asset->newById( $self->session, $lastPostId ) ) {
my $lastPost = eval { WebGUI::Asset->newById( $self->session, $lastPostId ); };
if ( ! Exception::Class->caught() ) {
$asset->incrementReplies( $lastPost->revisionDate, $lastPost->getId );
}
else {
@ -292,23 +292,30 @@ the parent thread.
=cut
override cut => sub {
warn "post's cut";
my $self = shift;
# Fetch the Thread and CS before cutting the asset.
my $thread = $self->getThread;
warn "got thread";
my $cs = $thread->getParent;
warn "got cs";
# Cut the asset
my $result = super();
warn "called super";
# If a post is being cut update the thread reply count first
if ($thread->getId ne $self->getId) {
warn "calling _fixReplyCount on thread";
$self->_fixReplyCount( $thread );
}
# Update the CS reply count. This step is also necessary when a Post is cut since the Thread's incrementReplies
# also calls the CS's incrementReplies, possibly with the wrong last post Id.
warn "calling _fixReplyCount on cs";
$self->_fixReplyCount( $cs );
warn "all should be well...?";
return $result;
};

View file

@ -501,12 +501,14 @@ property of the Asset.
=cut
sub getRssData {
my $self = shift;
my $self = shift;
my $session = $self->session;
my $url = $session->url->getSiteURL.$self->getUrl;
my $data = {
title => $self->headline || $self->getTitle,
description => $self->story,
'link' => $self->getUrl,
guid => $self->getUrl,
'link' => $url,
guid => $url,
author => $self->byline,
date => $self->lastModified,
pubDate => $self->session->datetime->epochToMail($self->creationDate),

View file

@ -769,7 +769,7 @@ sub getEventsIn {
&& Event.endTime IS NULL
&&
!(
Event.startDate > '$endDate'
Event.startDate > SUBDATE('$endDate', INTERVAL 1 DAY)
|| Event.endDate < '$startDate'
)
)
@ -794,7 +794,7 @@ sub getEventsIn {
my $orderby = join ',', @order_priority;
my $events
= $self->getLineage(["descendants"], {
= $self->getLineage(["children"], {
returnObjects => 1,
includeOnlyClasses => ['WebGUI::Asset::Event'],
joinClass => 'WebGUI::Asset::Event',

View file

@ -1176,7 +1176,7 @@ sub getThreadsPaginator {
$sortBy =~ s/^\w+\.//;
# Sort by the thread rating instead of the post rating. other places don't care about threads.
$sortBy = $sortBy eq 'rating' ? 'threadRating' : $sortBy;
if (! WebGUI::Utility::isIn($sortBy, qw/userDefined1 userDefined2 userDefined3 userDefined4 userDefined5 title lineage revisionDate creationDate karmaRank threadRating/)) {
if (! WebGUI::Utility::isIn($sortBy, qw/userDefined1 userDefined2 userDefined3 userDefined4 userDefined5 title lineage revisionDate creationDate karmaRank threadRating views replies lastPostDate/)) {
$sortBy = 'revisionDate';
}
if ($sortBy eq 'assetId' || $sortBy eq 'revisionDate') {

View file

@ -409,17 +409,23 @@ sub view {
my %rules;
$rules{endingLineageLength} = $start->getLineageLength+$self->descendantEndPoint;
$rules{assetToPedigree} = $current if (isIn("pedigree",@includedRelationships));
$rules{ancestorLimit} = $self->ancestorEndPoint;
$rules{orderByClause} = 'rpad(asset.lineage, 255, 9) desc' if ($self->reversePageLoop);
my $assets = $start->getLineage(\@includedRelationships,\%rules);
my $currentLineage = $current->lineage;
my $assetIter = $start->getLineageIterator(\@includedRelationships,\%rules);
my $currentLineage = $current->lineage;
my $lineageToSkip = "noskip";
my $absoluteDepthOfLastPage;
my $absoluteDepthOfFirstPage; # Will set on first iteration of loop, below
my %lastChildren;
my $previousPageData = undef;
my $eh = $self->session->errorHandler;
while ( my $asset = $assets->() ) {
while ( 1 ) {
my $asset;
eval { $asset = $assetIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $asset;
# skip pages we shouldn't see
my $pageLineage = $asset->lineage;
next if ($pageLineage =~ m/^$lineageToSkip/);

View file

@ -2408,6 +2408,8 @@ sub editThingData {
my $thingId = shift || $session->form->process('thingId');
my $thingDataId = shift || $session->form->process('thingDataId') || "new";
my $thingProperties = shift || $self->getThing($thingId);
my $errors = shift;
my $resetForm = shift;
my $i18n = WebGUI::International->new($self->session, "Asset_Thingy");
my $canEditThingData = $self->canEditThingData($thingId, $thingDataId, $thingProperties);
@ -2417,7 +2419,7 @@ sub editThingData {
my (%thingData, $fields,@field_loop,$fieldValue, $privilegedGroup);
my $var = $self->get;
my $url = $self->getUrl;
my $errors = shift;
$var->{error_loop} = $errors if ($errors);
$var->{canEditThings} = $self->canEdit;
@ -2465,14 +2467,17 @@ sub editThingData {
,[$self->getId,$thingId]);
while (my %field = $fields->hash) {
my $fieldName = 'field_'.$field{fieldId};
if ($session->form->process("func") eq "editThingDataSave"){
$fieldValue = $session->form->process($fieldName,$field{fieldType},$field{defaultValue});
$fieldValue = undef;
unless ($resetForm) {
if ($session->form->process("func") eq "editThingDataSave"){
$fieldValue = $session->form->process($fieldName,$field{fieldType},$field{defaultValue});
}
else{
$fieldValue = $thingData{"field_".$field{fieldId}};
}
}
else{
$fieldValue = $thingData{"field_".$field{fieldId}};
}
$field{value} = $fieldValue || $field{defaultValue};
my $formElement .= $self->getFormElement(\%field);
$field{value} = $fieldValue || $field{defaultValue};
my $formElement .= $self->getFormPlugin(\%field,($resetForm eq ""))->toHtml;
my $hidden = ($field{status} eq "hidden" && !$self->session->var->isAdminOn);
my $value = $field{value};
@ -2546,7 +2551,7 @@ sub www_editThingDataSave {
return $self->www_viewThingData($thingId,$newThingDataId);
}
elsif ($thingProperties->{afterSave} eq "addThing") {
return $self->www_editThingData($thingId,"new");
return $self->www_editThingData($thingId,"new",undef,undef,"resetForm");
}
elsif ($thingProperties->{afterSave} =~ m/^searchOther_/x){
$otherThingId = $thingProperties->{afterSave};
@ -2556,7 +2561,7 @@ sub www_editThingDataSave {
elsif ($thingProperties->{afterSave} =~ m/^addOther_/x){
$otherThingId = $thingProperties->{afterSave};
$otherThingId =~ s/^addOther_//x;
return $self->www_editThingData($otherThingId,"new");
return $self->www_editThingData($otherThingId,"new",undef,undef,"resetForm");
}
# if afterSave is thingy default or in any other case return www_view()
else {

View file

@ -353,7 +353,7 @@ sub view {
my $url = $self->session->url;
my $i18n = WebGUI::International->new($self->session, "Asset_UserList");
my (%var, @users, @profileField_loop, @profileFields);
my ($defaultPublicProfile, $defaultPublicEmail, $user, $sth, $sql, $profileField);
my ($user, $sth, $sql, $profileField);
my $currentUrlWithoutSort = $self->getUrl();
foreach ($form->param) {
@ -505,9 +505,6 @@ sub view {
$sortBy = join '.', map { $self->session->db->quoteIdentifier($_) } split /\./, $sortBy;
$sql .= " order by ".$sortBy." ".$sortOrder;
($defaultPublicProfile) = $self->session->db->quickArray("SELECT dataDefault FROM userProfileField WHERE fieldName='publicProfile'");
($defaultPublicEmail) = $self->session->db->quickArray("SELECT dataDefault FROM userProfileField WHERE fieldName='publicEmail'");
my $paginatePage = $form->param('pn') || 1;
my $currentUrl = $self->getUrl();
foreach ($form->param) {

View file

@ -468,14 +468,10 @@ sub getLineage {
my $sql = $self->getLineageSql($relatives, $rules);
unless ($sql) {
return [];
}
my @lineage;
my %relativeCache;
my $sth = $session->db->read($sql);
ASSET: while (my ($id, $class, $parentId, $version) = $sth->array) {
my @lineage;
my %relativeCache;
my $sth = $self->session->db->read($sql);
while (my ($id, $class, $parentId, $version) = $sth->array) {
# create whatever type of object was requested
my $asset;
if ($rules->{returnObjects}) {
@ -740,7 +736,8 @@ sub getLineageSql {
}
## finish up our where clause
if (!scalar(@whereModifiers)) {
return "";
#Return valid SQL that will never select an asset.
return q|select * from asset where assetId="###---###"|;
}
$where .= ' and ('.join(" or ",@whereModifiers).')';
if (exists $rules->{whereClause} && $rules->{whereClause}) {

View file

@ -297,7 +297,7 @@ JS
$output .= '<div class="crumbTrail">'.join(" &gt; ", @crumb)."</div>\n<ul>";
my $useAssetUrls = $session->config->get("richEditorsUseAssetUrls");
my $children = $base->getLineage(["children"]);
my $children = $base->getLineageIterator(["children"]);
while ( my $child = $children->() ) {
next unless $child->canView;
$output .= '<li>';

View file

@ -78,23 +78,23 @@ If true, this will limit the list of template to only include templates that are
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift || [];
my $i18n = WebGUI::International->new($session, 'Asset_Template');
push(@{$definition}, {
label=>{
defaultValue=>$i18n->get("assetName")
},
name=>{
defaultValue=>"templateId"
},
namespace=>{
defaultValue=>undef
},
onlyCommitted=>{
defaultValue=>''
},
my $class = shift;
my $session = shift;
my $definition = shift || [];
my $i18n = WebGUI::International->new($session, 'Asset_Template');
push(@{$definition}, {
label=>{
defaultValue=>$i18n->get("assetName")
},
name=>{
defaultValue=>"templateId"
},
namespace=>{
defaultValue=>undef
},
onlyCommitted=>{
defaultValue=>''
},
});
return $class->SUPER::definition($session, $definition);
}
@ -138,6 +138,54 @@ sub isDynamicCompatible {
#-------------------------------------------------------------------
=head2 getValueAsHtml ( )
Returns the tempalte name of the selected template.
=cut
sub getValueAsHtml {
my $self = shift;
$self->setOptions;
return $self->SUPER::getValueAsHtml;
}
#-------------------------------------------------------------------
=head2 setOptions
Fills the options of the select list with the appropriate templates.
=cut
sub setOptions {
my $self = shift;
my $session = $self->session;
my $userId = $session->user->userId;
my $onlyCommitted = $self->get( 'onlyCommitted' )
? q{assetData.status='approved'}
: $self->get( 'onlyCommitted' )
;
my $templateList = WebGUI::Asset::Template->getList( $session, $self->get( 'namespace' ), $onlyCommitted );
#Remove entries from template list that the user does not have permission to view.
for my $assetId ( keys %{$templateList} ) {
my $asset = eval { WebGUI::Asset->newById($session, $assetId); };
if (!Exception::Class->caught() && !$asset->canView($self->session->user->userId)) {
delete $templateList->{$assetId};
}
}
$self->set( 'options', $templateList );
return;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a template picker control.
@ -145,18 +193,11 @@ Renders a template picker control.
=cut
sub toHtml {
my $self = shift;
my $onlyCommitted = $self->get('onlyCommitted') ? "assetData.status='approved'" : $self->get('onlyCommitted');
my $templateList = WebGUI::Asset::Template->getList($self->session, $self->get("namespace"), $onlyCommitted);
#Remove entries from template list that the user does not have permission to view.
for my $assetId ( keys %{$templateList} ) {
my $asset = WebGUI::Asset::Template->newById($self->session, $assetId);
if (!$asset->canView($self->session->user->userId)) {
delete $templateList->{$assetId};
}
}
$self->set("options", $templateList);
return $self->SUPER::toHtml();
my $self = shift;
$self->setOptions;
return $self->SUPER::toHtml();
}
#-------------------------------------------------------------------

View file

@ -36,6 +36,31 @@ The following methods are specifically available from this class. Check the supe
=cut
#-------------------------------------------------------------------
=head2 getName ( session )
Returns the human readable name of this control.
=cut
sub getName {
my ($self, $session) = @_;
return WebGUI::International->new($session, 'WebGUI')->get('user');
}
#-------------------------------------------------------------------
=head2 isDynamicCompatible ( )
Since this Form field requires a thingId to work it is not dynamic compatible.
=cut
sub isDynamicCompatible {
return 0;
}
#----------------------------------------------------------------------------
=head2 www_getThingFields ($session)

View file

@ -58,6 +58,19 @@ Defaults to the setting textBoxSize or 30 if that's not set. Specifies how big o
#-------------------------------------------------------------------
=head2 getName ( session )
Returns the human readable name of this control.
=cut
sub getName {
my ($self, $session) = @_;
return WebGUI::International->new($session, 'Form_Username')->get('username');
}
#-------------------------------------------------------------------
=head2 getValue ( [ value ] )
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Strip newlines/carriage returns from the value.

View file

@ -283,6 +283,7 @@ sub clearCaches {
$stow->delete("groupObj");
$stow->delete("isInGroup");
$stow->delete("gotGroupsInGroup");
$stow->delete("gotGroupsForUser");
}
#-------------------------------------------------------------------

View file

@ -119,6 +119,29 @@ sub canRead {
#-------------------------------------------------------------------
=head2 deleteMessagesForUser ( $user )
Deletes all messages for a user.
=head3 $user
A WebGUI::User object, representing the user who will have all their messages deleted.
=cut
sub deleteMessagesForUser {
my $self = shift;
my $user = shift;
my $messages = $self->getMessagesForUser($user, 1e10);
my $userId = $user->userId;
foreach my $message (@{ $messages }) {
$message->delete($userId);
}
}
#-------------------------------------------------------------------
=head2 getMessage ( messageId [, userId] )
Returns a WebGUI::Inbox::Message object.
@ -448,7 +471,7 @@ sub getMessageSql {
}
if($whereClause) {
$whereClause = qq{WHERE $whereClause};
$whereClause = qq{AND $whereClause};
}
if($limit) {
@ -473,14 +496,13 @@ SELECT
my $sql = qq{
SELECT
$select
FROM (
( SELECT messageId, subject, sentBy, dateStamp, status FROM inbox WHERE userId = '$userId' order by dateStamp desc limit $limitHalf)
UNION
( SELECT messageId, subject, sentBy, dateStamp, status FROM inbox WHERE groupId IN ( $userGroups ) order by dateStamp desc limit $limitHalf )
) AS ibox
JOIN inbox_messageState on inbox_messageState.messageId=ibox.messageId and inbox_messageState.userId='$userId' and inbox_messageState.deleted=0
LEFT JOIN users on users.userId=ibox.sentBy
LEFT JOIN userProfileData on userProfileData.userId=ibox.sentBy
FROM inbox_messageState
JOIN inbox ibox USING (messageId)
JOIN users on users.userId = ibox.sentBy
JOIN userProfileData on userProfileData.userId = ibox.sentBy
WHERE inbox_messageState.messageId = ibox.messageId
AND inbox_messageState.userId = '$userId'
AND inbox_messageState.deleted = 0
$whereClause
$sortBy
$limit

View file

@ -266,8 +266,7 @@ sub delete {
);
#Delete the message from the database if everyone who was sent the message has deleted it
unless ($isActive) {
$db->write("delete from inbox where messageId=?",[$messageId]);
$db->write("delete from inbox_messageState where messageId=?",[$messageId]);
$self->purge;
}
}
@ -437,6 +436,22 @@ sub new {
#-------------------------------------------------------------------
=head2 purge
Completely deletes a message from the inbox.
=cut
sub purge {
my $self = shift;
my $db = $self->session->db;
my $messageId = $self->getId;
$db->write("delete from inbox where messageId=?",[$messageId]);
$db->write("delete from inbox_messageState where messageId=?",[$messageId]);
}
#-------------------------------------------------------------------
=head2 session
Returns a reference to the current session.

View file

@ -22,6 +22,7 @@ use Net::SMTP;
use WebGUI::Group;
use WebGUI::Macro;
use WebGUI::User;
use WebGUI::HTML;
use Encode qw(encode);
=head1 NAME
@ -84,15 +85,57 @@ sub addAttachment {
=head2 addFooter ( )
Adds the mail footer as set by the site admin to the end of this message.
Adds the mail footer as set by the site admin to the end of the first
part of this message. If the first part of the message has an HTML MIME-type,
then it will translate the footer to HTML.
If the message is empty, it will create a MIME entity part to hold it.
Macros in the footer will be evaluated.
=cut
sub addFooter {
my $self = shift;
return if $self->{_footerAdded};
my $text = "\n\n".$self->session->setting->get("mailFooter");
WebGUI::Macro::process($self->session, \$text);
$self->addText($text);
$self->{_footerAdded} = 1;
my @parts = $self->getMimeEntity->parts();
##No parts yet, add one with the footer content.
if (! $parts[0]) {
$self->addText($text);
return;
}
##Get the content of the first part, drop it from the set of parts
my $mime_body = $parts[0]->bodyhandle;
my $body_content = join '', $mime_body->as_lines;
my $mime_type;
if ($parts[0]->effective_type eq 'text/plain') {
$body_content .= $text;
my $new_part = MIME::Entity->build(
Charset => "UTF-8",
Encoding => "quoted-printable",
Type => 'text/plain',
Data => encode('utf8', $body_content),
);
shift @parts;
unshift @parts, $new_part;
$self->getMimeEntity->parts(\@parts);
}
elsif ($parts[0]->effective_type eq 'text/html') {
$text = WebGUI::HTML::format($text, 'mixed');
$body_content =~ s{(?=</body>)}{$text};
my $new_part = MIME::Entity->build(
Charset => "UTF-8",
Encoding => "quoted-printable",
Type => 'text/html',
Data => encode('utf8', $body_content),
);
shift @parts;
unshift @parts, $new_part;
$self->getMimeEntity->parts(\@parts);
}
}
#-------------------------------------------------------------------
@ -339,7 +382,13 @@ sub create {
delete $headers->{toGroup};
$message->attach(Data=>"This message was intended for ".$to." but was overridden in the config file.\n\n");
}
bless {_message=>$message, _session=>$session, _toGroup=>$headers->{toGroup}, _isInbox => $isInbox }, $class;
return bless {
_message => $message,
_session => $session,
_toGroup => $headers->{toGroup},
_isInbox => $isInbox,
_footerAdded => 0,
}, $class;
}
#-------------------------------------------------------------------
@ -462,6 +511,10 @@ sub send {
my $smtpServer = $session->setting->get("smtpServer");
my $status = 1;
if ($mail->parts <= 1) {
warn "making singlepart";
$mail->make_singlepart;
}
if ($mail->head->get("To")) {
if ($session->config->get("emailToLog")){
my $message = $mail->stringify;

View file

@ -308,7 +308,6 @@ sub www_runCronJob {
# Run the instance
my $error = $instance->start( 1 );
if ($error) {
$task->delete(1);
return "error";
}
$task->delete( 1 ) if ( $task->get("runOnce") );

View file

@ -87,7 +87,8 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -113,7 +114,8 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -192,7 +194,8 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -218,7 +221,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -269,7 +274,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -295,7 +302,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -321,7 +330,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -347,7 +358,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=head3 disabled
@ -381,7 +394,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -407,7 +422,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -433,7 +450,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -459,7 +478,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=head3 disabled
@ -529,7 +550,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -555,7 +578,9 @@ Any URL parameters that need to be tacked on to the current URL to accomplish wh
=head3 pageURL
The URL to any page. Defaults to the current page.
The URL to any page. Defaults to the current page. If a URL is passed, the gateway URL from the site's config
file will be prepended to it.
=cut
@ -570,6 +595,4 @@ sub view {
}
1;

View file

@ -133,7 +133,7 @@ sub session {
=head2 toHex ( guid )
Returns the hex value of a guid
Returns the hex value of a guid. For all GUIDs generated by the generate method, the return value will be 32 characters long. For some manually created invalid GUIDs, it may be 33 characters long.
=head3 guid
@ -142,11 +142,13 @@ guid to convert to hex value.
=cut
sub toHex {
my $self = shift;
my $self = shift;
my $id = shift;
$id =~ tr{_-}{+/};
my $bin_id = decode_base64("$id==");
my $hex_id = sprintf('%*v02x', '', $bin_id);
$id .= 'AA';
my $bin_id = decode_base64($id);
my $hex_id = unpack("H*", $bin_id);
$hex_id =~ s/0{3,4}$//;
return $hex_id
}

View file

@ -684,7 +684,20 @@ sub www_editAddressSave {
my %addressData = $self->processAddressForm();
my @missingFields = $self->missingFields(\%addressData);
if (@missingFields) {
return $self->www_editAddress(pop @missingFields);
my $i18n = WebGUI::International->new($self->session, "Shop");
my $missingField = pop @missingFields;
my $label = $missingField eq 'label' ? $i18n->get('label')
: $missingField eq 'firstName' ? $i18n->get('firstName')
: $missingField eq 'lastName' ? $i18n->get('lastName')
: $missingField eq 'address1' ? $i18n->get('address')
: $missingField eq 'city' ? $i18n->get('city')
: $missingField eq 'state' ? $i18n->get('state')
: $missingField eq 'country' ? $i18n->get('country')
: $missingField eq 'phoneNumber' ? $i18n->get('phone number')
: '' ;
if ($label) {
return $self->www_editAddress(sprintf($i18n->get('is a required field'), $label));
}
}
if ($form->get('addressId') eq '') {
$self->addAddress(\%addressData);

View file

@ -405,8 +405,8 @@ sub delete {
$db->write("DELETE FROM userSession WHERE userId=?",[$userId]);
# remove inbox entries
$db->write("DELETE FROM inbox_messageState WHERE userId=?",[$userId]);
$db->write("DELETE FROM inbox WHERE userId=? AND (groupId IS NULL OR groupId='')",[$userId]);
my $inbox = WebGUI::Inbox->new($session);
$inbox->deleteMessagesForUser($self);
# Shop cleanups
my $sth = $session->db->prepare('select addressBookId from addressBook where userId=?');

View file

@ -186,6 +186,64 @@ sub commit {
return 2;
}
#-------------------------------------------------------------------
=head2 commitAsUser ( userId , options )
Commits the working tab. If userId is passed in, commit will be done as that user
=head3 userId
User to commit tag as
=head3 options
hash ref of options to pass in
=head4 comments
optional comments to set in the version tag
=head4 commitNow
optional boolean which, if set, will perform an immediate.
=cut
sub commitAsUser {
my $self = shift;
my $session = $self->session;
my $config = $session->config;
my $userId = shift;
my $options = shift;
my $commitNow = $options->{commitNow};
my $comments = $options->{comments};
return 0 unless (defined $userId);
#Open a new session
my $new_session = WebGUI::Session->open( $config->pathToFile );
#Set the userId in the new session
$new_session->user( { userId => $userId } );
#Clone the tag into a new version tag in the new session
my $new_tag = __PACKAGE__->new( $new_session, $self->getId );
if ( defined $new_tag ) {
$new_tag->set( { comments => $comments } );
if ($commitNow) {
$new_tag->commit;
}
else {
$new_tag->requestCommit;
}
}
#End the new session
$new_session->var->end;
$new_session->close;
return 1;
}
#-------------------------------------------------------------------

View file

@ -17,7 +17,7 @@ package WebGUI::Workflow::Activity::PurgeOldInboxMessages;
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::Asset;
use WebGUI::Inbox::Message;
=head1 NAME
@ -77,45 +77,32 @@ See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my ($self, $nothing, $instance) = @_;
my ($self, undef, $instance) = @_;
my $session = $self->session;
my $log = $session->errorHandler;
# keep track of how much time it's taking
my $start = time;
my $limit = 2_500;
my $endTime = time() + $self->getTTL;;
my $sth
= $session->db->read(
"SELECT messageId FROM inbox WHERE completedOn IS NOT NULL AND dateStamp < ?",
[ $start - $self->get('purgeAfter') ],
);
while ( ( my $messageId ) = $sth->array ) {
$session->db->write(
"DELETE FROM inbox WHERE messageId = ?",
[ $messageId ],
[ time() - $self->get('purgeAfter') ],
);
MESSAGE: while ( ( my $messageId ) = $sth->array ) {
# give up if we're taking too long
if (time - $start > 120) {
if (time() > $endTime) {
$sth->finish;
return $self->WAITING(1);
}
}
my $message = WebGUI::Inbox::Message->new($session, $messageId);
next MESSAGE unless $message;
$message->purge;
}
# If there are more messages waiting to be purged, return WAITING
if ( $sth->rows >= $limit ) {
return $self->WAITING(1);
}
else {
return $self->COMPLETE;
}
$sth->finish;
return $self->COMPLETE;
}
1;

View file

@ -75,12 +75,14 @@ See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $sth = $self->session->db->read( "select assetId from Event where endDate < ?", [ time() - $self->get("trashAfter") ]);
my $self = shift;
my $session = $self->session;
my $finishTime = time() + $self->getTTL;
my $date = WebGUI::DateTime->new($session, time() - $self->get("trashAfter") );
my $sth = $session->db->read( "select Event.assetId, revisionDate from Event join assetData using (assetId, revisionDate) where endDate < ? and revisionDate = (select max(revisionDate) from assetData where assetData.assetId=Event.assetId);", [ $date->toDatabaseDate ]);
EVENT: while ( my ($id) = $sth->array ) {
my $asset = eval { WebGUI::Asset::Event->newById($self->session, $id); };
if (! Exception::Class->caught() && $asset->eventEndDate < time() - $self->trashAfter) {
my $asset = eval { WebGUI::Asset->newById($session, $id); };
if (! Exception::Class->caught()) {
$asset->trash;
}
last EVENT if time() > $finishTime;

View file

@ -1191,10 +1191,8 @@ submitted by a user.|,
},
'sort by description' => {
message => q|By default, all posts are displayed in a sorted order. Use this
field to choose by what property they are sorted. Multiple properties
may be selected.|,
lastUpdated => 1119070429,
message => q|By default, all posts are displayed in a sorted order. Use this field to choose by what property they are sorted.|,
lastUpdated => 1275922704,
},
'sort order description' => {

View file

@ -759,6 +759,12 @@ our $I18N = {
lastUpdated => 0,
context => q{Error when user is out of disk space.},
},
'error no image' => {
message => q{You need to select an image to upload.},
lastUpdated => 0,
context => q{Error when user tries to add photo without selecting image.},
},
'template comment add title' => {
message => q{Add comment},

View file

@ -0,0 +1,11 @@
package WebGUI::i18n::English::Form_ThingsFieldList;
use strict;
our $I18N = {
'Thingy Fields List' => {
message => q|Thingy Fields List|,
lastUpdated => 1217216725,
},
};
1;

View file

@ -6,6 +6,11 @@ our $I18N = {
message => q|Sorry, that account name is already in use by another member of this site.|,
lastUpdated => 1217216725
},
'username' => {
message => q|Username|,
lastUpdated => 1217216725,
context => q|Name of the form plugin|,
},
};
1;