Skip to content

Commit

Permalink
add dedicated fetch method
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu-rolland committed Oct 5, 2022
1 parent a976e57 commit 310da3c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
12 changes: 12 additions & 0 deletions classes/module/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,18 @@ public static function getModulesInstalled($position = 0)
return Db::getInstance()->executeS($sql);
}

/**
* Return modules that are installed AND enabled
*
* @return array Modules
*/
public static function getModulesInstalledAndEnabled()
{
$sql = 'SELECT m.* FROM `' . _DB_PREFIX_ . 'module` m WHERE `active` = 1';

return Db::getInstance()->executeS($sql);
}

/**
* Returns the list of the payment module associated to the current customer.
*
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ protected function formatCategoryDiscountList($id_group)

public function formatModuleListAuth($id_group)
{
$modules = Module::getModulesInstalled();
$modules = Module::getModulesInstalledAndEnabled();
$authorized_modules = '';

$auth_modules = [];
Expand Down
10 changes: 10 additions & 0 deletions src/Adapter/Module/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ public function getModulesInstalled($position = 0)
return LegacyModule::getModulesInstalled((int) $position);
}

/**
* Return modules that are installed AND enabled
*
* @return array Modules
*/
public function getModulesInstalledAndEnabled()
{
return LegacyModule::getModulesInstalledAndEnabled();
}

/**
* Return an instance of the specified module.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function indexAction(Request $request)

$moduleAdapter = $this->get('prestashop.adapter.legacy.module');
$hookProvider = $this->get('prestashop.adapter.legacy.hook');
$installedModules = $moduleAdapter->getModulesInstalled();
$installedModules = $moduleAdapter->getModulesInstalledAndEnabled();

$selectedModule = $request->get('show_modules');
if ($selectedModule && (string) $selectedModule != 'all') {
Expand All @@ -83,7 +83,7 @@ public function indexAction(Request $request)

$modules = [];
foreach ($installedModules as $installedModule) {
if ($installedModule['active'] && $module = $moduleAdapter->getInstanceById($installedModule['id_module'])) {
if ($module = $moduleAdapter->getInstanceById($installedModule['id_module'])) {
// We want to be able to sort modules by display name
$modules[(int) $module->id] = $module;
}
Expand Down

0 comments on commit 310da3c

Please sign in to comment.