auth->makePermissions([dcAuth::PERMISSION_USAGE, dcAuth::PERMISSION_CONTENT_ADMIN])); # Objects $per = new periodical(); # Default values $action = isset($_POST['action']) ? $_POST['action'] : ''; # Delete periods and related posts links if ($action == 'deleteperiods' && !empty($_POST['periods'])) { try { foreach($_POST['periods'] as $id) { $id = (integer) $id; $per->delPeriodPosts($id); $per->delPeriod($id); } dcAdminNotices::addSuccessNotice( __('Periods removed.') ); if (!empty($_POST['redir'])) { http::redirect($_POST['redir']); } else { dcCore::app()->adminurl->redirect('admin.plugin.periodical', ['part' => 'periods']); } } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } } # Delete periods related posts links (without delete periods) if ($action == 'emptyperiods' && !empty($_POST['periods'])) { try { foreach($_POST['periods'] as $id) { $id = (integer) $id; $per->delPeriodPosts($id); } dcAdminNotices::addSuccessNotice( __('Periods emptied.') ); if (!empty($_POST['redir'])) { http::redirect($_POST['redir']); } else { dcCore::app()->adminurl->redirect('admin.plugin.periodical', ['part' => 'periods']); } } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } } $combo_action = [ __('empty periods') => 'emptyperiods', __('delete periods') => 'deleteperiods' ]; # Filters $p_filter = new adminGenericFilter(dcCore::app(), 'periodical'); $p_filter->add('part', 'periods'); $params = $p_filter->params(); # Get periods try { $periods = $per->getPeriods($params); $counter = $per->getPeriods($params, true); $period_list = new adminPeriodicalList(dcCore::app(), $periods, $counter->f(0)); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } # Display echo '