Skip to content

Commit

Permalink
Commit for GCI Task #7114261
Browse files Browse the repository at this point in the history
Ported vvexport into Yii

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11413 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Shitiz Garg committed Nov 21, 2011
1 parent 0bf6429 commit d35620f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 47 deletions.
1 change: 1 addition & 0 deletions application/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function actions()
'index' => 'application.controllers.admin.index',
'globalsettings' => 'application.controllers.admin.globalsettings',
'quotas' => 'application.controllers.admin.quotas',
'export' => 'application.controllers.admin.export',
);
}

Expand Down
53 changes: 28 additions & 25 deletions application/controllers/admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@
*/

/**
* Export Controller
* Export Action
*
* This controller performs export actions
*
* @package LimeSurvey
* @subpackage Backend
*/
class export extends Survey_Common_Controller {
class export extends Survey_Common_Action {

/**
* Constructor
*/
function __construct()
{
parent::__construct();
$this->load->helper("export");
$this->load->helper("database");
}
* Run, routes it down to valid sub-action
*
* @access public
* @return void
*/
public function run($sa, $surveyid = null, $subaction = null)
{
if ($sa == 'vvexport')
$this->vvexport($surveyid, $subaction);
}

function survey($action,$sSurveyID)
{
Expand Down Expand Up @@ -948,19 +950,19 @@ function exportr($surveyi, $subaction = null)

}

function vvexport($surveyi, $subaction = null)
function vvexport($surveyid, $subaction = null)
{
$surveyid = (int) $surveyi;
$dbprefix = $this->db->dbprefix;
$surveyid = (int) $surveyid;

//Exports all responses to a survey in special "Verified Voting" format.
$clang = $this->limesurvey_lang;
$_POST = $this->input->post();
$clang = $this->getController()->lang;

if (!bHasSurveyPermission($surveyid, 'responses','export'))
{
return;
}

if (!$subaction == "export")
if ($subaction != "export")
{
if(incompleteAnsFilterstate() == "inc")
{
Expand All @@ -981,15 +983,16 @@ function vvexport($surveyi, $subaction = null)
$selectinc="";
}

self::_getAdminHeader();
self::_browsemenubar($surveyid, $clang->gT("Export VV file"));
$this->getController()->_getAdminHeader();
$this->_browsemenubar($surveyid, $clang->gT("Export VV file"));

$data["clang"] = $this->limesurvey_lang;
$data["clang"] = $clang;
$data['selectinc'] = $selectinc;
$data['selecthide'] = $selecthide;
$data['selectshow'] = $selectshow;
$this->load->view("admin/export/vv_view",$data);
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));
$data['surveyid'] = $surveyid;
$this->getController()->render("/admin/export/vv_view", $data);
$this->getController()->_getAdminFooter("http://docs.limesurvey.org", $clang->gT("LimeSurvey online manual"));
}
elseif (isset($surveyid) && $surveyid)
{
Expand All @@ -1002,11 +1005,11 @@ function vvexport($surveyi, $subaction = null)
$s="\t";

$fieldmap=createFieldMap($surveyid, "full");
$surveytable = "{$dbprefix}survey_$surveyid";
$surveytable = "{{survey_$surveyid}}";

GetBaseLanguageFromSurveyID($surveyid);

$fieldnames = array_values($this->db->list_fields("survey_$surveyid"));
$fieldnames = Yii::app()->db->schema->getTable($surveytable)->getColumnNames();

//Create the human friendly first line
$firstline="";
Expand All @@ -1033,9 +1036,9 @@ function vvexport($surveyi, $subaction = null)
{
$query .= " WHERE submitdate >= '01/01/1980' ";
}
$result = db_execute_assoc($query) or safe_die("Error:<br />$query<br />".$connect->ErrorMsg()); //Checked
$result = Yii::app()->db->createCommand($query)->query();

foreach ($result->result_array() as $row)
foreach ($result->readAll() as $row)
{
foreach ($fieldnames as $field)
{
Expand Down
1 change: 0 additions & 1 deletion application/controllers/admin/quotas.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class quotas extends Survey_Common_Action {
*/
public function run($surveyid, $subaction = null)
{

$surveyid = sanitize_int($surveyid);

$this->getController()->_js_admin_includes(Yii::app()->getConfig("generalscripts").'/jquery/jquery.tablesorter.min.js');
Expand Down
38 changes: 18 additions & 20 deletions application/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5040,25 +5040,24 @@ function incompleteAnsFilterstate()
$letsfilter='';
$letsfilter = returnglobal('filterinc'); //read get/post filterinc

$CI =& get_instance();

// first let's initialize the incompleteanswers session variable
if ($letsfilter != '')
{ // use the read value if not empty
$CI->session->set_userdata('incompleteanswers', $letsfilter);
Yii::app()->session['incompleteanswers'] = $letsfilter;
}
elseif (!$CI->session->userdata('incompleteanswers'))
elseif (empty(Yii::app()->session['incompleteanswers']))
{ // sets default variable value from config file
$CI->session->set_userdata('incompleteanswers', $filterout_incomplete_answers);
Yii::app()->session['incompleteanswers'] = $filterout_incomplete_answers;
}

if ($CI->session->userdata('incompleteanswers')=='filter') {
if (Yii::app()->session['incompleteanswers']=='filter') {
return "filter"; //COMPLETE ANSWERS ONLY
}
elseif ($CI->session->userdata('incompleteanswers')=='show') {
elseif (Yii::app()->session['incompleteanswers']=='show') {
return false; //ALL ANSWERS
}
elseif ($CI->session->userdata('incompleteanswers')=='incomplete') {
elseif (Yii::app()->session['incompleteanswers']=='incomplete') {
return "inc"; //INCOMPLETE ANSWERS ONLY
}
else
Expand Down Expand Up @@ -5876,24 +5875,23 @@ function sGetTemplateURL($sTemplateName)
* @param $sLanguage Language of the subquestion text
*/
function getSubQuestions($sid, $qid, $sLanguage) {
$CI = &get_instance();
$clang = $CI->limesurvey_lang;

$clang = Yii::app()->lang;
static $subquestions;

if (!isset($subquestions[$sid])) {
$sid = sanitize_int($sid);
/*$query = "SELECT sq.*, q.other FROM {$dbprefix}questions as sq, {$dbprefix}questions as q"
." WHERE sq.parent_qid=q.qid AND q.sid=$sid"
." AND sq.language='".$sLanguage. "' "
." AND q.language='".$sLanguage. "' "
." ORDER BY sq.parent_qid, q.question_order,sq.scale_id , sq.question_order";
$result=db_execute_assoc($query) or safe_die ("Couldn't get perform answers query<br />$query<br />".$connect->ErrorMsg()); //Checked
*/
$CI->load->model('questions_model');
$query = $CI->questions_model->getSubQuestions($sid,$sLanguage);

$query = "SELECT sq.*, q.other FROM {{questions}} as sq, {{questions}} as q"
." WHERE sq.parent_qid=q.qid AND q.sid=".$sid
." AND sq.language='".$sLanguage. "' "
." AND q.language='".$sLanguage. "' "
." ORDER BY sq.parent_qid, q.question_order,sq.scale_id , sq.question_order";

$query = Yii::app()->db->createCommand($query)->query();

$resultset=array();
//while ($row=$result->FetchRow())
foreach ($query->result_array() as $row)
foreach ($query->readAll() as $row)
{
$resultset[$row['parent_qid']][] = $row;
}
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/export/vv_view.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form id='vvexport' method='post' action='<?php echo site_url("admin/export/vvexport/$surveyid/export");?>'>
<form id='vvexport' method='post' action='<?php echo $this->createUrl("admin/export/sa/vvexport/surveyid/$surveyid/subaction/export");?>'>
<div class='header ui-widget-header'><?php echo $clang->gT("Export a VV survey file");?></div>
<ul>
<li>
Expand Down

0 comments on commit d35620f

Please sign in to comment.