Account release candidate - final changes before merge
This commit is contained in:
parent
aec93573f0
commit
11d18075fa
45 changed files with 3379 additions and 1325 deletions
|
|
@ -26,6 +26,52 @@ These subroutines are available from this package:
|
|||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 appendCommonVars ( var )
|
||||
|
||||
Appends common template variables that all inbox templates use
|
||||
|
||||
=head3 var
|
||||
|
||||
The hash reference to append template variables to
|
||||
|
||||
=cut
|
||||
|
||||
sub appendCommonVars {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $session = $self->session;
|
||||
my $user = $session->user;
|
||||
my $pageUrl = $session->url->page;
|
||||
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
$var->{'view_profile_url' } = $user->getProfileUrl($pageUrl);
|
||||
$var->{'edit_profile_url' } = $session->url->page("op=account");
|
||||
$var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_profile_url'}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canView ( )
|
||||
|
||||
Whether or not the current user can view this user's friends
|
||||
|
||||
=cut
|
||||
|
||||
sub canView {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $uid = $self->uid;
|
||||
|
||||
return 1 if (($session->user->userId eq $uid || $uid eq "") && $session->user->profileField('ableToBeFriend'));
|
||||
|
||||
my $user = WebGUI::User->new($session,$uid);
|
||||
return 0 if($user->isVisitor); #This should never happen but let's make sure
|
||||
return 0 unless ($user->profileField('ableToBeFriend')); #User doesn't have friends enabled
|
||||
return WebGUI::User->new($session,$uid)->profileIsViewable($session->user); #User's profile isn't viewable by this user
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -38,17 +84,68 @@ These subroutines are available from this package:
|
|||
sub editSettingsForm {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $setting = $session->setting;
|
||||
my $i18n = WebGUI::International->new($session,'Account_Friends');
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
|
||||
# $f->template(
|
||||
# name => "profileStyleTemplateId",
|
||||
# value => $self->getStyleTemplateId,
|
||||
# namespace => "style",
|
||||
# label => $i18n->get("profile style template label"),
|
||||
# hoverHelp => $i18n->get("profile style template hoverHelp")
|
||||
# );
|
||||
$f->template(
|
||||
name => "friendsStyleTemplateId",
|
||||
value => $self->getStyleTemplateId,
|
||||
namespace => "style",
|
||||
label => $i18n->get("friends style template label"),
|
||||
hoverHelp => $i18n->get("friends style template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "friendsLayoutTempalteId",
|
||||
value => $self->getLayoutTemplateId,
|
||||
namespace => "Account/Layout",
|
||||
label => $i18n->get("friends layout template label"),
|
||||
hoverHelp => $i18n->get("friends layout template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "friendsViewTemplateId",
|
||||
value => $self->getViewTemplateId,
|
||||
namespace => "Account/Friends/View",
|
||||
label => $i18n->get("friends view template label"),
|
||||
hoverHelp => $i18n->get("friends view template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "friendsEditTemplateId",
|
||||
value => $self->getEditTemplateId,
|
||||
namespace => "Account/Friends/Edit",
|
||||
label => $i18n->get("friends edit template label"),
|
||||
hoverHelp => $i18n->get("friends edit template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "friendsSendRequestTemplateId",
|
||||
value => $self->getSendRequestTemplateId,
|
||||
namespace => "Account/Friends/SendRequest",
|
||||
label => $i18n->get("friends send request template label"),
|
||||
hoverHelp => $i18n->get("friends send request template hoverHelp")
|
||||
);
|
||||
|
||||
$f->template(
|
||||
name => "friendsErrorTemplateId",
|
||||
value => $self->getErrorTemplateId,
|
||||
namespace => "Account/Friends/Error",
|
||||
label => $i18n->get("friends error template label"),
|
||||
hoverHelp => $i18n->get("friends error template hoverHelp")
|
||||
);
|
||||
|
||||
$f->template(
|
||||
name => "friendsConfirmTemplateId",
|
||||
value => $self->getConfirmTemplateId,
|
||||
namespace => "Account/Friends/Confirm",
|
||||
label => $i18n->get("friends confirm template label"),
|
||||
hoverHelp => $i18n->get("friends confirm template hoverHelp")
|
||||
);
|
||||
|
||||
$f->template(
|
||||
name => "friendsRemoveConfirmTemplateId",
|
||||
value => $self->getRemoveConfirmTemplateId,
|
||||
namespace => "Account/Friends/Confirm",
|
||||
label => $i18n->get("friends remove confirm template label"),
|
||||
hoverHelp => $i18n->get("friends remove confirm template hoverHelp")
|
||||
);
|
||||
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
|
@ -62,19 +159,60 @@ sub editSettingsForm {
|
|||
=cut
|
||||
|
||||
sub editSettingsFormSave {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $setting = $session->setting;
|
||||
my $form = $session->form;
|
||||
|
||||
$setting->set("friendsStyleTemplateId", $form->process("friendsStyleTemplateId","template"));
|
||||
$setting->set("friendsLayoutTempalteId", $form->process("friendsLayoutTempalteId","template"));
|
||||
$setting->set("friendsViewTemplateId", $form->process("friendsViewTemplateId","template"));
|
||||
$session->set("friendsEditTemplateId",$form->process("friendsEditTemplateId","template"));
|
||||
$session->set("friendsSendRequestTemplateId",$form->process("friendsSendRequestTemplateId","template"));
|
||||
$session->set("friendsErrorTemplateId",$form->process("friendsErrorTemplateId","template"));
|
||||
$session->set("friendsConfirmTemplateId",$form->process("friendsConfirmTemplateId","template"));
|
||||
$session->set("friendsRemoveConfirmTemplateId",$form->process("friendsRemoveConfirmTemplateId","template"));
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDisplayTemplateId ( )
|
||||
=head2 getConfirmTemplateId ( )
|
||||
|
||||
This method returns the template ID for the account layout.
|
||||
This method returns the template ID for the confirmation screen.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDisplayTemplateId {
|
||||
sub getConfirmTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("friendsDisplayTempalteId") || "defaultAssetId";
|
||||
return $self->session->setting->get("friendsConfirmTemplateId") || "K8F0j_cq_jgo8dvWY_26Ag";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditTemplateId ( )
|
||||
|
||||
This method returns the template ID for editing friends.
|
||||
|
||||
=cut
|
||||
|
||||
sub getEditTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("friendsEditTemplateId") || "AZFU33p0jpPJ-E6qLSWZng";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getErrorTemplateId ( )
|
||||
|
||||
This method returns the template ID for displaying errors.
|
||||
|
||||
=cut
|
||||
|
||||
sub getErrorTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("friendsErrorTemplateId") || "7Ijdd8SW32lVgg2H8R-Aqw";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -91,6 +229,33 @@ sub getLayoutTemplateId {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getConfirmTemplateId ( )
|
||||
|
||||
This method returns the template ID for the confirmation screen.
|
||||
|
||||
=cut
|
||||
|
||||
sub getRemoveConfirmTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("friendsRemoveConfirmTemplateId") || "G5V6neXIDiFXN05oL-U3AQ";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getSendRequestTemplateId ( )
|
||||
|
||||
This method returns the template ID for the send request page.
|
||||
|
||||
=cut
|
||||
|
||||
sub getSendRequestTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("friendsSendRequestTemplateId") || "AGJBGviWGAwjnwziiPjvDg";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStyleTemplateId ( )
|
||||
|
|
@ -114,40 +279,310 @@ This method returns the template ID for the main view.
|
|||
|
||||
sub getViewTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("friendsViewTemplateId") || "defaultAssetId";
|
||||
return $self->session->setting->get("friendsViewTemplateId") || "1Yn_zE_dSiNuaBGNLPbxtw";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_removeFriend ( )
|
||||
|
||||
This is a confirmation page of whether or not the user wishes to remove the selected user from friend
|
||||
|
||||
=cut
|
||||
|
||||
sub www_removeFriend {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $friendId = $session->form->get("friendId");
|
||||
my $var = {};
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
my $friend = WebGUI::Friends->new($session);
|
||||
|
||||
my $errorMsg = "";
|
||||
if (!$friendId) {
|
||||
my $i18n = WebGUI::International->new($session,"Account_Friends");
|
||||
$errorMsg = $i18n->get("no friend selected");
|
||||
}
|
||||
elsif(!$friend->isFriend($friendId)){
|
||||
my $i18n = WebGUI::International->new($session,"Account_Friends");
|
||||
$errorMsg = $i18n->get("not a friend error");
|
||||
}
|
||||
|
||||
if($errorMsg ne "") {
|
||||
my $backUrl = $self->getUrl("module=friends");
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getErrorTemplateId);
|
||||
}
|
||||
|
||||
my $user = WebGUI::User->new($session,$friendId);
|
||||
$var->{'user_full_name'} = $user->getWholeName;
|
||||
|
||||
$var->{'yes_url' } = $self->getUrl("module=friends;do=removeFriendConfirm;friendId=".$friendId);
|
||||
$var->{'no_url' } = $self->getUrl("module=friends");
|
||||
|
||||
return $self->processTemplate($var,$self->getRemoveConfirmTemplateId);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_removeFriend ( )
|
||||
|
||||
This is a confirmation page of whether or not the user wishes to remove the selected user from friend
|
||||
|
||||
=cut
|
||||
|
||||
sub www_removeFriendConfirm {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $friendId = $session->form->get("friendId");
|
||||
my $var = {};
|
||||
my $i18n = WebGUI::International->new($session,"Account_Friends");
|
||||
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
my $friend = WebGUI::Friends->new($session);
|
||||
|
||||
my $errorMsg = "";
|
||||
if (!$friendId) {
|
||||
$errorMsg = $i18n->get("no friend selected");
|
||||
}
|
||||
elsif(!$friend->isFriend($friendId)){
|
||||
$errorMsg = $i18n->get("not a friend error");
|
||||
}
|
||||
|
||||
if($errorMsg ne "") {
|
||||
my $backUrl = $self->getUrl("module=friends");
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getErrorTemplateId);
|
||||
}
|
||||
|
||||
my $user = WebGUI::User->new($session,$friendId);
|
||||
my $msg = sprintf($i18n->get("friend removed"),$user->getWholeName);
|
||||
|
||||
$friend->delete([$friendId]);
|
||||
|
||||
return $self->www_view($msg);
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_display ( )
|
||||
=head2 www_sendFriendsRequest ( )
|
||||
|
||||
The main view page for displaying the user's profile.
|
||||
The page which allows users to submit friends requests.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_display {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = {};
|
||||
sub www_sendFriendsRequest {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = {};
|
||||
my $uid = $self->uid;
|
||||
|
||||
my $user = WebGUI::User->new($session,$uid);
|
||||
my $i18n = WebGUI::International->new($session,'Account_Friends');
|
||||
|
||||
unless ($user->acceptsFriendsRequests($session->user)) {
|
||||
my $errorMsg = $i18n->get('does not want to be a friend');
|
||||
my $friend = WebGUI::Friends->new($session);
|
||||
if($friend->isFriend($uid)) {
|
||||
$errorMsg = $i18n->get("error user is already friend");
|
||||
}
|
||||
elsif($friend->isInvited($uid)) {
|
||||
$errorMsg = $i18n->get("error user is already invited");
|
||||
}
|
||||
return $self->showError($var,$errorMsg,$session->user->getProfileUrl,$self->getErrorTemplateId);
|
||||
}
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
#Overwrite these
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
|
||||
my $defaultComment = sprintf(
|
||||
$i18n->get('default friend comments'),
|
||||
$user->getFirstName,
|
||||
$session->user->getFirstName
|
||||
);
|
||||
$var->{'form_message_text'} = WebGUI::Form::textarea($session, {
|
||||
name =>"message",
|
||||
value =>$defaultComment,
|
||||
width =>600,
|
||||
height =>200
|
||||
});
|
||||
|
||||
$var->{'form_message_rich'} = WebGUI::Form::HTMLArea($session, {
|
||||
name => "message",
|
||||
value => $defaultComment,
|
||||
width => "600",
|
||||
});
|
||||
|
||||
$var->{'form_header' } = WebGUI::Form::formHeader($session,{
|
||||
action => $self->getUrl("module=friends;do=sendFriendsRequestSave;uid=$uid"),
|
||||
extras => q{name="messageForm"}
|
||||
});
|
||||
|
||||
$var->{'submit_button' } = WebGUI::Form::submit($session,{});
|
||||
$var->{'form_footer' } = WebGUI::Form::formFooter($session, {});
|
||||
|
||||
$var->{'cancel_url' } = $user->getProfileUrl;
|
||||
|
||||
return $self->processTemplate($var,$self->getSendRequestTemplateId);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_sendFriendsRequestSave ( )
|
||||
|
||||
This method allows users to save friends requests
|
||||
|
||||
=cut
|
||||
|
||||
sub www_sendFriendsRequestSave {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = {};
|
||||
my $uid = $self->uid;
|
||||
|
||||
my $user = WebGUI::User->new($session,$uid);
|
||||
|
||||
#Errors fall through to the view page.
|
||||
unless ($user->acceptsFriendsRequests($session->user)) {
|
||||
return $self->www_sendFriendsRequest;
|
||||
}
|
||||
|
||||
my $inboxUrl = WebGUI::Account::Inbox->getViewInvitationUrl($session);
|
||||
my $friends = WebGUI::Friends->new($session);
|
||||
$friends->sendAddRequest($uid, $session->form->get('message'),$inboxUrl);
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
#Overwrite this
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_profile_url' } = $user->getProfileUrl;
|
||||
|
||||
return $self->processTemplate($var,$self->getConfirmTemplateId);
|
||||
|
||||
return $self->processTemplate($var,$self->getDisplayTemplateId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view ( )
|
||||
|
||||
The main view page for editing the user's profile.
|
||||
The main view page for editing your friends.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = {};
|
||||
my $self = shift;
|
||||
my $msg = shift;
|
||||
my $session = $self->session;
|
||||
my $var = {};
|
||||
|
||||
return $self->processTemplate($var,$self->getViewTemplateId);
|
||||
my $uid = $self->uid;
|
||||
my $user = ($uid) ? WebGUI::User->new($session,$uid) : $session->user;
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
my $displayView = $uid ne "";
|
||||
$var->{'can_edit' } = $session->user->userId eq $user->userId;
|
||||
$var->{'display_message'} = $msg;
|
||||
|
||||
#Override these
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
|
||||
unless ($user->profileField('ableToBeFriend') && $user->profileIsViewable($session->user)) {
|
||||
my $i18n = WebGUI::International->new($session,"Account_Friends");
|
||||
my $errorMsg = "";
|
||||
if($var->{'can_edit'}) {
|
||||
$errorMsg = $i18n->get("friends is off");
|
||||
}
|
||||
else {
|
||||
$errorMsg = $i18n->get("no access");
|
||||
}
|
||||
my $backUrl = $self->getUrl("op=account");
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getErrorTemplateId);
|
||||
}
|
||||
|
||||
#Deal with rows per page
|
||||
my $rpp = $session->form->get("rpp") || 25;
|
||||
my $rpp_url = ";rpp=$rpp";
|
||||
|
||||
#Cache the base url
|
||||
my $friendsUrl = $self->getUrl("op=account;module=friends;do=view");
|
||||
|
||||
#Note for anyone who attempts to sort this list by the user's whole name:
|
||||
#You can do this, but the only way to do it efficiently is to join
|
||||
#the users, userProfileData, and groupings table. This will break if the groups API
|
||||
#changes in WebGUI 8, so we decided to leave it sorted by username only.
|
||||
|
||||
#Create the paginator
|
||||
my $friends = $user->friends->getUserList(1);
|
||||
my @friendIds = keys %{$friends};
|
||||
my $p = WebGUI::Paginator->new(
|
||||
$session,
|
||||
$friendsUrl.$rpp_url,
|
||||
$rpp
|
||||
);
|
||||
$p->setDataByArrayRef(\@friendIds);
|
||||
|
||||
#Export page to template
|
||||
my @friends = ();
|
||||
foreach my $friendId ( @{$p->getPageData} ) {
|
||||
my $friend = WebGUI::User->new($session,$friendId);
|
||||
next if($friend->isVisitor);
|
||||
#If you have friends turned off you shouldn't show up when other people view your friends friends
|
||||
next if($displayView && !$friend->profileField('ableToBeFriend'));
|
||||
|
||||
my $hash = {};
|
||||
$hash->{'friend_full_name' } = $friend->getWholeName;
|
||||
$hash->{'isViewable' } = $friend->profileIsViewable;
|
||||
$hash->{'friend_id' } = $friend->userId;
|
||||
$hash->{'friend_member_since' } = $friend->dateCreated;
|
||||
$hash->{'friend_member_since_human'} = $session->datetime->epochToHuman($friend->dateCreated);
|
||||
$hash->{'friend_isOnline' } = $friend->isOnline;
|
||||
if($hash->{'isViewable'}) {
|
||||
$hash->{'friend_profile_url'} = $friend->getProfileUrl;
|
||||
if($friend->profileField("photo")) {
|
||||
my $store = WebGUI::Storage::Image->get($session,$friend->profileField("photo"));
|
||||
my $file = $store->getFiles->[0];
|
||||
$hash->{'friend_photo_url' } = $store->getUrl($file);
|
||||
$hash->{'friend_photo_url_thumb'} = $store->getThumbnailUrl($file);
|
||||
}
|
||||
}
|
||||
|
||||
$hash->{'acceptsPrivateMessages'} = $friend->acceptsPrivateMessages($session->user->userId);
|
||||
if ($displayView) {
|
||||
if($friend->acceptsFriendsRequests($session->user)) {
|
||||
$hash->{'friend_request_url'} = $self->getUrl("module=friends;do=sendFriendsRequest;uid=".$friend->userId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$hash->{'remove_url'} = $self->getUrl("module=friends;do=removeFriend;friendId=".$friend->userId);
|
||||
}
|
||||
push(@friends,$hash);
|
||||
}
|
||||
my $friendCount = $p->getRowCount;
|
||||
|
||||
$var->{'friends_loop' } = \@friends;
|
||||
$var->{'has_friends' } = $friendCount > 0;
|
||||
$var->{'friends_total' } = $friendCount;
|
||||
|
||||
tie my %rpps, "Tie::IxHash";
|
||||
%rpps = (25 => "25", 50 => "50", 100=>"100");
|
||||
$var->{'message_rpp' } = WebGUI::Form::selectBox($session,{
|
||||
name =>"rpp",
|
||||
options => \%rpps,
|
||||
value => $session->form->get("rpp") || 25,
|
||||
extras => q{onchange="location.href='}.$friendsUrl.q{;rpp='+this.options[this.selectedIndex].value"}
|
||||
});
|
||||
|
||||
my $templateId = ($displayView) ? $self->getViewTemplateId : $self->getEditTemplateId;
|
||||
return $self->processTemplate($var,$templateId);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -46,17 +46,18 @@ These subroutines are available from this package:
|
|||
|
||||
sub appendCommonVars {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $inbox = shift;
|
||||
my $session = $self->session;
|
||||
my $var = shift;
|
||||
my $inbox = shift || WebGUI::Inbox->new($session);
|
||||
my $user = $session->user;
|
||||
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
$var->{'view_profile_url' } = $user->getProfileUrl;
|
||||
$self->SUPER::appendCommonVars($var);
|
||||
|
||||
$var->{'view_inbox_url' } = $self->getUrl("module=inbox;do=view");
|
||||
$var->{'view_invitations_url'} = $self->getUrl("module=inbox;do=manageInvitations");
|
||||
$var->{'unread_message_count'} = $inbox->getUnreadMessageCount;
|
||||
$var->{'invitation_count' } = $self->getInvitationCount;
|
||||
$var->{'invitations_enabled' } = $session->user->profileField('ableToBeFriend');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ sub appendCommonVars {
|
|||
|
||||
sub canView {
|
||||
my $self = shift;
|
||||
return ($self->session->form->get("uid") eq "");
|
||||
return ($self->uid eq "");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -145,11 +146,18 @@ sub editSettingsForm {
|
|||
hoverHelp => $i18n->get("inbox manage invitations template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "inboxInvitationErrorTemplateId",
|
||||
value => $self->getInvitationErrorTemplateId,
|
||||
namespace => "Account/Inbox/Error",
|
||||
label => $i18n->get("invitation error message template label"),
|
||||
hoverHelp => $i18n->get("invitation error message template hoverHelp")
|
||||
name => "inboxViewInvitationTemplateId",
|
||||
value => $self->getViewInvitationTemplateId,
|
||||
namespace => "Account/Inbox/ViewInvitation",
|
||||
label => $i18n->get("inbox view invitation template label"),
|
||||
hoverHelp => $i18n->get("inbox view invitation template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "inboxInvitationConfirmTemplateId",
|
||||
value => $self->getInvitationConfirmTemplateId,
|
||||
namespace => "Account/Inbox/Confirm",
|
||||
label => $i18n->get("invitation confirm message template label"),
|
||||
hoverHelp => $i18n->get("invitation confirm message template hoverHelp")
|
||||
);
|
||||
|
||||
return $f->printRowsOnly;
|
||||
|
|
@ -179,7 +187,8 @@ sub editSettingsFormSave {
|
|||
$session->set("inboxErrorTemplateId",$form->process("inboxErrorTemplateId","template"));
|
||||
#Invitations Settings
|
||||
$session->set("inboxManageInvitationsTemplateId",$form->process("inboxManageInvitationsTemplateId","template"));
|
||||
$session->set("inboxInvitationErrorTemplateId",$form->process("inboxInvitationErrorTemplateId","template"));
|
||||
$session->set("inboxViewInvitationTemplateId",$form->process("inboxViewInvitationTemplateId","template"));
|
||||
$session->set("inboxInvitationConfirmTemplateId",$form->process("inboxInvitationConfirmTemplateId","template"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -195,20 +204,37 @@ sub getInboxErrorTemplateId {
|
|||
return $self->session->setting->get("inboxErrorTemplateId") || "ErEzulFiEKDkaCDVmxUavw";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInvitationCount ( )
|
||||
|
||||
This method returns the total number of invitations in the invitation box.
|
||||
|
||||
=cut
|
||||
|
||||
sub getInvitationCount {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
return $session->db->quickScalar(
|
||||
q{select count(*) from friendInvitations where friendId=?},
|
||||
[$session->user->userId]
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInvitationErrorTemplateId ( )
|
||||
=head2 getInvitationConfirmTemplateId ( )
|
||||
|
||||
This method returns the template ID for invitation errors.
|
||||
|
||||
=cut
|
||||
|
||||
sub getInvitationErrorTemplateId {
|
||||
sub getInvitationConfirmTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("inboxInvitationErrorTemplateId") || "5A8Hd9zXvByTDy4x-H28qw";
|
||||
return $self->session->setting->get("inboxInvitationConfirmTemplateId") || "5A8Hd9zXvByTDy4x-H28qw";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLayoutTemplateId ( )
|
||||
|
|
@ -222,6 +248,7 @@ sub getLayoutTemplateId {
|
|||
return $self->session->setting->get("inboxLayoutTempalteId") || $self->SUPER::getLayoutTemplateId;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getManageInvitationsTemplateId ( )
|
||||
|
|
@ -295,6 +322,40 @@ sub getUserProfileUrl {
|
|||
return $self->store->{$userId};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getViewInvitationTemplateId ( )
|
||||
|
||||
This method returns the id for the view message template.
|
||||
|
||||
=cut
|
||||
|
||||
sub getViewInvitationTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("inboxViewInvitationTemplateId") || "VBkY05f-E3WJS50WpdKd1Q";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getViewInvitationUrl ( session )
|
||||
|
||||
Class method which returns the base url for viewing invitations
|
||||
|
||||
=head3 session
|
||||
|
||||
session object
|
||||
|
||||
=cut
|
||||
|
||||
sub getViewInvitationUrl {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $url = $session->url;
|
||||
|
||||
return $url->append($url->getSiteURL,"op=account;module=inbox;do=viewInvitation");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getViewMessageTemplateId ( )
|
||||
|
|
@ -323,6 +384,54 @@ sub getViewTemplateId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_approveDenyInvitations ( )
|
||||
|
||||
Approves or denies invitations passed in.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_approveDenyInvitations {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
|
||||
my @messages = $form->process("inviteId","checkList");
|
||||
my $approve = $form->get("accept");
|
||||
my $deny = $form->get("deny");
|
||||
|
||||
my $friends = WebGUI::Friends->new($session);
|
||||
|
||||
my @users = ();
|
||||
|
||||
foreach my $inviteId (@messages) {
|
||||
my $invite = $friends->getAddRequest($inviteId);
|
||||
my $inviter = WebGUI::User->new($session, $invite->{inviterId});
|
||||
next unless ($invite->{inviterId}); #Not sure how this could ever happen, but check for it
|
||||
next unless ($session->user->userId eq $invite->{friendId}); #Protect against malicious stuff
|
||||
if($deny) {
|
||||
$friends->rejectAddRequest($inviteId);
|
||||
}
|
||||
elsif($approve) {
|
||||
$friends->approveAddRequest($inviteId);
|
||||
}
|
||||
push (@users, {
|
||||
'friend_name' => $inviter->getWholeName,
|
||||
'is_denied' => ($deny ne ""),
|
||||
'is_approved' => ($approve ne ""),
|
||||
});
|
||||
}
|
||||
my $var = {};
|
||||
$var->{'friends_loop'} = \@users;
|
||||
|
||||
#Append common vars
|
||||
$self->appendCommonVars($var,WebGUI::Inbox->new($session));
|
||||
|
||||
#Return a confirm message
|
||||
return $self->processTemplate($var,$self->getInvitationConfirmTemplateId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteMessage ( )
|
||||
|
||||
Deletes a single messages passed in
|
||||
|
|
@ -389,15 +498,84 @@ The page on which users can manage their friends requests
|
|||
=cut
|
||||
|
||||
sub www_manageInvitations {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $user = $session->user;
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $user = $session->user;
|
||||
my $var = {};
|
||||
my $i18n = WebGUI::International->new($session,'Account_Inbox');
|
||||
|
||||
#Deal with rows per page
|
||||
my $rpp = $session->form->get("rpp") || 25;
|
||||
my $rpp_url = ";rpp=$rpp";
|
||||
|
||||
#Cache the base url
|
||||
my $inboxUrl = $self->getUrl("op=account;module=inbox;do=manageInvitations");
|
||||
|
||||
my $var = {};
|
||||
#Create the paginator
|
||||
my $sql = q{ select * from friendInvitations where friendId=? order by dateSent desc };
|
||||
my $p = WebGUI::Paginator->new(
|
||||
$session,
|
||||
$inboxUrl.$rpp_url,
|
||||
$rpp
|
||||
);
|
||||
$p->setDataByQuery($sql,undef,undef,[$user->userId]);
|
||||
|
||||
#Export page to template
|
||||
my @msg = ();
|
||||
foreach my $row ( @{$p->getPageData} ) {
|
||||
my $inviter = WebGUI::User->new($session,$row->{inviterId});
|
||||
next if($inviter->isVisitor); # Inviter account got deleted
|
||||
|
||||
my $epoch = WebGUI::DateTime->new(mysql => $row->{dateSent} )->epoch;
|
||||
|
||||
my $hash = {};
|
||||
$hash->{'invite_id' } = $row->{inviteId};
|
||||
$hash->{'message_url' } = $self->getUrl("module=inbox;do=viewInvitation;inviteId=".$row->{inviteId});
|
||||
$hash->{'from_id' } = $row->{inviterId};
|
||||
$hash->{'from_url' } = $inviter->getProfileUrl; #Get the profile url of this user which may be cached.
|
||||
$hash->{'from' } = $inviter->getWholeName;
|
||||
$hash->{'dateStamp' } = $epoch;
|
||||
$hash->{'dateStamp_formatted'} = $session->datetime->epochToHuman($epoch);
|
||||
$hash->{'form_checkbox' } = WebGUI::Form::checkbox($session,{
|
||||
name => "inviteId",
|
||||
value => $row->{inviteId}
|
||||
});
|
||||
push(@msg,$hash);
|
||||
}
|
||||
my $msgCount = $p->getRowCount;
|
||||
|
||||
$var->{'message_loop' } = \@msg;
|
||||
$var->{'has_messages' } = $msgCount > 0;
|
||||
$var->{'message_total' } = $msgCount;
|
||||
|
||||
#Add common template variable for displaying the inbox
|
||||
my $inbox = WebGUI::Inbox->new($session);
|
||||
$self->appendCommonVars($var,$inbox);
|
||||
$var->{'form_start' } = WebGUI::Form::formHeader($session,{
|
||||
action => $self->getUrl("module=inbox;do=approveDenyInvitations")
|
||||
});
|
||||
$var->{'form_end' } = WebGUI::Form::formFooter($session);
|
||||
|
||||
$var->{'form_accept' } = WebGUI::Form::submit($session,{
|
||||
name =>"accept",
|
||||
value =>$i18n->get("accept button label")
|
||||
});
|
||||
|
||||
$var->{'form_deny' } = WebGUI::Form::submit($session,{
|
||||
name =>"deny",
|
||||
value =>$i18n->get("deny button label")
|
||||
});
|
||||
|
||||
tie my %rpps, "Tie::IxHash";
|
||||
%rpps = (25 => "25", 50 => "50", 100=>"100");
|
||||
$var->{'message_rpp' } = WebGUI::Form::selectBox($session,{
|
||||
name =>"rpp",
|
||||
options => \%rpps,
|
||||
value => $session->form->get("rpp") || 25,
|
||||
extras => q{onchange="location.href='}.$inboxUrl.q{;rpp='+this.options[this.selectedIndex].value"}
|
||||
});
|
||||
|
||||
#Append common vars
|
||||
$self->appendCommonVars($var,WebGUI::Inbox->new($session));
|
||||
#Append pagination vars
|
||||
$p->appendTemplateVars($var);
|
||||
|
||||
return $self->processTemplate($var,$self->getManageInvitationsTemplateId);
|
||||
}
|
||||
|
|
@ -453,6 +631,7 @@ sub www_sendMessage {
|
|||
$errorMsg = $i18n->get("system message error");
|
||||
}
|
||||
if($errorMsg) {
|
||||
$var->{'isInbox'} = "true";
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId);
|
||||
}
|
||||
|
||||
|
|
@ -478,6 +657,7 @@ sub www_sendMessage {
|
|||
$errorMsg = $i18n->get("no self error");
|
||||
}
|
||||
if($errorMsg) {
|
||||
$var->{'isInbox'} = "true";
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId);
|
||||
}
|
||||
|
||||
|
|
@ -530,6 +710,7 @@ sub www_sendMessage {
|
|||
unless($activeFriendCount) {
|
||||
my $i18n = WebGUI::International->new($session,'Account_Inbox');
|
||||
$errorMsg = $i18n->get("no friends error");
|
||||
$var->{'isInbox'} = "true";
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId);
|
||||
}
|
||||
|
||||
|
|
@ -553,8 +734,10 @@ sub www_sendMessage {
|
|||
$var->{'message_body' } = $form->get('message');
|
||||
|
||||
$var->{'form_message_text'} = WebGUI::Form::textarea($session, {
|
||||
name =>"message",
|
||||
value =>$var->{'message_body'} || "",
|
||||
name =>"message",
|
||||
value =>$var->{'message_body'} || "",
|
||||
width =>600,
|
||||
height =>200
|
||||
});
|
||||
|
||||
$var->{'form_message_rich'} = WebGUI::Form::HTMLArea($session, {
|
||||
|
|
@ -771,6 +954,99 @@ sub www_view {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewInvitation ( )
|
||||
|
||||
The page on which users view their messages
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewInvitation {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $user = $session->user;
|
||||
|
||||
my $var = {};
|
||||
my $inviteId = shift || $session->form->get("inviteId");
|
||||
my $errorMsg = shift;
|
||||
my $i18n = WebGUI::International->new($session,'Account_Inbox');
|
||||
|
||||
|
||||
my $friends = WebGUI::Friends->new($session);
|
||||
my $invitation = $friends->getAddRequest($inviteId);
|
||||
my $inviter = WebGUI::User->new($session,$invitation->{inviterId});
|
||||
|
||||
#Add common template variable for displaying the inbox
|
||||
$self->appendCommonVars($var,WebGUI::Inbox->new($session));
|
||||
|
||||
#Handle Errors
|
||||
if (!($invitation->{inviteId})) { #Invitation is invalid
|
||||
$errorMsg = $i18n->get("invitation does not exist");
|
||||
}
|
||||
elsif ($inviter->isVisitor) { #Inviter user account was deleted
|
||||
$errorMsg = $i18n->get("inviter no longer exists");
|
||||
}
|
||||
elsif ($session->user->userId ne $invitation->{friendId}) { #User trying to view someone else's invitation
|
||||
$errorMsg = $i18n->get("no access to invitation");
|
||||
}
|
||||
|
||||
if($errorMsg) {
|
||||
my $backUrl = $var->{'view_invitations_url'};
|
||||
$var->{'isInvitation'} = "true";
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId);
|
||||
}
|
||||
|
||||
my $epoch = WebGUI::DateTime->new(mysql => $invitation->{dateSent} )->epoch;
|
||||
|
||||
$var->{'invite_id' } = $inviteId;
|
||||
$var->{'message_from_id' } = $inviter->userId;
|
||||
$var->{'message_from' } = $inviter->getWholeName;
|
||||
$var->{'message_from_url' } = $inviter->getProfileUrl;
|
||||
$var->{'message_dateStamp' } = $epoch;
|
||||
$var->{'message_dateStamp_human'} = $session->datetime->epochToHuman($epoch);
|
||||
$var->{'message_body' } = $invitation->{comments};
|
||||
|
||||
unless ($var->{'message_body'} =~ /\<a/ig) {
|
||||
$var->{'message_body'} =~ s/(http\S*)/\<a href=\"$1\"\>$1\<\/a\>/g;
|
||||
}
|
||||
unless ($var->{'message_body'} =~ /\<div/ig
|
||||
|| $var->{'message_body'} =~ /\<br/ig
|
||||
|| $var->{'message_body'} =~ /\<p/ig) {
|
||||
$var->{'message_body'} =~ s/\n/\<br \/\>\n/g;
|
||||
}
|
||||
|
||||
#Build the action URLs
|
||||
my $nextInvitation = $friends->getPreviousInvitation($invitation); #Messages sorted descending so next is actually previous
|
||||
if( $nextInvitation->{inviteId} ) {
|
||||
$var->{'hasNext' } = "true";
|
||||
$var->{'next_message_url'} = $self->getUrl("module=inbox;do=viewInvitation;inviteId=".$nextInvitation->{inviteId});
|
||||
}
|
||||
|
||||
my $prevInvitation = $friends->getNextInvitation($invitation); #Messages sorted descending so previous is actually next
|
||||
if( $prevInvitation->{inviteId} ) {
|
||||
$var->{'hasPrevious' } = "true";
|
||||
$var->{'prev_message_url'} = $self->getUrl("module=inbox;do=viewInvitation;inviteId=".$prevInvitation->{inviteId});
|
||||
}
|
||||
|
||||
$var->{'form_header' } = WebGUI::Form::formHeader($session,{
|
||||
action => $self->getUrl("module=inbox;do=approveDenyInvitations;inviteId=".$inviteId)
|
||||
});
|
||||
$var->{'form_footer' } = WebGUI::Form::formFooter($session);
|
||||
|
||||
$var->{'form_accept' } = WebGUI::Form::submit($session,{
|
||||
name =>"accept",
|
||||
value =>$i18n->get("accept button label")
|
||||
});
|
||||
|
||||
$var->{'form_deny' } = WebGUI::Form::submit($session,{
|
||||
name =>"deny",
|
||||
value =>$i18n->get("deny button label")
|
||||
});
|
||||
|
||||
return $self->processTemplate($var,$self->getViewInvitationTemplateId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewMessage ( )
|
||||
|
||||
The page on which users view their messages
|
||||
|
|
@ -804,6 +1080,7 @@ sub www_viewMessage {
|
|||
|
||||
if($errorMsg) {
|
||||
my $backUrl = $var->{'view_inbox_url'};
|
||||
$var->{'isInvitation'} = "true";
|
||||
return $self->showError($var,$errorMsg,$backUrl,$self->getInboxErrorTemplateId);
|
||||
}
|
||||
|
||||
|
|
@ -812,7 +1089,7 @@ sub www_viewMessage {
|
|||
$var->{'message_id' } = $messageId;
|
||||
$var->{'message_subject' } = $message->get("subject");
|
||||
$var->{'message_dateStamp' } = $message->get("dateStamp");
|
||||
$var->{'message_dateStemp_human'} = $session->datetime->epochToHuman($var->{'message_dateStamp'});
|
||||
$var->{'message_dateStamp_human'} = $session->datetime->epochToHuman($var->{'message_dateStamp'});
|
||||
$var->{'message_status' } = $message->getStatus;
|
||||
$var->{'message_body' } = $message->get("message");
|
||||
|
||||
|
|
@ -848,13 +1125,13 @@ sub www_viewMessage {
|
|||
$var->{'reply_url'} = $self->getUrl("module=inbox;do=sendMessage;messageId=".$messageId);
|
||||
}
|
||||
|
||||
my $nextMessage = $inbox->getNextMessage($message);
|
||||
my $nextMessage = $inbox->getPreviousMessage($message); #Message are displayed in descending order so next is actually previous
|
||||
if( defined $nextMessage ) {
|
||||
$var->{'hasNext' } = "true";
|
||||
$var->{'next_message_url'} = $self->getUrl("module=inbox;do=viewMessage;messageId=".$nextMessage->getId);
|
||||
}
|
||||
|
||||
my $prevMessage = $inbox->getPreviousMessage($message);
|
||||
my $prevMessage = $inbox->getNextMessage($message); #Messages are displayed in descending order so previous is actually next
|
||||
if(defined $prevMessage) {
|
||||
$var->{'hasPrevious' } = "true";
|
||||
$var->{'prev_message_url'} = $self->getUrl("module=inbox;do=viewMessage;messageId=".$prevMessage->getId);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ These subroutines are available from this package:
|
|||
|
||||
=head2 appendCommonVars ( var )
|
||||
|
||||
Appends common template variables that all inbox templates use
|
||||
Appends common template variables that all profile templates use
|
||||
|
||||
=head3 var
|
||||
|
||||
|
|
@ -47,11 +47,12 @@ sub appendCommonVars {
|
|||
my $user = $session->user;
|
||||
my $pageUrl = $session->url->page;
|
||||
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
$var->{'view_profile_url' } = $user->getProfileUrl($pageUrl);
|
||||
$var->{'edit_profile_url' } = $self->getUrl("module=profile;do=edit");
|
||||
$var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_profile_url'}
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
$var->{'view_profile_url' } = $user->getProfileUrl($pageUrl);
|
||||
$var->{'edit_profile_url' } = $self->getUrl("module=profile;do=edit");
|
||||
$var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_profile_url'};
|
||||
$var->{'invitations_enabled' } = $session->user->profileField('ableToBeFriend');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -104,6 +105,14 @@ sub editSettingsForm {
|
|||
label => $i18n->get("profile view template label"),
|
||||
hoverHelp => $i18n->get("profile view template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "profileErrorTemplateId",
|
||||
value => $self->getErrorTemplateId,
|
||||
namespace => "Account/Profile/Error",
|
||||
label => $i18n->get("profile error template label"),
|
||||
hoverHelp => $i18n->get("profile error template hoverHelp")
|
||||
);
|
||||
|
||||
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
|
@ -128,6 +137,7 @@ sub editSettingsFormSave {
|
|||
$setting->set("profileDisplayLayoutTemplateId", $form->process("profileDisplayLayoutTemplateId","template"));
|
||||
$setting->set("profileEditTemplateId", $form->process("profileEditTemplateId","template"));
|
||||
$setting->set("profileViewTempalteId", $form->process("profileViewTemplateId","template"));
|
||||
$setting->set("profileErrorTemplateId",$form->process("profileErrorTemplateId","template"));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -194,6 +204,20 @@ sub getEditTemplateId {
|
|||
return $self->session->setting->get("profileEditTemplateId") || "75CmQgpcCSkdsL-oawdn3Q";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getErrorTemplateId ( )
|
||||
|
||||
This method returns the template ID used to display the error page.
|
||||
|
||||
=cut
|
||||
|
||||
sub getErrorTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("profileErrorTemplateId") || "MBmWlA_YEA2I6D29OMGtRg";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLayoutTemplateId ( )
|
||||
|
|
@ -205,9 +229,9 @@ This method returns the template ID for the account layout.
|
|||
sub getLayoutTemplateId {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $method = $session->form->get("do");
|
||||
my $uid = $session->form->get("uid");
|
||||
|
||||
my $method = $self->method;
|
||||
my $uid = $self->uid;
|
||||
|
||||
return $self->getEditLayoutTemplateId if($method eq "edit" || $uid eq "");
|
||||
return $session->setting->get("profileLayoutTemplateId") || $self->SUPER::getLayoutTemplateId;
|
||||
}
|
||||
|
|
@ -240,114 +264,6 @@ sub getViewTemplateId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 saveProfileFields ( session, user, profile )
|
||||
|
||||
Saves profile data to a user's profile. Does not validate any of the data.
|
||||
|
||||
=head3 session
|
||||
|
||||
WebGUI session object
|
||||
|
||||
=head3 user
|
||||
|
||||
User object. Profile data will be placed in this user's profile.
|
||||
|
||||
=head3 profile
|
||||
|
||||
Hash ref of profile data to save.
|
||||
|
||||
=cut
|
||||
|
||||
sub saveProfileFields {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $u = shift;
|
||||
my $profile = shift;
|
||||
|
||||
foreach my $fieldName (keys %{$profile}) {
|
||||
$u->profileField($fieldName,${$profile}{$fieldName});
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 validateProfileFields ( session, fields )
|
||||
|
||||
Class method which validates profile data from the session form variables. Returns an data structure which contains the following
|
||||
|
||||
{
|
||||
profile => Hash reference containing all of the profile fields and their values
|
||||
errors => Array reference of error messages to be displayed
|
||||
errorCategory => Category in which the first error was thrown
|
||||
warnings => Array reference of warnings to be displayed
|
||||
errorFields => Array reference of the fieldIds that threw an error
|
||||
warningFields => Array reference of the fieldIds that threw a warning
|
||||
}
|
||||
|
||||
=head3 session
|
||||
|
||||
WebGUI session object
|
||||
|
||||
=head3 fields
|
||||
|
||||
An array reference of profile fields to validate.
|
||||
|
||||
=cut
|
||||
|
||||
sub validateProfileFields {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $fields = shift;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'Account_Profile');
|
||||
|
||||
my $data = {};
|
||||
my $errors = [];
|
||||
my $warnings = [];
|
||||
my $errorCat = undef;
|
||||
my $errorFields = [];
|
||||
my $warnFields = [];
|
||||
|
||||
foreach my $field (@{$fields}) {
|
||||
my $fieldId = $field->getId;
|
||||
my $fieldLabel = $field->getLabel;
|
||||
my $fieldValue = $field->formProcess;
|
||||
my $isValid = $field->isValid($fieldValue);
|
||||
|
||||
$data->{$fieldId} = (ref $fieldValue eq "ARRAY") ? $fieldValue->[0] : $fieldValue;
|
||||
|
||||
if(!$isValid) {
|
||||
$errorCat = $field->get("profileCategoryId") unless (defined $errorCat);
|
||||
push (@{$errors}, sprintf($i18n->get("required error"),$fieldLabel));
|
||||
push(@{$errorFields},$fieldId);
|
||||
}
|
||||
#The language field is special and must be always be valid or WebGUI will croak
|
||||
elsif($fieldId eq "language" && !(exists $i18n->getLanguages()->{$data->{$fieldId}})) {
|
||||
$errorCat = $field->get("profileCategoryId") unless (defined $errorCat);
|
||||
$session->log->warn("language $fieldValue does not exist");
|
||||
push (@{$errors}, sprintf($i18n->get("language not installed error"),$data->{$fieldId}));
|
||||
push(@{$errorFields},$fieldId);
|
||||
}
|
||||
#Duplicate emails throw warnings
|
||||
elsif($fieldId eq "email" && $field->isDuplicate($fieldValue)) {
|
||||
$errorCat = $field->get("profileCategoryId") unless (defined $errorCat);
|
||||
push (@{$warnings},$i18n->get("email already in use error"));
|
||||
push(@{$warnFields},$fieldId);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
profile => $data,
|
||||
errors => $errors,
|
||||
warnings => $warnings,
|
||||
errorCategory => $errorCat,
|
||||
errorFields => $errorFields,
|
||||
warningFields => $warnFields,
|
||||
};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
||||
The edit page for the user's profile.
|
||||
|
|
@ -369,6 +285,10 @@ sub www_edit {
|
|||
my @errorFields = ();
|
||||
@errorFields = (@{$errors->{errorFields}},@{$errors->{warningFields}}) if($hasErrors);
|
||||
|
||||
$var->{'profile_errors' } = [];
|
||||
map{ push(@{$var->{'profile_errors'}},{ error_message => $_ }) } @{$errors->{errors}} if($hasErrors);
|
||||
$var->{'hasErrors' } = scalar(@{$var->{'profile_errors'}}) > 0;
|
||||
|
||||
my @categories = ();
|
||||
foreach my $category (@{WebGUI::ProfileCategory->getCategories($session)}) {
|
||||
next unless $category->isEditable;
|
||||
|
|
@ -415,6 +335,7 @@ sub www_edit {
|
|||
'profile_category_shortLabel' => $shortCategoryLabel,
|
||||
'profile_category_index' => $categoryIndex,
|
||||
'profile_fields_loop' => \@fields,
|
||||
'profile_errors' => $var->{'profile_errors'},
|
||||
});
|
||||
#This value will determine whether or not a valid category is active or not
|
||||
$active ||= $isActive;
|
||||
|
|
@ -431,11 +352,8 @@ sub www_edit {
|
|||
});
|
||||
$var->{'profile_form_footer' } = WebGUI::Form::formFooter($session);
|
||||
|
||||
$var->{'profile_errors' } = [];
|
||||
map{ push(@{$var->{'profile_errors'}},{ error_message => $_ }) } @{$errors->{errors}} if($hasErrors);
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
|
||||
return $self->processTemplate($var,$self->getEditTemplateId);
|
||||
}
|
||||
|
||||
|
|
@ -453,7 +371,7 @@ sub www_editSave {
|
|||
my $session = $self->session;
|
||||
|
||||
my $fields = WebGUI::ProfileField->getEditableFields($session);
|
||||
my $retHash = $self->validateProfileFields($session,$fields);
|
||||
my $retHash = $session->user->validateProfileDataFromForm($fields);
|
||||
push (@{$retHash->{errors}},@{$retHash->{warnings}});
|
||||
|
||||
unless(scalar(@{$retHash->{errors}})) {
|
||||
|
|
@ -476,9 +394,8 @@ The display page of the .
|
|||
sub www_view {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $i18n = WebGUI::International->new($session, 'Account_Profile');
|
||||
my $var = {};
|
||||
my $uid = $session->form->get("uid");
|
||||
my $uid = $self->uid;
|
||||
my $selected = $session->form->get("selected"); #Allow users to template tabs or other category dividers
|
||||
|
||||
my $active = 0; #Whether or not a category is selected
|
||||
|
|
@ -487,15 +404,23 @@ sub www_view {
|
|||
#Ensure uid is passed in if they want to view a profile. This controls the tab state.
|
||||
return $self->www_edit unless ($uid);
|
||||
|
||||
my $user = WebGUI::User->new($session,$uid);
|
||||
my $user = WebGUI::User->new($session,$uid);
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
#Overwrite these
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
|
||||
#Check user privileges
|
||||
#return $session->style->userStyle($vars->{displayTitle}.'. '.$i18n->get(862)) if($u->profileField("publicProfile") < 1 && ($session->user->userId ne $session->form->process("uid") || $session->user->isAdmin));
|
||||
#return $session->privilege->insufficient() if(!$session->user->isRegistered);
|
||||
|
||||
if($user->isVisitor) {
|
||||
$var->{'restricted' } = "true";
|
||||
$var->{'error_message'} = $i18n->get("visitor profile restricted");
|
||||
unless ($user->profileIsViewable($session->user)) {
|
||||
my $i18n = WebGUI::International->new($session,'Account_Profile');
|
||||
return $self->showError(
|
||||
$var,
|
||||
$i18n->get("profile not public error"),
|
||||
$var->{'back_url'},
|
||||
$self->getErrorTemplateId
|
||||
);
|
||||
}
|
||||
|
||||
my @categories = ();
|
||||
|
|
@ -549,6 +474,8 @@ sub www_view {
|
|||
|
||||
#If not category is selected, set the first category as the active one
|
||||
$categories[0]->{profile_category_isActive} = 1 unless($active);
|
||||
my $privacySetting = $user->profileField("publicProfile") || "none";
|
||||
$var->{'profile_privacy_'.$privacySetting } = "true";
|
||||
|
||||
$var->{'profile_category_loop' } = \@categories;
|
||||
$var->{'profile_user_id' } = $user->userId;
|
||||
|
|
@ -556,12 +483,6 @@ sub www_view {
|
|||
$var->{'acceptsPrivateMessages'} = $user->acceptsPrivateMessages($session->user->userId);
|
||||
$var->{'acceptsFriendsRequests'} = $user->acceptsFriendsRequests($session->user);
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
#Overwrite these
|
||||
$var->{'user_full_name' } = $user->getWholeName;
|
||||
$var->{'user_member_since' } = $user->dateCreated;
|
||||
|
||||
return $self->processTemplate($var,$self->getViewTemplateId);
|
||||
}
|
||||
|
||||
|
|
|
|||
297
lib/WebGUI/Account/Shop.pm
Normal file
297
lib/WebGUI/Account/Shop.pm
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
package WebGUI::Account::Shop;
|
||||
|
||||
use strict;
|
||||
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Utility;
|
||||
use base qw/WebGUI::Account/;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Account::Shop
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Shop Features built into the Account system
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Account::Shop;
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 appendCommonVars ( var )
|
||||
|
||||
Appends common template variables that shop templates will use
|
||||
|
||||
=head3 var
|
||||
|
||||
The hash reference to append template variables to
|
||||
|
||||
=cut
|
||||
|
||||
sub appendCommonVars {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
|
||||
$self->SUPER::appendCommonVars($var);
|
||||
|
||||
my $session = $self->session;
|
||||
my $user = $session->user;
|
||||
my $method = $session->form->get("do");
|
||||
|
||||
$var->{'manage_purchases_url' } = $self->getUrl("module=shop;do=managePurchases");
|
||||
$var->{'managesPurchasesIsActive'} = WebGUI::Utility::isIn($method,("","managePurchases","view","viewTransaction"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canView ( )
|
||||
|
||||
Returns whether or not the user can view the the tab for this module
|
||||
|
||||
=cut
|
||||
|
||||
sub canView {
|
||||
my $self = shift;
|
||||
return ($self->uid eq "");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=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 $i18n = WebGUI::International->new($session,'Account_Shop');
|
||||
my $shopi18n = WebGUI::International->new($session,'Shop');
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
|
||||
$f->template(
|
||||
name => "shopStyleTemplateId",
|
||||
value => $self->getStyleTemplateId,
|
||||
namespace => "style",
|
||||
label => $i18n->get("shop style template label"),
|
||||
hoverHelp => $i18n->get("shop style template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "shopLayoutTemplateId",
|
||||
value => $self->getLayoutTemplateId,
|
||||
namespace => "Account/Layout",
|
||||
label => $i18n->get("shop layout template label"),
|
||||
hoverHelp => $i18n->get("shop layout template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "shopMyPurchasesTemplateId",
|
||||
value => $self->session->setting->get("shopMyPurchasesTemplateId"),
|
||||
namespace => "Shop/MyPurchases",
|
||||
label => $shopi18n->get("my purchases template"),
|
||||
hoverHelp => $shopi18n->get("my purchases template help")
|
||||
);
|
||||
$f->template(
|
||||
name => "shopMyPurchasesDetailTemplateId",
|
||||
value => $self->session->setting->get("shopMyPurchasesDetailTemplateId"),
|
||||
namespace => "Shop/MyPurchasesDetail",
|
||||
label => $shopi18n->get("my purchases detail template"),
|
||||
hoverHelp => $shopi18n->get("my purchases detail template help")
|
||||
);
|
||||
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 editSettingsFormSave ( )
|
||||
|
||||
Creates form elements for the 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("shopStyleTemplateId", $form->process("shopStyleTemplateId","template"));
|
||||
$setting->set("shopLayoutTemplateId", $form->process("shopLayoutTemplateId","template"));
|
||||
$setting->set("shopMyPurchasesTemplateId", $form->process("shopMyPurchasesTemplateId","template"));
|
||||
$setting->set("shopMyPurchasesDetailTemplateId", $form->process("shopMyPurchasesDetailTemplateId","template"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLayoutTemplateId ( )
|
||||
|
||||
This method returns the templateId for the layout of your new module.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLayoutTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("shopLayoutTemplateId") || "aUDsJ-vB9RgP-AYvPOy8FQ";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStyleTemplateId ( )
|
||||
|
||||
This method returns the template ID for the main style.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStyleTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("shopStyleTemplateId") || $self->SUPER::getStyleTemplateId;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_managePurchases ( )
|
||||
|
||||
The main view page for editing the user's profile.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_managePurchases {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $url = $session->url;
|
||||
|
||||
my $var = {};
|
||||
|
||||
# build list
|
||||
foreach my $id (@{WebGUI::Shop::Transaction->getTransactionIdsForUser($session)}) {
|
||||
my $transaction = WebGUI::Shop::Transaction->new($session, $id);
|
||||
push @{$var->{transactions}}, {
|
||||
%{$transaction->get},
|
||||
viewDetailUrl => $self->getUrl('op=account;module=shop;do=viewTransaction;transactionId='.$id),
|
||||
amount => sprintf("%.2f", $transaction->get('amount')),
|
||||
};
|
||||
}
|
||||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
return $self->processTemplate($var,$session->setting->get("shopMyPurchasesTemplateId"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_view ( )
|
||||
|
||||
The main view page for editing the user's profile.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
|
||||
#Use the view class as the driver for now. This will likely grow
|
||||
return $self->www_managePurchases();
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewTransaction ( )
|
||||
|
||||
The main view page for editing the user's profile.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewTransaction {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $transactionId = $session->form->get('transactionId');
|
||||
my $transaction = shift || WebGUI::Shop::Transaction->new($session,$transactionId);
|
||||
my $notice = shift;
|
||||
|
||||
return $session->insufficient unless ($transaction->get('userId') eq $session->user->userId);
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'Shop');
|
||||
my $i18n = WebGUI::International->new($session, 'Shop');
|
||||
my ($style, $url) = $session->quick(qw(style url));
|
||||
|
||||
my %var = (
|
||||
%{$transaction->get},
|
||||
notice => $notice,
|
||||
cancelRecurringUrl => $url->page('shop=transaction;method=cancelRecurring;transactionId='.$transaction->getId),
|
||||
amount => sprintf("%.2f", $transaction->get('amount')),
|
||||
inShopCreditDeduction => sprintf("%.2f", $transaction->get('inShopCreditDeduction')),
|
||||
taxes => sprintf("%.2f", $transaction->get('taxes')),
|
||||
shippingPrice => sprintf("%.2f", $transaction->get('shippingPrice')),
|
||||
shippingAddress => $transaction->formatAddress({
|
||||
name => $transaction->get('shippingAddressName'),
|
||||
address1 => $transaction->get('shippingAddress1'),
|
||||
address2 => $transaction->get('shippingAddress2'),
|
||||
address3 => $transaction->get('shippingAddress3'),
|
||||
city => $transaction->get('shippingCity'),
|
||||
state => $transaction->get('shippingState'),
|
||||
code => $transaction->get('shippingCode'),
|
||||
country => $transaction->get('shippingCountry'),
|
||||
phoneNumber => $transaction->get('shippingPhoneNumber'),
|
||||
}),
|
||||
paymentAddress => $transaction->formatAddress({
|
||||
name => $transaction->get('paymentAddressName'),
|
||||
address1 => $transaction->get('paymentAddress1'),
|
||||
address2 => $transaction->get('paymentAddress2'),
|
||||
address3 => $transaction->get('paymentAddress3'),
|
||||
city => $transaction->get('paymentCity'),
|
||||
state => $transaction->get('paymentState'),
|
||||
code => $transaction->get('paymentCode'),
|
||||
country => $transaction->get('paymentCountry'),
|
||||
phoneNumber => $transaction->get('paymentPhoneNumber'),
|
||||
}),
|
||||
);
|
||||
|
||||
# items
|
||||
my @items = ();
|
||||
foreach my $item (@{$transaction->getItems}) {
|
||||
my $address = '';
|
||||
if ($transaction->get('shippingAddressId') ne $item->get('shippingAddressId')) {
|
||||
$address = $transaction->formatAddress({
|
||||
name => $item->get('shippingAddressName'),
|
||||
address1 => $item->get('shippingAddress1'),
|
||||
address2 => $item->get('shippingAddress2'),
|
||||
address3 => $item->get('shippingAddress3'),
|
||||
city => $item->get('shippingCity'),
|
||||
state => $item->get('shippingState'),
|
||||
code => $item->get('shippingCode'),
|
||||
country => $item->get('shippingCountry'),
|
||||
phoneNumber => $item->get('shippingPhoneNumber'),
|
||||
});
|
||||
}
|
||||
push @items, {
|
||||
%{$item->get},
|
||||
viewItemUrl => $url->page('shop=transaction;method=viewItem;transactionId='.$transaction->getId.';itemId='.$item->getId),
|
||||
price => sprintf("%.2f", $item->get('price')),
|
||||
itemShippingAddress => $address,
|
||||
orderStatus => $i18n->get($item->get('orderStatus')),
|
||||
};
|
||||
}
|
||||
$var{items} = \@items;
|
||||
|
||||
$self->appendCommonVars(\%var);
|
||||
|
||||
# render
|
||||
return $self->processTemplate(\%var,$session->setting->get("shopMyPurchasesDetailTemplateId"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
@ -6,6 +6,8 @@ use WebGUI::Exception;
|
|||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Operation::Auth;
|
||||
|
||||
use base qw/WebGUI::Account/;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -26,6 +28,18 @@ These subroutines are available from this package:
|
|||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canView ( )
|
||||
|
||||
Returns whether or not the user can view the inbox tab
|
||||
|
||||
=cut
|
||||
|
||||
sub canView {
|
||||
my $self = shift;
|
||||
return ($self->uid eq "");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -42,13 +56,24 @@ sub editSettingsForm {
|
|||
my $i18n = WebGUI::International->new($session,'Account_User');
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
|
||||
# $f->template(
|
||||
# name => "profileStyleTemplateId",
|
||||
# value => $self->getStyleTemplateId,
|
||||
# namespace => "style",
|
||||
# label => $i18n->get("profile style template label"),
|
||||
# hoverHelp => $i18n->get("profile style template hoverHelp")
|
||||
# );
|
||||
$f->template(
|
||||
name => "userAccountStyleTemplateId",
|
||||
value => $self->session->setting->get("userAccountStyleTemplateId"),
|
||||
namespace => "style",
|
||||
label => $i18n->get("user style template label"),
|
||||
hoverHelp => $i18n->get("user style template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "userAccountLayoutTemplateId",
|
||||
value => $self->session->setting->get("userAccountLayoutTemplateId"),
|
||||
namespace => "Account/Layout",
|
||||
label => $i18n->get("layout template label"),
|
||||
hoverHelp => $i18n->get("layout template hoverHelp")
|
||||
);
|
||||
$f->raw(q{<tr><td class="formDescription" colspan="2"> </td></tr>});
|
||||
$f->readOnly (
|
||||
value => $i18n->get("templates in auth method message"),
|
||||
);
|
||||
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
|
@ -62,6 +87,13 @@ sub editSettingsForm {
|
|||
=cut
|
||||
|
||||
sub editSettingsFormSave {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $setting = $session->setting;
|
||||
my $form = $session->form;
|
||||
|
||||
$setting->set("userAccountStyleTemplateId", $form->process("userAccountStyleTemplateId","template"));
|
||||
$setting->set("userAccountLayoutTemplateId", $form->process("userAccountLayoutTemplateId","template"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -74,7 +106,7 @@ This method returns the template ID for the account layout.
|
|||
|
||||
sub getLayoutTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("userLayoutTempalteId") || $self->SUPER::getLayoutTemplateId;
|
||||
return $self->session->setting->get("userAccountLayoutTemplateId") || "9ThW278DWLV0-Svf68ljFQ";
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -88,21 +120,9 @@ This method returns the template ID for the main style.
|
|||
|
||||
sub getStyleTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("userStyleTemplateId") || $self->SUPER::getStyleTemplateId;
|
||||
return $self->session->setting->get("userAccountStyleTemplateId") || $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("userViewTemplateId") || "defaultAssetId";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -115,9 +135,10 @@ The main view page for editing the user's profile.
|
|||
sub www_view {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = {};
|
||||
|
||||
return $self->processTemplate($var,$self->getViewTemplateId);
|
||||
my $auth = WebGUI::Operation::Auth::getInstance($session);
|
||||
|
||||
return $auth->displayAccount;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
145
lib/WebGUI/Account/_NewModule.skeleton
Normal file
145
lib/WebGUI/Account/_NewModule.skeleton
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
package WebGUI::Account::NewModule;
|
||||
|
||||
use strict;
|
||||
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Utility;
|
||||
use base qw/WebGUI::Account/;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Account::NewAsset
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Describe your New Account Module's functionality and features here.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Account::NewModule;
|
||||
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canView ( )
|
||||
|
||||
Returns whether or not the user can view the the tab for this module
|
||||
|
||||
=cut
|
||||
|
||||
sub canView {
|
||||
my $self = shift;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=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 $i18n = WebGUI::International->new($session,'Account_NewModule');
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
|
||||
$f->template(
|
||||
name => "moduleStyleTemplateId",
|
||||
value => $self->getStyleTemplateId,
|
||||
namespace => "style",
|
||||
label => $i18n->get("style template label"),
|
||||
hoverHelp => $i18n->get("style template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "moduleLayoutTemplateId",
|
||||
value => $self->getLayoutTemplateId,
|
||||
namespace => "Account/Layout",
|
||||
label => $i18n->get("layout template label"),
|
||||
hoverHelp => $i18n->get("layout template hoverHelp")
|
||||
);
|
||||
$f->template(
|
||||
name => "moduleViewTemplateId",
|
||||
value => $self->session->setting->get("moduleViewTemplateId"),
|
||||
namespace => "Account/NewModule/View",
|
||||
label => $i18n->get("view template label"),
|
||||
hoverHelp => $i18n->get("view template hoverHelp")
|
||||
);
|
||||
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 editSettingsFormSave ( )
|
||||
|
||||
Creates form elements for the 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("moduleStyleTemplateId", $form->process("moduleStyleTemplateId","template"));
|
||||
$setting->set("moduleLayoutTemplateId", $form->process("moduleLayoutTemplateId","template"));
|
||||
$setting->set("moduleViewTemplateId", $form->process("moduleViewTemplateId","template"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLayoutTemplateId ( )
|
||||
|
||||
This method returns the templateId for the layout of your new module.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLayoutTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("moduleLayoutTempalteId") || $self->SUPER::getLayoutTemplateId;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStyleTemplateId ( )
|
||||
|
||||
This method returns the template ID for the main style.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStyleTemplateId {
|
||||
my $self = shift;
|
||||
return $self->session->setting->get("moduleStyleTemplateId") || $self->SUPER::getStyleTemplateId;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=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 $var = {};
|
||||
|
||||
return $self->processTemplate($var,$session->setting->get("moduleViewTemplateId"));
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue