From 0e9301112e4dba07ddc39ff497137990fa8e1976 Mon Sep 17 00:00:00 2001 From: Olle Harstedt Date: Thu, 28 Apr 2016 01:06:35 +0200 Subject: [PATCH] Dev: Add support for icon-class in extra menu --- application/models/Survey.php | 56 +++++++++++++++++++++ application/views/admin/super/adminmenu.php | 8 ++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/application/models/Survey.php b/application/models/Survey.php index 0181a08630b..978995db074 100644 --- a/application/models/Survey.php +++ b/application/models/Survey.php @@ -632,6 +632,62 @@ public function getActiveWord() return $activeword; } + /** + * Get state of survey, which can be one of five: + * 1. Not active + * 2. Expired + * 3. Will expire in the future (running now) + * 3. Will run in future + * 4. Running now (no expiration date) + * + * Code copied from getRunning below. + * + * @return string - 'inactive', 'expired', 'willRun', 'willExpire' or 'running' + */ + public function getState() + { + if($this->active == 'N') + { + return 'inactive'; + } + elseif ($this->expires != '' || $this->startdate != '') + { + // Time adjust + $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; + $sStart = ($this->startdate != '')?date("Y-m-d H:i:s", strtotime(Yii::app()->getConfig('timeadjust'), strtotime($this->startdate)) ):$sNow; + + // Time comparaison + $oNow = new DateTime($sNow); + $oStop = new DateTime($sStop); + $oStart = new DateTime($sStart); + + $bExpired = ($oStop < $oNow); + $bWillRun = ($oStart > $oNow); + + if ($bExpired) + { + return 'expired'; + } + elseif ($bWillRun) + { + return 'willRun'; + } + else + { + return 'willExpire'; + } + } + // If it's active, and doesn't have expire date, it's running + else + { + return 'running'; + } + } + + /** + * @todo Document code, please. + */ public function getRunning() { diff --git a/application/views/admin/super/adminmenu.php b/application/views/admin/super/adminmenu.php index 658a7d883f1..aa084f3ed08 100644 --- a/application/views/admin/super/adminmenu.php +++ b/application/views/admin/super/adminmenu.php @@ -158,7 +158,13 @@
  • - getLabel(); ?> + + + getIconClass() != ''): ?> +   + + getLabel(); ?> +