diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-14 20:01:59 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-05-14 20:01:59 +0000 |
commit | b6aaba915151dd07800761a01b67ffffaee1302b (patch) | |
tree | 53c30035411460270278943f2427405233b34fac /mod/invitefriends/actions | |
parent | ffbd7cd4179a0186dc674c2d24f578660cc75df0 (diff) | |
download | elgg-b6aaba915151dd07800761a01b67ffffaee1302b.tar.gz elgg-b6aaba915151dd07800761a01b67ffffaee1302b.tar.bz2 |
merge -r5898:5928 (not excluding riverdashboard, notifications, and messageboard) from 1.7 to trunk.
git-svn-id: http://code.elgg.org/elgg/trunk@6058 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/invitefriends/actions')
-rw-r--r-- | mod/invitefriends/actions/invite.php | 120 |
1 files changed, 59 insertions, 61 deletions
diff --git a/mod/invitefriends/actions/invite.php b/mod/invitefriends/actions/invite.php index 66902606a..abc212bea 100644 --- a/mod/invitefriends/actions/invite.php +++ b/mod/invitefriends/actions/invite.php @@ -1,73 +1,71 @@ <?php - /** - * Elgg invite action - * - * @package ElggFile - * @author Curverider Ltd - * @copyright Curverider Ltd 2008-2010 - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @link http://elgg.org/ - */ +/** + * Elgg invite friends action + * + * @package ElggInviteFriends + * @author Curverider Ltd + * @copyright Curverider Ltd 2008-2010 + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @link http://elgg.org/ + */ - global $CONFIG; - - gatekeeper(); - - $emails = get_input('emails'); - $emailmessage = get_input('emailmessage'); +$emails = get_input('emails'); +$emailmessage = get_input('emailmessage'); - $emails = trim($emails); - if (strlen($emails) > 0) { - $emails = preg_split('/\\s+/', $emails, -1, PREG_SPLIT_NO_EMPTY); +$emails = trim($emails); +if (strlen($emails) > 0) { + $emails = preg_split('/\\s+/', $emails, -1, PREG_SPLIT_NO_EMPTY); +} + +if (!is_array($emails) || count($emails) == 0) { + register_error(elgg_echo('invitefriends:failure')); + forward($_SERVER['HTTP_REFERER']); +} + +$current_user = get_loggedin_user(); + +$error = FALSE; +$bad_emails = array(); +foreach($emails as $email) { + + $email = trim($email); + if (empty($email)) { + continue; } - - if (!is_array($emails) || count($emails) == 0) { - register_error(elgg_echo('invitefriends:failure')); - forward($_SERVER['HTTP_REFERER']); + + // send out other email addresses + if (!is_email_address($email)) { + $error = TRUE; + $bad_emails[] = $email; + continue; } - - $error = FALSE; - $bad_emails = array(); - foreach($emails as $email) { - - $email = trim($email); - if (empty($email)) { - continue; - } - - // send out other email addresses - if (!is_email_address($email)) { - $error = TRUE; - $bad_emails[] = $email; - continue; - } - - $link = $CONFIG->wwwroot . 'pg/register?friend_guid=' . $_SESSION['guid'] . '&invitecode=' . generate_invite_code($_SESSION['user']->username); - $message = sprintf(elgg_echo('invitefriends:email'), - $CONFIG->site->name, - $_SESSION['user']->name, - $emailmessage, - $link - ); - $subject = sprintf(elgg_echo('invitefriends:subject'), $CONFIG->site->name); + $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, + $current_user->name, + $emailmessage, + $link + ); - // create the from address - $site = get_entity($CONFIG->site_guid); - if (($site) && (isset($site->email))) { - $from = $site->email; - } else { - $from = 'noreply@' . get_site_domain($CONFIG->site_guid); - } + $subject = sprintf(elgg_echo('invitefriends:subject'), $CONFIG->site->name); - elgg_send_email($from, $email, $subject, $message); + // create the from address + $site = get_entity($CONFIG->site_guid); + if (($site) && (isset($site->email))) { + $from = $site->email; + } else { + $from = 'noreply@' . get_site_domain($CONFIG->site_guid); } - if ($error) { - register_error(sprintf(elgg_echo('invitefriends:email_error'), implode(', ', $bad_emails))); - } else { - system_message(elgg_echo('invitefriends:success')); - } + elgg_send_email($from, $email, $subject, $message); +} - forward($_SERVER['HTTP_REFERER']); +if ($error) { + register_error(sprintf(elgg_echo('invitefriends:email_error'), implode(', ', $bad_emails))); +} else { + system_message(elgg_echo('invitefriends:success')); +} + +forward($_SERVER['HTTP_REFERER']); |