access != "admin") || $isAdmin) ? "" : "disabled "; foreach ($field->attribute as $attribute) $attributesString .= $attribute['key']. "='$attribute' "; if (is_array($custom_fields) and array_key_exists((string)$field['key'], $custom_fields)) $fieldValue = (string)$custom_fields[(string)$field['key']]; else $fieldValue = (string)$field->default_value; $idString = "id='".clean_id_string($field['key'])."'"; $nameString = "name='fields[".$field['key']."]'"; $fieldType = $field['type']; if ($fieldType == "select") { $inputElementString = ""; } else { if ($fieldType == "checkbox_key_value") { if ($fieldValue) // convert the XML object to string $attributesString .= "checked='checked' "; $fieldValue = $field['key']; $fieldType = "checkbox"; } else if ($fieldType == "checkbox") { if ($fieldValue) // convert the XML object to string $attributesString .= "checked='checked' "; } $inputElementString = ""; } echo "
"; echo "<< ".get_lang('back_to_game_monitor').""; echo "
"; if(isset($_POST['update_settings'])) { $save_field = $_POST['fields']; $updatedSettings = array(); foreach($server_xml->custom_fields->field as $field) { if (array_key_exists((string)$field['key'], (array)$custom_fields)){ $origValue = (string)$custom_fields[(string)$field['key']]; }else{ $origValue = ""; } $found = 0; foreach ($save_field as $key => $value ) { if($key == (string)$field['key']){ $found++; // If locked by an admin, ignore the value posted by the user $lockedByAdmin = false; if(property_exists($field, 'access') && $field->access == "admin") { $lockedByAdmin = true; if(!$isAdmin){ $value = $origValue; // Set it to the old saved value (which was last set by an admin) or set it to its default value } } if (strlen(trim($value)) > 0) { $updatedSettings[$key] = $value; } break; } } if($found == 0 && !empty($origValue)){ $updatedSettings[(string)$field['key']] = $origValue; } } if(is_array($updatedSettings) && count($updatedSettings) > 0){ $db->changeCustomFields($home_info['home_id'],json_encode($updatedSettings)); }else{ $db->changeCustomFields($home_info['home_id'],""); } print_success(get_lang('settings_updated')); $view->refresh("?m=user_games&p=custom_fields&home_id=".$home_id); } $ft = new FormTable(); $ft->start_form("", "post", "autocomplete=\"off\""); $ft->start_table(); foreach($server_xml->custom_fields->field as $field) { renderCustomFields($field, $home_info['home_id']); } $ft->end_table(); $ft->add_button("submit","update_settings",get_lang('update_settings')); $ft->end_form(); } ?>