aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-16 16:06:52 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-16 16:06:52 +0000
commitb8c4f458fd9701f58299ce44995390cc7df4c460 (patch)
treec0e86c790a43fdcda546fa07dd098f6df0393a2b /engine
parent522d92f546110902f98dd2b176944ab8f07221c7 (diff)
downloadelgg-b8c4f458fd9701f58299ce44995390cc7df4c460.tar.gz
elgg-b8c4f458fd9701f58299ce44995390cc7df4c460.tar.bz2
CLOSED - #5: Boolean metadata values
http://trac.elgg.org/elgg/ticket/5 git-svn-id: https://code.elgg.org/elgg/trunk@932 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/metadata.php24
1 files changed, 20 insertions, 4 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 8cc6a7202..7923039b1 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -200,15 +200,23 @@
$id = false;
$existing = get_data_row("SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name) . " limit 1");
- if (($existing) && (!$allow_multiple) && (!empty($value)))
+ if (($existing) && (!$allow_multiple) && (isset($value)))
{
$id = $existing->id;
$result = update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id);
if (!$result) return false;
}
- else if (!empty($value))
+ else if (isset($value))
{
+ // Support boolean types
+ if (is_bool($value)) {
+ if ($value)
+ $value = 1;
+ else
+ $value = 0;
+ }
+
// Add the metastrings
$value = add_metastring($value);
if (!$value) return false;
@@ -219,7 +227,7 @@
// If ok then add it
$id = insert_data("INSERT into {$CONFIG->dbprefix}metadata (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ($entity_guid, '$name','$value','$value_type', $owner_guid, $time, $access_id)");
} else if ($existing) {
-
+// TODO: Check... are you sure you meant to do this Ben? :)
$id = $existing->id;
delete_metadata($id);
@@ -243,7 +251,7 @@
global $CONFIG;
$id = (int)$id;
-
+
if (!$md = get_metadata($id)) return false;
if (!$md->canEdit()) return false;
@@ -258,6 +266,14 @@
$access = get_access_sql_suffix();
+ // Support boolean types (as integers)
+ if (is_bool($value)) {
+ if ($value)
+ $value = 1;
+ else
+ $value = 0;
+ }
+
// Add the metastring
$value = add_metastring($value);
if (!$value) return false;