Added Contributions Account Pluggin which displays assets a user has contributed to the site
This commit is contained in:
parent
a30520e871
commit
a50414025e
5 changed files with 303 additions and 0 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
- New Profile Account module added providing a better interface for users to view and update their profile
|
- New Profile Account module added providing a better interface for users to view and update their profile
|
||||||
- New Inbox Account module added providing a better interface into WebGUI's various messaging systems
|
- New Inbox Account module added providing a better interface into WebGUI's various messaging systems
|
||||||
- New Friends Account module added providing a better interface into WebGUI's friends system
|
- New Friends Account module added providing a better interface into WebGUI's friends system
|
||||||
|
- New Contributions Account module added which displays public assets a user has contributed to the website
|
||||||
- rfe: Event hover detail exclusions (#8761)
|
- rfe: Event hover detail exclusions (#8761)
|
||||||
- rfe: Database Link test (#513)
|
- rfe: Database Link test (#513)
|
||||||
- rfe: User Profile Privacy Settings (#507) - users now have granular control of whether or not their profile fields are viewable - admin settings still apply
|
- rfe: User Profile Privacy Settings (#507) - users now have granular control of whether or not their profile fields are viewable - admin settings still apply
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -409,6 +409,11 @@ sub upgradeAccount {
|
||||||
title => "^International(title,Account_Friends);",
|
title => "^International(title,Account_Friends);",
|
||||||
className => "WebGUI::Account::Friends"
|
className => "WebGUI::Account::Friends"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
identifier => "contributions",
|
||||||
|
title => "^International(title,Account_Contributions);",
|
||||||
|
className => "WebGUI::Account::Contributions"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
identifier => "shop",
|
identifier => "shop",
|
||||||
title => "^International(title,Account_Shop);",
|
title => "^International(title,Account_Shop);",
|
||||||
|
|
@ -487,6 +492,12 @@ sub upgradeAccount {
|
||||||
$setting->add("shopStyleTemplateId",""); #Use the userStyle by default
|
$setting->add("shopStyleTemplateId",""); #Use the userStyle by default
|
||||||
$setting->add("shopLayoutTemplateId","aUDsJ-vB9RgP-AYvPOy8FQ");
|
$setting->add("shopLayoutTemplateId","aUDsJ-vB9RgP-AYvPOy8FQ");
|
||||||
|
|
||||||
|
#Add the settings for the contributions module
|
||||||
|
$setting->add("contribStyleTemplateId",""); #Use the userStyle by default
|
||||||
|
$setting->add("contribLayoutTemplateId","b4n3VyUIsAHyIvT-W-jziA");
|
||||||
|
$setting->add("contribViewTemplateId","1IzRpX0tgW7iuCfaU2Kk0A");
|
||||||
|
|
||||||
|
|
||||||
#Add inbox changes
|
#Add inbox changes
|
||||||
$session->db->write(q{
|
$session->db->write(q{
|
||||||
create table inbox_messageState (
|
create table inbox_messageState (
|
||||||
|
|
|
||||||
222
lib/WebGUI/Account/Contributions.pm
Normal file
222
lib/WebGUI/Account/Contributions.pm
Normal file
|
|
@ -0,0 +1,222 @@
|
||||||
|
package WebGUI::Account::Contributions;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use WebGUI::Exception;
|
||||||
|
use WebGUI::International;
|
||||||
|
use WebGUI::Pluggable;
|
||||||
|
use WebGUI::Utility;
|
||||||
|
use WebGUI::Operation::Auth;
|
||||||
|
|
||||||
|
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("module=contributions;do=view;uid=$userId");
|
||||||
|
|
||||||
|
#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::Post::Thread',
|
||||||
|
],
|
||||||
|
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 = ();
|
||||||
|
foreach my $row ( @{$p->getPageData} ) {
|
||||||
|
my $assetId = $row->{assetId};
|
||||||
|
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
||||||
|
push(@contribs,$asset->get);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
|
return $self->processTemplate($var,$self->getViewTemplateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
69
lib/WebGUI/i18n/English/Account_Contributions.pm
Normal file
69
lib/WebGUI/i18n/English/Account_Contributions.pm
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
package WebGUI::i18n::English::Account_Contributions;
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
our $I18N = {
|
||||||
|
|
||||||
|
'title' => {
|
||||||
|
message => q{Contributions},
|
||||||
|
lastUpdated => 1225724810,
|
||||||
|
context => q{Tab label for User Contributions pluggin},
|
||||||
|
},
|
||||||
|
|
||||||
|
'contrib style template label' => {
|
||||||
|
message => q|Style Template|,
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'contrib style template hoverHelp' => {
|
||||||
|
message => q|Select a style template from the list to enclose the contributions tab in.|,
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'contrib layout template label' => {
|
||||||
|
message => q|Layout Template|,
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'contrib layout template hoverHelp' => {
|
||||||
|
message => q{Choose a layout template in which to enclose the content from the various methods within the contributions tab},
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'contrib view template label' => {
|
||||||
|
message => q|View Contributions Template|,
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'contrib view template hoverHelp' => {
|
||||||
|
message => q{Choose the template for displaying user contributions},
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'title label' => {
|
||||||
|
message => q{Title},
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'type label' => {
|
||||||
|
message => q{Type},
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'date label' => {
|
||||||
|
message => q{Date},
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'no contributions' => {
|
||||||
|
message => q{No contributions to display},
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
'contribution count' => {
|
||||||
|
message => q{total contributions},
|
||||||
|
lastUpdated => 1119068809
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
1;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue