From 336cec80e01349057b51fb96c210a53c00100938 Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 2 Dec 2010 18:43:35 +0000 Subject: [PATCH] Quick fix for an error showing up in some field types for the api Added an error catch, re-indexing the languages array when a user is saved, to ensure that the indecies are numeric --- user.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/user.inc.php b/user.inc.php index 6264f36..5837226 100644 --- a/user.inc.php +++ b/user.inc.php @@ -521,6 +521,8 @@ function user_get_fields($userRoles = null){ $fields[$fieldName]['type'] = 'integer'; }else if(!strncmp($ftype, "tinytext", 8)){ $fields[$fieldName]['type'] = 'text'; + }else if(!strncmp($ftype, "int", 3)){ + $fields[$fieldName]['type'] = $fieldType[$fieldName]; }else{ $fields[$fieldName]['type'] = "ERROR:" . $fieldType[$fieldName]; } @@ -661,6 +663,11 @@ function user_save(&$u) $set = ""; foreach($fields as $f) { + // re-indexing fields that might be mis-entered. Add additional field names to the array as needed. + if(in_array($f, array('languages'))){ + $u[$f] = array_values($u[$f]); + } + if($u[$f] == $u['orig'][$f]) continue; if($set != "") $set .=',';