aboutsummaryrefslogtreecommitdiff
path: root/mod/invitefriends
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-06-12 20:23:51 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-06-12 20:23:51 +0000
commit9c6eb2dae8143d7b615d213869bca4b5b2456a98 (patch)
treee2ad4b7d84642fcb35fedbf81e79c1cb2a6a6005 /mod/invitefriends
parent365e4fb08bbc5449d32e25e09face877afee4366 (diff)
downloadelgg-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')
-rw-r--r--mod/invitefriends/actions/invite.php24
-rw-r--r--mod/invitefriends/languages/en.php6
2 files changed, 25 insertions, 5 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'));
}
diff --git a/mod/invitefriends/languages/en.php b/mod/invitefriends/languages/en.php
index fa6cb3fd9..ad64e4fd8 100644
--- a/mod/invitefriends/languages/en.php
+++ b/mod/invitefriends/languages/en.php
@@ -18,8 +18,10 @@ $english = array(
'invitefriends:subject' => 'Invitation to join %s',
'invitefriends:success' => 'Your friends were invited.',
- 'invitefriends:email_error' => 'Invitations were sent, but the following addresses are not valid: %s',
- 'invitefriends:failure' => 'Your friends could not be invited.',
+ 'invitefriends:invitations_sent' => 'Invites sent: %s. There were the following problems:',
+ 'invitefriends:email_error' => 'The following addresses are not valid: %s',
+ 'invitefriends:already_members' => 'The following are already members: %s',
+ 'invitefriends:noemails' => 'No email addresses were entered.',
'invitefriends:message:default' => '
Hi,