blob: a04a12ddd8b7ba5a6b1d1dd3d1665c5efbca2e49 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?php
function init_invite() {
global $S;
if (!isset($S['user'])) {
return 'login';
}
if (!$S['user']->hasflag('a')) {
return 'denied';
}
}
function body_invite() {
global $S, $request, $conf;
if (isset($request['emails'])) {
echo '<h3>Inviting Users</h3>';
$emails=explode("\n", $request['emails']);
foreach ($emails as $email) {
// TODO proper checking that user and registrationtoken don't exist for this email to avoid errors
$email=trim($email);
if (strlen($email) == 0) {
continue;
}
if (!Validate::email($email)) {
echo 'Email address "'.htmlentities($email).'" invalid<br/>';
continue;
}
$token=sql_registrationtoken::create();
$token->email=$email;
$token->expire=time()+24*3600; // 24 hour shelf life (we're not checking currently)
$token->owner=$S['user']->id;
$token->write();
xhtmlemail($email, null, $conf['title'].' invitation', htmlentities($S['user']->name).' has invited you to create an account for '.$conf['title'].'. To create an account, click this link: <a href="'.url('register/'.$token->id).'">'.url('register/'.$token->id).'</a>');
echo 'Invited '.htmlentities($email).'<br/>';
}
echo '<a href="'.url('invite').'">Send more invitations</a>';
} else {
echo '<h3>Invite Users</h3><form action="'.url('invite').'" method="post">Email addresses to send invitations to: (one per line)<br/><textarea name="emails"></textarea><br/><input type="submit" value="Send Invitations" /></form>';
}
}
?>
|