aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/register.php6
-rw-r--r--engine/lib/access.php5
-rw-r--r--engine/lib/users.php6
-rw-r--r--mod/invitefriends/actions/invite.php24
-rw-r--r--mod/invitefriends/languages/en.php6
5 files changed, 34 insertions, 13 deletions
diff --git a/actions/register.php b/actions/register.php
index 556bad4cd..b5733635f 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -78,8 +78,4 @@ if ($CONFIG->allow_registration) {
register_error(elgg_echo('registerdisabled'));
}
-$qs = explode('?',$_SERVER['HTTP_REFERER']);
-$qs = $qs[0];
-$qs .= "?u=" . urlencode($username) . "&e=" . urlencode($email) . "&n=" . urlencode($name) . "&friend_guid=" . $friend_guid;
-
-forward($qs);
+forward(REFERER);
diff --git a/engine/lib/access.php b/engine/lib/access.php
index fc5081ced..b8d8820e1 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -628,7 +628,7 @@ function get_user_access_collections($owner_guid, $site_guid = 0) {
* @param true|false $idonly If set to true, will only return the members' IDs (default: false)
* @return ElggUser entities if successful, false if not
*/
-function get_members_of_access_collection($collection, $idonly = false) {
+function get_members_of_access_collection($collection, $idonly = FALSE) {
global $CONFIG;
$collection = (int)$collection;
@@ -638,6 +638,9 @@ function get_members_of_access_collection($collection, $idonly = false) {
} else {
$query = "SELECT e.guid FROM {$CONFIG->dbprefix}access_collection_membership m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";
$collection_members = get_data($query);
+ if (!$collection_members) {
+ return FALSE;
+ }
foreach($collection_members as $key => $val) {
$collection_members[$key] = $val->guid;
}
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 118a96b32..fcc10133f 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -754,8 +754,10 @@ function user_remove_friend($user_guid, $friend_guid) {
// perform cleanup for access lists.
$collections = get_user_access_collections($user_guid);
- foreach ($collections as $collection) {
- remove_user_from_access_collection($friend_guid, $collection->id);
+ if ($collections) {
+ foreach ($collections as $collection) {
+ remove_user_from_access_collection($friend_guid, $collection->id);
+ }
}
return remove_entity_relationship($user_guid, "friend", $friend_guid);
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,