/** * @param int $id * * @return array * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id) { $comments = $this->commentRepository->getAllByModuleInAcp($id); if (empty($comments) === false) { $moduleName = $this->systemModuleRepository->getModuleNameById($id); $this->breadcrumb->append($this->translator->t($moduleName, $moduleName)); /** @var Core\Helpers\DataGrid $dataGrid */ $dataGrid = $this->get('core.helpers.data_grid'); $dataGrid->setResults($comments)->setRecordsPerPage($this->resultsPerPage->getResultsPerPage(Schema::MODULE_NAME))->setIdentifier('#acp-table')->setResourcePathDelete('admin/comments/details/delete/id_' . $id)->setResourcePathEdit('admin/comments/details/edit'); $this->addDataGridColumns($dataGrid); return ['grid' => $dataGrid->render(), 'module_id' => $id, 'show_mass_delete_button' => $dataGrid->countDbResults() > 0]; } throw new Core\Controller\Exception\ResultNotExistsException(); }
/** * Saves the module's settings to the database * * @param array $data * @param string $module * * @return bool */ public function saveSettings($data, $module) { $bool = $bool2 = false; $moduleId = $this->systemModuleRepository->getModuleId($module); if (!empty($moduleId)) { $this->eventDispatcher->dispatch('core.settings.save_before', new SettingsSaveEvent($module, $data)); foreach ($data as $key => $value) { $updateValues = ['value' => $value]; $where = ['module_id' => $moduleId, 'name' => $key]; $bool = $this->systemSettingsRepository->update($updateValues, $where); } $bool2 = $this->saveCache(); } return $bool !== false && $bool2 !== false; }
/** * @param string $moduleDirectory * * @return array */ protected function fetchModuleInfo($moduleDirectory) { $vendors = array_reverse($this->vendors->getVendors()); // Reverse the order of the array -> search module customizations first, then 3rd party modules, then core modules foreach ($vendors as $vendor) { $path = $this->appPath->getModulesDir() . $vendor . '/' . $moduleDirectory . '/Resources/config/module.xml'; if (is_file($path) === true) { $moduleInfo = $this->xml->parseXmlFile($path, 'info'); if (!empty($moduleInfo)) { $moduleName = strtolower($moduleDirectory); $moduleInfoDb = $this->systemModuleRepository->getInfoByModuleName($moduleName); return ['id' => !empty($moduleInfoDb) ? $moduleInfoDb['id'] : 0, 'dir' => $moduleDirectory, 'installed' => !empty($moduleInfoDb), 'active' => !empty($moduleInfoDb) && $moduleInfoDb['active'] == 1, 'schema_version' => !empty($moduleInfoDb) ? (int) $moduleInfoDb['version'] : 0, 'description' => $this->getModuleDescription($moduleInfo, $moduleName), 'author' => $moduleInfo['author'], 'version' => $moduleInfo['version'], 'name' => $this->getModuleName($moduleInfo, $moduleName), 'categories' => isset($moduleInfo['categories']), 'protected' => isset($moduleInfo['protected']), 'dependencies' => $this->getModuleDependencies($path)]; } } } return []; }
/** * @param string $moduleName * * @return boolean */ public function moduleIsInstalled($moduleName) { return $this->db->fetchColumn("SELECT COUNT(*) FROM {$this->systemModuleRepository->getTableName()} WHERE `name` = ?", [$moduleName]) == 1; }