Merge branch 'master' into 8-merge
Conflicts: docs/gotcha.txt lib/WebGUI.pm lib/WebGUI/Asset.pm lib/WebGUI/Asset/File/GalleryFile/Photo.pm lib/WebGUI/Asset/Post.pm lib/WebGUI/Asset/Story.pm lib/WebGUI/Asset/Template.pm lib/WebGUI/Asset/Wobject/Calendar.pm lib/WebGUI/Asset/Wobject/GalleryAlbum.pm lib/WebGUI/Asset/Wobject/Navigation.pm lib/WebGUI/AssetLineage.pm lib/WebGUI/AssetTrash.pm lib/WebGUI/Config.pm lib/WebGUI/Form/Template.pm lib/WebGUI/Group.pm lib/WebGUI/Inbox.pm lib/WebGUI/Workflow/Activity/DeleteExpiredSessions.pm lib/WebGUI/Workflow/Activity/TrashExpiredEvents.pm sbin/testEnvironment.pl t/AdSpace.t t/AdSpace/Ad.t t/Asset/Asset.t t/Asset/AssetExportHtml.t t/Asset/AssetLineage.t t/Asset/EMSSubmissionForm.t t/Asset/Event.t t/Asset/File/GalleryFile/Photo/00base.t t/Asset/File/GalleryFile/Photo/comment.t t/Asset/File/GalleryFile/Photo/download.t t/Asset/File/GalleryFile/Photo/edit.t t/Asset/File/GalleryFile/Photo/exif.t t/Asset/File/GalleryFile/Photo/makeResolutions.t t/Asset/File/GalleryFile/Photo/makeShortcut.t t/Asset/File/Image/setfile.t t/Asset/File/setfile.t t/Asset/Post.t t/Asset/Post/Thread/getAdjacentThread.t t/Asset/Sku.t t/Asset/Sku/ProductCollateral.t t/Asset/Story.t t/Asset/Template.t t/Asset/Template/HTMLTemplateExpr.t t/Asset/Wobject/Gallery/00base.t t/Asset/Wobject/GalleryAlbum/00base.t t/Asset/Wobject/GalleryAlbum/ajax.t t/Asset/Wobject/GalleryAlbum/delete.t t/Asset/Wobject/Matrix.t t/Asset/Wobject/StoryArchive.t t/Asset/Wobject/Survey/ExpressionEngine.t t/Asset/Wobject/Survey/Reports.t t/AssetAspect/RssFeed.t t/Auth/mech.t t/Config.t t/Group.t t/Help/isa.t t/International.t t/Mail/Send.t t/Operation/AdSpace.t t/Operation/Auth.t t/Pluggable.t t/Session.t t/Session/DateTime.t t/Session/ErrorHandler.t t/Session/Scratch.t t/Session/Stow.t t/Shop/Cart.t t/Shop/Pay.t t/Shop/PayDriver/ITransact.t t/Shop/PayDriver/PayPalStd.t t/Shop/Ship.t t/Shop/ShipDriver.t t/Shop/TaxDriver/EU.t t/Shop/TaxDriver/Generic.t t/Shop/Transaction.t t/Shop/Vendor.t t/VersionTag.t t/Workflow/Activity/ArchiveOldStories.t t/Workflow/Activity/ExpireIncompleteSurveyResponses.t t/lib/WebGUI/Test.pm
This commit is contained in:
commit
babfa74209
238 changed files with 4557 additions and 1287 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ sub _fixReplyCount {
|
|||
my $lastPostId = $asset->getLineage( [ qw{ self descendants } ], {
|
||||
isa => 'WebGUI::Asset::Post',
|
||||
orderByClause => 'assetData.revisionDate desc',
|
||||
limit => 1,
|
||||
} )->[0];
|
||||
|
||||
if (my $lastPost = WebGUI::Asset->newById( $self->session, $lastPostId ) ) {
|
||||
|
|
@ -315,6 +316,53 @@ override cut => sub {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 disqualifyAsLastPost ( )
|
||||
|
||||
This method should be called whenever something happens to the Post or Thread that would disqualify
|
||||
it as being the last post in a Thread, or Collaboration System. Good examples are cutting to the
|
||||
clipboard, trashing, or archiving.
|
||||
|
||||
If the Post was the last post, it will find the second to last post for each kind of parent asset,
|
||||
and update that asset with that Post's information.
|
||||
|
||||
=cut
|
||||
|
||||
sub disqualifyAsLastPost {
|
||||
my $self = shift;
|
||||
my $thread = $self->getThread;
|
||||
if ($thread->get('lastPostId') eq $self->getId) {
|
||||
my $secondary_post = $thread->getLineage(['descendants'], {
|
||||
returnObjects => 1,
|
||||
includeOnlyClasses => ["WebGUI::Asset::Post", ],
|
||||
limit => 1,
|
||||
orderByClause => 'revisionDate,lineage DESC',
|
||||
})->[0];
|
||||
if ($secondary_post) { ##Handle edge case for no other
|
||||
$thread->update({ lastPostId => $secondary_post->getId, lastPostDate => $secondary_post->get('creationDate'), });
|
||||
}
|
||||
else {
|
||||
$thread->update({ lastPostId => '', lastPostDate => '', });
|
||||
}
|
||||
}
|
||||
my $cs = $thread->getParent;
|
||||
if ($cs->get('lastPostId') eq $self->getId) {
|
||||
my $secondary_post = $cs->getLineage(['descendants'], {
|
||||
returnObjects => 1,
|
||||
includeOnlyClasses => ["WebGUI::Asset::Post","WebGUI::Asset::Post::Thread"],
|
||||
limit => 1,
|
||||
orderByClause => 'revisionDate DESC',
|
||||
})->[0];
|
||||
if ($secondary_post) { ##Handle edge case for no other
|
||||
$cs->update({ lastPostId => $secondary_post->getId, lastPostDate => $secondary_post->get('creationDate'), });
|
||||
}
|
||||
else {
|
||||
$cs->update({ lastPostId => '', lastPostDate => '', });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 DESTROY
|
||||
|
||||
Extend the base method to delete the locally cached thread object.
|
||||
|
|
@ -1102,6 +1150,22 @@ sub postProcess {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 publish
|
||||
|
||||
Extend the base method to handle updating last post information in the parent Thread
|
||||
and CS.
|
||||
|
||||
=cut
|
||||
|
||||
sub publish {
|
||||
my $self = shift;
|
||||
$self->next::method(@_);
|
||||
$self->qualifyAsLastPost;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge
|
||||
|
||||
Extend the base method to handle cleaning up storage locations.
|
||||
|
|
@ -1149,6 +1213,31 @@ override purgeRevision => sub {
|
|||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 qualifyAsLastPost ( )
|
||||
|
||||
This method should be called whenever something happens to the Post or Thread that would qualify
|
||||
it as being the last post in a Thread, or Collaboration System. Good examples are pasting from
|
||||
the clipboard, restoring from the trash, or changing the state from archiving.
|
||||
|
||||
It checks the parent Thread and CS to see if it is now the last Post, and updates that asset with
|
||||
its information.
|
||||
|
||||
=cut
|
||||
|
||||
sub qualifyAsLastPost {
|
||||
my ($self) = @_;
|
||||
my $thread = $self->getThread();
|
||||
if ($self->get('creationDate') > $thread->get('lastPostDate')) {
|
||||
$thread->update({ lastPostId => $self->getId, lastPostDate => $self->get('creationDate'), });
|
||||
}
|
||||
my $cs = $thread->getParent;
|
||||
if ($self->get('creationDate') > $cs->get('lastPostDate')) {
|
||||
$cs->update({ lastPostId => $self->getId, lastPostDate => $self->get('creationDate'), });
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 rate ( rating )
|
||||
|
|
@ -1253,14 +1342,16 @@ override setParent => sub {
|
|||
|
||||
=head2 setStatusArchived ( )
|
||||
|
||||
Sets the status of this post to archived.
|
||||
Sets the status of this post to archived. Updates the parent thread and CS to remove
|
||||
the lastPost, if this post is the last post.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub setStatusArchived {
|
||||
my ($self) = @_;
|
||||
$self->update({status=>'archived'});
|
||||
my ($self) = @_;
|
||||
$self->update({status=>'archived'});
|
||||
$self->disqualifyAsLastPost;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1269,20 +1360,23 @@ sub setStatusArchived {
|
|||
=head2 setStatusUnarchived ( )
|
||||
|
||||
Sets the status of this post to approved, but does so without any of the normal notifications and other stuff.
|
||||
Updates the last post information in the parent Thread and CS if applicable.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub setStatusUnarchived {
|
||||
my ($self) = @_;
|
||||
$self->update({status=>'approved'}) if ($self->status eq "archived");
|
||||
my ($self) = @_;
|
||||
$self->update({status=>'approved'}) if ($self->get("status") eq "archived");
|
||||
$self->qualifyAsLastPost;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 trash ( )
|
||||
|
||||
Moves post to the trash, updates reply counter on thread and recalculates the thread rating.
|
||||
Moves post to the trash, updates reply counter on thread, recalculates the thread rating,
|
||||
and updates any lastPost information in the parent Thread, and CS.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -1291,22 +1385,8 @@ override trash => sub {
|
|||
super();
|
||||
$self->getThread->sumReplies if ($self->isReply);
|
||||
$self->getThread->updateThreadRating;
|
||||
if ($self->getThread->lastPostId eq $self->getId) {
|
||||
my $threadLineage = $self->getThread->lineage;
|
||||
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
|
||||
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
|
||||
order by creationDate desc",[$threadLineage.'%', $self->getId]);
|
||||
$self->getThread->update({lastPostId=>$id, lastPostDate=>$date});
|
||||
}
|
||||
if ($self->getThread->getParent->lastPostId eq $self->getId) {
|
||||
my $forumLineage = $self->getThread->getParent->lineage;
|
||||
my ($id, $date) = $self->session->db->quickArray("select assetId, creationDate from asset where
|
||||
lineage like ? and assetId<>? and asset.state='published' and className like 'WebGUI::Asset::Post%'
|
||||
order by creationDate desc",[$forumLineage.'%', $self->getId]);
|
||||
$self->getThread->getParent->update({lastPostId=>$id, lastPostDate=>$date});
|
||||
}
|
||||
};
|
||||
|
||||
$self->disqualifyAsLastPost;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -1506,6 +1586,7 @@ sub www_edit {
|
|||
$var{'archive.form'} = WebGUI::Form::yesNo($session, {
|
||||
name=>"archive"
|
||||
});
|
||||
$var{'isSubscribedToCs'} = $self->getThread->getParent->isSubscribed;
|
||||
$var{'form.header'} .= WebGUI::Form::hidden($session, {
|
||||
name=>"proceed",
|
||||
value=>"showConfirmation"
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -134,29 +134,77 @@ These methods are available from this class:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addAttachments ( attachments )
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
Adds attachments to this template. Attachments is an arrayref of hashrefs,
|
||||
where each hashref should have at least url, type, and sequence as keys.
|
||||
Defines the properties of this asset.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to an existing session.
|
||||
|
||||
=head3 definition
|
||||
|
||||
A hash reference passed in from a subclass definition.
|
||||
|
||||
=cut
|
||||
|
||||
sub addAttachments {
|
||||
my ($self, $attachments) = @_;
|
||||
|
||||
my $db = $self->session->db;
|
||||
|
||||
foreach my $a (@$attachments) {
|
||||
my %params = (
|
||||
templateId => $self->getId,
|
||||
revisionDate => $self->revisionDate,
|
||||
url => $a->{url},
|
||||
type => $a->{type},
|
||||
sequence => $a->{sequence},
|
||||
attachId => 'new',
|
||||
);
|
||||
$db->setRow('template_attachments', 'attachId', \%params);
|
||||
}
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Template");
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'template.gif',
|
||||
tableName => 'template',
|
||||
className => 'WebGUI::Asset::Template',
|
||||
properties => {
|
||||
template => {
|
||||
fieldType => 'codearea',
|
||||
syntax => "html",
|
||||
defaultValue => undef,
|
||||
filter => 'packTemplate',
|
||||
},
|
||||
isEditable => {
|
||||
noFormPost => 1,
|
||||
fieldType => 'hidden',
|
||||
defaultValue => 1,
|
||||
},
|
||||
isDefault => {
|
||||
fieldType => 'hidden',
|
||||
defaultValue => 0,
|
||||
},
|
||||
showInForms => {
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 1,
|
||||
},
|
||||
parser => {
|
||||
noFormPost => 1,
|
||||
fieldType => 'selectBox',
|
||||
defaultValue => [$session->config->get("defaultTemplateParser")],
|
||||
},
|
||||
namespace => {
|
||||
fieldType => 'combo',
|
||||
defaultValue => undef,
|
||||
},
|
||||
templatePacked => {
|
||||
fieldType => 'hidden',
|
||||
defaultValue => undef,
|
||||
noFormPost => 1,
|
||||
},
|
||||
usePacked => {
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
},
|
||||
storageIdExample => {
|
||||
fieldType => 'image',
|
||||
},
|
||||
attachmentsJson => {
|
||||
fieldType => 'JsonTable',
|
||||
},
|
||||
},
|
||||
};
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -171,7 +219,6 @@ override addRevision => sub {
|
|||
my ( $self, $properties, @args ) = @_;
|
||||
my $asset = super();
|
||||
delete $properties->{templatePacked};
|
||||
$asset->addAttachments($self->getAttachments);
|
||||
return $asset;
|
||||
};
|
||||
|
||||
|
|
@ -207,7 +254,6 @@ override duplicate => sub {
|
|||
my $self = shift;
|
||||
my $newTemplate = super();
|
||||
$newTemplate->update({isDefault => 0});
|
||||
$newTemplate->addAttachments($self->getAttachments);
|
||||
if ( my $storageId = $self->get('storageIdExample') ) {
|
||||
my $newStorage = WebGUI::Storage->get( $self->session, $storageId )->copy;
|
||||
$newTemplate->update({ storageIdExample => $newStorage->getId });
|
||||
|
|
@ -225,8 +271,7 @@ Override to add attachments to package data
|
|||
|
||||
override exportAssetData => sub {
|
||||
my ( $self ) = @_;
|
||||
my $data = super();
|
||||
$data->{template_attachments} = $self->getAttachments;
|
||||
my $data = $self->SUPER::exportAssetData;
|
||||
if ( $self->get('storageIdExample') ) {
|
||||
push @{$data->{storage}}, $self->get('storageIdExample');
|
||||
}
|
||||
|
|
@ -249,27 +294,24 @@ If defined, will limit the attachments to this type; e.g., passing
|
|||
|
||||
sub getAttachments {
|
||||
my ( $self, $type ) = @_;
|
||||
my @params = ($self->getId, $self->revisionDate);
|
||||
my $typeString;
|
||||
|
||||
if ($type) {
|
||||
$typeString = 'AND type = ?';
|
||||
push(@params, $type);
|
||||
}
|
||||
return [] if !$self->get('attachmentsJson');
|
||||
|
||||
my $sql = qq{
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_attachments
|
||||
WHERE
|
||||
templateId = ?
|
||||
AND revisionDate = ?
|
||||
$typeString
|
||||
ORDER BY
|
||||
type, sequence ASC
|
||||
};
|
||||
return $self->session->db->buildArrayRefOfHashRefs($sql, \@params);
|
||||
my $attachments = JSON->new->decode( $self->get('attachmentsJson') );
|
||||
|
||||
# We want it all and we want it now
|
||||
if ( !$type ) {
|
||||
return $attachments;
|
||||
}
|
||||
|
||||
my $output = [];
|
||||
for my $attach ( @{$attachments} ) {
|
||||
if ( $attach->{type} eq $type ) {
|
||||
push @{$output}, $attach;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -344,75 +386,31 @@ override getEditForm => sub {
|
|||
);
|
||||
}
|
||||
|
||||
### Template attachments
|
||||
my $session = $self->session;
|
||||
my @headers = map { '<th>' . $i18n->get("attachment header $_") . '</th>' }
|
||||
qw(index type url remove);
|
||||
|
||||
tie my %attachmentTypeNames, 'Tie::IxHash' => (
|
||||
stylesheet => $i18n->get('css label'),
|
||||
headScript => $i18n->get('js head label'),
|
||||
bodyScript => $i18n->get('js body label'),
|
||||
$tabform->getTab('properties')->jsonTable(
|
||||
name => 'attachmentsJson',
|
||||
value => $self->get('attachmentsJson'),
|
||||
label => $i18n->get("attachments display label"),
|
||||
fields => [
|
||||
{
|
||||
type => "text",
|
||||
name => "url",
|
||||
label => $i18n->get('attachment header url'),
|
||||
size => '48',
|
||||
},
|
||||
{
|
||||
type => "select",
|
||||
name => "type",
|
||||
label => $i18n->get('attachment header type'),
|
||||
options => [
|
||||
stylesheet => $i18n->get('css label'),
|
||||
headScript => $i18n->get('js head label'),
|
||||
bodyScript => $i18n->get('js body label'),
|
||||
],
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
my $table = '<table id="attachmentDisplay">';
|
||||
$table .= "<thead><tr>@headers</tr></thead><tbody id='addAnchor'>";
|
||||
foreach my $a ( @{ $self->getAttachments } ) {
|
||||
my ($seq, $type, $url) = @{$a}{qw(sequence type url)};
|
||||
# escape macros in the url so they don't get processed
|
||||
$url =~ s/\^/^/g;
|
||||
my $del = WebGUI::Form::checkbox(
|
||||
$session, {
|
||||
name => 'removeAttachment',
|
||||
value => $url,
|
||||
extras => 'class="id"',
|
||||
}
|
||||
);
|
||||
my @data = (
|
||||
"<td class='index'>$seq</td>",
|
||||
"<td class='type'>$type</td>",
|
||||
"<td class='url'>$url</td>",
|
||||
"<td>$del</td>",
|
||||
);
|
||||
$table .= "<tr class='existingAttachment'>@data</tr>";
|
||||
}
|
||||
$table .= '</tbody></table>';
|
||||
my $properties = $tabform->getTab('properties');
|
||||
my $label = $i18n->get('attachment display label');
|
||||
$properties->raw("<tr><td>$label</td><td>$table</td></tr>");
|
||||
|
||||
my @data = map { "<td>$_</td>" } (
|
||||
WebGUI::Form::integer(
|
||||
$session, { size => '2', id => 'addBoxIndex' }
|
||||
),
|
||||
WebGUI::Form::selectBox(
|
||||
$session, { options => \%attachmentTypeNames, id => 'addBoxType' }
|
||||
),
|
||||
WebGUI::Form::text($session, { id => 'addBoxUrl', size => 40 }),
|
||||
WebGUI::Form::button(
|
||||
$session, {
|
||||
value => $i18n->get('attachment add button'),
|
||||
extras => 'onclick="addClick()"'
|
||||
}
|
||||
),
|
||||
);
|
||||
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
$style->setScript($url->extras('yui/build/yahoo/yahoo-min.js'));
|
||||
$style->setScript($url->extras('yui/build/json/json-min.js'));
|
||||
$style->setScript($url->extras('yui/build/dom/dom-min.js'));
|
||||
$style->setScript($url->extras('yui/build/event/event-min.js'));
|
||||
$style->setScript($url->extras('yui/build/connection/connection-min.js'));
|
||||
$style->setScript($url->extras('yui-webgui/build/i18n/i18n.js'));
|
||||
|
||||
pop(@headers);
|
||||
my $scriptUrl = $url->extras('templateAttachments.js');
|
||||
$table = "<table id='addBox'><tr>@headers</tr><tr>@data</tr></table>";
|
||||
$table .= qq(<script type="text/javascript" src="$scriptUrl"></script>);
|
||||
$label = $i18n->get('attachment add field label');
|
||||
$properties->raw("<tr><td>$label</td><td>$table</td></tr>");
|
||||
|
||||
$properties->image(
|
||||
$tabform->getTab('properties')->image(
|
||||
name => 'storageIdExample',
|
||||
value => $self->getValue('storageIdExample'),
|
||||
label => $i18n->get('field storageIdExample'),
|
||||
|
|
@ -667,6 +665,7 @@ Extends the master class to handle template parsers, namespaces and template att
|
|||
override processPropertiesFromFormPost => sub {
|
||||
my $self = shift;
|
||||
super();
|
||||
my $session = $self->session;
|
||||
# TODO: Perhaps add a way to check template syntax before it blows stuff up?
|
||||
my %data;
|
||||
my $needsUpdate = 0;
|
||||
|
|
@ -688,28 +687,7 @@ override processPropertiesFromFormPost => sub {
|
|||
}
|
||||
|
||||
### Template attachments
|
||||
my $f = $self->session->form;
|
||||
my $p = $f->paramsHashRef;
|
||||
my @nums = grep {$_} map { my ($i) = /^attachmentUrl(\d+)$/; $i } keys %$p;
|
||||
my @add;
|
||||
|
||||
# Remove all attachments first, then re-add whatever's left in the form
|
||||
$self->removeAttachments;
|
||||
|
||||
foreach my $n (@nums) {
|
||||
my ($index, $type, $url) =
|
||||
map { $f->process('attachment' . $_ . $n) }
|
||||
qw(Index Type Url);
|
||||
|
||||
push(
|
||||
@add, {
|
||||
sequence => $index,
|
||||
url => $url,
|
||||
type => $type,
|
||||
}
|
||||
);
|
||||
}
|
||||
$self->addAttachments(\@add);
|
||||
$self->update({ attachmentsJson => $session->form->process( 'attachmentsJson', 'JsonTable' ), });
|
||||
|
||||
return;
|
||||
};
|
||||
|
|
@ -749,66 +727,25 @@ sub processRaw {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge ( )
|
||||
=head2 update
|
||||
|
||||
Extend the master to purge attachments in all revisions.
|
||||
Override update from Asset.pm to handle backwards compatibility with the old
|
||||
packages that contain headBlocks. This will be removed in the future. Don't plan
|
||||
on this being here.
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
sub update {
|
||||
my $self = shift;
|
||||
$self->session->db->write('delete from template_attachments where templateId=?', [$self->getId]);
|
||||
return $self->SUPER::purge(@_);
|
||||
}
|
||||
my $requestedProperties = shift;
|
||||
my $properties = clone($requestedProperties);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purgeRevision ( )
|
||||
|
||||
Extend the master purgeRevision to purge attachments
|
||||
|
||||
=cut
|
||||
|
||||
override purgeRevision => sub {
|
||||
my $self = shift;
|
||||
$self->removeAttachments;
|
||||
return super();
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 removeAttachments ( urls )
|
||||
|
||||
Removes attachments. C<urls> is an arrayref of URLs to remove. If C<urls>
|
||||
is not defined, will remove all attachments for this revision.
|
||||
|
||||
=cut
|
||||
|
||||
sub removeAttachments {
|
||||
my ($self, $urls) = @_;
|
||||
|
||||
my $db = $self->session->db;
|
||||
my $dbh = $db->dbh;
|
||||
my $rmsql = qq{
|
||||
DELETE FROM
|
||||
template_attachments
|
||||
WHERE
|
||||
templateId = ?
|
||||
AND revisionDate = ?
|
||||
};
|
||||
|
||||
if ( $urls && @{$urls} ) {
|
||||
my $in = join(',', map { $dbh->quote($_) } @{$urls});
|
||||
$rmsql .= qq{
|
||||
AND url IN ($in)
|
||||
};
|
||||
if (exists $properties->{headBlock}) {
|
||||
$properties->{extraHeadTags} .= $properties->{headBlock};
|
||||
delete $properties->{headBlock};
|
||||
}
|
||||
|
||||
my @params = (
|
||||
$self->getId,
|
||||
$self->get('revisionDate'),
|
||||
);
|
||||
$db->write($rmsql, \@params);
|
||||
$self->SUPER::update($properties);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -241,12 +241,36 @@ sub _listViewPageInterval_builder {
|
|||
}
|
||||
|
||||
property icalFeeds => (
|
||||
noFormPost => 1,
|
||||
fieldType => "textarea",
|
||||
default => sub { return []; },
|
||||
traits => ['Array', 'WebGUI::Definition::Meta::Property::Serialize',],
|
||||
isa => 'WebGUI::Type::JSONArray',
|
||||
coerce => 1,
|
||||
fieldType => "JsonTable",
|
||||
defaultValue => [],
|
||||
serialize => 1,
|
||||
tab => "feeds",
|
||||
fields => [
|
||||
{
|
||||
name => 'feedId',
|
||||
type => 'id',
|
||||
},
|
||||
{
|
||||
name => 'url',
|
||||
type => 'text',
|
||||
size => '40',
|
||||
label => $i18n->get('Feed URL'),
|
||||
},
|
||||
{
|
||||
name => 'status',
|
||||
type => 'readonly',
|
||||
label => $i18n->get('434','WebGUI'),
|
||||
},
|
||||
{
|
||||
name => 'lastUpdated',
|
||||
type => 'readonly',
|
||||
label => $i18n->get('454', 'WebGUI'),
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
property icalInterval => (
|
||||
|
|
@ -511,169 +535,17 @@ sub deleteFeed {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getEditForm
|
||||
=head2 getEditTabs ( )
|
||||
|
||||
Adds an additional tab for feeds.
|
||||
|
||||
TODO: Abstract the Javascript enough to export into extras/yui-webgui for use
|
||||
in other areas.
|
||||
Add the feeds tab to the edit form
|
||||
|
||||
=cut
|
||||
|
||||
override getEditForm => sub {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = super();
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Calendar");
|
||||
|
||||
my $tab = $form->addTab("feeds",$i18n->get("feeds"), 6);
|
||||
$tab->raw("<tr><td>");
|
||||
|
||||
$tab->raw(<<'ENDJS');
|
||||
<script type="text/javascript">
|
||||
var FeedsManager = new Object();
|
||||
|
||||
FeedsManager.addFeed = function (table,rowId,params) {
|
||||
// TODO: Verify that feed URL is valid
|
||||
|
||||
var table = document.getElementById(table);
|
||||
|
||||
// If id is "new"
|
||||
// Add a number on the end.
|
||||
if (rowId == "new")
|
||||
rowId = "new" + Math.round(Math.random() * 10000000000000000);
|
||||
|
||||
// Create 5 cells
|
||||
var cells = new Array();
|
||||
for (var i = 0; i < 5; i++)
|
||||
cells[i] = document.createElement("td");
|
||||
|
||||
|
||||
/*** [0] - Delete button */
|
||||
var button = document.createElement("img");
|
||||
button.setAttribute("src","/extras/wobject/Calendar/images/delete.gif");
|
||||
button.setAttribute("border","0");
|
||||
|
||||
var deleteLink = document.createElement("a");
|
||||
deleteLink.setAttribute("href","#");
|
||||
YAHOO.util.Event.addListener(deleteLink, "click", function (e, rowId) {
|
||||
FeedsManager.deleteFeed('feeds',rowId);
|
||||
YAHOO.util.Event.preventDefault(e);
|
||||
}, rowId);
|
||||
deleteLink.appendChild(button);
|
||||
|
||||
cells[0].appendChild(deleteLink);
|
||||
|
||||
|
||||
/*** [1] - Feed link for teh clicking and form element for teh saving */
|
||||
var feedLink = document.createElement("a");
|
||||
feedLink.setAttribute("href",params.url);
|
||||
feedLink.setAttribute("target","_new"); // TODO: Use JS to open window. target="" is deprecated
|
||||
feedLink.appendChild(document.createTextNode(params.url));
|
||||
|
||||
var formElement = document.createElement("input");
|
||||
formElement.setAttribute("type","hidden");
|
||||
formElement.setAttribute("name","feeds-"+rowId);
|
||||
formElement.setAttribute("value",params.url);
|
||||
|
||||
cells[1].appendChild(feedLink);
|
||||
cells[1].appendChild(formElement);
|
||||
|
||||
|
||||
/*** [2] - Result (new) */
|
||||
if (params.lastResult == undefined)
|
||||
params.lastResult = "new";
|
||||
var lastResult = document.createTextNode(params.lastResult);
|
||||
|
||||
cells[2].appendChild(lastResult);
|
||||
|
||||
|
||||
/*** [3] - Last updated */
|
||||
if (params.lastUpdated == undefined)
|
||||
params.lastUpdated = "never";
|
||||
var lastUpdated = document.createTextNode(params.lastUpdated);
|
||||
|
||||
cells[3].appendChild(lastUpdated);
|
||||
|
||||
|
||||
/*** [4] - Update now! */
|
||||
/* TODO */
|
||||
|
||||
|
||||
/* Add the row to the table */
|
||||
var row = document.createElement("tr");
|
||||
row.setAttribute("id",rowId);
|
||||
for (var i = 0; i < cells.length; i++)
|
||||
row.appendChild(cells[i]);
|
||||
|
||||
var tbody = table.getElementsByTagName('tbody')[0];
|
||||
if (tbody)
|
||||
tbody.appendChild(row);
|
||||
else
|
||||
table.appendChild(row);
|
||||
FeedsManager.updateFeed(table.getAttribute("id"),rowId);
|
||||
}
|
||||
|
||||
|
||||
FeedsManager.updateFeed = function (table,rowId) {
|
||||
/* TODO */
|
||||
|
||||
}
|
||||
|
||||
|
||||
FeedsManager.deleteFeed = function (table,rowId) {
|
||||
row = document.getElementById(rowId);
|
||||
|
||||
row.parentNode.removeChild(row);
|
||||
}
|
||||
|
||||
|
||||
FeedsManager.setFeed = function (table,rowId,params) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
ENDJS
|
||||
|
||||
|
||||
my $addFeed = $i18n->get('Add a feed');
|
||||
my $add = $i18n->get('Add');
|
||||
my $feedUrl = $i18n->get('Feed URL');
|
||||
my $status = $i18n->get('434', 'WebGUI');
|
||||
my $lastUpdated = $i18n->get('454', 'WebGUI');
|
||||
$tab->raw(<<"ENDHTML");
|
||||
<label for="addFeed">$addFeed</label>
|
||||
<input type="text" size="60" id="addFeed" name="addFeed" value="" />
|
||||
<input type="button" value="$add" onclick="FeedsManager.addFeed('feeds','new',{ 'url' : this.form.addFeed.value }); this.form.addFeed.value=''" />
|
||||
|
||||
<table id="feeds" style="width: 100%;">
|
||||
<thead>
|
||||
<th style="width: 30px;"> </th>
|
||||
<th style="width: 50%;">$feedUrl</th>
|
||||
<th>$status</th>
|
||||
<th>$lastUpdated</th>
|
||||
<th> </th>
|
||||
</thead>
|
||||
</table>
|
||||
ENDHTML
|
||||
|
||||
|
||||
|
||||
# Add the existing feeds
|
||||
my $feeds = $self->getFeeds();
|
||||
$tab->raw('<script type="text/javascript">'."\n");
|
||||
for my $feed (@{ $feeds }) {
|
||||
my $feedId = $feed->{feedId};
|
||||
$tab->raw("FeedsManager.addFeed('feeds','".$feedId."',".JSON->new->encode( $feed ).");\n");
|
||||
}
|
||||
$tab->raw('</script>');
|
||||
|
||||
|
||||
$tab->raw("</td></tr>");
|
||||
return $form;
|
||||
};
|
||||
sub getEditTabs {
|
||||
my ( $self ) = @_;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Calendar");
|
||||
return $self->SUPER::getEditTabs, ["feeds",$i18n->get("feeds"), 6];
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -769,7 +641,7 @@ sub getEventsIn {
|
|||
&& Event.endTime IS NULL
|
||||
&&
|
||||
!(
|
||||
Event.startDate > '$endDate'
|
||||
Event.startDate > SUBDATE('$endDate', INTERVAL 1 DAY)
|
||||
|| Event.endDate < '$startDate'
|
||||
)
|
||||
)
|
||||
|
|
@ -794,7 +666,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',
|
||||
|
|
@ -1004,37 +876,6 @@ override processPropertiesFromFormPost => sub {
|
|||
$self->createSubscriptionGroup();
|
||||
}
|
||||
|
||||
$self->session->errorHandler->info( "DEFAULT VIEW:" . $self->defaultView );
|
||||
|
||||
### Get feeds from the form
|
||||
# Workaround WebGUI::Session::Form->param bug that returns duplicate
|
||||
# names.
|
||||
my %feeds;
|
||||
for my $feedId ( grep /^feeds-/, ($form->param()) ) {
|
||||
$feedId =~ s/^feeds-//;
|
||||
$feeds{$feedId}++;
|
||||
}
|
||||
my @feedsFromForm = keys %feeds;
|
||||
|
||||
# Delete old feeds that are not in @feeds
|
||||
my @oldFeeds = map { $_->{feedId} } @{ $self->getFeeds };
|
||||
|
||||
for my $feedId (@oldFeeds) {
|
||||
if (!isIn($feedId, @feedsFromForm)) {
|
||||
$self->deleteFeed($feedId);
|
||||
}
|
||||
}
|
||||
|
||||
# Create new feeds
|
||||
for my $feedId (grep /^new(\d+)/, @feedsFromForm) {
|
||||
$self->addFeed({
|
||||
url => $form->param("feeds-".$feedId),
|
||||
feedType => "ical",
|
||||
lastUpdated => 'never',
|
||||
lastResult => '',
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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') {
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ sub view {
|
|||
$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 $assetIter = $start->getLineageIterator(\@includedRelationships,\%rules);
|
||||
my $currentLineage = $current->lineage;
|
||||
my $lineageToSkip = "noskip";
|
||||
my $absoluteDepthOfLastPage;
|
||||
|
|
@ -419,7 +419,15 @@ sub view {
|
|||
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/);
|
||||
|
|
|
|||
|
|
@ -288,9 +288,14 @@ sub getFolder {
|
|||
##For a fully automatic commit, save the current tag, create a new one
|
||||
##with the commit without approval workflow, commit it, then restore
|
||||
##the original if it exists
|
||||
my $oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');
|
||||
my $newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', });
|
||||
$newVersionTag->setWorking;
|
||||
my ($oldVersionTag, $newVersionTag);
|
||||
$oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate');
|
||||
|
||||
if ($self->hasBeenCommitted) {
|
||||
$newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', });
|
||||
$newVersionTag->setWorking;
|
||||
$newVersionTag->set({ name => 'Adding folder '. $folderName. ' to archive '. $self->getUrl});
|
||||
}
|
||||
|
||||
##Call SUPER because my addChild calls getFolder
|
||||
$folder = $self->addChild({
|
||||
|
|
@ -301,7 +306,7 @@ sub getFolder {
|
|||
isHidden => 1,
|
||||
styleTemplateId => $self->styleTemplateId,
|
||||
});
|
||||
$newVersionTag->commit();
|
||||
$newVersionTag->commit() if $newVersionTag;
|
||||
##Restore the old one, if it exists
|
||||
$oldVersionTag->setWorking() if $oldVersionTag;
|
||||
|
||||
|
|
|
|||
|
|
@ -996,20 +996,8 @@ sub getFormPlugin {
|
|||
eval { WebGUI::Pluggable::load($class) };
|
||||
if ($class->isa('WebGUI::Form::List')) {
|
||||
delete $param{size};
|
||||
|
||||
my $values = WebGUI::Operation::Shared::secureEval($session,$data->{possibleValues});
|
||||
if (ref $values eq 'HASH') {
|
||||
$param{options} = $values;
|
||||
}
|
||||
else{
|
||||
my %options;
|
||||
tie %options, 'Tie::IxHash';
|
||||
foreach (split(/\n/x, $data->{possibleValues})) {
|
||||
s/\s+$//x; # remove trailing spaces
|
||||
$options{$_} = $_;
|
||||
}
|
||||
$param{options} = \%options;
|
||||
}
|
||||
$param{options} = $values;
|
||||
}
|
||||
|
||||
if ($data->{fieldType} eq "YesNo") {
|
||||
|
|
@ -2408,6 +2396,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 +2407,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 +2455,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 +2539,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 +2549,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 {
|
||||
|
|
@ -3233,7 +3226,7 @@ $self->session->form->process($_) eq "") {
|
|||
sequenceNumber');
|
||||
while (my $field = $fields->hashRef) {
|
||||
if ($field->{searchIn}){
|
||||
my $searchForm = $self->getFormElement($field);
|
||||
my $searchForm = $self->getFormPlugin($field, 1);
|
||||
my $searchTextForm = WebGUI::Form::Text($self->session, {
|
||||
name=>"field_".$field->{fieldId},
|
||||
size=>25,
|
||||
|
|
@ -3248,9 +3241,10 @@ sequenceNumber');
|
|||
push(@searchFields_loop, {
|
||||
"searchFields_fieldId" => $field->{fieldId},
|
||||
"searchFields_label" => $field->{label},
|
||||
"searchFields_form" => $searchForm,
|
||||
"searchFields_form" => $searchForm->toHtml,
|
||||
"searchFields_textForm" => $searchTextForm,
|
||||
"searchFields_is".$fieldType => 1,
|
||||
"searchFields_listType" => $searchForm->isa('WebGUI::Form::List'),
|
||||
});
|
||||
|
||||
my @searchValue = $session->form->process("field_".$field->{fieldId});
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ sub getAssetsInClipboard {
|
|||
{
|
||||
statesToInclude => ["clipboard"],
|
||||
returnObjects => 1,
|
||||
statusToInclude => [qw/approved pending archived/],
|
||||
whereClause => $limit,
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -420,10 +420,6 @@ An array reference containing a list of asset classes to remove from the result
|
|||
|
||||
A boolean indicating that we should return objects rather than asset ids.
|
||||
|
||||
=head4 returnSQL
|
||||
|
||||
A boolean indicating that we should return the sql statement rather than asset ids.
|
||||
|
||||
=head4 invertTree
|
||||
|
||||
A boolean indicating whether the resulting asset tree should be returned in reverse order.
|
||||
|
|
@ -446,7 +442,8 @@ A string containing as asset class to join in. There is no real reason to use a
|
|||
|
||||
=head4 whereClause
|
||||
|
||||
A string containing extra where clause information for the query.
|
||||
A string containing extra WHERE clause information for the query. The AND conjunction will be added internally, so the clause
|
||||
should not start with AND.
|
||||
|
||||
=head4 orderByClause
|
||||
|
||||
|
|
@ -595,6 +592,7 @@ An integer describing how many levels of ancestry from the start point that shou
|
|||
=head4 excludeClasses
|
||||
|
||||
An array reference containing a list of asset classes to remove from the result set. The opposite of the includOnlyClasses rule.
|
||||
Each class is internally appended with a SQL wildcard, so any subclass will also be excluded.
|
||||
|
||||
=head4 invertTree
|
||||
|
||||
|
|
@ -740,7 +738,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}) {
|
||||
|
|
|
|||
|
|
@ -57,39 +57,20 @@ sub getAssetsInTrash {
|
|||
my $self = shift;
|
||||
my $limitToUser = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
my @assets;
|
||||
my $limit;
|
||||
if ($limitToUser) {
|
||||
$limit = "and asset.stateChangedBy=".$self->session->db->quote($userId);
|
||||
$limit = "asset.stateChangedBy=".$self->session->db->quote($userId);
|
||||
}
|
||||
my $sth = $self->session->db->read("
|
||||
select
|
||||
asset.assetId,
|
||||
assetData.revisionDate
|
||||
from
|
||||
asset
|
||||
left join
|
||||
assetData on asset.assetId=assetData.assetId
|
||||
where
|
||||
asset.state='trash'
|
||||
and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId)
|
||||
$limit
|
||||
group by
|
||||
assetData.assetId
|
||||
order by
|
||||
assetData.title desc
|
||||
");
|
||||
while (my ($id, $date) = $sth->array) {
|
||||
my $asset = WebGUI::Asset->newById($self->session, $id, $date);
|
||||
if (!Exception::Class->caught()) {
|
||||
push(@assets, $asset);
|
||||
}
|
||||
else {
|
||||
$self->session->errorHandler->error("AssetTrash::getAssetsInTrash - failed to instanciate asset with assetId $id and revisionDate $date");
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
return \@assets;
|
||||
my $root = WebGUI::Asset->getRoot($self->session);
|
||||
return $root->getLineage(
|
||||
["descendants", ],
|
||||
{
|
||||
statesToInclude => ["trash"],
|
||||
statusToInclude => [qw/approved pending archived/],
|
||||
returnObjects => 1,
|
||||
whereClause => $limit,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -800,7 +800,9 @@ Returns whether or not a method is callable
|
|||
|
||||
sub isCallable {
|
||||
my $self = shift;
|
||||
return isIn($_[0],@{$self->{callable}})
|
||||
return 1 if isIn($_[0],@{$self->{callable}});
|
||||
return 1 if $self->can( 'www_' . $_[0] );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
297
lib/WebGUI/Auth/Twitter.pm
Normal file
297
lib/WebGUI/Auth/Twitter.pm
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
package WebGUI::Auth::Twitter;
|
||||
|
||||
=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::Auth';
|
||||
use Net::Twitter;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Auth::Twitter -- Twitter auth for WebGUI
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Allow WebGUI to authenticate to WebGUI
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 new ( ... )
|
||||
|
||||
Create a new object
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $self = shift->SUPER::new(@_);
|
||||
return bless $self, __PACKAGE__; # Auth requires rebless
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 createTwitterUser ( twitterUserId, username )
|
||||
|
||||
my $user = $self->createTwitterUser( $twitterUserId, $username );
|
||||
|
||||
Create a new Auth::Twitter user with the given twitter userId and screen name.
|
||||
|
||||
=cut
|
||||
|
||||
sub createTwitterUser {
|
||||
my ( $self, $twitterUserId, $username ) = @_;
|
||||
my $user = WebGUI::User->create( $self->session );
|
||||
$user->username( $username );
|
||||
$self->saveParams( $user->userId, $self->authMethod, {
|
||||
"twitterUserId" => $twitterUserId,
|
||||
} );
|
||||
return $user;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 editUserSettingsForm ( )
|
||||
|
||||
Return the form to edit the settings of this Auth module
|
||||
|
||||
=cut
|
||||
|
||||
sub editUserSettingsForm {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my ( $setting ) = $session->quick(qw( setting ));
|
||||
my $i18n = WebGUI::International->new( $session, 'Auth_Twitter' );
|
||||
|
||||
my $keyUrl = 'http://dev.twitter.com/apps/new';
|
||||
|
||||
my $f = WebGUI::HTMLForm->new( $session );
|
||||
|
||||
$f->yesNo(
|
||||
name => 'twitterEnabled',
|
||||
value => $setting->get( 'twitterEnabled' ),
|
||||
label => $i18n->get('enabled'),
|
||||
hoverHelp => $i18n->get('enabled help'),
|
||||
);
|
||||
|
||||
$f->text(
|
||||
name => 'twitterConsumerKey',
|
||||
value => $setting->get( 'twitterConsumerKey' ),
|
||||
label => $i18n->get('consumer key'),
|
||||
hoverHelp => $i18n->get('consumer key help'),
|
||||
subtext => sprintf( $i18n->get('get key'), ($keyUrl) x 2 ),
|
||||
);
|
||||
|
||||
$f->text(
|
||||
name => 'twitterConsumerSecret',
|
||||
value => $setting->get( 'twitterConsumerSecret' ),
|
||||
label => $i18n->get('consumer secret'),
|
||||
hoverHelp => $i18n->get('consumer secret help'),
|
||||
);
|
||||
|
||||
$f->template(
|
||||
name => 'twitterTemplateIdChooseUsername',
|
||||
value => $setting->get( 'twitterTemplateIdChooseUsername' ),
|
||||
label => $i18n->get('choose username template'),
|
||||
hoverHelp => $i18n->get('choose username template help'),
|
||||
namespace => 'Auth/Twitter/ChooseUsername',
|
||||
);
|
||||
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 editUserSettingsFormSave ( )
|
||||
|
||||
Process the form for this Auth module's settings
|
||||
|
||||
=cut
|
||||
|
||||
sub editUserSettingsFormSave {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my ( $form, $setting ) = $session->quick(qw( form setting ));
|
||||
|
||||
my @fields = qw(
|
||||
twitterEnabled twitterConsumerKey twitterConsumerSecret
|
||||
twitterTemplateIdChooseUsername
|
||||
);
|
||||
for my $field ( @fields ) {
|
||||
$setting->set( $field, $form->get( $field ) );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getTemplateChooseUsername ( )
|
||||
|
||||
Get the template to choose a username
|
||||
|
||||
=cut
|
||||
|
||||
sub getTemplateChooseUsername {
|
||||
my ( $self ) = @_;
|
||||
my $templateId = $self->session->setting->get('twitterTemplateIdChooseUsername');
|
||||
return WebGUI::Asset::Template->new( $self->session, $templateId );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getTwitter ( )
|
||||
|
||||
Get the Net::Twitter object with the appropriate keys
|
||||
|
||||
=cut
|
||||
|
||||
sub getTwitter {
|
||||
my ( $self ) = @_;
|
||||
my $setting = $self->session->setting;
|
||||
if ( !$self->{_twitter} ) {
|
||||
my $nt = Net::Twitter->new(
|
||||
traits => [qw/API::REST OAuth/],
|
||||
consumer_key => $setting->get( 'twitterConsumerKey' ), # Test: '3hvJpBr73pa4FycNrqw',
|
||||
consumer_secret => $setting->get( 'twitterConsumerSecret' ), # Test: 'E4M5DJ66RAXiHgNCnJES96yTqglttsUes6OBcw9A',
|
||||
);
|
||||
|
||||
$self->{_twitter} = $nt;
|
||||
}
|
||||
return $self->{_twitter};
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_login ( )
|
||||
|
||||
Begin the login procedure
|
||||
|
||||
=cut
|
||||
|
||||
sub www_login {
|
||||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
my ( $url, $scratch, $setting ) = $session->quick( qw( url scratch setting ) );
|
||||
|
||||
my $nt = $self->getTwitter;
|
||||
|
||||
my $auth_url = $nt->get_authentication_url(
|
||||
callback => $url->getSiteURL . $url->page('op=auth&authType=Twitter&method=callback'),
|
||||
);
|
||||
|
||||
$scratch->set( 'AuthTwitterToken', $nt->request_token );
|
||||
$scratch->set( 'AuthTwitterTokenSecret', $nt->request_token_secret );
|
||||
|
||||
$session->http->setRedirect($auth_url);
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_callback ( )
|
||||
|
||||
Callback from the Twitter authentication. Try to log the user in, creating a
|
||||
new user account if necessary.
|
||||
|
||||
If the username is taken, allow the user to choose a new one.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_callback {
|
||||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
my ( $form, $scratch, $db, $setting ) = $session->quick(qw( form scratch db setting ));
|
||||
|
||||
my $verifier = $form->get('oauth_verifier');
|
||||
|
||||
my $nt = $self->getTwitter;
|
||||
$nt->request_token( $scratch->get('AuthTwitterToken') );
|
||||
$nt->request_token_secret( $scratch->get('AuthTwitterTokenSecret') );
|
||||
|
||||
my ($access_token, $access_token_secret, $twitterUserId, $twitterScreenName )
|
||||
= $nt->request_access_token(verifier => $verifier);
|
||||
|
||||
### Log the user in
|
||||
# Find their twitter user ID
|
||||
my $userId = $db->quickScalar(
|
||||
"SELECT userId FROM authentication WHERE authMethod = ? AND fieldName = ? AND fieldData = ?",
|
||||
[ "Twitter", "twitterUserId", $twitterUserId ],
|
||||
);
|
||||
|
||||
# Returning user
|
||||
if ( $userId ) {
|
||||
my $user = WebGUI::User->new( $session, $userId );
|
||||
$self->user( $user );
|
||||
return $self->login;
|
||||
}
|
||||
# Otherwise see if their screen name exists and create a user
|
||||
elsif ( !WebGUI::User->newByUsername( $session, $twitterScreenName ) ) {
|
||||
my $user = $self->createTwitterUser( $twitterUserId, $twitterScreenName );
|
||||
$self->user( $user );
|
||||
return $self->login;
|
||||
}
|
||||
|
||||
# Otherwise ask them for a new username to use
|
||||
my $i18n = WebGUI::International->new( $session, 'Auth_Twitter' );
|
||||
$scratch->set( "AuthTwitterUserId", $twitterUserId );
|
||||
my $tmpl = $self->getTemplateChooseUsername;
|
||||
my $var = {
|
||||
message => sprintf( $i18n->get("twitter screen name taken"), $twitterScreenName ),
|
||||
};
|
||||
|
||||
return $tmpl->process( $var );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_setUsername ( )
|
||||
|
||||
Set the username for a twitter user. Only used as part of the initial twitter
|
||||
registration.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_setUsername {
|
||||
my ( $self ) = @_;
|
||||
my $session = $self->session;
|
||||
my ( $form, $scratch, $db ) = $session->quick(qw( form scratch db ));
|
||||
my $i18n = WebGUI::International->new( $session, 'Auth_Twitter' );
|
||||
|
||||
# Don't allow just anybody to set a username
|
||||
return unless $scratch->get('AuthTwitterUserId');
|
||||
|
||||
my $username = $form->get('newUsername');
|
||||
if ( !WebGUI::User->newByUsername( $session, $username ) ) {
|
||||
my $twitterUserId = $scratch->get( "AuthTwitterUserId" );
|
||||
my $user = $self->createTwitterUser( $twitterUserId, $username );
|
||||
$self->user( $user );
|
||||
return $self->login;
|
||||
}
|
||||
|
||||
# Username is again taken! Noooooo!
|
||||
my $tmpl = $self->getTemplateChooseUsername;
|
||||
my $var = {
|
||||
message => sprintf( $i18n->get("webgui username taken"), $username ),
|
||||
};
|
||||
|
||||
return $tmpl->process( $var );
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -373,9 +373,6 @@ sub www_manage {
|
|||
$session->style->setScript( $session->url->extras( 'yui-webgui/build/form/form.js' ) );
|
||||
|
||||
$session->style->setRawHeadTags( <<ENDHTML );
|
||||
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.6.0/build/logger/assets/skins/sam/logger.css">
|
||||
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/logger/logger-min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
YAHOO.util.Event.onDOMReady( WebGUI.AssetManager.initManager );
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ JS
|
|||
$output .= '<div class="crumbTrail">'.join(" > ", @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>';
|
||||
|
|
|
|||
215
lib/WebGUI/Form/JsonTable.pm
Normal file
215
lib/WebGUI/Form/JsonTable.pm
Normal file
|
|
@ -0,0 +1,215 @@
|
|||
package WebGUI::Form::JsonTable;
|
||||
|
||||
=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;
|
||||
use JSON;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Form::JsonTable
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Creates a table to edit a JSON blob
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This is a subclass of WebGUI::Form::Control.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 fields
|
||||
|
||||
An array of hashrefs defining the fields in this JsonTable.
|
||||
|
||||
{
|
||||
type => "text", # One of "text", "select", or "readonly"
|
||||
name => "name", # The name of the field
|
||||
label => "Name", # an i18n label
|
||||
options => [ option => "label", ... ] # Options for select fields
|
||||
}
|
||||
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
push @{$definition}, {
|
||||
fields => {
|
||||
defaultValue => [],
|
||||
},
|
||||
};
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the name of the form control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($class, $session) = @_;
|
||||
return WebGUI::International->new($session, "Form_JsonTable")->get("topicName");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getOriginalValue ( )
|
||||
|
||||
Get the original value, encoding to JSON if necessary
|
||||
|
||||
=cut
|
||||
|
||||
sub getOriginalValue {
|
||||
my ( $self ) = @_;
|
||||
my $value = $self->SUPER::getOriginalValue;
|
||||
if ( ref $value eq "ARRAY" ) {
|
||||
return JSON->new->encode( $value );
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( value )
|
||||
|
||||
Get the value of the field. Substitute id fields with GUIDs.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my ( $self, $value ) = @_;
|
||||
$value ||= $self->SUPER::getValue;
|
||||
|
||||
$self->session->log->info( "JsonTable Got $value from form" );
|
||||
$value = JSON->new->decode( $value );
|
||||
|
||||
for my $row ( @{$value} ) {
|
||||
for my $field ( @{$self->get('fields')} ) {
|
||||
if ( $field->{type} eq 'id' && $row->{ $field->{name} } eq "new" ) {
|
||||
$row->{ $field->{name} } = $self->session->id->generate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return JSON->new->encode( $value );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an input tag of type text.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my ( $url, $style ) = $session->quick(qw( url style ));
|
||||
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->getOriginalValue)));
|
||||
my $output = '';
|
||||
|
||||
# Table headers
|
||||
$output .= '<table id="' . $self->get( 'id' ) . '"><thead><tr>';
|
||||
for my $field ( @{ $self->get('fields') } ) {
|
||||
$output .= '<th>' . $field->{label} . '</th>';
|
||||
}
|
||||
$output .= '<th> </th>'; # Extra column for buttons
|
||||
|
||||
# Buttons to add rows in the table footer
|
||||
my $cols = scalar @{ $self->get('fields') } + 1; # Extra column for buttons
|
||||
$output .= '</thead><tfoot><tr><td colspan="' . $cols . '">'
|
||||
. '<button id="' . $self->get('id') . '_add">' . "Add" . '</button>'
|
||||
. '</td></tr></tfoot>'
|
||||
;
|
||||
|
||||
# Build a hidden row to copy for new rows
|
||||
$output .= '<tbody><tr class="new_row" style="display: none">';
|
||||
for my $field ( @{ $self->get('fields') } ) {
|
||||
my $fieldName = join "_", $self->get('name'), $field->{name};
|
||||
# Drawing using raw HTML to sanitize field HTML and allow future merging with DataTable
|
||||
my $fieldHtml;
|
||||
|
||||
if ( $field->{type} eq "text" ) {
|
||||
$fieldHtml = '<input type="text" name="' . $fieldName . '" size="' . $field->{size} . '" />';
|
||||
}
|
||||
elsif ( $field->{type} eq "select" ) {
|
||||
$fieldHtml = '<select name="' . $fieldName . '" size="' . $field->{size} . '">';
|
||||
my $opts = @{$field->{options}} / 2; # options is arrayref of name => label
|
||||
for my $i ( 0 .. $opts-1 ) {
|
||||
my $optValue = $field->{options}[$i*2];
|
||||
my $optLabel = $field->{options}[$i*2+1];
|
||||
$fieldHtml .= '<option value="' . $optValue . '">' . $optLabel . '</option>';
|
||||
}
|
||||
$fieldHtml .= '</select>';
|
||||
}
|
||||
elsif ( $field->{type} eq "id" ) {
|
||||
$fieldHtml .= '<input type="hidden" class="jsontable_id" name="' . $fieldName . '" value="new" />';
|
||||
}
|
||||
else { # Readonly or unknown
|
||||
$fieldHtml = ' ';
|
||||
}
|
||||
|
||||
$output .= '<td>' . $fieldHtml . '</td>';
|
||||
}
|
||||
|
||||
$output .= '<td></td>' # Extra cell for buttons
|
||||
. '</tr></tbody></table>';
|
||||
|
||||
# Build the existing rows
|
||||
$output .= '<input type="hidden" name="' . $self->get('name') . '" value="' . $value . '" />';
|
||||
|
||||
# Existing rows are entirely built in javascript from the JSON in the hidden field
|
||||
$style->setScript(
|
||||
$url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'),
|
||||
{ type => 'text/javascript' },
|
||||
);
|
||||
$style->setScript(
|
||||
$url->extras('yui/build/json/json-min.js'),
|
||||
{ type => 'text/javascript' },
|
||||
);
|
||||
$output .= sprintf '<script src="%s" type="text/javascript"></script>',
|
||||
$url->extras('yui-webgui/build/form/jsontable.js');
|
||||
$output .= '<script type="text/javascript">'
|
||||
. q{new WebGUI.Form.JsonTable("} . $self->get('name') . q{","} . $self->get( 'id' ) . q{", }
|
||||
. JSON->new->encode( $self->get('fields') ) . q{ );}
|
||||
. '</script>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
#vim:ft=perl
|
||||
|
|
@ -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,16 +138,39 @@ sub isDynamicCompatible {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Renders a template picker control.
|
||||
Returns the tempalte name of the selected template.
|
||||
|
||||
=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);
|
||||
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 = WebGUI::Asset::Template->newById($self->session, $assetId);
|
||||
|
|
@ -155,8 +178,26 @@ sub toHtml {
|
|||
delete $templateList->{$assetId};
|
||||
}
|
||||
}
|
||||
$self->set("options", $templateList);
|
||||
return $self->SUPER::toHtml();
|
||||
|
||||
$self->set( 'options', $templateList );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a template picker control.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
|
||||
$self->setOptions;
|
||||
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -283,6 +283,7 @@ sub clearCaches {
|
|||
$stow->delete("groupObj");
|
||||
$stow->delete("isInGroup");
|
||||
$stow->delete("gotGroupsInGroup");
|
||||
$session->stow->delete("gotGroupsForUser");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ our $HELP = {
|
|||
{ 'name' => 'reply.synopsis' },
|
||||
{ 'name' => 'reply.content' },
|
||||
{ 'name' => 'reply.userDefinedN' },
|
||||
{ 'name' => 'isSubscribedToCs' },
|
||||
{ 'name' => 'subscribe.form' },
|
||||
{ 'name' => 'isNewThread' },
|
||||
{ 'name' => 'archive.form' },
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ our $HELP = {
|
|||
{ 'name' => 'searchFields_textForm' },
|
||||
{ 'name' => 'searchFields_label' },
|
||||
{ 'name' => 'searchFields_is__fieldType__' },
|
||||
{ 'name' => 'searchFields_listType' },
|
||||
],
|
||||
},
|
||||
{ 'name' => 'listOfThings',
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ our $HELP = {
|
|||
name => "quantity",
|
||||
description => "quantity help",
|
||||
},
|
||||
{
|
||||
name => "removeBox",
|
||||
description => "removeBox help",
|
||||
},
|
||||
{
|
||||
name => "dateAdded",
|
||||
description => "dateAdded help",
|
||||
|
|
@ -102,32 +106,36 @@ our $HELP = {
|
|||
description => "price help",
|
||||
},
|
||||
{
|
||||
name => "removeButton",
|
||||
description => "removeButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipToButton",
|
||||
description => "item shipToButton help",
|
||||
name => "itemAddressChooser",
|
||||
description => "itemAddressChooser help",
|
||||
},
|
||||
{
|
||||
name => "shippingAddress",
|
||||
description => "shippingAddress help",
|
||||
},
|
||||
{
|
||||
name => "isCashier",
|
||||
name => "taxRate",
|
||||
description => "item taxRate help",
|
||||
},
|
||||
{
|
||||
name => "posLookupForm",
|
||||
name => "taxAmount",
|
||||
description => "item taxAmount help",
|
||||
},
|
||||
{
|
||||
name => "posUsername",
|
||||
name => "pricePlusTax",
|
||||
description => "item pricePlusTax help",
|
||||
},
|
||||
{
|
||||
name => "posUserId",
|
||||
name => "extendedPricePlusTax",
|
||||
description => "item extendedPricePlusTax help",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name => "message",
|
||||
description => "message help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "error",
|
||||
description => "error help",
|
||||
|
|
@ -152,10 +160,26 @@ our $HELP = {
|
|||
name => "continueShoppingButton",
|
||||
description => "continueShoppingButton help",
|
||||
},
|
||||
{
|
||||
name => "minimumCartAmount",
|
||||
description => "minimumCartAmount help",
|
||||
},
|
||||
{
|
||||
name => "subtotalPrice",
|
||||
description => "subtotalPrice help",
|
||||
},
|
||||
{
|
||||
name => "shippingAddressChooser",
|
||||
description => "shippingAddressChooser help",
|
||||
},
|
||||
{
|
||||
name => "billingAddressChooser",
|
||||
description => "billingAddressChooser help",
|
||||
},
|
||||
{
|
||||
name => "sameShippingAsBilling",
|
||||
description => "sameShippingAsBilling help",
|
||||
},
|
||||
{
|
||||
name => "shippingPrice",
|
||||
description => "shippingPrice help",
|
||||
|
|
@ -164,19 +188,27 @@ our $HELP = {
|
|||
name => "tax",
|
||||
description => "tax help",
|
||||
},
|
||||
{
|
||||
name => "userIsVisitor",
|
||||
description => "userIsVisitor help",
|
||||
},
|
||||
{
|
||||
name => "shippableItemsInCart",
|
||||
},
|
||||
{
|
||||
name => "hasShippingAddress",
|
||||
description => "hasShippingAddress help",
|
||||
},
|
||||
{
|
||||
name => "shippingAddress",
|
||||
description => "shippingAddress help",
|
||||
},
|
||||
{
|
||||
name => "shippingOptions",
|
||||
description => "shippingOptions help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "paymentOptions",
|
||||
description => "paymentOptions help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "totalPrice",
|
||||
description => "totalPrice help",
|
||||
|
|
@ -190,6 +222,158 @@ our $HELP = {
|
|||
name => "inShopCreditDeduction",
|
||||
description => "inShopCreditDeduction help",
|
||||
},
|
||||
{
|
||||
name => "isCashier",
|
||||
},
|
||||
{
|
||||
name => "posLookupForm",
|
||||
},
|
||||
{
|
||||
name => "posUsername",
|
||||
},
|
||||
{
|
||||
name => "posUserId",
|
||||
},
|
||||
{
|
||||
name => "loginFormHeader",
|
||||
description => "loginFormHeader help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "loginFormFooter",
|
||||
description => "loginFormFooter help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "loginFormUsername",
|
||||
description => "loginFormUsername help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "loginFormPassword",
|
||||
description => "loginFormPassword help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "loginFormButton",
|
||||
description => "loginFormButton help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "registerLink",
|
||||
description => "registerLink help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_address1Field",
|
||||
description => "address1Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_address2Field",
|
||||
description => "address2Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_address3Field",
|
||||
description => "address3Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_labelField",
|
||||
description => "address labelField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_nameField",
|
||||
description => "address nameField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_cityField",
|
||||
description => "cityField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_stateField",
|
||||
description => "stateField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_countryField",
|
||||
description => "countryField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_codeField",
|
||||
description => "codeField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_phoneNumberField",
|
||||
description => "phoneNumberField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "billing_emailField",
|
||||
description => "emailField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_address1Field",
|
||||
description => "address1Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_address2Field",
|
||||
description => "address2Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_address3Field",
|
||||
description => "address3Field help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_labelField",
|
||||
description => "address labelField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_nameField",
|
||||
description => "address nameField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_cityField",
|
||||
description => "cityField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_stateField",
|
||||
description => "stateField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_countryField",
|
||||
description => "countryField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_codeField",
|
||||
description => "codeField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_phoneNumberField",
|
||||
description => "phoneNumberField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "shipping_emailField",
|
||||
description => "emailField help",
|
||||
required => 1,
|
||||
},
|
||||
],
|
||||
related => [
|
||||
{
|
||||
|
|
@ -379,6 +563,11 @@ our $HELP = {
|
|||
description => "phoneNumberField help",
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => "emailField",
|
||||
description => "emailField help",
|
||||
required => 1,
|
||||
},
|
||||
],
|
||||
related => [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
58
lib/WebGUI/Macro/TwitterLogin.pm
Normal file
58
lib/WebGUI/Macro/TwitterLogin.pm
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package WebGUI::Macro::TwitterLogin;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# 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 strict;
|
||||
use List::MoreUtils qw( any );
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::TwitterLogin
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Display a twitter login button
|
||||
|
||||
=head2 process( $session )
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
A session variable
|
||||
|
||||
=item *
|
||||
|
||||
A URL to an image to log in via Twitter
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
|
||||
return "" unless any { $_ eq 'Twitter' } @{ $session->config->get( 'authMethods' ) };
|
||||
return "" unless $session->user->isVisitor;
|
||||
return "" unless $session->setting->get('twitterEnabled'); # Don't allow if twitter login is disabled
|
||||
|
||||
my $loginUrl = $session->url->page('op=auth;authType=Twitter;method=login');
|
||||
my $imgUrl = shift || $session->url->extras( 'twitter_login.png' );
|
||||
|
||||
my $output = sprintf '<a href="%s"><img src="%s" border="0" /></a>', $loginUrl, $imgUrl;
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
@ -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,9 @@ sub send {
|
|||
my $smtpServer = $session->setting->get("smtpServer");
|
||||
my $status = 1;
|
||||
|
||||
if ($mail->parts <= 1) {
|
||||
$mail->make_singlepart;
|
||||
}
|
||||
if ($mail->head->get("To")) {
|
||||
if ($session->config->get("emailToLog")){
|
||||
my $message = $mail->stringify;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ package WebGUI::Operation::Auth;
|
|||
# logic that defines how Authentication should happen
|
||||
|
||||
use strict qw(vars subs);
|
||||
use List::MoreUtils qw( any );
|
||||
use URI;
|
||||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::Pluggable;
|
||||
|
|
@ -33,9 +34,16 @@ Get the instance of this object or create a new instance if none exists
|
|||
sub getInstance {
|
||||
my $session = shift;
|
||||
#Get Auth Settings
|
||||
my $authMethod = $session->user->authMethod || $session->setting->get("authMethod");
|
||||
$authMethod = $session->setting->get("authMethod") if($session->user->isVisitor);
|
||||
$authMethod = $_[0] if($_[0] && isIn($_[0], @{$session->config->get("authMethods")}));
|
||||
my $authMethod = $_[0]
|
||||
|| ( !$session->user->isVisitor && $session->user->authMethod ) # Visitor has no authType
|
||||
|| $session->form->get('authType')
|
||||
|| $session->setting->get("authMethod")
|
||||
;
|
||||
# Verify is in auth method list
|
||||
if ( !any { $_ eq $authMethod } @{$session->config->get('authMethods')} ) {
|
||||
$authMethod = $session->setting->get('authMethod');
|
||||
}
|
||||
|
||||
my $userId = $_[1];
|
||||
#Create Auth Object
|
||||
my $auth = eval { WebGUI::Pluggable::instanciate("WebGUI::Auth::".$authMethod, "new", [ $session, $authMethod, $userId ] ) };
|
||||
|
|
@ -68,11 +76,15 @@ sub www_auth {
|
|||
my $authMethod = getInstance($session,$auth);
|
||||
my $methodCall = shift || $session->form->process("method") || "init";
|
||||
if(!$authMethod->isCallable($methodCall)){
|
||||
$session->errorHandler->security("access uncallable auth method");
|
||||
$session->errorHandler->security("access uncallable auth method: $methodCall");
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
return $i18n->get(1077);
|
||||
}
|
||||
my $out = $authMethod->$methodCall;
|
||||
|
||||
# Determine if we have a www_ method
|
||||
my $method = $authMethod->can( 'www_' . $methodCall )
|
||||
|| $authMethod->can( $methodCall );
|
||||
my $out = $method->( $authMethod );
|
||||
if (substr($session->http->getMimeType(),0,9) eq "text/html") {
|
||||
return $session->style->userStyle($out);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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") );
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package WebGUI::Paginator;
|
|||
use strict;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Utility;
|
||||
use List::Util qw/min/;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -428,10 +429,10 @@ sub getPageData {
|
|||
}
|
||||
|
||||
#Handle setByArrayRef or the old setDataByQuery method
|
||||
my @pageRows = ();
|
||||
my $rowsPerPage = $self->{_rpp};
|
||||
my $rowsPerPage = $self->{_rpp};
|
||||
my $pageStartRow = ($pageNumber*$rowsPerPage)-$rowsPerPage;
|
||||
my $pageEndRow = $pageNumber*$rowsPerPage;
|
||||
my $pageEndRow = min($pageNumber*$rowsPerPage, $#{$allRows}+1);
|
||||
my @pageRows = ();
|
||||
for (my $i=$pageStartRow; $i<$pageEndRow; $i++) {
|
||||
$pageRows[$i-$pageStartRow] = $allRows->[$i] if ($i <= $#{$self->{_rowRef}});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -762,6 +762,15 @@ sub updateFromForm {
|
|||
$error{id $self} = $i18n->get('mixed items warning');
|
||||
}
|
||||
|
||||
my @cartItemIds = $form->process('remove_item', 'checkList');
|
||||
foreach my $cartItemId (@cartItemIds) {
|
||||
my $item = eval { $self->getItem($cartItemId); };
|
||||
$item->remove if ! Exception::Class->caught();
|
||||
}
|
||||
|
||||
##Visitor cannot have an address book, or set a payment gateway, so skip the rest of this.
|
||||
return 1 if $session->user->isVisitor;
|
||||
|
||||
my $book = $self->getAddressBook;
|
||||
|
||||
my $cartProperties = {};
|
||||
|
|
@ -825,12 +834,6 @@ sub updateFromForm {
|
|||
$cartProperties->{ shipperId } = $form->process( 'shipperId' ) if $form->process( 'shipperId' );
|
||||
$cartProperties->{ gatewayId } = $form->process( 'gatewayId' ) if $form->process( 'gatewayId' );
|
||||
$self->update( $cartProperties );
|
||||
|
||||
my @cartItemIds = $form->process('remove_item', 'checkList');
|
||||
foreach my $cartItemId (@cartItemIds) {
|
||||
my $item = eval { $self->getItem($cartItemId); };
|
||||
$item->remove if ! Exception::Class->caught();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1096,15 +1099,15 @@ sub www_view {
|
|||
options => \%specialAddressOptions,
|
||||
extras => q|class="itemAddressMenu"|,
|
||||
});
|
||||
$taxDriver->appendCartItemVars( \%properties, $item );
|
||||
}
|
||||
|
||||
$taxDriver->appendCartItemVars( \%properties, $item );
|
||||
|
||||
push(@items, \%properties);
|
||||
}
|
||||
|
||||
$var{items} = \@items;
|
||||
if ($var{shippableItemsInCart}) {
|
||||
if (! $var{userIsVisitor} && $var{shippableItemsInCart}) {
|
||||
my $ship = WebGUI::Shop::Ship->new($self->session);
|
||||
my $options = $ship->getOptions($self);
|
||||
my $numberOfOptions = scalar keys %{ $options };
|
||||
|
|
|
|||
|
|
@ -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=?');
|
||||
|
|
|
|||
|
|
@ -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->getWebguiRoot, $config->getFilename );
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -306,6 +306,7 @@ sub setApproved {
|
|||
my $self = shift;
|
||||
my $instance = shift;
|
||||
$instance->setScratch( "status", "approved" );
|
||||
$instance->set({}); ##Bump spectre to get it to run right now.
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -325,7 +326,8 @@ sub setDenied {
|
|||
my $self = shift;
|
||||
my $instance = shift;
|
||||
$instance->setScratch( "status", "denied" );
|
||||
}
|
||||
$instance->set({}); ##Bump spectre to get it to run right now.
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -75,9 +75,11 @@ 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) {
|
||||
|
|
|
|||
|
|
@ -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' => {
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ editing an existing Post.|,
|
|||
lastUpdated => 1149829706,
|
||||
},
|
||||
|
||||
'isSubscribedToCs' => {
|
||||
message => q|A boolean which will be true if the current user is subscribed to the CS containing this Post.|,
|
||||
context => q|Template variable description|,
|
||||
lastUpdated => 1149829706,
|
||||
},
|
||||
|
||||
'subscribe.form' => {
|
||||
message => q|A yes/no button to allow the user to subscribe to the thread this post belongs to.|,
|
||||
lastUpdated => 1149829706,
|
||||
|
|
|
|||
|
|
@ -584,14 +584,12 @@ you wish to appear, one per line. <br />
|
|||
<br />If you want a different label for a value, the possible values list has to be
|
||||
formatted as follows:
|
||||
<pre>
|
||||
{
|
||||
"key1"=>"value1",
|
||||
"key2"=>"value2",
|
||||
"key3"=>"value3"
|
||||
key1|value1
|
||||
key2|value2
|
||||
key3|value3
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
Braces, quotes and all. You simply replace "key1"/"value1" with your own name/value pairs},
|
||||
Simply replace "key1"/"value1" with your own name/value pairs},
|
||||
lastUpdated => 1223372150,
|
||||
},
|
||||
|
||||
|
|
@ -972,11 +970,17 @@ search has been done.|,
|
|||
},
|
||||
|
||||
'searchFields_is__fieldType__' => {
|
||||
message => q|A boolean indicating wether this field is of type __fieldType__. The first letter of __fieldType__ is always uppercase. Example: for a select box the value of <tmpl_var searchFields_isSelectBox> is true.|,
|
||||
message => q|A boolean indicating whether this field is of type __fieldType__. The first letter of __fieldType__ is always uppercase. Example: for a select box the value of <tmpl_var searchFields_isSelectBox> is true.|,
|
||||
lastUpdated => 1104630516,
|
||||
context => q|Description of a tmpl_var for the template help.|,
|
||||
},
|
||||
|
||||
'searchFields_listType' => {
|
||||
message => q|A boolean indicating whether this field is a List type field.|,
|
||||
lastUpdated => 1277849256,
|
||||
context => q|Description of a tmpl_var for the template help.|,
|
||||
},
|
||||
|
||||
'displayInSearchFields_loop' => {
|
||||
message => q|A loop containing the fields that are displayed in the search results.|,
|
||||
lastUpdated => 1104630516,
|
||||
|
|
|
|||
80
lib/WebGUI/i18n/English/Auth_Twitter.pm
Normal file
80
lib/WebGUI/i18n/English/Auth_Twitter.pm
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
package WebGUI::i18n::English::Auth_Twitter;
|
||||
|
||||
use strict;
|
||||
|
||||
our $I18N = {
|
||||
'enabled' => {
|
||||
message => q{Enabled},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for auth setting field},
|
||||
},
|
||||
|
||||
'enabled help' => {
|
||||
message => q{Enabled Twitter-based login},
|
||||
lastUpdated => 0,
|
||||
context => q{Hover help for auth setting field},
|
||||
},
|
||||
|
||||
'get key' => {
|
||||
message => q{Get a Twitter API key from <a href="%s">%s</a>},
|
||||
lastUpdated => 0,
|
||||
context => q{Link to get a twitter API key},
|
||||
},
|
||||
|
||||
'consumer key' => {
|
||||
message => q{Twitter Consumer Key},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for auth setting field},
|
||||
},
|
||||
|
||||
'consumer key help' => {
|
||||
message => q{The Consumer Key from your application settings},
|
||||
lastUpdated => 0,
|
||||
context => q{Hover help for auth setting field},
|
||||
},
|
||||
|
||||
'consumer secret' => {
|
||||
message => q{Twitter Consumer Secret},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for auth setting field},
|
||||
},
|
||||
|
||||
'consumer secret help' => {
|
||||
message => q{The Consumer Secret from your application settings},
|
||||
lastUpdated => 0,
|
||||
context => q{Hover help for auth setting field},
|
||||
},
|
||||
|
||||
'choose username title' => {
|
||||
message => q{Choose a Username},
|
||||
lastUpdated => 0,
|
||||
context => q{Title for screen to choose a username},
|
||||
},
|
||||
|
||||
'twitter screen name taken' => {
|
||||
message => q{Your twitter screen name "%s" is taken. Please choose a new username.},
|
||||
lastUpdated => 0,
|
||||
context => q{An error message for the choose a username screen},
|
||||
},
|
||||
|
||||
'webgui username taken' => {
|
||||
message => q{That username "%s" is taken. Please choose another.},
|
||||
lastUpdated => 0,
|
||||
context => q{An error message for the choose a username screen},
|
||||
},
|
||||
|
||||
'choose username template' => {
|
||||
message => q{Choose Username Template},
|
||||
lastUpdated => 0,
|
||||
context => q{Label for auth setting field},
|
||||
},
|
||||
|
||||
'choose username template help' => {
|
||||
message => q{The template to choose a username if the user's screen name already exists},
|
||||
lastUpdated => 0,
|
||||
context => q{Hover help for auth setting field},
|
||||
},
|
||||
};
|
||||
|
||||
1;
|
||||
#vim:ft=perl
|
||||
11
lib/WebGUI/i18n/English/Form_ThingsFieldList.pm
Normal file
11
lib/WebGUI/i18n/English/Form_ThingsFieldList.pm
Normal 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;
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -165,18 +165,6 @@ our $I18N = {
|
|||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'removeButton help' => {
|
||||
message => q|Clicking this button will remove the item from the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'item shipToButton help' => {
|
||||
message => q|Clicking this button will set an alternate address as the destination of this item.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'shippingAddress help' => {
|
||||
message => q|The HTML formatted address to ship to.|,
|
||||
lastUpdated => 0,
|
||||
|
|
@ -189,6 +177,12 @@ our $I18N = {
|
|||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'message help' => {
|
||||
message => q|If the cart is empty, this internationalized message should be displayed to the user.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'formHeader help' => {
|
||||
message => q|The top of the form.|,
|
||||
lastUpdated => 0,
|
||||
|
|
@ -243,6 +237,12 @@ our $I18N = {
|
|||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'paymentOptions help' => {
|
||||
message => q|A select list containing all the configured payment options for this order.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'inShopCreditAvailable help' => {
|
||||
message => q|The amount of in-shop credit the user has.|,
|
||||
lastUpdated => 0,
|
||||
|
|
@ -447,6 +447,12 @@ our $I18N = {
|
|||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'emailField help' => {
|
||||
message => q|A field to contain the email address for this address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a help description|,
|
||||
},
|
||||
|
||||
'phoneNumber help' => {
|
||||
message => q|A phone number for this address.|,
|
||||
lastUpdated => 0,
|
||||
|
|
@ -1782,7 +1788,7 @@ our $I18N = {
|
|||
'shippableItemsInCart' => {
|
||||
message => q|A boolean which will be true if any item in the cart requires shipping.|,
|
||||
lastUpdated => 0,
|
||||
context => q|form label for the cart. Allows user to choose a payment method. Bart Jol for Minister in 2012!|
|
||||
context => q|Template variable help.|
|
||||
},
|
||||
|
||||
'no billing address' => {
|
||||
|
|
@ -1905,6 +1911,108 @@ our $I18N = {
|
|||
context => q|Cart error message|
|
||||
},
|
||||
|
||||
'minimumCartAmount help' => {
|
||||
message => q|The minimum cart amount, from the settings, formatted to two decimal places.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'userIsVisitor help' => {
|
||||
message => q|A boolean which will be true if the currrent user is Visitor|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'removeBox help' => {
|
||||
message => q|A checkbox that will allow this item to be removed from the cart.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'itemAddressChooser help' => {
|
||||
message => q|A dropdown for choosing an address to ship an individual item in the cart to, enabling per-item shipping.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'shippingAddressChooser help' => {
|
||||
message => q|A dropdown for choosing a default shipping address for all items in the cart. Also contains actions for editing and adding new addresses.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'billingAddressChooser help' => {
|
||||
message => q|A dropdown for choosing a default billing address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'sameShippingAsBilling help' => {
|
||||
message => q|A checkbox to tell the cart that the user wants to use the same shipping address, as their billing address.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'loginFormHeader help' => {
|
||||
message => q|The start of the form to help a user log in. This variable will only be populated if the current user is Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'loginFormFooter help' => {
|
||||
message => q|The end of the form to help a user log in. This variable will only be populated if the current user is Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'loginFormUsername help' => {
|
||||
message => q|A text box for the user to enter in their name. This variable will only be populated if the current user is Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'loginFormPassword help' => {
|
||||
message => q|A text box for the user to enter in their password, obscured. This variable will only be populated if the current user is Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'loginFormButton help' => {
|
||||
message => q|The end of the form to help a user log in. This variable will only be populated if the current user is Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'registerLink help' => {
|
||||
message => q|A link for a user to register an account on this site, if they do not already have one. This variable will only be populated if the current user is Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'item taxRate help' => {
|
||||
message => q|The tax rate for this item. This variable will only be populated if the current user is not Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'item taxAmount help' => {
|
||||
message => q|The amount of tax for this item. This variable will only be populated if the current user is not Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'item pricePlusTax help' => {
|
||||
message => q|The amount of tax plus the price for this item. This variable will only be populated if the current user is not Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
'item extendedPricePlusTax help' => {
|
||||
message => q|The amount of tax plus the price for this item, times the quantity of this item in the cart. This variable will only be populated if the current user is not Visitor.|,
|
||||
lastUpdated => 0,
|
||||
context => q|Template variable help|
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue