name = 'Configuration'; } public function defaultTask() { $this->layout = 'default'; $data = []; ConfigurationService::prepareTableSelect($data); ConfigurationService::prepareConditionSelect($data); $this->prepareExecutionSelect($data); $this->prepareCurrentConfig($data); $data['tables_filters'] = [ 'cms' => [ 'values' => [], 'text' => 'CMS', ], ]; $this->prepareCmsGroupFilter($data); if ($this->isAcymailingInstalled) { $data['tables_filters']['acymailing'] = [ 'values' => [], 'text' => 'AcyMailing', ]; $this->prepareAcyMailingListFilter($data); } $this->breadcrumb[__('Clean my database', 'acychecker')] = Url::completeLink('configuration'); $this->display($data); } private function prepareExecutionSelect(&$data) { $data['execution_select'] = [ [ 'value' => 'now', 'text' => __('Right now', 'acychecker'), ], [ 'value' => 'week', 'text' => __('Every week', 'acychecker'), ], [ 'value' => 'month', 'text' => __('Every month', 'acychecker'), ], ]; } private function prepareCmsGroupFilter(&$data) { $cmsGroups = User::getGroups(); foreach ($cmsGroups as $group) { $data['tables_filters']['cms']['values'][$group->id] = $group->text; } } private function prepareAcyMailingListFilter(&$data) { if ($this->isAcymailingInstalled) { $acymailingListClass = new AcymailingListClass(); $data['tables_filters']['acymailing']['values'] = $acymailingListClass->getAllListsForSelect(); } } private function prepareCurrentConfig(&$data) { $currentConfig = []; $currentConfig['tables_selected'] = $this->config->get('tables_selected', []); if (!empty($currentConfig['tables_selected'])) $currentConfig['tables_selected'] = explode(',', $currentConfig['tables_selected']); $currentConfig['table_filter_cms'] = $this->config->get('table_filter_cms', []); if (!empty($currentConfig['table_filter_cms'])) $currentConfig['table_filter_cms'] = explode(',', $currentConfig['table_filter_cms']); $currentConfig['table_filter_acymailing'] = $this->config->get('table_filter_acymailing', []); if (!empty($currentConfig['table_filter_acymailing'])) $currentConfig['table_filter_acymailing'] = explode(',', $currentConfig['table_filter_acymailing']); $currentConfig['conditions_selected'] = $this->config->get('conditions_selected', []); if (!empty($currentConfig['conditions_selected'])) $currentConfig['conditions_selected'] = explode(',', $currentConfig['conditions_selected']); $currentConfig['execution_selected'] = $this->config->get('execution_selected', 'week'); $data['current_config'] = $currentConfig; } protected function store() { $config = Security::getVar('array', 'acyc_config'); $this->config->save($config); } public function save() { $this->store(); $this->defaultTask(); } public function process() { $this->store(); $cronService = new CronService(); $cronService->processBatches(); $this->defaultTask(); } }