From a7e2dcecb603734d2c47ffa506e91a2d3ae77253 Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 19 Nov 2008 19:46:12 +0000 Subject: Base private setting functions, commit 1 git-svn-id: https://code.elgg.org/elgg/trunk@2465 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/engine/lib/entities.php b/engine/lib/entities.php index fd0475d07..05f8f9dcd 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -2134,6 +2134,60 @@ return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle); + } + + /** + * Gets a private setting for an entity. + * + * @param int $entity_guid The entity GUID + * @param string $name The name of the setting + * @return mixed The setting value, or false on failure + */ + function get_private_setting($entity_guid, $name) { + + global $CONFIG; + $entity_guid = (int) $entity_guid; + $name = mysql_real_escape_string($name); + if ($setting = get_data_row("select value from {$CONFIG->prefix}private_settings where name = '{$name}' and entity_guid = {$entity_guid}")) { + return $setting->value; + } + return false; + + } + + /** + * Sets a private setting for an entity. + * + * @param int $entity_guid The entity GUID + * @param string $name The name of the setting + * @param string $value The value of the setting + * @return mixed The setting ID, or false on failure + */ + function set_private_setting($entity_guid, $name, $value) { + + global $CONFIG; + $entity_guid = (int) $entity_guid; + $name = mysql_real_escape_string($name); + $value = mysql_real_escape_string($value); + return insert_data("insert into {$CONFIG->prefix}private_settings set name = '{$name}', value = '{$value}' where entity_guid = {$entity_guid}"); + + } + + /** + * Deletes a private setting for an entity. + * + * @param int $entity_guid The Entity GUID + * @param string $name The name of the setting + * @return true|false depending on success + * + */ + function remove_private_setting($entity_guid, $name) { + + global $CONFIG; + $entity_guid = (int) $entity_guid; + $name = mysql_real_escape_string($name); + return delete_data("delete from {$CONFIG->prefix}private_settings where name = '{$name}' and entity_guid = {$entity_guid}"); + } /** -- cgit v1.2.3