$result = save_widget_info($guid,$params);
}
+if ($noforward) {
+ exit;
+}
+
if ($result) {
system_message(elgg_echo('widgets:save:success'));
} else {
register_error(elgg_echo('widgets:save:failure'));
}
-if (!$noforward) {
- forward($_SERVER['HTTP_REFERER']);
-}
+forward($_SERVER['HTTP_REFERER']);
\ No newline at end of file
return $CONFIG->default_access;
}
- if (!($user) || (!$user = get_loggedin_user())) {
+ if (!($user) && (!$user = get_loggedin_user())) {
return $CONFIG->default_access;
}
global $CONFIG;
if (!headers_sent()) {
+ if ($location === REFERER) {
+ $location = $_SERVER['HTTP_REFERER'];
+ }
+
$current_page = current_page_url();
if ((substr_count($location, 'http://') == 0) && (substr_count($location, 'https://') == 0)) {
$location = $CONFIG->url . $location;
return $viewtype;
}
+/**
+ * Register a viewtype to fall back to a default view if view does not exist in
+ * that viewtype.
+ *
+ * This is useful for alternate html viewtypes (such as for mobile devices)
+ *
+ * @param string $viewtype The viewtype to register
+ */
+function elgg_register_viewtype_fallback($viewtype) {
+ global $CONFIG;
+
+ if (!isset($CONFIG->viewtype)) {
+ $CONFIG->viewtype = new stdClass;
+ }
+
+ if (!isset($CONFIG->viewtype->fallback)) {
+ $CONFIG->viewtype->fallback = array();
+ }
+
+ $CONFIG->viewtype->fallback[] = $viewtype;
+}
+
+/**
+ * Checks if this viewtype falls back to default
+ *
+ * @param string $viewtype
+ * @return boolean
+ */
+function elgg_does_viewtype_fallback($viewtype) {
+ global $CONFIG;
+
+ if (isset($CONFIG->viewtype) && isset($CONFIG->viewtype->fallback)) {
+ return in_array($viewtype, $CONFIG->viewtype->fallback);
+ }
+
+ return FALSE;
+}
+
+
/**
* Return the location of a given view.
*
$error = "$viewtype/$view view does not exist.";
// attempt to load default view
- if ($viewtype != 'default') {
+ if ($viewtype != 'default' && elgg_does_viewtype_fallback($viewtype)) {
if (file_exists($default_view_file) && include($default_view_file)) {
// default view found
$error .= " Using default/$view instead.";
define('ACCESS_PUBLIC', 2);
define('ACCESS_FRIENDS', -2);
+/**
+ * @since 1.7
+ */
define('ELGG_ENTITIES_ANY_VALUE', NULL);
define('ELGG_ENTITIES_NO_VALUE', 0);
+/**
+ * @since 1.7.2
+ */
+define('REFERRER', -1);
+define('REFERER', -1);
+
register_elgg_event_handler('init', 'system', 'elgg_init');
register_elgg_event_handler('boot', 'system', 'elgg_boot', 1000);
register_plugin_hook('unit_test', 'system', 'elgg_api_test');
}
if ($timeupper) {
- $options['time_upper'] = $timeupper;
+ $options['created_time_upper'] = $timeupper;
}
if ($timelower) {
- $options['time_lower'] = $timelower;
+ $options['created_time_lower'] = $timelower;
}
$r = elgg_get_entities($options);
throw new NotificationException(sprintf(elgg_echo('NotificationException:NoEmailAddress'), $to->guid));
}
- // Sanitise subject
- $subject = preg_replace("/(\r\n|\r|\n)/", " ", $subject); // Strip line endings
-
// To
$to = $to->email;
} else if (($site) && (isset($site->email))) {
// Has the current site got a from email address?
$from = $site->email;
- } else if (isset($from->url)) {
- // If we have a url then try and use that.
- $breakdown = parse_url($from->url);
- $from = 'noreply@' . $breakdown['host']; // Handle anything with a url
} else {
// If all else fails, use the domain of the site.
$from = 'noreply@' . get_site_domain($CONFIG->site_guid);
}
- if (is_callable('mb_internal_encoding')) {
- mb_internal_encoding('UTF-8');
- }
- $site = get_entity($CONFIG->site_guid);
- $sitename = $site->name;
- if (is_callable('mb_encode_mimeheader')) {
- $sitename = mb_encode_mimeheader($site->name,"UTF-8", "B");
- }
-
- $header_eol = "\r\n";
- if (
- (isset($CONFIG->broken_mta)) &&
- ($CONFIG->broken_mta)
- ) {
- // Allow non-RFC 2822 mail headers to support some broken MTAs
- $header_eol = "\n";
- }
-
- $from_email = "\"$sitename\" <$from>";
- if (strtolower(substr(PHP_OS, 0 , 3)) == 'win') {
- // Windows is somewhat broken, so we use a different format from header
- $from_email = "$from";
- }
-
- $headers = "From: $from_email{$header_eol}"
- . "Content-Type: text/plain; charset=UTF-8; format=flowed{$header_eol}"
- . "MIME-Version: 1.0{$header_eol}"
- . "Content-Transfer-Encoding: 8bit{$header_eol}";
-
- if (is_callable('mb_encode_mimeheader')) {
- $subject = mb_encode_mimeheader($subject,"UTF-8", "B");
- }
-
- // Format message
- $message = html_entity_decode($message, ENT_COMPAT, 'UTF-8'); // Decode any html entities
- $message = strip_tags($message); // Strip tags from message
- $message = preg_replace("/(\r\n|\r)/", "\n", $message); // Convert to unix line endings in body
- $message = preg_replace("/^From/", ">From", $message); // Change lines starting with From to >From
-
- return mail($to, $subject, wordwrap($message), $headers);
+ return elgg_send_email($from, $to, $subject, $message);
}
/**
}
// Format message
- $message = html_entity_decode($body, ENT_COMPAT, 'UTF-8'); // Decode any html entities
- $message = strip_tags($body); // Strip tags from message
- $message = preg_replace("/(\r\n|\r)/", "\n", $body); // Convert to unix line endings in body
- $message = preg_replace("/^From/", ">From", $body); // Change lines starting with From to >From
+ $body = html_entity_decode($body, ENT_COMPAT, 'UTF-8'); // Decode any html entities
+ $body = strip_tags($body); // Strip tags from message
+ $body = preg_replace("/(\r\n|\r)/", "\n", $body); // Convert to unix line endings in body
+ $body = preg_replace("/^From/", ">From", $body); // Change lines starting with From to >From
return mail($to, $subject, wordwrap($body), $headers);
}
// Construct 'where' clauses for the river
$where = array();
+ // river table does not have columns expected by get_access_sql_suffix so we modify its output
$where[] = str_replace("and enabled='yes'",'',str_replace('owner_guid','subject_guid',get_access_sql_suffix()));
if (empty($subject_relationship)) {
return ElggSession::$__localcache[$key];
}
- $value = null;
- $value = trigger_plugin_hook('session:get', $key, null, $value);
+ $value = NULL;
+ $value = trigger_plugin_hook('session:get', $key, NULL, $value);
ElggSession::$__localcache[$key] = $value;
/**
- * Return the current logged in user, or null if no user is logged in.
+ * Return the current logged in user, or NULL if no user is logged in.
*
* If no user can be found in the current session, a plugin hook - 'session:get' 'user' to give plugin
* authors another way to provide user details to the ACL system without touching the session.
+ * @return ElggUser|NULL
*/
function get_loggedin_user() {
global $SESSION;
return $SESSION['user'];
}
- return false;
+ return NULL;
}
/**
*/
function get_loggedin_userid() {
$user = get_loggedin_user();
- if ($user)
+ if ($user) {
return $user->guid;
+ }
return 0;
}
$object_subtype = $object->getSubtype();
$event = sanitise_string($event);
$time = time();
- $performed_by = (int)$_SESSION['guid'];
+ $performed_by = get_loggedin_userid();
if (isset($object->access_id)) {
$access_id = $object->access_id;
}
if ($end_ts) {
- $options['time_upper'] = $end_ts;
+ $options['created_time_upper'] = $end_ts;
}
if ($start_ts) {
- $options['time_lower'] = $start_ts;
+ $options['created_time_lower'] = $start_ts;
}
$r = elgg_get_tags($options);
global $CONFIG;
$user = get_loggedin_user();
add_submenu_item(elgg_echo('friends:collections'), $CONFIG->wwwroot . "pg/collections/" . $user->username);
- add_submenu_item(elgg_echo('friends:collections:add'),$CONFIG->wwwroot."pg/collections/add");
+ add_submenu_item(elgg_echo('friends:collections:add'), $CONFIG->wwwroot . "pg/collections/add");
}
/**
if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {
set_page_owner($user->getGUID());
}
- if ($_SESSION['guid'] == page_owner()) {
+ if (get_loggedin_userid() == page_owner()) {
// collections_submenu_items(); disabled for now as we no longer use friends collections (replaced by shared access)
}
-
require_once(dirname(dirname(dirname(__FILE__))) . "/friends/index.php");
}
if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {
set_page_owner($user->getGUID());
}
- if ($_SESSION['guid'] == page_owner()) {
+ if (get_loggedin_userid() == page_owner()) {
// collections_submenu_items(); disabled for now as we no longer use friends collections (replaced by shared access)
}
require_once(dirname(dirname(dirname(__FILE__))) . "/friends/of.php");
}
/**
- * Page handler for friends of
+ * Page handler for friends collections
*
*/
function collections_page_handler($page_elements) {
if (isset($page_elements[0])) {
if ($page_elements[0] == "add") {
- set_page_owner($_SESSION['guid']);
+ set_page_owner(get_loggedin_userid());
collections_submenu_items();
require_once(dirname(dirname(dirname(__FILE__))) . "/friends/add.php");
} else {
if ($user = get_user_by_username($page_elements[0])) {
set_page_owner($user->getGUID());
- if ($_SESSION['guid'] == page_owner()) {
+ if (get_loggedin_userid() == page_owner()) {
collections_submenu_items();
}
require_once(dirname(dirname(dirname(__FILE__))) . "/friends/collections.php");
<?php
/**
* Elgg groups forum
- *
+ *
* @package ElggGroups
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
- set_page_owner((int)get_input('group_guid'));
- if (!(page_owner_entity() instanceof ElggGroup)) forward();
+ $group_guid = (int)get_input('group_guid');
+ set_page_owner($group_guid);
+ if (!(page_owner_entity() instanceof ElggGroup)) {
+ forward();
+ }
group_gatekeeper();
set_context('search');
// set up breadcrumbs
- $group_guid = get_input('group_guid');
$group = get_entity($group_guid);
elgg_push_breadcrumb(elgg_echo('groups'), $CONFIG->wwwroot."pg/groups/world/");
elgg_push_breadcrumb($group->name, $group->getURL());
if(page_owner_entity()->isMember($vars['user'])) {
?>
<div class="content_header_options">
- <a class="action_button" href="<?php echo $vars['url']; ?>mod/groups/addtopic.php?group_guid=<?php echo get_input('group_guid'); ?>"><?php echo elgg_echo("groups:addtopic"); ?></a>
+ <a class="action_button" href="<?php echo $vars['url']; ?>mod/groups/addtopic.php?group_guid=<?php echo vars('group_guid'); ?>"><?php echo elgg_echo("groups:addtopic"); ?></a>
</div>
<?php
}
<?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']);
<?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);
<?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
);
- add_translation("en",$english);
-?>
+add_translation("en", $english);
<?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');
<?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'
+ )
+);
<?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>";
if (!in_array($size,array('large','medium','small','tiny','master','topbar')))
$size = "medium";
+// If user doesn't exist, return default icon
+if (!$user) {
+ $path = elgg_view("icon/user/default/$size");
+ header("Location: $path");
+ exit;
+}
+
// Try and get the icon
$filehandler = new ElggFile();
$filehandler->owner_guid = $user->getGUID();
<?php
/**
- * Elgg create river item
+ * Elgg create new friend river item
*
* @package Elgg
* @author Curverider Ltd <info@elgg.com>
*/
$performed_by = get_entity($vars['item']->subject_guid);
$performed_on = get_entity($vars['item']->object_guid);
-$url = $performed_on->getURL();
$url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
$string = sprintf(elgg_echo("friends:river:add"),$url) . " ";
--- /dev/null
+<?php
+
+$entities = $vars['entities'];
+$fullview = $vars['fullview'];
+
+if (is_array($entities) && sizeof($entities) > 0) {
+ foreach($entities as $entity) {
+ echo elgg_view_entity($entity, $fullview);
+ }
+}
\ No newline at end of file