Skip to content

Commit

Permalink
Dev: Screen out if quota match (CintLink)
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 19, 2016
1 parent fd6cf43 commit b6ba430
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions application/core/plugins/CintLink/CintLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ public function init()
{
$this->subscribe('afterQuickMenuLoad');
$this->subscribe('afterSurveyComplete'); // Redirect to Cint
$this->subscribe('afterSurveyQuota'); // Redirect to Cint, screen out
$this->subscribe('beforeActivate'); // Create db
$this->subscribe('beforeAdminMenuRender');
$this->subscribe('beforeToolsMenuRender');
$this->subscribe('beforeControllerAction'); // To load Cint icon
$this->subscribe('beforeSurveyDeactivate'); // Don't deactivate if Cint is active
$this->subscribe('beforeSurveyActivate'); // Forbid tokens if Cint order
$this->subscribe('newDirectRequest'); // Ajax calls
$this->subscribe('onSurveyDenied'); // To send Cint survey closed redirect
$this->subscribe('onSurveyDenied'); // Redirect to Cint, survey closed

// Login session key from com_api at limesurvey.org
$limesurveyOrgKey = Yii::app()->user->getState('limesurveyOrgKey');
Expand Down Expand Up @@ -296,6 +297,25 @@ public function afterSurveyComplete()
}
}

/**
* If participant is screened out, redirect to Cint
* @return void
*/
public function afterSurveyQuota()
{
$event = $this->getEvent();
$surveyId = $event->get('surveyId');
$matched = $event->get('aMatchedQuotas');

if (!empty($matched) &&
CintLinkOrder::hasAnyBlockingOrders($surveyId))
{
$url = 'http://cds.cintworks.net/survey/screen_out';
$event->set('action', 1);
$event->set('url', $url);
}
}

/**
* If survey is closed/deactivated and a participant
* happens to click on survey link, redirect to Cint.
Expand All @@ -315,13 +335,11 @@ public function onSurveyDenied()
$request = Yii::app()->request;
$participantGUID = $request->getParam('respondent');

if (!empty($participantGUID))
if (!empty($participantGUID) &&
CintLinkOrder::hasAnyBlockingOrders($surveyId))
{
if (CintLinkOrder::hasAnyBlockingOrders($surveyId))
{
header('Location: http://cds.cintworks.net/survey/closed?respondent=' . $participantGUID);
exit;
}
header('Location: http://cds.cintworks.net/survey/closed?respondent=' . $participantGUID);
exit;
}
}

Expand Down

0 comments on commit b6ba430

Please sign in to comment.