db = PearDatabase::getInstance(); $self->setModuleName($module); $self->retrieveData(); return $self; } public static function isInstalled() { $adb = PearDatabase::getInstance(); $result = $adb->query('SELECT * FROM its4you_reminder_settings'); return $adb->num_rows($result); } /** * @throws Exception */ public function retrieveData() { $result = $this->db->pquery('SELECT * FROM its4you_reminder_settings WHERE module_name=?', array($this->getModuleName())); $row = $this->db->query_result_rowdata($result); $this->setData($row); $this->set('module_name', $this->getModuleName()); } /** * @return string */ public function getModuleName() { return $this->moduleName; } /** * @param string $value */ public function setModuleName($value) { $this->moduleName = $value; } public function save() { $params = array($this->get('module_name'), $this->get('active')); if (!$this->isEmpty('id')) { array_push($params, $this->get('id')); $this->db->pquery('UPDATE its4you_reminder_settings SET module_name=?,active=? WHERE id=?', $params); } else { $this->db->pquery('INSERT INTO its4you_reminder_settings (module_name, active) VALUES (?,?)', $params); } } public static $activeModules = []; public static function getActiveModules() { if (empty(self::$activeModules)) { $adb = PearDatabase::getInstance(); $result = $adb->pquery('SELECT module_name FROM its4you_reminder_settings WHERE active=?', array('1') ); while ($row = $adb->fetchByAssoc($result)) { self::$activeModules[] = $row['module_name']; } } return self::$activeModules; } }