aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggEntity.php3
-rw-r--r--engine/classes/ElggGroup.php9
-rw-r--r--engine/classes/ElggMenuItem.php24
-rw-r--r--engine/classes/ElggObject.php5
-rw-r--r--engine/classes/ElggPluginManifest.php2
-rw-r--r--engine/classes/ElggRelationship.php4
-rw-r--r--engine/classes/ElggSite.php5
-rw-r--r--engine/classes/ElggUser.php5
-rw-r--r--engine/lib/access.php7
-rw-r--r--engine/lib/admin.php12
-rw-r--r--engine/lib/annotations.php4
-rw-r--r--engine/lib/cron.php7
-rw-r--r--engine/lib/database.php12
-rw-r--r--engine/lib/deprecated-1.8.php37
-rw-r--r--engine/lib/elgglib.php42
-rw-r--r--engine/lib/entities.php50
-rw-r--r--engine/lib/input.php12
-rw-r--r--engine/lib/location.php2
-rw-r--r--engine/lib/metadata.php2
-rw-r--r--engine/lib/metastrings.php2
-rw-r--r--engine/lib/navigation.php8
-rw-r--r--engine/lib/pagehandler.php68
-rw-r--r--engine/lib/plugins.php2
-rw-r--r--engine/lib/private_settings.php2
-rw-r--r--engine/lib/relationships.php8
-rw-r--r--engine/lib/river.php32
-rw-r--r--engine/lib/tags.php30
-rw-r--r--engine/lib/user_settings.php14
-rw-r--r--engine/lib/users.php104
-rw-r--r--engine/lib/views.php15
-rw-r--r--engine/start.php5
-rw-r--r--engine/tests/api/access_collections.php4
-rw-r--r--engine/tests/api/entity_getter_functions.php71
-rw-r--r--engine/tests/api/helpers.php6
-rw-r--r--engine/tests/api/metadata.php4
-rw-r--r--engine/tests/api/metastrings.php10
-rw-r--r--engine/tests/api/plugins.php65
-rw-r--r--engine/tests/objects/entities.php28
-rw-r--r--engine/tests/objects/sites.php9
-rw-r--r--engine/tests/objects/users.php5
-rw-r--r--engine/tests/test_files/plugin_17/manifest.xml4
-rw-r--r--engine/tests/test_files/plugin_18/manifest.xml8
-rw-r--r--engine/tests/test_skeleton.php3
43 files changed, 419 insertions, 332 deletions
diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php
index fdf2a80ea..df87082fe 100644
--- a/engine/classes/ElggEntity.php
+++ b/engine/classes/ElggEntity.php
@@ -1335,6 +1335,9 @@ abstract class ElggEntity extends ElggData implements
$this->attributes['tables_loaded']++;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
// Cache object handle
if ($this->attributes['guid']) {
cache_entity($this);
diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php
index 49ba27204..0190e5eac 100644
--- a/engine/classes/ElggGroup.php
+++ b/engine/classes/ElggGroup.php
@@ -309,7 +309,7 @@ class ElggGroup extends ElggEntity
*
* @param ElggUser $user User
*
- * @return void
+ * @return bool
*/
public function leave(ElggUser $user) {
return leave_group($this->getGUID(), $user->getGUID());
@@ -322,7 +322,7 @@ class ElggGroup extends ElggEntity
*
* @param int $guid GUID of an ElggGroup entity
*
- * @return true
+ * @return bool
*/
protected function load($guid) {
// Test to see if we have the generic stuff
@@ -340,7 +340,7 @@ class ElggGroup extends ElggEntity
$row = get_group_entity_as_row($guid);
if (($row) && (!$this->isFullyLoaded())) {
// If $row isn't a cached copy then increment the counter
- $this->attributes['tables_loaded'] ++;
+ $this->attributes['tables_loaded']++;
}
// Now put these into the attributes array as core values
@@ -349,6 +349,9 @@ class ElggGroup extends ElggEntity
$this->attributes[$key] = $value;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
return true;
}
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index 8ddb1ecd8..62547134a 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -100,6 +100,9 @@ class ElggMenuItem {
if (!isset($options['name']) || !isset($options['text'])) {
return NULL;
}
+ if (!isset($options['href'])) {
+ $options['href'] = '';
+ }
$item = new ElggMenuItem($options['name'], $options['text'], $options['href']);
unset($options['name']);
@@ -412,6 +415,7 @@ class ElggMenuItem {
*
* @param int $priority The smaller numbers mean higher priority (1 before 100)
* @return void
+ * @deprecated
*/
public function setWeight($priority) {
$this->data['priority'] = $priority;
@@ -421,12 +425,32 @@ class ElggMenuItem {
* Get the priority of the menu item
*
* @return int
+ * @deprecated
*/
public function getWeight() {
return $this->data['priority'];
}
/**
+ * Set the priority of the menu item
+ *
+ * @param int $priority The smaller numbers mean higher priority (1 before 100)
+ * @return void
+ */
+ public function setPriority($priority) {
+ $this->data['priority'] = $priority;
+ }
+
+ /**
+ * Get the priority of the menu item
+ *
+ * @return int
+ */
+ public function getPriority() {
+ return $this->data['priority'];
+ }
+
+ /**
* Set the section identifier
*
* @param string $section The identifier of the section
diff --git a/engine/classes/ElggObject.php b/engine/classes/ElggObject.php
index caccfb038..0b8340697 100644
--- a/engine/classes/ElggObject.php
+++ b/engine/classes/ElggObject.php
@@ -110,7 +110,7 @@ class ElggObject extends ElggEntity {
$row = get_object_entity_as_row($guid);
if (($row) && (!$this->isFullyLoaded())) {
// If $row isn't a cached copy then increment the counter
- $this->attributes['tables_loaded'] ++;
+ $this->attributes['tables_loaded']++;
}
// Now put these into the attributes array as core values
@@ -119,6 +119,9 @@ class ElggObject extends ElggEntity {
$this->attributes[$key] = $value;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
return true;
}
diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php
index eacc16455..7592eb667 100644
--- a/engine/classes/ElggPluginManifest.php
+++ b/engine/classes/ElggPluginManifest.php
@@ -553,7 +553,7 @@ class ElggPluginManifest {
}
/**
- * Returns the admin interface to use.
+ * Should this plugin be activated when Elgg is installed
*
* @return bool
*/
diff --git a/engine/classes/ElggRelationship.php b/engine/classes/ElggRelationship.php
index a0826689d..2d9a32cbd 100644
--- a/engine/classes/ElggRelationship.php
+++ b/engine/classes/ElggRelationship.php
@@ -10,9 +10,9 @@ class ElggRelationship extends ElggData implements
{
/**
- * Construct a new site object, optionally from a given id value or row.
+ * Create a relationship object, optionally from a given id value or row.
*
- * @param mixed $id ElggRelationship id
+ * @param mixed $id ElggRelationship id, database row, or null for new relationship
*/
function __construct($id = null) {
$this->initializeAttributes();
diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php
index 16b80b9d3..5c44d4076 100644
--- a/engine/classes/ElggSite.php
+++ b/engine/classes/ElggSite.php
@@ -128,7 +128,7 @@ class ElggSite extends ElggEntity {
$row = get_site_entity_as_row($guid);
if (($row) && (!$this->isFullyLoaded())) {
// If $row isn't a cached copy then increment the counter
- $this->attributes['tables_loaded'] ++;
+ $this->attributes['tables_loaded']++;
}
// Now put these into the attributes array as core values
@@ -137,6 +137,9 @@ class ElggSite extends ElggEntity {
$this->attributes[$key] = $value;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
return true;
}
diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php
index 75ac008f6..a1c7147a5 100644
--- a/engine/classes/ElggUser.php
+++ b/engine/classes/ElggUser.php
@@ -114,7 +114,7 @@ class ElggUser extends ElggEntity
$row = get_user_entity_as_row($guid);
if (($row) && (!$this->isFullyLoaded())) {
// If $row isn't a cached copy then increment the counter
- $this->attributes['tables_loaded'] ++;
+ $this->attributes['tables_loaded']++;
}
// Now put these into the attributes array as core values
@@ -123,6 +123,9 @@ class ElggUser extends ElggEntity
$this->attributes[$key] = $value;
}
+ // guid needs to be an int http://trac.elgg.org/ticket/4111
+ $this->attributes['guid'] = (int)$this->attributes['guid'];
+
return true;
}
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 002413baa..08b9283cd 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -610,8 +610,7 @@ function delete_access_collection($collection_id) {
WHERE id = {$collection_id}";
$result = delete_data($q);
-
- return $result;
+ return (bool)$result;
}
/**
@@ -718,7 +717,7 @@ function remove_user_from_access_collection($user_guid, $collection_id) {
WHERE access_collection_id = {$collection_id}
AND user_guid = {$user_guid}";
- return delete_data($q);
+ return (bool)delete_data($q);
}
/**
@@ -792,7 +791,7 @@ function get_members_of_access_collection($collection, $idonly = FALSE) {
* access_id => int The access ID of the entity.
*
* @see elgg_get_entities()
- * @return mixed if count, int. if not count, array. false on errors.
+ * @return mixed If count, int. If not count, array. false on errors.
* @since 1.7.0
*/
function elgg_get_entities_from_access_id(array $options = array()) {
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index ae6429baf..3baf2ff61 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -314,7 +314,7 @@ function admin_init() {
// automatic adding of widgets for admin
elgg_register_event_handler('make_admin', 'user', 'elgg_add_admin_widgets');
- elgg_register_page_handler('admin', 'admin_settings_page_handler');
+ elgg_register_page_handler('admin', 'admin_page_handler');
elgg_register_page_handler('admin_plugin_screenshot', 'admin_plugin_screenshot_page_handler');
elgg_register_page_handler('admin_plugin_text_file', 'admin_markdown_page_handler');
}
@@ -427,10 +427,10 @@ function admin_pagesetup() {
*
* @param array $page Array of pages
*
- * @return void
+ * @return bool
* @access private
*/
-function admin_settings_page_handler($page) {
+function admin_page_handler($page) {
admin_gatekeeper();
elgg_admin_add_plugin_settings_menu();
@@ -478,6 +478,7 @@ function admin_settings_page_handler($page) {
$body = elgg_view_layout('admin', array('content' => $content, 'title' => $title));
echo elgg_view_page($title, $body, 'admin');
+ return true;
}
/**
@@ -485,7 +486,7 @@ function admin_settings_page_handler($page) {
* admin_plugin_screenshot/<plugin_id>/<size>/<ss_name>.<ext>
*
* @param array $pages The pages array
- * @return true
+ * @return bool
* @access private
*/
function admin_plugin_screenshot_page_handler($pages) {
@@ -524,7 +525,6 @@ function admin_plugin_screenshot_page_handler($pages) {
echo file_get_contents($file);
break;
}
-
return true;
}
@@ -541,6 +541,7 @@ function admin_plugin_screenshot_page_handler($pages) {
* * LICENSE.txt
*
* @param type $page
+ * @return bool
* @access private
*/
function admin_markdown_page_handler($pages) {
@@ -596,6 +597,7 @@ function admin_markdown_page_handler($pages) {
));
echo elgg_view_page($title, $body, 'admin');
+ return true;
}
/**
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 66c6454c3..e40ab2e39 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -320,7 +320,7 @@ function elgg_list_annotations($options) {
*
* annotation_ids => NULL|ARR Annotation IDs
*
- * @return mixed if count, int. if not count, array or false if no entities. false also on errors.
+ * @return mixed If count, int. If not count, array. false on errors.
* @since 1.7.0
*/
function elgg_get_entities_from_annotations(array $options = array()) {
@@ -397,7 +397,7 @@ function elgg_list_entities_from_annotations($options = array()) {
* 'metadata_names' => The name of metadata on the entity.
* 'metadata_values' => The value of metadata on the entitiy.
*
- * @return mixed
+ * @return mixed If count, int. If not count, array. false on errors.
*/
function elgg_get_entities_from_annotation_calculation($options) {
$db_prefix = elgg_get_config('dbprefix');
diff --git a/engine/lib/cron.php b/engine/lib/cron.php
index 8c0b62a53..f7a032f4a 100644
--- a/engine/lib/cron.php
+++ b/engine/lib/cron.php
@@ -25,7 +25,7 @@ function cron_init() {
*
* @param array $page Pages
*
- * @return void
+ * @return bool
* @access private
*/
function cron_page_handler($page) {
@@ -50,10 +50,6 @@ function cron_page_handler($page) {
$params = array();
$params['time'] = time();
- foreach ($CONFIG->input as $k => $v) {
- $params[$k] = $v;
- }
-
// Data to return to
$std_out = "";
$old_stdout = "";
@@ -63,6 +59,7 @@ function cron_page_handler($page) {
$std_out = ob_get_clean();
echo $std_out . $old_stdout;
+ return true;
}
/**
diff --git a/engine/lib/database.php b/engine/lib/database.php
index b5ad7897f..c44fdf1fd 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -400,11 +400,10 @@ function get_data_row($query, $callback = "") {
function elgg_query_runner($query, $callback = null, $single = false) {
global $CONFIG, $DB_QUERY_CACHE;
- $query = elgg_format_query($query);
-
- // since we want to cache results of running the callback, we need to
- // need to namespace the query with the callback, and single result request.
- $hash = (string)$callback . (string)$single . $query;
+ // Since we want to cache results of running the callback, we need to
+ // need to namespace the query with the callback and single result request.
+ // http://trac.elgg.org/ticket/4049
+ $hash = (string)$callback . (int)$single . $query;
// Is cached?
if ($DB_QUERY_CACHE) {
@@ -466,7 +465,6 @@ function elgg_query_runner($query, $callback = null, $single = false) {
function insert_data($query) {
global $CONFIG, $DB_QUERY_CACHE;
- $query = elgg_format_query($query);
elgg_log("DB query $query", 'NOTICE');
$dblink = get_db_link('write');
@@ -498,7 +496,6 @@ function insert_data($query) {
function update_data($query) {
global $CONFIG, $DB_QUERY_CACHE;
- $query = elgg_format_query($query);
elgg_log("DB query $query", 'NOTICE');
$dblink = get_db_link('write');
@@ -529,7 +526,6 @@ function update_data($query) {
function delete_data($query) {
global $CONFIG, $DB_QUERY_CACHE;
- $query = elgg_format_query($query);
elgg_log("DB query $query", 'NOTICE');
$dblink = get_db_link('write');
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php
index beba7d2b7..e1866498b 100644
--- a/engine/lib/deprecated-1.8.php
+++ b/engine/lib/deprecated-1.8.php
@@ -4735,3 +4735,40 @@ function remove_from_river_by_id($id) {
return elgg_delete_river(array('id' => $id));
}
+
+/**
+ * A default page handler
+ * Tries to locate a suitable file to include. Only works for core pages, not plugins.
+ *
+ * @param array $page The page URL elements
+ * @param string $handler The base handler
+ *
+ * @return true|false Depending on success
+ * @deprecated 1.8
+ */
+function default_page_handler($page, $handler) {
+ global $CONFIG;
+
+ elgg_deprecated_notice("default_page_handler is deprecated", "1.8");
+
+ $page = implode('/', $page);
+
+ // protect against including arbitary files
+ $page = str_replace("..", "", $page);
+
+ $callpath = $CONFIG->path . $handler . "/" . $page;
+ if (is_dir($callpath)) {
+ $callpath = sanitise_filepath($callpath);
+ $callpath .= "index.php";
+ if (file_exists($callpath)) {
+ if (include($callpath)) {
+ return TRUE;
+ }
+ }
+ } else if (file_exists($callpath)) {
+ include($callpath);
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 66268cc96..57d602450 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -107,7 +107,10 @@ function elgg_load_library($name) {
}
if (!include_once($CONFIG->libraries[$name])) {
- $error = elgg_echo('InvalidParameterException:LibraryNotRegistered', array($name));
+ $error = elgg_echo('InvalidParameterException:LibraryNotFound', array(
+ $name,
+ $CONFIG->libraries[$name])
+ );
throw new InvalidParameterException($error);
}
}
@@ -1475,8 +1478,12 @@ function elgg_http_url_is_identical($url1, $url2, $ignore_params = array('offset
$url1_info = parse_url($url1);
$url2_info = parse_url($url2);
- $url1_info['path'] = trim($url1_info['path'], '/');
- $url2_info['path'] = trim($url2_info['path'], '/');
+ if (isset($url1_info['path'])) {
+ $url1_info['path'] = trim($url1_info['path'], '/');
+ }
+ if (isset($url2_info['path'])) {
+ $url2_info['path'] = trim($url2_info['path'], '/');
+ }
// compare basic bits
$parts = array('scheme', 'host', 'path');
@@ -1740,7 +1747,7 @@ function _elgg_shutdown_hook() {
*
* @param array $page The page array
*
- * @return void
+ * @return bool
* @elgg_pagehandler js
* @access private
*/
@@ -1755,7 +1762,7 @@ function elgg_js_page_handler($page) {
*
* @param array $page The page array
*
- * @return void
+ * @return bool
* @elgg_pagehandler ajax
* @access private
*/
@@ -1776,9 +1783,9 @@ function elgg_ajax_page_handler($page) {
}
echo elgg_view($view, $vars);
+ return true;
}
-
- return true;
+ return false;
}
/**
@@ -1809,7 +1816,7 @@ function elgg_css_page_handler($page) {
* @param array $page The page array
* @param string $type The type: js or css
*
- * @return mixed
+ * @return bool
* @access private
*/
function elgg_cacheable_view_page_handler($page, $type) {
@@ -1850,9 +1857,8 @@ function elgg_cacheable_view_page_handler($page, $type) {
//header("Content-Length: " . strlen($return));
echo $return;
+ return true;
}
-
- return true;
}
/**
@@ -1886,6 +1892,8 @@ function elgg_sql_reverse_order_by_clause($order_by) {
*
* Used as a callback for ElggBatch.
*
+ * @todo why aren't these static methods on ElggBatch?
+ *
* @param object $object The object to enable
* @return bool
* @access private
@@ -1990,10 +1998,12 @@ function elgg_is_valid_options_for_batch_operation($options, $type) {
function elgg_walled_garden_index() {
elgg_register_css('elgg.walled_garden', '/css/walled_garden.css');
elgg_load_css('elgg.walled_garden');
+ elgg_register_js('elgg.walled_garden', '/js/walled_garden.js');
+ elgg_load_js('elgg.walled_garden');
- $login = elgg_view('core/account/login_walled_garden');
+ $body = elgg_view('core/walled_garden/body');
- echo elgg_view_page('', $login, 'walled_garden');
+ echo elgg_view_page('', $body, 'walled_garden');
// return true to prevent other plugins from adding a front page
return true;
@@ -2041,12 +2051,12 @@ function elgg_init() {
elgg_register_page_handler('css', 'elgg_css_page_handler');
elgg_register_page_handler('ajax', 'elgg_ajax_page_handler');
- elgg_register_js('elgg.autocomplete', 'js/lib/autocomplete.js');
+ elgg_register_js('elgg.autocomplete', 'js/lib/ui.autocomplete.js');
elgg_register_js('jquery.ui.autocomplete.html', 'vendors/jquery/jquery.ui.autocomplete.html.js');
- elgg_register_js('elgg.userpicker', 'js/lib/userpicker.js');
- elgg_register_js('elgg.friendspicker', 'js/lib/friends_picker.js');
+ elgg_register_js('elgg.userpicker', 'js/lib/ui.userpicker.js');
+ elgg_register_js('elgg.friendspicker', 'js/lib/ui.friends_picker.js');
elgg_register_js('jquery.easing', 'vendors/jquery/jquery.easing.1.3.packed.js');
- elgg_register_js('elgg.avatar_cropper', 'js/lib/avatar_cropper.js');
+ elgg_register_js('elgg.avatar_cropper', 'js/lib/ui.avatar_cropper.js');
elgg_register_js('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect-0.9.8/scripts/jquery.imgareaselect.min.js');
elgg_register_css('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect-0.9.8/css/imgareaselect-deprecated.css');
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index fcd4544bf..f7ae108ed 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -124,8 +124,6 @@ function retrieve_cached_entity_row($guid) {
* @internal Subtypes are stored in the entity_subtypes table. There is a foreign
* key in the entities table.
*
- * @todo Move to a nicer place?
- *
* @param string $type Type
* @param string $subtype Subtype
*
@@ -144,7 +142,7 @@ function get_subtype_id($type, $subtype) {
return FALSE;
}
- // Todo: cache here? Or is looping less efficient that going to the db each time?
+ // @todo use the cache before hitting database
$result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes
where type='$type' and subtype='$subtype'");
@@ -163,8 +161,6 @@ function get_subtype_id($type, $subtype) {
/**
* Return string name for a given subtype ID.
*
- * @todo Move to a nicer place?
- *
* @param int $subtype_id Subtype ID
*
* @return string Subtype name
@@ -199,11 +195,11 @@ function get_subtype_from_id($subtype_id) {
}
/**
- * Return a classname for a registered type and subtype.
+ * Return the class name for a registered type and subtype.
*
* Entities can be registered to always be loaded as a certain class
- * with {@link register_entity_subtype()}. This function returns
- * the class name if found, and NULL if not.
+ * with add_subtype() or update_subtype(). This function returns the class
+ * name if found and NULL if not.
*
* @param string $type The type
* @param string $subtype The subtype
@@ -219,7 +215,7 @@ function get_subtype_class($type, $subtype) {
$type = sanitise_string($type);
$subtype = sanitise_string($subtype);
- // Todo: cache here? Or is looping less efficient that going to the db each time?
+ // @todo use the cache before going to the database
$result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes
where type='$type' and subtype='$subtype'");
@@ -236,7 +232,7 @@ function get_subtype_class($type, $subtype) {
}
/**
- * Returns the classname for a subtype id.
+ * Returns the class name for a subtype id.
*
* @param int $subtype_id The subtype id
*
@@ -279,6 +275,9 @@ function get_subtype_class_from_id($subtype_id) {
* it will be loaded as that class automatically when retrieved from the database with
* {@link get_entity()}.
*
+ * @warning This function cannot be used to change the class for a type-subtype pair.
+ * Use update_subtype() for that.
+ *
* @param string $type The type you're subtyping (site, user, object, or group)
* @param string $subtype The subtype
* @param string $class Optional class name for the object
@@ -410,7 +409,7 @@ function update_entity($guid, $owner_guid, $access_id, $container_guid = null, $
$newentity_cache = new ElggMemcache('new_entity_cache');
}
if ($newentity_cache) {
- $new_entity = $newentity_cache->delete($guid);
+ $newentity_cache->delete($guid);
}
// Handle cases where there was no error BUT no rows were updated!
@@ -466,12 +465,10 @@ function can_write_to_container($user_guid = 0, $container_guid = 0, $type = 'al
$return = true;
}
- // Basics, see if the user is a member of the group.
+ // If still not approved, see if the user is a member of the group
// @todo this should be moved to the groups plugin/library
- if ($user && $container instanceof ElggGroup) {
- if (!$container->isMember($user)) {
- $return = false;
- } else {
+ if (!$return && $user && $container instanceof ElggGroup) {
+ if ($container->isMember($user)) {
$return = true;
}
}
@@ -774,7 +771,7 @@ function elgg_entity_exists($guid) {
*
* callback => string A callback function to pass each row through
*
- * @return mixed if count, int. if not count, array or false if no entities. false also on errors.
+ * @return mixed If count, int. If not count, array. false on errors.
* @since 1.7.0
* @see elgg_get_entities_from_metadata()
* @see elgg_get_entities_from_relationship()
@@ -987,7 +984,7 @@ function elgg_get_entity_type_subtype_where_sql($table, $types, $subtypes, $pair
foreach ($types as $type) {
if (!in_array($type, $valid_types)) {
$valid_types_count--;
- unset ($types[array_search($type, $types)]);
+ unset($types[array_search($type, $types)]);
} else {
// do the checking (and decrementing) in the subtype section.
$valid_subtypes_count += count($subtypes);
@@ -1039,7 +1036,7 @@ function elgg_get_entity_type_subtype_where_sql($table, $types, $subtypes, $pair
foreach ($pairs as $paired_type => $paired_subtypes) {
if (!in_array($paired_type, $valid_types)) {
$valid_pairs_count--;
- unset ($pairs[array_search($paired_type, $pairs)]);
+ unset($pairs[array_search($paired_type, $pairs)]);
} else {
if ($paired_subtypes && !is_array($paired_subtypes)) {
$pairs[$paired_type] = array($paired_subtypes);
@@ -1489,6 +1486,15 @@ function delete_entity($guid, $recursive = true) {
if (isset($ENTITY_CACHE[$guid])) {
invalidate_cache_for_entity($guid);
}
+
+ // If memcache is available then delete this entry from the cache
+ static $newentity_cache;
+ if ((!$newentity_cache) && (is_memcache_available())) {
+ $newentity_cache = new ElggMemcache('new_entity_cache');
+ }
+ if ($newentity_cache) {
+ $newentity_cache->delete($guid);
+ }
// Delete contained owned and otherwise releated objects (depth first)
if ($recursive) {
@@ -1556,7 +1562,7 @@ function delete_entity($guid, $recursive = true) {
}
}
- return $res;
+ return (bool)$res;
}
}
}
@@ -2069,7 +2075,7 @@ function is_registered_entity_type($type, $subtype = null) {
*
* @param array $page Page elements from pain page handler
*
- * @return void
+ * @return bool
* @elgg_page_handler view
* @access private
*/
@@ -2078,7 +2084,9 @@ function entities_page_handler($page) {
global $CONFIG;
set_input('guid', $page[0]);
include($CONFIG->path . "pages/entities/index.php");
+ return true;
}
+ return false;
}
/**
diff --git a/engine/lib/input.php b/engine/lib/input.php
index 2f68195f2..57e35786f 100644
--- a/engine/lib/input.php
+++ b/engine/lib/input.php
@@ -301,12 +301,12 @@ function input_livesearch_page_handler($page) {
}
$output = elgg_view_list_item($entity, array(
- 'hover' => false,
+ 'use_hover' => false,
'class' => 'elgg-autocomplete-item',
));
$icon = elgg_view_entity_icon($entity, 'tiny', array(
- 'hover' => false,
+ 'use_hover' => false,
));
$result = array(
@@ -344,12 +344,12 @@ function input_livesearch_page_handler($page) {
}
$output = elgg_view_list_item($entity, array(
- 'hover' => false,
+ 'use_hover' => false,
'class' => 'elgg-autocomplete-item',
));
$icon = elgg_view_entity_icon($entity, 'tiny', array(
- 'hover' => false,
+ 'use_hover' => false,
));
$result = array(
@@ -391,12 +391,12 @@ function input_livesearch_page_handler($page) {
}
$output = elgg_view_list_item($entity, array(
- 'hover' => false,
+ 'use_hover' => false,
'class' => 'elgg-autocomplete-item',
));
$icon = elgg_view_entity_icon($entity, 'tiny', array(
- 'hover' => false,
+ 'use_hover' => false,
));
$result = array(
diff --git a/engine/lib/location.php b/engine/lib/location.php
index 7e2c38fc8..5b889509b 100644
--- a/engine/lib/location.php
+++ b/engine/lib/location.php
@@ -74,7 +74,7 @@ function elgg_geocode_location($location) {
*
* @see ElggEntity::setLatLong()
*
- * @return array
+ * @return mixed If count, int. If not count, array. false on errors.
* @since 1.8.0
*/
function elgg_get_entities_from_location(array $options = array()) {
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 0220e6c1f..050e69526 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -398,7 +398,7 @@ function elgg_enable_metadata(array $options) {
*
* metadata_owner_guids => NULL|ARR guids for metadata owners
*
- * @return mixed if count, int. if not count, array or false if no entities. false also on errors.
+ * @return mixed If count, int. If not count, array. false on errors.
* @since 1.7.0
*/
function elgg_get_entities_from_metadata(array $options = array()) {
diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php
index 9dccec700..9fe9b4bff 100644
--- a/engine/lib/metastrings.php
+++ b/engine/lib/metastrings.php
@@ -810,7 +810,7 @@ function elgg_delete_metastring_based_object_by_id($id, $type) {
}
if (($obj->canEdit()) && (elgg_trigger_event('delete', $type, $obj))) {
- return delete_data("DELETE from $table where id=$id");
+ return (bool)delete_data("DELETE from $table where id=$id");
}
}
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index aaf9fb544..176790188 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -207,7 +207,7 @@ function elgg_register_title_button($handler = null, $name = 'add') {
*/
function elgg_push_breadcrumb($title, $link = NULL) {
global $CONFIG;
- if (!is_array($CONFIG->breadcrumbs)) {
+ if (!isset($CONFIG->breadcrumbs)) {
$CONFIG->breadcrumbs = array();
}
@@ -242,7 +242,11 @@ function elgg_pop_breadcrumb() {
function elgg_get_breadcrumbs() {
global $CONFIG;
- return (is_array($CONFIG->breadcrumbs)) ? $CONFIG->breadcrumbs : array();
+ if (isset($CONFIG->breadcrumbs) && is_array($CONFIG->breadcrumbs)) {
+ return $CONFIG->breadcrumbs;
+ }
+
+ return array();
}
/**
diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php
index 0d5e5f89b..aba921416 100644
--- a/engine/lib/pagehandler.php
+++ b/engine/lib/pagehandler.php
@@ -7,14 +7,16 @@
*/
/**
- * Turns the current page over to the page handler, allowing registered handlers to take over.
+ * Routes the request to a registered page handler
*
- * If a page handler returns FALSE, the request is handed over to the default_page_handler.
+ * This function sets the context based on the handler name (first segment of the
+ * URL). It also triggers a plugin hook 'route', $handler so that plugins can
+ * modify the routing or handle a request.
*
* @param string $handler The name of the handler type (eg 'blog')
* @param array $page The parameters to the page, as an array (exploded by '/' slashes)
*
- * @return true|false Depending on whether a registered page handler was found
+ * @return bool
* @access private
*/
function page_handler($handler, $page) {
@@ -42,26 +44,13 @@ function page_handler($handler, $page) {
$handler = $params['handler'];
$page = $params['segments'];
- if (!isset($CONFIG->pagehandler) || empty($handler)) {
- $result = false;
- } else if (isset($CONFIG->pagehandler[$handler]) && is_callable($CONFIG->pagehandler[$handler])) {
+ $result = false;
+ if (isset($CONFIG->pagehandler) && !empty($handler) && isset($CONFIG->pagehandler[$handler])) {
$function = $CONFIG->pagehandler[$handler];
$result = call_user_func($function, $page, $handler);
- if ($result !== false) {
- $result = true;
- }
- } else {
- $result = false;
}
- if (!$result) {
- $result = default_page_handler($page, $handler);
- }
- if ($result !== false) {
- $result = true;
- }
-
- return $result;
+ return $result || headers_sent();
}
/**
@@ -74,14 +63,16 @@ function page_handler($handler, $page) {
* For example, the URL http://yoururl/blog/username/friends/ would result in the call:
* blog_page_handler(array('username','friends'), blog);
*
- * Page handler functions should return true or the default page handler will be called.
- *
* A request to register a page handler with the same identifier as previously registered
* handler will replace the previous one.
*
* The context is set to the page handler identifier before the registered
* page handler function is called. For the above example, the context is set to 'blog'.
*
+ * Page handlers should return true to indicate that they handled the request.
+ * Requests not handled are forwarded to the front page with a reason of 404.
+ * Plugins can register for the 'forward', '404' plugin hook. @see forward()
+ *
* @param string $handler The page type to handle
* @param string $function Your function name
*
@@ -119,38 +110,3 @@ function elgg_unregister_page_handler($handler) {
unset($CONFIG->pagehandler[$handler]);
}
-
-/**
- * A default page handler
- * Tries to locate a suitable file to include. Only works for core pages, not plugins.
- *
- * @param array $page The page URL elements
- * @param string $handler The base handler
- *
- * @return true|false Depending on success
- * @access private
- */
-function default_page_handler($page, $handler) {
- global $CONFIG;
-
- $page = implode('/', $page);
-
- // protect against including arbitary files
- $page = str_replace("..", "", $page);
-
- $callpath = $CONFIG->path . $handler . "/" . $page;
- if (is_dir($callpath)) {
- $callpath = sanitise_filepath($callpath);
- $callpath .= "index.php";
- if (file_exists($callpath)) {
- if (include($callpath)) {
- return TRUE;
- }
- }
- } else if (file_exists($callpath)) {
- include($callpath);
- return TRUE;
- }
-
- return FALSE;
-}
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index fac52b152..be871d025 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -1007,7 +1007,7 @@ function elgg_unset_all_plugin_settings($plugin_id = null) {
* plugin_user_setting_name_value_pairs_operator => NULL|STR The operator to use for combining
* (name = value) OPERATOR (name = value); default AND
*
- * @return mixed int if count is true, an array of entity objects, or false on failure
+ * @return mixed int If count, int. If not count, array. false on errors.
*/
function elgg_get_entities_from_plugin_user_settings(array $options = array()) {
// if they're passing it don't bother
diff --git a/engine/lib/private_settings.php b/engine/lib/private_settings.php
index 95b1afa57..386af5279 100644
--- a/engine/lib/private_settings.php
+++ b/engine/lib/private_settings.php
@@ -38,7 +38,7 @@
* their own settings.
*
*
- * @return mixed int if count is true, an array of entity objects, or false on failure
+ * @return mixed int If count, int. If not count, array. false on errors.
* @since 1.8.0
*/
function elgg_get_entities_from_private_settings(array $options = array()) {
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index 1a5833732..5b7080b56 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -123,7 +123,7 @@ function check_entity_relationship($guid_one, $relationship, $guid_two) {
AND relationship='$relationship'
AND guid_two=$guid_two limit 1";
- $row = $row = get_data_row($query);
+ $row = get_data_row($query);
if ($row) {
return $row;
}
@@ -158,7 +158,7 @@ function remove_entity_relationship($guid_one, $relationship, $guid_two) {
and relationship='$relationship'
and guid_two=$guid_two";
- return delete_data($query);
+ return (bool)delete_data($query);
} else {
return false;
}
@@ -250,7 +250,7 @@ function get_entity_relationships($guid, $inverse_relationship = FALSE) {
*
* inverse_relationship => BOOL Inverse the relationship
*
- * @return mixed if count, int. if not count, array or false if no entities. false also on errors.
+ * @return mixed If count, int. If not count, array. false on errors.
* @since 1.7.0
*/
function elgg_get_entities_from_relationship($options) {
@@ -372,7 +372,7 @@ function elgg_list_entities_from_relationship(array $options = array()) {
*
* @param array $options An options array compatible with
* elgg_get_entities_from_relationship()
- * @return mixed int if count is true, an array of entity objects, or false on failure
+ * @return mixed int If count, int. If not count, array. false on errors.
* @since 1.8.0
*/
function elgg_get_entities_from_relationship_count(array $options = array()) {
diff --git a/engine/lib/river.php b/engine/lib/river.php
index f430eb224..02d52dea1 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -447,7 +447,8 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
return '';
}
- $wheres = array();
+ $types_wheres = array();
+ $subtypes_wheres = array();
// if no pairs, use types and subtypes
if (!is_array($pairs)) {
@@ -457,7 +458,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($types as $type) {
$type = sanitise_string($type);
- $wheres[] = "({$table}.type = '$type')";
+ $types_wheres[] = "({$table}.type = '$type')";
}
}
@@ -467,13 +468,20 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($subtypes as $subtype) {
$subtype = sanitise_string($subtype);
- $wheres[] = "({$table}.subtype = '$subtype')";
+ $subtypes_wheres[] = "({$table}.subtype = '$subtype')";
}
}
- if (is_array($wheres) && count($wheres)) {
- $wheres = array(implode(' OR ', $wheres));
+ if (is_array($types_wheres) && count($types_wheres)) {
+ $types_wheres = array(implode(' OR ', $types_wheres));
}
+
+ if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
+ $subtypes_wheres = array(implode(' OR ', $subtypes_wheres));
+ }
+
+ $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres)));
+
} else {
// using type/subtype pairs
foreach ($pairs as $paired_type => $paired_subtypes) {
@@ -586,6 +594,7 @@ function update_river_access_by_object($object_guid, $access_id) {
* Page handler for activiy
*
* @param array $page
+ * @return bool
* @access private
*/
function elgg_river_page_handler($page) {
@@ -606,6 +615,17 @@ function elgg_river_page_handler($page) {
$entity_subtype = '';
require_once("{$CONFIG->path}pages/river.php");
+ return true;
+}
+
+/**
+ * Register river unit tests
+ * @access private
+ */
+function elgg_river_test($hook, $type, $value) {
+ global $CONFIG;
+ $value[] = $CONFIG->path . 'engine/tests/api/river.php';
+ return $value;
}
/**
@@ -618,6 +638,8 @@ function elgg_river_init() {
elgg_register_menu_item('site', $item);
elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description'));
+
+ elgg_register_plugin_hook_handler('unit_test', 'system', 'elgg_river_test');
}
elgg_register_event_handler('init', 'system', 'elgg_river_init');
diff --git a/engine/lib/tags.php b/engine/lib/tags.php
index 6275d653c..a0887d0f3 100644
--- a/engine/lib/tags.php
+++ b/engine/lib/tags.php
@@ -321,25 +321,23 @@ function elgg_get_registered_tag_metadata_names() {
*
* @param array $page Page array
*
- * @return void
+ * @return bool
* @access private
*/
function elgg_tagcloud_page_handler($page) {
- switch ($page[0]) {
- default:
- $title = elgg_view_title(elgg_echo('tags:site_cloud'));
- $options = array(
- 'threshold' => 0,
- 'limit' => 100,
- 'tag_name' => 'tags',
- );
- $tags = elgg_view_tagcloud($options);
- $content = $title . $tags;
- $body = elgg_view_layout('one_sidebar', array('content' => $content));
-
- echo elgg_view_page(elgg_echo('tags:site_cloud'), $body);
- break;
- }
+
+ $title = elgg_view_title(elgg_echo('tags:site_cloud'));
+ $options = array(
+ 'threshold' => 0,
+ 'limit' => 100,
+ 'tag_name' => 'tags',
+ );
+ $tags = elgg_view_tagcloud($options);
+ $content = $title . $tags;
+ $body = elgg_view_layout('one_sidebar', array('content' => $content));
+
+ echo elgg_view_page(elgg_echo('tags:site_cloud'), $body);
+ return true;
}
/**
diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php
index bb5d8d6c4..c71670357 100644
--- a/engine/lib/user_settings.php
+++ b/engine/lib/user_settings.php
@@ -265,8 +265,8 @@ function elgg_set_user_default_access() {
* @access private
*/
function usersettings_pagesetup() {
- if (elgg_get_context() == "settings" && elgg_get_logged_in_user_guid()) {
- $user = elgg_get_logged_in_user_entity();
+ if (elgg_get_context() == "settings") {
+ $user = elgg_get_page_owner_entity();
$params = array(
'name' => '1_account',
@@ -294,7 +294,7 @@ function usersettings_pagesetup() {
*
* @param array $page Pages array
*
- * @return void
+ * @return bool
* @access private
*/
function usersettings_page_handler($page) {
@@ -304,7 +304,7 @@ function usersettings_page_handler($page) {
$page[0] = 'user';
}
- if ($page[1]) {
+ if (isset($page[1])) {
$user = get_user_by_username($page[1]);
elgg_set_page_owner_guid($user->guid);
} else {
@@ -324,12 +324,14 @@ function usersettings_page_handler($page) {
$path = $CONFIG->path . "pages/settings/tools.php";
break;
case 'user':
- default:
$path = $CONFIG->path . "pages/settings/account.php";
break;
}
- require($path);
+ if (isset($path)) {
+ require $path;
+ return true;
+ }
}
/**
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 843b897e9..3a86c1faa 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -565,6 +565,8 @@ function get_user_by_username($username) {
$entity = get_data_row($query, 'entity_row_to_elggstar');
if ($entity) {
$USERNAME_TO_GUID_MAP_CACHE[$username] = $entity->guid;
+ } else {
+ $entity = false;
}
return $entity;
@@ -1044,40 +1046,35 @@ function collections_submenu_items() {
}
/**
- * Page handler for friends
+ * Page handler for friends-related pages
*
- * @param array $page_elements Page elements
+ * @param array $segments URL segments
+ * @param string $handler The first segment in URL used for routing
*
- * @return void
+ * @return bool
* @access private
*/
-function friends_page_handler($page_elements) {
+function friends_page_handler($page_elements, $handler) {
+ elgg_set_context('friends');
+
if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {
elgg_set_page_owner_guid($user->getGUID());
}
if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
collections_submenu_items();
}
- require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/index.php");
-}
-/**
- * Page handler for friends of
- *
- * @param array $page_elements Page elements
- *
- * @return void
- * @access private
- */
-function friends_of_page_handler($page_elements) {
- elgg_set_context('friends');
- if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {
- set_page_owner($user->getGUID());
- }
- if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
- collections_submenu_items();
+ switch ($handler) {
+ case 'friends':
+ require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/index.php");
+ break;
+ case 'friendsof':
+ require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/of.php");
+ break;
+ default:
+ return false;
}
- require_once(dirname(dirname(dirname(__FILE__))) . "/pages/friends/of.php");
+ return true;
}
/**
@@ -1085,7 +1082,7 @@ function friends_of_page_handler($page_elements) {
*
* @param array $page_elements Page elements
*
- * @return void
+ * @return bool
* @access private
*/
function collections_page_handler($page_elements) {
@@ -1093,20 +1090,23 @@ function collections_page_handler($page_elements) {
$base = elgg_get_config('path');
if (isset($page_elements[0])) {
if ($page_elements[0] == "add") {
- set_page_owner(elgg_get_logged_in_user_guid());
+ elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
collections_submenu_items();
require_once "{$base}pages/friends/collections/add.php";
+ return true;
} else {
$user = get_user_by_username($page_elements[0]);
if ($user) {
- set_page_owner($user->getGUID());
+ elgg_set_page_owner_guid($user->getGUID());
if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) {
collections_submenu_items();
}
require_once "{$base}pages/friends/collections/view.php";
+ return true;
}
}
}
+ return false;
}
/**
@@ -1115,13 +1115,16 @@ function collections_page_handler($page_elements) {
* @param array $page_elements Page elements
* @param string $handler The handler string
*
- * @return void
+ * @return bool
* @access private
*/
function elgg_user_account_page_handler($page_elements, $handler) {
$base_dir = elgg_get_root_path() . 'pages/account';
switch ($handler) {
+ case 'login':
+ require_once("$base_dir/login.php");
+ break;
case 'forgotpassword':
require_once("$base_dir/forgotten_password.php");
break;
@@ -1131,26 +1134,10 @@ function elgg_user_account_page_handler($page_elements, $handler) {
case 'register':
require_once("$base_dir/register.php");
break;
+ default:
+ return false;
}
-}
-
-/**
- * Display a login box.
- *
- * This is a fallback for non-JS users who click on the
- * dropdown login link.
- *
- * @return void
- * @access private
- */
-function elgg_user_login_page_handler() {
- if (elgg_is_logged_in()) {
- forward();
- }
-
- $login_box = elgg_view('core/account/login_box');
- $content = elgg_view_layout('one_column', array('content' => $login_box));
- echo elgg_view_page(elgg_echo('login'), $content);
+ return true;
}
/**
@@ -1296,6 +1283,11 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
$item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('admin');
$return[] = $item;
+
+ $url = "settings/user/$user->username";
+ $item = new ElggMenuItem('settings:edit', elgg_echo('settings:edit'), $url);
+ $item->setSection('admin');
+ $return[] = $item;
}
return $return;
@@ -1404,6 +1396,7 @@ function elgg_profile_fields_setup() {
* /avatar/view/<username>/<size>/<icontime>
*
* @param array $page
+ * @return bool
* @access private
*/
function elgg_avatar_page_handler($page) {
@@ -1416,16 +1409,20 @@ function elgg_avatar_page_handler($page) {
if ($page[0] == 'edit') {
require_once("{$CONFIG->path}pages/avatar/edit.php");
+ return true;
} else {
set_input('size', $page[2]);
require_once("{$CONFIG->path}pages/avatar/view.php");
+ return true;
}
+ return false;
}
/**
* Profile page handler
*
* @param array $page
+ * @return bool
* @access private
*/
function elgg_profile_page_handler($page) {
@@ -1436,7 +1433,9 @@ function elgg_profile_page_handler($page) {
if ($page[1] == 'edit') {
require_once("{$CONFIG->path}pages/profile/edit.php");
+ return true;
}
+ return false;
}
/**
@@ -1484,14 +1483,15 @@ function users_pagesetup() {
// topbar
if ($viewer) {
-
- $icon_url = $viewer->getIconURL('topbar');
- $class = 'elgg-border-plain elgg-transition';
- $title = elgg_echo('profile');
elgg_register_menu_item('topbar', array(
'name' => 'profile',
'href' => $viewer->getURL(),
- 'text' => "<img src=\"$icon_url\" alt=\"$viewer->name\" title=\"$title\" class=\"$class\" />",
+ 'text' => elgg_view('output/img', array(
+ 'src' => $viewer->getIconURL('topbar'),
+ 'alt' => $viewer->name,
+ 'title' => elgg_echo('profile'),
+ 'class' => 'elgg-border-plain elgg-transition',
+ )),
'priority' => 100,
'link_class' => 'elgg-topbar-avatar',
));
@@ -1532,11 +1532,11 @@ function users_pagesetup() {
function users_init() {
elgg_register_page_handler('friends', 'friends_page_handler');
- elgg_register_page_handler('friendsof', 'friends_of_page_handler');
+ elgg_register_page_handler('friendsof', 'friends_page_handler');
elgg_register_page_handler('register', 'elgg_user_account_page_handler');
elgg_register_page_handler('forgotpassword', 'elgg_user_account_page_handler');
elgg_register_page_handler('resetpassword', 'elgg_user_account_page_handler');
- elgg_register_page_handler('login', 'elgg_user_login_page_handler');
+ elgg_register_page_handler('login', 'elgg_user_account_page_handler');
elgg_register_page_handler('avatar', 'elgg_avatar_page_handler');
elgg_register_page_handler('profile', 'elgg_profile_page_handler');
elgg_register_page_handler('collections', 'collections_page_handler');
diff --git a/engine/lib/views.php b/engine/lib/views.php
index e7bc44cf7..d3c9ff551 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -743,7 +743,11 @@ function elgg_view_menu($menu_name, array $vars = array()) {
$sort_by = elgg_extract('sort_by', $vars, 'text');
- $menu = $CONFIG->menus[$menu_name];
+ if (isset($CONFIG->menus[$menu_name])) {
+ $menu = $CONFIG->menus[$menu_name];
+ } else {
+ $menu = array();
+ }
// Give plugins a chance to add menu items just before creation.
// This supports dynamic menus (example: user_hover).
@@ -860,7 +864,9 @@ function elgg_view_entity(ElggEntity $entity, $vars = array(), $bypass = true, $
*
* @param ElggEntity $entity The entity to display
* @param string $size The size: tiny, small, medium, large
- * @param array $vars An array of variables to pass to the view
+ * @param array $vars An array of variables to pass to the view. Some possible
+ * variables are img_class and link_class. See the
+ * specific icon view for more parameters.
*
* @return string HTML to display or false
*/
@@ -1196,7 +1202,8 @@ function elgg_view_image_block($image, $body, $vars = array()) {
* @since 1.8.0
*/
function elgg_view_module($type, $title, $body, $vars = array()) {
- $vars['class'] .= " elgg-module-$type";
+
+ $vars['class'] = elgg_extract('class', $vars, '') . " elgg-module-$type";
$vars['title'] = $title;
$vars['body'] = $body;
return elgg_view('page/components/module', $vars);
@@ -1582,7 +1589,7 @@ function elgg_views_boot() {
elgg_register_simplecache_view('css/ie7');
elgg_register_simplecache_view('js/elgg');
- elgg_register_js('jquery', '/vendors/jquery/jquery-1.6.2.min.js', 'head');
+ elgg_register_js('jquery', '/vendors/jquery/jquery-1.6.4.min.js', 'head');
elgg_register_js('jquery-ui', '/vendors/jquery/jquery-ui-1.8.16.min.js', 'head');
elgg_register_js('jquery.form', '/vendors/jquery/jquery.form.js');
diff --git a/engine/start.php b/engine/start.php
index fc3aa004e..00bdc3197 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -60,7 +60,8 @@ $lib_dir = dirname(__FILE__) . '/lib/';
*/
$required_files = array(
'elgglib.php', 'views.php', 'access.php', 'system_log.php', 'export.php',
- 'sessions.php', 'languages.php', 'input.php', 'cache.php', 'output.php'
+ 'sessions.php', 'languages.php', 'pageowner.php', 'input.php', 'cache.php',
+ 'output.php'
);
// include bootstraping libs
@@ -96,7 +97,7 @@ $lib_files = array(
'extender.php', 'filestore.php', 'group.php',
'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php',
'metastrings.php', 'navigation.php', 'notification.php', 'objects.php',
- 'opendd.php', 'pagehandler.php', 'pageowner.php', 'pam.php', 'plugins.php',
+ 'opendd.php', 'pagehandler.php', 'pam.php', 'plugins.php',
'private_settings.php', 'relationships.php', 'river.php', 'sites.php',
'statistics.php', 'tags.php', 'user_settings.php', 'users.php',
'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', 'xml-rpc.php',
diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php
index 0c37fa779..bea995a6e 100644
--- a/engine/tests/api/access_collections.php
+++ b/engine/tests/api/access_collections.php
@@ -76,7 +76,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
$q = "SELECT * FROM {$this->dbPrefix}access_collections WHERE id = $acl_id";
$data = get_data($q);
- $this->assertFalse($data);
+ $this->assertIdentical(array(), $data);
}
}
@@ -88,7 +88,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
if ($result) {
$result = remove_user_from_access_collection($this->user->guid, $acl_id);
- $this->assertTrue($result);
+ $this->assertIdentical(true, $result);
}
delete_access_collection($acl_id);
diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php
index e7906d3c8..9db248de9 100644
--- a/engine/tests/api/entity_getter_functions.php
+++ b/engine/tests/api/entity_getter_functions.php
@@ -175,9 +175,10 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
/**
+ * Get a mix of valid and invalid types
*
- * @param unknown_type $num
- * @return unknown_type
+ * @param int $num
+ * @return array
*/
public function getRandomMixedTypes($num = 2) {
$have_valid = $have_invalid = false;
@@ -196,8 +197,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
* Get random mix of valid and invalid subtypes for types given.
*
* @param array $types
- * @param unknown_type $num
- * @return unknown_type
+ * @param int $num
+ * @return array
*/
public function getRandomMixedSubtypes(array $types, $num = 2) {
$types_c = count($types);
@@ -230,8 +231,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
/**
* Creates random annotations on $entity
*
- * @param unknown_type $entity
- * @param unknown_type $max
+ * @param ElggEntity $entity
+ * @param int $max
*/
public function createRandomAnnotations($entity, $max = 1) {
$annotations = array();
@@ -563,7 +564,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
* TYPE_SUBTYPE_PAIRS
***************************/
-
+ /**
+ * Valid type, valid subtype pairs
+ */
public function testElggAPIGettersTSPValidTypeValidSubtype() {
$type_num = 1;
$subtype_num = 1;
@@ -586,6 +589,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
+ /**
+ * Valid type, multiple valid subtypes
+ */
public function testElggAPIGettersTSPValidTypeValidPluralSubtype() {
$type_num = 1;
$subtype_num = 3;
@@ -608,6 +614,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
+ /**
+ * Valid type, both valid and invalid subtypes
+ */
public function testElggAPIGettersTSPValidTypeMixedPluralSubtype() {
$type_num = 1;
$valid_subtype_num = 2;
@@ -635,9 +644,6 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
-
-
-
/****************************
* FALSE-RETURNING TESTS
****************************
@@ -652,8 +658,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
*/
- /*
- * Test invalid types.
+ /**
+ * Test invalid types with singular 'type'.
*/
public function testElggApiGettersInvalidTypeUsingType() {
$type_arr = $this->getRandomInvalids();
@@ -667,7 +673,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$this->assertFalse($es);
}
-
+ /**
+ * Test invalid types with plural 'types'.
+ */
public function testElggApiGettersInvalidTypeUsingTypesAsString() {
$type_arr = $this->getRandomInvalids();
$type = $type_arr[0];
@@ -680,8 +688,11 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$this->assertFalse($es);
}
+ /**
+ * Test invalid types with plural 'types' and an array of a single type
+ */
public function testElggApiGettersInvalidTypeUsingTypesAsArray() {
- $type_arr = $this->getRandomInvalids();
+ $type_arr = $this->getRandomInvalids(1);
$options = array(
'types' => $type_arr
@@ -691,6 +702,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$this->assertFalse($es);
}
+ /**
+ * Test invalid types with plural 'types' and an array of a two types
+ */
public function testElggApiGettersInvalidTypes() {
$type_arr = $this->getRandomInvalids(2);
@@ -1053,7 +1067,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
$e->delete();
}
@@ -1081,7 +1095,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
$e->delete();
}
@@ -1214,7 +1228,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
- function testElggApiGettersEntityMetadatavalueInvalidSingle() {
+ function testElggApiGettersEntityMetadataValueInvalidSingle() {
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
$md_name = 'test_metadata_name_' . rand();
@@ -1235,7 +1249,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
$e->delete();
}
@@ -1263,7 +1277,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
$e->delete();
}
@@ -1641,6 +1655,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
+ /**
+ * Name value pair with valid name and invalid value
+ */
function testElggApiGettersEntityMetadataNVPValidNInvalidV() {
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
@@ -1676,7 +1693,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
foreach ($guids as $guid) {
if ($e = get_entity($guid)) {
@@ -1685,7 +1702,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
}
}
-
+ /**
+ * Name value pair with invalid name and valid value
+ */
function testElggApiGettersEntityMetadataNVPInvalidNValidV() {
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
@@ -1721,7 +1740,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$entities = elgg_get_entities_from_metadata($options);
- $this->assertFalse($entities);
+ $this->assertIdentical(array(), $entities);
foreach ($guids as $guid) {
if ($e = get_entity($guid)) {
@@ -2083,7 +2102,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$es = elgg_get_entities_from_relationship($options);
$this->assertTrue(is_array($es));
- $this->assertTrue(count($es), 1);
+ $this->assertIdentical(count($es), 1);
foreach ($es as $e) {
$this->assertEqual($guids[1], $e->guid);
@@ -2115,7 +2134,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$es = elgg_get_entities_from_relationship($options);
$this->assertTrue(is_array($es));
- $this->assertTrue(count($es), 1);
+ $this->assertIdentical(count($es), 1);
foreach ($es as $e) {
$this->assertEqual($guids[1], $e->guid);
@@ -2151,7 +2170,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
$es = elgg_get_entities_from_relationship($options);
$this->assertTrue(is_array($es));
- $this->assertTrue(count($es), 1);
+ $this->assertIdentical(count($es), 1);
foreach ($es as $e) {
$this->assertEqual($guids[1], $e->guid);
@@ -2578,7 +2597,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest {
foreach ($fan_entities as $fan_entity) {
$this->assertTrue(in_array($fan_entity->guid, $relationships[$e->guid]));
- $this->assertTrue(check_entity_relationship($fan_entity->guid, $relationship_name, $e->guid));
+ $this->assertNotIdentical(false, check_entity_relationship($fan_entity->guid, $relationship_name, $e->guid));
}
}
}
diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php
index f48f91faf..77205138d 100644
--- a/engine/tests/api/helpers.php
+++ b/engine/tests/api/helpers.php
@@ -127,7 +127,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$this->assertIdentical('http://test1.com', $item->url);
// send a bad url
- $result = @elgg_register_js('bad');
+ $result = elgg_register_js('bad', null);
$this->assertFalse($result);
}
@@ -351,7 +351,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$test_elements = $pl->getElements();
// make sure it's gone.
- $this->assertTrue(2, count($test_elements));
+ $this->assertEqual(2, count($test_elements));
$this->assertIdentical($elements[0], $test_elements[0]);
$this->assertIdentical($elements[2], $test_elements[2]);
}
@@ -369,7 +369,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest {
$pl->add($element, $priority);
}
- $this->assertTrue($pl->move($elements[-5], 10));
+ $this->assertEqual($pl->move($elements[-5], 10), 10);
// check it's at the new place
$this->assertIdentical($elements[-5], $pl->getElement(10));
diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php
index 7897b8d47..f5b615ca8 100644
--- a/engine/tests/api/metadata.php
+++ b/engine/tests/api/metadata.php
@@ -58,11 +58,11 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest {
$this->create_metastring('tested');
// create_metadata returns id of metadata on success
- $this->assertTrue(create_metadata($this->object->guid, 'metaUnitTest', 'tested'));
+ $this->assertNotEqual(false, create_metadata($this->object->guid, 'metaUnitTest', 'tested'));
// check value with improper case
$options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'Tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE);
- $this->assertFalse(elgg_get_entities_from_metadata($options));
+ $this->assertIdentical(array(), elgg_get_entities_from_metadata($options));
// compare forced case with ignored case
$options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE);
diff --git a/engine/tests/api/metastrings.php b/engine/tests/api/metastrings.php
index 9b5d7ee4e..a96388217 100644
--- a/engine/tests/api/metastrings.php
+++ b/engine/tests/api/metastrings.php
@@ -68,9 +68,6 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest {
parent::__destruct();
}
- /**
- * A basic test that will be called and fail.
- */
public function testDeleteByID() {
$db_prefix = elgg_get_config('dbprefix');
$annotations = $this->createAnnotations(1);
@@ -83,8 +80,8 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest {
$test = get_data($q);
$this->assertEqual($test[0]->id, $id);
- $this->assertTrue(elgg_delete_metastring_based_object_by_id($id, $type));
- $this->assertFalse(get_data($q));
+ $this->assertIdentical(true, elgg_delete_metastring_based_object_by_id($id, $type));
+ $this->assertIdentical(array(), get_data($q));
}
}
@@ -101,9 +98,6 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest {
}
}
- /**
- * A basic test that will be called and fail.
- */
public function testEnableDisableByID() {
$db_prefix = elgg_get_config('dbprefix');
$annotations = $this->createAnnotations(1);
diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php
index 8f5f5dd1e..8ecb0a46c 100644
--- a/engine/tests/api/plugins.php
+++ b/engine/tests/api/plugins.php
@@ -68,8 +68,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
'blurb' => 'A concise description.',
'description' => 'A longer, more interesting description.',
'website' => 'http://www.elgg.org/',
- 'copyright' => '(C) Elgg 2010',
- 'license' => 'GNU Public License version 2',
+ 'copyright' => '(C) Elgg Foundation 2011',
+ 'license' => 'GNU General Public License version 2',
'requires' => array(
array('type' => 'elgg_version', 'version' => '3009030802', 'comparison' => 'lt'),
@@ -93,22 +93,23 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
),
'conflicts' => array(
- array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.0)
+ array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.0')
),
'provides' => array(
- array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.3),
- array('type' => 'php_extension', 'name' => 'big_math', 'version' => 1.0)
+ array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.3'),
+ array('type' => 'php_extension', 'name' => 'big_math', 'version' => '1.0')
),
'suggests' => array(
- array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => 1.0),
+ array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => '1.0'),
),
- 'activate_on_install' => true
+ // string because we are reading from a file
+ 'activate_on_install' => 'true',
);
- $this->assertEqual($this->manifest18->getManifest(), $manifest_array);
+ $this->assertIdentical($this->manifest18->getManifest(), $manifest_array);
}
public function testElggPluginManifest17() {
@@ -117,13 +118,13 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
'version' => '1.0',
'description' => 'A 1.7-style manifest.',
'website' => 'http://www.elgg.org/',
- 'copyright' => '(C) Elgg 2010',
- 'license' => 'GNU Public License version 2',
+ 'copyright' => '(C) Elgg Foundation 2011',
+ 'license' => 'GNU General Public License version 2',
'elgg_version' => '2009030702',
'name' => 'Plugin Test 17',
);
- $this->assertEqual($this->manifest17->getManifest(), $manifest_array);
+ $this->assertIdentical($this->manifest17->getManifest(), $manifest_array);
}
@@ -165,13 +166,13 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
}
public function testElggPluginManifestGetCopyright() {
- $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg 2010');
- $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg 2010');
+ $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg Foundation 2011');
+ $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg Foundation 2011');
}
public function testElggPluginManifestGetLicense() {
- $this->assertEqual($this->manifest18->getLicense(), 'GNU Public License version 2');
- $this->assertEqual($this->manifest17->getLicense(), 'GNU Public License version 2');
+ $this->assertEqual($this->manifest18->getLicense(), 'GNU General Public License version 2');
+ $this->assertEqual($this->manifest17->getLicense(), 'GNU General Public License version 2');
}
@@ -180,7 +181,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('type' => 'elgg_version', 'version' => '3009030802', 'comparison' => 'lt'),
array('type' => 'elgg_release', 'version' => '1.8-svn', 'comparison' => 'ge'),
array('type' => 'php_extension', 'name' => 'gd', 'version' => '', 'comparison' => '='),
- array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 'off', 'comparison' => '='),
+ array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 0, 'comparison' => '='),
array('type' => 'php_extension', 'name' => 'made_up', 'version' => '1.0', 'comparison' => '='),
array('type' => 'plugin', 'name' => 'fake_plugin', 'version' => '1.0', 'comparison' => 'ge'),
array('type' => 'plugin', 'name' => 'profile', 'version' => '1.0', 'comparison' => 'ge'),
@@ -188,13 +189,13 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('type' => 'priority', 'priority' => 'after', 'plugin' => 'profile'),
);
- $this->assertEqual($this->package18->getManifest()->getRequires(), $requires);
+ $this->assertIdentical($this->package18->getManifest()->getRequires(), $requires);
$requires = array(
array('type' => 'elgg_version', 'version' => '2009030702', 'comparison' => 'ge')
);
- $this->assertEqual($this->package17->getManifest()->getRequires(), $requires);
+ $this->assertIdentical($this->package17->getManifest()->getRequires(), $requires);
}
public function testElggPluginManifestGetSuggests() {
@@ -202,11 +203,11 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => '1.0', 'comparison' => 'ge'),
);
- $this->assertEqual($this->package18->getManifest()->getSuggests(), $suggests);
+ $this->assertIdentical($this->package18->getManifest()->getSuggests(), $suggests);
$suggests = array();
- $this->assertEqual($this->package17->getManifest()->getSuggests(), $suggests);
+ $this->assertIdentical($this->package17->getManifest()->getSuggests(), $suggests);
}
public function testElggPluginManifestGetDescription() {
@@ -219,8 +220,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
'Admin', 'ServiceAPI'
);
- $this->assertEqual($this->package18->getManifest()->getCategories(), $categories);
- $this->assertEqual($this->package17->getManifest()->getCategories(), array());
+ $this->assertIdentical($this->package18->getManifest()->getCategories(), $categories);
+ $this->assertIdentical($this->package17->getManifest()->getCategories(), array());
}
public function testElggPluginManifestGetScreenshots() {
@@ -229,25 +230,25 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
array('description' => 'Fun things to do 2', 'path' => 'graphics/plugin_ss2.png'),
);
- $this->assertEqual($this->package18->getManifest()->getScreenshots(), $screenshots);
- $this->assertEqual($this->package17->getManifest()->getScreenshots(), array());
+ $this->assertIdentical($this->package18->getManifest()->getScreenshots(), $screenshots);
+ $this->assertIdentical($this->package17->getManifest()->getScreenshots(), array());
}
public function testElggPluginManifestGetProvides() {
$provides = array(
- array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.3),
- array('type' => 'php_extension', 'name' => 'big_math', 'version' => 1.0),
- array('type' => 'plugin', 'name' => 'plugin_18', 'version' => 1.0)
+ array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.3'),
+ array('type' => 'php_extension', 'name' => 'big_math', 'version' => '1.0'),
+ array('type' => 'plugin', 'name' => 'plugin_18', 'version' => '1.0')
);
- $this->assertEqual($this->package18->getManifest()->getProvides(), $provides);
+ $this->assertIdentical($this->package18->getManifest()->getProvides(), $provides);
$provides = array(
array('type' => 'plugin', 'name' => 'plugin_17', 'version' => '1.0')
);
- $this->assertEqual($this->package17->getManifest()->getProvides(), $provides);
+ $this->assertIdentical($this->package17->getManifest()->getProvides(), $provides);
}
public function testElggPluginManifestGetConflicts() {
@@ -260,12 +261,12 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
)
);
- $this->assertEqual($this->manifest18->getConflicts(), $conflicts);
- $this->assertEqual($this->manifest17->getConflicts(), array());
+ $this->assertIdentical($this->manifest18->getConflicts(), $conflicts);
+ $this->assertIdentical($this->manifest17->getConflicts(), array());
}
public function testElggPluginManifestGetActivateOnInstall() {
- $this->assertEqual($this->manifest18->getActivateOnInstall(), true);
+ $this->assertIdentical($this->manifest18->getActivateOnInstall(), true);
}
// ElggPluginPackage
diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php
index c13b4c731..1772f7c1a 100644
--- a/engine/tests/objects/entities.php
+++ b/engine/tests/objects/entities.php
@@ -89,21 +89,21 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
$this->assertFalse(isset($this->entity->non_existent));
// create metadata
- $this->assertTrue($this->entity->non_existent = 'testing');
+ $this->entity->existent = 'testing';
+ $this->assertIdentical($this->entity->existent, 'testing');
// check metadata set
- $this->assertTrue(isset($this->entity->non_existent));
- $this->assertIdentical($this->entity->non_existent, 'testing');
- $this->assertIdentical($this->entity->getMetaData('non_existent'), 'testing');
+ $this->assertTrue(isset($this->entity->existent));
+ $this->assertIdentical($this->entity->getMetaData('existent'), 'testing');
// check internal metadata array
$metadata = $this->entity->expose_metadata();
- $this->assertIdentical($metadata['non_existent'], 'testing');
+ $this->assertIdentical($metadata['existent'], 'testing');
}
public function testElggEnityGetAndSetAnnotations() {
$this->assertFalse(array_key_exists('non_existent', $this->entity->expose_annotations()));
- $this->assertFalse($this->entity->getAnnotations('non_existent'));
+ $this->assertIdentical($this->entity->getAnnotations('non_existent'), array());
// set and check temp annotation
$this->assertTrue($this->entity->annotate('non_existent', 'testing'));
@@ -178,7 +178,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
$this->AssertEqual($this->entity->get('non_existent'), 'testing');
// clean up with delete
- $this->assertTrue($this->entity->delete());
+ $this->assertIdentical(true, $this->entity->delete());
}
public function testElggEntityDisableAndEnable() {
@@ -230,24 +230,26 @@ class ElggCoreEntityTest extends ElggCoreUnitTest {
// let's delete a non-existent metadata
$this->assertFalse($this->entity->deleteMetadata('important'));
- // let's add the meatadata
- $this->assertTrue($this->entity->important = 'indeed!');
- $this->assertTrue($this->entity->less_important = 'true, too!');
+ // let's add the metadata
+ $this->entity->important = 'indeed!';
+ $this->assertIdentical('indeed!', $this->entity->important);
+ $this->entity->less_important = 'true, too!';
+ $this->assertIdentical('true, too!', $this->entity->less_important);
$this->save_entity();
// test deleting incorrectly
// @link http://trac.elgg.org/ticket/2273
- $this->assertFalse($this->entity->deleteMetadata('impotent'));
+ $this->assertNull($this->entity->deleteMetadata('impotent'));
$this->assertEqual($this->entity->important, 'indeed!');
// get rid of one metadata
$this->assertEqual($this->entity->important, 'indeed!');
$this->assertTrue($this->entity->deleteMetadata('important'));
- $this->assertEqual($this->entity->important, '');
+ $this->assertNull($this->entity->important);
// get rid of all metadata
$this->assertTrue($this->entity->deleteMetadata());
- $this->assertEqual($this->entity->less_important, '');
+ $this->assertNull($this->entity->less_important);
// clean up database
$this->assertTrue($this->entity->delete());
diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php
index e5acbb3f9..a01a661e3 100644
--- a/engine/tests/objects/sites.php
+++ b/engine/tests/objects/sites.php
@@ -36,9 +36,6 @@ class ElggCoreSiteTest extends ElggCoreUnitTest {
parent::__destruct();
}
- /**
- * A basic test that will be called and fail.
- */
public function testElggSiteConstructor() {
$attributes = array();
$attributes['guid'] = NULL;
@@ -66,8 +63,10 @@ class ElggCoreSiteTest extends ElggCoreUnitTest {
}
public function testElggSiteSaveAndDelete() {
- $this->assertTrue($this->site->save());
- $this->assertTrue($this->site->delete());
+ $guid = $this->site->save();
+ $this->assertIsA($guid, 'int');
+ $this->assertTrue($guid > 0);
+ $this->assertIdentical(true, $this->site->delete());
}
}
diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php
index d1533c3d2..a3573acb6 100644
--- a/engine/tests/objects/users.php
+++ b/engine/tests/objects/users.php
@@ -41,9 +41,6 @@ class ElggCoreUserTest extends ElggCoreUnitTest {
parent::__destruct();
}
- /**
- * A basic test that will be called and fail.
- */
public function testElggUserConstructor() {
$attributes = array();
$attributes['guid'] = NULL;
@@ -138,7 +135,7 @@ class ElggCoreUserTest extends ElggCoreUnitTest {
$guid = $this->user->save();
// delete object
- $this->assertTrue($this->user->delete());
+ $this->assertIdentical(true, $this->user->delete());
// check GUID not in database
$this->assertFalse($this->fetchUser($guid));
diff --git a/engine/tests/test_files/plugin_17/manifest.xml b/engine/tests/test_files/plugin_17/manifest.xml
index bb178ab93..706734265 100644
--- a/engine/tests/test_files/plugin_17/manifest.xml
+++ b/engine/tests/test_files/plugin_17/manifest.xml
@@ -4,7 +4,7 @@
<field key="version" value="1.0" />
<field key="description" value="A 1.7-style manifest." />
<field key="website" value="http://www.elgg.org/" />
- <field key="copyright" value="(C) Elgg 2010" />
- <field key="license" value="GNU Public License version 2" />
+ <field key="copyright" value="(C) Elgg Foundation 2011" />
+ <field key="license" value="GNU General Public License version 2" />
<field key="elgg_version" value="2009030702" />
</plugin_manifest> \ No newline at end of file
diff --git a/engine/tests/test_files/plugin_18/manifest.xml b/engine/tests/test_files/plugin_18/manifest.xml
index 445a41c2e..9654b6422 100644
--- a/engine/tests/test_files/plugin_18/manifest.xml
+++ b/engine/tests/test_files/plugin_18/manifest.xml
@@ -6,8 +6,8 @@
<blurb>A concise description.</blurb>
<description>A longer, more interesting description.</description>
<website>http://www.elgg.org/</website>
- <copyright>(C) Elgg 2010</copyright>
- <license>GNU Public License version 2</license>
+ <copyright>(C) Elgg Foundation 2011</copyright>
+ <license>GNU General Public License version 2</license>
<requires>
<type>elgg_version</type>
@@ -34,8 +34,6 @@
<category>ServiceAPI</category>
- <activate_on_install>true</activate_on_install>
-
<requires>
<type>php_extension</type>
<name>gd</name>
@@ -102,4 +100,6 @@
<version>1.0</version>
</suggests>
+ <activate_on_install>true</activate_on_install>
+
</plugin_manifest>
diff --git a/engine/tests/test_skeleton.php b/engine/tests/test_skeleton.php
index e5ff557e5..5a5de89bb 100644
--- a/engine/tests/test_skeleton.php
+++ b/engine/tests/test_skeleton.php
@@ -49,9 +49,6 @@ class ElggCoreSkeletonTest extends ElggCoreUnitTest {
parent::__destruct();
}
- /**
- * A basic test that will be called and fail.
- */
public function testFailure() {
$this->assertTrue(FALSE);
}