function validate_s_attribute_type($s_attribute_type) { $s_attribute_type = strtoupper($s_attribute_type); if (strlen($s_attribute_type) > 0) { if (!is_exists_attribute_type($s_attribute_type)) { return FALSE; } } //else return $s_attribute_type; }
$update_result = update_s_attribute_type($HTTP_VARS['s_attribute_type'], $HTTP_VARS['description'], $HTTP_VARS['prompt'], $HTTP_VARS['input_type'], $HTTP_VARS['input_type_arg1'], $HTTP_VARS['input_type_arg2'], $HTTP_VARS['input_type_arg3'], $HTTP_VARS['input_type_arg4'], $HTTP_VARS['input_type_arg5'], $HTTP_VARS['display_type'], $HTTP_VARS['display_type_arg1'], $HTTP_VARS['display_type_arg2'], $HTTP_VARS['display_type_arg3'], $HTTP_VARS['display_type_arg4'], $HTTP_VARS['display_type_arg5'], $HTTP_VARS['s_field_type'], $HTTP_VARS['site_type'], $HTTP_VARS['listing_link_ind'], $HTTP_VARS['file_attribute_ind'], $HTTP_VARS['lookup_attribute_ind'], $HTTP_VARS['multi_attribute_ind'], $HTTP_VARS['view_perm']); } } } if (!$update_result) { $errors[] = array('error' => 'Attribute type not updated', 'detail' => db_error()); } $HTTP_VARS['op'] = 'edit'; } else { $HTTP_VARS['op'] = 'edit'; } } else { if ($HTTP_VARS['op'] == 'insert') { set_attribute_ind_type($HTTP_VARS); $HTTP_VARS['s_attribute_type'] = strtoupper(preg_replace("/[\\s|'|\\\\|\"]+/", "", trim(strip_tags($HTTP_VARS['s_attribute_type'])))); if (!is_exists_attribute_type($HTTP_VARS['s_attribute_type'])) { if (!is_reserved_s_attribute_type($HTTP_VARS['s_attribute_type'])) { // site type not valid for these if ($HTTP_VARS['s_field_type'] == 'ADDRESS' || $HTTP_VARS['s_field_type'] == 'RATING') { $HTTP_VARS['site_type'] = NULL; } if (!insert_s_attribute_type($HTTP_VARS['s_attribute_type'], $HTTP_VARS['description'], $HTTP_VARS['prompt'], $HTTP_VARS['input_type'], $HTTP_VARS['input_type_arg1'], $HTTP_VARS['input_type_arg2'], $HTTP_VARS['input_type_arg3'], $HTTP_VARS['input_type_arg4'], $HTTP_VARS['input_type_arg5'], $HTTP_VARS['display_type'], $HTTP_VARS['display_type_arg1'], $HTTP_VARS['display_type_arg2'], $HTTP_VARS['display_type_arg3'], $HTTP_VARS['display_type_arg4'], $HTTP_VARS['display_type_arg5'], $HTTP_VARS['s_field_type'], $HTTP_VARS['site_type'], $HTTP_VARS['listing_link_ind'], $HTTP_VARS['file_attribute_ind'], $HTTP_VARS['lookup_attribute_ind'], $HTTP_VARS['multi_attribute_ind'], $HTTP_VARS['view_perm'])) { $errors[] = array('error' => 'Attribute type (' . $HTTP_VARS['s_attribute_type'] . ') not inserted', 'detail' => db_error()); $HTTP_VARS['op'] = 'new'; } else { $HTTP_VARS['op'] = 'edit'; $HTTP_VARS['active_tab'] = strtoupper(substr(trim($HTTP_VARS['s_attribute_type']), 0, 1)); } } else { $errors[] = array('error' => 'Attribute type\'s with a \'S_\' prefix are reserved for internal use.'); $HTTP_VARS['op'] = 'new';
// TITLE, STATUS, CATEGORY. The DURATION is required if // get_opendb_config_var('borrow', 'enable') == TRUE AND get_opendb_config_var('borrow', 'duration_support') == TRUE $missing_s_field_types = NULL; if (strlen($HTTP_VARS['s_field_type']['TITLE']) == 0 || !is_exists_attribute_type($HTTP_VARS['s_field_type']['TITLE'])) { $missing_s_field_types[] = 'TITLE'; } if (strlen($HTTP_VARS['s_field_type']['STATUSCMNT']) == 0 || !is_exists_attribute_type($HTTP_VARS['s_field_type']['STATUSCMNT'])) { $missing_s_field_types[] = 'STATUSCMNT'; } if (strlen($HTTP_VARS['s_field_type']['STATUSTYPE']) == 0 || !is_exists_attribute_type($HTTP_VARS['s_field_type']['STATUSTYPE'])) { $missing_s_field_types[] = 'STATUSTYPE'; } if (strlen($HTTP_VARS['s_field_type']['CATEGORY']) == 0 || !is_exists_attribute_type($HTTP_VARS['s_field_type']['CATEGORY'])) { $missing_s_field_types[] = 'CATEGORY'; } if (get_opendb_config_var('borrow', 'enable') !== FALSE && get_opendb_config_var('borrow', 'duration_support') !== FALSE && (strlen($HTTP_VARS['s_field_type']['DURATION']) == 0 || !is_exists_attribute_type($HTTP_VARS['s_field_type']['DURATION']))) { $missing_s_field_types[] = 'DURATION'; } if (is_empty_array($missing_s_field_types)) { if (insert_s_item_type($HTTP_VARS['s_item_type'], $HTTP_VARS['order_no'], $HTTP_VARS['description'], $HTTP_VARS['image'])) { //Insert required system s_attribute_type's. insert_s_item_attribute_type($HTTP_VARS['s_item_type'], $HTTP_VARS['s_field_type']['TITLE'], '1', NULL, 'N', 'Y', 'N', 'N'); insert_s_item_attribute_type($HTTP_VARS['s_item_type'], $HTTP_VARS['s_field_type']['CATEGORY'], '10', NULL, 'N', 'N', 'N', 'N'); if (get_opendb_config_var('borrow', 'enable') !== FALSE && get_opendb_config_var('borrow', 'duration_support') !== FALSE) { insert_s_item_attribute_type($HTTP_VARS['s_item_type'], $HTTP_VARS['s_field_type']['DURATION'], '200', NULL, 'N', 'N', 'N', 'N'); } insert_s_item_attribute_type($HTTP_VARS['s_item_type'], $HTTP_VARS['s_field_type']['STATUSTYPE'], '254', NULL, 'N', 'N', 'N', 'N'); insert_s_item_attribute_type($HTTP_VARS['s_item_type'], $HTTP_VARS['s_field_type']['STATUSCMNT'], '255', NULL, 'N', 'N', 'N', 'N'); // Load the edit_types form now. $HTTP_VARS['op'] = 'edit_types'; } else {