This patch adds user invitations, a way for existing users on a site

to send an email to their friends and invite them to create an account
on the site.  The feature is enabled or disabled in the site Settings.
(Operation/Settings.pm)

It is implemented as a new operation, Invite (Operation/Invite.pm,
Help/Invite.pm, i18n/English/Invite.pm), and the option is displayed
as an option on the user's account screen. (Operation/Shared.pm).
The form is templated, and lives in the Invite namespace.  Once
the invitation is submitted, if the user's email address is not
already in WebGUI, an email is sent and a record is stored in
the userInvitations table.

When the friend gets the invitation, they are taken to the account
creation screen, which conveniently has their email address already
filled in.  This required changes in the Auth modules (Auth.pm, Auth/*.pm),
and ProfileField.pm.  The latter was so that profile fields can have
their values manually set.  The former changes handle inserting the
email address, bypassing the anonymous registration check, and
updating the record in ther userInvitations table.

I refactored some code out of the AdminConsole for finding the url
back to the site and added it to Session/Url.pm.  The method is
called getBackToSiteUrl.
This commit is contained in:
Colin Kuskie 2007-06-10 16:38:43 +00:00
parent 32f7866f3b
commit 21c4fcb75f
18 changed files with 586 additions and 28 deletions

View file

@ -10,6 +10,7 @@
- add: User profile data table is now a flat table, one column for each
field.
- add: Posts can now have Metadata (United Knowledge)
- add: Users can now invite others to create an account (United Knowledge)
- add: Calendar events now allow attachments
- add: Calendar events now allow setting view permissions
- add: WebGUI::Paginator now capable of more efficient SQL paginations using

View file

@ -0,0 +1,47 @@
#PBtmpl00000userInvite1
#url: userInviteTemplate
#title:User Invite Template
#menuTitle:Default User Invite Template
#namespace:userInvite
#create
<h1><tmpl_var title></h1>
<tmpl_var formHeader>
<table width="100%" cellspacing="1" cellpadding="2" border="0">
<tbody>
<tr>
<td class="tableData">
<tmpl_var emailAddressLabel>
</td>
<td class="tableData">
<tmpl_var emailAddressForm>
</td>
</tr>
<tr>
<td class="tableData">
<tmpl_var subjectLabel>
</td>
<td class="tableData">
<tmpl_var subjectForm>
</td>
</tr>
<tr>
<td class="tableData">
<tmpl_var messageLabel>
</td>
<td class="tableData">
<tmpl_var messageForm>
</td>
</tr>
<tr>
<td class="tableData">
&nbsp;
</td>
<td class="tableData">
<tmpl_var submitButton>
</td>
</tr>
</tbody>
</table>
<tmpl_var formFooter>

View file

@ -26,6 +26,7 @@ fixProfileDataWithoutFields($session);
buildNewUserProfileTable($session);
addAttachmentsToEvents($session);
addMetaDataPostsToCS($session);
addUserInvitations($session);
finish($session); # this line required
@ -118,6 +119,35 @@ sub addMetaDataPostsToCS {
}
#----------------------------------------------------------------------------
sub addUserInvitations {
my $session = shift;
my $db = $session->db;
print "\tAdding the ability for users's to invite others to the site... " unless $quiet;
##Add settings
$session->setting->add('userInvitationsEnabled', 0);
$session->setting->add('userInvitationsEmailExists', 'This email address exists in our system. This means that your friend is already a member of the site. The invitation will not be sent.');
##Create table for tracking invitations
$session->db->write(<<EOSQL);
CREATE TABLE userInvitations (
inviteId VARCHAR(22) BINARY NOT NULL,
userId VARCHAR(22) BINARY NOT NULL,
dateSent DATE,
email VARCHAR(255) NOT NULL,
newUserId VARCHAR(22) BINARY,
dateCreated DATE,
PRIMARY KEY (inviteId)
)
EOSQL
print "OK!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub buildNewUserProfileTable {