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
232 lines
6.6 KiB
Perl
232 lines
6.6 KiB
Perl
package WebGUI::Account::Contributions;
|
|
|
|
use strict;
|
|
|
|
use WebGUI::Exception;
|
|
use WebGUI::International;
|
|
use WebGUI::Pluggable;
|
|
use WebGUI::Operation::Auth;
|
|
use Tie::IxHash;
|
|
|
|
use base qw/WebGUI::Account/;
|
|
|
|
=head1 NAME
|
|
|
|
Package WebGUI::Account::Contributions
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
This is the class which is used to display a users's contributions to the site
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
use WebGUI::Account::Contributions;
|
|
|
|
=head1 METHODS
|
|
|
|
These subroutines are available from this package:
|
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
=head2 editSettingsForm ( )
|
|
|
|
Creates form elements for user settings page custom to this account module
|
|
|
|
=cut
|
|
|
|
sub editSettingsForm {
|
|
my $self = shift;
|
|
my $session = $self->session;
|
|
my $setting = $session->setting;
|
|
my $i18n = WebGUI::International->new($session,'Account_Contributions');
|
|
my $f = WebGUI::HTMLForm->new($session);
|
|
|
|
$f->template(
|
|
name => "contribStyleTemplateId",
|
|
value => $self->getStyleTemplateId,
|
|
namespace => "style",
|
|
label => $i18n->get("contrib style template label"),
|
|
hoverHelp => $i18n->get("contrib style template hoverHelp")
|
|
);
|
|
$f->template(
|
|
name => "contribLayoutTemplateId",
|
|
value => $self->getLayoutTemplateId,
|
|
namespace => "Account/Layout",
|
|
label => $i18n->get("contrib layout template label"),
|
|
hoverHelp => $i18n->get("contrib layout template hoverHelp")
|
|
);
|
|
$f->template(
|
|
name => "contribViewTemplateId",
|
|
value => $self->getViewTemplateId,
|
|
namespace => "Account/Contrib/View",
|
|
label => $i18n->get("contrib view template label"),
|
|
hoverHelp => $i18n->get("contrib view template hoverHelp")
|
|
);
|
|
|
|
return $f->printRowsOnly;
|
|
}
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
=head2 editSettingsFormSave ( )
|
|
|
|
Creates form elements for user settings page custom to this account module
|
|
|
|
=cut
|
|
|
|
sub editSettingsFormSave {
|
|
my $self = shift;
|
|
my $session = $self->session;
|
|
my $setting = $session->setting;
|
|
my $form = $session->form;
|
|
|
|
$setting->set("contribStyleTemplateId", $form->process("contribStyleTemplateId","template"));
|
|
$setting->set("contribLayoutTemplateId", $form->process("contribLayoutTemplateId","template"));
|
|
$setting->set("contribViewTemplateId", $form->process("contribViewTemplateId","template"));
|
|
}
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
=head2 getLayoutTemplateId ( )
|
|
|
|
This method returns the template ID for the account layout.
|
|
|
|
=cut
|
|
|
|
sub getLayoutTemplateId {
|
|
my $self = shift;
|
|
return $self->session->setting->get("contribLayoutTemplateId") || "b4n3VyUIsAHyIvT-W-jziA";
|
|
}
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
=head2 getStyleTemplateId ( )
|
|
|
|
This method returns the template ID for the main style.
|
|
|
|
=cut
|
|
|
|
sub getStyleTemplateId {
|
|
my $self = shift;
|
|
return $self->session->setting->get("contribStyleTemplateId") || $self->SUPER::getStyleTemplateId;
|
|
}
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
=head2 getViewTemplateId ( )
|
|
|
|
This method returns the template ID for the main view.
|
|
|
|
=cut
|
|
|
|
sub getViewTemplateId {
|
|
my $self = shift;
|
|
return $self->session->setting->get("contribViewTemplateId") || "1IzRpX0tgW7iuCfaU2Kk0A";
|
|
}
|
|
|
|
|
|
#-------------------------------------------------------------------
|
|
|
|
=head2 www_view ( )
|
|
|
|
The main view page for editing the user's profile.
|
|
|
|
=cut
|
|
|
|
sub www_view {
|
|
my $self = shift;
|
|
my $session = $self->session;
|
|
my $userId = $self->uid || $session->user->userId;
|
|
my $var = {};
|
|
|
|
#Set the uid just in case;
|
|
#$self->uid($userId);
|
|
|
|
|
|
#Deal with sort order
|
|
my $sortBy = $session->form->get("sortBy") || "creationDate";
|
|
my $sort_url = ($sortBy)?";sortBy=$sortBy":"";
|
|
|
|
#Deal with sort direction
|
|
my $sortDir = $session->form->get("sortDir") || "desc";
|
|
my $sortDir_url = ";sortDir=".(($sortDir eq "desc")?"asc":"desc");
|
|
|
|
#Deal with rows per page
|
|
my $rpp = $session->form->get("rpp") || 25;
|
|
my $rpp_url = ";rpp=$rpp";
|
|
|
|
#Cache the base url
|
|
my $contribsUrl = $self->getUrl(undef, 'appendUID');
|
|
|
|
#Create sortBy headers
|
|
$var->{'title_url' } = $contribsUrl.";sortBy=title".$sortDir_url.$rpp_url;
|
|
$var->{'type_url' } = $contribsUrl.";sortBy=className".$sortDir_url.$rpp_url;
|
|
$var->{'dateStamp_url' } = $contribsUrl.";sortBy=creationDate".$sortDir_url.$rpp_url;
|
|
$var->{'rpp_url' } = $contribsUrl.$sort_url.";sortDir=".$sortDir;
|
|
|
|
#Create the paginator
|
|
my $root = WebGUI::Asset->getRoot( $session );
|
|
my $sql = $root->getLineageSql(
|
|
[ "self", "descendants" ],
|
|
{
|
|
includeOnlyClasses => [
|
|
'WebGUI::Asset::Wobject::Article',
|
|
'WebGUI::Asset::Post',
|
|
'WebGUI::Asset::Wobject::GalleryAlbum',
|
|
'WebGUI::Asset::Event',
|
|
'WebGUI::Asset::WikiPage',
|
|
'WebGUI::Asset::Post::Thread',
|
|
],
|
|
statusToInclude => [ qw/approved archived/ ],
|
|
whereClause => "asset.createdBy = '$userId' or assetData.ownerUserId = '$userId'",
|
|
orderByClause => "$sortBy $sortDir"
|
|
}
|
|
);
|
|
|
|
|
|
my $p = WebGUI::Paginator->new(
|
|
$session,
|
|
$contribsUrl.";uid=".$userId.$sort_url.";sortDir=".$sortDir.$rpp_url,
|
|
$rpp
|
|
);
|
|
$p->setDataByQuery($sql);
|
|
|
|
#Export page to template
|
|
my @contribs = ();
|
|
ROW: foreach my $row ( @{$p->getPageData} ) {
|
|
my $assetId = $row->{assetId};
|
|
my $asset = eval { WebGUI::Asset->newById( $session, $assetId ); };
|
|
if (Exception::Class->caught()) {
|
|
$session->log->error("Unable to instanciate assetId $assetId: $@");
|
|
next ROW;
|
|
}
|
|
my $props = $asset->get;
|
|
$props->{url} = $asset->getUrl;
|
|
push(@contribs,$props);
|
|
}
|
|
my $contribsCount = $p->getRowCount;
|
|
|
|
$var->{'contributions_loop' } = \@contribs;
|
|
$var->{'has_contributions' } = $contribsCount > 0;
|
|
$var->{'contributions_total' } = $contribsCount;
|
|
|
|
tie my %rpps, "Tie::IxHash";
|
|
%rpps = (25 => "25", 50 => "50", 100=>"100");
|
|
$var->{'contributions_rpp' } = WebGUI::Form::selectBox($session,{
|
|
name =>"rpp",
|
|
options => \%rpps,
|
|
value => $session->form->get("rpp") || 25,
|
|
extras => q{onchange="location.href='}.$var->{'rpp_url'}.q{;rpp='+this.options[this.selectedIndex].value"}
|
|
});
|
|
|
|
$self->appendCommonVars($var);
|
|
$p->appendTemplateVars($var);
|
|
|
|
return $self->processTemplate($var,$self->getViewTemplateId);
|
|
}
|
|
|
|
|
|
1;
|