aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-01 06:36:29 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-01 06:36:29 +0000
commitbeaaf5c3bdc700a872df2b7a39e268ce36cc0012 (patch)
treed0cb1da31f2895f01683ed8ae8b8a12617636efe
parent95caad1ac699e356b424cc9151ce8c91e1cb6221 (diff)
downloadelgg-beaaf5c3bdc700a872df2b7a39e268ce36cc0012.tar.gz
elgg-beaaf5c3bdc700a872df2b7a39e268ce36cc0012.tar.bz2
Reversing 7975
git-svn-id: http://code.elgg.org/elgg/trunk@7978 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/access.php98
-rw-r--r--engine/lib/actions.php17
-rw-r--r--engine/lib/admin.php25
-rw-r--r--engine/lib/annotations.php350
-rw-r--r--engine/lib/deprecated.php1761
-rw-r--r--engine/lib/elgglib.php320
-rw-r--r--engine/lib/entities.php260
-rw-r--r--engine/lib/group.php469
-rw-r--r--engine/lib/install.php10
-rw-r--r--engine/lib/location.php156
-rw-r--r--engine/lib/mb_wrapper.php2
-rw-r--r--engine/lib/metadata.php236
-rw-r--r--engine/lib/metastrings.php2
-rw-r--r--engine/lib/navigation.php116
-rw-r--r--engine/lib/objects.php90
-rw-r--r--engine/lib/output.php95
-rw-r--r--engine/lib/pageowner.php83
-rw-r--r--engine/lib/plugins.php295
-rw-r--r--engine/lib/private_settings.php163
19 files changed, 2780 insertions, 1768 deletions
diff --git a/engine/lib/access.php b/engine/lib/access.php
index ae95982e6..de246ee20 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -744,6 +744,83 @@ function elgg_view_access_collections($owner_guid) {
}
/**
+ * Get entities with the specified access collection id.
+ *
+ * @deprecated 1.7. Use elgg_get_entities_from_access_id()
+ *
+ * @param int $collection_id ID of collection
+ * @param string $entity_type Type of entities
+ * @param string $entity_subtype Subtype of entities
+ * @param int $owner_guid Guid of owner
+ * @param int $limit Limit of number of entities to return
+ * @param int $offset Skip this many entities
+ * @param string $order_by Column to order by
+ * @param int $site_guid The site guid
+ * @param bool $count Return a count or entities
+ *
+ * @return array
+ */
+function get_entities_from_access_id($collection_id, $entity_type = "", $entity_subtype = "",
+ $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
+ // log deprecated warning
+ elgg_deprecated_notice('get_entities_from_access_id() was deprecated by elgg_get_entities()', 1.7);
+
+ if (!$collection_id) {
+ return FALSE;
+ }
+
+ // build the options using given parameters
+ $options = array();
+ $options['limit'] = $limit;
+ $options['offset'] = $offset;
+ $options['count'] = $count;
+
+ if ($entity_type) {
+ $options['type'] = sanitise_string($entity_type);
+ }
+
+ if ($entity_subtype) {
+ $options['subtype'] = $entity_subtype;
+ }
+
+ if ($site_guid) {
+ $options['site_guid'] = $site_guid;
+ }
+
+ if ($order_by) {
+ $options['order_by'] = sanitise_string("e.time_created, $order_by");
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ if ($site_guid) {
+ $options['site_guid'] = $site_guid;
+ }
+
+ $options['access_id'] = $collection_id;
+
+ return elgg_get_entities_from_access_id($options);
+}
+
+/**
+ * @deprecated 1.7
+ */
+function get_entities_from_access_collection($collection_id, $entity_type = "", $entity_subtype = "",
+ $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
+
+ elgg_deprecated_notice('get_entities_from_access_collection() was deprecated by elgg_get_entities()', 1.7);
+
+ return get_entities_from_access_id($collection_id, $entity_type, $entity_subtype,
+ $owner_guid, $limit, $offset, $order_by, $site_guid, $count);
+}
+
+/**
* Return entities based upon access id.
*
* @param array $options Any options accepted by {@link elgg_get_entities()} and:
@@ -790,6 +867,27 @@ function elgg_list_entities_from_access_id(array $options = array()) {
}
/**
+ * @return str
+ * @deprecated 1.8 Use elgg_list_entities_from_access_id()
+ */
+function list_entities_from_access_id($access_id, $entity_type = "", $entity_subtype = "",
+ $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
+
+ elgg_deprecated_notice("All list_entities* functions were deprecated in 1.8. Use elgg_list_entities* instead.", 1.8);
+
+ echo elgg_list_entities_from_access_id(array(
+ 'access_id' => $access_id,
+ 'types' => $entity_type,
+ 'subtypes' => $entity_subtype,
+ 'owner_guids' => $owner_guid,
+ 'limit' => $limit,
+ 'full_view' => $fullview,
+ 'list_type_toggle' => $listtypetoggle,
+ 'pagination' => $pagination,
+ ));
+}
+
+/**
* Return the name of an ACCESS_* constant or a access collection,
* but only if the user has write access on that ACL.
*
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index 0691e306a..d95fe0435 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -181,6 +181,23 @@ function elgg_register_action($action, $filename = "", $access = 'logged_in') {
}
/**
+ * @deprecated 1.8 Use {@link elgg_register_action()} instead
+ */
+function register_action($action, $public = false, $filename = "", $admin_only = false) {
+ elgg_deprecated_notice("register_action() was deprecated by elgg_register_action()", 1.8);
+
+ if ($admin_only) {
+ $access = 'admin';
+ } elseif ($public) {
+ $access = 'public';
+ } else {
+ $access = 'logged_in';
+ }
+
+ return elgg_register_action($action, $filename, $access);
+}
+
+/**
* Validate an action token.
*
* Calls to actions will automatically validate tokens.
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index c26ba131c..c8254a0ff 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -8,6 +8,30 @@
*/
/**
+ * Register an admin page with the admin panel.
+ * This function extends the view "admin/main" with the provided view.
+ * This view should provide a description and either a control or a link to.
+ *
+ * Usage:
+ * - To add a control to the main admin panel then extend admin/main
+ * - To add a control to a new page create a page which renders a view admin/subpage
+ * (where subpage is your new page -
+ * nb. some pages already exist that you can extend), extend the main view to point to it,
+ * and add controls to your new view.
+ *
+ * At the moment this is essentially a wrapper around elgg_extend_view().
+ *
+ * @param string $new_admin_view The view associated with the control you're adding
+ * @param string $view The view to extend, by default this is 'admin/main'.
+ * @param int $priority Optional priority to govern the appearance in the list.
+ *
+ * @return void
+ */
+function extend_elgg_admin_page($new_admin_view, $view = 'admin/main', $priority = 500) {
+ elgg_deprecated_notice('extend_elgg_admin_page() does nothing. Extend admin views manually.', 1.8);
+}
+
+/**
* Create the plugin settings submenu.
*
* This is done in a separate function called from the admin
@@ -253,6 +277,7 @@ function elgg_add_admin_notice($id, $message) {
return FALSE;
}
+
/**
* Remove an admin notice by ID.
*
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 035c5e705..f069e1d05 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -408,6 +408,160 @@ function elgg_get_entities_from_annotations(array $options = array()) {
}
/**
+ * Get entities from annotations
+ *
+ * No longer used.
+ *
+ * @deprecated 1.7 Use elgg_get_entities_from_annotations()
+ *
+ * @param mixed $entity_type Type of entity
+ * @param mixed $entity_subtype Subtype of entity
+ * @param string $name Name of annotation
+ * @param string $value Value of annotation
+ * @param int $owner_guid Guid of owner of annotation
+ * @param int $group_guid Guid of group
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @param string $order_by SQL order by string
+ * @param bool $count Count or return entities
+ * @param int $timelower Lower time limit
+ * @param int $timeupper Upper time limit
+ *
+ * @return unknown_type
+ */
+function get_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "",
+$value = "", $owner_guid = 0, $group_guid = 0, $limit = 10, $offset = 0, $order_by = "asc",
+$count = false, $timelower = 0, $timeupper = 0) {
+ $msg = 'get_entities_from_annotations() is deprecated by elgg_get_entities_from_annotations().';
+ elgg_deprecated_notice($msg, 1.7);
+
+ $options = array();
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
+ }
+
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
+
+ $options['annotation_names'] = $name;
+
+ if ($value) {
+ $options['annotation_values'] = $value;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['annotation_owner_guids'] = $owner_guid;
+ } else {
+ $options['annotation_owner_guid'] = $owner_guid;
+ }
+ }
+
+ if ($group_guid) {
+ $options['container_guid'] = $group_guid;
+ }
+
+ if ($limit) {
+ $options['limit'] = $limit;
+ }
+
+ if ($offset) {
+ $options['offset'] = $offset;
+ }
+
+ if ($order_by) {
+ $options['order_by'] = "maxtime $order_by";
+ }
+
+ if ($count) {
+ $options['count'] = $count;
+ }
+
+ if ($timelower) {
+ $options['annotation_created_time_lower'] = $timelower;
+ }
+
+ if ($timeupper) {
+ $options['annotation_created_time_upper'] = $timeupper;
+ }
+
+ return elgg_get_entities_from_annotations($options);
+}
+
+/**
+ * Lists entities
+ *
+ * @see elgg_view_entity_list
+ *
+ * @param string $entity_type Type of entity.
+ * @param string $entity_subtype Subtype of entity.
+ * @param string $name Name of annotation.
+ * @param string $value Value of annotation.
+ * @param int $limit Maximum number of results to return.
+ * @param int $owner_guid Owner.
+ * @param int $group_guid Group container. Currently only supported if entity_type is object
+ * @param boolean $asc Whether to list in ascending or descending order (default: desc)
+ * @param boolean $fullview Whether to display the entities in full
+ * @param boolean $listtypetoggle Can 'gallery' view can be displayed (default: no)
+ *
+ * @deprecated 1.7 Use elgg_list_entities_from_annotations()
+ * @return string Formatted entity list
+ */
+function list_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "",
+$value = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true,
+$listtypetoggle = false) {
+
+ $msg = 'list_entities_from_annotations is deprecated by elgg_list_entities_from_annotations';
+ elgg_deprecated_notice($msg, 1.8);
+
+ $options = array();
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
+ }
+
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
+
+ if ($name) {
+ $options['annotation_names'] = $name;
+ }
+
+ if ($value) {
+ $options['annotation_values'] = $value;
+ }
+
+ if ($limit) {
+ $options['limit'] = $limit;
+ }
+
+ if ($owner_guid) {
+ $options['annotation_owner_guid'] = $owner_guid;
+ }
+
+ if ($group_guid) {
+ $options['container_guid'] = $group_guid;
+ }
+
+ if ($asc) {
+ $options['order_by'] = 'maxtime desc';
+ }
+
+ if ($offset = sanitise_int(get_input('offset', null))) {
+ $options['offset'] = $offset;
+ }
+
+ $options['full_view'] = $fullview;
+ $options['list_type_toggle'] = $listtypetoggle;
+ $options['pagination'] = $pagination;
+
+ return elgg_list_entities_from_annotations($options);
+}
+
+/**
* Returns a viewable list of entities from annotations.
*
* @param array $options Options array
@@ -696,6 +850,140 @@ function elgg_get_entities_from_annotation_calculation($options) {
}
/**
+ * Get entities ordered by a mathematical calculation
+ *
+ * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation()
+ *
+ * @param string $sum What sort of calculation to perform
+ * @param string $entity_type Type of Entity
+ * @param string $entity_subtype Subtype of Entity
+ * @param string $name Name of annotation
+ * @param string $mdname Metadata name
+ * @param string $mdvalue Metadata value
+ * @param int $owner_guid GUID of owner of annotation
+ * @param int $limit Limit of results
+ * @param int $offset Offset of results
+ * @param string $orderdir Order of results
+ * @param bool $count Return count or entities
+ *
+ * @return mixed
+ */
+function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "",
+$entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0,
+$limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
+
+ $msg = 'get_entities_from_annotations_calculate_x() is deprecated by elgg_get_entities_from_annotation_calculation().';
+
+ elgg_deprecated_notice($msg, 1.8);
+
+ $options = array();
+
+ $options['calculation'] = $sum;
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
+ }
+
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
+
+ $options['annotation_names'] = $name;
+
+ if ($mdname) {
+ $options['metadata_names'] = $mdname;
+ }
+
+ if ($mdvalue) {
+ $options['metadata_values'] = $mdvalue;
+ }
+
+ // original function rewrote this to container guid.
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['container_guids'] = $owner_guid;
+ } else {
+ $options['container_guid'] = $owner_guid;
+ }
+ }
+
+ $options['limit'] = $limit;
+ $options['offset'] = $offset;
+
+ $options['order_by'] = "calculated $orderdir";
+
+ $options['count'] = $count;
+
+ return elgg_get_entities_from_annotation_calculation($options);
+}
+
+/**
+ * Returns entities ordered by the sum of an annotation
+ *
+ * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation()
+ *
+ * @param string $entity_type Type of Entity
+ * @param string $entity_subtype Subtype of Entity
+ * @param string $name Name of annotation
+ * @param string $mdname Metadata name
+ * @param string $mdvalue Metadata value
+ * @param int $owner_guid GUID of owner of annotation
+ * @param int $limit Limit of results
+ * @param int $offset Offset of results
+ * @param string $orderdir Order of results
+ * @param bool $count Return count or entities
+ *
+ * @return unknown
+ */
+function get_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "",
+$mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc',
+$count = false) {
+
+ $msg = 'get_entities_from_annotation_count() is deprecated by elgg_get_entities_from_annotation_calculation().';
+
+ elgg_deprecated_notice($msg, 1.8);
+
+ $options = array();
+
+ $options['calculation'] = 'sum';
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
+ }
+
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
+
+ $options['annotation_names'] = $name;
+
+ if ($mdname) {
+ $options['metadata_names'] = $mdname;
+ }
+
+ if ($mdvalue) {
+ $options['metadata_values'] = $mdvalue;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ $options['limit'] = $limit;
+ $options['offset'] = $offset;
+
+ $options['order_by'] = "calculated $orderdir";
+
+ $options['count'] = $count;
+
+ return elgg_get_entities_from_annotation_calculation($options);
+}
+
+/**
* List entities from an annotation calculation.
*
* @see elgg_get_entities_from_annotation_calculation()
@@ -709,6 +997,68 @@ function elgg_list_entities_from_annotation_calculation($options) {
}
/**
+ * Lists entities by the totals of a particular kind of annotation
+ *
+ * @deprecated 1.8 Use elgg_list_entities_from_annotation_calculation()
+ *
+ * @param string $entity_type Type of entity.
+ * @param string $entity_subtype Subtype of entity.
+ * @param string $name Name of annotation.
+ * @param int $limit Maximum number of results to return.
+ * @param int $owner_guid Owner.
+ * @param int $group_guid Group container. Currently only supported if entity_type is object
+ * @param boolean $asc Whether to list in ascending or descending order (default: desc)
+ * @param boolean $fullview Whether to display the entities in full
+ * @param boolean $listtypetoggle Can the 'gallery' view can be displayed (default: no)
+ * @param boolean $pagination Add pagination
+ * @param string $orderdir Order desc or asc
+ *
+ * @return string Formatted entity list
+ */
+function list_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "",
+$limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true,
+$listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
+
+ $msg = 'list_entities_from_annotation_count() is deprecated by elgg_list_entities_from_annotation_calculation().';
+
+ elgg_deprecated_notice($msg, 1.8);
+
+ $options = array();
+
+ $options['calculation'] = 'sum';
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
+ }
+
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
+
+ $options['annotation_names'] = $name;
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ $options['full_view'] = $fullview;
+
+ $options['list_type_toggle'] = $listtypetoggle;
+
+ $options['pagination'] = $pagination;
+
+ $options['limit'] = $limit;
+
+ $options['order_by'] = "calculated $orderdir";
+
+ return elgg_get_entities_from_annotation_calculation($options);
+}
+
+/**
* Lists entities by the totals of a particular kind of annotation AND
* the value of a piece of metadata
*
diff --git a/engine/lib/deprecated.php b/engine/lib/deprecated.php
deleted file mode 100644
index 94d3fdd9b..000000000
--- a/engine/lib/deprecated.php
+++ /dev/null
@@ -1,1761 +0,0 @@
-<?php
-/**
- * @deprecated 1.6
- */
-function delete_group_entity($guid) {
- elgg_deprecated_notice("delete_group_entity has been deprecated", 1.6);
-
- // Always return that we have deleted one row in order to not break existing code.
- return 1;
-}
-
-
-/**#@+
- * @deprecated 1.7
- */
-
-function get_entities_from_access_id($collection_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
- // log deprecated warning
- elgg_deprecated_notice('get_entities_from_access_id() was deprecated by elgg_get_entities()', 1.7);
-
- if (!$collection_id) {
- return FALSE;
- }
-
- // build the options using given parameters
- $options = array();
- $options['limit'] = $limit;
- $options['offset'] = $offset;
- $options['count'] = $count;
-
- if ($entity_type) {
- $options['type'] = sanitise_string($entity_type);
- }
-
- if ($entity_subtype) {
- $options['subtype'] = $entity_subtype;
- }
-
- if ($site_guid) {
- $options['site_guid'] = $site_guid;
- }
-
- if ($order_by) {
- $options['order_by'] = sanitise_string("e.time_created, $order_by");
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- if ($site_guid) {
- $options['site_guid'] = $site_guid;
- }
-
- $options['access_id'] = $collection_id;
-
- return elgg_get_entities_from_access_id($options);
-}
-
-function get_entities_from_access_collection($collection_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
-
- elgg_deprecated_notice('get_entities_from_access_collection() was deprecated by elgg_get_entities()', 1.7);
-
- return get_entities_from_access_id($collection_id, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, $order_by, $site_guid, $count);
-}
-
-function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0, $timeupper = 0) {
-
- elgg_deprecated_notice('get_entities() was deprecated by elgg_get_entities().', 1.7);
-
- // rewrite owner_guid to container_guid to emulate old functionality
- if ($owner_guid != "") {
- if (is_null($container_guid)) {
- $container_guid = $owner_guid;
- $owner_guid = NULL;
- }
- }
-
- $options = array();
- if ($type) {
- if (is_array($type)) {
- $options['types'] = $type;
- } else {
- $options['type'] = $type;
- }
- }
-
- if ($subtype) {
- if (is_array($subtype)) {
- $options['subtypes'] = $subtype;
- } else {
- $options['subtype'] = $subtype;
- }
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- if ($order_by) {
- $options['order_by'] = $order_by;
- }
-
- // need to pass 0 for all option
- $options['limit'] = $limit;
-
- if ($offset) {
- $options['offset'] = $offset;
- }
-
- if ($count) {
- $options['count'] = $count;
- }
-
- if ($site_guid) {
- $options['site_guids'] = $site_guid;
- }
-
- if ($container_guid) {
- $options['container_guids'] = $container_guid;
- }
-
- if ($timeupper) {
- $options['created_time_upper'] = $timeupper;
- }
-
- if ($timelower) {
- $options['created_time_lower'] = $timelower;
- }
-
- $r = elgg_get_entities($options);
- return $r;
-}
-
-function list_entities($type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $pagination = true) {
-
- elgg_deprecated_notice('list_entities() was deprecated by elgg_list_entities()!', 1.7);
-
- $options = array();
-
- // rewrite owner_guid to container_guid to emulate old functionality
- if ($owner_guid) {
- $options['container_guids'] = $owner_guid;
- }
-
- if ($type) {
- $options['types'] = $type;
- }
-
- if ($subtype) {
- $options['subtypes'] = $subtype;
- }
-
- if ($limit) {
- $options['limit'] = $limit;
- }
-
- if ($offset = sanitise_int(get_input('offset', null))) {
- $options['offset'] = $offset;
- }
-
- $options['full_view'] = $fullview;
- $options['list_type_toggle'] = $listtypetoggle;
- $options['pagination'] = $pagination;
-
- return elgg_list_entities($options);
-}
-
-function delete_entities($type = "", $subtype = "", $owner_guid = 0) {
- elgg_deprecated_notice('delete_entities() was deprecated because no one should use it.', 1.7);
- return false;
-}
-
-function elgg_validate_action_url($url) {
- elgg_deprecated_notice('elgg_validate_action_url() deprecated by elgg_add_action_tokens_to_url().', '1.7b');
-
- return elgg_add_action_tokens_to_url($url);
-}
-
-function test_ip() {
- elgg_deprecated_notice('test_ip() was removed because of licensing issues.', 1.7);
-
- return 0;
-}
-
-function is_ip_in_array() {
- elgg_deprecated_notice('is_ip_in_array() was removed because of licensing issues.', 1.7);
-
- return false;
-}
-
-function list_registered_entities($owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $allowedtypes = true) {
-
- elgg_deprecated_notice('list_registered_entities() was deprecated by elgg_list_registered_entities().', 1.7);
-
- $options = array();
-
- // don't want to send anything if not being used.
- if ($owner_guid) {
- $options['owner_guid'] = $owner_guid;
- }
-
- if ($limit) {
- $options['limit'] = $limit;
- }
-
- if ($allowedtypes) {
- $options['allowed_types'] = $allowedtypes;
- }
-
- // need to send because might be BOOL
- $options['full_view'] = $fullview;
- $options['list_type_toggle'] = $listtypetoggle;
-
- $options['offset'] = get_input('offset', 0);
-
- return elgg_list_registered_entities($options);
-}
-
-function get_library_files($directory, $exceptions = array(), $list = array()) {
- elgg_deprecated_notice('get_library_files() deprecated by elgg_get_file_list()', 1.7);
- return elgg_get_file_list($directory, $exceptions, $list, array('.php'));
-}
-
-function get_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "", $value = "", $owner_guid = 0, $group_guid = 0, $limit = 10, $offset = 0, $order_by = "asc", $count = false, $timelower = 0, $timeupper = 0) {
- $msg = 'get_entities_from_annotations() is deprecated by elgg_get_entities_from_annotations().';
- elgg_deprecated_notice($msg, 1.7);
-
- $options = array();
-
- if ($entity_type) {
- $options['types'] = $entity_type;
- }
-
- if ($entity_subtype) {
- $options['subtypes'] = $entity_subtype;
- }
-
- $options['annotation_names'] = $name;
-
- if ($value) {
- $options['annotation_values'] = $value;
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['annotation_owner_guids'] = $owner_guid;
- } else {
- $options['annotation_owner_guid'] = $owner_guid;
- }
- }
-
- if ($group_guid) {
- $options['container_guid'] = $group_guid;
- }
-
- if ($limit) {
- $options['limit'] = $limit;
- }
-
- if ($offset) {
- $options['offset'] = $offset;
- }
-
- if ($order_by) {
- $options['order_by'] = "maxtime $order_by";
- }
-
- if ($count) {
- $options['count'] = $count;
- }
-
- if ($timelower) {
- $options['annotation_created_time_lower'] = $timelower;
- }
-
- if ($timeupper) {
- $options['annotation_created_time_upper'] = $timeupper;
- }
-
- return elgg_get_entities_from_annotations($options);
-}
-
-function list_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "", $value = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true, $listtypetoggle = false) {
-
- $msg = 'list_entities_from_annotations is deprecated by elgg_list_entities_from_annotations';
- elgg_deprecated_notice($msg, 1.8);
-
- $options = array();
-
- if ($entity_type) {
- $options['types'] = $entity_type;
- }
-
- if ($entity_subtype) {
- $options['subtypes'] = $entity_subtype;
- }
-
- if ($name) {
- $options['annotation_names'] = $name;
- }
-
- if ($value) {
- $options['annotation_values'] = $value;
- }
-
- if ($limit) {
- $options['limit'] = $limit;
- }
-
- if ($owner_guid) {
- $options['annotation_owner_guid'] = $owner_guid;
- }
-
- if ($group_guid) {
- $options['container_guid'] = $group_guid;
- }
-
- if ($asc) {
- $options['order_by'] = 'maxtime desc';
- }
-
- if ($offset = sanitise_int(get_input('offset', null))) {
- $options['offset'] = $offset;
- }
-
- $options['full_view'] = $fullview;
- $options['list_type_toggle'] = $listtypetoggle;
- $options['pagination'] = $pagination;
-
- return elgg_list_entities_from_annotations($options);
-}
-
-function search_for_group($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
- elgg_deprecated_notice('search_for_group() was deprecated by new search plugin.', 1.7);
- global $CONFIG;
-
- $criteria = sanitise_string($criteria);
- $limit = (int)$limit;
- $offset = (int)$offset;
- $order_by = sanitise_string($order_by);
-
- $access = get_access_sql_suffix("e");
-
- if ($order_by == "") {
- $order_by = "e.time_created desc";
- }
-
- if ($count) {
- $query = "SELECT count(e.guid) as total ";
- } else {
- $query = "SELECT e.* ";
- }
- $query .= "from {$CONFIG->dbprefix}entities e" . " JOIN {$CONFIG->dbprefix}groups_entity g on e.guid=g.guid where ";
-
- $query .= "(g.name like \"%{$criteria}%\" or g.description like \"%{$criteria}%\")";
- $query .= " and $access";
-
- if (!$count) {
- $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
- return get_data($query, "entity_row_to_elggstar");
- } else {
- if ($count = get_data_row($query)) {
- return $count->total;
- }
- }
- return false;
-}
-
-function search_list_groups_by_name($hook, $user, $returnvalue, $tag) {
- elgg_deprecated_notice('search_list_groups_by_name() was deprecated by new search plugin', 1.7);
- // Change this to set the number of groups that display on the search page
- $threshold = 4;
-
- $object = get_input('object');
-
- if (!get_input('offset') && (empty($object) || $object == 'group')) {
- if ($groups = search_for_group($tag, $threshold)) {
- $countgroups = search_for_group($tag, 0, 0, "", true);
-
- $return = elgg_view('group/search/startblurb', array('count' => $countgroups,
- 'tag' => $tag));
- foreach ($groups as $group) {
- $return .= elgg_view_entity($group);
- }
- $vars = array('count' => $countgroups, 'threshold' => $threshold, 'tag' => $tag);
- $return .= elgg_view('group/search/finishblurb', $vars);
- return $return;
- }
- }
-}
-
-function list_group_search($tag, $limit = 10) {
- elgg_deprecated_notice('list_group_search() was deprecated by new search plugin.', 1.7);
- $offset = (int)get_input('offset');
- $limit = (int)$limit;
- $count = (int)search_for_group($tag, 10, 0, '', true);
- $entities = search_for_group($tag, $limit, $offset);
-
- return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, false);
-
-}
-
-function get_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, $case_sensitive = TRUE) {
-
- elgg_deprecated_notice('get_entities_from_metadata() was deprecated by elgg_get_entities_from_metadata()!', 1.7);
-
- $options = array();
-
- $options['metadata_names'] = $meta_name;
-
- if ($meta_value) {
- $options['metadata_values'] = $meta_value;
- }
-
- if ($entity_type) {
- $options['types'] = $entity_type;
- }
-
- if ($entity_subtype) {
- $options['subtypes'] = $entity_subtype;
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- if ($limit) {
- $options['limit'] = $limit;
- }
-
- if ($offset) {
- $options['offset'] = $offset;
- }
-
- if ($order_by) {
- $options['order_by'];
- }
-
- if ($site_guid) {
- $options['site_guid'];
- }
-
- if ($count) {
- $options['count'] = $count;
- }
-
- // need to be able to pass false
- $options['metadata_case_sensitive'] = $case_sensitive;
-
- return elgg_get_entities_from_metadata($options);
-}
-
-function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false, $meta_array_operator = 'and') {
-
- elgg_deprecated_notice('get_entities_from_metadata_multi() was deprecated by elgg_get_entities_from_metadata()!', 1.7);
-
- if (!is_array($meta_array) || sizeof($meta_array) == 0) {
- return false;
- }
-
- $options = array();
-
- $options['metadata_name_value_pairs'] = $meta_array;
-
- if ($entity_type) {
- $options['types'] = $entity_type;
- }
-
- if ($entity_subtype) {
- $options['subtypes'] = $entity_subtype;
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- if ($limit) {
- $options['limit'] = $limit;
- }
-
- if ($offset) {
- $options['offset'] = $offset;
- }
-
- if ($order_by) {
- $options['order_by'];
- }
-
- if ($site_guid) {
- $options['site_guid'];
- }
-
- if ($count) {
- $options['count'] = $count;
- }
-
- $options['metadata_name_value_pairs_operator'] = $meta_array_operator;
-
- return elgg_get_entities_from_metadata($options);
-}
-
-function menu_item($menu_name, $menu_url) {
- elgg_deprecated_notice('menu_item() is deprecated by add_submenu_item', 1.7);
- return make_register_object($menu_name, $menu_url);
-}
-
-function search_for_object($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
- elgg_deprecated_notice('search_for_object() was deprecated by new search plugin.', 1.7);
- global $CONFIG;
-
- $criteria = sanitise_string($criteria);
- $limit = (int)$limit;
- $offset = (int)$offset;
- $order_by = sanitise_string($order_by);
- $container_guid = (int)$container_guid;
-
- $access = get_access_sql_suffix("e");
-
- if ($order_by == "") {
- $order_by = "e.time_created desc";
- }
-
- if ($count) {
- $query = "SELECT count(e.guid) as total ";
- } else {
- $query = "SELECT e.* ";
- }
- $query .= "from {$CONFIG->dbprefix}entities e
- join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid
- where match(o.title,o.description) against ('$criteria') and $access";
-
- if (!$count) {
- $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
- return get_data($query, "entity_row_to_elggstar");
- } else {
- if ($count = get_data_row($query)) {
- return $count->total;
- }
- }
- return false;
-}
-
-function search_list_objects_by_name($hook, $user, $returnvalue, $tag) {
- elgg_deprecated_notice('search_list_objects_by_name was deprecated by new search plugin.', 1.7);
-
- // Change this to set the number of users that display on the search page
- $threshold = 4;
-
- $object = get_input('object');
-
- if (!get_input('offset') && (empty($object) || $object == 'user')) {
- if ($users = search_for_user($tag, $threshold)) {
- $countusers = search_for_user($tag, 0, 0, "", true);
-
- $return = elgg_view('user/search/startblurb', array('count' => $countusers,
- 'tag' => $tag));
- foreach ($users as $user) {
- $return .= elgg_view_entity($user);
- }
- $return .= elgg_view('user/search/finishblurb', array('count' => $countusers,
- 'threshold' => $threshold, 'tag' => $tag));
-
- return $return;
-
- }
- }
-}
-
-/**#@-*/
-
-/**#@+
- * @deprecated 1.8
- */
-
-function elgg_get_entity_site_where_sql($table, $site_guids) {
- elgg_deprecated_notice('elgg_get_entity_site_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
-
- return elgg_get_guid_based_where_sql("{$table}.site_guid", $site_guids);
-}
-
-function elgg_get_entity_container_where_sql($table, $container_guids) {
- elgg_deprecated_notice('elgg_get_entity_container_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
-
- return elgg_get_guid_based_where_sql("{$table}.container_guid", $container_guids);
-}
-
-function elgg_get_entity_owner_where_sql($table, $owner_guids) {
- elgg_deprecated_notice('elgg_get_entity_owner_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
-
- return elgg_get_guid_based_where_sql("{$table}.owner_guid", $owner_guids);
-}
-
-function list_entities_from_access_id($access_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
- elgg_deprecated_notice("All list_entities* functions were deprecated in 1.8. Use elgg_list_entities* instead.", 1.8);
-
- echo elgg_list_entities_from_access_id(array('access_id' => $access_id,
- 'types' => $entity_type, 'subtypes' => $entity_subtype, 'owner_guids' => $owner_guid,
- 'limit' => $limit, 'full_view' => $fullview, 'list_type_toggle' => $listtypetoggle,
- 'pagination' => $pagination,));
-}
-
-function register_action($action, $public = false, $filename = "", $admin_only = false) {
- elgg_deprecated_notice("register_action() was deprecated by elgg_register_action()", 1.8);
-
- if ($admin_only) {
- $access = 'admin';
- } elseif ($public) {
- $access = 'public';
- } else {
- $access = 'logged_in';
- }
-
- return elgg_register_action($action, $filename, $access);
-}
-
-function extend_elgg_admin_page($new_admin_view, $view = 'admin/main', $priority = 500) {
- elgg_deprecated_notice('extend_elgg_admin_page() does nothing. Extend admin views manually.', 1.8);
-}
-
-function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
-
- $msg = 'get_entities_from_annotations_calculate_x() is deprecated by elgg_get_entities_from_annotation_calculation().';
-
- elgg_deprecated_notice($msg, 1.8);
-
- $options = array();
-
- $options['calculation'] = $sum;
-
- if ($entity_type) {
- $options['types'] = $entity_type;
- }
-
- if ($entity_subtype) {
- $options['subtypes'] = $entity_subtype;
- }
-
- $options['annotation_names'] = $name;
-
- if ($mdname) {
- $options['metadata_names'] = $mdname;
- }
-
- if ($mdvalue) {
- $options['metadata_values'] = $mdvalue;
- }
-
- // original function rewrote this to container guid.
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['container_guids'] = $owner_guid;
- } else {
- $options['container_guid'] = $owner_guid;
- }
- }
-
- $options['limit'] = $limit;
- $options['offset'] = $offset;
-
- $options['order_by'] = "calculated $orderdir";
-
- $options['count'] = $count;
-
- return elgg_get_entities_from_annotation_calculation($options);
-}
-
-function get_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) {
-
- $msg = 'get_entities_from_annotation_count() is deprecated by elgg_get_entities_from_annotation_calculation().';
-
- elgg_deprecated_notice($msg, 1.8);
-
- $options = array();
-
- $options['calculation'] = 'sum';
-
- if ($entity_type) {
- $options['types'] = $entity_type;
- }
-
- if ($entity_subtype) {
- $options['subtypes'] = $entity_subtype;
- }
-
- $options['annotation_names'] = $name;
-
- if ($mdname) {
- $options['metadata_names'] = $mdname;
- }
-
- if ($mdvalue) {
- $options['metadata_values'] = $mdvalue;
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- $options['limit'] = $limit;
- $options['offset'] = $offset;
-
- $options['order_by'] = "calculated $orderdir";
-
- $options['count'] = $count;
-
- return elgg_get_entities_from_annotation_calculation($options);
-}
-
-function list_entities_from_annotation_count($entity_type = "", $entity_subtype = "", $name = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $orderdir = 'desc') {
-
- $msg = 'list_entities_from_annotation_count() is deprecated by elgg_list_entities_from_annotation_calculation().';
-
- elgg_deprecated_notice($msg, 1.8);
-
- $options = array();
-
- $options['calculation'] = 'sum';
-
- if ($entity_type) {
- $options['types'] = $entity_type;
- }
-
- if ($entity_subtype) {
- $options['subtypes'] = $entity_subtype;
- }
-
- $options['annotation_names'] = $name;
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- $options['full_view'] = $fullview;
-
- $options['list_type_toggle'] = $listtypetoggle;
-
- $options['pagination'] = $pagination;
-
- $options['limit'] = $limit;
-
- $options['order_by'] = "calculated $orderdir";
-
- return elgg_get_entities_from_annotation_calculation($options);
-}
-
-function get_register($register_name) {
- elgg_deprecated_notice("get_register() has been deprecated", 1.8);
- global $CONFIG;
-
- if (isset($CONFIG->registers[$register_name])) {
- return $CONFIG->registers[$register_name];
- }
-
- return false;
-}
-
-function events($event = "", $object_type = "", $function = "", $priority = 500, $call = false, $object = null) {
-
- elgg_deprecated_notice('events() has been deprecated.', 1.8);
-
- // leaving this here just in case someone was directly calling this internal function
- if (!$call) {
- return elgg_register_event_handler($event, $object_type, $function, $priority);
- } else {
- return trigger_elgg_event($event, $object_type, $object);
- }
-}
-
-function register_elgg_event_handler($event, $object_type, $callback, $priority = 500) {
- elgg_deprecated_notice("register_elgg_event_handler() was deprecated by elgg_register_event_handler()", 1.8);
- return elgg_register_event_handler($event, $object_type, $callback, $priority);
-}
-
-function unregister_elgg_event_handler($event, $object_type, $callback) {
- elgg_deprecated_notice('unregister_elgg_event_handler => elgg_unregister_event_handler', 1.8);
- elgg_unregister_event_handler($event, $object_type, $callback);
-}
-
-function trigger_elgg_event($event, $object_type, $object = null) {
- elgg_deprecated_notice('trigger_elgg_event() was deprecated by elgg_trigger_event()', 1.8);
- return elgg_trigger_event($event, $object_type, $object);
-}
-
-function register_plugin_hook($hook, $type, $callback, $priority = 500) {
- elgg_deprecated_notice("register_plugin_hook() was deprecated by elgg_register_plugin_hook_handler()", 1.8);
- return elgg_register_plugin_hook_handler($hook, $type, $callback, $priority);
-}
-
-function unregister_plugin_hook($hook, $entity_type, $callback) {
- elgg_deprecated_notice("unregister_plugin_hook() was deprecated by elgg_unregister_plugin_hook_handler()", 1.8);
- elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback);
-}
-
-function trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) {
- elgg_deprecated_notice("trigger_plugin_hook() was deprecated by elgg_trigger_plugin_hook()", 1.8);
- return elgg_trigger_plugin_hook($hook, $type, $params, $returnvalue);
-}
-
-function call_gatekeeper($function, $file = "") {
- elgg_deprecated_notice("call_gatekeeper() is neat but pointless", 1.8);
- // Sanity check
- if (!$function) {
- return false;
- }
-
- // Check against call stack to see if this is being called from the correct location
- $callstack = debug_backtrace();
- $stack_element = false;
-
- foreach ($callstack as $call) {
- if (is_array($function)) {
- if ((strcmp($call['class'], $function[0]) == 0) && (strcmp($call['function'], $function[1]) == 0)) {
- $stack_element = $call;
- }
- } else {
- if (strcmp($call['function'], $function) == 0) {
- $stack_element = $call;
- }
- }
- }
-
- if (!$stack_element) {
- return false;
- }
-
- // If file then check that this it is being called from this function
- if ($file) {
- $mirror = null;
-
- if (is_array($function)) {
- $mirror = new ReflectionMethod($function[0], $function[1]);
- } else {
- $mirror = new ReflectionFunction($function);
- }
-
- if ((!$mirror) || (strcmp($file, $mirror->getFileName()) != 0)) {
- return false;
- }
- }
-
- return true;
-}
-
-function callpath_gatekeeper($path, $include_subdirs = true, $strict_mode = false) {
- elgg_deprecated_notice("callpath_gatekeeper() is neat but pointless", 1.8);
-
- global $CONFIG;
-
- $path = sanitise_string($path);
-
- if ($path) {
- $callstack = debug_backtrace();
-
- foreach ($callstack as $call) {
- $call['file'] = str_replace("\\", "/", $call['file']);
-
- if ($include_subdirs) {
- if (strpos($call['file'], $path) === 0) {
-
- if ($strict_mode) {
- $callstack[1]['file'] = str_replace("\\", "/", $callstack[1]['file']);
- if ($callstack[1] === $call) {
- return true;
- }
- } else {
- return true;
- }
- }
- } else {
- if (strcmp($path, $call['file']) == 0) {
- if ($strict_mode) {
- if ($callstack[1] === $call) {
- return true;
- }
- } else {
- return true;
- }
- }
- }
-
- }
- return false;
- }
-
- if (isset($CONFIG->debug)) {
- system_message("Gatekeeper'd function called from {$callstack[1]['file']}:" . "{$callstack[1]['line']}\n\nStack trace:\n\n" . print_r($callstack, true));
- }
-
- return false;
-}
-
-function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = FALSE) {
- elgg_deprecated_notice("get_objects_in_group was deprected in 1.8. Use elgg_get_entities() instead", 1.8);
-
- global $CONFIG;
-
- if ($subtype === FALSE || $subtype === null || $subtype === 0) {
- return FALSE;
- }
-
- if ($order_by == "") {
- $order_by = "e.time_created desc";
- }
- $order_by = sanitise_string($order_by);
- $limit = (int)$limit;
- $offset = (int)$offset;
- $site_guid = (int)$site_guid;
- if ($site_guid == 0) {
- $site_guid = $CONFIG->site_guid;
- }
-
- $container_guid = (int)$group_guid;
- if ($container_guid == 0) {
- $container_guid = elgg_get_page_owner_guid();
- }
-
- $where = array();
-
- $where[] = "e.type='object'";
-
- if (!empty($subtype)) {
- if (!$subtype = get_subtype_id('object', $subtype)) {
- return FALSE;
- }
- $where[] = "e.subtype=$subtype";
- }
- if ($owner_guid != "") {
- if (!is_array($owner_guid)) {
- $owner_guid = (int)$owner_guid;
- $where[] = "e.container_guid = '$owner_guid'";
- } else if (sizeof($owner_guid) > 0) {
- // Cast every element to the owner_guid array to int
- $owner_guid = array_map("sanitise_int", $owner_guid);
- $owner_guid = implode(",", $owner_guid);
- $where[] = "e.container_guid in ({$owner_guid})";
- }
- }
- if ($site_guid > 0) {
- $where[] = "e.site_guid = {$site_guid}";
- }
-
- if ($container_guid > 0) {
- $where[] = "e.container_guid = {$container_guid}";
- }
-
- if (!$count) {
- $query = "SELECT * from {$CONFIG->dbprefix}entities e" . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
- } else {
- $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e" . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
- }
- foreach ($where as $w) {
- $query .= " $w and ";
- }
-
- // Add access controls
- $query .= get_access_sql_suffix('e');
- if (!$count) {
- $query .= " order by $order_by";
-
- // Add order and limit
- if ($limit) {
- $query .= " limit $offset, $limit";
- }
-
- $dt = get_data($query, "entity_row_to_elggstar");
- return $dt;
- } else {
- $total = get_data_row($query);
- return $total->total;
- }
-}
-
-function list_entities_groups($subtype = "", $owner_guid = 0, $container_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
- elgg_deprecated_notice("list_entities_groups was deprecated in 1.8. Use elgg_list_entities() instead.", 1.8);
- $offset = (int)get_input('offset');
- $count = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset, true);
- $entities = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset);
-
- return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
-}
-
-function get_entities_from_metadata_groups($group_guid, $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_entities_from_metadata_groups was deprecated in 1.8.", 1.8);
- global $CONFIG;
-
- $meta_n = get_metastring_id($meta_name);
- $meta_v = get_metastring_id($meta_value);
-
- $entity_type = sanitise_string($entity_type);
- $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
- $limit = (int)$limit;
- $offset = (int)$offset;
- if ($order_by == "") {
- $order_by = "e.time_created desc";
- }
- $order_by = sanitise_string($order_by);
- $site_guid = (int)$site_guid;
- if (is_array($owner_guid)) {
- foreach ($owner_guid as $key => $guid) {
- $owner_guid[$key] = (int)$guid;
- }
- } else {
- $owner_guid = (int)$owner_guid;
- }
- if ($site_guid == 0) {
- $site_guid = $CONFIG->site_guid;
- }
-
- $container_guid = (int)$group_guid;
- if ($container_guid == 0) {
- $container_guid = elgg_get_page_owner_guid();
- }
-
- $where = array();
-
- if ($entity_type != "") {
- $where[] = "e.type='$entity_type'";
- }
- if ($entity_subtype) {
- $where[] = "e.subtype=$entity_subtype";
- }
- if ($meta_name != "") {
- $where[] = "m.name_id='$meta_n'";
- }
- if ($meta_value != "") {
- $where[] = "m.value_id='$meta_v'";
- }
- if ($site_guid > 0) {
- $where[] = "e.site_guid = {$site_guid}";
- }
- if ($container_guid > 0) {
- $where[] = "e.container_guid = {$container_guid}";
- }
-
- if (is_array($owner_guid)) {
- $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")";
- } else if ($owner_guid > 0) {
- $where[] = "e.container_guid = {$owner_guid}";
- }
-
- if (!$count) {
- $query = "SELECT distinct e.* ";
- } else {
- $query = "SELECT count(e.guid) as total ";
- }
-
- $query .= "from {$CONFIG->dbprefix}entities e" . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid " . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid where";
-
- foreach ($where as $w) {
- $query .= " $w and ";
- }
-
- // Add access controls
- $query .= get_access_sql_suffix("e");
-
- if (!$count) {
- $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
- return get_data($query, "entity_row_to_elggstar");
- } else {
- if ($row = get_data_row($query)) {
- return $row->total;
- }
- }
- return false;
-}
-
-function get_entities_from_metadata_groups_multi($group_guid, $meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
- elgg_deprecated_notice("get_entities_from_metadata_groups_multi was deprecated in 1.8.", 1.8);
-
- global $CONFIG;
-
- if (!is_array($meta_array) || sizeof($meta_array) == 0) {
- return false;
- }
-
- $where = array();
-
- $mindex = 1;
- $join = "";
- foreach ($meta_array as $meta_name => $meta_value) {
- $meta_n = get_metastring_id($meta_name);
- $meta_v = get_metastring_id($meta_value);
- $join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid" . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid ";
-
- if ($meta_name != "") {
- $where[] = "m{$mindex}.name_id='$meta_n'";
- }
-
- if ($meta_value != "") {
- $where[] = "m{$mindex}.value_id='$meta_v'";
- }
-
- $mindex++;
- }
-
- $entity_type = sanitise_string($entity_type);
- $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
- $limit = (int)$limit;
- $offset = (int)$offset;
- if ($order_by == "") {
- $order_by = "e.time_created desc";
- }
- $order_by = sanitise_string($order_by);
- $owner_guid = (int)$owner_guid;
-
- $site_guid = (int)$site_guid;
- if ($site_guid == 0) {
- $site_guid = $CONFIG->site_guid;
- }
-
- //$access = get_access_list();
-
- if ($entity_type != "") {
- $where[] = "e.type = '{$entity_type}'";
- }
-
- if ($entity_subtype) {
- $where[] = "e.subtype = {$entity_subtype}";
- }
-
- if ($site_guid > 0) {
- $where[] = "e.site_guid = {$site_guid}";
- }
-
- if ($owner_guid > 0) {
- $where[] = "e.owner_guid = {$owner_guid}";
- }
-
- if ($container_guid > 0) {
- $where[] = "e.container_guid = {$container_guid}";
- }
-
- if ($count) {
- $query = "SELECT count(e.guid) as total ";
- } else {
- $query = "SELECT distinct e.* ";
- }
-
- $query .= " from {$CONFIG->dbprefix}entities e {$join} where";
- foreach ($where as $w) {
- $query .= " $w and ";
- }
- $query .= get_access_sql_suffix("e"); // Add access controls
-
- if (!$count) {
- $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
- return get_data($query, "entity_row_to_elggstar");
- } else {
- if ($count = get_data_row($query)) {
- return $count->total;
- }
- }
- return false;
-}
-
-function list_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
- elgg_deprecated_notice('list_entities_in_area() was deprecated. Use elgg_list_entities_from_location()', 1.8);
-
- $options = array();
-
- $options['latitude'] = $lat;
- $options['longitude'] = $long;
- $options['distance'] = $radius;
-
- if ($type) {
- $options['types'] = $type;
- }
-
- if ($subtype) {
- $options['subtypes'] = $subtype;
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- $options['limit'] = $limit;
-
- $options['full_view'] = $fullview;
- $options['list_type_toggle'] = $listtypetoggle;
- $options['pagination'] = $pagination;
-
- return elgg_list_entities_from_location($options);
-}
-
-function list_entities_location($location, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
- elgg_deprecated_notice('list_entities_location() was deprecated. Use elgg_list_entities_from_metadata()', 1.8);
-
- return list_entities_from_metadata('location', $location, $type, $subtype, $owner_guid, $limit, $fullview, $listtypetoggle, $navigation);
-}
-
-function get_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = NULL) {
- elgg_deprecated_notice('get_entities_in_area() was deprecated by elgg_get_entities_from_location()!', 1.8);
-
- $options = array();
-
- $options['latitude'] = $lat;
- $options['longitude'] = $long;
- $options['distance'] = $radius;
-
- // set container_guid to owner_guid to emulate old functionality
- if ($owner_guid != "") {
- if (is_null($container_guid)) {
- $container_guid = $owner_guid;
- }
- }
-
- if ($type) {
- $options['types'] = $type;
- }
-
- if ($subtype) {
- $options['subtypes'] = $subtype;
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- if ($container_guid) {
- if (is_array($container_guid)) {
- $options['container_guids'] = $container_guid;
- } else {
- $options['container_guid'] = $container_guid;
- }
- }
-
- $options['limit'] = $limit;
-
- if ($offset) {
- $options['offset'] = $offset;
- }
-
- if ($order_by) {
- $options['order_by'];
- }
-
- if ($site_guid) {
- $options['site_guid'];
- }
-
- if ($count) {
- $options['count'] = $count;
- }
-
- return elgg_get_entities_from_location($options);
-}
-
-function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type = ELGG_ENTITIES_ANY_VALUE, $entity_subtype = ELGG_ENTITIES_ANY_VALUE, $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true, $case_sensitive = true) {
-
- elgg_deprecated_notice('list_entities_from_metadata() was deprecated by elgg_list_entities_from_metadata()!', 1.8);
-
- $offset = (int)get_input('offset');
- $limit = (int)$limit;
- $options = array('metadata_name' => $meta_name, 'metadata_value' => $meta_value,
- 'types' => $entity_type, 'subtypes' => $entity_subtype, 'owner_guid' => $owner_guid,
- 'limit' => $limit, 'offset' => $offset, 'count' => TRUE,
- 'metadata_case_sensitive' => $case_sensitive);
- $count = elgg_get_entities_from_metadata($options);
-
- $options['count'] = FALSE;
- $entities = elgg_get_entities_from_metadata($options);
-
- return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
-}
-
-function list_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
- elgg_deprecated_notice(elgg_echo('deprecated:function', array(
- 'list_entities_from_metadata_multi', 'elgg_get_entities_from_metadata')), 1.8);
-
- $offset = (int)get_input('offset');
- $limit = (int)$limit;
- $count = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", $site_guid, true);
- $entities = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", $site_guid, false);
-
- return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $listtypetoggle, $pagination);
-}
-
-function add_submenu_item($label, $link, $group = 'default', $onclick = false, $selected = NULL) {
- elgg_deprecated_notice('add_submenu_item was deprecated by elgg_register_menu_item', 1.8);
-
- // submenu items were added in the page setup hook usually by checking
- // the context. We'll pass in the current context here, which will
- // emulate that effect.
- // if context == 'main' (default) it probably means they always wanted
- // the menu item to show up everywhere.
- $context = elgg_get_context();
-
- if ($context == 'main') {
- $context = 'all';
- }
-
- $item = array('name' => $label, 'title' => $label, 'url' => $link, 'context' => $context,
- 'section' => $group,);
-
- if ($selected) {
- $item['selected'] = true;
- }
-
- if ($onclick) {
- $js = "onclick=\"javascript:return confirm('" . elgg_echo('deleteconfirm') . "')\"";
- $item['vars'] = array('js' => $js);
- }
-
- return elgg_register_menu_item('page', $item);
-}
-
-function get_submenu() {
- elgg_deprecated_notice("get_submenu() has been deprecated by elgg_view_menu()", 1.8);
- return elgg_view_menu('owner_block', array('entity' => $owner,
- 'class' => 'elgg-owner-block-menu',));
-}
-
-function add_menu($menu_name, $menu_url, $menu_children = array(), $context = "") {
- elgg_deprecated_notice('add_menu() deprecated by elgg_register_menu_item()', 1.8);
-
- return elgg_register_menu_item('site', array('name' => $menu_name, 'title' => $menu_name,
- 'url' => $menu_url,));
-}
-
-function remove_menu($menu_name) {
- elgg_deprecated_notice("remove_menu() deprecated by elgg_unregister_menu_item()", 1.8);
- return elgg_unregister_menu_item('site', $menu_name);
-}
-
-function friendly_title($title) {
- elgg_deprecated_notice('friendly_title was deprecated by elgg_get_friendly_title', 1.8);
- return elgg_get_friendly_title($title);
-}
-
-function friendly_time($time) {
- elgg_deprecated_notice('friendly_time was deprecated by elgg_view_friendly_time', 1.8);
- return elgg_view_friendly_time($time);
-}
-
-function filter_string($string) {
- elgg_deprecated_notice('filter_string() was deprecated!', 1.8);
-
- // Convert it to lower and trim
- $string = strtolower($string);
- $string = trim($string);
-
- // Remove links and email addresses
- // match protocol://address/path/file.extension?some=variable&another=asf%
- $string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}" . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
-
- // match www.something.domain/path/file.extension?some=variable&another=asf%
- $string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}" . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
-
- // match name@address
- $string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]" . "*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu", " ", $string);
-
- // Sanitise the string; remove unwanted characters
- $string = preg_replace('/\W/ui', ' ', $string);
-
- // Explode it into an array
- $terms = explode(' ', $string);
-
- // Remove any blacklist terms
- //$terms = array_filter($terms, 'remove_blacklist');
-
- return $terms;
-}
-
-function remove_blacklist($input) {
- elgg_deprecated_notice('remove_blacklist() was deprecated!', 1.8);
-
- global $CONFIG;
-
- if (!is_array($CONFIG->wordblacklist)) {
- return $input;
- }
-
- if (strlen($input) < 3 || in_array($input, $CONFIG->wordblacklist)) {
- return false;
- }
-
- return true;
-}
-
-function page_owner() {
- elgg_deprecated_notice('page_owner() was deprecated by elgg_get_page_owner_guid().', 1.8);
- return elgg_get_page_owner_guid();
-}
-
-function page_owner_entity() {
- elgg_deprecated_notice('page_owner_entity() was deprecated by elgg_get_page_owner_entity().', 1.8);
- return elgg_get_page_owner_entity();
-}
-
-function add_page_owner_handler($functionname) {
- elgg_deprecated_notice("add_page_owner_handler() was deprecated by the plugin hook 'page_owner', 'system'.", 1.8);
-}
-
-function set_page_owner($entitytoset = -1) {
- elgg_deprecated_notice('set_page_owner() was deprecated by elgg_set_page_owner_guid().', 1.8);
- elgg_set_page_owner_guid($entitytoset);
-}
-
-function set_context($context) {
- elgg_deprecated_notice('set_context() was deprecated by elgg_set_context().', 1.8);
- elgg_set_context($context);
- if (empty($context)) {
- return false;
- }
- return $context;
-}
-
-function get_context() {
- elgg_deprecated_notice('get_context() was deprecated by elgg_get_context().', 1.8);
- return elgg_get_context();
-
- // @todo - used to set context based on calling script
- // $context = get_plugin_name(true)
-}
-
-function get_installed_plugins($status = 'all') {
- global $CONFIG;
-
- elgg_deprecated_notice('get_installed_plugins() was deprecated by elgg_get_plugins()', 1.8);
-
- $plugins = elgg_get_plugins($status);
-
- if (!$plugins) {
- return array();
- }
-
- $installed_plugins = array();
-
- foreach ($plugins as $plugin) {
- if (!$plugin->isValid()) {
- continue;
- }
-
- $installed_plugins[$plugin->getID()] = array(
- 'active' => $plugin->isActive(),
- 'manifest' => $plugin->manifest->getManifest()
- );
- }
-
- return $installed_plugins;
-}
-
-function enable_plugin($plugin, $site_guid = null) {
- elgg_deprecated_notice('enable_plugin() was deprecated by ElggPlugin->activate()', 1.8);
-
- $plugin = sanitise_string($plugin);
-
- $site_guid = (int) $site_guid;
- if (!$site_guid) {
- $site = get_config('site');
- $site_guid = $site->guid;
- }
-
- try {
- $plugin = new ElggPlugin($plugin);
- } catch(Exception $e) {
- return false;
- }
-
- if (!$plugin->canActivate($site_guid)) {
- return false;
- }
-
- return $plugin->activate($site_guid);
-}
-
-function disable_plugin($plugin, $site_guid = 0) {
- elgg_deprecated_notice('disable_plugin() was deprecated by ElggPlugin->deactivate()', 1.8);
-
- $plugin = sanitise_string($plugin);
-
- $site_guid = (int) $site_guid;
- if (!$site_guid) {
- $site = get_config('site');
- $site_guid = $site->guid;
- }
-
- try {
- $plugin = new ElggPlugin($plugin);
- } catch(Exception $e) {
- return false;
- }
-
- return $plugin->deactivate($site_guid);
-}
-
-function is_plugin_enabled($plugin, $site_guid = 0) {
- elgg_deprecated_notice('is_plugin_enabled() was deprecated by ElggPlugin->isActive()', 1.8);
-
- $plugin = sanitise_string($plugin);
-
- $site_guid = (int) $site_guid;
- if (!$site_guid) {
- $site = get_config('site');
- $site_guid = $site->guid;
- }
-
- try {
- $plugin = new ElggPlugin($plugin);
- } catch(Exception $e) {
- return false;
- }
-
- return $plugin->isActive($site_guid);
-}
-
-function get_plugin_list() {
- elgg_deprecated_notice('get_plugin_list() is deprecated by elgg_get_plugin_ids_in_dir() or elgg_get_plugins()', 1.8);
-
- $plugins = elgg_get_plugins('any');
-
- $list = array();
- if ($plugins) {
- foreach ($plugins as $i => $plugin) {
- // in <=1.7 this returned indexed by multiples of 10.
- // uh...sure...why not.
- $index = ($i + 1) * 10;
- $list[$index] = $plugin->getID();
- }
- }
-
- return $list;
-}
-
-function regenerate_plugin_list($pluginorder = FALSE) {
- $msg = 'regenerate_plugin_list() is (sorta) deprecated by elgg_generate_plugin_entities() and'
- . ' elgg_set_plugin_priorities().';
- elgg_deprecated_notice($msg, 1.8);
-
- // they're probably trying to set it?
- if ($pluginorder) {
- if (elgg_generate_plugin_entities()) {
- // sort the plugins by the index numerically since we used
- // weird indexes in the old system.
- ksort($pluginorder, SORT_NUMERIC);
- return elgg_set_plugin_priorities($pluginorder);
- }
- return false;
- } else {
- // they're probably trying to regenerate from disk?
- return elgg_generate_plugin_entities();
- }
-}
-
-function get_plugin_name($mainfilename = false) {
- elgg_deprecated_notice('get_plugin_name() is deprecated by elgg_get_calling_plugin_id()', 1.8);
-
- return elgg_get_calling_plugin_id($mainfilename);
-}
-
-function load_plugin_manifest($plugin) {
- elgg_deprecated_notice('load_plugin_manifest() is deprecated by ElggPlugin->getManifest()', 1.8);
-
- $xml_file = elgg_get_plugin_path() . "$plugin/manifest.xml";
-
- try {
- $manifest = new ElggPluginManifest($xml_file, $plugin);
- } catch(Exception $e) {
- return false;
- }
-
- return $manifest->getManifest();
-}
-
-function check_plugin_compatibility($manifest_elgg_version_string) {
- elgg_deprecated_notice('check_plugin_compatibility() is deprecated by ElggPlugin->canActivate()', 1.8);
-
- $version = get_version();
-
- if (strpos($manifest_elgg_version_string, '.') === false) {
- // Using version
- $req_version = (int)$manifest_elgg_version_string;
-
- return ($version >= $req_version);
- }
-
- return false;
-}
-
-function find_plugin_settings($plugin_id = null) {
- elgg_deprecated_notice('find_plugin_setting() is deprecated by elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()', 1.8);
- if ($plugin_id) {
- return elgg_get_plugin_from_id($plugin_id);
- } else {
- return elgg_get_calling_plugin_entity();
- }
-}
-
-function get_entities_from_private_setting($name = "", $value = "", $type = "", $subtype = "",
-$owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
-$container_guid = null) {
- elgg_deprecated_notice('get_entities_from_private_setting() was deprecated by elgg_get_entities_from_private_setting()!', 1.8);
-
- $options = array();
-
- $options['private_setting_name'] = $name;
- $options['private_setting_value'] = $value;
-
- // set container_guid to owner_guid to emulate old functionality
- if ($owner_guid != "") {
- if (is_null($container_guid)) {
- $container_guid = $owner_guid;
- }
- }
-
- if ($type) {
- $options['types'] = $type;
- }
-
- if ($subtype) {
- $options['subtypes'] = $subtype;
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- if ($container_guid) {
- if (is_array($container_guid)) {
- $options['container_guids'] = $container_guid;
- } else {
- $options['container_guid'] = $container_guid;
- }
- }
-
- $options['limit'] = $limit;
-
- if ($offset) {
- $options['offset'] = $offset;
- }
-
- if ($order_by) {
- $options['order_by'];
- }
-
- if ($site_guid) {
- $options['site_guid'];
- }
-
- if ($count) {
- $options['count'] = $count;
- }
-
- return elgg_get_entities_from_private_settings($options);
-}
-
-function get_entities_from_private_setting_multi(array $name, $type = "", $subtype = "",
-$owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false,
-$site_guid = 0, $container_guid = null) {
-
- elgg_deprecated_notice('get_entities_from_private_setting_multi() was deprecated by elgg_get_entities_from_private_setting()!', 1.8);
-
- $options = array();
-
- $pairs = array();
- foreach ($name as $setting_name => $setting_value) {
- $pairs[] = array('name' => $setting_name, 'value' => $setting_value);
- }
- $options['private_setting_name_value_pairs'] = $pairs;
-
- // set container_guid to owner_guid to emulate old functionality
- if ($owner_guid != "") {
- if (is_null($container_guid)) {
- $container_guid = $owner_guid;
- }
- }
-
- if ($type) {
- $options['types'] = $type;
- }
-
- if ($subtype) {
- $options['subtypes'] = $subtype;
- }
-
- if ($owner_guid) {
- if (is_array($owner_guid)) {
- $options['owner_guids'] = $owner_guid;
- } else {
- $options['owner_guid'] = $owner_guid;
- }
- }
-
- if ($container_guid) {
- if (is_array($container_guid)) {
- $options['container_guids'] = $container_guid;
- } else {
- $options['container_guid'] = $container_guid;
- }
- }
-
- $options['limit'] = $limit;
-
- if ($offset) {
- $options['offset'] = $offset;
- }
-
- if ($order_by) {
- $options['order_by'];
- }
-
- if ($site_guid) {
- $options['site_guid'];
- }
-
- if ($count) {
- $options['count'] = $count;
- }
-
- return elgg_get_entities_from_private_settings($options);
-}
-// these were internal functions that perhaps can be removed rather than deprecated
-function is_db_installed() {
- elgg_deprecated_notice('is_db_installed() has been deprecated', 1.8);
- return true;
-}
-
-function is_installed() {
- elgg_deprecated_notice('is_installed() has been deprecated', 1.8);
- return true;
-}
-
-/**#@-*/
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index e6c71813d..e8d47eaca 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -214,7 +214,7 @@ function elgg_register_external_file($type, $url, $id, $location) {
}
if (!isset($CONFIG->externals[$type])) {
- $CONFIG->externals[$type] = array();
+ $CONFIG->externals[$type] = array();
}
if (!isset($CONFIG->externals[$type][$location])) {
@@ -387,6 +387,22 @@ function elgg_count_comments($entity) {
}
/**
+ * Returns all php files in a directory.
+ *
+ * @deprecated 1.7 Use elgg_get_file_list() instead
+ *
+ * @param string $directory Directory to look in
+ * @param array $exceptions Array of extensions (with .!) to ignore
+ * @param array $list A list files to include in the return
+ *
+ * @return array
+ */
+function get_library_files($directory, $exceptions = array(), $list = array()) {
+ elgg_deprecated_notice('get_library_files() deprecated by elgg_get_file_list()', 1.7);
+ return elgg_get_file_list($directory, $exceptions, $list, array('.php'));
+}
+
+/**
* Returns a list of files in $directory.
*
* Only returns files. Does not recurse into subdirs.
@@ -476,7 +492,7 @@ $children_array = array()) {
}
if (!isset($CONFIG->registers[$register_name])) {
- $CONFIG->registers[$register_name] = array();
+ $CONFIG->registers[$register_name] = array();
}
$subregister = new stdClass;
@@ -552,6 +568,25 @@ function make_register_object($register_name, $register_value, $children_array =
}
/**
+ * If it exists, returns a particular register as an array
+ *
+ * @param string $register_name The name of the register
+ *
+ * @return array|false Depending on success
+ * @deprecated 1.8
+ */
+function get_register($register_name) {
+ elgg_deprecated_notice("get_register() has been deprecated", 1.8);
+ global $CONFIG;
+
+ if (isset($CONFIG->registers[$register_name])) {
+ return $CONFIG->registers[$register_name];
+ }
+
+ return false;
+}
+
+/**
* Queues a message to be displayed.
*
* Messages will not be displayed immediately, but are stored in
@@ -657,6 +692,33 @@ function register_error($error) {
}
/**
+ * Deprecated events core function. Code divided between elgg_register_event_handler()
+ * and trigger_elgg_event().
+ *
+ * @param string $event The type of event (eg 'init', 'update', 'delete')
+ * @param string $object_type The type of object (eg 'system', 'blog', 'user')
+ * @param string $function The name of the function that will handle the event
+ * @param int $priority Priority to call handler. Lower numbers called first (default 500)
+ * @param boolean $call Set to true to call the event rather than add to it (default false)
+ * @param mixed $object Optionally, the object the event is being performed on (eg a user)
+ *
+ * @return true|false Depending on success
+ * @deprecated 1.8 Use explicit register/trigger event functions
+ */
+function events($event = "", $object_type = "", $function = "", $priority = 500,
+$call = false, $object = null) {
+
+ elgg_deprecated_notice('events() has been deprecated.', 1.8);
+
+ // leaving this here just in case someone was directly calling this internal function
+ if (!$call) {
+ return elgg_register_event_handler($event, $object_type, $function, $priority);
+ } else {
+ return trigger_elgg_event($event, $object_type, $object);
+ }
+}
+
+/**
* Register a callback as an Elgg event handler.
*
* Events are emitted by Elgg when certain actions occur. Plugins
@@ -747,6 +809,14 @@ function elgg_register_event_handler($event, $object_type, $callback, $priority
}
/**
+ * @deprecated 1.8 Use elgg_register_event_handler() instead
+ */
+function register_elgg_event_handler($event, $object_type, $callback, $priority = 500) {
+ elgg_deprecated_notice("register_elgg_event_handler() was deprecated by elgg_register_event_handler()", 1.8);
+ return elgg_register_event_handler($event, $object_type, $callback, $priority);
+}
+
+/**
* Unregisters a callback for an event.
*
* @param string $event The event type
@@ -766,6 +836,14 @@ function elgg_unregister_event_handler($event, $object_type, $callback) {
}
/**
+ * @deprecated 1.8 Use elgg_unregister_event_handler instead
+ */
+function unregister_elgg_event_handler($event, $object_type, $callback) {
+ elgg_deprecated_notice('unregister_elgg_event_handler => elgg_unregister_event_handler', 1.8);
+ elgg_unregister_event_handler($event, $object_type, $callback);
+}
+
+/**
* Trigger an Elgg Event and run all handler callbacks registered to that event, type.
*
* This function runs all handlers registered to $event, $object_type or
@@ -829,6 +907,14 @@ function elgg_trigger_event($event, $object_type, $object = null) {
}
/**
+ * @deprecated 1.8 Use elgg_trigger_event() instead
+ */
+function trigger_elgg_event($event, $object_type, $object = null) {
+ elgg_deprecated_notice('trigger_elgg_event() was deprecated by elgg_trigger_event()', 1.8);
+ return elgg_trigger_event($event, $object_type, $object);
+}
+
+/**
* Register a callback as a plugin hook handler.
*
* Plugin hooks allow developers to losely couple plugins and features by
@@ -926,6 +1012,14 @@ function elgg_register_plugin_hook_handler($hook, $type, $callback, $priority =
}
/**
+ * @deprecated 1.8 Use elgg_register_plugin_hook_handler() instead
+ */
+function register_plugin_hook($hook, $type, $callback, $priority = 500) {
+ elgg_deprecated_notice("register_plugin_hook() was deprecated by elgg_register_plugin_hook_handler()", 1.8);
+ return elgg_register_plugin_hook_handler($hook, $type, $callback, $priority);
+}
+
+/**
* Unregister a callback as a plugin hook.
*
* @param string $hook The name of the hook
@@ -945,6 +1039,14 @@ function elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback) {
}
/**
+ * @deprecated 1.8 Use elgg_unregister_plugin_hook_handler() instead
+ */
+function unregister_plugin_hook($hook, $entity_type, $callback) {
+ elgg_deprecated_notice("unregister_plugin_hook() was deprecated by elgg_unregister_plugin_hook_handler()", 1.8);
+ elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback);
+}
+
+/**
* Trigger a Plugin Hook and run all handler callbacks registered to that hook:type.
*
* This function runs all handlers regsitered to $hook, $type or
@@ -1019,6 +1121,14 @@ function elgg_trigger_plugin_hook($hook, $type, $params = null, $returnvalue = n
}
/**
+ * @deprecated 1.8 Use elgg_trigger_plugin_hook() instead
+ */
+function trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) {
+ elgg_deprecated_notice("trigger_plugin_hook() was deprecated by elgg_trigger_plugin_hook()", 1.8);
+ return elgg_trigger_plugin_hook($hook, $type, $params, $returnvalue);
+}
+
+/**
* Intercepts, logs, and display uncaught exceptions.
*
* @warning This function should never be called directly.
@@ -1079,8 +1189,8 @@ function _elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
throw new Exception($error);
break;
- case E_WARNING:
- case E_USER_WARNING:
+ case E_WARNING :
+ case E_USER_WARNING :
error_log("PHP WARNING: $error");
break;
@@ -1259,6 +1369,163 @@ function elgg_deprecated_notice($msg, $dep_version) {
return TRUE;
}
+
+/**
+ * Checks if code is being called from a certain function.
+ *
+ * To use, call this function with the function name (and optional
+ * file location) that it has to be called from, it will either
+ * return true or false.
+ *
+ * e.g.
+ *
+ * function my_secure_function()
+ * {
+ * if (!call_gatekeeper("my_call_function"))
+ * return false;
+ *
+ * ... do secure stuff ...
+ * }
+ *
+ * function my_call_function()
+ * {
+ * // will work
+ * my_secure_function();
+ * }
+ *
+ * function bad_function()
+ * {
+ * // Will not work
+ * my_secure_function();
+ * }
+ *
+ * @param mixed $function The function that this function must have in its call stack,
+ * to test against a method pass an array containing a class and
+ * method name.
+ * @param string $file Optional file that the function must reside in.
+ *
+ * @return bool
+ *
+ * @deprecated 1.8 A neat but pointless function
+ */
+function call_gatekeeper($function, $file = "") {
+ elgg_deprecated_notice("call_gatekeeper() is neat but pointless", 1.8);
+ // Sanity check
+ if (!$function) {
+ return false;
+ }
+
+ // Check against call stack to see if this is being called from the correct location
+ $callstack = debug_backtrace();
+ $stack_element = false;
+
+ foreach ($callstack as $call) {
+ if (is_array($function)) {
+ if (
+ (strcmp($call['class'], $function[0]) == 0) &&
+ (strcmp($call['function'], $function[1]) == 0)
+ ) {
+ $stack_element = $call;
+ }
+ } else {
+ if (strcmp($call['function'], $function) == 0) {
+ $stack_element = $call;
+ }
+ }
+ }
+
+ if (!$stack_element) {
+ return false;
+ }
+
+ // If file then check that this it is being called from this function
+ if ($file) {
+ $mirror = null;
+
+ if (is_array($function)) {
+ $mirror = new ReflectionMethod($function[0], $function[1]);
+ } else {
+ $mirror = new ReflectionFunction($function);
+ }
+
+ if ((!$mirror) || (strcmp($file, $mirror->getFileName()) != 0)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * This function checks to see if it is being called at somepoint by a function defined somewhere
+ * on a given path (optionally including subdirectories).
+ *
+ * This function is similar to call_gatekeeper() but returns true if it is being called
+ * by a method or function which has been defined on a given path or by a specified file.
+ *
+ * @param string $path The full path and filename that this function must have
+ * in its call stack If a partial path is given and
+ * $include_subdirs is true, then the function will return
+ * true if called by any function in or below the specified path.
+ * @param bool $include_subdirs Are subdirectories of the path ok, or must you specify an
+ * absolute path and filename.
+ * @param bool $strict_mode If true then the calling method or function must be directly
+ * called by something on $path, if false the whole call stack is
+ * searched.
+ *
+ * @return void
+ *
+ * @deprecated 1.8 A neat but pointless function
+ */
+function callpath_gatekeeper($path, $include_subdirs = true, $strict_mode = false) {
+ elgg_deprecated_notice("callpath_gatekeeper() is neat but pointless", 1.8);
+
+ global $CONFIG;
+
+ $path = sanitise_string($path);
+
+ if ($path) {
+ $callstack = debug_backtrace();
+
+ foreach ($callstack as $call) {
+ $call['file'] = str_replace("\\", "/", $call['file']);
+
+ if ($include_subdirs) {
+ if (strpos($call['file'], $path) === 0) {
+
+ if ($strict_mode) {
+ $callstack[1]['file'] = str_replace("\\", "/", $callstack[1]['file']);
+ if ($callstack[1] === $call) {
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+ } else {
+ if (strcmp($path, $call['file']) == 0) {
+ if ($strict_mode) {
+ if ($callstack[1] === $call) {
+ return true;
+ }
+ } else {
+ return true;
+ }
+ }
+ }
+
+ }
+ return false;
+ }
+
+ if (isset($CONFIG->debug)) {
+ system_message("Gatekeeper'd function called from {$callstack[1]['file']}:"
+ . "{$callstack[1]['line']}\n\nStack trace:\n\n" . print_r($callstack, true));
+ }
+
+ return false;
+}
+
/**
* Returns the current page's complete URL.
*
@@ -1391,6 +1658,23 @@ function elgg_add_action_tokens_to_url($url, $html_encode = FALSE) {
return elgg_http_build_url($components, $html_encode);
}
+
+/**
+ * Add action tokens to URL.
+ *
+ * @param string $url URL
+ *
+ * @return string
+ *
+ * @deprecated 1.7 final
+ */
+function elgg_validate_action_url($url) {
+ elgg_deprecated_notice('elgg_validate_action_url() deprecated by elgg_add_action_tokens_to_url().',
+ '1.7b');
+
+ return elgg_add_action_tokens_to_url($url);
+}
+
/**
* Removes an element from a URL's query string.
*
@@ -1726,7 +2010,7 @@ $sort_type = SORT_LOCALE_STRING) {
} else {
$sort[] = NULL;
}
- }
+ };
return array_multisort($sort, $sort_order, $sort_type, $array);
}
@@ -1767,7 +2051,7 @@ function elgg_get_ini_setting_in_bytes($setting) {
// convert INI setting when shorthand notation is used
$last = strtolower($val[strlen($val) - 1]);
- switch ($last) {
+ switch($last) {
case 'g':
$val *= 1024;
case 'm':
@@ -1834,6 +2118,30 @@ function elgg_normalise_plural_options_array($options, $singulars) {
}
/**
+ * Does nothing.
+ *
+ * @deprecated 1.7
+ * @return 0
+ */
+function test_ip() {
+ elgg_deprecated_notice('test_ip() was removed because of licensing issues.', 1.7);
+
+ return 0;
+}
+
+/**
+ * Does nothing.
+ *
+ * @return bool
+ * @deprecated 1.7
+ */
+function is_ip_in_array() {
+ elgg_deprecated_notice('is_ip_in_array() was removed because of licensing issues.', 1.7);
+
+ return false;
+}
+
+/**
* Emits a shutdown:system event upon PHP shutdown, but before database connections are dropped.
*
* @tip Register for the shutdown:system event to perform functions at the end of page loads.
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index 2a3c6ba91..aebaf1724 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -674,6 +674,7 @@ function get_entity($guid) {
return entity_row_to_elggstar(get_entity_as_row($guid));
}
+
/**
* Returns an array of entities with optional filtering.
*
@@ -884,6 +885,99 @@ function elgg_get_entities(array $options = array()) {
}
/**
+ * Returns entities.
+ *
+ * @deprecated 1.7. Use elgg_get_entities().
+ *
+ * @param string $type Entity type
+ * @param string $subtype Entity subtype
+ * @param int $owner_guid Owner GUID
+ * @param string $order_by Order by clause
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @param bool $count Return a count or an array of entities
+ * @param int $site_guid Site GUID
+ * @param int $container_guid Container GUID
+ * @param int $timelower Lower time limit
+ * @param int $timeupper Upper time limit
+ *
+ * @return array
+ */
+function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10,
+$offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0,
+$timeupper = 0) {
+
+ elgg_deprecated_notice('get_entities() was deprecated by elgg_get_entities().', 1.7);
+
+ // rewrite owner_guid to container_guid to emulate old functionality
+ if ($owner_guid != "") {
+ if (is_null($container_guid)) {
+ $container_guid = $owner_guid;
+ $owner_guid = NULL;
+ }
+ }
+
+ $options = array();
+ if ($type) {
+ if (is_array($type)) {
+ $options['types'] = $type;
+ } else {
+ $options['type'] = $type;
+ }
+ }
+
+ if ($subtype) {
+ if (is_array($subtype)) {
+ $options['subtypes'] = $subtype;
+ } else {
+ $options['subtype'] = $subtype;
+ }
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ if ($order_by) {
+ $options['order_by'] = $order_by;
+ }
+
+ // need to pass 0 for all option
+ $options['limit'] = $limit;
+
+ if ($offset) {
+ $options['offset'] = $offset;
+ }
+
+ if ($count) {
+ $options['count'] = $count;
+ }
+
+ if ($site_guid) {
+ $options['site_guids'] = $site_guid;
+ }
+
+ if ($container_guid) {
+ $options['container_guids'] = $container_guid;
+ }
+
+ if ($timeupper) {
+ $options['created_time_upper'] = $timeupper;
+ }
+
+ if ($timelower) {
+ $options['created_time_lower'] = $timelower;
+ }
+
+ $r = elgg_get_entities($options);
+ return $r;
+}
+
+/**
* Returns SQL where clause for type and subtype on main entity table
*
* @param string $table Entity table prefix as defined in SELECT...FROM entities $table
@@ -1085,6 +1179,43 @@ function elgg_get_guid_based_where_sql($column, $guids) {
}
/**
+ * Returns SQL where clause for owner and containers.
+ *
+ * @deprecated 1.8 Use elgg_get_guid_based_where_sql();
+ *
+ * @param string $table Entity table prefix as defined in SELECT...FROM entities $table
+ * @param NULL|array $owner_guids Owner GUIDs
+ *
+ * @return FALSE|str
+ * @since 1.7.0
+ * @access private
+ */
+function elgg_get_entity_owner_where_sql($table, $owner_guids) {
+ elgg_deprecated_notice('elgg_get_entity_owner_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
+
+ return elgg_get_guid_based_where_sql("{$table}.owner_guid", $owner_guids);
+}
+
+/**
+ * Returns SQL where clause for containers.
+ *
+ * @deprecated 1.8 Use elgg_get_guid_based_where_sql();
+ *
+ * @param string $table Entity table prefix as defined in
+ * SELECT...FROM entities $table
+ * @param NULL|array $container_guids Array of container guids
+ *
+ * @return FALSE|string
+ * @since 1.7.0
+ * @access private
+ */
+function elgg_get_entity_container_where_sql($table, $container_guids) {
+ elgg_deprecated_notice('elgg_get_entity_container_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
+
+ return elgg_get_guid_based_where_sql("{$table}.container_guid", $container_guids);
+}
+
+/**
* Returns SQL where clause for entity time limits.
*
* @param string $table Entity table prefix as defined in
@@ -1129,6 +1260,24 @@ $time_created_lower = NULL, $time_updated_upper = NULL, $time_updated_lower = NU
}
/**
+ * Returns SQL where clause for site entities
+ *
+ * @deprecated 1.8 Use elgg_get_guid_based_where_sql()
+ *
+ * @param string $table Entity table prefix as defined in SELECT...FROM entities $table
+ * @param NULL|array $site_guids Array of site guids
+ *
+ * @return FALSE|string
+ * @since 1.7.0
+ * @access private
+ */
+function elgg_get_entity_site_where_sql($table, $site_guids) {
+ elgg_deprecated_notice('elgg_get_entity_site_where_sql() is deprecated by elgg_get_guid_based_where_sql().', 1.8);
+
+ return elgg_get_guid_based_where_sql("{$table}.site_guid", $site_guids);
+}
+
+/**
* Returns a string of parsed entities.
*
* Displays list of entities with formatting specified
@@ -1178,6 +1327,56 @@ function elgg_list_entities(array $options = array(), $getter = 'elgg_get_entiti
}
/**
+ * Lists entities
+ *
+ * @deprecated 1.7. Use elgg_list_entities().
+ *
+ * @param string $type Entity type
+ * @param string $subtype Entity subtype
+ * @param int $owner_guid Owner GUID
+ * @param int $limit Limit
+ * @param bool $fullview Display entity full views?
+ * @param bool $listtypetoggle Allow switching to gallery mode?
+ * @param bool $pagination Show pagination?
+ *
+ * @return string
+ */
+function list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true,
+$listtypetoggle = false, $pagination = true) {
+
+ elgg_deprecated_notice('list_entities() was deprecated by elgg_list_entities()!', 1.7);
+
+ $options = array();
+
+ // rewrite owner_guid to container_guid to emulate old functionality
+ if ($owner_guid) {
+ $options['container_guids'] = $owner_guid;
+ }
+
+ if ($type) {
+ $options['types'] = $type;
+ }
+
+ if ($subtype) {
+ $options['subtypes'] = $subtype;
+ }
+
+ if ($limit) {
+ $options['limit'] = $limit;
+ }
+
+ if ($offset = sanitise_int(get_input('offset', null))) {
+ $options['offset'] = $offset;
+ }
+
+ $options['full_view'] = $fullview;
+ $options['list_type_toggle'] = $listtypetoggle;
+ $options['pagination'] = $pagination;
+
+ return elgg_list_entities($options);
+}
+
+/**
* Returns a list of months in which entities were updated or created.
*
* @tip Use this to generate a list of archives by month for when entities were added or updated.
@@ -1479,6 +1678,25 @@ function delete_entity($guid, $recursive = true) {
}
/**
+ * Delete multiple entities that match a given query.
+ * This function iterates through and calls delete_entity on
+ * each one, this is somewhat inefficient but lets
+ * the 'delete' event be called for each entity.
+ *
+ * @deprecated 1.7. This is a dangerous function as it defaults to deleting everything.
+ *
+ * @param string $type The type of entity (eg "user", "object" etc)
+ * @param string $subtype The arbitrary subtype of the entity
+ * @param int $owner_guid The GUID of the owning user
+ *
+ * @return false
+ */
+function delete_entities($type = "", $subtype = "", $owner_guid = 0) {
+ elgg_deprecated_notice('delete_entities() was deprecated because no one should use it.', 1.7);
+ return false;
+}
+
+/**
* Exports attributes generated on the fly (volatile) about an entity.
*
* @param string $hook volatile
@@ -2103,6 +2321,47 @@ function entities_page_handler($page) {
}
/**
+ * Lists entities.
+ *
+ * @param int $owner_guid Owner GUID
+ * @param int $limit Limit
+ * @param bool $fullview Show entity full views
+ * @param bool $listtypetoggle Show list type toggle
+ * @param bool $allowedtypes A string of the allowed types
+ *
+ * @return string
+ * @deprecated 1.7. Use elgg_list_registered_entities().
+ */
+function list_registered_entities($owner_guid = 0, $limit = 10, $fullview = true,
+$listtypetoggle = false, $allowedtypes = true) {
+
+ elgg_deprecated_notice('list_registered_entities() was deprecated by elgg_list_registered_entities().', 1.7);
+
+ $options = array();
+
+ // don't want to send anything if not being used.
+ if ($owner_guid) {
+ $options['owner_guid'] = $owner_guid;
+ }
+
+ if ($limit) {
+ $options['limit'] = $limit;
+ }
+
+ if ($allowedtypes) {
+ $options['allowed_types'] = $allowedtypes;
+ }
+
+ // need to send because might be BOOL
+ $options['full_view'] = $fullview;
+ $options['list_type_toggle'] = $listtypetoggle;
+
+ $options['offset'] = get_input('offset', 0);
+
+ return elgg_list_registered_entities($options);
+}
+
+/**
* Returns a viewable list of entities based on the registered types.
*
* @see elgg_view_entity_list
@@ -2215,6 +2474,7 @@ function elgg_instanceof($entity, $type = NULL, $subtype = NULL, $class = NULL)
return $return;
}
+
/**
* Update the last_action column in the entities table for $guid.
*
diff --git a/engine/lib/group.php b/engine/lib/group.php
index 7b3f76e27..e69ae6070 100644
--- a/engine/lib/group.php
+++ b/engine/lib/group.php
@@ -79,6 +79,23 @@ function create_group_entity($guid, $name, $description) {
}
/**
+ * THIS FUNCTION IS DEPRECATED.
+ *
+ * Delete a group's extra data.
+ *
+ * @param int $guid The guid of the group
+ *
+ * @return bool
+ * @deprecated 1.6
+ */
+function delete_group_entity($guid) {
+ elgg_deprecated_notice("delete_group_entity has been deprecated", 1.6);
+
+ // Always return that we have deleted one row in order to not break existing code.
+ return 1;
+}
+
+/**
* Add an object to the given group.
*
* @param int $group_guid The group to add the object to.
@@ -147,6 +164,352 @@ function remove_object_from_group($group_guid, $object_guid) {
}
/**
+ * Return an array of objects in a given container.
+ *
+ * @see get_entities()
+ *
+ * @param int $group_guid The container (defaults to current page owner)
+ * @param string $subtype The subtype
+ * @param int $owner_guid Owner
+ * @param int $site_guid The site
+ * @param string $order_by Order
+ * @param int $limit Limit on number of elements to return, by default 10.
+ * @param int $offset Where to start, by default 0.
+ * @param bool $count Whether to return the entities or a count of them.
+ *
+ * @return array|false
+ * @deprecated 1.8 Use elgg_get_entities() instead
+ */
+function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0,
+$order_by = "", $limit = 10, $offset = 0, $count = FALSE) {
+ elgg_deprecated_notice("get_objects_in_group was deprected in 1.8. Use elgg_get_entities() instead", 1.8);
+
+ global $CONFIG;
+
+ if ($subtype === FALSE || $subtype === null || $subtype === 0) {
+ return FALSE;
+ }
+
+ if ($order_by == "") {
+ $order_by = "e.time_created desc";
+ }
+ $order_by = sanitise_string($order_by);
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0) {
+ $site_guid = $CONFIG->site_guid;
+ }
+
+ $container_guid = (int)$group_guid;
+ if ($container_guid == 0) {
+ $container_guid = elgg_get_page_owner_guid();
+ }
+
+ $where = array();
+
+ $where[] = "e.type='object'";
+
+ if (!empty($subtype)) {
+ if (!$subtype = get_subtype_id('object', $subtype)) {
+ return FALSE;
+ }
+ $where[] = "e.subtype=$subtype";
+ }
+ if ($owner_guid != "") {
+ if (!is_array($owner_guid)) {
+ $owner_guid = (int) $owner_guid;
+ $where[] = "e.container_guid = '$owner_guid'";
+ } else if (sizeof($owner_guid) > 0) {
+ // Cast every element to the owner_guid array to int
+ $owner_guid = array_map("sanitise_int", $owner_guid);
+ $owner_guid = implode(",", $owner_guid);
+ $where[] = "e.container_guid in ({$owner_guid})";
+ }
+ }
+ if ($site_guid > 0) {
+ $where[] = "e.site_guid = {$site_guid}";
+ }
+
+ if ($container_guid > 0) {
+ $where[] = "e.container_guid = {$container_guid}";
+ }
+
+ if (!$count) {
+ $query = "SELECT * from {$CONFIG->dbprefix}entities e"
+ . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
+ } else {
+ $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e"
+ . " join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where ";
+ }
+ foreach ($where as $w) {
+ $query .= " $w and ";
+ }
+
+ // Add access controls
+ $query .= get_access_sql_suffix('e');
+ if (!$count) {
+ $query .= " order by $order_by";
+
+ // Add order and limit
+ if ($limit) {
+ $query .= " limit $offset, $limit";
+ }
+
+ $dt = get_data($query, "entity_row_to_elggstar");
+ return $dt;
+ } else {
+ $total = get_data_row($query);
+ return $total->total;
+ }
+}
+
+/**
+ * Lists entities that belong to a group.
+ *
+ * @param string $subtype The arbitrary subtype of the entity
+ * @param int $owner_guid The GUID of the owning user
+ * @param int $container_guid The GUID of the containing group
+ * @param int $limit The number of entities to display per page (default: 10)
+ * @param bool $fullview Whether or not to display the full view (default: true)
+ * @param bool $listtypetoggle Whether or not to allow gallery view (default: true)
+ * @param bool $pagination Whether to display pagination (default: true)
+ *
+ * @return string List of parsed entities
+ *
+ * @see elgg_list_entities()
+ * @deprecated 1.8 Use elgg_list_entities() instead
+ */
+function list_entities_groups($subtype = "", $owner_guid = 0, $container_guid = 0,
+$limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
+ elgg_deprecated_notice("list_entities_groups was deprecated in 1.8. Use elgg_list_entities() instead.", 1.8);
+ $offset = (int) get_input('offset');
+ $count = get_objects_in_group($container_guid, $subtype, $owner_guid,
+ 0, "", $limit, $offset, true);
+ $entities = get_objects_in_group($container_guid, $subtype, $owner_guid,
+ 0, "", $limit, $offset);
+
+ return elgg_view_entity_list($entities, $count, $offset, $limit,
+ $fullview, $listtypetoggle, $pagination);
+}
+
+/**
+ * Get all the entities from metadata from a group.
+ *
+ * @param int $group_guid The ID of the group.
+ * @param mixed $meta_name Metadata name
+ * @param mixed $meta_value Metadata value
+ * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+ * @param string $entity_subtype The subtype of the entity.
+ * @param int $owner_guid Owner guid
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @param string $order_by Optional ordering.
+ * @param int $site_guid Site GUID. 0 for current, -1 for any
+ * @param bool $count Return count instead of entities
+ *
+ * @return array|false
+ * @deprecated 1.8 Use elgg_get_entities_from_metadata()
+ */
+function get_entities_from_metadata_groups($group_guid, $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_entities_from_metadata_groups was deprecated in 1.8.", 1.8);
+ global $CONFIG;
+
+ $meta_n = get_metastring_id($meta_name);
+ $meta_v = get_metastring_id($meta_value);
+
+ $entity_type = sanitise_string($entity_type);
+ $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+ if ($order_by == "") {
+ $order_by = "e.time_created desc";
+ }
+ $order_by = sanitise_string($order_by);
+ $site_guid = (int) $site_guid;
+ if (is_array($owner_guid)) {
+ foreach ($owner_guid as $key => $guid) {
+ $owner_guid[$key] = (int) $guid;
+ }
+ } else {
+ $owner_guid = (int) $owner_guid;
+ }
+ if ($site_guid == 0) {
+ $site_guid = $CONFIG->site_guid;
+ }
+
+ $container_guid = (int)$group_guid;
+ if ($container_guid == 0) {
+ $container_guid = elgg_get_page_owner_guid();
+ }
+
+ $where = array();
+
+ if ($entity_type != "") {
+ $where[] = "e.type='$entity_type'";
+ }
+ if ($entity_subtype) {
+ $where[] = "e.subtype=$entity_subtype";
+ }
+ if ($meta_name != "") {
+ $where[] = "m.name_id='$meta_n'";
+ }
+ if ($meta_value != "") {
+ $where[] = "m.value_id='$meta_v'";
+ }
+ if ($site_guid > 0) {
+ $where[] = "e.site_guid = {$site_guid}";
+ }
+ if ($container_guid > 0) {
+ $where[] = "e.container_guid = {$container_guid}";
+ }
+
+ if (is_array($owner_guid)) {
+ $where[] = "e.container_guid in (" . implode(",", $owner_guid ) . ")";
+ } else if ($owner_guid > 0) {
+ $where[] = "e.container_guid = {$owner_guid}";
+ }
+
+ if (!$count) {
+ $query = "SELECT distinct e.* ";
+ } else {
+ $query = "SELECT count(e.guid) as total ";
+ }
+
+ $query .= "from {$CONFIG->dbprefix}entities e"
+ . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid "
+ . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid where";
+
+ foreach ($where as $w) {
+ $query .= " $w and ";
+ }
+
+ // Add access controls
+ $query .= get_access_sql_suffix("e");
+
+ if (!$count) {
+ $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+ return get_data($query, "entity_row_to_elggstar");
+ } else {
+ if ($row = get_data_row($query)) {
+ return $row->total;
+ }
+ }
+ return false;
+}
+
+/**
+ * As get_entities_from_metadata_groups() but with multiple entities.
+ *
+ * @param int $group_guid The ID of the group.
+ * @param array $meta_array Array of 'name' => 'value' pairs
+ * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+ * @param string $entity_subtype The subtype of the entity.
+ * @param int $owner_guid Owner GUID
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @param string $order_by Optional ordering.
+ * @param int $site_guid Site GUID. 0 for current, -1 for any
+ * @param bool $count Return count of entities instead of entities
+ *
+ * @return int|array List of ElggEntities, or the total number if count is set to false
+ * @deprecated 1.8 Use elgg_get_entities_from_metadata()
+ */
+function get_entities_from_metadata_groups_multi($group_guid, $meta_array, $entity_type = "",
+$entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "",
+$site_guid = 0, $count = false) {
+ elgg_deprecated_notice("get_entities_from_metadata_groups_multi was deprecated in 1.8.", 1.8);
+
+ global $CONFIG;
+
+ if (!is_array($meta_array) || sizeof($meta_array) == 0) {
+ return false;
+ }
+
+ $where = array();
+
+ $mindex = 1;
+ $join = "";
+ foreach ($meta_array as $meta_name => $meta_value) {
+ $meta_n = get_metastring_id($meta_name);
+ $meta_v = get_metastring_id($meta_value);
+ $join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid"
+ . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid ";
+
+ if ($meta_name != "") {
+ $where[] = "m{$mindex}.name_id='$meta_n'";
+ }
+
+ if ($meta_value != "") {
+ $where[] = "m{$mindex}.value_id='$meta_v'";
+ }
+
+ $mindex++;
+ }
+
+ $entity_type = sanitise_string($entity_type);
+ $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+ if ($order_by == "") {
+ $order_by = "e.time_created desc";
+ }
+ $order_by = sanitise_string($order_by);
+ $owner_guid = (int) $owner_guid;
+
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0) {
+ $site_guid = $CONFIG->site_guid;
+ }
+
+ //$access = get_access_list();
+
+ if ($entity_type != "") {
+ $where[] = "e.type = '{$entity_type}'";
+ }
+
+ if ($entity_subtype) {
+ $where[] = "e.subtype = {$entity_subtype}";
+ }
+
+ if ($site_guid > 0) {
+ $where[] = "e.site_guid = {$site_guid}";
+ }
+
+ if ($owner_guid > 0) {
+ $where[] = "e.owner_guid = {$owner_guid}";
+ }
+
+ if ($container_guid > 0) {
+ $where[] = "e.container_guid = {$container_guid}";
+ }
+
+ if ($count) {
+ $query = "SELECT count(e.guid) as total ";
+ } else {
+ $query = "SELECT distinct e.* ";
+ }
+
+ $query .= " from {$CONFIG->dbprefix}entities e {$join} where";
+ foreach ($where as $w) {
+ $query .= " $w and ";
+ }
+ $query .= get_access_sql_suffix("e"); // Add access controls
+
+ if (!$count) {
+ $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+ return get_data($query, "entity_row_to_elggstar");
+ } else {
+ if ($count = get_data_row($query)) {
+ return $count->total;
+ }
+ }
+ return false;
+}
+
+/**
* Return a list of this group's members.
*
* @param int $group_guid The ID of the container/group.
@@ -332,3 +695,109 @@ function remove_group_tool_option($name) {
}
}
}
+
+
+/**
+ * Searches for a group based on a complete or partial name or description
+ *
+ * @param string $criteria The partial or full name or description
+ * @param int $limit Limit of the search.
+ * @param int $offset Offset.
+ * @param string $order_by The order.
+ * @param boolean $count Whether to return the count of results or just the results.
+ *
+ * @return mixed
+ * @deprecated 1.7
+ */
+function search_for_group($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
+ elgg_deprecated_notice('search_for_group() was deprecated by new search plugin.', 1.7);
+ global $CONFIG;
+
+ $criteria = sanitise_string($criteria);
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+ $order_by = sanitise_string($order_by);
+
+ $access = get_access_sql_suffix("e");
+
+ if ($order_by == "") {
+ $order_by = "e.time_created desc";
+ }
+
+ if ($count) {
+ $query = "SELECT count(e.guid) as total ";
+ } else {
+ $query = "SELECT e.* ";
+ }
+ $query .= "from {$CONFIG->dbprefix}entities e"
+ . " JOIN {$CONFIG->dbprefix}groups_entity g on e.guid=g.guid where ";
+
+ $query .= "(g.name like \"%{$criteria}%\" or g.description like \"%{$criteria}%\")";
+ $query .= " and $access";
+
+ if (!$count) {
+ $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+ return get_data($query, "entity_row_to_elggstar");
+ } else {
+ if ($count = get_data_row($query)) {
+ return $count->total;
+ }
+ }
+ return false;
+}
+
+/**
+ * Returns a formatted list of groups suitable for injecting into search.
+ *
+ * @deprecated 1.7
+ *
+ * @param string $hook Hook name
+ * @param string $user User
+ * @param mixed $returnvalue Previous hook's return value
+ * @param string $tag Tag to search on
+ *
+ * @return string
+ */
+function search_list_groups_by_name($hook, $user, $returnvalue, $tag) {
+ elgg_deprecated_notice('search_list_groups_by_name() was deprecated by new search plugin', 1.7);
+ // Change this to set the number of groups that display on the search page
+ $threshold = 4;
+
+ $object = get_input('object');
+
+ if (!get_input('offset') && (empty($object) || $object == 'group')) {
+ if ($groups = search_for_group($tag, $threshold)) {
+ $countgroups = search_for_group($tag, 0, 0, "", true);
+
+ $return = elgg_view('group/search/startblurb', array('count' => $countgroups, 'tag' => $tag));
+ foreach ($groups as $group) {
+ $return .= elgg_view_entity($group);
+ }
+ $vars = array('count' => $countgroups, 'threshold' => $threshold, 'tag' => $tag);
+ $return .= elgg_view('group/search/finishblurb', $vars);
+ return $return;
+ }
+ }
+}
+
+/**
+ * Displays a list of group objects that have been searched for.
+ *
+ * @see elgg_view_entity_list
+ *
+ * @param string $tag Search criteria
+ * @param int $limit The number of entities to display on a page
+ *
+ * @return string The list in a form suitable to display
+ * @deprecated 1.7
+ */
+function list_group_search($tag, $limit = 10) {
+ elgg_deprecated_notice('list_group_search() was deprecated by new search plugin.', 1.7);
+ $offset = (int) get_input('offset');
+ $limit = (int) $limit;
+ $count = (int) search_for_group($tag, 10, 0, '', true);
+ $entities = search_for_group($tag, $limit, $offset);
+
+ return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, false);
+
+}
diff --git a/engine/lib/install.php b/engine/lib/install.php
index 57ddf03f5..cfb8ac7ec 100644
--- a/engine/lib/install.php
+++ b/engine/lib/install.php
@@ -8,4 +8,14 @@
* @subpackage Installation
*/
+// these were internal functions that perhaps can be removed rather than deprecated
+function is_db_installed() {
+ elgg_deprecated_notice('is_db_installed() has been deprecated', 1.8);
+ return true;
+}
+
+function is_installed() {
+ elgg_deprecated_notice('is_installed() has been deprecated', 1.8);
+ return true;
+}
diff --git a/engine/lib/location.php b/engine/lib/location.php
index 7e2c38fc8..4819bc9b0 100644
--- a/engine/lib/location.php
+++ b/engine/lib/location.php
@@ -54,6 +54,87 @@ function elgg_geocode_location($location) {
/**
* Return entities within a given geographic area.
*
+ * @param float $lat Latitude
+ * @param float $long Longitude
+ * @param float $radius The radius
+ * @param string $type The type of entity (eg "user", "object" etc)
+ * @param string $subtype The arbitrary subtype of the entity
+ * @param int $owner_guid The GUID of the owning user
+ * @param string $order_by The field to order by; by default, time_created desc
+ * @param int $limit The number of entities to return; 10 by default
+ * @param int $offset The indexing offset, 0 by default
+ * @param boolean $count Count entities
+ * @param int $site_guid Site GUID. 0 for current, -1 for any
+ * @param int|array $container_guid Container GUID
+ *
+ * @return array A list of entities.
+ * @deprecated 1.8
+ */
+function get_entities_in_area($lat, $long, $radius, $type = "", $subtype = "", $owner_guid = 0,
+$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = NULL) {
+ elgg_deprecated_notice('get_entities_in_area() was deprecated by elgg_get_entities_from_location()!', 1.8);
+
+ $options = array();
+
+ $options['latitude'] = $lat;
+ $options['longitude'] = $long;
+ $options['distance'] = $radius;
+
+ // set container_guid to owner_guid to emulate old functionality
+ if ($owner_guid != "") {
+ if (is_null($container_guid)) {
+ $container_guid = $owner_guid;
+ }
+ }
+
+ if ($type) {
+ $options['types'] = $type;
+ }
+
+ if ($subtype) {
+ $options['subtypes'] = $subtype;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ if ($container_guid) {
+ if (is_array($container_guid)) {
+ $options['container_guids'] = $container_guid;
+ } else {
+ $options['container_guid'] = $container_guid;
+ }
+ }
+
+ $options['limit'] = $limit;
+
+ if ($offset) {
+ $options['offset'] = $offset;
+ }
+
+ if ($order_by) {
+ $options['order_by'];
+ }
+
+ if ($site_guid) {
+ $options['site_guid'];
+ }
+
+ if ($count) {
+ $options['count'] = $count;
+ }
+
+ return elgg_get_entities_from_location($options);
+}
+
+/**
+ * Return entities within a given geographic area.
+ *
* Also accepts all options available to elgg_get_entities().
*
* @see elgg_get_entities
@@ -137,6 +218,29 @@ function elgg_get_entities_from_location(array $options = array()) {
}
/**
+ * List entities in a given location
+ *
+ * @param string $location Location
+ * @param string $type The type of entity (eg "user", "object" etc)
+ * @param string $subtype The arbitrary subtype of the entity
+ * @param int $owner_guid The GUID of the owning user
+ * @param int $limit The number of entities to display per page (default: 10)
+ * @param bool $fullview Whether or not to display the full view (default: true)
+ * @param bool $listtypetoggle Whether or not to allow gallery view
+ * @param bool $navigation Display pagination? Default: true
+ *
+ * @return string A viewable list of entities
+ * @deprecated 1.8
+ */
+function list_entities_location($location, $type= "", $subtype = "", $owner_guid = 0, $limit = 10,
+$fullview = true, $listtypetoggle = false, $navigation = true) {
+ elgg_deprecated_notice('list_entities_location() was deprecated. Use elgg_list_entities_from_metadata()', 1.8);
+
+ return list_entities_from_metadata('location', $location, $type, $subtype, $owner_guid, $limit,
+ $fullview, $listtypetoggle, $navigation);
+}
+
+/**
* Returns a viewable list of entities from location
*
* @param array $options
@@ -151,6 +255,58 @@ function elgg_list_entities_from_location(array $options = array()) {
return elgg_list_entities($options, 'elgg_get_entities_from_location');
}
+/**
+ * List items within a given geographic area.
+ *
+ * @param real $lat Latitude
+ * @param real $long Longitude
+ * @param real $radius The radius
+ * @param string $type The type of entity (eg "user", "object" etc)
+ * @param string $subtype The arbitrary subtype of the entity
+ * @param int $owner_guid The GUID of the owning user
+ * @param int $limit The number of entities to display per page (default: 10)
+ * @param bool $fullview Whether or not to display the full view (default: true)
+ * @param bool $listtypetoggle Whether or not to allow gallery view
+ * @param bool $navigation Display pagination? Default: true
+ *
+ * @return string A viewable list of entities
+ * @deprecated 1.8
+ */
+function list_entities_in_area($lat, $long, $radius, $type= "", $subtype = "", $owner_guid = 0,
+$limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
+ elgg_deprecated_notice('list_entities_in_area() was deprecated. Use elgg_list_entities_from_location()', 1.8);
+
+ $options = array();
+
+ $options['latitude'] = $lat;
+ $options['longitude'] = $long;
+ $options['distance'] = $radius;
+
+ if ($type) {
+ $options['types'] = $type;
+ }
+
+ if ($subtype) {
+ $options['subtypes'] = $subtype;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ $options['limit'] = $limit;
+
+ $options['full_view'] = $fullview;
+ $options['list_type_toggle'] = $listtypetoggle;
+ $options['pagination'] = $pagination;
+
+ return elgg_list_entities_from_location($options);
+}
+
// Some distances in degrees (approximate)
// @todo huh? see warning on elgg_get_entities_from_location()
define("MILE", 0.01515);
diff --git a/engine/lib/mb_wrapper.php b/engine/lib/mb_wrapper.php
index 7e0e4c7ff..da7a96c1f 100644
--- a/engine/lib/mb_wrapper.php
+++ b/engine/lib/mb_wrapper.php
@@ -26,6 +26,8 @@ function elgg_parse_str($str) {
return $results;
}
+
+
/**
* Wrapper function for mb_split(). Falls back to split() if
* mb_split() isn't available. Parameters are passed to the
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 79bb774f8..0ae576328 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -890,6 +890,132 @@ $owner_guids = NULL) {
}
/**
+ * Return a list of entities based on the given search criteria.
+ *
+ * @deprecated 1.7 use elgg_get_entities_from_metadata().
+ *
+ * @param mixed $meta_name Metadat name
+ * @param mixed $meta_value Metadata value
+ * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+ * @param string $entity_subtype The subtype of the entity.
+ * @param int $owner_guid Owner GUID
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @param string $order_by Optional ordering.
+ * @param int $site_guid Site GUID. 0 for current, -1 for any.
+ * @param bool $count Return a count instead of entities
+ * @param bool $case_sensitive Metadata names case sensitivity
+ *
+ * @return int|array A list of entities, or a count if $count is set to true
+ */
+function get_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, $case_sensitive = TRUE) {
+
+ elgg_deprecated_notice('get_entities_from_metadata() was deprecated by elgg_get_entities_from_metadata()!', 1.7);
+
+ $options = array();
+
+ $options['metadata_names'] = $meta_name;
+
+ if ($meta_value) {
+ $options['metadata_values'] = $meta_value;
+ }
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
+ }
+
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ if ($limit) {
+ $options['limit'] = $limit;
+ }
+
+ if ($offset) {
+ $options['offset'] = $offset;
+ }
+
+ if ($order_by) {
+ $options['order_by'];
+ }
+
+ if ($site_guid) {
+ $options['site_guid'];
+ }
+
+ if ($count) {
+ $options['count'] = $count;
+ }
+
+ // need to be able to pass false
+ $options['metadata_case_sensitive'] = $case_sensitive;
+
+ return elgg_get_entities_from_metadata($options);
+}
+
+/**
+ * Return a list of entities suitable for display based on the given search criteria.
+ *
+ * @see elgg_view_entity_list
+ *
+ * @deprecated 1.8 Use elgg_list_entities_from_metadata
+ *
+ * @param mixed $meta_name Metadata name to search on
+ * @param mixed $meta_value The value to match, optionally
+ * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+ * @param string $entity_subtype The subtype of the entity
+ * @param int $owner_guid Owner GUID
+ * @param int $limit Number of entities to display per page
+ * @param bool $fullview WDisplay the full view (default: true)
+ * @param bool $listtypetoggle Allow users to toggle to the gallery view. Default: true
+ * @param bool $pagination Display pagination? Default: true
+ * @param bool $case_sensitive Case sensitive metadata names?
+ *
+ * @return string
+ *
+ * @return string A list of entities suitable for display
+ */
+function list_entities_from_metadata($meta_name, $meta_value = "",
+$entity_type = ELGG_ENTITIES_ANY_VALUE, $entity_subtype = ELGG_ENTITIES_ANY_VALUE,
+$owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true,
+$pagination = true, $case_sensitive = true) {
+
+ elgg_deprecated_notice('list_entities_from_metadata() was deprecated by elgg_list_entities_from_metadata()!', 1.8);
+
+ $offset = (int) get_input('offset');
+ $limit = (int) $limit;
+ $options = array(
+ 'metadata_name' => $meta_name,
+ 'metadata_value' => $meta_value,
+ 'types' => $entity_type,
+ 'subtypes' => $entity_subtype,
+ 'owner_guid' => $owner_guid,
+ 'limit' => $limit,
+ 'offset' => $offset,
+ 'count' => TRUE,
+ 'metadata_case_sensitive' => $case_sensitive
+ );
+ $count = elgg_get_entities_from_metadata($options);
+
+ $options['count'] = FALSE;
+ $entities = elgg_get_entities_from_metadata($options);
+
+ return elgg_view_entity_list($entities, $count, $offset, $limit,
+ $fullview, $listtypetoggle, $pagination);
+}
+
+/**
* Returns a list of entities filtered by provided metadata.
*
* @see elgg_get_entities_from_metadata
@@ -904,6 +1030,116 @@ function elgg_list_entities_from_metadata($options) {
}
/**
+ * Return entities from metadata
+ *
+ * @deprecated 1.7. Use elgg_get_entities_from_metadata().
+ *
+ * @param mixed $meta_array Metadata name
+ * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+ * @param string $entity_subtype The subtype of the entity.
+ * @param int $owner_guid Owner GUID
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @param string $order_by Optional ordering.
+ * @param int $site_guid Site GUID. 0 for current, -1 for any.
+ * @param bool $count Return a count instead of entities
+ * @param bool $meta_array_operator Operator for metadata values
+ *
+ * @return int|array A list of entities, or a count if $count is set to true
+ */
+function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "",
+$owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
+$count = false, $meta_array_operator = 'and') {
+
+ elgg_deprecated_notice('get_entities_from_metadata_multi() was deprecated by elgg_get_entities_from_metadata()!', 1.7);
+
+ if (!is_array($meta_array) || sizeof($meta_array) == 0) {
+ return false;
+ }
+
+ $options = array();
+
+ $options['metadata_name_value_pairs'] = $meta_array;
+
+ if ($entity_type) {
+ $options['types'] = $entity_type;
+ }
+
+ if ($entity_subtype) {
+ $options['subtypes'] = $entity_subtype;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ if ($limit) {
+ $options['limit'] = $limit;
+ }
+
+ if ($offset) {
+ $options['offset'] = $offset;
+ }
+
+ if ($order_by) {
+ $options['order_by'];
+ }
+
+ if ($site_guid) {
+ $options['site_guid'];
+ }
+
+ if ($count) {
+ $options['count'] = $count;
+ }
+
+ $options['metadata_name_value_pairs_operator'] = $meta_array_operator;
+
+ return elgg_get_entities_from_metadata($options);
+}
+
+/**
+ * Returns a viewable list of entities based on the given search criteria.
+ *
+ * @see elgg_view_entity_list
+ *
+ * @param array $meta_array Array of 'name' => 'value' pairs
+ * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+ * @param string $entity_subtype The subtype of the entity.
+ * @param int $owner_guid Owner GUID
+ * @param int $limit Limit
+ * @param bool $fullview WDisplay the full view (default: true)
+ * @param bool $listtypetoggle Allow users to toggle to the gallery view. Default: true
+ * @param bool $pagination Display pagination? Default: true
+ *
+ * @return string List of ElggEntities suitable for display
+ *
+ * @deprecated Use elgg_list_entities_from_metadata() instead
+ */
+function list_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "",
+$owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) {
+ elgg_deprecated_notice(elgg_echo('deprecated:function', array(
+ 'list_entities_from_metadata_multi',
+ 'elgg_get_entities_from_metadata'
+ )), 1.8);
+
+
+ $offset = (int) get_input('offset');
+ $limit = (int) $limit;
+ $count = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype,
+ $owner_guid, $limit, $offset, "", $site_guid, true);
+ $entities = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype,
+ $owner_guid, $limit, $offset, "", $site_guid, false);
+
+ return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview,
+ $listtypetoggle, $pagination);
+}
+
+/**
* Clear all the metadata for a given entity, assuming you have access to that metadata.
*
* @param int $entity_guid Entity GUID
diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php
index 80511832c..229adb0ed 100644
--- a/engine/lib/metastrings.php
+++ b/engine/lib/metastrings.php
@@ -22,7 +22,7 @@ $METASTRINGS_DEADNAME_CACHE = array();
* @param bool $case_sensitive Do we want to make the query case sensitive?
* If not there may be more than one result
*
- * @return int|array|false metastring id, array of ids or false if none found
+ * @return int|array|false meta string id, array of ids or false if none found
*/
function get_metastring_id($string, $case_sensitive = TRUE) {
global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index d11262933..8ed87ffb7 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -122,6 +122,122 @@ function elgg_get_breadcrumbs() {
return (is_array($CONFIG->breadcrumbs)) ? $CONFIG->breadcrumbs : array();
}
+
+/**
+ * Deprecated by elgg_register_menu_item(). Set $menu_name to 'page'.
+ *
+ * @see elgg_register_menu_item()
+ * @deprecated 1.8
+ *
+ * @param string $label The label
+ * @param string $link The link
+ * @param string $group The group to store item in
+ * @param boolean $onclick Add a confirmation when clicked?
+ * @param boolean $selected Is menu item selected
+ *
+ * @return bool
+ */
+function add_submenu_item($label, $link, $group = 'default', $onclick = false, $selected = NULL) {
+ elgg_deprecated_notice('add_submenu_item was deprecated by elgg_register_menu_item', 1.8);
+
+ // submenu items were added in the page setup hook usually by checking
+ // the context. We'll pass in the current context here, which will
+ // emulate that effect.
+ // if context == 'main' (default) it probably means they always wanted
+ // the menu item to show up everywhere.
+ $context = elgg_get_context();
+
+ if ($context == 'main') {
+ $context = 'all';
+ }
+
+ $item = array(
+ 'name' => $label,
+ 'title' => $label,
+ 'url' => $link,
+ 'context' => $context,
+ 'section' => $group,
+ );
+
+ if ($selected) {
+ $item['selected'] = true;
+ }
+
+ if ($onclick) {
+ $js = "onclick=\"javascript:return confirm('" . elgg_echo('deleteconfirm') . "')\"";
+ $item['vars'] = array('js' => $js);
+ }
+
+ return elgg_register_menu_item('page', $item);
+}
+
+/**
+ * Use elgg_view_menu(). Set $menu_name to 'owner_block'.
+ *
+ * @see elgg_view_menu()
+ * @deprecated 1.8
+ *
+ * @return string
+ */
+function get_submenu() {
+ elgg_deprecated_notice("get_submenu() has been deprecated by elgg_view_menu()", 1.8);
+ return elgg_view_menu('owner_block', array(
+ 'entity' => $owner,
+ 'class' => 'elgg-owner-block-menu',
+ ));
+}
+
+/**
+ * Adds an item to the site-wide menu.
+ *
+ * You can obtain the menu array by calling {@link get_register('menu')}
+ *
+ * @param string $menu_name The name of the menu item
+ * @param string $menu_url The URL of the page
+ * @param array $menu_children Optionally, an array of submenu items (not used)
+ * @param string $context (not used)
+ *
+ * @return true|false Depending on success
+ * @deprecated 1.8 use elgg_register_menu_item() for the menu 'site'
+ */
+function add_menu($menu_name, $menu_url, $menu_children = array(), $context = "") {
+ elgg_deprecated_notice('add_menu() deprecated by elgg_register_menu_item()', 1.8);
+
+ return elgg_register_menu_item('site', array(
+ 'name' => $menu_name,
+ 'title' => $menu_name,
+ 'url' => $menu_url,
+ ));
+}
+
+/**
+ * Removes an item from the menu register
+ *
+ * @param string $menu_name The name of the menu item
+ *
+ * @return true|false Depending on success
+ * @deprecated 1.8
+ */
+function remove_menu($menu_name) {
+ elgg_deprecated_notice("remove_menu() deprecated by elgg_unregister_menu_item()", 1.8);
+ return elgg_unregister_menu_item('site', $menu_name);
+}
+
+/**
+ * Returns a menu item for use in the children section of add_menu()
+ * This is not currently used in the Elgg core.
+ *
+ * @param string $menu_name The name of the menu item
+ * @param string $menu_url Its URL
+ *
+ * @return stdClass|false Depending on success
+ * @deprecated 1.7
+ */
+function menu_item($menu_name, $menu_url) {
+ elgg_deprecated_notice('menu_item() is deprecated by add_submenu_item', 1.7);
+ return make_register_object($menu_name, $menu_url);
+}
+
/**
* Set up the site menu
*
diff --git a/engine/lib/objects.php b/engine/lib/objects.php
index 184fe44bd..51b47df2a 100644
--- a/engine/lib/objects.php
+++ b/engine/lib/objects.php
@@ -95,6 +95,59 @@ function delete_object_entity($guid) {
}
/**
+ * Searches for an object based on a complete or partial title
+ * or description using full text searching.
+ *
+ * IMPORTANT NOTE: With MySQL's default setup:
+ * 1) $criteria must be 4 or more characters long
+ * 2) If $criteria matches greater than 50% of results NO RESULTS ARE RETURNED!
+ *
+ * @param string $criteria The partial or full name or username.
+ * @param int $limit Limit of the search.
+ * @param int $offset Offset.
+ * @param string $order_by The order.
+ * @param boolean $count Whether to return the count of results or just the results.
+ *
+ * @return int|false
+ * @deprecated 1.7
+ */
+function search_for_object($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) {
+ elgg_deprecated_notice('search_for_object() was deprecated by new search plugin.', 1.7);
+ global $CONFIG;
+
+ $criteria = sanitise_string($criteria);
+ $limit = (int)$limit;
+ $offset = (int)$offset;
+ $order_by = sanitise_string($order_by);
+ $container_guid = (int)$container_guid;
+
+ $access = get_access_sql_suffix("e");
+
+ if ($order_by == "") {
+ $order_by = "e.time_created desc";
+ }
+
+ if ($count) {
+ $query = "SELECT count(e.guid) as total ";
+ } else {
+ $query = "SELECT e.* ";
+ }
+ $query .= "from {$CONFIG->dbprefix}entities e
+ join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid
+ where match(o.title,o.description) against ('$criteria') and $access";
+
+ if (!$count) {
+ $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+ return get_data($query, "entity_row_to_elggstar");
+ } else {
+ if ($count = get_data_row($query)) {
+ return $count->total;
+ }
+ }
+ return false;
+}
+
+/**
* Get the sites this object is part of
*
* @param int $object_guid The object's GUID
@@ -134,5 +187,42 @@ function objects_test($hook, $type, $value, $params) {
}
+/**
+ * Returns a formatted list of objects suitable for injecting into search.
+ *
+ * @deprecated 1.7
+ *
+ * @param sting $hook Hook
+ * @param string $user user
+ * @param mixed $returnvalue Previous return value
+ * @param mixed $tag Search term
+ *
+ * @return array
+ */
+function search_list_objects_by_name($hook, $user, $returnvalue, $tag) {
+ elgg_deprecated_notice('search_list_objects_by_name was deprecated by new search plugin.', 1.7);
+
+ // Change this to set the number of users that display on the search page
+ $threshold = 4;
+
+ $object = get_input('object');
+
+ if (!get_input('offset') && (empty($object) || $object == 'user')) {
+ if ($users = search_for_user($tag, $threshold)) {
+ $countusers = search_for_user($tag, 0, 0, "", true);
+
+ $return = elgg_view('user/search/startblurb', array('count' => $countusers, 'tag' => $tag));
+ foreach ($users as $user) {
+ $return .= elgg_view_entity($user);
+ }
+ $return .= elgg_view('user/search/finishblurb',
+ array('count' => $countusers, 'threshold' => $threshold, 'tag' => $tag));
+
+ return $return;
+
+ }
+ }
+}
+
elgg_register_event_handler('init', 'system', 'objects_init', 0);
elgg_register_plugin_hook_handler('unit_test', 'system', 'objects_test'); \ No newline at end of file
diff --git a/engine/lib/output.php b/engine/lib/output.php
index 967af263f..25fb23e3d 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -186,6 +186,7 @@ function elgg_format_attributes(array $attrs) {
return implode(' ', $attributes);
}
+
/**
* Preps an associative array for use in {@link elgg_format_attributes()}.
*
@@ -267,6 +268,19 @@ function elgg_normalize_url($url) {
* @param string $title The title
*
* @return string The optimised title
+ * @deprecated 1.8
+ */
+function friendly_title($title) {
+ elgg_deprecated_notice('friendly_title was deprecated by elgg_get_friendly_title', 1.8);
+ return elgg_get_friendly_title($title);
+}
+
+/**
+ * When given a title, returns a version suitable for inclusion in a URL
+ *
+ * @param string $title The title
+ *
+ * @return string The optimised title
* @since 1.7.2
*/
function elgg_get_friendly_title($title) {
@@ -288,6 +302,19 @@ function elgg_get_friendly_title($title) {
}
/**
+ * Displays a UNIX timestamp in a friendly way (eg "less than a minute ago")
+ *
+ * @param int $time A UNIX epoch timestamp
+ *
+ * @return string The friendly time
+ * @deprecated 1.8
+ */
+function friendly_time($time) {
+ elgg_deprecated_notice('friendly_time was deprecated by elgg_view_friendly_time', 1.8);
+ return elgg_view_friendly_time($time);
+}
+
+/**
* Formats a UNIX timestamp in a friendly way (eg "less than a minute ago")
*
* @see elgg_view_friendly_time()
@@ -367,3 +394,71 @@ function elgg_strip_tags($string) {
return $string;
}
+
+
+
+/**
+ * Filters a string into an array of significant words
+ *
+ * @deprecated 1.8
+ *
+ * @param string $string A string
+ *
+ * @return array
+ */
+function filter_string($string) {
+ elgg_deprecated_notice('filter_string() was deprecated!', 1.8);
+
+ // Convert it to lower and trim
+ $string = strtolower($string);
+ $string = trim($string);
+
+ // Remove links and email addresses
+ // match protocol://address/path/file.extension?some=variable&another=asf%
+ $string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}"
+ . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
+
+ // match www.something.domain/path/file.extension?some=variable&another=asf%
+ $string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}"
+ . "[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu", " ", $string);
+
+ // match name@address
+ $string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]"
+ . "*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu", " ", $string);
+
+ // Sanitise the string; remove unwanted characters
+ $string = preg_replace('/\W/ui', ' ', $string);
+
+ // Explode it into an array
+ $terms = explode(' ', $string);
+
+ // Remove any blacklist terms
+ //$terms = array_filter($terms, 'remove_blacklist');
+
+ return $terms;
+}
+
+/**
+ * Returns true if the word in $input is considered significant
+ *
+ * @deprecated 1.8
+ *
+ * @param string $input A word
+ *
+ * @return true|false
+ */
+function remove_blacklist($input) {
+ elgg_deprecated_notice('remove_blacklist() was deprecated!', 1.8);
+
+ global $CONFIG;
+
+ if (!is_array($CONFIG->wordblacklist)) {
+ return $input;
+ }
+
+ if (strlen($input) < 3 || in_array($input, $CONFIG->wordblacklist)) {
+ return false;
+ }
+
+ return true;
+} \ No newline at end of file
diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php
index f8b23b6a9..41e0aa0ef 100644
--- a/engine/lib/pageowner.php
+++ b/engine/lib/pageowner.php
@@ -34,6 +34,18 @@ function elgg_get_page_owner_guid($guid = 0) {
}
/**
+ * Gets the guid of the entity that owns the current page.
+ *
+ * @deprecated 1.8 Use elgg_get_page_owner_guid()
+ *
+ * @return int The current page owner guid (0 if none).
+ */
+function page_owner() {
+ elgg_deprecated_notice('page_owner() was deprecated by elgg_get_page_owner_guid().', 1.8);
+ return elgg_get_page_owner_guid();
+}
+
+/**
* Gets the owner entity for the current page.
*
* @return ElggEntity|false The current page owner or false if none.
@@ -50,6 +62,17 @@ function elgg_get_page_owner_entity() {
}
/**
+ * Gets the owner entity for the current page.
+ *
+ * @deprecated 1.8 Use elgg_get_page_owner()
+ * @return ElggEntity|false The current page owner or false if none.
+ */
+function page_owner_entity() {
+ elgg_deprecated_notice('page_owner_entity() was deprecated by elgg_get_page_owner_entity().', 1.8);
+ return elgg_get_page_owner_entity();
+}
+
+/**
* Set the guid of the entity that owns this page
*
* @param int $guid The guid of the page owner
@@ -60,6 +83,32 @@ function elgg_set_page_owner_guid($guid) {
elgg_get_page_owner_guid($guid);
}
+
+/**
+ * Registers a page owner handler function
+ *
+ * @param string $functionname The callback function
+ *
+ * @deprecated 1.8 Use the 'page_owner', 'system' plugin hook
+ * @return void
+ */
+function add_page_owner_handler($functionname) {
+ elgg_deprecated_notice("add_page_owner_handler() was deprecated by the plugin hook 'page_owner', 'system'.", 1.8);
+}
+
+/**
+ * Set a page owner entity
+ *
+ * @param int $entitytoset The GUID of the entity
+ *
+ * @deprecated 1.8 Use elgg_set_page_owner_guid()
+ * @return void
+ */
+function set_page_owner($entitytoset = -1) {
+ elgg_deprecated_notice('set_page_owner() was deprecated by elgg_set_page_owner_guid().', 1.8);
+ elgg_set_page_owner_guid($entitytoset);
+}
+
/**
* Handles default page owners
*
@@ -198,6 +247,40 @@ function elgg_in_context($context) {
}
/**
+ * Sets the functional context of a page
+ *
+ * @deprecated 1.8 Use elgg_set_context()
+ *
+ * @param string $context The context of the page
+ *
+ * @return mixed Either the context string, or false on failure
+ */
+function set_context($context) {
+ elgg_deprecated_notice('set_context() was deprecated by elgg_set_context().', 1.8);
+ elgg_set_context($context);
+ if (empty($context)) {
+ return false;
+ }
+ return $context;
+}
+
+/**
+ * Returns the functional context of a page
+ *
+ * @deprecated 1.8 Use elgg_get_context()
+ *
+ * @return string The context, or 'main' if no context has been provided
+ */
+function get_context() {
+ elgg_deprecated_notice('get_context() was deprecated by elgg_get_context().', 1.8);
+ return elgg_get_context();
+
+ // @todo - used to set context based on calling script
+ // $context = get_plugin_name(true)
+}
+
+
+/**
* Initializes the page owner functions
*
* @note This is on the 'boot, system' event so that the context is set up quickly.
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index c5a34bc81..9a3dd630a 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -449,6 +449,67 @@ function elgg_reindex_plugin_priorities() {
}
/**
+ * Returns a list of plugins to load, in the order that they should be loaded.
+ *
+ * @deprecated 1.8
+ *
+ * @return array List of plugins
+ */
+function get_plugin_list() {
+ elgg_deprecated_notice('get_plugin_list() is deprecated by elgg_get_plugin_ids_in_dir() or elgg_get_plugins()', 1.8);
+
+ $plugins = elgg_get_plugins('any');
+
+ $list = array();
+ if ($plugins) {
+ foreach ($plugins as $i => $plugin) {
+ // in <=1.7 this returned indexed by multiples of 10.
+ // uh...sure...why not.
+ $index = ($i + 1) * 10;
+ $list[$index] = $plugin->getID();
+ }
+ }
+
+ return $list;
+}
+
+/**
+ * Regenerates the list of known plugins and saves it to the current site
+ *
+ * Important: You should regenerate simplecache and the viewpath cache after executing this function
+ * otherwise you may experience view display artifacts. Do this with the following code:
+ *
+ * elgg_view_regenerate_simplecache();
+ * elgg_filepath_cache_reset();
+ *
+ * @deprecated 1.8
+ *
+ * @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) {
+ $msg = 'regenerate_plugin_list() is (sorta) deprecated by elgg_generate_plugin_entities() and'
+ . ' elgg_set_plugin_priorities().';
+ elgg_deprecated_notice($msg, 1.8);
+
+ // they're probably trying to set it?
+ if ($pluginorder) {
+ if (elgg_generate_plugin_entities()) {
+ // sort the plugins by the index numerically since we used
+ // weird indexes in the old system.
+ ksort($pluginorder, SORT_NUMERIC);
+ return elgg_set_plugin_priorities($pluginorder);
+ }
+ return false;
+ } else {
+ // they're probably trying to regenerate from disk?
+ return elgg_generate_plugin_entities();
+ }
+}
+
+
+/**
* Loads plugins
*
* @deprecate 1.8
@@ -461,6 +522,7 @@ function load_plugins() {
return elgg_load_plugins();
}
+
/**
* Namespaces a string to be used as a private setting for a plugin.
*
@@ -532,6 +594,74 @@ function elgg_get_calling_plugin_id($mainfilename = false) {
}
/**
+ * Get the name of the most recent plugin to be called in the
+ * call stack (or the plugin that owns the current page, if any).
+ *
+ * i.e., if the last plugin was in /mod/foobar/, get_plugin_name would return foo_bar.
+ *
+ * @deprecated 1.8
+ *
+ * @param boolean $mainfilename If set to true, this will instead determine the
+ * context from the main script filename called by
+ * the browser. Default = false.
+ *
+ * @return string|false Plugin name, or false if no plugin name was called
+ */
+function get_plugin_name($mainfilename = false) {
+ elgg_deprecated_notice('get_plugin_name() is deprecated by elgg_get_calling_plugin_id()', 1.8);
+
+ return elgg_get_calling_plugin_id($mainfilename);
+}
+
+/**
+ * Load and parse a plugin manifest from a plugin XML file.
+ *
+ * @example plugins/manifest.xml Example 1.8-style manifest file.
+ *
+ * @deprecated 1.8
+ *
+ * @param string $plugin Plugin name.
+ * @return array of values
+ */
+function load_plugin_manifest($plugin) {
+ elgg_deprecated_notice('load_plugin_manifest() is deprecated by ElggPlugin->getManifest()', 1.8);
+
+ $xml_file = elgg_get_plugin_path() . "$plugin/manifest.xml";
+
+ try {
+ $manifest = new ElggPluginManifest($xml_file, $plugin);
+ } catch(Exception $e) {
+ return false;
+ }
+
+ return $manifest->getManifest();
+}
+
+/**
+ * This function checks a plugin manifest 'elgg_version' value against the current install
+ * returning TRUE if the elgg_version is >= the current install's version.
+ *
+ * @deprecated 1.8
+ *
+ * @param string $manifest_elgg_version_string The build version (eg 2009010201).
+ * @return bool
+ */
+function check_plugin_compatibility($manifest_elgg_version_string) {
+ elgg_deprecated_notice('check_plugin_compatibility() is deprecated by ElggPlugin->canActivate()', 1.8);
+
+ $version = get_version();
+
+ if (strpos($manifest_elgg_version_string, '.') === false) {
+ // Using version
+ $req_version = (int)$manifest_elgg_version_string;
+
+ return ($version >= $req_version);
+ }
+
+ return false;
+}
+
+/**
* Returns an array of all provides from all active plugins.
*
* Array in the form array(
@@ -721,6 +851,27 @@ function elgg_get_plugin_dependency_strings($dep) {
return $strings;
}
+
+
+/**
+ * Shorthand function for finding the plugin settings.
+ *
+ * @deprecated 1.8
+ *
+ * @param string $plugin_id Optional plugin id, if not specified
+ * then it is detected from where you are calling.
+ *
+ * @return mixed
+ */
+function find_plugin_settings($plugin_id = null) {
+ elgg_deprecated_notice('find_plugin_setting() is deprecated by elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()', 1.8);
+ if ($plugin_id) {
+ return elgg_get_plugin_from_id($plugin_id);
+ } else {
+ return elgg_get_calling_plugin_entity();
+ }
+}
+
/**
* Returns the ElggPlugin entity of the last plugin called.
*
@@ -984,6 +1135,149 @@ function clear_all_plugin_settings($plugin_id = "") {
}
/**
+ * Return an array of installed plugins.
+ *
+ * @deprecated 1.8
+ *
+ * @param string $status any|enabled|disabled
+ * @return array
+ */
+function get_installed_plugins($status = 'all') {
+ global $CONFIG;
+
+ elgg_deprecated_notice('get_installed_plugins() was deprecated by elgg_get_plugins()', 1.8);
+
+ $plugins = elgg_get_plugins($status);
+
+ if (!$plugins) {
+ return array();
+ }
+
+ $installed_plugins = array();
+
+ foreach ($plugins as $plugin) {
+ if (!$plugin->isValid()) {
+ continue;
+ }
+
+ $installed_plugins[$plugin->getID()] = array(
+ 'active' => $plugin->isActive(),
+ 'manifest' => $plugin->manifest->getManifest()
+ );
+ }
+
+ return $installed_plugins;
+}
+
+/**
+ * Enable a plugin for a site (default current site)
+ *
+ * Important: You should regenerate simplecache and the viewpath cache after executing this function
+ * otherwise you may experience view display artifacts. Do this with the following code:
+ *
+ * elgg_view_regenerate_simplecache();
+ * elgg_filepath_cache_reset();
+ *
+ * @deprecated 1.8
+ *
+ * @param string $plugin The plugin name.
+ * @param int $site_guid The site id, if not specified then this is detected.
+ *
+ * @return array
+ * @throws InvalidClassException
+ */
+function enable_plugin($plugin, $site_guid = null) {
+ elgg_deprecated_notice('enable_plugin() was deprecated by ElggPlugin->activate()', 1.8);
+
+ $plugin = sanitise_string($plugin);
+
+ $site_guid = (int) $site_guid;
+ if (!$site_guid) {
+ $site = get_config('site');
+ $site_guid = $site->guid;
+ }
+
+ try {
+ $plugin = new ElggPlugin($plugin);
+ } catch(Exception $e) {
+ return false;
+ }
+
+ if (!$plugin->canActivate($site_guid)) {
+ return false;
+ }
+
+ return $plugin->activate($site_guid);
+}
+
+/**
+ * Disable a plugin for a site (default current site)
+ *
+ * Important: You should regenerate simplecache and the viewpath cache after executing this function
+ * otherwise you may experience view display artifacts. Do this with the following code:
+ *
+ * elgg_view_regenerate_simplecache();
+ * elgg_filepath_cache_reset();
+ *
+ * @deprecated 1.8
+ *
+ * @param string $plugin The plugin name.
+ * @param int $site_guid The site id, if not specified then this is detected.
+ *
+ * @return bool
+ * @throws InvalidClassException
+ */
+function disable_plugin($plugin, $site_guid = 0) {
+ elgg_deprecated_notice('disable_plugin() was deprecated by ElggPlugin->deactivate()', 1.8);
+
+ $plugin = sanitise_string($plugin);
+
+ $site_guid = (int) $site_guid;
+ if (!$site_guid) {
+ $site = get_config('site');
+ $site_guid = $site->guid;
+ }
+
+ try {
+ $plugin = new ElggPlugin($plugin);
+ } catch(Exception $e) {
+ return false;
+ }
+
+ return $plugin->deactivate($site_guid);
+}
+
+/**
+ * Return whether a plugin is enabled or not.
+ *
+ * @deprecated 1.8
+ *
+ * @param string $plugin The plugin name.
+ * @param int $site_guid The site id, if not specified then this is detected.
+ *
+ * @return bool
+ */
+function is_plugin_enabled($plugin, $site_guid = 0) {
+ elgg_deprecated_notice('is_plugin_enabled() was deprecated by ElggPlugin->isActive()', 1.8);
+
+ $plugin = sanitise_string($plugin);
+
+ $site_guid = (int) $site_guid;
+ if (!$site_guid) {
+ $site = get_config('site');
+ $site_guid = $site->guid;
+ }
+
+ try {
+ $plugin = new ElggPlugin($plugin);
+ } catch(Exception $e) {
+ return false;
+ }
+
+ return $plugin->isActive($site_guid);
+}
+
+/**
* Register object, plugin entities as ElggPlugin classes
*
* @return void
@@ -992,6 +1286,7 @@ function plugin_run_once() {
add_subtype("object", "plugin", "ElggPlugin");
}
+
/**
* Runs unit tests for the entity objects.
*
diff --git a/engine/lib/private_settings.php b/engine/lib/private_settings.php
index 77641e122..bf81e4a3a 100644
--- a/engine/lib/private_settings.php
+++ b/engine/lib/private_settings.php
@@ -9,6 +9,169 @@
*/
/**
+ * Get entities based on their private data.
+ *
+ * @param string $name The name of the setting
+ * @param string $value The value of the setting
+ * @param string $type The type of entity (eg "user", "object" etc)
+ * @param string $subtype The arbitrary subtype of the entity
+ * @param int $owner_guid The GUID of the owning user
+ * @param string $order_by The field to order by; by default, time_created desc
+ * @param int $limit The number of entities to return; 10 by default
+ * @param int $offset The indexing offset, 0 by default
+ * @param boolean $count Return a count of entities
+ * @param int $site_guid The site to get entities for. 0 for current, -1 for any
+ * @param mixed $container_guid The container(s) GUIDs
+ *
+ * @return array A list of entities.
+ * @deprecated 1.8
+ */
+function get_entities_from_private_setting($name = "", $value = "", $type = "", $subtype = "",
+$owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
+$container_guid = null) {
+ elgg_deprecated_notice('get_entities_from_private_setting() was deprecated by elgg_get_entities_from_private_setting()!', 1.8);
+
+ $options = array();
+
+ $options['private_setting_name'] = $name;
+ $options['private_setting_value'] = $value;
+
+ // set container_guid to owner_guid to emulate old functionality
+ if ($owner_guid != "") {
+ if (is_null($container_guid)) {
+ $container_guid = $owner_guid;
+ }
+ }
+
+ if ($type) {
+ $options['types'] = $type;
+ }
+
+ if ($subtype) {
+ $options['subtypes'] = $subtype;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ if ($container_guid) {
+ if (is_array($container_guid)) {
+ $options['container_guids'] = $container_guid;
+ } else {
+ $options['container_guid'] = $container_guid;
+ }
+ }
+
+ $options['limit'] = $limit;
+
+ if ($offset) {
+ $options['offset'] = $offset;
+ }
+
+ if ($order_by) {
+ $options['order_by'];
+ }
+
+ if ($site_guid) {
+ $options['site_guid'];
+ }
+
+ if ($count) {
+ $options['count'] = $count;
+ }
+
+ return elgg_get_entities_from_private_settings($options);
+}
+
+/**
+ * Get entities based on their private data by multiple keys.
+ *
+ * @param string $name The name of the setting
+ * @param mixed $type Entity type
+ * @param string $subtype Entity subtype
+ * @param int $owner_guid The GUID of the owning user
+ * @param string $order_by The field to order by; by default, time_created desc
+ * @param int $limit The number of entities to return; 10 by default
+ * @param int $offset The indexing offset, 0 by default
+ * @param bool $count Count entities
+ * @param int $site_guid Site GUID. 0 for current, -1 for any.
+ * @param mixed $container_guid Container GUID
+ *
+ * @return array A list of entities.
+ * @deprecated 1.8
+ */
+function get_entities_from_private_setting_multi(array $name, $type = "", $subtype = "",
+$owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false,
+$site_guid = 0, $container_guid = null) {
+
+ elgg_deprecated_notice('get_entities_from_private_setting_multi() was deprecated by elgg_get_entities_from_private_setting()!', 1.8);
+
+ $options = array();
+
+ $pairs = array();
+ foreach ($name as $setting_name => $setting_value) {
+ $pairs[] = array('name' => $setting_name, 'value' => $setting_value);
+ }
+ $options['private_setting_name_value_pairs'] = $pairs;
+
+ // set container_guid to owner_guid to emulate old functionality
+ if ($owner_guid != "") {
+ if (is_null($container_guid)) {
+ $container_guid = $owner_guid;
+ }
+ }
+
+ if ($type) {
+ $options['types'] = $type;
+ }
+
+ if ($subtype) {
+ $options['subtypes'] = $subtype;
+ }
+
+ if ($owner_guid) {
+ if (is_array($owner_guid)) {
+ $options['owner_guids'] = $owner_guid;
+ } else {
+ $options['owner_guid'] = $owner_guid;
+ }
+ }
+
+ if ($container_guid) {
+ if (is_array($container_guid)) {
+ $options['container_guids'] = $container_guid;
+ } else {
+ $options['container_guid'] = $container_guid;
+ }
+ }
+
+ $options['limit'] = $limit;
+
+ if ($offset) {
+ $options['offset'] = $offset;
+ }
+
+ if ($order_by) {
+ $options['order_by'];
+ }
+
+ if ($site_guid) {
+ $options['site_guid'];
+ }
+
+ if ($count) {
+ $options['count'] = $count;
+ }
+
+ return elgg_get_entities_from_private_settings($options);
+}
+
+/**
* Returns entities based upon private settings. Also accepts all
* options available to elgg_get_entities(). Supports
* the singular option shortcut.