aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/access.php5
-rw-r--r--engine/lib/admin.php5
-rw-r--r--engine/lib/annotations.php32
-rw-r--r--engine/lib/deprecated-1.9.php (renamed from engine/lib/calendar.php)29
-rw-r--r--engine/lib/elgglib.php5
-rw-r--r--engine/lib/entities.php35
-rw-r--r--engine/lib/languages.php11
-rw-r--r--engine/lib/metastrings.php2
-rw-r--r--engine/lib/navigation.php50
-rw-r--r--engine/lib/output.php10
-rw-r--r--engine/lib/pagehandler.php33
-rw-r--r--engine/lib/relationships.php2
-rw-r--r--engine/lib/river.php33
-rw-r--r--engine/lib/user_settings.php11
-rw-r--r--engine/lib/users.php16
-rw-r--r--engine/lib/views.php2
-rw-r--r--engine/lib/widgets.php87
-rw-r--r--engine/lib/xml-rpc.php203
18 files changed, 268 insertions, 303 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 97f744fb9..08b9283cd 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -610,8 +610,7 @@ function delete_access_collection($collection_id) {
WHERE id = {$collection_id}";
$result = delete_data($q);
-
- return $result;
+ return (bool)$result;
}
/**
@@ -718,7 +717,7 @@ function remove_user_from_access_collection($user_guid, $collection_id) {
WHERE access_collection_id = {$collection_id}
AND user_guid = {$user_guid}";
- return delete_data($q);
+ return (bool)delete_data($q);
}
/**
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 3baf2ff61..a191d740b 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -225,6 +225,7 @@ function admin_init() {
elgg_register_action('admin/site/update_basic', '', 'admin');
elgg_register_action('admin/site/update_advanced', '', 'admin');
+ elgg_register_action('admin/site/flush_cache', '', 'admin');
elgg_register_action('admin/menu/save', '', 'admin');
@@ -301,7 +302,7 @@ function admin_init() {
}
// widgets
- $widgets = array('online_users', 'new_users', 'content_stats', 'admin_welcome');
+ $widgets = array('online_users', 'new_users', 'content_stats', 'admin_welcome', 'control_panel');
foreach ($widgets as $widget) {
elgg_register_widget_type(
$widget,
@@ -616,7 +617,7 @@ function elgg_add_admin_widgets($event, $type, $user) {
// In the form column => array of handlers in order, top to bottom
$adminWidgets = array(
- 1 => array('admin_welcome'),
+ 1 => array('control_panel', 'admin_welcome'),
2 => array('online_users', 'new_users', 'content_stats'),
);
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index e40ab2e39..bfd40d1e8 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -529,6 +529,20 @@ function elgg_annotation_exists($entity_guid, $annotation_type, $owner_guid = NU
}
/**
+ * Return the URL for a comment
+ *
+ * @param ElggAnnotation $comment The comment object
+ * @return string
+ * @access private
+ */
+function elgg_comment_url_handler(ElggAnnotation $comment) {
+ $entity = $comment->getEntity();
+ if ($entity) {
+ return $entity->getURL() . '#item-annotation-' . $comment->id;
+ }
+}
+
+/**
* Register an annotation url handler.
*
* @param string $function_name The function.
@@ -540,11 +554,6 @@ function elgg_register_annotation_url_handler($extender_name = "all", $function_
return elgg_register_extender_url_handler('annotation', $extender_name, $function_name);
}
-/** Register the hook */
-elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2);
-
-elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test');
-
/**
* Register annotation unit tests
* @access private
@@ -554,3 +563,16 @@ function annotations_test($hook, $type, $value, $params) {
$value[] = $CONFIG->path . 'engine/tests/api/annotations.php';
return $value;
}
+
+/**
+ * Initialize the annotation library
+ * @access private
+ */
+function elgg_annotations_init() {
+ elgg_register_annotation_url_handler('generic_comment', 'elgg_comment_url_handler');
+
+ elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2);
+ elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test');
+}
+
+elgg_register_event_handler('init', 'system', 'elgg_annotations_init');
diff --git a/engine/lib/calendar.php b/engine/lib/deprecated-1.9.php
index 9a06c5292..31d03428f 100644
--- a/engine/lib/calendar.php
+++ b/engine/lib/deprecated-1.9.php
@@ -1,14 +1,5 @@
<?php
/**
- * Elgg calendar / entity / event functions.
- *
- * @package Elgg.Core
- * @subpackage Calendar
- *
- * @todo Implement or remove
- */
-
-/**
* Return a timestamp for the start of a given day (defaults today).
*
* @param int $day Day
@@ -17,8 +8,10 @@
*
* @return int
* @access private
+ * @deprecated 1.9
*/
function get_day_start($day = null, $month = null, $year = null) {
+ elgg_deprecated_notice('get_day_start() has been deprecated', 1.9);
return mktime(0, 0, 0, $month, $day, $year);
}
@@ -31,8 +24,10 @@ function get_day_start($day = null, $month = null, $year = null) {
*
* @return int
* @access private
+ * @deprecated 1.9
*/
function get_day_end($day = null, $month = null, $year = null) {
+ elgg_deprecated_notice('get_day_end() has been deprecated', 1.9);
return mktime(23, 59, 59, $month, $day, $year);
}
@@ -53,10 +48,12 @@ function get_day_end($day = null, $month = null, $year = null) {
*
* @return array|false
* @access private
+ * @deprecated 1.9
*/
function get_notable_entities($start_time, $end_time, $type = "", $subtype = "", $owner_guid = 0,
$order_by = "asc", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
$container_guid = null) {
+ elgg_deprecated_notice('get_notable_entities() has been deprecated', 1.9);
global $CONFIG;
if ($subtype === false || $subtype === null || $subtype === 0) {
@@ -201,10 +198,12 @@ $container_guid = null) {
*
* @return int|array A list of entities, or a count if $count is set to true
* @access private
+ * @deprecated 1.9
*/
function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "",
$entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "",
$site_guid = 0, $count = false) {
+ elgg_deprecated_notice('get_notable_entities_from_metadata() has been deprecated', 1.9);
global $CONFIG;
@@ -331,10 +330,12 @@ $site_guid = 0, $count = false) {
*
* @return array|int|false An array of entities, or the number of entities, or false on failure
* @access private
+ * @deprecated 1.9
*/
function get_noteable_entities_from_relationship($start_time, $end_time, $relationship,
$relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
+ elgg_deprecated_notice('get_noteable_entities_from_relationship() has been deprecated', 1.9);
global $CONFIG;
@@ -441,9 +442,11 @@ $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
*
* @return array|false
* @access private
+ * @deprecated 1.9
*/
function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "",
$limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) {
+ elgg_deprecated_notice('get_todays_entities() has been deprecated', 1.9);
$day_start = get_day_start();
$day_end = get_day_end();
@@ -468,10 +471,12 @@ $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null
*
* @return int|array A list of entities, or a count if $count is set to true
* @access private
+ * @deprecated 1.9
*/
function get_todays_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "",
$entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
$count = false) {
+ elgg_deprecated_notice('get_todays_entities_from_metadata() has been deprecated', 1.9);
$day_start = get_day_start();
$day_end = get_day_end();
@@ -499,10 +504,12 @@ $count = false) {
*
* @return array|int|false An array of entities, or the number of entities, or false on failure
* @access private
+ * @deprecated 1.9
*/
function get_todays_entities_from_relationship($relationship, $relationship_guid,
$inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
+ elgg_deprecated_notice('get_todays_entities_from_relationship() has been deprecated', 1.9);
$day_start = get_day_start();
$day_end = get_day_end();
@@ -529,9 +536,11 @@ $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
*
* @return string A viewable list of entities
* @access private
+ * @deprecated 1.9
*/
function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0,
$limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
+ elgg_deprecated_notice('list_notable_entities() has been deprecated', 1.9);
$offset = (int) get_input('offset');
$count = get_notable_entities($start_time, $end_time, $type, $subtype,
@@ -559,9 +568,11 @@ $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
*
* @return string A viewable list of entities
* @access private
+ * @deprecated 1.9
*/
function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10,
$fullview = true, $listtypetoggle = false, $navigation = true) {
+ elgg_deprecated_notice('list_todays_entities() has been deprecated', 1.9);
$day_start = get_day_start();
$day_end = get_day_end();
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 08b346960..57d602450 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -107,7 +107,10 @@ function elgg_load_library($name) {
}
if (!include_once($CONFIG->libraries[$name])) {
- $error = elgg_echo('InvalidParameterException:LibraryNotRegistered', array($name));
+ $error = elgg_echo('InvalidParameterException:LibraryNotFound', array(
+ $name,
+ $CONFIG->libraries[$name])
+ );
throw new InvalidParameterException($error);
}
}
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index fd2b0e9f9..daced6740 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -124,8 +124,6 @@ function retrieve_cached_entity_row($guid) {
* @internal Subtypes are stored in the entity_subtypes table. There is a foreign
* key in the entities table.
*
- * @todo Move to a nicer place?
- *
* @param string $type Type
* @param string $subtype Subtype
*
@@ -144,7 +142,7 @@ function get_subtype_id($type, $subtype) {
return FALSE;
}
- // Todo: cache here? Or is looping less efficient that going to the db each time?
+ // @todo use the cache before hitting database
$result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes
where type='$type' and subtype='$subtype'");
@@ -163,8 +161,6 @@ function get_subtype_id($type, $subtype) {
/**
* Return string name for a given subtype ID.
*
- * @todo Move to a nicer place?
- *
* @param int $subtype_id Subtype ID
*
* @return string Subtype name
@@ -199,11 +195,11 @@ function get_subtype_from_id($subtype_id) {
}
/**
- * Return a classname for a registered type and subtype.
+ * Return the class name for a registered type and subtype.
*
* Entities can be registered to always be loaded as a certain class
- * with {@link register_entity_subtype()}. This function returns
- * the class name if found, and NULL if not.
+ * with add_subtype() or update_subtype(). This function returns the class
+ * name if found and NULL if not.
*
* @param string $type The type
* @param string $subtype The subtype
@@ -219,7 +215,7 @@ function get_subtype_class($type, $subtype) {
$type = sanitise_string($type);
$subtype = sanitise_string($subtype);
- // Todo: cache here? Or is looping less efficient that going to the db each time?
+ // @todo use the cache before going to the database
$result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes
where type='$type' and subtype='$subtype'");
@@ -236,7 +232,7 @@ function get_subtype_class($type, $subtype) {
}
/**
- * Returns the classname for a subtype id.
+ * Returns the class name for a subtype id.
*
* @param int $subtype_id The subtype id
*
@@ -279,6 +275,9 @@ function get_subtype_class_from_id($subtype_id) {
* it will be loaded as that class automatically when retrieved from the database with
* {@link get_entity()}.
*
+ * @warning This function cannot be used to change the class for a type-subtype pair.
+ * Use update_subtype() for that.
+ *
* @param string $type The type you're subtyping (site, user, object, or group)
* @param string $subtype The subtype
* @param string $class Optional class name for the object
@@ -670,7 +669,10 @@ function get_entity($guid) {
static $newentity_cache;
$new_entity = false;
- if (!is_numeric($guid)) {
+ // We could also use: if (!(int) $guid) { return FALSE },
+ // but that evaluates to a false positive for $guid = TRUE.
+ // This is a bit slower, but more thorough.
+ if (!is_numeric($guid) || $guid === 0 || $guid === '0') {
return FALSE;
}
@@ -1563,7 +1565,7 @@ function delete_entity($guid, $recursive = true) {
}
}
- return $res;
+ return (bool)$res;
}
}
}
@@ -2148,8 +2150,13 @@ function elgg_list_registered_entities(array $options = array()) {
}
}
- $count = elgg_get_entities(array_merge(array('count' => TRUE), $options));
- $entities = elgg_get_entities($options);
+ if (!empty($options['type_subtype_pairs'])) {
+ $count = elgg_get_entities(array_merge(array('count' => TRUE), $options));
+ $entities = elgg_get_entities($options);
+ } else {
+ $count = 0;
+ $entities = array();
+ }
return elgg_view_entity_list($entities, $count, $options['offset'],
$options['limit'], $options['full_view'], $options['list_type_toggle'], $options['pagination']);
diff --git a/engine/lib/languages.php b/engine/lib/languages.php
index 7607ea3bf..0400843af 100644
--- a/engine/lib/languages.php
+++ b/engine/lib/languages.php
@@ -301,4 +301,15 @@ function get_missing_language_keys($language) {
return false;
}
+/**
+ * Initialize the language library
+ * @access private
+ */
+function elgg_languages_init() {
+ $lang = get_current_language();
+ elgg_register_simplecache_view("cache/js/languages/$lang");
+}
+
+elgg_register_event_handler('init', 'system', 'elgg_languages_init');
+
register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/");
diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php
index 9dccec700..9fe9b4bff 100644
--- a/engine/lib/metastrings.php
+++ b/engine/lib/metastrings.php
@@ -810,7 +810,7 @@ function elgg_delete_metastring_based_object_by_id($id, $type) {
}
if (($obj->canEdit()) && (elgg_trigger_event('delete', $type, $obj))) {
- return delete_data("DELETE from $table where id=$id");
+ return (bool)delete_data("DELETE from $table where id=$id");
}
}
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 176790188..956ca220a 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -385,6 +385,55 @@ function elgg_entity_menu_setup($hook, $type, $return, $params) {
}
/**
+ * Widget menu is a set of widget controls
+ * @access private
+ */
+function elgg_widget_menu_setup($hook, $type, $return, $params) {
+
+ $widget = $params['entity'];
+ $show_edit = elgg_extract('show_edit', $params, true);
+
+ $collapse = array(
+ 'name' => 'collapse',
+ 'text' => ' ',
+ 'href' => "#elgg-widget-content-$widget->guid",
+ 'class' => 'elgg-widget-collapse-button',
+ 'rel' => 'toggle',
+ 'priority' => 1
+ );
+ $return[] = ElggMenuItem::factory($collapse);
+
+ if ($widget->canEdit()) {
+ $delete = array(
+ 'name' => 'delete',
+ 'text' => elgg_view_icon('delete-alt'),
+ 'title' => elgg_echo('widget:delete', array($widget->getTitle())),
+ 'href' => "action/widgets/delete?widget_guid=$widget->guid",
+ 'is_action' => true,
+ 'class' => 'elgg-widget-delete-button',
+ 'id' => "elgg-widget-delete-button-$widget->guid",
+ 'priority' => 900
+ );
+ $return[] = ElggMenuItem::factory($delete);
+
+ if ($show_edit) {
+ $edit = array(
+ 'name' => 'settings',
+ 'text' => elgg_view_icon('settings-alt'),
+ 'title' => elgg_echo('widget:edit'),
+ 'href' => "#widget-edit-$widget->guid",
+ 'class' => "elgg-widget-edit-button",
+ 'rel' => 'toggle',
+ 'priority' => 800,
+ );
+ $return[] = ElggMenuItem::factory($edit);
+ }
+ }
+
+ return $return;
+}
+
+/**
* Adds a delete link to "generic_comment" annotations
* @access private
*/
@@ -418,6 +467,7 @@ function elgg_nav_init() {
elgg_register_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup');
elgg_register_plugin_hook_handler('register', 'menu:river', 'elgg_river_menu_setup');
elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_entity_menu_setup');
+ elgg_register_plugin_hook_handler('register', 'menu:widget', 'elgg_widget_menu_setup');
elgg_register_plugin_hook_handler('register', 'menu:annotation', 'elgg_annotation_menu_setup');
}
diff --git a/engine/lib/output.php b/engine/lib/output.php
index 60bcc72cd..6554481f5 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -234,7 +234,7 @@ function elgg_clean_vars(array $vars = array()) {
*
* @example
* elgg_normalize_url(''); // 'http://my.site.com/'
- * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard'
+ * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard'
* elgg_normalize_url('http://google.com/'); // no change
* elgg_normalize_url('//google.com/'); // no change
*
@@ -257,6 +257,11 @@ function elgg_normalize_url($url) {
$validated = filter_var($url, FILTER_VALIDATE_URL);
}
+ // work around for handling absoluate IRIs (RFC 3987) - see #4190
+ if (!$validated && (strpos($url, 'http:') === 0) || (strpos($url, 'https:') === 0)) {
+ $validated = true;
+ }
+
if ($validated) {
// all normal URLs including mailto:
return $url;
@@ -306,6 +311,9 @@ function elgg_get_friendly_title($title) {
}
//$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title);
+
+ // use A-Za-z0-9_ instead of \w because \w is locale sensitive
+ $title = preg_replace("/[^A-Za-z0-9_ ]/", "", $title);
$title = preg_replace("/[^\w ]/", "", $title);
$title = str_replace(" ", "-", $title);
$title = str_replace("--", "-", $title);
diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php
index aba921416..ffcfc5b6a 100644
--- a/engine/lib/pagehandler.php
+++ b/engine/lib/pagehandler.php
@@ -110,3 +110,36 @@ function elgg_unregister_page_handler($handler) {
unset($CONFIG->pagehandler[$handler]);
}
+
+/**
+ * Serve an error page
+ *
+ * @todo not sending status codes yet
+ *
+ * @param string $hook The name of the hook
+ * @param string $type The type of the hook
+ * @param bool $result The current value of the hook
+ * @param array $params Parameters related to the hook
+ */
+function elgg_error_page_handler($hook, $type, $result, $params) {
+ if (elgg_view_exists("errors/$type")) {
+ $content = elgg_view("errors/$type", $params);
+ } else {
+ $content = elgg_view("errors/default", $params);
+ }
+ $body = elgg_view_layout('error', array('content' => $content));
+ echo elgg_view_page($title, $body, 'error');
+ exit;
+}
+
+/**
+ * Initializes the page handler/routing system
+ *
+ * @return void
+ * @access private
+ */
+function page_handler_init() {
+ elgg_register_plugin_hook_handler('forward', '404', 'elgg_error_page_handler');
+}
+
+elgg_register_event_handler('init', 'system', 'page_handler_init');
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index 3578f0cb8..5b7080b56 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -158,7 +158,7 @@ function remove_entity_relationship($guid_one, $relationship, $guid_two) {
and relationship='$relationship'
and guid_two=$guid_two";
- return delete_data($query);
+ return (bool)delete_data($query);
} else {
return false;
}
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 466eca253..421813441 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -207,6 +207,8 @@ function elgg_delete_river(array $options = array()) {
/**
* Get river items
*
+ * @note If using types and subtypes in a query, they are joined with an AND.
+ *
* @param array $options
* ids => INT|ARR River item id(s)
* subject_guids => INT|ARR Subject guid(s)
@@ -430,7 +432,6 @@ function elgg_river_get_access_sql() {
*
* @internal This is a simplified version of elgg_get_entity_type_subtype_where_sql()
* which could be used for all queries once the subtypes have been denormalized.
- * FYI: It allows types and subtypes to not be paired.
*
* @param string $table 'rv'
* @param NULL|array $types Array of types or NULL if none.
@@ -447,7 +448,8 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
return '';
}
- $wheres = array();
+ $types_wheres = array();
+ $subtypes_wheres = array();
// if no pairs, use types and subtypes
if (!is_array($pairs)) {
@@ -457,7 +459,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($types as $type) {
$type = sanitise_string($type);
- $wheres[] = "({$table}.type = '$type')";
+ $types_wheres[] = "({$table}.type = '$type')";
}
}
@@ -467,13 +469,20 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($subtypes as $subtype) {
$subtype = sanitise_string($subtype);
- $wheres[] = "({$table}.subtype = '$subtype')";
+ $subtypes_wheres[] = "({$table}.subtype = '$subtype')";
}
}
- if (is_array($wheres) && count($wheres)) {
- $wheres = array(implode(' OR ', $wheres));
+ if (is_array($types_wheres) && count($types_wheres)) {
+ $types_wheres = array(implode(' OR ', $types_wheres));
+ }
+
+ if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
+ $subtypes_wheres = array('(' . implode(' OR ', $subtypes_wheres) . ')');
}
+
+ $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres)));
+
} else {
// using type/subtype pairs
foreach ($pairs as $paired_type => $paired_subtypes) {
@@ -611,6 +620,16 @@ function elgg_river_page_handler($page) {
}
/**
+ * Register river unit tests
+ * @access private
+ */
+function elgg_river_test($hook, $type, $value) {
+ global $CONFIG;
+ $value[] = $CONFIG->path . 'engine/tests/api/river.php';
+ return $value;
+}
+
+/**
* Initialize river library
* @access private
*/
@@ -620,6 +639,8 @@ function elgg_river_init() {
elgg_register_menu_item('site', $item);
elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description'));
+
+ elgg_register_plugin_hook_handler('unit_test', 'system', 'elgg_river_test');
}
elgg_register_event_handler('init', 'system', 'elgg_river_init');
diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php
index 1e2d6db10..af30d8f0d 100644
--- a/engine/lib/user_settings.php
+++ b/engine/lib/user_settings.php
@@ -265,8 +265,8 @@ function elgg_set_user_default_access() {
* @access private
*/
function usersettings_pagesetup() {
- if (elgg_get_context() == "settings" && elgg_get_logged_in_user_guid()) {
- $user = elgg_get_logged_in_user_entity();
+ if (elgg_get_context() == "settings") {
+ $user = elgg_get_page_owner_entity();
$params = array(
'name' => '1_account',
@@ -346,6 +346,13 @@ function usersettings_init() {
elgg_register_plugin_hook_handler('usersettings:save', 'user', 'users_settings_save');
elgg_register_action("usersettings/save");
+
+ // extend the account settings form
+ elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100);
+ elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100);
+ elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100);
+ elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100);
+ elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100);
}
elgg_register_event_handler('init', 'system', 'usersettings_init');
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 9cb8ddfa7..1b3cca799 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -565,6 +565,8 @@ function get_user_by_username($username) {
$entity = get_data_row($query, 'entity_row_to_elggstar');
if ($entity) {
$USERNAME_TO_GUID_MAP_CACHE[$username] = $entity->guid;
+ } else {
+ $entity = false;
}
return $entity;
@@ -1019,7 +1021,7 @@ function elgg_get_user_validation_status($user_guid) {
return;
}
- if ($md->value) {
+ if ($md[0]->value) {
return true;
}
@@ -1281,6 +1283,11 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
$item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('admin');
$return[] = $item;
+
+ $url = "settings/user/$user->username";
+ $item = new ElggMenuItem('settings:edit', elgg_echo('settings:edit'), $url);
+ $item->setSection('admin');
+ $return[] = $item;
}
return $return;
@@ -1555,13 +1562,6 @@ function users_init() {
elgg_register_widget_type('friends', elgg_echo('friends'), elgg_echo('friends:widget:description'));
- // extend the account settings form
- elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100);
- elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100);
- elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100);
- elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100);
- elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100);
-
// Register the user type
elgg_register_entity_type('user', '');
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 0f806b8be..b938dd60e 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1598,10 +1598,10 @@ function elgg_views_boot() {
elgg_load_js('jquery');
elgg_load_js('jquery-ui');
- elgg_load_js('jquery.form');
elgg_load_js('elgg');
elgg_register_simplecache_view('js/lightbox');
+ elgg_register_simplecache_view('css/lightbox');
$lightbox_js_url = elgg_get_simplecache_url('js', 'lightbox');
elgg_register_js('lightbox', $lightbox_js_url);
$lightbox_css_url = elgg_get_simplecache_url('css', 'lightbox');
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 5d18a16b0..46f34391a 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -332,14 +332,14 @@ function elgg_default_widgets_init() {
* @param string $event The event
* @param string $type The type of object
* @param object $entity The entity being created
- * @return null
+ * @return void
* @access private
*/
function elgg_create_default_widgets($event, $type, $entity) {
$default_widget_info = elgg_get_config('default_widget_info');
if (!$default_widget_info || !$entity) {
- return null;
+ return;
}
$type = $entity->getType();
@@ -347,53 +347,48 @@ function elgg_create_default_widgets($event, $type, $entity) {
// event is already guaranteed by the hook registration.
// need to check subtype and type.
- foreach ($default_widget_info as $temp) {
- if ($temp['entity_type'] == $type) {
- if ($temp['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $temp['entity_subtype'] == $subtype) {
- $info = $temp;
- break;
+ foreach ($default_widget_info as $info) {
+ if ($info['entity_type'] == $type) {
+ if ($info['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $info['entity_subtype'] == $subtype) {
+
+ // need to be able to access everything
+ $old_ia = elgg_set_ignore_access(true);
+ elgg_push_context('create_default_widgets');
+
+ // pull in by widget context with widget owners as the site
+ // not using elgg_get_widgets() because it sorts by columns and we don't care right now.
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'widget',
+ 'owner_guid' => elgg_get_site_entity()->guid,
+ 'private_setting_name' => 'context',
+ 'private_setting_value' => $info['widget_context'],
+ 'limit' => 0
+ );
+
+ $widgets = elgg_get_entities_from_private_settings($options);
+
+ foreach ($widgets as $widget) {
+ // change the container and owner
+ $new_widget = clone $widget;
+ $new_widget->container_guid = $entity->guid;
+ $new_widget->owner_guid = $entity->guid;
+
+ // pull in settings
+ $settings = get_all_private_settings($widget->guid);
+
+ foreach ($settings as $name => $value) {
+ $new_widget->$name = $value;
+ }
+
+ $new_widget->save();
+ }
+
+ elgg_set_ignore_access($old_ia);
+ elgg_pop_context();
}
}
}
-
- // need to be able to access everything
- $old_ia = elgg_get_ignore_access(true);
- elgg_push_context('create_default_widgets');
-
- // pull in by widget context with widget owners as the site
- // not using elgg_get_widgets() because it sorts by columns and we don't care right now.
- $options = array(
- 'type' => 'object',
- 'subtype' => 'widget',
- 'owner_guid' => elgg_get_site_entity()->guid,
- 'private_setting_name' => 'context',
- 'private_setting_value' => $info['widget_context'],
- 'limit' => 0
- );
-
- $widgets = elgg_get_entities_from_private_settings($options);
-
- foreach ($widgets as $widget) {
- // change the container and owner
- $new_widget = clone $widget;
- $new_widget->container_guid = $entity->guid;
- $new_widget->owner_guid = $entity->guid;
-
- // pull in settings
- $settings = get_all_private_settings($widget->guid);
-
- foreach ($settings as $name => $value) {
- $new_widget->$name = $value;
- }
-
- $new_widget->save();
- }
-
- elgg_get_ignore_access($old_ia);
- elgg_pop_context();
-
- // failure here shouldn't stop the event.
- return null;
}
/**
diff --git a/engine/lib/xml-rpc.php b/engine/lib/xml-rpc.php
deleted file mode 100644
index bfe1a8645..000000000
--- a/engine/lib/xml-rpc.php
+++ /dev/null
@@ -1,203 +0,0 @@
-<?php
-/**
- * Elgg XML-RPC library.
- * Contains functions and classes to handle XML-RPC services, currently only server only.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-
-/**
- * parse XMLRPCCall parameters
- *
- * Convert an XMLRPCCall result array into native data types
- *
- * @param array $parameters An array of params
- *
- * @return array
- * @access private
- */
-function xmlrpc_parse_params($parameters) {
- $result = array();
-
- foreach ($parameters as $parameter) {
- $result[] = xmlrpc_scalar_value($parameter);
- }
-
- return $result;
-}
-
-/**
- * Extract the scalar value of an XMLObject type result array
- *
- * @param XMLObject $object And object
- *
- * @return mixed
- * @access private
- */
-function xmlrpc_scalar_value($object) {
- if ($object->name == 'param') {
- $object = $object->children[0]->children[0];
- }
-
- switch ($object->name) {
- case 'string':
- return $object->content;
-
- case 'array':
- foreach ($object->children[0]->children as $child) {
- $value[] = xmlrpc_scalar_value($child);
- }
- return $value;
-
- case 'struct':
- foreach ($object->children as $child) {
- if (isset($child->children[1]->children[0])) {
- $value[$child->children[0]->content] = xmlrpc_scalar_value($child->children[1]->children[0]);
- } else {
- $value[$child->children[0]->content] = $child->children[1]->content;
- }
- }
- return $value;
-
- case 'boolean':
- return (boolean) $object->content;
-
- case 'i4':
- case 'int':
- return (int) $object->content;
-
- case 'double':
- return (double) $object->content;
-
- case 'dateTime.iso8601':
- return (int) strtotime($object->content);
-
- case 'base64':
- return base64_decode($object->content);
-
- case 'value':
- return xmlrpc_scalar_value($object->children[0]);
-
- default:
- // @todo unsupported, throw an error
- return false;
- }
-}
-
-// Functions for adding handlers //////////////////////////////////////////////////////////
-
-/** XML-RPC Handlers */
-global $XML_RPC_HANDLERS;
-$XML_RPC_HANDLERS = array();
-
-/**
- * Register a method handler for a given XML-RPC method.
- *
- * @param string $method Method parameter.
- * @param string $handler The handler function. This function accepts
- * one XMLRPCCall object and must return a XMLRPCResponse object.
- *
- * @return bool
- */
-function register_xmlrpc_handler($method, $handler) {
- global $XML_RPC_HANDLERS;
-
- $XML_RPC_HANDLERS[$method] = $handler;
-}
-
-/**
- * Trigger a method call and pass the relevant parameters to the funciton.
- *
- * @param XMLRPCCall $parameters The call and parameters.
- *
- * @return XMLRPCCall
- * @access private
- */
-function trigger_xmlrpc_handler(XMLRPCCall $parameters) {
- global $XML_RPC_HANDLERS;
-
- // Go through and see if we have a handler
- if (isset($XML_RPC_HANDLERS[$parameters->getMethodName()])) {
- $handler = $XML_RPC_HANDLERS[$parameters->getMethodName()];
- $result = $handler($parameters);
-
- if (!($result instanceof XMLRPCResponse)) {
- $msg = elgg_echo('InvalidParameterException:UnexpectedReturnFormat',
- array($parameters->getMethodName()));
- throw new InvalidParameterException($msg);
- }
-
- // Result in right format, return it.
- return $result;
- }
-
- // if no handler then throw exception
- $msg = elgg_echo('NotImplementedException:XMLRPCMethodNotImplemented',
- array($parameters->getMethodName()));
- throw new NotImplementedException($msg);
-}
-
-/**
- * PHP Error handler function.
- * This function acts as a wrapper to catch and report PHP error messages.
- *
- * @see http://uk3.php.net/set-error-handler
- *
- * @param int $errno Error number
- * @param string $errmsg Human readable message
- * @param string $filename Filename
- * @param int $linenum Line number
- * @param array $vars Vars
- *
- * @return void
- * @access private
- */
-function _php_xmlrpc_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
- $error = date("Y-m-d H:i:s (T)") . ": \"" . $errmsg . "\" in file "
- . $filename . " (line " . $linenum . ")";
-
- switch ($errno) {
- case E_USER_ERROR:
- error_log("ERROR: " . $error);
-
- // Since this is a fatal error, we want to stop any further execution but do so gracefully.
- throw new Exception("ERROR: " . $error);
- break;
-
- case E_WARNING :
- case E_USER_WARNING :
- error_log("WARNING: " . $error);
- break;
-
- default:
- error_log("DEBUG: " . $error);
- }
-}
-
-/**
- * PHP Exception handler for XMLRPC.
- *
- * @param Exception $exception The exception
- *
- * @return void
- * @access private
- */
-function _php_xmlrpc_exception_handler($exception) {
-
- error_log("*** FATAL EXCEPTION (XML-RPC) *** : " . $exception);
-
- $code = $exception->getCode();
-
- if ($code == 0) {
- $code = -32400;
- }
-
- $result = new XMLRPCErrorResponse($exception->getMessage(), $code);
-
- $vars = array('result' => $result);
-
- $content = elgg_view("xml-rpc/output", $vars);
-
- echo elgg_view_page($exception->getMessage(), $content);
-}