From b6aaba915151dd07800761a01b67ffffaee1302b Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 14 May 2010 20:01:59 +0000 Subject: 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 --- mod/invitefriends/actions/invite.php | 120 ++++++++++----------- mod/invitefriends/index.php | 39 ++++--- mod/invitefriends/languages/en.php | 48 ++++----- mod/invitefriends/start.php | 24 ++--- .../views/default/invitefriends/form.php | 31 +++--- .../views/default/invitefriends/formitems.php | 18 ++-- 6 files changed, 138 insertions(+), 142 deletions(-) (limited to 'mod/invitefriends') 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 @@ 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']); diff --git a/mod/invitefriends/index.php b/mod/invitefriends/index.php index 2a9aee790..1f27f07aa 100644 --- a/mod/invitefriends/index.php +++ b/mod/invitefriends/index.php @@ -1,24 +1,23 @@ \ No newline at end of file +page_draw(elgg_echo('friends:invite'), $body); diff --git a/mod/invitefriends/languages/en.php b/mod/invitefriends/languages/en.php index 357ceeeea..fa6cb3fd9 100644 --- a/mod/invitefriends/languages/en.php +++ b/mod/invitefriends/languages/en.php @@ -1,31 +1,32 @@ 'Invite friends', - 'invitefriends:introduction' => 'To invite friends to join you on this network, enter their email addresses below (one per line):', - 'invitefriends:message' => 'Enter a message they will receive with your invitation:', - 'invitefriends:subject' => 'Invitation to join %s', +/** + * Elgg invite language file + * + * @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/ + */ + +$english = array( + + 'friends:invite' => 'Invite friends', + 'invitefriends:introduction' => 'To invite friends to join you on this network, enter their email addresses below (one per line):', + 'invitefriends:message' => 'Enter a message they will receive with your invitation:', + '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: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:message:default' => ' + 'invitefriends:message:default' => ' Hi, I want to invite you to join my network here on %s.', - 'invitefriends:email' => ' + + 'invitefriends:email' => ' You have been invited to join %s by %s. They included the following message: %s @@ -38,5 +39,4 @@ You will automatically add them as a friend when you create your account.', ); - add_translation("en",$english); -?> +add_translation("en", $english); diff --git a/mod/invitefriends/start.php b/mod/invitefriends/start.php index f2b532253..6bdedcffa 100644 --- a/mod/invitefriends/start.php +++ b/mod/invitefriends/start.php @@ -1,25 +1,25 @@ wwwroot."mod/invitefriends/",'invite'); - } } +} - global $CONFIG; - register_action('invitefriends/invite', false, $CONFIG->pluginspath . 'invitefriends/actions/invite.php'); - register_elgg_event_handler('pagesetup','system','invitefriends_pagesetup',1000); -?> \ No newline at end of file +register_action('invitefriends/invite', false, $CONFIG->pluginspath . 'invitefriends/actions/invite.php'); +register_elgg_event_handler('pagesetup', 'system', 'invitefriends_pagesetup'); diff --git a/mod/invitefriends/views/default/invitefriends/form.php b/mod/invitefriends/views/default/invitefriends/form.php index ef66c1e84..ed8fa2d15 100644 --- a/mod/invitefriends/views/default/invitefriends/form.php +++ b/mod/invitefriends/views/default/invitefriends/form.php @@ -1,18 +1,17 @@ $vars['url'] . 'action/invitefriends/invite', - 'body' => elgg_view('invitefriends/formitems'), - 'method' => 'post' - ) - ); +/** + * Elgg invite form wrapper + * + * @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/ + */ -?> +echo elgg_view('input/form', array( + 'action' => $vars['url'] . 'action/invitefriends/invite', + 'body' => elgg_view('invitefriends/formitems'), + 'method' => 'post' + ) +); diff --git a/mod/invitefriends/views/default/invitefriends/formitems.php b/mod/invitefriends/views/default/invitefriends/formitems.php index 875287821..ce9a84073 100644 --- a/mod/invitefriends/views/default/invitefriends/formitems.php +++ b/mod/invitefriends/views/default/invitefriends/formitems.php @@ -1,14 +1,14 @@ ".elgg_echo('friends:invite').""; -- cgit v1.2.3