diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-01 12:12:59 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-01 12:12:59 +0000 |
commit | 01693c67dbb7ed686b6fa03faba875eb11fea160 (patch) | |
tree | 501a02b3cd555cb087b6f02cf039959dc60cc269 /engine | |
parent | 9f35703c6e30b86a91d88325df4dcba54acb74f1 (diff) | |
download | elgg-01693c67dbb7ed686b6fa03faba875eb11fea160.tar.gz elgg-01693c67dbb7ed686b6fa03faba875eb11fea160.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Fixed regression on custom class loader
git-svn-id: https://code.elgg.org/elgg/trunk@590 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/database.php | 2 | ||||
-rw-r--r-- | engine/lib/entities.php | 37 |
2 files changed, 30 insertions, 9 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php index 0979592c0..0f4bc89b9 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -355,7 +355,7 @@ * @param string $string The string to sanitise
* @return string Sanitised string
*/
- function sanitise_string($string) {
+ function sanitise_string($string) {return $string;
return mysql_real_escape_string(trim($string));
}
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index c62eb8ea7..a4df6fa02 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -595,7 +595,7 @@ * * TODO: Move to a nicer place? * - * @param string $subtype_id + * @param int $subtype_id */ function get_subtype_from_id($subtype_id) { @@ -632,6 +632,25 @@ } /** + * This function tests to see if a subtype has a registered class handler by its id. + * + * @param int $subtype_id The subtype + * @return a class name or null + */ + function get_subtype_class_from_id($subtype_id) + { + global $CONFIG; + + $subtype = (int)$subtype_id; + + $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where id=$subtype_id"); + if ($result) + return $result->class; + + return NULL; + } + + /** * This function will register a new subtype, returning its ID as required. * * @param string $type The type you're subtyping @@ -641,18 +660,17 @@ function add_subtype($type, $subtype, $class = "") { global $CONFIG; - $type = sanitise_string($type); $subtype = sanitise_string($subtype); $class = sanitise_string($class); - + // Short circuit if no subtype is given - if ($subtype == "") + if ($subtype2 == "") return 0; - + $id = get_subtype_id($type, $subtype); - if (!$id) + if ($id==0) return insert_data("insert into {$CONFIG->dbprefix}entity_subtypes (type, subtype, class) values ('$type','$subtype','$class')"); return $id; @@ -748,14 +766,16 @@ if (!($row instanceof stdClass)) return $row; // See if there are any registered subtype handler classes for this type and subtype - $classname = get_subtype_class($row->type, $row->subtype); + + $classname = get_subtype_class_from_id($row->subtype); if ($classname!="") { $tmp = new $classname($row); if (!($tmp instanceof ElggEntity)) throw new ClassException("$classname is not an ElggEntity."); - + + return $tmp; } else { @@ -842,6 +862,7 @@ if (!$count) {
$query .= " order by $order_by";
if ($limit) $query .= " limit $offset, $limit"; // Add order and limit + $dt = get_data($query, "entity_row_to_elggstar");
return $dt;
} else {
|