Merged the "Invite a Friend" application into the Account system and cleaned up the templates in the Inbox

This commit is contained in:
Frank Dillon 2008-11-18 04:52:16 +00:00
parent e7469531cf
commit d91bc5754d
13 changed files with 532 additions and 213 deletions

View file

@ -9,11 +9,12 @@ save you many hours of grief.
7.6.4
--------------------------------------------------------------------
* The user facing portions of WebGUI's profile, inbox, and friends systems
have been completely updated. No data will be lost but all templates
including custom templates that are related to these systems will be deleted
on upgrade. Please make sure you export your custom templates prior to
upgrading as you will need to modify them for the new system.
* The user facing portions of WebGUI's profile, inbox, friends, and "invite
a friend" systems have been completely updated. No data will be lost
but all templates including custom templates that are related to these
systems will be deleted on upgrade. Please make sure you export your
custom templates prior to upgrading as you will need to modify them for
the new system.
* The Survey system has been completely updated. Please make sure you
create full backups of your survey results and export them as needed.

View file

@ -393,7 +393,7 @@ sub upgradeAccount {
#Add the settings for the inbox module
$setting->add("inboxStyleTemplateId",""); #Use the userStyle by default
$setting->add("inboxLayoutTempalteId","N716tpSna0iIQTKxS4gTWA");
$setting->add("inboxLayoutTempalteId","gfZOwaTWYjbSoVaQtHBBEw");
$setting->add("inboxViewTemplateId","c8xrwVuu5QE0XtF9DiVzLw");
$setting->add("inboxViewMessageTemplateId","0n4HtbXaWa_XJHkFjetnLQ");
$setting->add("inboxSendMessageTemplateId","6uQEULvXFgCYlRWnYzZsuA");
@ -403,7 +403,16 @@ sub upgradeAccount {
$setting->add("inboxManageInvitationsTemplateId","1Q4Je3hKCJzeo0ZBB5YB8g");
$setting->add("inboxViewInvitationTemplateId","VBkY05f-E3WJS50WpdKd1Q");
$setting->add("inboxInvitationConfirmTemplateId","5A8Hd9zXvByTDy4x-H28qw");
#Inbox Invitations
$setting->add("inboxInviteUserEnabled",$session->setting->get("userInvitationsEnabled"));
$setting->add("inboxInviteUserRestrictSubject","0");
$setting->add("inboxInviteUserSubject","^International(invite subject,Account_Inbox,^u;);");
$setting->add("inboxInviteUserRestrictMessage","0");
$setting->add("inboxInviteUserMessage","^International(invite message,Account_Inbox);");
$setting->add("inboxInviteUserMessageTemplateId","XgcsoDrbC0duVla7N7JAdw");
$setting->add("inboxInviteUserTemplateId","cR0UFm7I1qUI2Wbpj--08Q");
$setting->add("inboxInviteUserConfirmTemplateId","SVIhz68689hwUGgcDM-gWw");
#Add the settings for the friends module
$setting->add("friendsStyleTemplateId",""); #Use the userStyle by default
$setting->add("friendsLayoutTempalteId","N716tpSna0iIQTKxS4gTWA");
@ -422,6 +431,7 @@ sub upgradeAccount {
$setting->add("shopStyleTemplateId",""); #Use the userStyle by default
$setting->add("shopLayoutTemplateId","aUDsJ-vB9RgP-AYvPOy8FQ");
#Add inbox changes
$session->db->write(q{
create table inbox_messageState (
@ -489,20 +499,25 @@ sub upgradeAccount {
$session->db->write(q{REPLACE INTO `userProfileField` VALUES ('publicProfile','WebGUI::International::get(861)',1,0,'RadioList','{ all=>WebGUI::International::get(\'public label\',\'Account_Profile\'), friends=>WebGUI::International::get(\'friends only label\',\'Account_Profile\'), none=>WebGUI::International::get(\'private label\',\'Account_Profile\')}','[\"none\"]',8,'4',1,1,0,0,0,'')});
#Clean up old templates and settings
my $oldtemplates = {
editUserProfileTemplate => 'Operation/Profile/Edit',
viewUserProfileTemplate => 'Operation/Profile/View',
manageFriendsTemplateId => 'friends/manage',
sendPrivateMessageTemplateId => 'Inbox/SendPrivateMessage',
viewInboxTemplateId => 'Inbox',
viewInboxMessageTemplateId => 'Inbox/Message',
my $oldsettings = {
editUserProfileTemplate => 'Operation/Profile/Edit',
viewUserProfileTemplate => 'Operation/Profile/View',
manageFriendsTemplateId => 'friends/manage',
sendPrivateMessageTemplateId => 'Inbox/SendPrivateMessage',
viewInboxTemplateId => 'Inbox',
viewInboxMessageTemplateId => 'Inbox/Message',
userInvitationsEmailTemplateId => 'userInvite/Email',
userInvitationsEnabled => 'userInvite',
userInvitationsEmailExists => '',
};
foreach my $setting (keys %{$oldtemplates}) {
foreach my $setting (keys %{$oldsettings}) {
#Remove the setting
$session->db->write("delete from settings where name=?",[$setting]);
$session->setting->remove($setting);
#$session->db->write("delete from settings where name=?",[$setting]);
#Remove all the templates with the related namespace
my $assets = $session->db->buildArrayRef("select distinct assetId from template where namespace=?",[$oldtemplates->{$setting}]);
next if ($oldsettings->{$setting} eq "");
my $assets = $session->db->buildArrayRef("select distinct assetId from template where namespace=?",[$oldsettings->{$setting}]);
#Purge the template
foreach my $assetId (@{$assets}) {
WebGUI::Asset->newByDynamicClass($session,$assetId)->purge;

View file

@ -77,13 +77,6 @@ sub appendAccountLinks {
});
}
#Pluggin - delete eventually
if ($session->setting->get('userInvitationsEnabled')) {
push @array, {
'options.display' => sprintf('<a href=%s>%s</a>', $session->url->page('op=inviteUser'), $i18n->get('invite a friend')),
};
}
#Logout
$var->{'logout_url' } = $session->url->page('op=auth;method=logout');
$var->{'logout_text'} = $i18n->get(64);

View file

@ -50,15 +50,21 @@ sub appendCommonVars {
my $var = shift;
my $inbox = shift || WebGUI::Inbox->new($session);
my $user = $session->user;
my $method = $self->method;
$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');
$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');
$var->{'user_invitations_enabled'} = $session->setting->get("inboxInviteUserEnabled");
$var->{'invite_friend_url' } = $self->getUrl("module=inbox;do=inviteUser");
my $tab = $self->store->{tab};
$var->{'is_tab_'.$tab} = "true";
}
#-------------------------------------------------------------------
@ -158,8 +164,60 @@ sub editSettingsForm {
namespace => "Account/Inbox/Confirm",
label => $i18n->get("invitation confirm message template label"),
hoverHelp => $i18n->get("invitation confirm message template hoverHelp")
);
);
$f->yesNo(
name => "inboxInviteUserEnabled",
value => $setting->get("inboxInviteUserEnabled"),
label => $i18n->get("invite user enabled template label"),
hoverHelp => $i18n->get("invite user enabled template hoverHelp")
);
$f->yesNo(
name => "inboxInviteUserRestrictSubject",
value => $setting->get("inboxInviteUserRestrictSubject"),
label => $i18n->get("invite user restrict subject template label"),
hoverHelp => $i18n->get("invite user restrict subject template hoverHelp")
);
$f->text(
name => "inboxInviteUserSubject",
value => $setting->get("inboxInviteUserSubject"),
label => $i18n->get("invite user subject template label"),
hoverHelp => $i18n->get("invite user subject template hoverHelp")
);
$f->yesNo(
name => "inboxInviteUserRestrictMessage",
value => $setting->get("inboxInviteUserRestrictMessage"),
label => $i18n->get("invite user restrict message template label"),
hoverHelp => $i18n->get("invite user restrict message template hoverHelp")
);
$f->textarea(
name => "inboxInviteUserMessage",
value => $setting->get("inboxInviteUserMessage"),
height => 300,
label => $i18n->get("invite user message label"),
hoverHelp => $i18n->get("invite user message hoverHelp")
);
$f->template(
name => "inboxInviteUserMessageTemplateId",
value => $self->getInviteUserMessageTempalteId,
namespace => "Account/Inbox/InviteUserMessage",
label => $i18n->get("invite user message template label"),
hoverHelp => $i18n->get("invite user message template hoverHelp")
);
$f->template(
name => "inboxInviteUserTemplateId",
value => $self->getInviteUserTemplateId,
namespace => "Account/Inbox/InviteUser",
label => $i18n->get("invite user template label"),
hoverHelp => $i18n->get("invite user template hoverHelp")
);
$f->template(
name => "inboxInviteUserConfirmTemplateId",
value => $self->getInviteUserConfirmTemplateId,
namespace => "Account/Inbox/InviteUserConfirm",
label => $i18n->get("invite user confirm template label"),
hoverHelp => $i18n->get("invite user confirm template hoverHelp")
);
return $f->printRowsOnly;
}
@ -181,16 +239,27 @@ sub editSettingsFormSave {
$setting->set("inboxStyleTemplateId", $form->process("inboxStyleTemplateId","template"));
$setting->set("inboxLayoutTempalteId", $form->process("inboxLayoutTempalteId","template"));
$setting->set("inboxViewTemplateId", $form->process("inboxViewTemplateId","template"));
$session->set("inboxViewMessageTemplateId",$form->process("inboxViewMessageTemplateId","template"));
$session->set("inboxSendMessageTemplateId",$form->process("inboxSendMessageTemplateId","template"));
$session->set("inboxMessageConfirmationTemplateId",$form->process("inboxMessageConfirmationTemplateId","template"));
$session->set("inboxErrorTemplateId",$form->process("inboxErrorTemplateId","template"));
#Invitations Settings
$session->set("inboxManageInvitationsTemplateId",$form->process("inboxManageInvitationsTemplateId","template"));
$session->set("inboxViewInvitationTemplateId",$form->process("inboxViewInvitationTemplateId","template"));
$session->set("inboxInvitationConfirmTemplateId",$form->process("inboxInvitationConfirmTemplateId","template"));
$setting->set("inboxViewMessageTemplateId",$form->process("inboxViewMessageTemplateId","template"));
$setting->set("inboxSendMessageTemplateId",$form->process("inboxSendMessageTemplateId","template"));
$setting->set("inboxMessageConfirmationTemplateId",$form->process("inboxMessageConfirmationTemplateId","template"));
$setting->set("inboxErrorTemplateId",$form->process("inboxErrorTemplateId","template"));
#Friends Invitations Settings
$setting->set("inboxManageInvitationsTemplateId",$form->process("inboxManageInvitationsTemplateId","template"));
$setting->set("inboxViewInvitationTemplateId",$form->process("inboxViewInvitationTemplateId","template"));
$setting->set("inboxInvitationConfirmTemplateId",$form->process("inboxInvitationConfirmTemplateId","template"));
#User Invitation Settings
$setting->set("inboxInviteUserEnabled",$form->process("inboxInviteUserEnabled","yesNo"));
$setting->set("inboxInviteUserRestrictSubject",$form->process("inboxInviteUserRestrictSubject","yesNo"));
$setting->set("inboxInviteUserSubject",$form->process("inboxInviteUserSubject","text"));
$setting->set("inboxInviteUserRestrictMessage",$form->process("inboxInviteUserRestrictMessage","yesNo"));
$setting->set("inboxInviteUserMessage",$form->process("inboxInviteUserMessage","HTMLArea"));
$setting->set("inboxInviteUserMessageTemplateId",$form->process("inboxInviteUserMessageTemplateId","template"));
$setting->set("inboxInviteUserTemplateId",$form->process("inboxInviteUserTemplateId","template"));
$setting->set("inboxInviteUserConfirmTemplateId",$form->process("inboxInviteUserConfirmTemplateId","template"));
}
#-------------------------------------------------------------------
=head2 getInboxErrorTemplateId ( )
@ -234,6 +303,44 @@ sub getInvitationConfirmTemplateId {
return $self->session->setting->get("inboxInvitationConfirmTemplateId") || "5A8Hd9zXvByTDy4x-H28qw";
}
#-------------------------------------------------------------------
=head2 getInviteUserMessageTempalteId ( )
This method returns the template ID for the user email message
=cut
sub getInviteUserMessageTempalteId {
my $self = shift;
return $self->session->setting->get("inboxInviteUserMessageTemplateId") || "XgcsoDrbC0duVla7N7JAdw";
}
#-------------------------------------------------------------------
=head2 getInviteUserTemplateId ( )
This method returns the template ID for the main invite user screen.
=cut
sub getInviteUserTemplateId {
my $self = shift;
return $self->session->setting->get("inboxInviteUserTemplateId") || "cR0UFm7I1qUI2Wbpj--08Q";
}
#-------------------------------------------------------------------
=head2 getInviteUserConfirmTemplateId ( )
This method returns the template ID for invitation errors.
=cut
sub getInviteUserConfirmTemplateId {
my $self = shift;
return $self->session->setting->get("inboxInviteUserConfirmTemplateId") || "SVIhz68689hwUGgcDM-gWw";
}
#-------------------------------------------------------------------
@ -245,7 +352,7 @@ This method returns the template ID for the account layout.
sub getLayoutTemplateId {
my $self = shift;
return $self->session->setting->get("inboxLayoutTempalteId") || $self->SUPER::getLayoutTemplateId;
return $self->session->setting->get("inboxLayoutTempalteId") || "gfZOwaTWYjbSoVaQtHBBEw";
}
@ -399,6 +506,8 @@ sub www_approveDenyInvitations {
my $approve = $form->get("accept");
my $deny = $form->get("deny");
$self->store->{tab} = "invitations";
my $friends = WebGUI::Friends->new($session);
my @users = ();
@ -445,6 +554,8 @@ sub www_deleteMessage {
my $messageId = $session->form->get("messageId");
my $inbox = WebGUI::Inbox->new($session);
my $message = $inbox->getMessage($messageId);
$self->store->{tab} = "inbox";
if (!(defined $message) || !$inbox->canRead($message)) {
#View will handle displaying these errors
@ -479,6 +590,8 @@ sub www_deleteMessages {
my $self = shift;
my $session = $self->session;
$self->store->{tab} = "inbox";
my @messages = $session->form->process("message","checkList");
foreach my $messageId (@messages) {
@ -491,6 +604,182 @@ sub www_deleteMessages {
#-------------------------------------------------------------------
=head2 www_inviteUser ( )
Form for inviting a user to join the site.
=cut
sub www_inviteUser {
my $self = shift;
my $session = $self->session;
my $form = $session->form;
my $setting = $session->setting;
my $user = $session->user;
my $displayError = shift;
my $var = {};
#Let the tab display that they are currently on
$self->store->{tab} = "invitations";
#Add any error passed in to be displayed if the form reloads
$var->{'message_display_error'} = $displayError;
#Message From
$var->{'message_from' } = $user->getWholeName;
$var->{'message_from_id' } = $user->userId;
#Message To
$var->{'form_to' } = WebGUI::Form::email($session, {
name => "to",
value => $session->form->get('to'),
});
#Message Subject
my $defaultSubject = $setting->get("inboxInviteUserSubject");
WebGUI::Macro::process($session,\$defaultSubject);
my $subject = $form->get('subject') || $defaultSubject;
$var->{'subject_allowed'} = !($setting->get("inboxInviteUserRestrictSubject"));
if($var->{'subject_allowed'}) {
$var->{'form_subject' } = WebGUI::Form::text($session, {
name => "subject",
value => $subject,
extras => q{ class="invite_subject" }
});
}
else {
$var->{'form_subject' } = $subject;
}
#Message Body
my $defaultMessage = $setting->get("inboxInviteUserMessage");
WebGUI::Macro::process($session,\$defaultMessage);
my $message = $form->get('message') || $defaultMessage;
$var->{'message_allowed' } = !($setting->get("inboxInviteUserRestrictMessage"));
if($var->{'message_allowed'}) {
$var->{'form_message_text'} = WebGUI::Form::textarea($session, {
name =>"message",
value =>$message,
width =>600,
height =>200
});
$var->{'form_message_rich'} = WebGUI::Form::HTMLArea($session, {
name => "message",
value => $message,
width => "600",
});
}
else {
$var->{'form_message_text'} = $message;
$var->{'form_message_rich'} = $message;
}
$var->{'form_header' } = WebGUI::Form::formHeader($session,{
action => $self->getUrl("module=inbox;do=inviteUserSave"),
extras => q{name="inviteForm"}
});
$var->{'submit_button' } = WebGUI::Form::submit($session,{});
$var->{'form_footer' } = WebGUI::Form::formFooter($session, {});
$var->{'back_url' } = $session->env->get("HTTP_REFERER") || $var->{'view_inbox_url'};
#Add common template variable for displaying the inbox
$self->appendCommonVars($var);
return $self->processTemplate($var,$self->getInviteUserTemplateId);
}
#-------------------------------------------------------------------
=head2 www_inviteUserSave ( )
Post process the form, check for required fields, handle inviting users who are already
members (determined by email address) and send the email.
=cut
sub www_inviteUserSave {
my $self = shift;
my $session = $self->session;
my $form = $session->form;
my $setting = $session->setting;
my $user = $session->user;
my $i18n = WebGUI::International->new($session,"Account_Inbox");
#Must have a person to send email to
my $to = $form->get('to');
return $self->www_inviteUser($i18n->get('missing email')) unless $to;
#Must have a subject
my $defaultSubject = $setting->get("inboxInviteUserSubject");
WebGUI::Macro::process($session,\$defaultSubject);
my $subject = ($setting->get("inboxInviteUserRestrictSubject"))
? $defaultSubject
: $form->get('subject')
;
return $self->www_inviteUser($i18n->get('missing subject')) unless $subject;
#Must have a message
my $defaultMessage = $setting->get("inboxInviteUserMessage");
WebGUI::Macro::process($session,\$defaultMessage);
my $message = ($setting->get("inboxInviteUserRestrictMessage"))
? $defaultMessage
: $form->get("message")
;
return $self->www_inviteUser($i18n->get('missing message')) unless $message;
#User existance check.
my $existingUser = WebGUI::User->newByEmail($session,$to);
if (defined $existingUser) {
my $existingProfile = $existingUser->getProfileUrl;
my $existingUser = $existingUser->username;
my $errorMsg = sprintf($i18n->get('already a member'),$existingProfile,$existingUser);
return $self->www_inviteUser($errorMsg);
}
#Profile Email address check
my $email = $session->user->profileField('email');
unless ($email) {
return $self->www_inviteUser($i18n->get('no email'));
}
my $var = {};
##No sneaky attack paths...
$var->{'message'} = WebGUI::HTML::html2text(WebGUI::HTML::filter($message));
##Create the invitation url.
my $inviteId = $session->id->generate();
$var->{'url'} = $session->url->append(
$session->url->getSiteURL,'op=auth;method=createAccount;code='.$inviteId
);
my $emailBody = $self->processTemplate($var,$self->getInviteUserMessageTempalteId);
##Create the invitation record.
my $hash = {
userId => $user->userId,
dateSent => WebGUI::DateTime->new($session, time)->toMysqlDate,
email => $to,
};
$session->db->setRow('userInvitations','inviteId',$hash,$inviteId);
my $invitation = WebGUI::Mail::Send->create($session, {
to => $to,
from => $email,
subject => $subject,
});
$invitation->addText($emailBody);
$invitation->send;
$var = {};
$self->appendCommonVars($var);
return $self->processTemplate($var,$self->getInviteUserConfirmTemplateId);
}
#-------------------------------------------------------------------
=head2 www_manageInvitations ( )
The page on which users can manage their friends requests
@ -503,6 +792,8 @@ sub www_manageInvitations {
my $user = $session->user;
my $var = {};
my $i18n = WebGUI::International->new($session,'Account_Inbox');
$self->store->{tab} = "invitations";
#Deal with rows per page
my $rpp = $session->form->get("rpp") || 25;
@ -548,10 +839,10 @@ sub www_manageInvitations {
$var->{'has_messages' } = $msgCount > 0;
$var->{'message_total' } = $msgCount;
$var->{'form_start' } = WebGUI::Form::formHeader($session,{
$var->{'form_header' } = WebGUI::Form::formHeader($session,{
action => $self->getUrl("module=inbox;do=approveDenyInvitations")
});
$var->{'form_end' } = WebGUI::Form::formFooter($session);
$var->{'form_footer' } = WebGUI::Form::formFooter($session);
$var->{'form_accept' } = WebGUI::Form::submit($session,{
name =>"accept",
@ -597,6 +888,8 @@ sub www_sendMessage {
my $toUser = undef;
my $var = {};
$self->store->{tab} = "inbox";
#Add any error passed in to be displayed if the form reloads
$var->{'message_display_error'} = $displayError;
@ -775,6 +1068,8 @@ sub www_sendMessageSave {
my $errorMsg = "";
my @toUsers = ();
$self->store->{tab} = "inbox";
#Add common template variable for displaying the inbox
my $inbox = WebGUI::Inbox->new($session);
@ -864,6 +1159,8 @@ sub www_view {
my $session = $self->session;
my $user = $session->user;
my $var = {};
$self->store->{tab} = "inbox";
#Deal with sort order
my $sortBy = $session->form->get("sortBy") || undef;
@ -931,11 +1228,6 @@ sub www_view {
$var->{'new_message_url' } = $self->getUrl("module=inbox;do=sendMessage");
$var->{'canSendMessages' } = $user->hasFriends;
$var->{'inbox_form_start' } = WebGUI::Form::formHeader($session,{
action => $self->getUrl("module=inbox;do=deleteMessages")
});
$var->{'inbox_form_end' } = WebGUI::Form::formFooter($session);
tie my %rpps, "Tie::IxHash";
%rpps = (25 => "25", 50 => "50", 100=>"100");
$var->{'message_rpp' } = WebGUI::Form::selectBox($session,{
@ -945,7 +1237,12 @@ sub www_view {
extras => q{onchange="location.href='}.$var->{'rpp_url'}.q{;rpp='+this.options[this.selectedIndex].value"}
});
#Append common vars
$var->{'form_header'} = WebGUI::Form::formHeader($session,{
action => $self->getUrl("module=inbox;do=deleteMessages")
});
$var->{'form_footer'} = WebGUI::Form::formFooter($session);
#Append common vars - form headers set in here
$self->appendCommonVars($var,$inbox);
#Append pagination vars
$p->appendTemplateVars($var);
@ -970,6 +1267,7 @@ sub www_viewInvitation {
my $errorMsg = shift;
my $i18n = WebGUI::International->new($session,'Account_Inbox');
$self->store->{tab} = "invitations";
my $friends = WebGUI::Friends->new($session);
my $invitation = $friends->getAddRequest($inviteId);
@ -1062,6 +1360,8 @@ sub www_viewMessage {
my $messageId = shift || $session->form->get("messageId");
my $errorMsg = shift;
$self->store->{tab} = "inbox";
my $inbox = WebGUI::Inbox->new($session);
my $message = $inbox->getMessage($messageId);

View file

@ -30,6 +30,7 @@ use WebGUI::Operation::Shared;
use WebGUI::Operation::Profile;
use WebGUI::Workflow::Instance;
use WebGUI::Inbox;
use WebGUI::Friends;
# Profile field name for the number of times the showMessageOnLogin has been
# seen.
@ -194,7 +195,7 @@ sub createAccount {
;
# User Defined Options
my $userInvitation = $self->session->setting->get('userInvitationsEnabled');
my $userInvitation = $self->session->setting->get('inboxInviteUserEnabled');
$vars->{'create.form.profile'} = [];
foreach my $field (@{WebGUI::ProfileField->getRegistrationFields($self->session)}) {
my $id = $field->getId;
@ -321,15 +322,20 @@ sub createAccountSave {
##Finalize the record in the user invitation table.
my $inviteId = $self->session->form->get('uniqueUserInvitationCode');
if ($inviteId) {
$self->session->db->setRow(
'userInvitations',
'inviteId',
{
inviteId => $inviteId,
newUserId => $u->userId,
dateCreated => WebGUI::DateTime->new($self->session, time)->toMysqlDate,
},
);
$self->session->db->setRow('userInvitations','inviteId',{
inviteId => $inviteId,
newUserId => $u->userId,
dateCreated => WebGUI::DateTime->new($self->session, time)->toMysqlDate,
});
#Get the invite record
my $inviteRecord = $self->session->db->getRow('userInvitations','inviteId',$inviteId);
#Get the user
my $inviteUser = WebGUI::User->new($self->session,$inviteRecord->{userId});
#Automatically add the friend that invited the user and vice versa if the friend has friends enabled
if($inviteUser->acceptsFriendsRequests($u)) {
my $friends = WebGUI::Friends->new($self->session,$u);
$friends->add([$inviteUser->userId]);
}
}
# If we have something to do after login, do it

View file

@ -224,7 +224,7 @@ sub createAccount {
if ($self->session->user->isRegistered) {
return $self->displayAccount;
}
elsif (!$self->session->setting->get("anonymousRegistration") && !$self->session->setting->get('userInvitationsEnabled')) {
elsif (!$self->session->setting->get("anonymousRegistration") && !$self->session->setting->get('inboxInviteUserEnabled')) {
return $self->displayLogin;
}

View file

@ -144,7 +144,7 @@ sub createAccount {
if ($self->session->user->isRegistered) {
return $self->displayAccount;
}
elsif (!$setting->get("anonymousRegistration") && !$setting->get('userInvitationsEnabled')) {
elsif (!$setting->get("anonymousRegistration") && !$setting->get('inboxInviteUserEnabled')) {
return $self->displayLogin;
}
@ -212,7 +212,7 @@ sub createAccountSave {
return $self->displayAccount if ($session->user->isRegistered);
# Make sure anonymous registration is enabled
if (!$setting->get("anonymousRegistration") && !$setting->get("userInvitationsEnabled")) {
if (!$setting->get("anonymousRegistration") && !$setting->get("inboxInviteUserEnabled")) {
$session->errorHandler->security($i18n->get("no registration hack", "AuthWebGUI"));
return $self->displayLogin;
}

View file

@ -137,7 +137,6 @@ sub getOperations {
'sendPrivateMessage' => 'Inbox',
'inviteUser' => 'Invite',
'inviteUserSave' => 'Invite',
'acceptInvite' => 'Invite',
'addFriend' => 'Friends',

View file

@ -23,7 +23,8 @@ Package WebGUI::Operation::Invite
=head1 DESCRIPTION
Operation handler for handling user invitations.
DEPRECATED - This module is deprecated and should not be used in any new code.
Use WebGUI::Account::Inbox instead.
=cut
@ -31,159 +32,28 @@ Operation handler for handling user invitations.
=head2 www_inviteUser ( )
Form for inviting a user.
DEPRECATED - This method is deprecated and should not be used in any new code.
Use WebGUI::Account::Inbox::inviteUser instead.
=cut
sub www_inviteUser {
my $session = shift;
return $session->privilege->insufficient() unless ($session->user->isRegistered);
my $formError = shift;
my $vars = {};
my $i18n = WebGUI::International->new($session, 'Invite');
$vars->{inviteFormError} = $i18n->get($formError);
$vars->{formHeader} = WebGUI::Form::formHeader($session).WebGUI::Form::hidden($session, {name => "op", value => "inviteUserSave"});
$vars->{formFooter} = WebGUI::Form::formFooter($session, {});
$vars->{title} = $i18n->get('invite a friend title');
$vars->{emailAddressLabel} = $i18n->get('480', 'WebGUI');
$vars->{emailAddressForm} = WebGUI::Form::email(
$session,
{
name => "invite_email",
value => $session->form->get('invite_email'),
},
);
$vars->{subjectLabel} = $i18n->get('229', 'WebGUI');
$vars->{subjectForm} = WebGUI::Form::text(
$session,
{
name => "invite_subject",
value => $session->form->get('invite_subject'),
},
);
$vars->{messageLabel} = $i18n->get('351', 'WebGUI');
$vars->{messageForm} = WebGUI::Form::textarea(
$session,
{
name => "invite_message",
value => $session->form->get('invite_message') || $i18n->get('default invite'),
},
);
$vars->{submitButton} = WebGUI::Form::submit(
$session,
{value => $i18n->get('submit', 'WebGUI')},
);
my $output = WebGUI::Asset::Template->new($session,"PBtmpl00000userInvite1")->process($vars);
return $session->style->userStyle($output);
}
#-------------------------------------------------------------------
=head2 www_inviteUserSave ( )
Post process the form, check for required fields, handle inviting users who are already
members (determined by email address) and send the email.
=cut
sub www_inviteUserSave {
my $session = shift;
return $session->privilege->insufficient() unless ($session->user->isRegistered);
#Mandatory field checks
my $hisEmailAddress = $session->form->get('invite_email');
return www_inviteUser($session, 'missing email') unless $hisEmailAddress;
my $message = $session->form->get('invite_message');
return www_inviteUser($session, 'missing message') unless $message;
my $subject = $session->form->get('invite_subject');
return www_inviteUser($session, 'missing subject') unless $subject;
my $i18n = WebGUI::International->new($session, 'Invite');
#User existance check.
my $existingUser = WebGUI::User->newByEmail($session, $hisEmailAddress);
if (defined $existingUser) {
my $output = sprintf qq!<h1>%s</h1>\n<p>%s</p><a href="%s">%s</a>!,
$i18n->get('already a member'),
$session->setting->get('userInvitationsEmailExists'),
$session->url->getBackToSiteURL(),
$i18n->get('493', 'WebGUI');
return $session->style->userStyle($output);
}
my $myEmailAddress = $session->user->profileField('email');
my $invitation = WebGUI::Mail::Send->create(
$session,
{
to => $hisEmailAddress,
from => $myEmailAddress,
subject => $subject,
},
);
##No sneaky attack paths...
$message = WebGUI::HTML::html2text(WebGUI::HTML::filter($message));
##Create the invitation url.
my $inviteId = $session->id->generate();
my $inviteUrl = $session->url->append($session->url->getSiteURL, 'op=acceptInvite;code='.$inviteId);
my $var;
$var->{registrationUrl} = $inviteUrl;
$var->{invitationMessage} = $message;
my $emailTemplate = WebGUI::Asset::Template->new($session, $session->setting->get('userInvitationsEmailTemplateId'));
my $templatedEmail = $emailTemplate->process($var);
##Create the invitation record.
$session->db->setRow(
'userInvitations',
'inviteId',
{
userId => $session->user->userId,
dateSent => WebGUI::DateTime->new($session, time)->toMysqlDate,
email => $hisEmailAddress,
},
$inviteId,
);
$invitation->addText($templatedEmail);
$invitation->send;
my $output = sprintf qq!<p>%s</p><a href="%s">%s</a>!,
$i18n->get('invitation sent'),
$session->url->getBackToSiteURL(),
$i18n->get('493', 'WebGUI');
return $session->style->userStyle($output);
my $instance = WebGUI::Content::Account->createInstance($session,"inbox");
return $instance->displayContent($instance->callMethod("inviteUser"));
}
#-------------------------------------------------------------------
=head2 www_acceptInvite ( )
Validate the invitation code. If valid, send the user over to the
create account page. Otherwise, scourge and flay them.
DEPRECATED - This method is deprecated and should not be used by any new code.
=cut
sub www_acceptInvite {
my $session = shift;
return $session->privilege->insufficient() if ($session->user->isRegistered);
my $i18n = WebGUI::International->new($session, 'Invite');
my $inviteId = $session->form->get('code');
my ($validInviteId) = $session->db->quickArray('select userId from userInvitations where inviteId=?',[$inviteId]);
if (!$validInviteId) {
my $output = sprintf qq!<h1>%s</h1>\n<p>%s</p><a href="%s">%s</a>!,
$i18n->get('invalid invite code'),
$i18n->get('invalid invite code message'),
$session->url->getBackToSiteURL(),
$i18n->get('493', 'WebGUI');
return $session->style->userStyle($output);
}
##Everything looks good. Sign them up!
##Send them right to auth.
my $auth = WebGUI::Operation::Auth::getInstance($session);
return $session->style->userStyle($auth->createAccount());
}

View file

@ -99,6 +99,87 @@ our $I18N = {
lastUpdated => 1119068809
},
'invite user enabled template label' => {
message => q|Enable user invitations?|,
lastUpdated => 1119068809
},
'invite user enabled template hoverHelp' => {
message => q|Enable users to send emails to their friends, inviting them to come and create an account on this site.|,
lastUpdated => 1119068809
},
'invite user restrict subject template label' => {
message => q|Restrict Invitation Subject?|,
lastUpdated => 1119068809
},
'invite user restrict subject template hoverHelp' => {
message => q|If this setting is 'yes', users will not be able to modify the default subject of the invitation|,
lastUpdated => 1119068809
},
'invite user subject template label' => {
message => q|Default Invitation Subject|,
lastUpdated => 1119068809
},
'invite user subject template hoverHelp' => {
message => q|Enter the default text for the subject of user invitations. Macros will be processed on this field (macros will not be processed on the actual subject sent)|,
lastUpdated => 1119068809
},
'invite user restrict message template label' => {
message => q|Restrict Invitation Message?|,
lastUpdated => 1119068809
},
'invite user restrict message template hoverHelp' => {
message => q|If this setting is 'yes', users will not be able to modify the default message of the invitation|,
lastUpdated => 1119068809
},
'invite user message label' => {
message => q|Default Invitation Message|,
lastUpdated => 1119068809
},
'invite user message hoverHelp' => {
message => q|Enter the default text for the message of user invitations. Macros will be processed on this field (macros will not be processed on the actual message sent)|,
lastUpdated => 1119068809
},
'invite user message template label' => {
message => q|Invitation Email Template|,
lastUpdated => 1119068809
},
'invite user message template hoverHelp' => {
message => q|Choose the template for the email that will be sent as the user invitation. This will include the text of the message as well as the registration link and any headers or footers you choose to add to the message.|,
lastUpdated => 1119068809
},
'invite user template label' => {
message => q|Invite User Send Tempalte|,
lastUpdated => 1119068809
},
'invite user template hoverHelp' => {
message => q|Choose the template for viewing the main user invitation screen|,
lastUpdated => 1119068809
},
'invite user confirm template label' => {
message => q|Invite User Confirmation Template|,
lastUpdated => 1119068809
},
'invite user confirm template hoverHelp' => {
message => q|Choose the template for viewing user invitation confirmations|,
lastUpdated => 1119068809
},
'subject label' => {
message => q|Subject|,
lastUpdated => 1119068809
@ -353,7 +434,56 @@ our $I18N = {
message => q{The user who sent this invitation is no longer a member of the site.},
lastUpdated => 1119068809
},
'invite a friend' => {
message => q{invite a friend to join this website},
lastUpdated => 1119068809
},
'invite subject' => {
message => q{An invitation to join %s},
lastUpdated => 1119068809
},
'invite message' => {
message => q{I'm a member of a site that I thought you would find very useful, so I'm sending this invitation hoping you'll join me here. Click on the link below to register.},
lastUpdated => 1119068809,
},
'missing email' => {
message => q|The invitation cannot be sent because you did not enter an email address.|,
lastUpdated => 1181409056,
},
'missing message' => {
message => q|Your invitiation must have a message.|,
lastUpdated => 1181409432,
},
'missing subject' => {
message => q|Your invitation must have a subject.|,
lastUpdated => 1181409433,
},
'already a member' => {
message => q|The email address you entered is already regiestered to <a href="%s">%s</a> on this site.|,
lastUpdated => 1181410226,
},
'no email' => {
message => q{The invitation cannot be sent because you do not have an email address set in your profile.},
lastUpdated => 1119068809,
},
'invitation sent label' => {
message => q|Invitation Sent|,
lastUpdated => 1181410226,
},
'invitation sent text' => {
message => q|Your invitation has been sent successfully.|,
lastUpdated => 1181410226,
},
};

View file

@ -3232,10 +3232,6 @@ and tracked by WebGUI.|,
lastUpdated => 1163457062,
},
'Enable user invitations description' => {
message => q|Enable users to send emails to their friends, inviting them to come and create an account on this site.|,
lastUpdated => 1181017746,
},
'164 description' => {
message => q|<p>Set the default authentication method for new accounts. The two available options by default are WebGUI and LDAP. WebGUI authentication means that the users will authenticate against the username and password stored in the WebGUI database. LDAP authentication means that users will authenticate against an external LDAP server. Other methods can be provided by writing a custom authentication plug-in.</p>
@ -3259,11 +3255,6 @@ a user.|,
lastUpdated => 1167189802,
},
'Enable user invitations' => {
message => q|Enable user invitations?|,
lastUpdated => 1181017730
},
'Illegal Warning' => {
message => q|Enabling this feature is illegal in some countries, like Australia. In addition, some countries require you to add a warning to your site if you use this feature. Consult your local authorities for local laws. Plain Black Corporation is not responsible for your illegal activities, regardless of ignorance or malice.|,
lastUpdated => 1089039511

View file

@ -27,13 +27,27 @@
height: 300px;
border: solid #BECEF8 1px;
margin-left: 50px;
margin-bottom: 20px;
margin-bottom: 10px;
overflow:-moz-scrollbars-vertical;
overflow-x:hidden;
overflow-y:scroll;
background-color: white;
text-align: left;
}
.userInvite_subject {
width: 500px;
height: 25px;
border: solid #BECEF8 1px;
/*margin-left: 50px;*/
/*margin-bottom: 20px;*/
/*overflow:-moz-scrollbars-vertical;
overflow-x:hidden;
overflow-y:scroll;*/
background-color: white;
text-align: left;
}
.profileMember {
text-align:right;
margin-right:20px;
@ -215,7 +229,7 @@
.editBox {
font-size:9px;
font-weight:bold;
background:white url(images/edit_box_bg.jpg) no-repeat bottom left;
/*background:white url(images/edit_box_bg.jpg) no-repeat bottom left;*/
border:solid #8DABF1 2px;
padding:5px;
width:590px;