Skip to content

Commit

Permalink
Question groups list now added to surveymenu. Made helpers for Import…
Browse files Browse the repository at this point in the history
… and Copy survey(feature available after import controller is implemented). Fixed few errors in common_helper and groups_model!

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10354 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
sachdeva-shubham committed Jun 27, 2011
1 parent 9388326 commit 1ce437d
Show file tree
Hide file tree
Showing 11 changed files with 1,154 additions and 16 deletions.
163 changes: 163 additions & 0 deletions application/controllers/admin/survey.php
Expand Up @@ -38,6 +38,169 @@ function view($surveyid)
}
}

function copy()
{

if ( $this->input->post('copysurveytranslinksfields') == "on" || $this->input->post('translinksfields') == "on")
{
$sTransLinks = true;
}

//$importsurvey = "<div class='header ui-widget-header'>".$clang->gT("Copy survey")."</div>\n";
$copyfunction= true;
//$importsurvey .= "<div class='messagebox ui-corner-all'>\n";
$importerror=false; // Put a var for continue
$surveyid = sanitize_int($this->input->post('copysurveylist'));

$exclude = array();
if (get_magic_quotes_gpc()) {$sNewSurveyName = stripslashes($this->input->post('copysurveyname'));}
else{
$sNewSurveyName=$this->input->post('copysurveyname');
}

/*require_once("../classes/inputfilter/class.inputfilter_clean.php");
$myFilter = new InputFilter('','',1,1,1);
if ($filterxsshtml)
{
$sNewSurveyName = $myFilter->process($sNewSurveyName);
} else {
$sNewSurveyName = html_entity_decode($sNewSurveyName, ENT_QUOTES, "UTF-8");
} */
if ($this->input->post('copysurveyexcludequotas') == "on")
{
$exclude['quotas'] = true;
}
if ($this->input->post('copysurveyexcludeanswers') == "on")
{
$exclude['answers'] = true;
}
if ($this->input->post('copysurveyresetconditions') == "on")
{
$exclude['conditions'] = true;
}
echo "hi";
//include("export_structure_xml.php");
$this->load->helper('admin/export_structure_xml');

if (!isset($surveyid))
{
$surveyid=returnglobal('sid');
}

$clang = $this->limesurvey_lang;
if (!$surveyid)
{

self::_getAdminHeader();
self::_showadminmenu();
$data['clang'] = $clang;
$this->load->view('admin/Survey/exportSurveyError_view',$data);

exit;
}

if (!isset($copyfunction))
{
$fn = "limesurvey_survey_$surveyid.lss";
header("Content-Type: text/xml");
header("Content-Disposition: attachment; filename=$fn");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public"); // HTTP/1.0
echo getXMLData('',$surveyid);
exit;
}

$copysurveydata = getXMLData($exclude,$surveyid);
// $this->load->helper('import');
//require_once('import_functions.php');
if (!$importerror)
{
$aImportResults=XMLImportSurvey('',$copysurveydata,$sNewSurveyName);
}
else
{
$importerror=true;
}

/**
if (isset($aImportResults['error']) && $aImportResults['error']!=false)
{
$importsurvey .= "<div class='warningheader'>".$clang->gT("Error")."</div><br />\n";
$importsurvey .= $aImportResults['error']."<br /><br />\n";
$importsurvey .= "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_top')\" />\n";
$importerror = true;
}
if (!$importerror)
{
$importsurvey .= "<br />\n<div class='successheader'>".$clang->gT("Success")."</div><br /><br />\n";
$importsurvey .= "<strong>".$clang->gT("Survey import summary")."</strong><br />\n";
$importsurvey .= "<ul style=\"text-align:left;\">\n\t<li>".$clang->gT("Surveys").": {$aImportResults['surveys']}</li>\n";
$importsurvey .= "\t<li>".$clang->gT("Languages").": {$aImportResults['languages']}</li>\n";
$importsurvey .= "\t<li>".$clang->gT("Question groups").": {$aImportResults['groups']}</li>\n";
$importsurvey .= "\t<li>".$clang->gT("Questions").": {$aImportResults['questions']}</li>\n";
$importsurvey .= "\t<li>".$clang->gT("Answers").": {$aImportResults['answers']}</li>\n";
if (isset($aImportResults['subquestions']))
{
$importsurvey .= "\t<li>".$clang->gT("Subquestions").": {$aImportResults['subquestions']}</li>\n";
}
if (isset($aImportResults['defaultvalues']))
{
$importsurvey .= "\t<li>".$clang->gT("Default answers").": {$aImportResults['defaultvalues']}</li>\n";
}
if (isset($aImportResults['conditions']))
{
$importsurvey .= "\t<li>".$clang->gT("Conditions").": {$aImportResults['conditions']}</li>\n";
}
if (isset($aImportResults['labelsets']))
{
$importsurvey .= "\t<li>".$clang->gT("Label sets").": {$aImportResults['labelsets']}</li>\n";
}
if (isset($aImportResults['deniedcountls']) && $aImportResults['deniedcountls']>0)
{
$importsurvey .= "\t<li>".$clang->gT("Not imported label sets").": {$aImportResults['deniedcountls']} ".$clang->gT("(Label sets were not imported since you do not have the permission to create new label sets.)")."</li>\n";
}
$importsurvey .= "\t<li>".$clang->gT("Question attributes").": {$aImportResults['question_attributes']}</li>\n";
$importsurvey .= "\t<li>".$clang->gT("Assessments").": {$aImportResults['assessments']}</li>\n";
$importsurvey .= "\t<li>".$clang->gT("Quotas").": {$aImportResults['quota']} ({$aImportResults['quotamembers']} ".$clang->gT("quota members")." ".$clang->gT("and")." {$aImportResults['quotals']} ".$clang->gT("quota language settings").")</li>\n</ul><br />\n";
if (count($aImportResults['importwarnings'])>0)
{
$importsurvey .= "<div class='warningheader'>".$clang->gT("Warnings").":</div><ul style=\"text-align:left;\">";
foreach ($aImportResults['importwarnings'] as $warning)
{
$importsurvey .='<li>'.$warning.'</li>';
}
$importsurvey .= "</ul><br />\n";
}
$importsurvey .= "<strong>".$clang->gT("Copy of survey is completed.")."</strong><br />\n"
. "<a href='$scriptname?sid={$aImportResults['newsid']}'>".$clang->gT("Go to survey")."</a><br />\n";
}
// end of traitment an close message box
$importsurvey .= "</div><br />\n"; */

$data['clang'] = $clang;
$data['aImportResults'] = $aImportResults;
$data['importerror'] = $importerror;
self::_getAdminHeader();
self::_showadminmenu();
self::_surveybar($surveyid);
//self::_surveysummary($surveyid);
$this->load->view('admin/Survey/copySurvey_view',$data);
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));

}

