diff --git a/app/modules/resources/classes/modules.php b/app/modules/resources/classes/modules.php index 114e00afdd..de5f774974 100644 --- a/app/modules/resources/classes/modules.php +++ b/app/modules/resources/classes/modules.php @@ -47,6 +47,7 @@ if (!class_exists('modules')) { private $uuid_prefix; private $toggle_field; private $toggle_values; + private $active_modules; /** * called when the object is created @@ -63,6 +64,11 @@ if (!class_exists('modules')) { $this->toggle_field = 'module_enabled'; $this->toggle_values = ['true','false']; + //get the list of active modules + $this->fp = event_socket_create(); + $cmd = "api show modules as json"; + $json = event_socket_request($this->fp, $cmd); + $this->active_modules = json_decode($json, true); } //get the additional information about a specific module @@ -681,22 +687,17 @@ if (!class_exists('modules')) { //check the status of the module public function active($name) { - if (!$this->fp) { - $this->fp = event_socket_create(); - } - if ($this->fp) { - $cmd = "api module_exists ".$name; - $response = trim(event_socket_request($this->fp, $cmd)); - return $response == "true" ? true : false; - } - else { - return false; + foreach ($this->active_modules['rows'] as $row) { + if ($row['ikey'] === $name) { + return true; + } } + return false; } //get the list of modules public function get_modules() { - $sql = " select * from v_modules "; + $sql = "select * from v_modules "; $sql .= "order by module_category, module_label"; $database = new database; $this->modules = $database->select($sql, null, 'all');