Changeset 702 for trunk/forum/includes/functions_profile_fields.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/functions_profile_fields.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : functions_profile_fields.php 9127 2008-11-26 19:58:35Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 40 40 { 41 41 case 'register': 42 // If the field is required we show it on the registration page and do not show hidden fields43 $sql_where .= ' AND f.field_show_on_reg = 1 AND f.field_no_view = 0';42 // If the field is required we show it on the registration page 43 $sql_where .= ' AND f.field_show_on_reg = 1'; 44 44 break; 45 45 … … 93 93 switch ($field_type) 94 94 { 95 case FIELD_INT:96 case FIELD_DROPDOWN:97 $field_value = (int) $field_value;98 break;99 100 case FIELD_BOOL:101 $field_value = (bool) $field_value;102 break;103 }104 105 switch ($field_type)106 {107 95 case FIELD_DATE: 108 96 $field_validate = explode('-', $field_value); … … 134 122 135 123 case FIELD_BOOL: 124 $field_value = (bool) $field_value; 125 136 126 if (!$field_value && $field_data['field_required']) 137 127 { … … 141 131 142 132 case FIELD_INT: 143 if ( empty($field_value)&& !$field_data['field_required'])133 if (trim($field_value) === '' && !$field_data['field_required']) 144 134 { 145 135 return false; 146 136 } 137 138 $field_value = (int) $field_value; 147 139 148 140 if ($field_value < $field_data['field_minlen']) … … 157 149 158 150 case FIELD_DROPDOWN: 151 $field_value = (int) $field_value; 152 159 153 if ($field_value == $field_data['field_novalue'] && $field_data['field_required']) 160 154 { … … 165 159 case FIELD_STRING: 166 160 case FIELD_TEXT: 167 if ( empty($field_value)&& !$field_data['field_required'])161 if (trim($field_value) === '' && !$field_data['field_required']) 168 162 { 169 163 return false; 170 164 } 171 else if ( empty($field_value)&& $field_data['field_required'])165 else if (trim($field_value) === '' && $field_data['field_required']) 172 166 { 173 167 return 'FIELD_REQUIRED'; … … 260 254 261 255 /** 262 * Submit profile field 256 * Submit profile field for validation 263 257 * @access public 264 258 */ … … 271 265 { 272 266 case 'register': 273 // If the field is required we show it on the registration page and do not show hidden fields274 $sql_where .= ' AND f.field_show_on_reg = 1 AND f.field_no_view = 0';267 // If the field is required we show it on the registration page 268 $sql_where .= ' AND f.field_show_on_reg = 1'; 275 269 break; 276 270 … … 351 345 352 346 /** 347 * Update profile field data directly 348 */ 349 function update_profile_field_data($user_id, &$cp_data) 350 { 351 global $db; 352 353 if (!sizeof($cp_data)) 354 { 355 return; 356 } 357 358 switch ($db->sql_layer) 359 { 360 case 'oracle': 361 case 'firebird': 362 case 'postgres': 363 $right_delim = $left_delim = '"'; 364 break; 365 366 case 'sqlite': 367 case 'mssql': 368 case 'mssql_odbc': 369 $right_delim = ']'; 370 $left_delim = '['; 371 break; 372 373 case 'mysql': 374 case 'mysql4': 375 case 'mysqli': 376 $right_delim = $left_delim = '`'; 377 break; 378 } 379 380 // use new array for the UPDATE; changes in the key do not affect the original array 381 $cp_data_sql = array(); 382 foreach ($cp_data as $key => $value) 383 { 384 // Firebird is case sensitive with delimiter 385 $cp_data_sql[$left_delim . (($db->sql_layer == 'firebird' || $db->sql_layer == 'oracle') ? strtoupper($key) : $key) . $right_delim] = $value; 386 } 387 388 $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' 389 SET ' . $db->sql_build_array('UPDATE', $cp_data_sql) . " 390 WHERE user_id = $user_id"; 391 $db->sql_query($sql); 392 393 if (!$db->sql_affectedrows()) 394 { 395 $cp_data_sql['user_id'] = (int) $user_id; 396 397 $db->sql_return_on_error(true); 398 399 $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data_sql); 400 $db->sql_query($sql); 401 402 $db->sql_return_on_error(false); 403 } 404 } 405 406 /** 353 407 * Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled) 354 408 * This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template … … 455 509 { 456 510 case 'int': 457 if ($value == '')511 if ($value === '') 458 512 { 459 513 return NULL; … … 571 625 else 572 626 { 573 if (!$preview && isset($user->profile_fields[$user_ident]) && is_null($user->profile_fields[$user_ident]))627 if (!$preview && array_key_exists($user_ident, $user->profile_fields) && is_null($user->profile_fields[$user_ident])) 574 628 { 575 629 $value = NULL; … … 585 639 } 586 640 587 return (is_null($value) ) ? '' : (int) $value;641 return (is_null($value) || $value === '') ? '' : (int) $value; 588 642 } 589 643 else
Note:
See TracChangeset
for help on using the changeset viewer.