Skip to content

Commit

Permalink
Merge branch 'master' into 2.5
Browse files Browse the repository at this point in the history
Conflicts:
	application/helpers/expressions/em_manager_helper.php
	application/helpers/qanda_helper.php
	application/helpers/update/updatedb_helper.php
	application/views/admin/labels/labelview_view.php
	application/views/admin/participants/viewAttribute_view.php
	scripts/admin/labels.js
	scripts/admin/viewAttribute.js
	templates/citronade/template.js
  • Loading branch information
LouisGac committed Jan 8, 2016
2 parents 130ece8 + e3bb114 commit 9d7bd82
Show file tree
Hide file tree
Showing 25 changed files with 561 additions and 570 deletions.
2 changes: 2 additions & 0 deletions application/controllers/survey/index.php
Expand Up @@ -574,6 +574,7 @@ function action()
}
}
}

// Preview action : Preview right already tested before
if ($previewmode)
{
Expand Down Expand Up @@ -604,6 +605,7 @@ function action()
{
echo "<script type='text/javascript'> $(document).ready( function() { alert('".gT("Your responses were successfully saved.","js")."');}) </script>";
}

}

function _getParameters($args = array(), $post = array())
Expand Down
11 changes: 10 additions & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -404,6 +404,7 @@ function run($surveyid,$args)
'token' => (isset($clienttoken) ? $clienttoken : NULL),
);


//Security Checked: POST, GET, SESSION, REQUEST, returnGlobal, DB
$previewgrp = false;
if ($surveyMode == 'group' && isset($param['action']) && ($param['action'] == 'previewgroup'))
Expand Down Expand Up @@ -435,7 +436,9 @@ function run($surveyid,$args)
//$sTemplatePath = $_SESSION[$LEMsessid]['templatepath'];

if($surveyid != LimeExpressionManager::getLEMsurveyId())
{
LimeExpressionManager::SetDirtyFlag();
}

LimeExpressionManager::StartSurvey($surveyid, $surveyMode, $surveyOptions, false, $LEMdebugLevel);
$_SESSION[$LEMsessid]['step'] = 0;
Expand All @@ -445,7 +448,13 @@ function run($surveyid,$args)
}
elseif (isset($thissurvey['showwelcome']) && $thissurvey['showwelcome'] == 'N')
{
$moveResult = LimeExpressionManager::NavigateForwards();
// BUG: This will CLEAR and SAVE IN DB the last question group to NULL if it's still in the cookie (which it is if same browser is used).
//$moveResult = LimeExpressionManager::NavigateForwards();

// Jump WITHOUT saving anything (needed for e-mail link).
LimeExpressionManager::JumpTo(1, false, false, true);

// TODO: Delete this line?
//$_SESSION[$LEMsessid]['step']=1;
}
}
Expand Down
8 changes: 1 addition & 7 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -1471,8 +1471,7 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,


case "I": //Language
// Using previously defined $surveylanguagecodes array of language codes
foreach ($surveylanguagecodes as $availlang)
foreach (Survey::model()->findByPk($surveyid)->getAllLanguages() as $availlang)
{
$alist[]=array($availlang, getLanguageNameFromCode($availlang,false));
}
Expand Down Expand Up @@ -1619,7 +1618,6 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
$tempurl = Yii::app()->getConfig("tempurl");
$firstletter = substr($rt, 0, 1);
$astatdata=array();

