public function post() { $data = $this->get_posted_data(); $field_id = $this->request->param('awpcp_extra_field_id'); if (!empty($field_id)) { $previous_field = awpcp_get_extra_field($field_id); } else { $previous_field = null; } try { // TODO: do not return output, render it // The above is not currently possible, because the whole admin section is // being handled in a single function. That code needs to be converted into // a page class. return $this->save_field_data($data, $previous_field); } catch (AWPCP_Exception $e) { $output = load_the_extra_fields_form($previous_field ? $previous_field->field_id : 0, $data['field_name'], $data['field_label'], $data['field_label_view'], $data['field_input_type'], $data['field_mysql_data_type'], $data['field_options'], $data['field_validation'], $data['field_privacy'], $data['field_category'], $e->getMessage(), $data['nosearch'], $data['show_on_listings'], $data['required']); throw new AWPCP_Exception($output); } }
/** * @deprecated 3.4.1 */ function awpcp_extra_fields_get_next_field($field) { _deprecated_function(__FUNCTION__, '3.4.1', 'AWPCP_FormFields::get_fields_order'); global $wpdb; $query = 'SELECT field_id FROM ' . AWPCP_TABLE_EXTRA_FIELDS . ' '; $query .= 'WHERE weight > %d ORDER BY weight ASC, field_id ASC LIMIT 0, 1'; $query = $wpdb->prepare($query, $field->weight); $results = $wpdb->get_row($query); if (count($results) > 0) { return awpcp_get_extra_field($results->field_id); } return null; }