Check all active modules with one event socket request

This makes the modules page lighter on resources and load much faster.
This commit is contained in:
FusionPBX 2023-09-28 10:48:36 -06:00 committed by GitHub
parent 434b691883
commit 3c170f8597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 11 deletions

View File

@ -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');