From: brettp Date: Tue, 23 Mar 2010 20:06:36 +0000 (+0000) Subject: Added remove_subtype() and update_subtype(). X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=5595bf0ccbd10869f20ccd0ee4f7ad1935956408;p=lorea%2Felgg.git Added remove_subtype() and update_subtype(). git-svn-id: http://code.elgg.org/elgg/trunk@5488 36083f99-b078-4883-b0ff-0f9b5a30f544 --- diff --git a/CHANGES.txt b/CHANGES.txt index 3d64def69..074aa6c62 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,7 @@ Version 1.8.0 Generic API changes: * Added elgg_instanceof(). + * Added remove_subtype() and update_subtype(). UI/UX API changes: * Added elgg_push_breadcrumb(), elgg_pop_breadcrumb(), and elgg_get_breadcrumbs(). diff --git a/engine/lib/entities.php b/engine/lib/entities.php index fd46b062d..e3fa0cb52 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1461,6 +1461,44 @@ function add_subtype($type, $subtype, $class = "") { return $id; } +/** + * Removes a registered subtype + * + * @param string $type + * @param string $subtype + */ +function remove_subtype($type, $subtype) { + global $CONFIG; + + $type = sanitise_string($type); + $subtype = sanitise_string($subtype); + + return delete_data("DELETE FROM {$CONFIG->dbprefix}entity_subtypes WHERE type = '$type' AND subtype = '$subtype'"); +} + +/** + * Update the registered information + * + * @param string $type + * @param string $subtype + * @param string $class + */ +function update_subtype($type, $subtype, $class = '') { + global $CONFIG; + + if (!$id = get_subtype_id($type, $subtype)) { + return FALSE; + } + $type = sanitise_string($type); + $subtype = sanitise_string($subtype); + + return update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes + SET type = '$type', subtype = '$subtype', class = '$class' + WHERE id = $id + "); +} + + /** * Update an existing entity. *