Module Error on Save when Deployed

I have two modules that I have created that work together: Products & Categories. They work wonderfully when developing locally, but when I deployed them to my Network Solutions hosting I now get "internal error or misconfiguration" errors. All other pages on the site work fine except for the modules. I'm pretty clueless as to what is causing this, any ideas. Screenshot Below:
image

--categories_model.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once(FUEL_PATH.'models/base_module_model.php');

class Categories_model extends Base_module_model {

public $record_class = 'Category';

function __construct()
{
parent::__construct('categories');
}


// cleanup category to products
function on_after_delete($where)
{
$this->delete_related('categories_to_products_model', 'category_id', $where);
}

// add unique name validation
function on_before_validate($values)
{
if (!empty($values['id']))
{
$this->add_validation('name', array(&$this, 'is_editable'), lang('error_val_empty_or_already_exists', lang('form_label_name')), array('name', $values['id']));
}
else
{
$this->add_validation('name', array(&$this, 'is_new'), lang('error_val_empty_or_already_exists', lang('form_label_name')), 'name');
}
return $values;
}

function does_category_match($category) {
$categories = $this->find_all();

foreach($categories as $cat){
if ($cat->name == $category)
{
return true;
}
}
//If none returned true, then return false
return false;
}

}

class Category_model extends Base_module_record {

function get_products()
{
$this->_CI->load->model('categories_to_products_model');
$where = array('category_id' => $this->id, 'products.published' => 'yes');
$products = $this->_CI->categories_to_products_model->find_all($where, "precedence asc");
return $products;
}
}

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');


--categories_to_products_model.php
class Categories_to_products_model extends MY_Model {

public $record_class = 'Category_to_product';
public $foreign_keys = array('category_id' => 'categories_model', 'product_id' => 'products_model');

function __construct()
{
parent::__construct('categories_to_products');
}

function _common_query()
{
$this->db->select('categories_to_products.*, products.*');
$this->db->join('products', 'categories_to_products.product_id = products.id', 'left');
$this->db->join('categories', 'categories_to_products.category_id = categories.id', 'left');
}

}

class Category_to_product_model extends Data_record {
public $category_name = '';
public $title = '';
}

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once(FUEL_PATH.'models/base_module_model.php');


--products_model.php
class Products_model extends Base_module_model {

public $required = array();

function __construct()
{
parent::__construct('products'); // table name
}

function list_items($limit = NULL, $offset = NULL, $col = '', $order = 'desc')
{
$this->db->select('products.id, title, SUBSTRING(description, 1, 50) AS description, products.published, products.precedence', FALSE);
$data = parent::list_items($limit, $offset, $col, $order);
return $data;
}

function tree()
{
$CI =& get_instance();
$CI->load->model('categories_model');
$CI->load->model('categories_to_products_model');

$return = array();
$categories = $CI->categories_model->find_all(array(), 'id asc');
$categories_to_products = $CI->categories_to_products_model->find_all('', 'categories.name asc');
foreach($categories as $category)
{
$cat_id = $category->id;
$return[] = array('id' => $category->id, 'label' => $category->name, 'parent_id' => 0, 'location' => fuel_url('categories/edit/'.$category->id));
}
$i = $cat_id +1;

foreach($categories_to_products as $val)
{
$attributes = ($val->published == 'no') ? array('class' => 'unpublished', 'title' => 'unpublished') : NULL;
$return[$i] = array('id' => $i, 'label' => $val->title, 'parent_id' => $val->category_id, 'location' => fuel_url('products/edit/'.$val->product_id), 'attributes' => $attributes);
$i++;
}
return $return;
}

function form_fields($values = array())
{
$fields = parent::form_fields();
$CI =& get_instance();
$CI->load->model('categories_model');
$CI->load->model('categories_to_products_model');

$category_options = $CI->categories_model->options_list('id', 'name', array('published' => 'yes'), 'name');
$category_values = (!empty($values['id'])) ? array_keys($CI->categories_to_products_model->find_all_array_assoc('category_id', array('product_id' => $values['id'], 'categories.published' => 'yes'))) : array();
$fields['categories'] = array('label' => 'Categories', 'type' => 'array', 'class' => 'add_edit categories', 'options' => $category_options, 'value' => $category_values, 'mode' => 'multi');

$fields['product_image_upload']['upload_path'] = assets_server_path('products/', 'images');
$fields['nutrition_label_image_upload']['upload_path'] = assets_server_path('nutrition/', 'images');

return $fields;
}

// add categories
function on_after_save($values)
{
$data = (!empty($this->normalized_save_data['categories'])) ? $this->normalized_save_data['categories'] : array();
$this->save_related('categories_to_products_model', array('product_id' => $values['id']), array('category_id' => $data));
}

// cleanup products from categories to products table
function on_after_delete($where)
{
$this->delete_related('categories_to_products_model', 'product_id', $where);
}

function on_after_post($values)
{
$CI =& get_instance();
$CI->load->library('image_lib');

// resize if an image is uploaded
if (!empty($CI->upload))
{
$data = $CI->upload->data();
if (!empty($data['full_path']))
{
// resize to proper dimensions
$config = array();
$config['source_image'] = $data['full_path'];
$config['create_thumb'] = FALSE;
//$config['new_image'] = $thumb_img;
$config['width'] = 960;
$config['height'] = 100000;
$config['master_dim'] = 'width';
$config['maintain_ratio'] = TRUE;
$CI->image_lib->clear();
$CI->image_lib->initialize($config);
if (!$CI->image_lib->resize())
{
$this->add_error($CI->image_lib->display_errors());
}
}
}
return $values;
}

}

class Product_model extends Data_record {
}
?>

Thank you for your help,
Brandon Boswell

Comments

  • Do you get this error only when you save something or do you get it as soon as you click on the products module?
  • I do sometimes get this error when just opening the products module, but this does not occur every time.
  • edited 2:35PM
    The list area is AJAXed in which is why you see the error displayed in that way (as opposed to the whole page). We've had problems with Network Solutions in the past, regarding .htaccess, but don't remember anything quite like what you have. Regardless, I would look at your htaccess file. Here is an article I found regarding a similar situation:
    http://www.mainelydesign.com/blog/view/network-solutions-htaccess-mod_rewrite-rewriterule-flawed
  • Hosting on Network Solutions has been a nightmare, I'll see if I can get my client to switch. I haven't had any of these issues on other hosting providers I've tried.
Sign In or Register to comment.