function index($action)
{
global $surveyid;
Expand Down
36 changes: 33 additions & 3 deletions application/core/SurveyCommonController.php
Expand Up @@ -40,7 +40,7 @@ function _surveybar($surveyid)
{
//$this->load->helper('surveytranslator');
$clang = $this->limesurvey_lang;

echo $this->config->item('gid');
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$condition = array('sid' => $surveyid, 'language' => $baselang);
$this->load->model('surveys_model');
Expand Down Expand Up @@ -144,7 +144,33 @@ function _surveybar($surveyid)
$data['responsesread'] = bHasSurveyPermission($surveyid,'responses','read');
// TOKEN MANAGEMENT BUTTON
$data['tokenmanagement'] = bHasSurveyPermission($surveyid,'surveysettings','update') || bHasSurveyPermission($surveyid,'tokens','read');


$data['gid'] = $gid = $this->config->item('gid');

if (bHasSurveyPermission($surveyid,'surveycontent','read'))
{
$data['permission']= true;
}
else
{
$data['gid'] = $gid =null;
$qid=null;
}

if (getgrouplistlang($gid, $baselang))
{
$data['groups']= getgrouplistlang($gid, $baselang);
}
else
{
$data['groups']= "<option>".$clang->gT("None")."</option>";
}

$data['GidPrev'] = $GidPrev = getGidPrevious($surveyid, $gid);

$data['GidNext'] = $GidNext = getGidNext($surveyid, $gid);
$data['activated'] = $activated;

$this->load->view("admin/survey/surveybar",$data);


Expand Down Expand Up @@ -252,8 +278,12 @@ function _surveybar($surveyid)
$surveysummary .= "<img src='".$this->config->item('imageurl')."/blank.gif' width='18' alt='' />\n";
}
$surveysummary .= "</div>\n"
. "</div>\n"
. "</div>\n";
*/


}

/**
Expand Down

0 comments on commit 1ce437d

Please sign in to comment.