public function set() { if (!$this->user->hasPermission('modify', 'module/journal2')) { throw new Exception('You do not have permissions to modify Journal2 module'); } if (!isset($this->post_data['value'])) { throw new Exception('Parameter value was not found'); } $value = $this->post_data['value']; if (!isset($this->get_data['key'])) { throw new Exception('Parameter key was not found'); } $key = $this->get_data['key']; if (!isset($this->get_data['store_id'])) { $store_id = 0; } else { $store_id = $this->get_data['store_id']; } if (is_scalar($value)) { $json_encoded = 0; } else { $value = json_encode($value); $json_encoded = 1; } $this->db->query('INSERT INTO ' . DB_PREFIX . 'journal2_config (`key`, `store_id`, `value`, `serialized`) VALUES ("' . $this->db->escape($key) . '", "' . (int) $store_id . '", "' . $this->db->escape($value) . '", "' . $json_encoded . '") ON DUPLICATE KEY UPDATE `value` = "' . $this->db->escape($value) . '", `serialized` = "' . $json_encoded . '"'); Journal2Cache::deleteModuleCache("config_{$key}"); return null; }
public function save() { if (!$this->user->hasPermission('modify', 'module/journal2')) { throw new Exception('You do not have permissions to modify Journal2 module'); } if (!isset($this->get_data['module_type'])) { throw new Exception('Parameter module_type was not found'); } if (!isset($this->post_data['module_data'])) { throw new Exception('Parameter module_data was not found'); } $module_type = 'journal2_' . $this->get_data['module_type']; $module_data = $this->post_data['module_data']; if (Front::$IS_OC2) { $this->db->query('DELETE FROM ' . DB_PREFIX . 'layout_module WHERE `code` LIKE "' . $this->db->escape($module_type) . '%"'); $this->db->query('DELETE FROM ' . DB_PREFIX . 'setting WHERE `code` LIKE "' . $this->db->escape($module_type) . '"'); foreach ($module_data as $module) { $this->db->query('INSERT INTO ' . DB_PREFIX . 'layout_module (`layout_id`, `code`, `position`, `sort_order`) VALUES (' . (int) $module['layout_id'] . ', "' . $this->db->escape($module_type . '.' . (int) $module['module_id']) . '", "' . $this->db->escape($module['position']) . '", ' . (int) $module['sort_order'] . ')'); $this->db->query('INSERT INTO ' . DB_PREFIX . 'setting (`code`, `key`, `value`, `serialized`) VALUES ("' . $this->db->escape($module_type) . '", "' . $this->db->escape($module_type . '_' . (int) $this->db->getLastId() . '_status') . '", "' . (int) $module['status'] . '", 0)'); } } else { $this->load->model('setting/extension'); $this->load->model('setting/setting'); $this->model_setting_extension->uninstallJ2Extension('module', $module_type); $this->model_setting_extension->install('module', $module_type); $this->model_setting_setting->editSetting($module_type, array($module_type . '_module' => $module_data)); } Journal2Cache::deleteModuleCache("module_journal_{$this->get_data['module_type']}"); return null; }