From 00b871df5c5521194f4e7f99e0896d5d1c3029de Mon Sep 17 00:00:00 2001 From: m Date: Sat, 14 Apr 2018 08:48:24 +0200 Subject: [PATCH] =?UTF-8?q?nettoyage=20du=20sondage=20de=20d=C3=A9monstrat?= =?UTF-8?q?ion=20https://framagit.org/framasoft/framadate/issues/316?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/classes/Framadate/Services/PurgeService.php | 5 +++++ create_classic_poll.php | 3 +-- create_date_poll.php | 3 +-- index.php | 9 +++++++-- tpl/admin/config.tpl | 7 +++++++ tpl/index.tpl | 4 ++-- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/classes/Framadate/Services/PurgeService.php b/app/classes/Framadate/Services/PurgeService.php index 2d92233..e0a4aa7 100644 --- a/app/classes/Framadate/Services/PurgeService.php +++ b/app/classes/Framadate/Services/PurgeService.php @@ -23,6 +23,11 @@ class PurgeService { $this->commentRepository = RepositoryFactory::commentRepository(); } + public function repeatedCleanings() { + $this->purgeOldPolls(); + $this->cleanDemoPoll(); + } + /** * This methode purges all old polls (the ones with end_date in past). * diff --git a/create_classic_poll.php b/create_classic_poll.php index 920b0ae..193b7c8 100644 --- a/create_classic_poll.php +++ b/create_classic_poll.php @@ -107,8 +107,7 @@ if (empty($_SESSION['form']->title) || empty($_SESSION['form']->admin_name) || ( // Clean Form data in $_SESSION unset($_SESSION['form']); - // Delete old polls - $purgeService->purgeOldPolls(); + $purgeService->repeatedCleanings(); // creation message $sessionService->set("Framadate", "messagePollCreated", TRUE); diff --git a/create_date_poll.php b/create_date_poll.php index a66330d..69a5b93 100644 --- a/create_date_poll.php +++ b/create_date_poll.php @@ -231,8 +231,7 @@ switch ($step) { // Clean Form data in $_SESSION unset($_SESSION['form']); - // Delete old polls - $purgeService->purgeOldPolls(); + $purgeService->repeatedCleanings(); // creation message $sessionService->set("Framadate", "messagePollCreated", TRUE); diff --git a/index.php b/index.php index 0052b98..4782288 100644 --- a/index.php +++ b/index.php @@ -35,14 +35,19 @@ $pollService = new PollService($connect, new $logService()); /* PAGE */ /* ---- */ -$demoPoll = $pollService->findById('aqg259dth55iuhwm'); +$demoPollURL = ""; + +if (defined("DEMO_POLL_ID")) { + $demoPollURL = Utils::getUrlSondage(DEMO_POLL_ID); +} + $nbcol = max( $config['show_what_is_that'] + $config['show_the_software'] + $config['show_cultivate_your_garden'], 1 ); $smarty->assign('show_what_is_that', $config['show_what_is_that']); $smarty->assign('show_the_software', $config['show_the_software']); $smarty->assign('show_cultivate_your_garden', $config['show_cultivate_your_garden']); $smarty->assign('col_size', 12 / $nbcol); -$smarty->assign('demo_poll', $demoPoll); +$smarty->assign('demo_poll_url', $demoPollURL); $smarty->assign('title', __('Generic', 'Make your polls')); diff --git a/tpl/admin/config.tpl b/tpl/admin/config.tpl index b0ae98f..e3b22c0 100644 --- a/tpl/admin/config.tpl +++ b/tpl/admin/config.tpl @@ -82,6 +82,13 @@ const MAX_SLOTS_PER_POLL = 366; // Number of seconds before we allow to resend an "Remember Edit Link" email. const TIME_EDIT_LINK_EMAIL = 60; +// uncomment to display a link to the demo poll at the home page +//const DEMO_POLL_ID = "aqg259dth55iuhwm"; + +// number of recent votes that are not deleted +const DEMO_POLL_NUMBER_VOTES = 10; + + // Config $config = [ /* general config */ diff --git a/tpl/index.tpl b/tpl/index.tpl index 2524f1f..1d3bafd 100644 --- a/tpl/index.tpl +++ b/tpl/index.tpl @@ -58,10 +58,10 @@
  • {__('1st section', 'Discuss and make a decision')}
  • - {if $demo_poll != null} + {if $demo_poll_url}

    {__('1st section', 'Do you want to')} - {__('1st section', 'view an example?')} + {__('1st section', 'view an example?')}

    {/if}