Skip to content

Commit

Permalink
Dev: added a step to confirm token removal from optout
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jun 22, 2017
1 parent bfaf882 commit 4bb6882
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion application/controllers/OptoutController.php 100644 → 100755
Expand Up @@ -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.

Copy link
@Shnoulle

Shnoulle Jun 22, 2017

Collaborator

Question : why send a 404 here and not if : !$iSurveyID ? Currently : i think (maybe for develop ?) we must send 403 or 500 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 :)

This comment has been minimized.

Copy link
@LouisGac

LouisGac Jun 22, 2017

Contributor

no deep reason: just a dirty copy/pasta from the original actiontokens

And yep, we could use the error page from twig (for now, output rendering is still not twigged)

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Jun 22, 2017

Collaborator

todo : move error404 to twig ;)

Edit : https://bugs.limesurvey.org/view.php?id=12486

}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');
Expand Down

0 comments on commit 4bb6882

Please sign in to comment.