Skip to content

Commit

Permalink
Merge branch '2.05' of github.com:LimeSurvey/LimeSurvey into 2.05
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Oct 21, 2013
2 parents cd59510 + 6254e7d commit 96fa59c
Show file tree
Hide file tree
Showing 16 changed files with 584 additions and 517 deletions.
3 changes: 2 additions & 1 deletion application/controllers/InstallerController.php
Expand Up @@ -294,7 +294,8 @@ private function stepDatabaseConfiguration()
// Check if the surveys table exists or not
if ($bDBExists == true) {
try {
$this->connection->createCommand()->select()->from('{{surveys}}')->queryAll();
if ($dataReader=$this->connection->createCommand()->select()->from('{{users}}')->query()->rowCount==0) // DBLIB does not throw an exception on a missing table
$bTablesDoNotExist = true;
} catch(Exception $e) {
$bTablesDoNotExist = true;
}
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/authentication.php
Expand Up @@ -164,7 +164,7 @@ public function forgotpassword()
private function _sendPasswordEmail($sEmailAddr, $aFields)
{
$clang = $this->getController()->lang;
$sFrom = Yii::app()->getConfig('siteadminemail');
$sFrom = Yii::app()->getConfig("siteadminname") . " <" . Yii::app()->getConfig("siteadminemail") . ">";
$sTo = $sEmailAddr;
$sSubject = $clang->gT('User data');
$sNewPass = createPassword();
Expand Down
15 changes: 8 additions & 7 deletions application/controllers/admin/participantsaction.php
Expand Up @@ -626,10 +626,11 @@ function getSurveyInfo_json()
*/
function exporttocsvcount()
{
$searchconditionurl = Yii::app()->request->getPost('searchcondition');
$searchcondition = basename($searchconditionurl);
$searchconditionurl = Yii::app()->request->getPost('searchURL');
$searchcondition = Yii::app()->request->getPost('searchcondition');
$searchconditionurl = basename($searchconditionurl);

if ($searchcondition != 'getParticipants_json') // if there is a search condition then only the participants that match the search criteria are counted
if ($searchconditionurl != 'getParticipants_json') // if there is a search condition then only the participants that match the search criteria are counted
{
$condition = explode("||", $searchcondition);
$search = Participant::model()->getParticipantsSearchMultipleCondition($condition);
Expand Down Expand Up @@ -750,17 +751,17 @@ function getSearchIDs()
*/
function exporttocsv()
{
$searchconditionurl = Yii::app()->request->getPost('searchcondition');
$searchcondition = basename($searchconditionurl);
$searchconditionurl = Yii::app()->request->getPost('searchURL');
$searchcondition = Yii::app()->request->getPost('searchcondition');
$searchconditionurl = basename($searchconditionurl);

if ($searchcondition != 'getParticipants_json') // if there is a search condition then only the participants that match the search criteria are counted
if ($searchconditionurl != 'getParticipants_json') // if there is a search condition then only the participants that match the search criteria are counted
{
$condition = explode("||", $searchcondition);
$search = Participant::model()->getParticipantsSearchMultipleCondition($condition);
} else {
$search = null;
}

$this->csvExport($search);
}

Expand Down
1 change: 1 addition & 0 deletions application/controllers/admin/templates.php
Expand Up @@ -735,6 +735,7 @@ protected function _initcssfiles()
*/
protected function _initialise($templatename, $screenname, $editfile, $showsummary = true)
{
App()->getClientScript()->reset();
$clang = $this->getController()->lang;
Yii::app()->loadHelper('surveytranslator');
Yii::app()->loadHelper('admin/template');
Expand Down
3 changes: 2 additions & 1 deletion application/controllers/admin/tokens.php
Expand Up @@ -489,7 +489,7 @@ function getTokens_json($iSurveyId, $search = null)
}
if(Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update'))
$action .= viewHelper::getImageLink('edit_16.png', null, $clang->gT("Edit token entry"), null, 'imagelink token_edit');
if(!empty($token['participant_id']) && $token['participant_id'] != "" && hasGlobalPermission('USER_RIGHT_PARTICIPANT_PANEL')) {
if(!empty($token['participant_id']) && $token['participant_id'] != "" && Permission::model()->hasGlobalPermission('participantpanel','read')) {
$action .= viewHelper::getImageLink('cpdb_16.png', null, $clang->gT("View this person in the central participants database"), null, 'imagelink cpdb',array('onclick'=>"sendPost('".$this->getController()->createUrl('admin/participants/sa/displayParticipants')."','',['searchcondition'],['participant_id||equal||{$token['participant_id']}']);"));
} else {
$action .= '<div style="width: 20px; height: 16px; float: left;"></div>';
Expand Down Expand Up @@ -2369,6 +2369,7 @@ function _newtokentable($iSurveyId)
if (Yii::app()->request->getQuery('createtable') == "Y")
{
createTokenTable($iSurveyId);
LimeExpressionManager::SetDirtyFlag(); // LimeExpressionManager needs to know about the new token table
$this->_renderWrappedTemplate('token', array('message' =>array(
'title' => $clang->gT("Token control"),
'message' => $clang->gT("A token table has been created for this survey.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_$iSurveyId\")<br /><br />\n"
Expand Down
78 changes: 7 additions & 71 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -975,78 +975,14 @@ function run($surveyid,$args) {

// the runonce element has been changed from a hidden to a text/display:none one
// in order to workaround an not-reproduced issue #4453 (lemeur)
echo "<input type='text' id='runonce' value='0' style='display: none;'/>
<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->
<script type='text/javascript'>
<!--\n";
echo "<input type='text' id='runonce' value='0' style='display: none;'/>";

// lemradix and var for LemRadix
$sLemRadixVarScript=" LEMradix='" . $radix . "';\n"
." numRegex = new RegExp('[^-' + LEMradix + '0-9]','g');\n"
." intRegex = new RegExp('[^-0-9]','g');\n";
Yii::app()->clientScript->registerScript('LemRadixVarScript',$sLemRadixVarScript,CClientScript::POS_HEAD);

echo "var LEMradix='" . $radix . "';\n";
echo "var numRegex = new RegExp('[^-' + LEMradix + '0-9]','g');\n";
echo "var intRegex = new RegExp('[^-0-9]','g');\n";

print <<<END
function fixnum_checkconditions(value, name, type, evt_type, intonly)
{
newval = new String(value);
if (typeof intonly !=='undefined' && intonly==1) {
newval = newval.replace(intRegex,'');
}
else {
newval = newval.replace(numRegex,'');
}
if (LEMradix === ',') {
newval = newval.split(',').join('.');
}
if (newval != '-' && newval != '.' && newval != '-.' && newval != parseFloat(newval)) {
newval = '';
}
displayVal = newval;
if (LEMradix === ',') {
displayVal = displayVal.split('.').join(',');
}
if (name.match(/other$/)) {
$('#answer'+name+'text').val(displayVal);
}
$('#answer'+name).val(displayVal);
if (typeof evt_type === 'undefined')
{
evt_type = 'onchange';
}
checkconditions(newval, name, type, evt_type);
}
function checkconditions(value, name, type, evt_type)
{
if (typeof evt_type === 'undefined')
{
evt_type = 'onchange';
}
if (type == 'radio' || type == 'select-one')
{
$('#java'+name).val(value);
}
else if (type == 'checkbox')
{
if ($('#answer'+name).is(':checked'))
{
$('#java'+name).val('Y');
} else
{
$('#java'+name).val('');
}
}
else if (type == 'text' && name.match(/other$/))
{
$('#java'+name).val(value);
}
ExprMgr_process_relevance_and_tailoring(evt_type,name,type);
END;
print <<<END
}
// -->
</script>
END;
$showpopups=Yii::app()->getConfig('showpopups');
//Display the "mandatory" message on page if necessary
if (!$showpopups && $stepInfo['mandViolation'] && $okToShowErrors)
Expand Down
3 changes: 0 additions & 3 deletions application/helpers/admin/activate_helper.php
Expand Up @@ -251,8 +251,6 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)

function activateSurvey($iSurveyID, $simulate = false)
{


$createsurvey='';
$activateoutput='';
$createsurveytimings='';
Expand Down Expand Up @@ -463,7 +461,6 @@ function activateSurvey($iSurveyID, $simulate = false)
}
$acquery = "UPDATE {{surveys}} SET active='Y' WHERE sid=".$iSurveyID;
$acresult = Yii::app()->db->createCommand($acquery)->query();

return $aResult;
}

Expand Down
6 changes: 3 additions & 3 deletions application/helpers/export_helper.php
Expand Up @@ -329,7 +329,7 @@ function SPSSGetValues ($field = array(), $qidattributes = null, $language ) {
* @return array
*/
function SPSSFieldMap($iSurveyID, $prefix = 'V') {
global $clang, $surveyprivate, $tokensexist;
global $clang, $surveyprivate;

$typeMap = array(
'5'=>Array('name'=>'5 Point Choice','size'=>1,'SPSStype'=>'F','Scale'=>3),
Expand Down Expand Up @@ -368,7 +368,7 @@ function SPSSFieldMap($iSurveyID, $prefix = 'V') {
$fieldmap = createFieldMap($iSurveyID,'full',false,false,getBaseLanguageFromSurveyID($iSurveyID));

#See if tokens are being used
$tokensexist = Yii::app()->db->schema->getTable('{{tokens_'.$iSurveyID . '}}');
$bTokenTableExists = tableExists('tokens_'.$iSurveyID);

#Lookup the names of the attributes
$query="SELECT sid, anonymized, language FROM {{surveys}} WHERE sid=$iSurveyID";
Expand All @@ -379,7 +379,7 @@ function SPSSFieldMap($iSurveyID, $prefix = 'V') {
$fieldno=0;

$fields=array();
if (isset($tokensexist) && $tokensexist == true && $surveyprivate == 'N' && Permission::model()->hasSurveyPermission($iSurveyID,'tokens','read')) {
if ($bTokenTableExists && $surveyprivate == 'N' && Permission::model()->hasSurveyPermission($iSurveyID,'tokens','read')) {
$tokenattributes=getTokenFieldsAndNames($iSurveyID,false);
foreach ($tokenattributes as $attributefield=>$attributedescription)
{
Expand Down
23 changes: 16 additions & 7 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -268,14 +268,22 @@ private function RDP_EvaluateBinary(array $token)
$this->RDP_AddError(gT("Invalid value(s) on the stack"), $token);
return false;
}
// TODO: try to determine datatype?
$bNumericArg1 = is_numeric($arg1[0]) || $arg1[0] == '';
$bNumericArg2 = is_numeric($arg2[0]) || $arg2[0] == '';
// Set bothnumeric only if set to numeric
// Not sure if needed to test if [2] is set. : TODO review
$bNumericArg1 = ((is_numeric($arg1[0]) || $arg1[0] == '') && (!isset($arg1[2]) || $arg1[2]=='NUMBER'));
$bNumericArg2 = ((is_numeric($arg2[0]) || $arg2[0] == '') && (!isset($arg2[2]) || $arg2[2]=='NUMBER'));
$bStringArg1 = !$bNumericArg1 || $arg1[0] == '';
$bStringArg2 = !$bNumericArg2 || $arg2[0] == '';
$bBothNumeric = ($bNumericArg1 && $bNumericArg2);
$bBothString = ($bStringArg1 && $bStringArg2);
$bMismatchType = (!$bBothNumeric && !$bBothString);
$bMismatchType=(!$bBothNumeric && !$bBothString);
if($bMismatchType){// Try same than JS: if can be numeric: convert to numeric else false
if((is_numeric($arg1[0]) || $arg1[0] == '') && (is_numeric($arg2[0]) || $arg2[0] == ''))
{
$bBothNumeric=true;
$bMismatchType=false;
}
}
switch(strtolower($token[0]))
{
case 'or':
Expand All @@ -296,7 +304,7 @@ private function RDP_EvaluateBinary(array $token)
break;
case '<':
case 'lt':
if ($bMismatchType) {
if ($bMismatchType && false) {
$result = array(false,$token[1],'NUMBER');
}
else {
Expand Down Expand Up @@ -335,7 +343,7 @@ private function RDP_EvaluateBinary(array $token)
break;
case '>=';
case 'ge':
if ($bMismatchType) {
if ($bMismatchType && false) {
$result = array(false,$token[1],'NUMBER');
}
else {
Expand Down Expand Up @@ -565,7 +573,8 @@ private function RDP_EvaluateConstantVarOrFunction()
}
if ($relStatus==1)
{
$result = array($this->GetVarAttribute($token[0],NULL,''),$token[1],'NUMBER');
$argtype=($this->GetVarAttribute($token[0],'onlynum',0))?"NUMBER":"WORD";
$result = array($this->GetVarAttribute($token[0],NULL,''),$token[1],$argtype);
}
else
{
Expand Down

0 comments on commit 96fa59c

Please sign in to comment.