Skip to content

Commit

Permalink
Minor fixes for the frontend, common helper, and survey import.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11819 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Aaron Schmitz committed Jan 1, 2012
1 parent 43dfc30 commit f23a418
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
11 changes: 6 additions & 5 deletions application/controllers/admin/surveyaction.php
Expand Up @@ -1212,11 +1212,12 @@ function copy()
}
elseif (isset($sExtension) && strtolower($sExtension) == 'zip') // Import a survey archive
{
$this->load->library("admin/pclzip/pclzip", array('p_zipname' => $sFullFilepath));
$aFiles = $this->pclzip->listContent();
Yii::import("application.libraries.admin.pclzip.pclzip", true);
$pclzip = new PclZip(array('p_zipname' => $sFullFilepath));
$aFiles = $pclzip->listContent();

if ($this->pclzip->extract(PCLZIP_OPT_PATH, Yii::app()->getConfig('tempdir').DIRECTORY_SEPARATOR, PCLZIP_OPT_BY_EREG, '/(lss|lsr|lsi|lst)$/')== 0) {
unset($this->pclzip);
if ($pclzip->extract(PCLZIP_OPT_PATH, Yii::app()->getConfig('tempdir').DIRECTORY_SEPARATOR, PCLZIP_OPT_BY_EREG, '/(lss|lsr|lsi|lst)$/')== 0) {
unset($pclzip);
}
// Step 1 - import the LSS file and activate the survey
foreach ($aFiles as $aFile)
Expand Down Expand Up @@ -1275,7 +1276,7 @@ function copy()
$importerror = true;
}
}
elseif ($action == 'copysurvey' && empty($importerror) || !$importerror)
elseif ($action == 'copysurvey' && (empty($importerror) || !$importerror))
{
$aImportResults=XMLImportSurvey('',$copysurveydata,$sNewSurveyName);
}
Expand Down
10 changes: 4 additions & 6 deletions application/helpers/admin/import_helper.php
Expand Up @@ -3859,10 +3859,8 @@ function GetNewSurveyID($oldsid)

function XMLImportTokens($sFullFilepath,$iSurveyID,$sCreateMissingAttributeFields=true)
{
$CI =& get_instance();

$CI->load->helper('database');
$clang = $CI->limesurvey_lang;
$this->getController()->loadhelper('database');
$clang = Yii::app()->lang;
$xml = simplexml_load_file($sFullFilepath);

if ($xml->LimeSurveyDocType!='Tokens')
Expand All @@ -3883,7 +3881,6 @@ function XMLImportTokens($sFullFilepath,$iSurveyID,$sCreateMissingAttributeField

if ($sCreateMissingAttributeFields)
{
$CI->load->dbforge();
// Get a list with all fieldnames in the XML
$aXLMFieldNames=array();
foreach ($xml->tokens->fields->fieldname as $sFieldName )
Expand Down Expand Up @@ -3919,7 +3916,8 @@ function XMLImportTokens($sFullFilepath,$iSurveyID,$sCreateMissingAttributeField
$insertdata[(string)$key]=(string)$value;
}

$result = $CI->tokens_dynamic_model->insertToken($iSurveyID,$insertdata) or safe_die($clang->gT("Error").": Failed to insert data<br />");
Tokens_dynamic->sid($iSurveyID);
$result = Tokens_dynamic->model()->insertToken($insertdata) or safe_die($clang->gT("Error").": Failed to insert data<br />");

$results['tokens']++;
}
Expand Down
22 changes: 11 additions & 11 deletions application/helpers/common_helper.php
Expand Up @@ -1736,11 +1736,11 @@ function getsidgidqidaidtype($fieldcode)

if ( count($result) == 0 )
{ // question doesn't exist
return Array();
return array();
}
else
{ // certainly is type M or P
foreach ($result->readAll() as $row)
foreach ($result as $row)
{
$aRef['type']=$row['type'];
}
Expand Down Expand Up @@ -5634,15 +5634,15 @@ function getNumericalFormat($lang = 'en', $integer = false, $negative = true) {
function getTokenData($surveyid, $token)
{
Tokens_dynamic::sid($surveyid);
$query=$Tokens_dynamic::model()->getAllRecords(array("token"=>$token));
$query = Tokens_dynamic::model()->findAll('token = :token',array(':token' => $token));

// while($row=$result->FetchRow())
foreach ($query->readAll() as $row)
foreach ($query as $row)
{
$thistoken=array("firstname"=>$row['firstname'],
"lastname"=>$row['lastname'],
"email"=>$row['email'],
"language" =>$row['language']);
$thistoken=array("firstname"=>$row->firstname,
"lastname"=>$row->lastname,
"email"=>$row->email,
"language" =>$row->language);
$attrfieldnames=GetAttributeFieldnames($surveyid);
foreach ($attrfieldnames as $attr_name)
{
Expand Down Expand Up @@ -5783,9 +5783,9 @@ function usedTokens($token, $surveyid)
Tokens_dynamic::sid($surveyid);
$query=Tokens_dynamic::model()->getSomeRecords(array("tid, usesleft"), array("token"=>$token));

if ($query->count() > 0) {
$row = $query->readAll();
if ($row['usesleft']>0) $utresult = false;
if (count($query) > 0) {
$row = $query[0];
if ($row->usesleft > 0) $utresult = false;
}
return $utresult;
}
Expand Down
3 changes: 1 addition & 2 deletions application/helpers/frontend_helper.php
Expand Up @@ -1518,10 +1518,9 @@ function buildsurveysession($surveyid)
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>
<form id='tokenform' method='post' action='".Yii::app()->createUrl("$surveyid")."'>
<form id='tokenform' method='post' action='".Yii::app()->createUrl("/survey/index/sid/$surveyid")."'>
<ul>
<li>
<label for='token'>".$clang->gT("Token")."</label><input class='text $kpclass' id='token' type='text' name='token' />";
echo "<input type='hidden' name='sid' value='".$surveyid."' id='sid' />
<input type='hidden' name='lang' value='".$templang."' id='lang' />";
Expand Down

0 comments on commit f23a418

Please sign in to comment.