* @link http://elgg.org/
*/
-global $CONFIG;
-
gatekeeper();
$email = get_input('email');
$user_id = get_input('guid');
-$user = "";
if (!$user_id) {
- $user = $_SESSION['user'];
+ $user = get_loggedin_user();
} else {
$user = get_entity($user_id);
}
} else {
register_error(elgg_echo('email:save:fail'));
}
-
-//forward($_SERVER['HTTP_REFERER']);
-//exit;
-?>
// Get the user
try {
- if (!$_SESSION['user']->addFriend($friend_guid)) {
+ if (!get_loggedin_user()->addFriend($friend_guid)) {
$errors = true;
}
} catch (Exception $e) {
}
if (!$errors){
// add to river
- add_to_river('friends/river/create','friend',$_SESSION['user']->guid,$friend_guid);
+ add_to_river('friends/river/create','friend',get_loggedin_userid(),$friend_guid);
system_message(sprintf(elgg_echo("friends:add:successful"),$friend->name));
}
if($collection_name){
//create the collection
- $create_collection = create_access_collection($collection_name, $_SESSION['user']->getGUID());
+ $create_collection = create_access_collection($collection_name, get_loggedin_userid());
//if the collection was created and the user passed some friends from the form, add them
if($create_collection && (!empty($friends))){
// Success message
system_message(elgg_echo("friends:collectionadded"));
// Forward to the collections page
- forward("pg/collections/" . $_SESSION['user']->username);
+ forward("pg/collections/" . get_loggedin_user()->username);
} else {
register_error(elgg_echo("friends:nocollectionname"));
// Check to see that the access collection exist and grab its owner
$get_collection = get_access_collection($collection_id);
-if($get_collection){
+if ($get_collection) {
- if($get_collection->owner_guid == $_SESSION['user']->getGUID()) {
+ if ($get_collection->owner_guid == get_loggedin_userid()) {
$delete_collection = delete_access_collection($collection_id);
}
// Forward to the collections page
-forward("pg/collections/" . $_SESSION['user']->username);
+forward("pg/collections/" . get_loggedin_user()->username);
// Get the user
try{
if ($friend instanceof ElggUser) {
- $_SESSION['user']->removeFriend($friend_guid);
+ get_loggedin_user()->removeFriend($friend_guid);
} else{
register_error(sprintf(elgg_echo("friends:remove:failure"), $friend->name));
$errors = true;
foreach ($params as $k => $v) {
// Save
- $result = set_plugin_usersetting($k, $v, $_SESSION['user']->guid, $plugin);
+ $result = set_plugin_usersetting($k, $v, get_loggedin_userid(), $plugin);
// Error?
if (!$result) {
$default_access = get_input('default_access');
$user_id = get_input('guid');
- $user = "";
if (!$user_id) {
- $user = $_SESSION['user'];
+ $user = get_loggedin_user();
} else {
$user = get_entity($user_id);
}
* @link http://elgg.org/
*/
-global $CONFIG;
-
gatekeeper();
$language = get_input('language');
$user_id = get_input('guid');
-$user = "";
if (!$user_id) {
- $user = $_SESSION['user'];
+ $user = get_loggedin_user();
} else {
$user = get_entity($user_id);
}
* @link http://elgg.org/
*/
-global $CONFIG;
-
gatekeeper();
$name = strip_tags(get_input('name'));
$user_id = get_input('guid');
-$user = "";
if (!$user_id) {
- $user = $_SESSION['user'];
+ $user = get_loggedin_user();
} else {
$user = get_entity($user_id);
}
* @link http://elgg.org/
*/
-global $CONFIG;
-
gatekeeper();
$password = get_input('password');
$password2 = get_input('password2');
$user_id = get_input('guid');
-$user = "";
if (!$user_id) {
- $user = $_SESSION['user'];
+ $user = get_loggedin_user();
} else {
$user = get_entity($user_id);
}
$closed = true;
}
-$_SESSION['user']->spotlightclosed = $closed;
+get_loggedin_user()->spotlightclosed = $closed;
+// exit as this action is called through Ajax
exit;
\ No newline at end of file
/**
* ElggAnnotation
*
- * An annotation is similar to metadata each entity can contain more than one of each annotation.
+ * An annotation is similar to metadata.
+ * Each entity can have more than one of each type of annotation.
*
* @package Elgg
* @subpackage Core
class ElggAnnotation extends ElggExtender {
/**
- * Construct a new site object, optionally from a given id value or db row.
+ * Construct a new annotation, optionally from a given id value or db object.
*
* @param mixed $id
*/
$this->value_type, $this->owner_guid, $this->access_id);
if (!$this->id) {
- throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class()));
+ throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class()));
}
return $this->id;
}
}
/**
- * Delete a given site.
+ * Delete the annotation.
*/
function delete() {
return delete_annotation($this->id);
* Convert a database row to a new ElggAnnotation
*
* @param stdClass $row
- * @return stdClass or ElggAnnotation
+ * @return ElggAnnotation
*/
function row_to_elggannotation($row) {
if (!($row instanceof stdClass)) {
* Get a specific annotation.
*
* @param int $annotation_id
+ * @return ElggAnnotation
*/
function get_annotation($annotation_id) {
global $CONFIG;
* @param string $value_type
* @param int $owner_guid
* @param int $access_id
+ * @return int|bool id on success or false on failure
*/
function create_annotation($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE) {
global $CONFIG;
* @param string $value_type
* @param int $owner_guid
* @param int $access_id
+ * @return bool
*/
function update_annotation($annotation_id, $name, $value, $value_type, $owner_guid, $access_id) {
global $CONFIG;
if (empty($resultarray)) {
elgg_log("DB query \"$query\" returned no results.");
+ // @todo consider changing this to return empty array #1242
return false;
}
}
// check for upscaling
- // @todo This ignores squares, coordinates, and cropping. It's probably not the best idea.
- // Size checking should be done in action code, but for backward compatibility
- // this duplicates the previous behavior.
if (!$upscale && ($height < $new_height || $width < $new_width)) {
- // zero out offsets
- $widthoffset = $heightoffset = 0;
-
// determine if we can scale it down at all
// (ie, if only one dimension is too small)
// if not, just use original size.
} elseif ($width < $new_width) {
$ratio = $new_height / $height;
}
+
$selection_height = $height;
$selection_width = $width;
- $new_height = floor($height * $ratio);
- $new_width = floor($width * $ratio);
}
$params = array(
return $params;
}
-
// putting these here for now
function file_delete($guid) {
if ($file = get_entity($guid)) {
* @param unknown_type $offset Where to start, by default 0.
* @param unknown_type $count Whether to return the entities or a count of them.
*/
-function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false) {
- global $CONFIG;
-
- if ($subtype === false || $subtype === null || $subtype === 0) {
- return false;
+function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = FALSE) {
+ if ($subtype === FALSE || $subtype === null || $subtype === 0) {
+ return FALSE;
}
- $subtype = get_subtype_id('object', $subtype);
-
if ($order_by == "") {
$order_by = "e.time_created desc";
}
$where = array();
$where[] = "e.type='object'";
- if ($subtype!=="") {
+
+ if (!empty($subtype)) {
+ if (!$subtype = get_subtype_id('object', $subtype)) {
+ return FALSE;
+ }
$where[] = "e.subtype=$subtype";
}
if ($owner_guid != "") {
} else {
$this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
if (!$this->id) {
- throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class()));
+ throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class()));
}
return $this->id;
}
* @param array $pluginorder Optionally, a list of existing plugins and their orders
* @return array The new list of plugins and their orders
*/
-function regenerate_plugin_list($pluginorder = false) {
+function regenerate_plugin_list($pluginorder = FALSE) {
global $CONFIG;
- $CONFIG->pluginlistcache = null;
+ $CONFIG->pluginlistcache = NULL;
if ($site = get_entity($CONFIG->site_guid)) {
if (empty($pluginorder)) {
$site->pluginorder = $plugins;
- // Regenerate caches
- elgg_view_regenerate_simplecache();
- elgg_filepath_cache_reset();
-
return $plugins;
-
}
- return false;
+ return FALSE;
}
$this->id = add_entity_relationship($this->guid_one, $this->relationship, $this->guid_two);
if (!$this->id) {
- throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class()));
+ throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class()));
}
return $this->id;
$query .= get_access_sql_suffix('e');
$threshold = sanitise_int($options['threshold']);
- $query .= " GROUP BY msv.string HAVING total > {$threshold} ";
+ $query .= " GROUP BY msv.string HAVING total >= {$threshold} ";
$query .= " ORDER BY total DESC ";
$limit = sanitise_int($options['limit']);
// clean up
$this->entity->delete();
}
+
+ /**
+ * #2063 - get_resized_image_from_existing_file() fails asked for image larger than selection and not scaling an image up
+ * Test get_image_resize_parameters().
+ */
+ public function testElggResizeImage() {
+ $orig_width = 100;
+ $orig_height = 150;
+
+ // test against selection > max
+ $options = array(
+ 'maxwidth' => 50,
+ 'maxheight' => 50,
+ 'square' => TRUE,
+ 'upscale' => FALSE,
+
+ 'x1' => 25,
+ 'y1' => 75,
+ 'x2' => 100,
+ 'y2' => 150
+ );
+
+ // should get back the same x/y offset == x1, y1 and an image of 50x50
+ $params = get_image_resize_parameters($orig_width, $orig_height, $options);
+
+ $this->assertEqual($params['newwidth'], $options['maxwidth']);
+ $this->assertEqual($params['newheight'], $options['maxheight']);
+ $this->assertEqual($params['xoffset'], $options['x1']);
+ $this->assertEqual($params['yoffset'], $options['y1']);
+
+ // test against selection < max
+ $options = array(
+ 'maxwidth' => 50,
+ 'maxheight' => 50,
+ 'square' => TRUE,
+ 'upscale' => FALSE,
+
+ 'x1' => 75,
+ 'y1' => 125,
+ 'x2' => 100,
+ 'y2' => 150
+ );
+
+ // should get back the same x/y offset == x1, y1 and an image of 50x50
+ $params = get_image_resize_parameters($orig_width, $orig_height, $options);
+
+ $this->assertEqual($params['newwidth'], $options['maxwidth']);
+ $this->assertEqual($params['newheight'], $options['maxheight']);
+ $this->assertEqual($params['xoffset'], $options['x1']);
+ $this->assertEqual($params['yoffset'], $options['y1']);
+ }
}
<?php
/**
- * Activity viewer
+ * Entity viewer
*
* @package Elgg
* @subpackage Core
*/
require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
set_context('search');
-$area2 = elgg_list_entities("","",0,10,false);
+$area2 = elgg_list_entities();
set_context('entities');
-$body = elgg_view_layout('two_column_left_sidebar',$area1, $area2);
-page_draw("",$body);
\ No newline at end of file
+
+$body = elgg_view_layout('two_column_left_sidebar', $area1, $area2);
+
+page_draw("", $body);
\ No newline at end of file
$subtype = get_input("subtype", ELGG_ENTITIES_ANY_VALUE);
$type = get_input("type", 'object');
-$objects = list_entities_from_metadata('universal_categories',
- $category,
- $type,
- $subtype,
- $owner_guid,
- $limit,
- false,
- false,
- true,
- false);
-
+$params = array(
+ 'metadata_name' => 'universal_categories',
+ 'metadata_value' => $category,
+ 'types' => $type,
+ 'subtypes' => $subtype,
+ 'owner_guid' => $owner_guid,
+ 'limit' => $limit,
+ 'full_view' => FALSE,
+ 'metadata_case_sensitive' => FALSE,
+);
+$current_context = get_context();
+set_context('search');
+$objects = elgg_list_entities_from_metadata($params);
+set_context($current_context);
$title = sprintf(elgg_echo('categories:results'), $category);
if (isset($vars['owner_guid'])) {
$owner_guid = (int) $vars['owner_guid'];
}
- if ($cats = get_tags(0,999,'universal_categories','object',$vars['subtype'],$owner_guid)) {
+
+ elgg_register_tag_metadata_name('universal_categories');
+ $params = array(
+ 'threshold' => 1,
+ 'limit' => 999,
+ 'tag_names' => array('universal_categories'),
+ 'types' => 'object',
+ 'subtypes' => $vars['subtype'],
+ 'owner_guid' => $owner_guid,
+ );
+ $cats = elgg_get_tags($params);
+ if ($cats) {
foreach($cats as $cat) {
$flag[] = $cat->tag;
}
$limit = 10;
if ($search_viewtype == "gallery") $limit = 12;
if (!empty($tag)) {
- $area2 .= list_entities_from_metadata($md_type, $tag, 'object', 'file', $owner_guid, $limit);
+ $params = array(
+ 'metadata_name' => $md_type,
+ 'metadata_value' => $tag,
+ 'types' => 'object',
+ 'subtypes' => 'file',
+ 'owner_guid' => $owner_guid,
+ 'limit' => $limit,
+ );
+ $area2 .= elgg_list_entities_from_metadata($params);
} else {
$area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset));
}
// send welcome email
notify_user($user->getGUID(), $group->owner_guid,
sprintf(elgg_echo('groups:welcome:subject'), $group->name),
- sprintf(elgg_echo('groups:welcome:body'), $user->name, $logged_in_user->name, $group->name, $group->getURL()),
+ sprintf(elgg_echo('groups:welcome:body'), $user->name, $group->name, $group->getURL()),
NULL);
system_message(elgg_echo('groups:addedtogroup'));
*/
'groups:access:private' => 'Closed - Users must be invited',
'groups:access:public' => 'Open - Any user may join',
- 'groups:closedgroup' => 'This group has a closed membership. To ask to be added, click the "request membership" link.',
+ 'groups:closedgroup' => 'This group has a closed membership.',
+ 'groups:closedgroup:request' => 'To ask to be added, click the "request membership" menu link.',
'groups:visibility' => 'Who can see this group?',
/*
*/
?>
-<p class="margin_top"><?php echo elgg_echo('groups:closedgroup'); ?></p>
+<p class="margin_top">
+<?php
+echo elgg_echo('groups:closedgroup');
+if (isloggedin()) {
+ echo ' ' . elgg_echo('groups:closedgroup:request');
+}
+?>
+</p>
require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
if (!page_owner()) {
- set_page_owner($_SESSION['guid']);
+ set_page_owner(get_loggedin_userid());
}
// Make sure we don't open a security hole ...
if ((!page_owner_entity()) || (!page_owner_entity()->canEdit())) {
- set_page_owner($_SESSION['guid']);
+ set_page_owner(get_loggedin_userid());
}
// Forward to the user settings
<?php
/**
- * Elgg user settings functions.
+ * Elgg user plugin settings.
*
* @package Elgg
* @subpackage Core
* @link http://elgg.org/
*/
-// Get the Elgg framework
require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
// Make sure only valid users can see this
// Make sure we don't open a security hole ...
if ((!page_owner_entity()) || (!page_owner_entity()->canEdit())) {
- set_page_owner($_SESSION['guid']);
+ set_page_owner(get_loggedin_userid());
}
-// Display main admin menu
-page_draw(elgg_echo("usersettings:plugins"),elgg_view_layout('one_column_with_sidebar', elgg_view_title(elgg_echo("usersettings:plugins")) . elgg_view("usersettings/plugins", array('installed_plugins' => get_installed_plugins()))));
+$content = elgg_view_title(elgg_echo("usersettings:plugins"));
+$content .= elgg_view("usersettings/plugins", array('installed_plugins' => get_installed_plugins()));
+
+$body = elgg_view_layout('one_column_with_sidebar', $content);
+
+page_draw(elgg_echo("usersettings:plugins"), $body);
<?php
/**
- * Elgg user settings functions.
+ * Elgg user statistics.
*
* @package Elgg
* @subpackage Core
// Make sure we don't open a security hole ...
if ((!page_owner_entity()) || (!page_owner_entity()->canEdit())) {
- set_page_owner($_SESSION['guid']);
+ set_page_owner(get_loggedin_userid());
}
-// Display main admin menu
-page_draw(elgg_echo("usersettings:statistics"),elgg_view_layout('one_column_with_sidebar', elgg_view_title(elgg_echo("usersettings:statistics")) . elgg_view("usersettings/statistics")));
\ No newline at end of file
+$content = elgg_view_title(elgg_echo("usersettings:statistics"));
+$content .= elgg_view("usersettings/statistics");
+
+$body = elgg_view_layout('one_column_with_sidebar', $content);
+
+page_draw(elgg_echo("usersettings:statistics"), $body);
<?php
/**
- * Elgg user settings functions.
+ * Elgg user account settings.
*
* @package Elgg
* @subpackage Core
// Make sure we don't open a security hole ...
if ((!page_owner_entity()) || (!page_owner_entity()->canEdit())) {
- set_page_owner($_SESSION['guid']);
+ set_page_owner(get_loggedin_userid());
}
-// Display main admin menu
-page_draw(
- elgg_echo("usersettings:user"),
- elgg_view_layout("one_column_with_sidebar", elgg_view_title(elgg_echo('usersettings:user')) . elgg_view("usersettings/form"))
-);
\ No newline at end of file
+$content = elgg_view_title(elgg_echo('usersettings:user'));
+$content .= elgg_view("usersettings/form");
+
+$body = elgg_view_layout("one_column_with_sidebar", $content);
+
+page_draw(elgg_echo("usersettings:user"), $body);
<?php
/**
- * Elgg default layout
+ * JSON river view
*
* @package Elgg
* @subpackage Core
* @link http://elgg.org/
*/
global $jsonexport;
-if (isset($vars['items']) && is_array($vars['items'])) {
+$json_items = array();
+
+if (isset($vars['items']) && is_array($vars['items'])) {
$i = 0;
+
if (!empty($vars['items'])) {
foreach($vars['items'] as $item) {
+
+ $json_entry = array(
+ 'subject' => NULL,
+ 'object' => NULL,
+ 'type' => NULL,
+ 'subtype' => NULL,
+ 'action_type' => NULL,
+ 'view' => NULL,
+ 'annotation' => NULL,
+ 'timestamp' => NULL,
+ 'string' => NULL
+ );
- // echo elgg_view_river_item($item);
- if (elgg_view_exists($item->view,'default')) {
- $body = elgg_view($item->view,array('item' => $item), false, false, 'default');
- $time = date("r",$item->posted);
- if ($entity = get_entity($item->object_guid)) {
- $url = htmlspecialchars($entity->getURL());
- } else {
- $url = $vars['url'];
- }
- $title = strip_tags($body);
-
- $jsonitem = $item;
- $jsonitem->url = $url;
- $jsonitem->description = autop($body);
- $jsonitem->title = $title;
- unset($jsonitem->view);
-
- if ($subject = get_entity($item->subject_guid)) {
- elgg_view_entity($subject);
- }
- if ($object = get_entity($item->object_guid)) {
- elgg_view_entity($object);
- }
-
- $jsonexport['activity'][] = $jsonitem;
+ if (elgg_view_exists($item->view, 'default')) {
+ $json_entry['string'] = elgg_view($item->view, array('item' => $item), FALSE, FALSE, 'default');
+ $json_entry['timestamp'] = (int)$item->posted;
}
+ $json_items[] = $json_entry;
+
$i++;
if ($i >= $vars['limit']) {
break;
}
}
}
-echo "!";
\ No newline at end of file
+
+$jsonexport['activity'] = $json_items;