Skip to content

Commit

Permalink
Dev: Add support for icon-class in extra menu
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Apr 27, 2016
1 parent 4ac660a commit 0e93011
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
56 changes: 56 additions & 0 deletions application/models/Survey.php
Expand Up @@ -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()
{

Expand Down
8 changes: 7 additions & 1 deletion application/views/admin/super/adminmenu.php
Expand Up @@ -158,7 +158,13 @@
<li class="dropdown-header"><?php echo $menuItem->getLabel();?></li>
<?php else: ?>
<li>
<a href="<?php echo $menuItem->getHref(); ?>"><?php echo $menuItem->getLabel(); ?></a>
<a href="<?php echo $menuItem->getHref(); ?>">
<!-- Spit out icon if present -->
<?php if ($menuItem->getIconClass() != ''): ?>
<span class="<?php echo $menuItem->getIconClass(); ?>">&nbsp;</span>
<?php endif; ?>
<?php echo $menuItem->getLabel(); ?>
</a>
</li>
<?php endif; ?>
<?php endforeach; ?>
Expand Down

0 comments on commit 0e93011

Please sign in to comment.