Skip to content

Commit

Permalink
Dev: new functionnality : survey with register show token form by def…
Browse files Browse the repository at this point in the history
…aut and a link to registering
  • Loading branch information
Shnoulle committed Dec 13, 2012
1 parent 15c09c0 commit b2057ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
15 changes: 1 addition & 14 deletions application/controllers/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ function actionIndex($surveyid = null)
Yii::app()->request->redirect(Yii::app()->baseUrl);
}

getGlobalSetting('SessionName');
if (getGlobalSetting('SessionName'))
{
$stg_SessionName=$usrow['stg_value'];
Yii::app()->session->setSessionName("$stg_SessionName-runtime-$iSurveyID");
}
else
{
Yii::app()->setSessionName("LimeSurveyRuntime-$iSurveyID");
}

Yii::app()->session->setCookieParams(array(0, Yii::app()->getConfig('publicurl')));

// Get passed language from form, so that we dont loose this!
if (!isset($sLanguage) || $sLanguage == "" || !$sLanguage )
{
Expand Down Expand Up @@ -140,7 +127,7 @@ function actionIndex($surveyid = null)

$iTokenLength = $aSurveyInfo['tokenlength'];
//if tokenlength is not set or there are other problems use the default value (15)
if(!$iTokenLength || trim($iTokenLength) == '')
if(!$iTokenLength || intval($iTokenLength) == 0)
{
$iTokenLength = 15;
}
Expand Down
21 changes: 14 additions & 7 deletions application/helpers/frontend_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,9 @@ function submitfailed($errormsg='')
function buildsurveysession($surveyid,$previewGroup=false)
{
global $thissurvey, $secerror, $clienttoken;
global $tokensexist;
//global $surveyid;
global $templang, $move, $rooturl;
global $tokensexist;
//global $surveyid;
global $templang, $move, $rooturl;

$clang = Yii::app()->lang;

Expand Down Expand Up @@ -1362,17 +1362,24 @@ function buildsurveysession($surveyid,$previewGroup=false)
echo templatereplace(file_get_contents($sTemplatePath."startpage.pstpl"),array(),$redata,'frontend_helper[1594]');
//echo makedropdownlist();
echo templatereplace(file_get_contents($sTemplatePath."survey.pstpl"),array(),$redata,'frontend_helper[1596]');
if (isset($thissurvey) && $thissurvey['allowregister'] == "Y")
if ($thissurvey['allowregister'] == "Y" && Yii::app()->request->getParam('register'))
{
echo templatereplace(file_get_contents($sTemplatePath."register.pstpl"),array(),$redata,'frontend_helper[1599]');
}
else
{
// ->renderPartial('entertoken_view');
if (isset($secerror)) echo "<span class='error'>".$secerror."</span><br />";
echo '<div id="wrapper"><p id="tokenmessage">'.$clang->gT("This is a controlled survey. You need a valid token to participate.")."<br />";
echo $clang->gT("If you have been issued a token, please enter it in the box below and click continue.")."</p>
<script type='text/javascript'>var focus_element='#token';</script>"
echo '<div id="wrapper"><p id="tokenmessage" class="information">'.$clang->gT("This is a controlled survey. You need a valid token to participate.")."<br />";
echo $clang->gT("If you have been issued a token, please enter it in the box below and click continue.")."</p>";
if ($thissurvey['allowregister'] == "Y")
{
$registerurl=Yii::app()->getController()->createUrl("/survey/index/sid/{$surveyid}/register/new");
echo "<p id='registerurl' class='information'>"
. sprintf($clang->gT("If you don't have a token, <a href='%s'>you may register for this survey if you wish to take part</a>.",'unescaped'),$registerurl)
. "</p>";
}
echo "<script type='text/javascript'>var focus_element='#token';</script>"
.CHtml::form(array("/survey/index/sid/{$surveyid}"), 'post', array('id'=>'tokenform'))."
<ul>
<li>";?>
Expand Down

0 comments on commit b2057ac

Please sign in to comment.