From 083219d563d9c3a35429b27a1b76a312e7fa72dd Mon Sep 17 00:00:00 2001 From: icewing Date: Wed, 12 Mar 2008 10:58:35 +0000 Subject: Marcus Povey * Added get_entity_subtypes function git-svn-id: https://code.elgg.org/elgg/trunk@183 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 engine/lib/entities.php (limited to 'engine/lib/entities.php') diff --git a/engine/lib/entities.php b/engine/lib/entities.php new file mode 100644 index 000000000..2b97ffa10 --- /dev/null +++ b/engine/lib/entities.php @@ -0,0 +1,34 @@ + + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + /** + * Get the subtype of a given entity, based on its id and type pair. + * + * @param int $entity_id The entity ID + * @param string $entity_type The entity type string. + * @return mixed Either an int id into the *_entity_subtypes + */ + function get_entity_subtype($entity_id, $entity_type) + { + global $CONFIG; + + $entity_id = (int)$entity_id; + $entity_type = sanitise_string($entity_type); + + $row = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where entity_id=$entity_id and entity_type='$entity_type' limit 1"); + if ($row) + return $row->id; + + return false; + } +?> \ No newline at end of file -- cgit v1.2.3