diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-06-12 20:23:51 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-06-12 20:23:51 +0000 |
commit | 9c6eb2dae8143d7b615d213869bca4b5b2456a98 (patch) | |
tree | e2ad4b7d84642fcb35fedbf81e79c1cb2a6a6005 /mod/invitefriends/actions | |
parent | 365e4fb08bbc5449d32e25e09face877afee4366 (diff) | |
download | elgg-9c6eb2dae8143d7b615d213869bca4b5b2456a98.tar.gz elgg-9c6eb2dae8143d7b615d213869bca4b5b2456a98.tar.bz2 |
Merged r6362:6366 from 1.7 to trunk.
git-svn-id: http://code.elgg.org/elgg/trunk@6469 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/invitefriends/actions')
-rw-r--r-- | mod/invitefriends/actions/invite.php | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/mod/invitefriends/actions/invite.php b/mod/invitefriends/actions/invite.php index abc212bea..9334860a7 100644 --- a/mod/invitefriends/actions/invite.php +++ b/mod/invitefriends/actions/invite.php @@ -19,7 +19,7 @@ if (strlen($emails) > 0) { } if (!is_array($emails) || count($emails) == 0) { - register_error(elgg_echo('invitefriends:failure')); + register_error(elgg_echo('invitefriends:noemails')); forward($_SERVER['HTTP_REFERER']); } @@ -27,7 +27,9 @@ $current_user = get_loggedin_user(); $error = FALSE; $bad_emails = array(); -foreach($emails as $email) { +$already_members = array(); +$sent_total = 0; +foreach ($emails as $email) { $email = trim($email); if (empty($email)) { @@ -41,6 +43,12 @@ foreach($emails as $email) { continue; } + if (get_user_by_email($email)) { + $error = TRUE; + $already_members[] = $email; + continue; + } + $link = $CONFIG->wwwroot . 'pg/register?friend_guid=' . $current_user->guid . '&invitecode=' . generate_invite_code($current_user->username); $message = sprintf(elgg_echo('invitefriends:email'), $CONFIG->site->name, @@ -60,10 +68,20 @@ foreach($emails as $email) { } elgg_send_email($from, $email, $subject, $message); + $sent_total++; } if ($error) { - register_error(sprintf(elgg_echo('invitefriends:email_error'), implode(', ', $bad_emails))); + register_error(sprintf(elgg_echo('invitefriends:invitations_sent'), $sent_total)); + + if (count($bad_emails) > 0) { + register_error(sprintf(elgg_echo('invitefriends:email_error'), implode(', ', $bad_emails))); + } + + if (count($already_members) > 0) { + register_error(sprintf(elgg_echo('invitefriends:already_members'), implode(', ', $already_members))); + } + } else { system_message(elgg_echo('invitefriends:success')); } |