if ($usegraph==1)
{
//for creating graphs we need some more scripts which are included here
Expand Down Expand Up @@ -3089,10 +3087,6 @@ public function generate_statistics($surveyid, $allfields, $q2show='all', $usegr
//no survey ID? -> come and get one
if (!isset($surveyid)) {$surveyid=returnGlobal('sid');}

//Get an array of codes of all available languages in this survey
$surveylanguagecodes = Survey::model()->findByPk($surveyid)->additionalLanguages;
$surveylanguagecodes[] = Survey::model()->findByPk($surveyid)->language;

$fieldmap=createFieldMap($surveyid, "full", false, false, $sLanguageCode);

// Set language for questions and answers to base language of this survey
Expand Down
37 changes: 8 additions & 29 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -153,8 +153,10 @@ class LimeExpressionManager {
* @var type
*/
private $allOnOnePage=false;

/**
* survey mode. One of 'survey', 'group', or 'question'
* @todo Please add more information here. What does the alternatives mean?
* @var string
*/
private $surveyMode='group';
Expand Down Expand Up @@ -1465,30 +1467,9 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
);
}
break;
case 'D': // dropdown box: validate that a complete date is entered
// TODO: generic validation as to dateformat[SGQA].value
if ($hasSubqs) {
$subqs = $qinfo['subqs'];
$sq_equs=array();

foreach($subqs as $sq)
{
$sq_name = ($this->sgqaNaming)?$sq['rowdivid'].".NAOK":$sq['varName'].".NAOK";
$sq_equs[] = '('.$sq_name.'!="INVALID")';
}
if (!isset($validationEqn[$questionNum]))
{
$validationEqn[$questionNum] = array();
}
$validationEqn[$questionNum][] = array(
'qtype' => $type,
'type' => 'default',
'class' => 'default',
'eqn' => implode(' and ',$sq_equs),
'qid' => $questionNum,
);
}
break;
case 'D':
// TODO: generic validation as to dateformat[SGQA].value : BUT not same in PHP and JS
break;
default:
break;
}
Expand Down Expand Up @@ -4868,6 +4849,7 @@ static function StartSurvey($surveyid,$surveyMode='group',$aSurveyOptions=NULL,$
$LEM->indexQseq=array();
$LEM->qrootVarName2arrayFilter=array();
templatereplace("{}"); // Needed for coreReplacements in relevance equation (in all mode)

if (isset($_SESSION[$LEM->sessid]['startingValues']) && is_array($_SESSION[$LEM->sessid]['startingValues']) && count($_SESSION[$LEM->sessid]['startingValues']) > 0)
{
$startingValues = array();
Expand Down Expand Up @@ -4902,7 +4884,7 @@ static function StartSurvey($surveyid,$surveyMode='group',$aSurveyOptions=NULL,$
}
else
{
// We don't really validate date here, anyone can send anything : forced too
// We don't really validate date here, anyone can send anything : forced too
$dateformatdatat=getDateFormatData($LEM->surveyOptions['surveyls_dateformat']);
$datetimeobj = new Date_Time_Converter($value, $dateformatdatat['phpdate']);
$value=$datetimeobj->convert("Y-m-d H:i");
Expand Down Expand Up @@ -5537,6 +5519,7 @@ static function JumpTo($seq,$preview=false,$processPOST=true,$force=false,$chang

$LEM->ParseResultCache=array(); // to avoid running same test more than once for a given group
$LEM->updatedValues = array();
// TODO: Should seq be below 0? It will be -1 after survey submit and re-click on invitation link in e-mail (see issue #10162).
--$seq; // convert to 0-based numbering

switch ($LEM->surveyMode)
Expand Down Expand Up @@ -8551,10 +8534,6 @@ static function ProcessCurrentResponses()
switch($type)
{
case 'D': //DATE
if (isset($_POST['qattribute_answer'.$sq])) // push validation message (see qanda_helper) to $_SESSION
{
$_SESSION[$LEM->sessid]['qattribute_answer'.$sq]=($_POST['qattribute_answer'.$sq]);
}
$value=trim($value);
if ($value!="" && $value!="INVALID")
{
Expand Down
1 change: 0 additions & 1 deletion application/helpers/frontend_helper.php
Expand Up @@ -18,7 +18,6 @@ function loadanswers()
global $thissurvey, $thisstep;
global $clienttoken;


$scid=Yii::app()->request->getQuery('scid');
if (Yii::app()->request->getParam('loadall') == "reload")
{
Expand Down
5 changes: 1 addition & 4 deletions application/helpers/qanda_helper.php
Expand Up @@ -1023,7 +1023,6 @@ function do_date($ia)
$aQuestionAttributes=getQuestionAttributeValues($ia[0],$ia[4]);
$sDateLangvarJS=" translt = {
alertInvalidDate: '" . gT('Date entered is invalid!','js') . "',
infoCompleteAll: '" . gT('Please complete all parts of the date!','js') . "'
};";
App()->getClientScript()->registerScript("sDateLangvarJS",$sDateLangvarJS,CClientScript::POS_HEAD);
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig("generalscripts").'date.js');
Expand Down Expand Up @@ -1308,9 +1307,7 @@ function do_date($ia)

$answer .= '<input class="text" type="text" size="10" name="'.$ia[1].'" style="display: none" id="answer'.$ia[1].'" value="'.htmlspecialchars($dateoutput,ENT_QUOTES,'utf-8').'" maxlength="10" alt="'.gT('Answer').'" onchange="'.$checkconditionFunction.'(this.value, this.name, this.type)" title="'.sprintf(gT('Date in the format : %s'),$dateformatdetails['dateformat']).'" />
</p>';
$answer .= '
<input type="hidden" id="qattribute_answer'.$ia[1].'" name="qattribute_answer'.$ia[1].'" value="'.$ia[1].'"/>
<input type="hidden" id="dateformat'.$ia[1].'" value="'.$dateformatdetails['jsdate'].'"/>';
$answer .= '<input type="hidden" id="dateformat'.$ia[1].'" value="'.$dateformatdetails['jsdate'].'"/>';
App()->getClientScript()->registerScript("doDropDownDate{$ia[0]}","doDropDownDate({$ia[0]});",CClientScript::POS_HEAD);
// MayDo:
// add js code to
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/replacements_helper.php
Expand Up @@ -459,7 +459,7 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
{
if($_token)
{
$returnlink=Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}",array('token'=>sanitize_token($_token)));
$returnlink=Yii::app()->getController()->createUrl("survey/index/sid/{$surveyid}",array('token'=>Token::sanitizeToken($_token)));
}
else
{
Expand Down
7 changes: 5 additions & 2 deletions application/helpers/sanitize_helper.php
Expand Up @@ -309,7 +309,7 @@ function sanitize_float($float, $min='', $max='')
$fNumber = floatval($fNumber);
if((($min != '') && ($fNumber < $min)) || (($max != '') && ($fNumber > $max)))
return FALSE;
return $fNumber;
return $fNumber;
}
}

Expand Down Expand Up @@ -395,8 +395,11 @@ function sanitize_languagecodeS($codestringtosanitize) {
return implode(" ",$codearray);
}

/**
* @deprecated use Token::sanitizeToken($codetosanitize);
*/
function sanitize_token($codetosanitize) {
return preg_replace('/[^_a-z0-9]/i', '', $codetosanitize);
return Token::sanitizeToken($codetosanitize);
}

function sanitize_signedint($integer, $min='', $max='')
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -1504,9 +1504,9 @@ function fixKCFinder184()
rmdirr($sThirdPartyDir.'ckeditor/plugins/toolbar/ls-office2003');
$aUnlink = glob($sThirdPartyDir.'kcfinder/cache/*.js');
if ($aUnlink !== false) {
array_map('unlink', $aUnlink);
array_map('unlink', $aUnlink);
}
$aUnlink = glob($sThirdPartyDir.'kcfinder/cache/*.css');
$aUnlink = glob($sThirdPartyDir.'kcfinder/cache/*.css');
if ($aUnlink !== false) {
array_map('unlink', $aUnlink);
}
Expand Down
11 changes: 10 additions & 1 deletion application/models/Token.php
Expand Up @@ -151,7 +151,16 @@ public function generateToken()
}
}
}

/**
* Sanitize token show to the user (replace sanitize_helper sanitize_token)
* @param string token to sanitize
* @return string sanitized token
*/
public static function sanitizeToken($token)
{
// According to Yii doc : http://www.yiiframework.com/doc/api/1.1/CSecurityManager#generateRandomString-detail
return preg_replace('/[^0-9a-zA-Z_~]/', '', $token);
}
/**
* Generates a token for all token objects in this survey.
* Syntax: Token::model(12345)->generateTokens();
Expand Down

0 comments on commit 9d7bd82

Please sign in to comment.