shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

module.php (1877B)


      1 <?php
      2 class ModelSettingModule extends Model {
      3 	public function addModule($code, $data) {
      4 		$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)) . "'");
      5 	}
      6 	
      7 	public function editModule($module_id, $data) {
      8 		$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 . "'");
      9 	}
     10 
     11 	public function deleteModule($module_id) {
     12 		$this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE `module_id` = '" . (int)$module_id . "'");
     13 		$this->db->query("DELETE FROM `" . DB_PREFIX . "layout_module` WHERE `code` LIKE '%." . (int)$module_id . "'");
     14 	}
     15 		
     16 	public function getModule($module_id) {
     17 		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` WHERE `module_id` = '" . (int)$module_id . "'");
     18 
     19 		if ($query->row) {
     20 			return json_decode($query->row['setting'], true);
     21 		} else {
     22 			return array();
     23 		}
     24 	}
     25 	
     26 	public function getModules() {
     27 		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` ORDER BY `code`");
     28 
     29 		return $query->rows;
     30 	}	
     31 		
     32 	public function getModulesByCode($code) {
     33 		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` WHERE `code` = '" . $this->db->escape($code) . "' ORDER BY `name`");
     34 
     35 		return $query->rows;
     36 	}	
     37 	
     38 	public function deleteModulesByCode($code) {
     39 		$this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE `code` = '" . $this->db->escape($code) . "'");
     40 		$this->db->query("DELETE FROM `" . DB_PREFIX . "layout_module` WHERE `code` LIKE '" . $this->db->escape($code) . "' OR `code` LIKE '" . $this->db->escape($code . '.%') . "'");
     41 	}	
     42 }