diff --git a/application/controllers/admin/surveyaction.php b/application/controllers/admin/surveyaction.php
index e6e445c60fa..48c2b8ae3b6 100644
--- a/application/controllers/admin/surveyaction.php
+++ b/application/controllers/admin/surveyaction.php
@@ -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)
@@ -1275,7 +1276,7 @@ function copy()
$importerror = true;
}
}
- elseif ($action == 'copysurvey' && empty($importerror) || !$importerror)
+ elseif ($action == 'copysurvey' && (empty($importerror) || !$importerror))
{
$aImportResults=XMLImportSurvey('',$copysurveydata,$sNewSurveyName);
}
diff --git a/application/helpers/admin/import_helper.php b/application/helpers/admin/import_helper.php
index 943789b025f..e9eb74083e7 100644
--- a/application/helpers/admin/import_helper.php
+++ b/application/helpers/admin/import_helper.php
@@ -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')
@@ -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 )
@@ -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
");
+ Tokens_dynamic->sid($iSurveyID);
+ $result = Tokens_dynamic->model()->insertToken($insertdata) or safe_die($clang->gT("Error").": Failed to insert data
");
$results['tokens']++;
}
diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php
index 749e72c081d..16e15d8380b 100644
--- a/application/helpers/common_helper.php
+++ b/application/helpers/common_helper.php
@@ -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'];
}
@@ -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)
{
@@ -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;
}
diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php
index c6f061354a2..0f700f89d56 100644
--- a/application/helpers/frontend_helper.php
+++ b/application/helpers/frontend_helper.php
@@ -1518,10 +1518,9 @@ function buildsurveysession($surveyid)
echo '
'.$clang->gT("This is a controlled survey. You need a valid token to participate.")."
";
echo $clang->gT("If you have been issued a token, please enter it in the box below and click continue.")."