public function saveForm() { $serial = new stdClass(); $serial->serial_id = hikaserial::getCID('serial_id'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['serial'] as $col => $val) { hikaserial::secureField($col); if (is_array($val) || is_object($val)) { continue; } $serial->{$col} = strip_tags($val); } if (!empty($formData['serial']['serial_extradata'])) { $serial->serial_extradata = $formData['serial']['serial_extradata']; } else { $isExtraData = JRequest::getInt('hikaserial_extradata', 0); if ($isExtraData) { $serial->serial_extradata = ''; } } JPluginHelper::importPlugin('hikashop'); JPluginHelper::importPlugin('hikaserial'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeSerialSave', array(&$serial)); $status = $this->save($serial); if ($status) { $productClass = hikaserial::get('class.product'); $productClass->refreshQuantities(); } return $status; }
public function saveForm() { $pack = new stdClass(); $pack->pack_id = hikaserial::getCID('pack_id'); $formData = JRequest::getVar('data', array(), '', 'array'); foreach ($formData['pack'] as $col => $val) { hikaserial::secureField($col); $pack->{$col} = strip_tags($val); } $pack->pack_params = null; if (!empty($formData['pack_params'])) { $pack->pack_params = new stdClass(); foreach ($formData['pack_params'] as $k => $v) { hikaserial::secureField($k); $pack->pack_params->{$k} = $v; } } $pack->pack_description = JRequest::getVar('pack_description', '', '', 'string', JREQUEST_ALLOWRAW); $status = $this->save($pack); if ($status) { } return $status; }
public function store() { $this->plugin = JRequest::getCmd('name', ''); $this->plugin_type = JRequest::getCmd('plugin_type', 'generator'); if (empty($this->plugin) || !in_array($this->plugin_type, array('generator', 'consumer', 'plugin'))) { return false; } $data = hikaserial::import('hikaserial', $this->plugin); $element = new stdClass(); $id = hikaserial::getCID($this->plugin_type . '_id'); $formData = JRequest::getVar('data', array(), '', 'array'); $params_name = $this->plugin_type . '_params'; if (!empty($formData[$this->plugin_type])) { $element = new stdClass(); $plugin_id = $this->plugin_type . '_id'; $element->{$plugin_id} = $id; foreach ($formData[$this->plugin_type] as $column => $value) { hikaserial::secureField($column); if (is_array($value)) { if ($column == $params_name) { $element->{$params_name} = new stdClass(); foreach ($formData[$this->plugin_type][$column] as $key => $val) { hikaserial::secureField($key); if (!is_array($val)) { $element->{$params_name}->{$key} = strip_tags($val); } else { $element->{$params_name}->{$key} = $val; } } } } else { $element->{$column} = strip_tags($value); } } $plugin_description = $this->plugin_type . '_description'; $plugin_description_data = JRequest::getVar($plugin_description, '', '', 'string', JREQUEST_ALLOWRAW); $element->{$plugin_description} = $plugin_description_data; } $function = 'on' . ucfirst($this->plugin_type) . 'ConfigurationSave'; if (method_exists($data, $function)) { $data->{$function}($element); } if (!empty($element)) { $pluginClass = hikaserial::get('class.' . $this->plugin_type); if (isset($element->{$params_name})) { $element->{$params_name} = serialize($element->{$params_name}); } $status = $pluginClass->save($element); if (!$status) { JRequest::setVar('fail', $element); } else { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('HIKASHOP_SUCC_SAVED'), 'message'); if (empty($id)) { JRequest::setVar($this->plugin_type . '_id', $status); } } } }