Skip to content

Commit

Permalink
Fixed issue: Problems importing URL parameters
Browse files Browse the repository at this point in the history
Fixed issue: URL parameters empty on repeated editing
  • Loading branch information
c-schmitz committed Oct 4, 2012
1 parent 70d808a commit 9d10edd
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 60 deletions.
12 changes: 10 additions & 2 deletions application/controllers/admin/surveyadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1380,11 +1380,20 @@ function getUrlParamsJSON($iSurveyID)
left join {{questions}} sq on sq.qid=up.targetsqid
where up.sid={$iSurveyID}");
$i = 0;
$clang = $this->getController()->lang;
$aData = new stdClass();

foreach ($oResult->readAll() as $oRow)
{
$aData->rows[$i]['id'] = $oRow['id'];
$oRow['title'] .= ': ' . ellipsize(flattenText($oRow['question'], false, true), 43, .70);
if ($oRow['question'] != '')
{
$oRow['title'] .= ': ' . ellipsize(flattenText($oRow['question'], false, true), 43, .70);
}
else
{
$oRow['title'] = $clang->gT('(No target question)');
}

if ($oRow['sqquestion'] != '')
{
Expand All @@ -1398,7 +1407,6 @@ function getUrlParamsJSON($iSurveyID)
$i++;
}

$aData = new stdClass();
$aData->page = 1;
$aData->records = $oResult->getRowCount();
$aData->total = 1;
Expand Down
15 changes: 11 additions & 4 deletions application/helpers/admin/import_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3941,16 +3941,16 @@ function XMLImportSurvey($sFullFilepath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
$insertdata[(string)$key]=(string)$value;
}
$insertdata['sid']=$iNewSID; // remap the survey id
if ($insertdata['targetsqid']!='')
if (isset($insertdata['targetsqid']) && $insertdata['targetsqid']!='')
{
$insertdata['targetsqid'] =$aSQIDReplacements[(int)$insertdata['targetsqid']]; // remap the qid
}
if ($insertdata['targetqid']!='')
if (isset($insertdata['targetqid']) && $insertdata['targetqid']!='')
{
$insertdata['targetqid'] =$aQIDReplacements[(int)$insertdata['targetqid']]; // remap the qid
}
unset($insertdata['id']);
$result=Survey_url_parameters::model()->insertRecords($insertdata) or safeDie($clang->gT("Error").": Failed to insert data<br />");
$result=Survey_url_parameters::model()->insertRecord($insertdata) or safeDie($clang->gT("Error").": Failed to insert data<br />");
$results['survey_url_parameters']++;
}
}
Expand Down Expand Up @@ -4331,8 +4331,15 @@ function TSVImportSurvey($sFullFilepath)
// Create the survey entry
$surveyinfo['startdate']=NULL;
$surveyinfo['active']='N';
// unset($surveyinfo['datecreated']);
switchMSSQLIdentityInsert('surveys',true);
$iNewSID = Survey::model()->insertNewSurvey($surveyinfo) or safeDie($clang->gT("Error").": Failed to insert survey<br />");
$iNewSID = Survey::model()->insertNewSurvey($surveyinfo) ; //or safeDie($clang->gT("Error").": Failed to insert survey<br />");
if ($iNewSID==false)
{
$results['error'] = Survey::model()->getErrors();
$results['bFailed'] = true;
return $results;
}
$surveyinfo['sid']=$iNewSID;
$results['surveys']++;
switchMSSQLIdentityInsert('surveys',false);
Expand Down
108 changes: 54 additions & 54 deletions application/models/Survey_url_parameters.php
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
<?php
/*
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/
class Survey_url_parameters extends CActiveRecord{
/**
* Returns the static model of Settings table
*
* @static
* @access public
* @param string $class
* @return CActiveRecord
*/
public static function model($class = __CLASS__)
{
return parent::model($class);
}
/*
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/
class Survey_url_parameters extends CActiveRecord{
/**
* Returns the static model of Settings table
*
* @static
* @access public
* @param string $class
* @return CActiveRecord
*/
public static function model($class = __CLASS__)
{
return parent::model($class);
}

/**
* Returns the setting's table name to be used by the model
*
* @access public
* @return string
*/
public function tableName()
{
return '{{survey_url_parameters}}';
}
/**
* Returns the setting's table name to be used by the model
*
* @access public
* @return string
*/
public function tableName()
{
return '{{survey_url_parameters}}';
}

function getParametersForSurvey($iSurveyID)
{
return Yii::app()->db->createCommand("select '' as act, up.*,q.title, sq.title as sqtitle, q.question, sq.question as sqquestion from {{survey_url_parameters}} up
left join {{questions}} q on q.qid=up.targetqid
left join {{questions}} sq on q.qid=up.targetsqid
where up.sid=:surveyid")->bindParam(":surveyid", $iSurveyID, PDO::PARAM_INT)->query();
}
function getParametersForSurvey($iSurveyID)
{
return Yii::app()->db->createCommand("select '' as act, up.*,q.title, sq.title as sqtitle, q.question, sq.question as sqquestion from {{survey_url_parameters}} up
left join {{questions}} q on q.qid=up.targetqid
left join {{questions}} sq on q.qid=up.targetsqid
where up.sid=:surveyid")->bindParam(":surveyid", $iSurveyID, PDO::PARAM_INT)->query();
}

function deleteRecords($aConditions)
{
foreach ($aConditions as $sFieldname=>$sFieldvalue)
function deleteRecords($aConditions)
{
$this->db->where($sFieldname,$sFieldvalue);
foreach ($aConditions as $sFieldname=>$sFieldvalue)
{
Yii::app()->db->createCommand()->where($sFieldname,$sFieldvalue);
}
return Yii::app()->db->delete('survey_url_parameters');// Deletes from token
}
return $this->db->delete('survey_url_parameters');// Deletes from token
}

function insertRecord($aData)
{
function insertRecord($aData)
{

$this->db->insert('survey_url_parameters',$aData);
}
return Yii::app()->db->createCommand()->insert('{{survey_url_parameters}}',$aData);
}

}
}

?>

0 comments on commit 9d10edd

Please sign in to comment.