aboutsummaryrefslogtreecommitdiff
path: root/mod/invitefriends
diff options
context:
space:
mode:
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,