From 059aa2db0dd5af4a1b35253b2c136813f86c3ca5 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 20 Nov 2011 08:13:34 -0500 Subject: Fixes #4140 fixed spelling mistake --- install/languages/en.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'install') diff --git a/install/languages/en.php b/install/languages/en.php index 3e2569669..bbcd72d20 100644 --- a/install/languages/en.php +++ b/install/languages/en.php @@ -64,7 +64,7 @@ If you are ready to proceed, click the Next button.", 'install:database:label:dbhost' => 'Database Host', 'install:database:label:dbprefix' => 'Database Table Prefix', - 'install:database:help:dbuser' => 'User that has full priviledges to the MySQL database that you created for Elgg', + 'install:database:help:dbuser' => 'User that has full privileges to the MySQL database that you created for Elgg', 'install:database:help:dbpassword' => 'Password for the above database user account', 'install:database:help:dbname' => 'Name of the Elgg database', 'install:database:help:dbhost' => 'Hostname of the MySQL server (usually localhost)', -- cgit v1.2.3 From dfaa80f0a44afe6faed0212e61c3edef48afc64d Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 14 Dec 2011 20:02:25 -0500 Subject: Fixes #3341 removed xml-rpc code from Elgg - see xml-rpc plugin if you need an xml-rpc endpoint --- engine/classes/ElggSite.php | 2 - engine/classes/XMLRPCArrayParameter.php | 56 --------- engine/classes/XMLRPCBase64Parameter.php | 28 ----- engine/classes/XMLRPCBoolParameter.php | 30 ----- engine/classes/XMLRPCCall.php | 62 ---------- engine/classes/XMLRPCDateParameter.php | 33 ----- engine/classes/XMLRPCDoubleParameter.php | 29 ----- engine/classes/XMLRPCErrorResponse.php | 36 ------ engine/classes/XMLRPCIntParameter.php | 29 ----- engine/classes/XMLRPCParameter.php | 16 --- engine/classes/XMLRPCResponse.php | 71 ----------- engine/classes/XMLRPCStringParameter.php | 30 ----- engine/classes/XMLRPCStructParameter.php | 55 --------- engine/classes/XMLRPCSuccessResponse.php | 22 ---- engine/handlers/page_handler.php | 8 +- engine/handlers/xml-rpc_handler.php | 44 ------- engine/lib/xml-rpc.php | 203 ------------------------------- engine/start.php | 2 +- htaccess_dist | 3 - install/ElggInstaller.php | 2 +- languages/en.php | 9 -- views/xml/xml-rpc/output.php | 11 -- 22 files changed, 8 insertions(+), 773 deletions(-) delete mode 100644 engine/classes/XMLRPCArrayParameter.php delete mode 100644 engine/classes/XMLRPCBase64Parameter.php delete mode 100644 engine/classes/XMLRPCBoolParameter.php delete mode 100644 engine/classes/XMLRPCCall.php delete mode 100644 engine/classes/XMLRPCDateParameter.php delete mode 100644 engine/classes/XMLRPCDoubleParameter.php delete mode 100644 engine/classes/XMLRPCErrorResponse.php delete mode 100644 engine/classes/XMLRPCIntParameter.php delete mode 100644 engine/classes/XMLRPCParameter.php delete mode 100644 engine/classes/XMLRPCResponse.php delete mode 100644 engine/classes/XMLRPCStringParameter.php delete mode 100644 engine/classes/XMLRPCStructParameter.php delete mode 100644 engine/classes/XMLRPCSuccessResponse.php delete mode 100644 engine/handlers/xml-rpc_handler.php delete mode 100644 engine/lib/xml-rpc.php delete mode 100644 views/xml/xml-rpc/output.php (limited to 'install') diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index 5c44d4076..0d03cbd28 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -421,8 +421,6 @@ class ElggSite extends ElggEntity { 'action/security/refreshtoken', 'ajax/view/js/languages', 'upgrade\.php', - 'xml-rpc\.php', - 'mt/mt-xmlrpc\.cgi', 'css/.*', 'js/.*' ); 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 @@ -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 "$params"; - } -} 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 @@ -value = base64_encode($blob); - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "{$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 @@ -value = (bool)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - $code = ($this->value) ? "1" : "0"; - return "{$code}"; - } -} 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 @@ -_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 @@ -value = $timestamp; - - if (!$timestamp) { - $this->value = time(); - } - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - $value = date('c', $this->value); - return "{$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 @@ -value = (float)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "{$this->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 @@ -addParameter( - new XMLRPCStructParameter( - array ( - 'faultCode' => new XMLRPCIntParameter($code), - 'faultString' => new XMLRPCStringParameter($message) - ) - ) - ); - } - - /** - * Output to XML. - * - * @return string - */ - public function __toString() { - return "{$this->parameters[0]}"; - } -} 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 @@ -value = (int)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "{$this->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 @@ -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 @@ -value = $value; - } - - /** - * Convert to XML string - * - * @return string - */ - function __toString() { - $value = htmlentities($this->value); - return "{$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 @@ - $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 .= "$k$v"; - } - - return "$params"; - } -} 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 @@ -parameters as $param) { - $params .= "$param\n"; - } - - return "$params"; - } -} 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 @@ - $result))); 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 @@ -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..454dc7377 100644 --- a/engine/start.php +++ b/engine/start.php @@ -100,7 +100,7 @@ $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', diff --git a/htaccess_dist b/htaccess_dist index 526299b94..88285f81b 100644 --- a/htaccess_dist +++ b/htaccess_dist @@ -115,9 +115,6 @@ RewriteRule ^services\/api\/([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/service_ha RewriteRule ^export\/([A-Za-z]+)\/([0-9]+)\/?$ engine/handlers/export_handler.php?view=$1&guid=$2 RewriteRule ^export\/([A-Za-z]+)\/([0-9]+)\/([A-Za-z]+)\/([A-Za-z0-9\_]+)\/$ engine/handlers/export_handler.php?view=$1&guid=$2&type=$3&idname=$4 -RewriteRule xml-rpc.php engine/handlers/xml-rpc_handler.php -RewriteRule mt/mt-xmlrpc.cgi engine/handlers/xml-rpc_handler.php - # rule for rewrite module test during install - can be removed after installation RewriteRule ^rewrite.php$ install.php diff --git a/install/ElggInstaller.php b/install/ElggInstaller.php index d556ba744..367d23b4d 100644 --- a/install/ElggInstaller.php +++ b/install/ElggInstaller.php @@ -790,7 +790,7 @@ class ElggInstaller { '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', 'deprecated-1.7.php', + 'widgets.php', 'xml.php', 'deprecated-1.7.php', 'deprecated-1.8.php', ); diff --git a/languages/en.php b/languages/en.php index 036ca8883..17587b178 100644 --- a/languages/en.php +++ b/languages/en.php @@ -208,10 +208,6 @@ $english = array( 'SecurityException:InvalidAPIKey' => "Invalid or missing API Key.", 'NotImplementedException:CallMethodNotImplemented' => "Call method '%s' is currently not supported.", - 'NotImplementedException:XMLRPCMethodNotImplemented' => "XML-RPC method call '%s' not implemented.", - 'InvalidParameterException:UnexpectedReturnFormat' => "Call to method '%s' returned an unexpected result.", - 'CallException:NotRPCCall' => "Call does not appear to be a valid XML-RPC call", - 'PluginException:NoPluginName' => "The plugin name could not be found", 'SecurityException:authenticationfailed' => "User could not be authenticated", @@ -1079,11 +1075,6 @@ If you requested this, click on the link below. Otherwise ignore this email. 'user:default_access:success' => "Your new default access level was saved.", 'user:default_access:failure' => "Your new default access level could not be saved.", -/** - * XML-RPC - */ - 'xmlrpc:noinputdata' => "Input data missing", - /** * Comments */ diff --git a/views/xml/xml-rpc/output.php b/views/xml/xml-rpc/output.php deleted file mode 100644 index 4276029d1..000000000 --- a/views/xml/xml-rpc/output.php +++ /dev/null @@ -1,11 +0,0 @@ - Date: Tue, 20 Dec 2011 07:32:11 -0500 Subject: Fixes #4211 removes calendar library --- engine/lib/calendar.php | 571 ----------------------------------------- engine/lib/deprecated-1.9.php | 582 ++++++++++++++++++++++++++++++++++++++++++ engine/start.php | 6 +- install/ElggInstaller.php | 4 +- 4 files changed, 587 insertions(+), 576 deletions(-) delete mode 100644 engine/lib/calendar.php create mode 100644 engine/lib/deprecated-1.9.php (limited to 'install') diff --git a/engine/lib/calendar.php b/engine/lib/calendar.php deleted file mode 100644 index 9a06c5292..000000000 --- a/engine/lib/calendar.php +++ /dev/null @@ -1,571 +0,0 @@ -site_guid; - } - - $where = array(); - - if (is_array($type)) { - $tempwhere = ""; - if (sizeof($type)) { - foreach ($type as $typekey => $subtypearray) { - foreach ($subtypearray as $subtypeval) { - $typekey = sanitise_string($typekey); - if (!empty($subtypeval)) { - $subtypeval = (int) get_subtype_id($typekey, $subtypeval); - } else { - $subtypeval = 0; - } - if (!empty($tempwhere)) { - $tempwhere .= " or "; - } - $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})"; - } - } - } - if (!empty($tempwhere)) { - $where[] = "({$tempwhere})"; - } - } else { - $type = sanitise_string($type); - $subtype = get_subtype_id($type, $subtype); - - if ($type != "") { - $where[] = "e.type='$type'"; - } - - if ($subtype !== "") { - $where[] = "e.subtype=$subtype"; - } - } - - if ($owner_guid != "") { - if (!is_array($owner_guid)) { - $owner_array = array($owner_guid); - $owner_guid = (int) $owner_guid; - $where[] = "e.owner_guid = '$owner_guid'"; - } else if (sizeof($owner_guid) > 0) { - $owner_array = array_map('sanitise_int', $owner_guid); - // Cast every element to the owner_guid array to int - $owner_guid = implode(",", $owner_guid); - $where[] = "e.owner_guid in ({$owner_guid})"; - } - if (is_null($container_guid)) { - $container_guid = $owner_array; - } - } - - if ($site_guid > 0) { - $where[] = "e.site_guid = {$site_guid}"; - } - - if (!is_null($container_guid)) { - if (is_array($container_guid)) { - foreach ($container_guid as $key => $val) { - $container_guid[$key] = (int) $val; - } - $where[] = "e.container_guid in (" . implode(",", $container_guid) . ")"; - } else { - $container_guid = (int) $container_guid; - $where[] = "e.container_guid = {$container_guid}"; - } - } - - // Add the calendar stuff - $cal_join = " - JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id - - JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id - "; - $where[] = "cal_start_name.string='calendar_start'"; - $where[] = "cal_start_value.string>=$start_time"; - $where[] = "cal_end_name.string='calendar_end'"; - $where[] = "cal_end_value.string <= $end_time"; - - - if (!$count) { - $query = "SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where "; - } else { - $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where "; - } - foreach ($where as $w) { - $query .= " $w and "; - } - - $query .= get_access_sql_suffix('e'); // Add access controls - - if (!$count) { - $query .= " order by n.calendar_start $order_by"; - // Add order and limit - if ($limit) { - $query .= " limit $offset, $limit"; - } - $dt = get_data($query, "entity_row_to_elggstar"); - - return $dt; - } else { - $total = get_data_row($query); - return $total->total; - } -} - -/** - * Return the notable entities for a given time period based on an item of metadata. - * - * @param int $start_time The start time as a unix timestamp. - * @param int $end_time The end time as a unix timestamp. - * @param mixed $meta_name Metadata name - * @param mixed $meta_value Metadata value - * @param string $entity_type The type of entity to look for, eg 'site' or 'object' - * @param string $entity_subtype The subtype of the entity. - * @param int $owner_guid Owner GUID - * @param int $limit Limit - * @param int $offset Offset - * @param string $order_by Optional ordering. - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any. - * @param bool $count If true, returns count instead of entities. (Default: false) - * - * @return int|array A list of entities, or a count if $count is set to true - * @access private - */ -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) { - - global $CONFIG; - - $meta_n = get_metastring_id($meta_name); - $meta_v = get_metastring_id($meta_value); - - $start_time = (int)$start_time; - $end_time = (int)$end_time; - $entity_type = sanitise_string($entity_type); - $entity_subtype = get_subtype_id($entity_type, $entity_subtype); - $limit = (int)$limit; - $offset = (int)$offset; - if ($order_by == "") { - $order_by = "e.time_created desc"; - } - $order_by = sanitise_string($order_by); - $site_guid = (int) $site_guid; - if ((is_array($owner_guid) && (count($owner_guid)))) { - foreach ($owner_guid as $key => $guid) { - $owner_guid[$key] = (int) $guid; - } - } else { - $owner_guid = (int) $owner_guid; - } - - if ($site_guid == 0) { - $site_guid = $CONFIG->site_guid; - } - - //$access = get_access_list(); - - $where = array(); - - if ($entity_type != "") { - $where[] = "e.type='$entity_type'"; - } - - if ($entity_subtype) { - $where[] = "e.subtype=$entity_subtype"; - } - - if ($meta_name != "") { - $where[] = "m.name_id='$meta_n'"; - } - - if ($meta_value != "") { - $where[] = "m.value_id='$meta_v'"; - } - - if ($site_guid > 0) { - $where[] = "e.site_guid = {$site_guid}"; - } - - if (is_array($owner_guid)) { - $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")"; - } else if ($owner_guid > 0) { - $where[] = "e.container_guid = {$owner_guid}"; - } - - // Add the calendar stuff - $cal_join = " - JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id - - JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id - "; - - $where[] = "cal_start_name.string='calendar_start'"; - $where[] = "cal_start_value.string>=$start_time"; - $where[] = "cal_end_name.string='calendar_end'"; - $where[] = "cal_end_value.string <= $end_time"; - - if (!$count) { - $query = "SELECT distinct e.* "; - } else { - $query = "SELECT count(distinct e.guid) as total "; - } - - $query .= "from {$CONFIG->dbprefix}entities e" - . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where"; - - foreach ($where as $w) { - $query .= " $w and "; - } - - // Add access controls - $query .= get_access_sql_suffix("e"); - $query .= ' and ' . get_access_sql_suffix("m"); - - if (!$count) { - // Add order and limit - $query .= " order by $order_by limit $offset, $limit"; - return get_data($query, "entity_row_to_elggstar"); - } else { - if ($row = get_data_row($query)) { - return $row->total; - } - } - - return false; -} - -/** - * Return the notable entities for a given time period based on their relationship. - * - * @param int $start_time The start time as a unix timestamp. - * @param int $end_time The end time as a unix timestamp. - * @param string $relationship The relationship eg "friends_of" - * @param int $relationship_guid The guid of the entity to use query - * @param bool $inverse_relationship Reverse the normal function of the query to say - * "give me all entities for whom $relationship_guid is a - * $relationship of" - * @param string $type Entity type - * @param string $subtype Entity subtype - * @param int $owner_guid Owner GUID - * @param string $order_by Optional Order by - * @param int $limit Limit - * @param int $offset Offset - * @param boolean $count If true returns a count of entities (default false) - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any - * - * @return array|int|false An array of entities, or the number of entities, or false on failure - * @access private - */ -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) { - - global $CONFIG; - - $start_time = (int)$start_time; - $end_time = (int)$end_time; - $relationship = sanitise_string($relationship); - $relationship_guid = (int)$relationship_guid; - $inverse_relationship = (bool)$inverse_relationship; - $type = sanitise_string($type); - $subtype = get_subtype_id($type, $subtype); - $owner_guid = (int)$owner_guid; - if ($order_by == "") { - $order_by = "time_created desc"; - } - $order_by = sanitise_string($order_by); - $limit = (int)$limit; - $offset = (int)$offset; - $site_guid = (int) $site_guid; - if ($site_guid == 0) { - $site_guid = $CONFIG->site_guid; - } - - //$access = get_access_list(); - - $where = array(); - - if ($relationship != "") { - $where[] = "r.relationship='$relationship'"; - } - if ($relationship_guid) { - $where[] = $inverse_relationship ? - "r.guid_two='$relationship_guid'" : "r.guid_one='$relationship_guid'"; - } - if ($type != "") { - $where[] = "e.type='$type'"; - } - if ($subtype) { - $where[] = "e.subtype=$subtype"; - } - if ($owner_guid != "") { - $where[] = "e.container_guid='$owner_guid'"; - } - if ($site_guid > 0) { - $where[] = "e.site_guid = {$site_guid}"; - } - - // Add the calendar stuff - $cal_join = " - JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id - - JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id - "; - $where[] = "cal_start_name.string='calendar_start'"; - $where[] = "cal_start_value.string>=$start_time"; - $where[] = "cal_end_name.string='calendar_end'"; - $where[] = "cal_end_value.string <= $end_time"; - - // Select what we're joining based on the options - $joinon = "e.guid = r.guid_one"; - if (!$inverse_relationship) { - $joinon = "e.guid = r.guid_two"; - } - - if ($count) { - $query = "SELECT count(distinct e.guid) as total "; - } else { - $query = "SELECT distinct e.* "; - } - $query .= " from {$CONFIG->dbprefix}entity_relationships r" - . " JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where "; - - foreach ($where as $w) { - $query .= " $w and "; - } - // Add access controls - $query .= get_access_sql_suffix("e"); - if (!$count) { - $query .= " order by $order_by limit $offset, $limit"; // Add order and limit - return get_data($query, "entity_row_to_elggstar"); - } else { - if ($count = get_data_row($query)) { - return $count->total; - } - } - return false; -} - -/** - * Get all entities for today. - * - * @param string $type The type of entity (eg "user", "object" etc) - * @param string $subtype The arbitrary subtype of the entity - * @param int $owner_guid The GUID of the owning user - * @param string $order_by The field to order by; by default, time_created desc - * @param int $limit The number of entities to return; 10 by default - * @param int $offset The indexing offset, 0 by default - * @param boolean $count If true returns a count of entities (default false) - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any - * @param mixed $container_guid Container(s) to get entities from (default: any). - * - * @return array|false - * @access private - */ -function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", -$limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) { - - $day_start = get_day_start(); - $day_end = get_day_end(); - - return get_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $order_by, - $limit, $offset, $count, $site_guid, $container_guid); -} - -/** - * Get entities for today from metadata. - * - * @param mixed $meta_name Metadata name - * @param mixed $meta_value Metadata value - * @param string $entity_type The type of entity to look for, eg 'site' or 'object' - * @param string $entity_subtype The subtype of the entity. - * @param int $owner_guid Owner GUID - * @param int $limit Limit - * @param int $offset Offset - * @param string $order_by Optional ordering. - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any. - * @param bool $count If true, returns count instead of entities. (Default: false) - * - * @return int|array A list of entities, or a count if $count is set to true - * @access private - */ -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) { - - $day_start = get_day_start(); - $day_end = get_day_end(); - - return get_notable_entities_from_metadata($day_start, $day_end, $meta_name, $meta_value, - $entity_type, $entity_subtype, $owner_guid, $limit, $offset, $order_by, $site_guid, $count); -} - -/** - * Get entities for today from a relationship - * - * @param string $relationship The relationship eg "friends_of" - * @param int $relationship_guid The guid of the entity to use query - * @param bool $inverse_relationship Reverse the normal function of the query to say - * "give me all entities for whom $relationship_guid is a - * $relationship of" - * @param string $type Entity type - * @param string $subtype Entity subtype - * @param int $owner_guid Owner GUID - * @param string $order_by Optional Order by - * @param int $limit Limit - * @param int $offset Offset - * @param boolean $count If true returns a count of entities (default false) - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any - * - * @return array|int|false An array of entities, or the number of entities, or false on failure - * @access private - */ -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) { - - $day_start = get_day_start(); - $day_end = get_day_end(); - - return get_notable_entities_from_relationship($day_start, $day_end, $relationship, - $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, $order_by, - $limit, $offset, $count, $site_guid); -} - -/** - * Returns a viewable list of entities for a given time period. - * - * @see elgg_view_entity_list - * - * @param int $start_time The start time as a unix timestamp. - * @param int $end_time The end time as a unix timestamp. - * @param string $type The type of entity (eg "user", "object" etc) - * @param string $subtype The arbitrary subtype of the entity - * @param int $owner_guid The GUID of the owning user - * @param int $limit The number of entities to return; 10 by default - * @param boolean $fullview Whether or not to display the full view (default: true) - * @param boolean $listtypetoggle Whether or not to allow gallery view - * @param boolean $navigation Display pagination? Default: true - * - * @return string A viewable list of entities - * @access private - */ -function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0, -$limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) { - - $offset = (int) get_input('offset'); - $count = get_notable_entities($start_time, $end_time, $type, $subtype, - $owner_guid, "", $limit, $offset, true); - - $entities = get_notable_entities($start_time, $end_time, $type, $subtype, - $owner_guid, "", $limit, $offset); - - return elgg_view_entity_list($entities, $count, $offset, $limit, - $fullview, $listtypetoggle, $navigation); -} - -/** - * Return a list of today's entities. - * - * @see list_notable_entities - * - * @param string $type The type of entity (eg "user", "object" etc) - * @param string $subtype The arbitrary subtype of the entity - * @param int $owner_guid The GUID of the owning user - * @param int $limit The number of entities to return; 10 by default - * @param boolean $fullview Whether or not to display the full view (default: true) - * @param boolean $listtypetoggle Whether or not to allow gallery view - * @param boolean $navigation Display pagination? Default: true - * - * @return string A viewable list of entities - * @access private - */ -function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, -$fullview = true, $listtypetoggle = false, $navigation = true) { - - $day_start = get_day_start(); - $day_end = get_day_end(); - - return list_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $limit, - $fullview, $listtypetoggle, $navigation); -} diff --git a/engine/lib/deprecated-1.9.php b/engine/lib/deprecated-1.9.php new file mode 100644 index 000000000..31d03428f --- /dev/null +++ b/engine/lib/deprecated-1.9.php @@ -0,0 +1,582 @@ +site_guid; + } + + $where = array(); + + if (is_array($type)) { + $tempwhere = ""; + if (sizeof($type)) { + foreach ($type as $typekey => $subtypearray) { + foreach ($subtypearray as $subtypeval) { + $typekey = sanitise_string($typekey); + if (!empty($subtypeval)) { + $subtypeval = (int) get_subtype_id($typekey, $subtypeval); + } else { + $subtypeval = 0; + } + if (!empty($tempwhere)) { + $tempwhere .= " or "; + } + $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})"; + } + } + } + if (!empty($tempwhere)) { + $where[] = "({$tempwhere})"; + } + } else { + $type = sanitise_string($type); + $subtype = get_subtype_id($type, $subtype); + + if ($type != "") { + $where[] = "e.type='$type'"; + } + + if ($subtype !== "") { + $where[] = "e.subtype=$subtype"; + } + } + + if ($owner_guid != "") { + if (!is_array($owner_guid)) { + $owner_array = array($owner_guid); + $owner_guid = (int) $owner_guid; + $where[] = "e.owner_guid = '$owner_guid'"; + } else if (sizeof($owner_guid) > 0) { + $owner_array = array_map('sanitise_int', $owner_guid); + // Cast every element to the owner_guid array to int + $owner_guid = implode(",", $owner_guid); + $where[] = "e.owner_guid in ({$owner_guid})"; + } + if (is_null($container_guid)) { + $container_guid = $owner_array; + } + } + + if ($site_guid > 0) { + $where[] = "e.site_guid = {$site_guid}"; + } + + if (!is_null($container_guid)) { + if (is_array($container_guid)) { + foreach ($container_guid as $key => $val) { + $container_guid[$key] = (int) $val; + } + $where[] = "e.container_guid in (" . implode(",", $container_guid) . ")"; + } else { + $container_guid = (int) $container_guid; + $where[] = "e.container_guid = {$container_guid}"; + } + } + + // Add the calendar stuff + $cal_join = " + JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id + + JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id + "; + $where[] = "cal_start_name.string='calendar_start'"; + $where[] = "cal_start_value.string>=$start_time"; + $where[] = "cal_end_name.string='calendar_end'"; + $where[] = "cal_end_value.string <= $end_time"; + + + if (!$count) { + $query = "SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where "; + } else { + $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where "; + } + foreach ($where as $w) { + $query .= " $w and "; + } + + $query .= get_access_sql_suffix('e'); // Add access controls + + if (!$count) { + $query .= " order by n.calendar_start $order_by"; + // Add order and limit + if ($limit) { + $query .= " limit $offset, $limit"; + } + $dt = get_data($query, "entity_row_to_elggstar"); + + return $dt; + } else { + $total = get_data_row($query); + return $total->total; + } +} + +/** + * Return the notable entities for a given time period based on an item of metadata. + * + * @param int $start_time The start time as a unix timestamp. + * @param int $end_time The end time as a unix timestamp. + * @param mixed $meta_name Metadata name + * @param mixed $meta_value Metadata value + * @param string $entity_type The type of entity to look for, eg 'site' or 'object' + * @param string $entity_subtype The subtype of the entity. + * @param int $owner_guid Owner GUID + * @param int $limit Limit + * @param int $offset Offset + * @param string $order_by Optional ordering. + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any. + * @param bool $count If true, returns count instead of entities. (Default: false) + * + * @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; + + $meta_n = get_metastring_id($meta_name); + $meta_v = get_metastring_id($meta_value); + + $start_time = (int)$start_time; + $end_time = (int)$end_time; + $entity_type = sanitise_string($entity_type); + $entity_subtype = get_subtype_id($entity_type, $entity_subtype); + $limit = (int)$limit; + $offset = (int)$offset; + if ($order_by == "") { + $order_by = "e.time_created desc"; + } + $order_by = sanitise_string($order_by); + $site_guid = (int) $site_guid; + if ((is_array($owner_guid) && (count($owner_guid)))) { + foreach ($owner_guid as $key => $guid) { + $owner_guid[$key] = (int) $guid; + } + } else { + $owner_guid = (int) $owner_guid; + } + + if ($site_guid == 0) { + $site_guid = $CONFIG->site_guid; + } + + //$access = get_access_list(); + + $where = array(); + + if ($entity_type != "") { + $where[] = "e.type='$entity_type'"; + } + + if ($entity_subtype) { + $where[] = "e.subtype=$entity_subtype"; + } + + if ($meta_name != "") { + $where[] = "m.name_id='$meta_n'"; + } + + if ($meta_value != "") { + $where[] = "m.value_id='$meta_v'"; + } + + if ($site_guid > 0) { + $where[] = "e.site_guid = {$site_guid}"; + } + + if (is_array($owner_guid)) { + $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")"; + } else if ($owner_guid > 0) { + $where[] = "e.container_guid = {$owner_guid}"; + } + + // Add the calendar stuff + $cal_join = " + JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id + + JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id + "; + + $where[] = "cal_start_name.string='calendar_start'"; + $where[] = "cal_start_value.string>=$start_time"; + $where[] = "cal_end_name.string='calendar_end'"; + $where[] = "cal_end_value.string <= $end_time"; + + if (!$count) { + $query = "SELECT distinct e.* "; + } else { + $query = "SELECT count(distinct e.guid) as total "; + } + + $query .= "from {$CONFIG->dbprefix}entities e" + . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where"; + + foreach ($where as $w) { + $query .= " $w and "; + } + + // Add access controls + $query .= get_access_sql_suffix("e"); + $query .= ' and ' . get_access_sql_suffix("m"); + + if (!$count) { + // Add order and limit + $query .= " order by $order_by limit $offset, $limit"; + return get_data($query, "entity_row_to_elggstar"); + } else { + if ($row = get_data_row($query)) { + return $row->total; + } + } + + return false; +} + +/** + * Return the notable entities for a given time period based on their relationship. + * + * @param int $start_time The start time as a unix timestamp. + * @param int $end_time The end time as a unix timestamp. + * @param string $relationship The relationship eg "friends_of" + * @param int $relationship_guid The guid of the entity to use query + * @param bool $inverse_relationship Reverse the normal function of the query to say + * "give me all entities for whom $relationship_guid is a + * $relationship of" + * @param string $type Entity type + * @param string $subtype Entity subtype + * @param int $owner_guid Owner GUID + * @param string $order_by Optional Order by + * @param int $limit Limit + * @param int $offset Offset + * @param boolean $count If true returns a count of entities (default false) + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any + * + * @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; + + $start_time = (int)$start_time; + $end_time = (int)$end_time; + $relationship = sanitise_string($relationship); + $relationship_guid = (int)$relationship_guid; + $inverse_relationship = (bool)$inverse_relationship; + $type = sanitise_string($type); + $subtype = get_subtype_id($type, $subtype); + $owner_guid = (int)$owner_guid; + if ($order_by == "") { + $order_by = "time_created desc"; + } + $order_by = sanitise_string($order_by); + $limit = (int)$limit; + $offset = (int)$offset; + $site_guid = (int) $site_guid; + if ($site_guid == 0) { + $site_guid = $CONFIG->site_guid; + } + + //$access = get_access_list(); + + $where = array(); + + if ($relationship != "") { + $where[] = "r.relationship='$relationship'"; + } + if ($relationship_guid) { + $where[] = $inverse_relationship ? + "r.guid_two='$relationship_guid'" : "r.guid_one='$relationship_guid'"; + } + if ($type != "") { + $where[] = "e.type='$type'"; + } + if ($subtype) { + $where[] = "e.subtype=$subtype"; + } + if ($owner_guid != "") { + $where[] = "e.container_guid='$owner_guid'"; + } + if ($site_guid > 0) { + $where[] = "e.site_guid = {$site_guid}"; + } + + // Add the calendar stuff + $cal_join = " + JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id + + JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id + "; + $where[] = "cal_start_name.string='calendar_start'"; + $where[] = "cal_start_value.string>=$start_time"; + $where[] = "cal_end_name.string='calendar_end'"; + $where[] = "cal_end_value.string <= $end_time"; + + // Select what we're joining based on the options + $joinon = "e.guid = r.guid_one"; + if (!$inverse_relationship) { + $joinon = "e.guid = r.guid_two"; + } + + if ($count) { + $query = "SELECT count(distinct e.guid) as total "; + } else { + $query = "SELECT distinct e.* "; + } + $query .= " from {$CONFIG->dbprefix}entity_relationships r" + . " JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where "; + + foreach ($where as $w) { + $query .= " $w and "; + } + // Add access controls + $query .= get_access_sql_suffix("e"); + if (!$count) { + $query .= " order by $order_by limit $offset, $limit"; // Add order and limit + return get_data($query, "entity_row_to_elggstar"); + } else { + if ($count = get_data_row($query)) { + return $count->total; + } + } + return false; +} + +/** + * Get all entities for today. + * + * @param string $type The type of entity (eg "user", "object" etc) + * @param string $subtype The arbitrary subtype of the entity + * @param int $owner_guid The GUID of the owning user + * @param string $order_by The field to order by; by default, time_created desc + * @param int $limit The number of entities to return; 10 by default + * @param int $offset The indexing offset, 0 by default + * @param boolean $count If true returns a count of entities (default false) + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any + * @param mixed $container_guid Container(s) to get entities from (default: any). + * + * @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(); + + return get_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $order_by, + $limit, $offset, $count, $site_guid, $container_guid); +} + +/** + * Get entities for today from metadata. + * + * @param mixed $meta_name Metadata name + * @param mixed $meta_value Metadata value + * @param string $entity_type The type of entity to look for, eg 'site' or 'object' + * @param string $entity_subtype The subtype of the entity. + * @param int $owner_guid Owner GUID + * @param int $limit Limit + * @param int $offset Offset + * @param string $order_by Optional ordering. + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any. + * @param bool $count If true, returns count instead of entities. (Default: false) + * + * @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(); + + return get_notable_entities_from_metadata($day_start, $day_end, $meta_name, $meta_value, + $entity_type, $entity_subtype, $owner_guid, $limit, $offset, $order_by, $site_guid, $count); +} + +/** + * Get entities for today from a relationship + * + * @param string $relationship The relationship eg "friends_of" + * @param int $relationship_guid The guid of the entity to use query + * @param bool $inverse_relationship Reverse the normal function of the query to say + * "give me all entities for whom $relationship_guid is a + * $relationship of" + * @param string $type Entity type + * @param string $subtype Entity subtype + * @param int $owner_guid Owner GUID + * @param string $order_by Optional Order by + * @param int $limit Limit + * @param int $offset Offset + * @param boolean $count If true returns a count of entities (default false) + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any + * + * @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(); + + return get_notable_entities_from_relationship($day_start, $day_end, $relationship, + $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, $order_by, + $limit, $offset, $count, $site_guid); +} + +/** + * Returns a viewable list of entities for a given time period. + * + * @see elgg_view_entity_list + * + * @param int $start_time The start time as a unix timestamp. + * @param int $end_time The end time as a unix timestamp. + * @param string $type The type of entity (eg "user", "object" etc) + * @param string $subtype The arbitrary subtype of the entity + * @param int $owner_guid The GUID of the owning user + * @param int $limit The number of entities to return; 10 by default + * @param boolean $fullview Whether or not to display the full view (default: true) + * @param boolean $listtypetoggle Whether or not to allow gallery view + * @param boolean $navigation Display pagination? Default: true + * + * @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, + $owner_guid, "", $limit, $offset, true); + + $entities = get_notable_entities($start_time, $end_time, $type, $subtype, + $owner_guid, "", $limit, $offset); + + return elgg_view_entity_list($entities, $count, $offset, $limit, + $fullview, $listtypetoggle, $navigation); +} + +/** + * Return a list of today's entities. + * + * @see list_notable_entities + * + * @param string $type The type of entity (eg "user", "object" etc) + * @param string $subtype The arbitrary subtype of the entity + * @param int $owner_guid The GUID of the owning user + * @param int $limit The number of entities to return; 10 by default + * @param boolean $fullview Whether or not to display the full view (default: true) + * @param boolean $listtypetoggle Whether or not to allow gallery view + * @param boolean $navigation Display pagination? Default: 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(); + + return list_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $limit, + $fullview, $listtypetoggle, $navigation); +} diff --git a/engine/start.php b/engine/start.php index 454dc7377..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', @@ -102,8 +102,8 @@ $lib_files = array( 'statistics.php', 'tags.php', 'user_settings.php', 'users.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/install/ElggInstaller.php b/install/ElggInstaller.php index 367d23b4d..2070f15e9 100644 --- a/install/ElggInstaller.php +++ b/install/ElggInstaller.php @@ -780,7 +780,7 @@ class ElggInstaller { 'database.php', 'actions.php', 'admin.php', 'annotations.php', - 'calendar.php', 'cron.php', 'entities.php', + 'cron.php', 'entities.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', 'metastrings.php', @@ -791,7 +791,7 @@ class ElggInstaller { 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', 'deprecated-1.7.php', - 'deprecated-1.8.php', + 'deprecated-1.8.php', 'deprecated-1.9.php' ); foreach ($lib_files as $file) { -- cgit v1.2.3