Skip to content

Commit

Permalink
Port the frontend survey controller to the Yii framework by GCI parti…
Browse files Browse the repository at this point in the history
…cipant Aaron Schmitz

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11773 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Aaron Schmitz committed Dec 26, 2011
1 parent 9ee04ba commit e660c43
Show file tree
Hide file tree
Showing 16 changed files with 1,272 additions and 673 deletions.
594 changes: 594 additions & 0 deletions application/controllers/SurveyController.php

Large diffs are not rendered by default.

233 changes: 119 additions & 114 deletions application/controllers/surveyaction.php

Large diffs are not rendered by default.

60 changes: 21 additions & 39 deletions application/controllers/uploader.php
Expand Up @@ -14,35 +14,21 @@
* $Id: Admin_Controller.php 11256 2011-10-25 13:52:18Z c_schmitz $
*/

class uploader extends LSCI_Controller {

function __construct()
{
parent::__construct();
}
class Uploader extends CAction {

public function _remap($method, $params = array())
public function run()
{
array_unshift($params, $method);
return call_user_func_array(array($this, "action"), $params);
}
$this->action();
}

function action()
{
//Replace $param:
$arg_list = func_get_args();
if($arg_list[0]==__CLASS__) array_shift($arg_list);
if(count($arg_list)%2 == 0) {
for ($i = 0; $i < count($arg_list); $i+=2) {
//echo $arg_list[$i]."=" . $arg_list[$i+1] . "<br />\n";
$param[$arg_list[$i]] = returnglobal($arg_list[$i], $arg_list[$i+1]);
}
}

$uploaddir = $this->config->item("uploaddir");
$tempdir = $this->config->item("tempdir");

$uploaddir = Yii::app()->getConfig("uploaddir");
$tempdir = Yii::app()->getConfig("tempdir");

$this->load->helper("database");
Yii::app()->loadHelper("database");
$param = $_REQUEST;

if (isset($param['filegetcontents']))
{
Expand All @@ -60,7 +46,7 @@ function action()

if (!isset($surveyid))
{
$surveyid=sanitize_int($param['sid']);
$surveyid=sanitize_int(@$param['sid']);
}
else
{
Expand All @@ -72,11 +58,11 @@ function action()
// Session name is based:
// * on this specific limesurvey installation (Value SessionName in DB)
// * on the surveyid (from Get or Post param). If no surveyid is given we are on the public surveys portal
$usquery = "SELECT stg_value FROM ".$this->db->dbprefix("settings_global")." where stg_name='SessionName'";
$usquery = "SELECT stg_value FROM {{settings_global}} where stg_name='SessionName'";
$usresult = db_execute_assoc($usquery,'',true); //Checked
if ($usresult)
{
$usrow = $usresult->row_array();
$usrow = $usresult->read();
$stg_SessionName=$usrow['stg_value'];
if ($surveyid)
{
Expand All @@ -101,16 +87,14 @@ function action()
//session_set_cookie_params(0,$relativeurl.'/');
//@session_start();

if (!$this->session->userdata('fieldname'))
if (!@Yii::app()->session['fieldname'])
{
die("You don't have a valid session !");
}

if(isset($param['mode']) && $param['mode'] == "upload")
{
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$this->load->library('Limesurvey_lang',array("langcode"=>$baselang));
$clang = $this->limesurvey_lang;
$clang = Yii::app()->lang;

$randfilename = 'futmp_'.sRandomChars(15);
$sTempUploadDir = $tempdir.'/uploads/';
Expand Down Expand Up @@ -177,7 +161,7 @@ function action()
else
{ // if everything went fine and the file was uploaded successfuly,
// send the file related info back to the client
$iFileUploadTotalSpaceMB = $this->config->item("iFileUploadTotalSpaceMB");
$iFileUploadTotalSpaceMB = Yii::app()->getConfig("iFileUploadTotalSpaceMB");
if ($size > $maxfilesize)
{
$return = array(
Expand Down Expand Up @@ -246,19 +230,17 @@ function action()
}

$meta = '<script type="text/javascript">
var uploadurl = "'.site_url('uploader/mode/upload/').'";
var uploadurl = "'.$this->getController()->createUrl('uploader/mode/upload/').'";
var surveyid = "'.$surveyid.'";
var fieldname = "'.$param['fieldname'].'";
var questgrppreview = '.$param['preview'].';
</script>';

$meta .='<script type="text/javascript" src="'.$this->config->item("generalscripts").'/ajaxupload.js"></script>
<script type="text/javascript" src="'.$this->config->item("generalscripts").'/uploader.js"></script>
<link type="text/css" href="'.$this->config->item("generalscripts").'/uploader.css" rel="stylesheet" />';
$meta .='<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/ajaxupload.js"></script>
<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/uploader.js"></script>
<link type="text/css" href="'.Yii::app()->getConfig("generalscripts").'/uploader.css" rel="stylesheet" />';

$baselang = GetBaseLanguageFromSurveyID($surveyid);
$this->load->library('Limesurvey_lang',array("langcode"=>$baselang));
$clang = $this->limesurvey_lang;
$clang = Yii::app()->lang;

$header = getHeader($meta);

Expand Down Expand Up @@ -291,7 +273,7 @@ function action()
<input type="hidden" id="'.$fn.'_maxfiles" value="'.$qidattributes['max_num_of_files'].'" />
<input type="hidden" id="'.$fn.'_maxfilesize" value="'.$qidattributes['max_filesize'].'" />
<input type="hidden" id="'.$fn.'_allowed_filetypes" value="'.$qidattributes['allowed_filetypes'].'" />
<input type="hidden" id="preview" value="'.$this->session->userdata('preview').'" />
<input type="hidden" id="preview" value="'.Yii::app()->session['preview'].'" />
<input type="hidden" id="'.$fn.'_show_comment" value="'.$qidattributes['show_comment'].'" />
<input type="hidden" id="'.$fn.'_show_title" value="'.$qidattributes['show_title'].'" />
<input type="hidden" id="'.$fn.'_licount" value="0" />
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/common_helper.php
Expand Up @@ -1467,7 +1467,7 @@ function getSurveyInfo($surveyid, $languagecode='')
}

//not sure this should be here... ToDo: Find a better place
if (function_exists('makelanguagechanger')) $languagechanger = makelanguagechanger();
if (function_exists('makelanguagechanger')) $languagechanger = makelanguagechanger($languagecode);
return $thissurvey;
}

Expand Down

0 comments on commit e660c43

Please sign in to comment.