Skip to content

Commit

Permalink
Dev: Only show Cint widget button if survey is active
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jul 29, 2016
1 parent c6cd56e commit 308ce9c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
37 changes: 36 additions & 1 deletion application/core/plugins/CintLink/CintLink.php
Expand Up @@ -247,6 +247,8 @@ public function actionIndex($surveyId)

$this->registerCssAndJs();

//$this->showActivateMessage($surveyId, $orders);

return $content;
}

Expand Down Expand Up @@ -289,7 +291,6 @@ protected function registerCssAndJs() {
// Need to include this manually so Ajax loading of gridview will work
App()->clientScript->registerScriptFile('/framework/zii/widgets/assets/gridview/jquery.yiigridview.js');
App()->clientScript->registerScriptFile('/framework/web/js/source/jquery.ba-bbq.min.js');

}

/**
Expand Down Expand Up @@ -378,6 +379,7 @@ public function getDashboard(LSHttpRequest $request)
$data['user'] = Yii::app()->user;
$data['model'] = CintLinkOrder::model(); // TODO: Only show orders for this survey
$data['dateformatdata'] = getDateFormatData(Yii::app()->session['dateformat']);
$data['survey'] = Survey::model()->findByPk($surveyId);

$content = $this->renderPartial('global_dashboard', $data, true);

Expand Down Expand Up @@ -796,4 +798,37 @@ protected function checkPermission($surveyId = null, $orderUrl = null)
return $ownSurvey || $isSuperAdmin;
}

/**
* If any order is 'new' or 'live', survey must be active.
*
* @return void
*/
protected function showActivateMessage($surveyId) {
$survey = Survey::model()->findByPk($surveyId);
$orders = $this->getOrders(array(
'sid' => $surveyId,
'deleted' => false
));

if ($survey->active != 'Y')
{
Yii::app()->user->setFlash(
'warning',
$this->gT('This survey is live or under review by Cint. Please activate the survey as soon as possible.')
);
}

}

/**
*
*/
protected function anyOrderIsNewOrLive($surveyId) {
$orders = CintLinkOrder::model()->findAllByAttributes(
$conditions,
array('order' => 'url DESC')
);
return $orders;
}

}
6 changes: 6 additions & 0 deletions application/core/plugins/CintLink/views/global_dashboard.php
Expand Up @@ -5,6 +5,12 @@
 
<?php echo $plugin->gT('To order participants, please go to the survey specific CintLink view.'); ?>
</p>
<?php elseif (!empty($survey) && $survey->active != 'Y'): ?>
<p class='alert alert-info'>
<span class='fa fa-info-circle'></span>
&nbsp;
<?php echo $plugin->gT('Please activate the survey before you can order participants.'); ?>
</p>
<?php else: ?>
<button class='btn btn-default' onclick='LS.plugin.cintlink.showWidget();'>
<span class='fa fa-bars'></span>
Expand Down

0 comments on commit 308ce9c

Please sign in to comment.