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/ElggMemcache.php4
-rw-r--r--engine/classes/ElggObject.php5
-rw-r--r--engine/classes/ElggPluginManifest.php2
-rw-r--r--engine/classes/ElggSite.php11
-rw-r--r--engine/classes/ElggUser.php5
-rw-r--r--engine/classes/XMLRPCArrayParameter.php56
-rw-r--r--engine/classes/XMLRPCBase64Parameter.php28
-rw-r--r--engine/classes/XMLRPCBoolParameter.php30
-rw-r--r--engine/classes/XMLRPCCall.php62
-rw-r--r--engine/classes/XMLRPCDateParameter.php33
-rw-r--r--engine/classes/XMLRPCDoubleParameter.php29
-rw-r--r--engine/classes/XMLRPCErrorResponse.php36
-rw-r--r--engine/classes/XMLRPCIntParameter.php29
-rw-r--r--engine/classes/XMLRPCParameter.php16
-rw-r--r--engine/classes/XMLRPCResponse.php71
-rw-r--r--engine/classes/XMLRPCStringParameter.php30
-rw-r--r--engine/classes/XMLRPCStructParameter.php55
-rw-r--r--engine/classes/XMLRPCSuccessResponse.php22
-rw-r--r--engine/handlers/page_handler.php8
-rw-r--r--engine/handlers/xml-rpc_handler.php44
-rw-r--r--engine/lib/access.php5
-rw-r--r--engine/lib/admin.php5
-rw-r--r--engine/lib/annotations.php32
-rw-r--r--engine/lib/deprecated-1.9.php (renamed from engine/lib/calendar.php)29
-rw-r--r--engine/lib/elgglib.php5
-rw-r--r--engine/lib/entities.php35
-rw-r--r--engine/lib/languages.php11
-rw-r--r--engine/lib/metastrings.php2
-rw-r--r--engine/lib/navigation.php50
-rw-r--r--engine/lib/output.php10
-rw-r--r--engine/lib/pagehandler.php33
-rw-r--r--engine/lib/relationships.php2
-rw-r--r--engine/lib/river.php33
-rw-r--r--engine/lib/user_settings.php11
-rw-r--r--engine/lib/users.php16
-rw-r--r--engine/lib/views.php2
-rw-r--r--engine/lib/widgets.php87
-rw-r--r--engine/lib/xml-rpc.php203
-rw-r--r--engine/start.php8
-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.php49
-rw-r--r--engine/tests/api/river.php21
-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/regression/trac_bugs.php2
-rw-r--r--engine/tests/test_files/plugin_18/manifest.xml4
-rw-r--r--engine/tests/test_skeleton.php3
54 files changed, 428 insertions, 955 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/ElggMemcache.php b/engine/classes/ElggMemcache.php
index 1fd3be0d1..a54c29723 100644
--- a/engine/classes/ElggMemcache.php
+++ b/engine/classes/ElggMemcache.php
@@ -161,7 +161,7 @@ class ElggMemcache extends ElggSharedMemoryCache {
}
$result = $this->memcache->set($key, $data, null, $expires);
- if (!$result) {
+ if ($result === false) {
elgg_log("MEMCACHE: FAILED TO SAVE $key", 'ERROR');
}
@@ -181,7 +181,7 @@ class ElggMemcache extends ElggSharedMemoryCache {
$key = $this->_makeMemcacheKey($key);
$result = $this->memcache->get($key);
- if (!$result) {
+ if ($result === false) {
elgg_log("MEMCACHE: FAILED TO LOAD $key", 'ERROR');
}
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/ElggSite.php b/engine/classes/ElggSite.php
index 16b80b9d3..2d6238a19 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;
}
@@ -418,10 +421,10 @@ class ElggSite extends ElggEntity {
'action/security/refreshtoken',
'ajax/view/js/languages',
'upgrade\.php',
- 'xml-rpc\.php',
- 'mt/mt-xmlrpc\.cgi',
'css/.*',
- 'js/.*'
+ 'js/.*',
+ 'cache/css/.*',
+ 'cache/js/.*',
);
// include a hook for plugin authors to include public pages
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/classes/XMLRPCArrayParameter.php b/engine/classes/XMLRPCArrayParameter.php
deleted file mode 100644
index a8edccba7..000000000
--- a/engine/classes/XMLRPCArrayParameter.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-/**
- * An array containing other XMLRPCParameter objects.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- *
- */
-class XMLRPCArrayParameter extends XMLRPCParameter
-{
- /**
- * Construct an array.
- *
- * @param array $parameters Optional array of parameters, if not provided
- * then addField must be used.
- */
- function __construct($parameters = NULL) {
- parent::__construct();
-
- if (is_array($parameters)) {
- foreach ($parameters as $v) {
- $this->addField($v);
- }
- }
- }
-
- /**
- * Add a field to the container.
- *
- * @param XMLRPCParameter $value The value.
- *
- * @return void
- */
- public function addField(XMLRPCParameter $value) {
- if (!is_array($this->value)) {
- $this->value = array();
- }
-
- $this->value[] = $value;
- }
-
- /**
- * Converts XML array to string
- *
- * @return string
- */
- function __toString() {
- $params = "";
- foreach ($this->value as $value) {
- $params .= "$value";
- }
-
- return "<array><data>$params</data></array>";
- }
-}
diff --git a/engine/classes/XMLRPCBase64Parameter.php b/engine/classes/XMLRPCBase64Parameter.php
deleted file mode 100644
index 7db0a761c..000000000
--- a/engine/classes/XMLRPCBase64Parameter.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
- * A base 64 encoded blob of binary.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCBase64Parameter extends XMLRPCParameter {
- /**
- * Construct a base64 encoded block
- *
- * @param string $blob Unencoded binary blob
- */
- function __construct($blob) {
- parent::__construct();
-
- $this->value = base64_encode($blob);
- }
-
- /**
- * Convert to string
- *
- * @return string
- */
- function __toString() {
- return "<value><base64>{$value}</base64></value>";
- }
-}
diff --git a/engine/classes/XMLRPCBoolParameter.php b/engine/classes/XMLRPCBoolParameter.php
deleted file mode 100644
index 607841cb8..000000000
--- a/engine/classes/XMLRPCBoolParameter.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * A boolean.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCBoolParameter extends XMLRPCParameter {
-
- /**
- * New bool parameter
- *
- * @param bool $value Value
- */
- function __construct($value) {
- parent::__construct();
-
- $this->value = (bool)$value;
- }
-
- /**
- * Convert to string
- *
- * @return string
- */
- function __toString() {
- $code = ($this->value) ? "1" : "0";
- return "<value><boolean>{$code}</boolean></value>";
- }
-}
diff --git a/engine/classes/XMLRPCCall.php b/engine/classes/XMLRPCCall.php
deleted file mode 100644
index 8eeba0c29..000000000
--- a/engine/classes/XMLRPCCall.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/**
- * An XMLRPC call
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCCall {
- /** Method name */
- private $methodname;
-
- /** Parameters */
- private $params;
-
- /**
- * Construct a new XML RPC Call
- *
- * @param string $xml XML
- */
- function __construct($xml) {
- $this->_parse($xml);
- }
-
- /**
- * Return the method name associated with the call.
- *
- * @return string
- */
- public function getMethodName() { return $this->methodname; }
-
- /**
- * Return the parameters.
- * Returns a nested array of XmlElement.
- *
- * @see XmlElement
- * @return array
- */
- public function getParameters() { return $this->params; }
-
- /**
- * Parse the xml into its components according to spec.
- * This first version is a little primitive.
- *
- * @param string $xml XML
- *
- * @return void
- */
- private function _parse($xml) {
- $xml = xml_to_object($xml);
-
- // sanity check
- if ((isset($xml->name)) && (strcasecmp($xml->name, "methodCall") != 0)) {
- throw new CallException(elgg_echo('CallException:NotRPCCall'));
- }
-
- // method name
- $this->methodname = $xml->children[0]->content;
-
- // parameters
- $this->params = $xml->children[1]->children;
- }
-}
diff --git a/engine/classes/XMLRPCDateParameter.php b/engine/classes/XMLRPCDateParameter.php
deleted file mode 100644
index 93bbbd8f5..000000000
--- a/engine/classes/XMLRPCDateParameter.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * An ISO8601 data and time.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCDateParameter extends XMLRPCParameter {
- /**
- * Construct a date
- *
- * @param int $timestamp The unix timestamp, or blank for "now".
- */
- function __construct($timestamp = 0) {
- parent::__construct();
-
- $this->value = $timestamp;
-
- if (!$timestamp) {
- $this->value = time();
- }
- }
-
- /**
- * Convert to string
- *
- * @return string
- */
- function __toString() {
- $value = date('c', $this->value);
- return "<value><dateTime.iso8601>{$value}</dateTime.iso8601></value>";
- }
-}
diff --git a/engine/classes/XMLRPCDoubleParameter.php b/engine/classes/XMLRPCDoubleParameter.php
deleted file mode 100644
index b7834650e..000000000
--- a/engine/classes/XMLRPCDoubleParameter.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/**
- * A double precision signed floating point number.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCDoubleParameter extends XMLRPCParameter {
-
- /**
- * New XML Double
- *
- * @param int $value Value
- */
- function __construct($value) {
- parent::__construct();
-
- $this->value = (float)$value;
- }
-
- /**
- * Convert to string
- *
- * @return string
- */
- function __toString() {
- return "<value><double>{$this->value}</double></value>";
- }
-}
diff --git a/engine/classes/XMLRPCErrorResponse.php b/engine/classes/XMLRPCErrorResponse.php
deleted file mode 100644
index 425c075cc..000000000
--- a/engine/classes/XMLRPCErrorResponse.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/**
- * XMLRPC Error Response
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCErrorResponse extends XMLRPCResponse {
- /**
- * Set the error response and error code.
- *
- * @param string $message The message
- * @param int $code Error code (default = system error as defined by
- * http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php)
- */
- function __construct($message, $code = -32400) {
- $this->addParameter(
- new XMLRPCStructParameter(
- array (
- 'faultCode' => new XMLRPCIntParameter($code),
- 'faultString' => new XMLRPCStringParameter($message)
- )
- )
- );
- }
-
- /**
- * Output to XML.
- *
- * @return string
- */
- public function __toString() {
- return "<methodResponse><fault><value>{$this->parameters[0]}</value></fault></methodResponse>";
- }
-}
diff --git a/engine/classes/XMLRPCIntParameter.php b/engine/classes/XMLRPCIntParameter.php
deleted file mode 100644
index 0fc146165..000000000
--- a/engine/classes/XMLRPCIntParameter.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/**
- * An Integer.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCIntParameter extends XMLRPCParameter {
-
- /**
- * A new XML int
- *
- * @param int $value Value
- */
- function __construct($value) {
- parent::__construct();
-
- $this->value = (int)$value;
- }
-
- /**
- * Convert to string
- *
- * @return string
- */
- function __toString() {
- return "<value><i4>{$this->value}</i4></value>";
- }
-}
diff --git a/engine/classes/XMLRPCParameter.php b/engine/classes/XMLRPCParameter.php
deleted file mode 100644
index ffbad8082..000000000
--- a/engine/classes/XMLRPCParameter.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Superclass for all RPC parameters.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-abstract class XMLRPCParameter {
- protected $value;
-
- /**
- * Set initial values
- */
- function __construct() { }
-
-}
diff --git a/engine/classes/XMLRPCResponse.php b/engine/classes/XMLRPCResponse.php
deleted file mode 100644
index a6256d385..000000000
--- a/engine/classes/XMLRPCResponse.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-
-/**
- * XML-RPC Response.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-abstract class XMLRPCResponse {
- /** An array of parameters */
- protected $parameters = array();
-
- /**
- * Add a parameter here.
- *
- * @param XMLRPCParameter $param The parameter.
- *
- * @return void
- */
- public function addParameter(XMLRPCParameter $param) {
- if (!is_array($this->parameters)) {
- $this->parameters = array();
- }
-
- $this->parameters[] = $param;
- }
-
- /**
- * Add an integer
- *
- * @param int $value Value
- *
- * @return void
- */
- public function addInt($value) {
- $this->addParameter(new XMLRPCIntParameter($value));
- }
-
- /**
- * Add a string
- *
- * @param string $value Value
- *
- * @return void
- */
- public function addString($value) {
- $this->addParameter(new XMLRPCStringParameter($value));
- }
-
- /**
- * Add a double
- *
- * @param int $value Value
- *
- * @return void
- */
- public function addDouble($value) {
- $this->addParameter(new XMLRPCDoubleParameter($value));
- }
-
- /**
- * Add a boolean
- *
- * @param bool $value Value
- *
- * @return void
- */
- public function addBoolean($value) {
- $this->addParameter(new XMLRPCBoolParameter($value));
- }
-}
diff --git a/engine/classes/XMLRPCStringParameter.php b/engine/classes/XMLRPCStringParameter.php
deleted file mode 100644
index 35b28214b..000000000
--- a/engine/classes/XMLRPCStringParameter.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * A string.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCStringParameter extends XMLRPCParameter {
-
- /**
- * A new XML string
- *
- * @param string $value Value
- */
- function __construct($value) {
- parent::__construct();
-
- $this->value = $value;
- }
-
- /**
- * Convert to XML string
- *
- * @return string
- */
- function __toString() {
- $value = htmlentities($this->value);
- return "<value><string>{$value}</string></value>";
- }
-}
diff --git a/engine/classes/XMLRPCStructParameter.php b/engine/classes/XMLRPCStructParameter.php
deleted file mode 100644
index 694ddf5df..000000000
--- a/engine/classes/XMLRPCStructParameter.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-/**
- * A structure containing other XMLRPCParameter objects.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCStructParameter extends XMLRPCParameter {
- /**
- * Construct a struct.
- *
- * @param array $parameters Optional associated array of parameters, if
- * not provided then addField must be used.
- */
- function __construct($parameters = NULL) {
- parent::__construct();
-
- if (is_array($parameters)) {
- foreach ($parameters as $k => $v) {
- $this->addField($k, $v);
- }
- }
- }
-
- /**
- * Add a field to the container.
- *
- * @param string $name The name of the field.
- * @param XMLRPCParameter $value The value.
- *
- * @return void
- */
- public function addField($name, XMLRPCParameter $value) {
- if (!is_array($this->value)) {
- $this->value = array();
- }
-
- $this->value[$name] = $value;
- }
-
- /**
- * Convert to string
- *
- * @return string
- */
- function __toString() {
- $params = "";
- foreach ($this->value as $k => $v) {
- $params .= "<member><name>$k</name>$v</member>";
- }
-
- return "<value><struct>$params</struct></value>";
- }
-}
diff --git a/engine/classes/XMLRPCSuccessResponse.php b/engine/classes/XMLRPCSuccessResponse.php
deleted file mode 100644
index e02e82c5c..000000000
--- a/engine/classes/XMLRPCSuccessResponse.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
- * Success Response
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-class XMLRPCSuccessResponse extends XMLRPCResponse {
- /**
- * Output to XML.
- *
- * @return string
- */
- public function __toString() {
- $params = "";
- foreach ($this->parameters as $param) {
- $params .= "<param>$param</param>\n";
- }
-
- return "<methodResponse><params>$params</params></methodResponse>";
- }
-}
diff --git a/engine/handlers/page_handler.php b/engine/handlers/page_handler.php
index 1ed295b7d..7eca37bb1 100644
--- a/engine/handlers/page_handler.php
+++ b/engine/handlers/page_handler.php
@@ -13,12 +13,16 @@
* * cache
* * services
* * export
- * * mt
- * * xml-rpc.php
+ * * js
+ * * css
* * rewrite.php
* * tag (deprecated, reserved for backwards compatibility)
* * pg (deprecated, reserved for backwards compatibility)
*
+ * These additionally are reserved for the xml-rpc plugin
+ * * mt
+ * * xml-rpc.php
+ *
* {@link page_handler()} explodes the pages string by / and sends it to
* the page handler function as registered by {@link elgg_register_page_handler()}.
* If a valid page handler isn't found, plugins have a chance to provide a 404.
diff --git a/engine/handlers/xml-rpc_handler.php b/engine/handlers/xml-rpc_handler.php
deleted file mode 100644
index 2ee29e5b7..000000000
--- a/engine/handlers/xml-rpc_handler.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**
- * XML-RPC handler.
- *
- * @warning This is very old code. Does it work at all?
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- * @link http://docs.elgg.org/Tutorials/XMLRPC
- * @todo Does this work?
- */
-
-require_once(dirname(dirname(__FILE__)) . "/start.php");
-
-// Register the error handler
-error_reporting(E_ALL);
-set_error_handler('_php_xmlrpc_error_handler');
-
-// Register a default exception handler
-set_exception_handler('_php_xmlrpc_exception_handler');
-
-// Set some defaults
-$result = null;
-set_input('view', 'xml'); // Set default view regardless
-
-// Get the post data
-$input = get_post_data();
-
-if ($input) {
- // Parse structures from xml
- $call = new XMLRPCCall($input);
-
- // Process call
- $result = trigger_xmlrpc_handler($call);
-} else {
- throw new CallException(elgg_echo('xmlrpc:noinputdata'));
-}
-
-if (!($result instanceof XMLRPCResponse)) {
- throw new APIException(elgg_echo('APIException:ApiResultUnknown'));
-}
-
-// Output result
-echo elgg_view_page("XML-RPC", elgg_view("xml-rpc/output", array('result' => $result)));
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 97f744fb9..08b9283cd 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -610,8 +610,7 @@ function delete_access_collection($collection_id) {
WHERE id = {$collection_id}";
$result = delete_data($q);
-
- return $result;
+ return (bool)$result;
}
/**
@@ -718,7 +717,7 @@ function remove_user_from_access_collection($user_guid, $collection_id) {
WHERE access_collection_id = {$collection_id}
AND user_guid = {$user_guid}";
- return delete_data($q);
+ return (bool)delete_data($q);
}
/**
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 3baf2ff61..a191d740b 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -225,6 +225,7 @@ function admin_init() {
elgg_register_action('admin/site/update_basic', '', 'admin');
elgg_register_action('admin/site/update_advanced', '', 'admin');
+ elgg_register_action('admin/site/flush_cache', '', 'admin');
elgg_register_action('admin/menu/save', '', 'admin');
@@ -301,7 +302,7 @@ function admin_init() {
}
// widgets
- $widgets = array('online_users', 'new_users', 'content_stats', 'admin_welcome');
+ $widgets = array('online_users', 'new_users', 'content_stats', 'admin_welcome', 'control_panel');
foreach ($widgets as $widget) {
elgg_register_widget_type(
$widget,
@@ -616,7 +617,7 @@ function elgg_add_admin_widgets($event, $type, $user) {
// In the form column => array of handlers in order, top to bottom
$adminWidgets = array(
- 1 => array('admin_welcome'),
+ 1 => array('control_panel', 'admin_welcome'),
2 => array('online_users', 'new_users', 'content_stats'),
);
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index e40ab2e39..bfd40d1e8 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -529,6 +529,20 @@ function elgg_annotation_exists($entity_guid, $annotation_type, $owner_guid = NU
}
/**
+ * Return the URL for a comment
+ *
+ * @param ElggAnnotation $comment The comment object
+ * @return string
+ * @access private
+ */
+function elgg_comment_url_handler(ElggAnnotation $comment) {
+ $entity = $comment->getEntity();
+ if ($entity) {
+ return $entity->getURL() . '#item-annotation-' . $comment->id;
+ }
+}
+
+/**
* Register an annotation url handler.
*
* @param string $function_name The function.
@@ -540,11 +554,6 @@ function elgg_register_annotation_url_handler($extender_name = "all", $function_
return elgg_register_extender_url_handler('annotation', $extender_name, $function_name);
}
-/** Register the hook */
-elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2);
-
-elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test');
-
/**
* Register annotation unit tests
* @access private
@@ -554,3 +563,16 @@ function annotations_test($hook, $type, $value, $params) {
$value[] = $CONFIG->path . 'engine/tests/api/annotations.php';
return $value;
}
+
+/**
+ * Initialize the annotation library
+ * @access private
+ */
+function elgg_annotations_init() {
+ elgg_register_annotation_url_handler('generic_comment', 'elgg_comment_url_handler');
+
+ elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2);
+ elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test');
+}
+
+elgg_register_event_handler('init', 'system', 'elgg_annotations_init');
diff --git a/engine/lib/calendar.php b/engine/lib/deprecated-1.9.php
index 9a06c5292..31d03428f 100644
--- a/engine/lib/calendar.php
+++ b/engine/lib/deprecated-1.9.php
@@ -1,14 +1,5 @@
<?php
/**
- * Elgg calendar / entity / event functions.
- *
- * @package Elgg.Core
- * @subpackage Calendar
- *
- * @todo Implement or remove
- */
-
-/**
* Return a timestamp for the start of a given day (defaults today).
*
* @param int $day Day
@@ -17,8 +8,10 @@
*
* @return int
* @access private
+ * @deprecated 1.9
*/
function get_day_start($day = null, $month = null, $year = null) {
+ elgg_deprecated_notice('get_day_start() has been deprecated', 1.9);
return mktime(0, 0, 0, $month, $day, $year);
}
@@ -31,8 +24,10 @@ function get_day_start($day = null, $month = null, $year = null) {
*
* @return int
* @access private
+ * @deprecated 1.9
*/
function get_day_end($day = null, $month = null, $year = null) {
+ elgg_deprecated_notice('get_day_end() has been deprecated', 1.9);
return mktime(23, 59, 59, $month, $day, $year);
}
@@ -53,10 +48,12 @@ function get_day_end($day = null, $month = null, $year = null) {
*
* @return array|false
* @access private
+ * @deprecated 1.9
*/
function get_notable_entities($start_time, $end_time, $type = "", $subtype = "", $owner_guid = 0,
$order_by = "asc", $limit = 10, $offset = 0, $count = false, $site_guid = 0,
$container_guid = null) {
+ elgg_deprecated_notice('get_notable_entities() has been deprecated', 1.9);
global $CONFIG;
if ($subtype === false || $subtype === null || $subtype === 0) {
@@ -201,10 +198,12 @@ $container_guid = null) {
*
* @return int|array A list of entities, or a count if $count is set to true
* @access private
+ * @deprecated 1.9
*/
function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "",
$entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "",
$site_guid = 0, $count = false) {
+ elgg_deprecated_notice('get_notable_entities_from_metadata() has been deprecated', 1.9);
global $CONFIG;
@@ -331,10 +330,12 @@ $site_guid = 0, $count = false) {
*
* @return array|int|false An array of entities, or the number of entities, or false on failure
* @access private
+ * @deprecated 1.9
*/
function get_noteable_entities_from_relationship($start_time, $end_time, $relationship,
$relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
+ elgg_deprecated_notice('get_noteable_entities_from_relationship() has been deprecated', 1.9);
global $CONFIG;
@@ -441,9 +442,11 @@ $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
*
* @return array|false
* @access private
+ * @deprecated 1.9
*/
function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "",
$limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) {
+ elgg_deprecated_notice('get_todays_entities() has been deprecated', 1.9);
$day_start = get_day_start();
$day_end = get_day_end();
@@ -468,10 +471,12 @@ $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null
*
* @return int|array A list of entities, or a count if $count is set to true
* @access private
+ * @deprecated 1.9
*/
function get_todays_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "",
$entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0,
$count = false) {
+ elgg_deprecated_notice('get_todays_entities_from_metadata() has been deprecated', 1.9);
$day_start = get_day_start();
$day_end = get_day_end();
@@ -499,10 +504,12 @@ $count = false) {
*
* @return array|int|false An array of entities, or the number of entities, or false on failure
* @access private
+ * @deprecated 1.9
*/
function get_todays_entities_from_relationship($relationship, $relationship_guid,
$inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0,
$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
+ elgg_deprecated_notice('get_todays_entities_from_relationship() has been deprecated', 1.9);
$day_start = get_day_start();
$day_end = get_day_end();
@@ -529,9 +536,11 @@ $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
*
* @return string A viewable list of entities
* @access private
+ * @deprecated 1.9
*/
function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0,
$limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
+ elgg_deprecated_notice('list_notable_entities() has been deprecated', 1.9);
$offset = (int) get_input('offset');
$count = get_notable_entities($start_time, $end_time, $type, $subtype,
@@ -559,9 +568,11 @@ $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) {
*
* @return string A viewable list of entities
* @access private
+ * @deprecated 1.9
*/
function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10,
$fullview = true, $listtypetoggle = false, $navigation = true) {
+ elgg_deprecated_notice('list_todays_entities() has been deprecated', 1.9);
$day_start = get_day_start();
$day_end = get_day_end();
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 08b346960..57d602450 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -107,7 +107,10 @@ function elgg_load_library($name) {
}
if (!include_once($CONFIG->libraries[$name])) {
- $error = elgg_echo('InvalidParameterException:LibraryNotRegistered', array($name));
+ $error = elgg_echo('InvalidParameterException:LibraryNotFound', array(
+ $name,
+ $CONFIG->libraries[$name])
+ );
throw new InvalidParameterException($error);
}
}
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index fd2b0e9f9..daced6740 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -124,8 +124,6 @@ function retrieve_cached_entity_row($guid) {
* @internal Subtypes are stored in the entity_subtypes table. There is a foreign
* key in the entities table.
*
- * @todo Move to a nicer place?
- *
* @param string $type Type
* @param string $subtype Subtype
*
@@ -144,7 +142,7 @@ function get_subtype_id($type, $subtype) {
return FALSE;
}
- // Todo: cache here? Or is looping less efficient that going to the db each time?
+ // @todo use the cache before hitting database
$result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes
where type='$type' and subtype='$subtype'");
@@ -163,8 +161,6 @@ function get_subtype_id($type, $subtype) {
/**
* Return string name for a given subtype ID.
*
- * @todo Move to a nicer place?
- *
* @param int $subtype_id Subtype ID
*
* @return string Subtype name
@@ -199,11 +195,11 @@ function get_subtype_from_id($subtype_id) {
}
/**
- * Return a classname for a registered type and subtype.
+ * Return the class name for a registered type and subtype.
*
* Entities can be registered to always be loaded as a certain class
- * with {@link register_entity_subtype()}. This function returns
- * the class name if found, and NULL if not.
+ * with add_subtype() or update_subtype(). This function returns the class
+ * name if found and NULL if not.
*
* @param string $type The type
* @param string $subtype The subtype
@@ -219,7 +215,7 @@ function get_subtype_class($type, $subtype) {
$type = sanitise_string($type);
$subtype = sanitise_string($subtype);
- // Todo: cache here? Or is looping less efficient that going to the db each time?
+ // @todo use the cache before going to the database
$result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes
where type='$type' and subtype='$subtype'");
@@ -236,7 +232,7 @@ function get_subtype_class($type, $subtype) {
}
/**
- * Returns the classname for a subtype id.
+ * Returns the class name for a subtype id.
*
* @param int $subtype_id The subtype id
*
@@ -279,6 +275,9 @@ function get_subtype_class_from_id($subtype_id) {
* it will be loaded as that class automatically when retrieved from the database with
* {@link get_entity()}.
*
+ * @warning This function cannot be used to change the class for a type-subtype pair.
+ * Use update_subtype() for that.
+ *
* @param string $type The type you're subtyping (site, user, object, or group)
* @param string $subtype The subtype
* @param string $class Optional class name for the object
@@ -670,7 +669,10 @@ function get_entity($guid) {
static $newentity_cache;
$new_entity = false;
- if (!is_numeric($guid)) {
+ // We could also use: if (!(int) $guid) { return FALSE },
+ // but that evaluates to a false positive for $guid = TRUE.
+ // This is a bit slower, but more thorough.
+ if (!is_numeric($guid) || $guid === 0 || $guid === '0') {
return FALSE;
}
@@ -1563,7 +1565,7 @@ function delete_entity($guid, $recursive = true) {
}
}
- return $res;
+ return (bool)$res;
}
}
}
@@ -2148,8 +2150,13 @@ function elgg_list_registered_entities(array $options = array()) {
}
}
- $count = elgg_get_entities(array_merge(array('count' => TRUE), $options));
- $entities = elgg_get_entities($options);
+ if (!empty($options['type_subtype_pairs'])) {
+ $count = elgg_get_entities(array_merge(array('count' => TRUE), $options));
+ $entities = elgg_get_entities($options);
+ } else {
+ $count = 0;
+ $entities = array();
+ }
return elgg_view_entity_list($entities, $count, $options['offset'],
$options['limit'], $options['full_view'], $options['list_type_toggle'], $options['pagination']);
diff --git a/engine/lib/languages.php b/engine/lib/languages.php
index 7607ea3bf..0400843af 100644
--- a/engine/lib/languages.php
+++ b/engine/lib/languages.php
@@ -301,4 +301,15 @@ function get_missing_language_keys($language) {
return false;
}
+/**
+ * Initialize the language library
+ * @access private
+ */
+function elgg_languages_init() {
+ $lang = get_current_language();
+ elgg_register_simplecache_view("cache/js/languages/$lang");
+}
+
+elgg_register_event_handler('init', 'system', 'elgg_languages_init');
+
register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/");
diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php
index 9dccec700..9fe9b4bff 100644
--- a/engine/lib/metastrings.php
+++ b/engine/lib/metastrings.php
@@ -810,7 +810,7 @@ function elgg_delete_metastring_based_object_by_id($id, $type) {
}
if (($obj->canEdit()) && (elgg_trigger_event('delete', $type, $obj))) {
- return delete_data("DELETE from $table where id=$id");
+ return (bool)delete_data("DELETE from $table where id=$id");
}
}
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 176790188..956ca220a 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -385,6 +385,55 @@ function elgg_entity_menu_setup($hook, $type, $return, $params) {
}
/**
+ * Widget menu is a set of widget controls
+ * @access private
+ */
+function elgg_widget_menu_setup($hook, $type, $return, $params) {
+
+ $widget = $params['entity'];
+ $show_edit = elgg_extract('show_edit', $params, true);
+
+ $collapse = array(
+ 'name' => 'collapse',
+ 'text' => ' ',
+ 'href' => "#elgg-widget-content-$widget->guid",
+ 'class' => 'elgg-widget-collapse-button',
+ 'rel' => 'toggle',
+ 'priority' => 1
+ );
+ $return[] = ElggMenuItem::factory($collapse);
+
+ if ($widget->canEdit()) {
+ $delete = array(
+ 'name' => 'delete',
+ 'text' => elgg_view_icon('delete-alt'),
+ 'title' => elgg_echo('widget:delete', array($widget->getTitle())),
+ 'href' => "action/widgets/delete?widget_guid=$widget->guid",
+ 'is_action' => true,
+ 'class' => 'elgg-widget-delete-button',
+ 'id' => "elgg-widget-delete-button-$widget->guid",
+ 'priority' => 900
+ );
+ $return[] = ElggMenuItem::factory($delete);
+
+ if ($show_edit) {
+ $edit = array(
+ 'name' => 'settings',
+ 'text' => elgg_view_icon('settings-alt'),
+ 'title' => elgg_echo('widget:edit'),
+ 'href' => "#widget-edit-$widget->guid",
+ 'class' => "elgg-widget-edit-button",
+ 'rel' => 'toggle',
+ 'priority' => 800,
+ );
+ $return[] = ElggMenuItem::factory($edit);
+ }
+ }
+
+ return $return;
+}
+
+/**
* Adds a delete link to "generic_comment" annotations
* @access private
*/
@@ -418,6 +467,7 @@ function elgg_nav_init() {
elgg_register_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup');
elgg_register_plugin_hook_handler('register', 'menu:river', 'elgg_river_menu_setup');
elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_entity_menu_setup');
+ elgg_register_plugin_hook_handler('register', 'menu:widget', 'elgg_widget_menu_setup');
elgg_register_plugin_hook_handler('register', 'menu:annotation', 'elgg_annotation_menu_setup');
}
diff --git a/engine/lib/output.php b/engine/lib/output.php
index 60bcc72cd..6554481f5 100644
--- a/engine/lib/output.php
+++ b/engine/lib/output.php
@@ -234,7 +234,7 @@ function elgg_clean_vars(array $vars = array()) {
*
* @example
* elgg_normalize_url(''); // 'http://my.site.com/'
- * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard'
+ * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard'
* elgg_normalize_url('http://google.com/'); // no change
* elgg_normalize_url('//google.com/'); // no change
*
@@ -257,6 +257,11 @@ function elgg_normalize_url($url) {
$validated = filter_var($url, FILTER_VALIDATE_URL);
}
+ // work around for handling absoluate IRIs (RFC 3987) - see #4190
+ if (!$validated && (strpos($url, 'http:') === 0) || (strpos($url, 'https:') === 0)) {
+ $validated = true;
+ }
+
if ($validated) {
// all normal URLs including mailto:
return $url;
@@ -306,6 +311,9 @@ function elgg_get_friendly_title($title) {
}
//$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title);
+
+ // use A-Za-z0-9_ instead of \w because \w is locale sensitive
+ $title = preg_replace("/[^A-Za-z0-9_ ]/", "", $title);
$title = preg_replace("/[^\w ]/", "", $title);
$title = str_replace(" ", "-", $title);
$title = str_replace("--", "-", $title);
diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php
index aba921416..ffcfc5b6a 100644
--- a/engine/lib/pagehandler.php
+++ b/engine/lib/pagehandler.php
@@ -110,3 +110,36 @@ function elgg_unregister_page_handler($handler) {
unset($CONFIG->pagehandler[$handler]);
}
+
+/**
+ * Serve an error page
+ *
+ * @todo not sending status codes yet
+ *
+ * @param string $hook The name of the hook
+ * @param string $type The type of the hook
+ * @param bool $result The current value of the hook
+ * @param array $params Parameters related to the hook
+ */
+function elgg_error_page_handler($hook, $type, $result, $params) {
+ if (elgg_view_exists("errors/$type")) {
+ $content = elgg_view("errors/$type", $params);
+ } else {
+ $content = elgg_view("errors/default", $params);
+ }
+ $body = elgg_view_layout('error', array('content' => $content));
+ echo elgg_view_page($title, $body, 'error');
+ exit;
+}
+
+/**
+ * Initializes the page handler/routing system
+ *
+ * @return void
+ * @access private
+ */
+function page_handler_init() {
+ elgg_register_plugin_hook_handler('forward', '404', 'elgg_error_page_handler');
+}
+
+elgg_register_event_handler('init', 'system', 'page_handler_init');
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index 3578f0cb8..5b7080b56 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -158,7 +158,7 @@ function remove_entity_relationship($guid_one, $relationship, $guid_two) {
and relationship='$relationship'
and guid_two=$guid_two";
- return delete_data($query);
+ return (bool)delete_data($query);
} else {
return false;
}
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 466eca253..421813441 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -207,6 +207,8 @@ function elgg_delete_river(array $options = array()) {
/**
* Get river items
*
+ * @note If using types and subtypes in a query, they are joined with an AND.
+ *
* @param array $options
* ids => INT|ARR River item id(s)
* subject_guids => INT|ARR Subject guid(s)
@@ -430,7 +432,6 @@ function elgg_river_get_access_sql() {
*
* @internal This is a simplified version of elgg_get_entity_type_subtype_where_sql()
* which could be used for all queries once the subtypes have been denormalized.
- * FYI: It allows types and subtypes to not be paired.
*
* @param string $table 'rv'
* @param NULL|array $types Array of types or NULL if none.
@@ -447,7 +448,8 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
return '';
}
- $wheres = array();
+ $types_wheres = array();
+ $subtypes_wheres = array();
// if no pairs, use types and subtypes
if (!is_array($pairs)) {
@@ -457,7 +459,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($types as $type) {
$type = sanitise_string($type);
- $wheres[] = "({$table}.type = '$type')";
+ $types_wheres[] = "({$table}.type = '$type')";
}
}
@@ -467,13 +469,20 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs
}
foreach ($subtypes as $subtype) {
$subtype = sanitise_string($subtype);
- $wheres[] = "({$table}.subtype = '$subtype')";
+ $subtypes_wheres[] = "({$table}.subtype = '$subtype')";
}
}
- if (is_array($wheres) && count($wheres)) {
- $wheres = array(implode(' OR ', $wheres));
+ if (is_array($types_wheres) && count($types_wheres)) {
+ $types_wheres = array(implode(' OR ', $types_wheres));
+ }
+
+ if (is_array($subtypes_wheres) && count($subtypes_wheres)) {
+ $subtypes_wheres = array('(' . implode(' OR ', $subtypes_wheres) . ')');
}
+
+ $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres)));
+
} else {
// using type/subtype pairs
foreach ($pairs as $paired_type => $paired_subtypes) {
@@ -611,6 +620,16 @@ function elgg_river_page_handler($page) {
}
/**
+ * Register river unit tests
+ * @access private
+ */
+function elgg_river_test($hook, $type, $value) {
+ global $CONFIG;
+ $value[] = $CONFIG->path . 'engine/tests/api/river.php';
+ return $value;
+}
+
+/**
* Initialize river library
* @access private
*/
@@ -620,6 +639,8 @@ function elgg_river_init() {
elgg_register_menu_item('site', $item);
elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description'));
+
+ elgg_register_plugin_hook_handler('unit_test', 'system', 'elgg_river_test');
}
elgg_register_event_handler('init', 'system', 'elgg_river_init');
diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php
index 1e2d6db10..af30d8f0d 100644
--- a/engine/lib/user_settings.php
+++ b/engine/lib/user_settings.php
@@ -265,8 +265,8 @@ function elgg_set_user_default_access() {
* @access private
*/
function usersettings_pagesetup() {
- if (elgg_get_context() == "settings" && elgg_get_logged_in_user_guid()) {
- $user = elgg_get_logged_in_user_entity();
+ if (elgg_get_context() == "settings") {
+ $user = elgg_get_page_owner_entity();
$params = array(
'name' => '1_account',
@@ -346,6 +346,13 @@ function usersettings_init() {
elgg_register_plugin_hook_handler('usersettings:save', 'user', 'users_settings_save');
elgg_register_action("usersettings/save");
+
+ // extend the account settings form
+ elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100);
+ elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100);
+ elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100);
+ elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100);
+ elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100);
}
elgg_register_event_handler('init', 'system', 'usersettings_init');
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 9cb8ddfa7..1b3cca799 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -565,6 +565,8 @@ function get_user_by_username($username) {
$entity = get_data_row($query, 'entity_row_to_elggstar');
if ($entity) {
$USERNAME_TO_GUID_MAP_CACHE[$username] = $entity->guid;
+ } else {
+ $entity = false;
}
return $entity;
@@ -1019,7 +1021,7 @@ function elgg_get_user_validation_status($user_guid) {
return;
}
- if ($md->value) {
+ if ($md[0]->value) {
return true;
}
@@ -1281,6 +1283,11 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
$item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('admin');
$return[] = $item;
+
+ $url = "settings/user/$user->username";
+ $item = new ElggMenuItem('settings:edit', elgg_echo('settings:edit'), $url);
+ $item->setSection('admin');
+ $return[] = $item;
}
return $return;
@@ -1555,13 +1562,6 @@ function users_init() {
elgg_register_widget_type('friends', elgg_echo('friends'), elgg_echo('friends:widget:description'));
- // extend the account settings form
- elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100);
- elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100);
- elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100);
- elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100);
- elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100);
-
// Register the user type
elgg_register_entity_type('user', '');
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 0f806b8be..b938dd60e 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1598,10 +1598,10 @@ function elgg_views_boot() {
elgg_load_js('jquery');
elgg_load_js('jquery-ui');
- elgg_load_js('jquery.form');
elgg_load_js('elgg');
elgg_register_simplecache_view('js/lightbox');
+ elgg_register_simplecache_view('css/lightbox');
$lightbox_js_url = elgg_get_simplecache_url('js', 'lightbox');
elgg_register_js('lightbox', $lightbox_js_url);
$lightbox_css_url = elgg_get_simplecache_url('css', 'lightbox');
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 5d18a16b0..46f34391a 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -332,14 +332,14 @@ function elgg_default_widgets_init() {
* @param string $event The event
* @param string $type The type of object
* @param object $entity The entity being created
- * @return null
+ * @return void
* @access private
*/
function elgg_create_default_widgets($event, $type, $entity) {
$default_widget_info = elgg_get_config('default_widget_info');
if (!$default_widget_info || !$entity) {
- return null;
+ return;
}
$type = $entity->getType();
@@ -347,53 +347,48 @@ function elgg_create_default_widgets($event, $type, $entity) {
// event is already guaranteed by the hook registration.
// need to check subtype and type.
- foreach ($default_widget_info as $temp) {
- if ($temp['entity_type'] == $type) {
- if ($temp['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $temp['entity_subtype'] == $subtype) {
- $info = $temp;
- break;
+ foreach ($default_widget_info as $info) {
+ if ($info['entity_type'] == $type) {
+ if ($info['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $info['entity_subtype'] == $subtype) {
+
+ // need to be able to access everything
+ $old_ia = elgg_set_ignore_access(true);
+ elgg_push_context('create_default_widgets');
+
+ // pull in by widget context with widget owners as the site
+ // not using elgg_get_widgets() because it sorts by columns and we don't care right now.
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'widget',
+ 'owner_guid' => elgg_get_site_entity()->guid,
+ 'private_setting_name' => 'context',
+ 'private_setting_value' => $info['widget_context'],
+ 'limit' => 0
+ );
+
+ $widgets = elgg_get_entities_from_private_settings($options);
+
+ foreach ($widgets as $widget) {
+ // change the container and owner
+ $new_widget = clone $widget;
+ $new_widget->container_guid = $entity->guid;
+ $new_widget->owner_guid = $entity->guid;
+
+ // pull in settings
+ $settings = get_all_private_settings($widget->guid);
+
+ foreach ($settings as $name => $value) {
+ $new_widget->$name = $value;
+ }
+
+ $new_widget->save();
+ }
+
+ elgg_set_ignore_access($old_ia);
+ elgg_pop_context();
}
}
}
-
- // need to be able to access everything
- $old_ia = elgg_get_ignore_access(true);
- elgg_push_context('create_default_widgets');
-
- // pull in by widget context with widget owners as the site
- // not using elgg_get_widgets() because it sorts by columns and we don't care right now.
- $options = array(
- 'type' => 'object',
- 'subtype' => 'widget',
- 'owner_guid' => elgg_get_site_entity()->guid,
- 'private_setting_name' => 'context',
- 'private_setting_value' => $info['widget_context'],
- 'limit' => 0
- );
-
- $widgets = elgg_get_entities_from_private_settings($options);
-
- foreach ($widgets as $widget) {
- // change the container and owner
- $new_widget = clone $widget;
- $new_widget->container_guid = $entity->guid;
- $new_widget->owner_guid = $entity->guid;
-
- // pull in settings
- $settings = get_all_private_settings($widget->guid);
-
- foreach ($settings as $name => $value) {
- $new_widget->$name = $value;
- }
-
- $new_widget->save();
- }
-
- elgg_get_ignore_access($old_ia);
- elgg_pop_context();
-
- // failure here shouldn't stop the event.
- return null;
}
/**
diff --git a/engine/lib/xml-rpc.php b/engine/lib/xml-rpc.php
deleted file mode 100644
index bfe1a8645..000000000
--- a/engine/lib/xml-rpc.php
+++ /dev/null
@@ -1,203 +0,0 @@
-<?php
-/**
- * Elgg XML-RPC library.
- * Contains functions and classes to handle XML-RPC services, currently only server only.
- *
- * @package Elgg.Core
- * @subpackage XMLRPC
- */
-
-/**
- * parse XMLRPCCall parameters
- *
- * Convert an XMLRPCCall result array into native data types
- *
- * @param array $parameters An array of params
- *
- * @return array
- * @access private
- */
-function xmlrpc_parse_params($parameters) {
- $result = array();
-
- foreach ($parameters as $parameter) {
- $result[] = xmlrpc_scalar_value($parameter);
- }
-
- return $result;
-}
-
-/**
- * Extract the scalar value of an XMLObject type result array
- *
- * @param XMLObject $object And object
- *
- * @return mixed
- * @access private
- */
-function xmlrpc_scalar_value($object) {
- if ($object->name == 'param') {
- $object = $object->children[0]->children[0];
- }
-
- switch ($object->name) {
- case 'string':
- return $object->content;
-
- case 'array':
- foreach ($object->children[0]->children as $child) {
- $value[] = xmlrpc_scalar_value($child);
- }
- return $value;
-
- case 'struct':
- foreach ($object->children as $child) {
- if (isset($child->children[1]->children[0])) {
- $value[$child->children[0]->content] = xmlrpc_scalar_value($child->children[1]->children[0]);
- } else {
- $value[$child->children[0]->content] = $child->children[1]->content;
- }
- }
- return $value;
-
- case 'boolean':
- return (boolean) $object->content;
-
- case 'i4':
- case 'int':
- return (int) $object->content;
-
- case 'double':
- return (double) $object->content;
-
- case 'dateTime.iso8601':
- return (int) strtotime($object->content);
-
- case 'base64':
- return base64_decode($object->content);
-
- case 'value':
- return xmlrpc_scalar_value($object->children[0]);
-
- default:
- // @todo unsupported, throw an error
- return false;
- }
-}
-
-// Functions for adding handlers //////////////////////////////////////////////////////////
-
-/** XML-RPC Handlers */
-global $XML_RPC_HANDLERS;
-$XML_RPC_HANDLERS = array();
-
-/**
- * Register a method handler for a given XML-RPC method.
- *
- * @param string $method Method parameter.
- * @param string $handler The handler function. This function accepts
- * one XMLRPCCall object and must return a XMLRPCResponse object.
- *
- * @return bool
- */
-function register_xmlrpc_handler($method, $handler) {
- global $XML_RPC_HANDLERS;
-
- $XML_RPC_HANDLERS[$method] = $handler;
-}
-
-/**
- * Trigger a method call and pass the relevant parameters to the funciton.
- *
- * @param XMLRPCCall $parameters The call and parameters.
- *
- * @return XMLRPCCall
- * @access private
- */
-function trigger_xmlrpc_handler(XMLRPCCall $parameters) {
- global $XML_RPC_HANDLERS;
-
- // Go through and see if we have a handler
- if (isset($XML_RPC_HANDLERS[$parameters->getMethodName()])) {
- $handler = $XML_RPC_HANDLERS[$parameters->getMethodName()];
- $result = $handler($parameters);
-
- if (!($result instanceof XMLRPCResponse)) {
- $msg = elgg_echo('InvalidParameterException:UnexpectedReturnFormat',
- array($parameters->getMethodName()));
- throw new InvalidParameterException($msg);
- }
-
- // Result in right format, return it.
- return $result;
- }
-
- // if no handler then throw exception
- $msg = elgg_echo('NotImplementedException:XMLRPCMethodNotImplemented',
- array($parameters->getMethodName()));
- throw new NotImplementedException($msg);
-}
-
-/**
- * PHP Error handler function.
- * This function acts as a wrapper to catch and report PHP error messages.
- *
- * @see http://uk3.php.net/set-error-handler
- *
- * @param int $errno Error number
- * @param string $errmsg Human readable message
- * @param string $filename Filename
- * @param int $linenum Line number
- * @param array $vars Vars
- *
- * @return void
- * @access private
- */
-function _php_xmlrpc_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
- $error = date("Y-m-d H:i:s (T)") . ": \"" . $errmsg . "\" in file "
- . $filename . " (line " . $linenum . ")";
-
- switch ($errno) {
- case E_USER_ERROR:
- error_log("ERROR: " . $error);
-
- // Since this is a fatal error, we want to stop any further execution but do so gracefully.
- throw new Exception("ERROR: " . $error);
- break;
-
- case E_WARNING :
- case E_USER_WARNING :
- error_log("WARNING: " . $error);
- break;
-
- default:
- error_log("DEBUG: " . $error);
- }
-}
-
-/**
- * PHP Exception handler for XMLRPC.
- *
- * @param Exception $exception The exception
- *
- * @return void
- * @access private
- */
-function _php_xmlrpc_exception_handler($exception) {
-
- error_log("*** FATAL EXCEPTION (XML-RPC) *** : " . $exception);
-
- $code = $exception->getCode();
-
- if ($code == 0) {
- $code = -32400;
- }
-
- $result = new XMLRPCErrorResponse($exception->getMessage(), $code);
-
- $vars = array('result' => $result);
-
- $content = elgg_view("xml-rpc/output", $vars);
-
- echo elgg_view_page($exception->getMessage(), $content);
-}
diff --git a/engine/start.php b/engine/start.php
index 00bdc3197..1decc5d80 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -92,7 +92,7 @@ $lib_files = array(
// these need to be loaded first.
'database.php', 'actions.php',
- 'admin.php', 'annotations.php', 'calendar.php',
+ 'admin.php', 'annotations.php',
'configuration.php', 'cron.php', 'entities.php', 'export.php',
'extender.php', 'filestore.php', 'group.php',
'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php',
@@ -100,10 +100,10 @@ $lib_files = array(
'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',
+ 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php',
- //backwards compatibility
- 'deprecated-1.7.php', 'deprecated-1.8.php',
+ // backward compatibility
+ 'deprecated-1.7.php', 'deprecated-1.8.php', 'deprecated-1.9.php'
);
foreach ($lib_files as $file) {
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 a0faaff0e..8ecb0a46c 100644
--- a/engine/tests/api/plugins.php
+++ b/engine/tests/api/plugins.php
@@ -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() {
@@ -123,7 +124,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
'name' => 'Plugin Test 17',
);
- $this->assertEqual($this->manifest17->getManifest(), $manifest_array);
+ $this->assertIdentical($this->manifest17->getManifest(), $manifest_array);
}
@@ -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/api/river.php b/engine/tests/api/river.php
new file mode 100644
index 000000000..6931b9f41
--- /dev/null
+++ b/engine/tests/api/river.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Elgg Test river api
+ *
+ * @package Elgg
+ * @subpackage Test
+ */
+class ElggCoreRiverAPITest extends ElggCoreUnitTest {
+
+ public function testElggTypeSubtypeWhereSQL() {
+ $types = array('object');
+ $subtypes = array('blog');
+ $result = elgg_get_river_type_subtype_where_sql('rv', $types, $subtypes, null);
+ $this->assertIdentical($result, "((rv.type = 'object') AND ((rv.subtype = 'blog')))");
+
+ $types = array('object');
+ $subtypes = array('blog', 'file');
+ $result = elgg_get_river_type_subtype_where_sql('rv', $types, $subtypes, null);
+ $this->assertIdentical($result, "((rv.type = 'object') AND ((rv.subtype = 'blog') OR (rv.subtype = 'file')))");
+ }
+}
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/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php
index 2bfc37558..99cf81774 100644
--- a/engine/tests/regression/trac_bugs.php
+++ b/engine/tests/regression/trac_bugs.php
@@ -45,7 +45,7 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest {
/**
* #1558
*/
- public function testElggObjectClearAnnotations() {
+ public function testElggObjectDeleteAnnotations() {
$this->entity = new ElggObject();
$guid = $this->entity->save();
diff --git a/engine/tests/test_files/plugin_18/manifest.xml b/engine/tests/test_files/plugin_18/manifest.xml
index e0776ffc1..9654b6422 100644
--- a/engine/tests/test_files/plugin_18/manifest.xml
+++ b/engine/tests/test_files/plugin_18/manifest.xml
@@ -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);
}