aboutsummaryrefslogtreecommitdiffstats
path: root/public/admin/model/setting/module.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/admin/model/setting/module.php')
-rw-r--r--public/admin/model/setting/module.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/public/admin/model/setting/module.php b/public/admin/model/setting/module.php
new file mode 100644
index 0000000..c05b53a
--- /dev/null
+++ b/public/admin/model/setting/module.php
@@ -0,0 +1,42 @@
+<?php
+class ModelSettingModule extends Model {
+ public function addModule($code, $data) {
+ $this->db->query("INSERT INTO `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($data['name']) . "', `code` = '" . $this->db->escape($code) . "', `setting` = '" . $this->db->escape(json_encode($data)) . "'");
+ }
+
+ public function editModule($module_id, $data) {
+ $this->db->query("UPDATE `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($data['name']) . "', `setting` = '" . $this->db->escape(json_encode($data)) . "' WHERE `module_id` = '" . (int)$module_id . "'");
+ }
+
+ public function deleteModule($module_id) {
+ $this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE `module_id` = '" . (int)$module_id . "'");
+ $this->db->query("DELETE FROM `" . DB_PREFIX . "layout_module` WHERE `code` LIKE '%." . (int)$module_id . "'");
+ }
+
+ public function getModule($module_id) {
+ $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` WHERE `module_id` = '" . (int)$module_id . "'");
+
+ if ($query->row) {
+ return json_decode($query->row['setting'], true);
+ } else {
+ return array();
+ }
+ }
+
+ public function getModules() {
+ $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` ORDER BY `code`");
+
+ return $query->rows;
+ }
+
+ public function getModulesByCode($code) {
+ $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` WHERE `code` = '" . $this->db->escape($code) . "' ORDER BY `name`");
+
+ return $query->rows;
+ }
+
+ public function deleteModulesByCode($code) {
+ $this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE `code` = '" . $this->db->escape($code) . "'");
+ $this->db->query("DELETE FROM `" . DB_PREFIX . "layout_module` WHERE `code` LIKE '" . $this->db->escape($code) . "' OR `code` LIKE '" . $this->db->escape($code . '.%') . "'");
+ }
+} \ No newline at end of file