Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev: added a step to confirm token removal from optout
- Loading branch information
LouisGac
committed
Jun 22, 2017
1 parent
bfaf882
commit 4bb6882
Showing
1 changed file
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,55 @@ class OptoutController extends LSYii_Controller { | |
public $layout = 'bare'; | ||
public $defaultAction = 'tokens'; | ||
|
||
|
||
function actiontokens() | ||
{ | ||
|
||
|
||
$iSurveyID = Yii::app()->request->getQuery('surveyid'); | ||
$sLanguageCode = Yii::app()->request->getQuery('langcode'); | ||
$sToken = Token::sanitizeToken(Yii::app()->request->getQuery('token')); | ||
|
||
Yii::app()->loadHelper('database'); | ||
Yii::app()->loadHelper('sanitize'); | ||
|
||
//IF there is no survey id, redirect back to the default public page | ||
if (!$iSurveyID){ | ||
$this->redirect(array('/')); | ||
} | ||
|
||
$iSurveyID = (int)$iSurveyID; //Make sure it's an integer (protect from SQL injects) | ||
//Check that there is a SID | ||
// Get passed language from form, so that we dont lose this! | ||
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) | ||
{ | ||
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language; | ||
} | ||
else | ||
{ | ||
$sBaseLanguage = sanitize_languagecode($sLanguageCode); | ||
} | ||
|
||
Yii::app()->setLanguage($sBaseLanguage); | ||
|
||
$aSurveyInfo=getSurveyInfo($iSurveyID,$sBaseLanguage); | ||
|
||
if ($aSurveyInfo==false || !tableExists("{{tokens_{$iSurveyID}}}")){ | ||
throw new CHttpException(404, "The survey in which you are trying to participate does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect."); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
LouisGac
Contributor
|
||
}else{ | ||
$sMessage = "<p>".gT('This will remove you from this survey.')."</p>"; | ||
$sMessage .= '<p><a href="'.Yii::app()->createUrl('optout/removetokens', array('surveyid'=>$iSurveyID, 'langcode'=> $sBaseLanguage, 'token' => $sToken )).'" class="btn btn-default btn-lg">'.gT("Continue").'</a><p>'; | ||
$this->_renderHtml($sMessage, $aSurveyInfo, $iSurveyID); | ||
} | ||
|
||
|
||
} | ||
|
||
/** | ||
* This function is run when opting out of an individual token table. The other function /optout/participants | ||
* opts the user out of ALL survey invitations from the system | ||
*/ | ||
function actiontokens() | ||
function actionremovetokens() | ||
{ | ||
$iSurveyID=Yii::app()->request->getQuery('surveyid'); | ||
$sLanguageCode=Yii::app()->request->getQuery('langcode'); | ||
|
Question : why send a 404 here and not if :
!$iSurveyID
? Currently : i think (maybe for develop ?) we must send403
or500
id surveyid is not a integer >0.For develop because we have a actionError with own template (currently only 404, but can be extended). I open a mantis for discussion :)