0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
marketting
/
system
/
application
/
models
/
[
Home
]
File: forms_model.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* | ------------------------------------------------------------------------- | COPYRIGHT NOTICE | Copyright 2008 JROX Technologies, Inc. All Rights Reserved. | ------------------------------------------------------------------------- | This script may be only used and modified in accordance to the license | agreement attached (license.txt) except where expressly noted within | commented areas of the code body. This copyright notice and the | comments above and below must remain intact at all times. By using this | code you agree to indemnify JROX Technologies, Inc, its corporate agents | and affiliates from any liability that might arise from its use. | | Selling the code for this program without prior written consent is | expressly forbidden and in violation of Domestic and International | copyright laws. | | ------------------------------------------------------------------------- | FILENAME - forms_model.php | ------------------------------------------------------------------------- | | This model handles the functions for managing forms | */ class Forms_Model extends Model { function _show_field_name($name = '', $desc = '') { if (!empty($desc)) { return $desc; } return $this->lang->line($name); } // ------------------------------------------------------------------------ function _generate_form_values($id = '', $name = '', $value = '') { switch ($name) { case 'billing_country': case 'shipping_country': case 'payment_country': $value = !empty($value) ? $value : $this->config->item('sts_store_default_country'); return form_dropdown('form_field_values-' . $id, $this->config->item('country_options'), $value); break; default: return '<input name="form_field_values-' . $id . '" type="text" id="form_field_values-' . $id . '" value="' . $value . '" class="popup-form-input" />'; break; } } // ------------------------------------------------------------------------ function _get_forms($type = '', $status = '') { if (!empty($type)) { $this->db->where('form_type', $type); } if (!empty($status)) { $this->db->where('status', $status); } $this->db->order_by('sort_order', 'ASC'); $query = $this->db->get('form_fields'); if ($query->num_rows() > 0) { return $query->result_array(); } return false; } // ------------------------------------------------------------------------ function _update_forms() { //clean the data first $data = $this->db_validation_model->_clean_data($_POST); foreach ($data as $k => $v) { if (preg_match('/form_field_name-*/', $k)) { $array = explode('-', $k); $id = $array[1]; if (!empty($id)) { $sdata['form_field_description'] = empty($data['form_field_name-' . $id]) ? '' : $data['form_field_name-' . $id]; $sdata['sort_order'] = empty($data['sort_order-' . $id]) ? '' : $data['sort_order-' . $id]; $sdata['form_field_values'] = empty($data['form_field_values-' . $id]) ? '' : $data['form_field_values-' . $id]; if (!empty($data['form_field_required-' . $id])) { $sdata['form_field_required'] = $data['form_field_required-' . $id]; } else { $sdata['form_field_required'] = '0'; } if (!empty($data['status-' . $id])) { $sdata['status'] = $data['status-' . $id]; } else { $sdata['status'] = '0'; } //check if required, set status to 1 if ($sdata['status'] == 0) { $sdata['form_field_required'] = '0'; } //check form type if (!empty($data['form_field_type-' . $id])) { $sdata['form_field_type'] = $data['form_field_type-' . $id]; } //update the dd $this->db->where('ffid', $id); if (!$this->db->update('form_fields', $sdata)) { show_error($this->lang->line('could_not_update_form_fields')); //log error log_message('error', 'Could not update data in form_fields table'); } unset($array); } } } //update required form fields $cdata = array('form_field_required' => '1', 'status' => '1'); $this->db->where('form_field_name', 'fname'); $this->db->update('form_fields', $cdata); $this->db->where('form_field_name', 'primary_email'); $this->db->update('form_fields', $cdata); //make sure sort order is sequential $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'custom_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'custom_invoice_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'custom_commission_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'custom_payment_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'custom_contact_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'checkout_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'checkout_payment_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'checkout_shipping_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'registration_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'registration_payment_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'membership_fields\''); $this->db_validation_model->_db_sort_order('form_fields', 'ffid', 'sort_order', 'form_type = \'membership_payment_fields\''); return true; } // ------------------------------------------------------------------------ } ?>