From a776d941b20d53ea336519428598b24edfd5dd52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5nis=20Ormisson?= Date: Tue, 22 Jan 2019 17:14:59 +0200 Subject: [PATCH] New feature: Warn when activating a survey that is expired by config (#1207) --- application/models/Survey.php | 18 ++++++++++++++++++ .../views/admin/survey/activateSurvey_view.php | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/application/models/Survey.php b/application/models/Survey.php index 52233fb4d4e..d5aa182a3ac 100755 --- a/application/models/Survey.php +++ b/application/models/Survey.php @@ -145,6 +145,7 @@ * @property bool $isNoKeyboard Show on-screen keyboard * @property bool $isAllowEditAfterCompletion Allow multiple responses or update responses with one token * @property SurveyLanguageSetting $defaultlanguage + * @property boolean $isDateExpired Whether survey is expired depending on the current time and survey configuration status * @method mixed active() */ class Survey extends LSActiveRecord @@ -1162,6 +1163,23 @@ public function getState() } } + /** + * @return bool + * @throws Exception + */ + public function getIsDateExpired() + { + if (!empty($this->expires)) { + $sNow = date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime(date("Y-m-d H:i:s")))); + $sStop = ($this->expires != '') ? date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime($this->expires))) : $sNow; + + $oNow = new DateTime($sNow); + $oStop = new DateTime($sStop); + return $oStop < $oNow; + } + return false; + } + /** * @todo Document code, please. diff --git a/application/views/admin/survey/activateSurvey_view.php b/application/views/admin/survey/activateSurvey_view.php index 850f2938b3a..bcc3ac0ce0d 100644 --- a/application/views/admin/survey/activateSurvey_view.php +++ b/application/views/admin/survey/activateSurvey_view.php @@ -1,3 +1,7 @@ +
@@ -218,6 +222,15 @@ function alertPrivacy()



+ getIsDateExpired()):?> +
+
+ +
+
+ +
+