From a736690de481b6dadbcbac6f2f5a1f2f75115ddf Mon Sep 17 00:00:00 2001 From: icewing Date: Wed, 12 Mar 2008 09:29:16 +0000 Subject: Marcus Povey * object_* changed to entity_* git-svn-id: https://code.elgg.org/elgg/trunk@177 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/annotations.php | 98 +++++++++++++++++++++++----------------------- engine/lib/metadata.php | 56 +++++++++++++------------- 2 files changed, 77 insertions(+), 77 deletions(-) (limited to 'engine') diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index bbafd9bc3..5a2bed865 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -88,7 +88,7 @@ return update_annotation($this->id, $this->name, $this->value, $this->value_type, $this->owner_id, $this->access_id); else { - $this->id = create_annotation($this->object_id, $this->object_type, $this->name, $this->value, $this->value_type, $this->owner_id, $this->access_id); + $this->id = create_annotation($this->entity_id, $this->entity_type, $this->name, $this->value, $this->value_type, $this->owner_id, $this->access_id); if (!$this->id) throw new IOException("Unable to save new ElggAnnotation"); return $this->id; } @@ -134,8 +134,8 @@ /** * Get a list of annotations for a given object/user/annotation type. * - * @param int $object_id - * @param string $object_type + * @param int $entity_id + * @param string $entity_type * @param string $name * @param mixed $value * @param int $owner_id @@ -143,12 +143,12 @@ * @param int $limit * @param int $offset */ - function get_annotations($object_id = 0, $object_type = "", $name = "", $value = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0) + function get_annotations($entity_id = 0, $entity_type = "", $name = "", $value = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string(trim($object_type)); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string(trim($entity_type)); $name = sanitise_string(trim($name)); $value = sanitise_string(trim($value)); @@ -161,11 +161,11 @@ // Construct query $where = array(); - if ($object_id != 0) - $where[] = "object_id=$object_id"; + if ($entity_id != 0) + $where[] = "entity_id=$entity_id"; - if ($object_type != "") - $where[] = "object_type='$object_type'"; + if ($entity_type != "") + $where[] = "entity_type='$entity_type'"; if ($owner_id != 0) $where[] = "owner_id=$owner_id"; @@ -217,20 +217,20 @@ /** * Create a new annotation. * - * @param int $object_id - * @param string $object_type + * @param int $entity_id + * @param string $entity_type * @param string $name * @param string $value * @param string $value_type * @param int $owner_id * @param int $access_id */ - function create_annotation($object_id, $object_type, $name, $value, $value_type, $owner_id, $access_id = 0) + function create_annotation($entity_id, $entity_type, $name, $value, $value_type, $owner_id, $access_id = 0) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string(trim($object_type)); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string(trim($entity_type)); $name = sanitise_string(trim($name)); $value = sanitise_string(trim($value)); $value_type = detect_annotation_valuetype($value, sanitise_string(trim($value_type))); @@ -247,7 +247,7 @@ if (!$value) return false; // If ok then add it - return insert_data("INSERT into {$CONFIG->dbprefix}annotations (object_id, object_type, name, value, value_type, owner_id, created, access_id) VALUES ($object_id,'$object_type','$name','$value','$value_type', $owner_id, $time, $access_id)"); + return insert_data("INSERT into {$CONFIG->dbprefix}annotations (entity_id, entity_type, name, value, value_type, owner_id, created, access_id) VALUES ($entity_id,'$entity_type','$name','$value','$value_type', $owner_id, $time, $access_id)"); } /** @@ -287,19 +287,19 @@ /** * Count the number of annotations based on search parameters * - * @param int $object_id - * @param string $object_type + * @param int $entity_id + * @param string $entity_type * @param string $name * @param mixed $value * @param string $value_type * @param int $owner_id */ - function count_annotations($object_id = 0, $object_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0) + function count_annotations($entity_id = 0, $entity_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string($object_type); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string($entity_type); $name = sanitise_string($name); $value = sanitise_string($value); $value_type = sanitise_string($value_type); @@ -309,11 +309,11 @@ $where = array(); $where_q = ""; - if ($object_id != 0) - $where[] = "object_id=$object_id"; + if ($entity_id != 0) + $where[] = "entity_id=$entity_id"; - if ($object_type != "") - $where[] = "object_type='$object_type'"; + if ($entity_type != "") + $where[] = "entity_type='$entity_type'"; if ($name != "") $where[] = "name='$name'"; @@ -340,19 +340,19 @@ /** * Return the sum of a given integer annotation. * - * @param $object_id int - * @param $object_type string + * @param $entity_id int + * @param $entity_type string * @param $name string */ - function get_annotations_sum($object_id, $object_type, $name) + function get_annotations_sum($entity_id, $entity_type, $name) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string($object_type); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string($entity_type); $name = santitise_string($name); - $row = get_data_row("SELECT sum(value) as sum from {$CONFIG->dbprefix}annotations where object_id=$object_id and object_type='$object_type' and value_type='integer' and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); + $row = get_data_row("SELECT sum(value) as sum from {$CONFIG->dbprefix}annotations where entity_id=$entity_id and entity_type='$entity_type' and value_type='integer' and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); if ($row) return $row->sum; @@ -363,19 +363,19 @@ /** * Return the max of a given integer annotation. * - * @param $object_id int - * @param $object_type string + * @param $entity_id int + * @param $entity_type string * @param $name string */ - function get_annotations_max($object_id, $object_type, $name) + function get_annotations_max($entity_id, $entity_type, $name) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string($object_type); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string($entity_type); $name = santitise_string($name); - $row = get_data_row("SELECT max(value) as max from {$CONFIG->dbprefix}annotations where object_id=$object_id and object_type='$object_type' and value_type='integer' and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); + $row = get_data_row("SELECT max(value) as max from {$CONFIG->dbprefix}annotations where entity_id=$entity_id and entity_type='$entity_type' and value_type='integer' and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); if ($row) return $row->max; @@ -386,19 +386,19 @@ /** * Return the minumum of a given integer annotation. * - * @param $object_id int - * @param $object_type string + * @param $entity_id int + * @param $entity_type string * @param $name string */ - function get_annotations_min($object_id, $object_type, $name) + function get_annotations_min($entity_id, $entity_type, $name) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string($object_type); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string($entity_type); $name = santitise_string($name); - $row = get_data_row("SELECT min(value) as min from {$CONFIG->dbprefix}annotations where object_id=$object_id and object_type='$object_type' and value_type='integer' and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); + $row = get_data_row("SELECT min(value) as min from {$CONFIG->dbprefix}annotations where entity_id=$entity_id and entity_type='$entity_type' and value_type='integer' and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); if ($row) return $row->min; @@ -409,19 +409,19 @@ /** * Return the average of a given integer annotation. * - * @param $object_id int - * @param $object_type string + * @param $entity_id int + * @param $entity_type string * @param $name string */ - function get_annotations_avg($object_id, $object_type, $name) + function get_annotations_avg($entity_id, $entity_type, $name) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string($object_type); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string($entity_type); $name = santitise_string($name); - $row = get_data_row("SELECT avg(value) as avg from {$CONFIG->dbprefix}annotations where object_id=$object_id and object_type='$object_type' and value_type='integer' and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); + $row = get_data_row("SELECT avg(value) as avg from {$CONFIG->dbprefix}annotations where entity_id=$entity_id and entity_type='$entity_type' and value_type='integer' and name='$name' and (access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"); if ($row) return $row->avg; diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index ee356b9f4..e82af716e 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -88,7 +88,7 @@ return update_metadata($this->id, $this->name, $this->value, $this->value_type, $this->owner_id, $this->access_id); else { - $this->id = create_metadata($this->object_id, $this->object_type, $this->name, $this->value, $this->value_type, $this->owner_id, $this->access_id); + $this->id = create_metadata($this->entity_id, $this->entity_type, $this->name, $this->value, $this->value_type, $this->owner_id, $this->access_id); if (!$this->id) throw new IOException("Unable to save new ElggAnnotation"); return $this->id; } @@ -140,20 +140,20 @@ /** * Create a new metadata object, or update an existing one. * - * @param int $object_id - * @param string $object_type + * @param int $entity_id + * @param string $entity_type * @param string $name * @param string $value * @param string $value_type * @param int $owner_id * @param int $access_id */ - function create_metadata($object_id, $object_type, $name, $value, $value_type, $owner_id, $access_id = 0) + function create_metadata($entity_id, $entity_type, $name, $value, $value_type, $owner_id, $access_id = 0) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string(trim($object_type)); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string(trim($entity_type)); $name = sanitise_string(trim($name)); $value = sanitise_string(trim($value)); $value_type = detect_metadata_valuetype(sanitise_string(trim($value_type))); @@ -166,7 +166,7 @@ $id = false; - $existing = get_data_row("SELECT * from {$CONFIG->dbprefix}metadata WHERE object_id = $object_id and object_type='$object_type' and name='$name' limit 1"); + $existing = get_data_row("SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_id = $entity_id and entity_type='$entity_type' and name='$name' limit 1"); if ($existing) { $id = $existing->id; @@ -181,7 +181,7 @@ if (!$value) return false; // If ok then add it - $id = insert_data("INSERT into {$CONFIG->dbprefix}metadata (object_id, object_type, name, value, value_type, owner_id, created, access_id) VALUES ($object_id,'$object_type','$name','$value','$value_type', $owner_id, $time, $access_id)"); + $id = insert_data("INSERT into {$CONFIG->dbprefix}metadata (entity_id, entity_type, name, value, value_type, owner_id, created, access_id) VALUES ($entity_id,'$entity_type','$name','$value','$value_type', $owner_id, $time, $access_id)"); } return $id; @@ -240,20 +240,20 @@ /** * Get a list of metadatas for a given object/user/metadata type. * - * @param int $object_id - * @param string $object_type + * @param int $entity_id + * @param string $entity_type * @param int $owner_id * @param string $order_by * @param int $limit * @param int $offset * @return array of ElggMetadata */ - function get_metadatas($object_id = 0, $object_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0) + function get_metadatas($entity_id = 0, $entity_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0) { global $CONFIG; - $object_id = (int)$object_id; - $object_type = sanitise_string(trim($object_type)); + $entity_id = (int)$entity_id; + $entity_type = sanitise_string(trim($entity_type)); $name = sanitise_string(trim($name)); $value = sanitise_string(trim($value)); $value_type = sanitise_string(trim($value_type)); @@ -266,11 +266,11 @@ // Construct query $where = array(); - if ($object_id != 0) - $where[] = "object_id=$object_id"; + if ($entity_id != 0) + $where[] = "entity_id=$entity_id"; - if ($object_type != "") - $where[] = "object_type='$object_type'"; + if ($entity_type != "") + $where[] = "entity_type='$entity_type'"; if ($owner_id != 0) $where[] = "owner_id=$owner_id"; @@ -288,7 +288,7 @@ $access = get_access_list(); $where[] = "(access_id in {$access} or (access_id = 0 and owner_id = {$_SESSION['id']}))"; - if ($object_subtype!="") + if ($entity_subtype!="") $where[] = ""; // construct query. @@ -306,17 +306,17 @@ /** * Similar to get_metadatas, but instead returns the objects associated with a given meta search. * - * @param int $object_id - * @param string $object_type + * @param int $entity_id + * @param string $entity_type * @param int $owner_id * @param string $order_by * @param int $limit * @param int $offset * @return mixed Array of objects or false. */ - function get_objects_from_metadatas($object_id = 0, $object_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0) + function get_objects_from_metadatas($entity_id = 0, $entity_type = "", $name = "", $value = "", $value_type = "", $owner_id = 0, $order_by = "created desc", $limit = 10, $offset = 0) { - $results = get_metadatas($object_id, $object_type, $name, $value, $value_type, $owner_id, $order_by, $limit, $offset); + $results = get_metadatas($entity_id, $entity_type, $name, $value, $value_type, $owner_id, $order_by, $limit, $offset); $objects = false; if ($results) @@ -326,13 +326,13 @@ foreach ($results as $r) { - switch ($r->object_type) + switch ($r->entity_type) { - case 'object' : $objects[] = new ElggObject((int)$r->object_id); break; - case 'user' : $objects[] = new ElggUser((int)$r->object_id); break; - case 'collection' : $objects[] = new ElggCollection((int)$r->object_id); break; - case 'site' : $objects[] = new ElggSite((int)$r->object_id); break; - default: default : throw new InstallationException("Type {$r->object_type} is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade."); + case 'object' : $objects[] = new ElggObject((int)$r->entity_id); break; + case 'user' : $objects[] = new ElggUser((int)$r->entity_id); break; + case 'collection' : $objects[] = new ElggCollection((int)$r->entity_id); break; + case 'site' : $objects[] = new ElggSite((int)$r->entity_id); break; + default: default : throw new InstallationException("Type {$r->entity_type} is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade."); } } } -- cgit v1.2.3