Location: PHPKode > projects > HikaShop > back/classes/characteristic.php
<?php
/**
 * @package		HikaShop for Joomla!
 * @version		1.4.3
 * @author		hikashop.com
 * @copyright	(C) 2010 HIKARI SOFTWARE. All rights reserved.
 * @license		GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?>
<?php
class hikashopCharacteristicClass extends hikashopClass{
	var $tables = array('characteristic','characteristic');
	var $pkeys = array('characteristic_parent_id','characteristic_id');
	var $deleteToggle = array('variant'=>array('variant_characteristic_id','variant_product_id'));
	function saveForm(){
		$element = null;
		$element->characteristic_id = hikashop::getCID('characteristic_id');
		$formData = JRequest::getVar( 'data', array(), '', 'array' );
		foreach($formData['characteristic'] as $column => $value){
			hikashop::secureField($column);
			$element->$column = strip_tags($value);
		}
		$element->values = JRequest::getVar( 'characteristic', array(), '', 'array' );
		JArrayHelper::toInteger($element->values);
		$status = $this->save($element);
		if(!$status){
			JRequest::setVar( 'fail', $element  );
		}elseif(@$element->characteristic_parent_id==0){
			$this->updateValues($element,$status);
		}
		return $status;
	}
	function save(&$element){
		$class = hikashop::get('helper.translation');
		$class->getTranslations($element);
		$status = parent::save($element);
		if($status){
			$class->handleTranslations('characteristic',$status,$element);
		}
		return $status;
	}
	function updateValues(&$element,$status){
		$filter='';
		if(count($element->values)){
			$filter = ' AND characteristic_id NOT IN ('.implode(',',$element->values).')';
		}
		$query = 'DELETE FROM '.hikashop::table('characteristic').' WHERE characteristic_parent_id = '.$status.$filter;
		$this->database->setQuery($query);
		$this->database->query();
		if(count($element->values)){
			$query = 'UPDATE '.hikashop::table('characteristic').' SET characteristic_parent_id='.$status.' WHERE characteristic_id IN ('.implode(',',$element->values).') AND characteristic_parent_id<1';
			$this->database->setQuery($query);
			$this->database->query();
		}
	}
}
	
Return current item: HikaShop