aboutsummaryrefslogtreecommitdiff
path: root/mod/invitefriends
diff options
context:
space:
mode:
Diffstat (limited to 'mod/invitefriends')
-rw-r--r--mod/invitefriends/actions/invite.php120
-rw-r--r--mod/invitefriends/index.php39
-rw-r--r--mod/invitefriends/languages/en.php48
-rw-r--r--mod/invitefriends/start.php24
-rw-r--r--mod/invitefriends/views/default/invitefriends/form.php31
-rw-r--r--mod/invitefriends/views/default/invitefriends/formitems.php18
6 files changed, 138 insertions, 142 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']);
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 @@
<?php
+
/**
- * Elgg invite page
- *
- * @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 page
+ *
+ * @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/
+ */
+
+require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');
+
+gatekeeper();
+
+set_context('friends');
+set_page_owner(get_loggedin_userid());
- require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');
-
- gatekeeper();
-
- set_context('friends');
- set_page_owner($_SESSION['guid']);
-
- $body = elgg_view('invitefriends/form');
- $body = elgg_view_layout('one_column_with_sidebar', $body);
+$body = elgg_view('invitefriends/form');
+$body = elgg_view_layout('one_column_with_sidebar', $body);
- page_draw(elgg_echo('friends:invite'),$body);
-
-?> \ 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 @@
<?php
- /**
- * Elgg invite page
- *
- * @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/
- */
-
- $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',
+/**
+ * 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 @@
<?php
/**
- * Elgg invite page
- *
- * @package ElggFile
+ * Elgg invite friends
+ *
+ * @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/
*/
+/**
+ * Add menu item for invite friends
+ */
function invitefriends_pagesetup() {
-
- // Menu options
global $CONFIG;
- if (get_context() == "friends" ||
- get_context() == "friendsof") {
+ if (get_context() == "friends" ||
+ get_context() == "friendsof" ||
+ get_context() == "collections") {
add_submenu_item(elgg_echo('friends:invite'),$CONFIG->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 @@
<?php
- /**
- * Elgg invite page
- *
- * @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/
- */
- echo elgg_view('input/form', array(
- 'action' => $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 @@
<?php
- /**
- * Elgg invite page
- *
- * @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 form contents
+ *
+ * @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 "<h2>".elgg_echo('friends:invite')."</h2>";