Skip to content

Commit

Permalink
added Feature: Lsrc export for groups and questions
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@7302 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Tim Wahrendorff committed Jul 13, 2009
1 parent 5c98e01 commit 4087e7a
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 32 deletions.
36 changes: 28 additions & 8 deletions admin/admin.php
Expand Up @@ -193,22 +193,42 @@
{
if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('export_structure_quexml.php');}
else { include('access_denied.php');}
}
elseif ($action == 'exportsurvresources')
}
elseif ($action == 'exportstructurecsvGroup')
{
if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {$_SESSION['FileManagerContext']="edit:survey:$surveyid";include('export_resources_zip.php');}
if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('dumpgroup.php');}
else { include('access_denied.php');}
}
elseif ($action == 'dumpquestion')
}
elseif ($action == 'exportstructureLsrcCsvGroup')
{
if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('dumpgroup.php');}
else { include('access_denied.php');}
}
elseif ($action == 'exportstructurecsvQuestion')
{
if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('dumpquestion.php');}
else { include('access_denied.php');}
}
elseif ($action == 'dumpgroup')
}
elseif ($action == 'exportstructureLsrcCsvQuestion')
{
if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('dumpgroup.php');}
if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('dumpquestion.php');}
else { include('access_denied.php');}
}
elseif ($action == 'exportsurvresources')
{
if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {$_SESSION['FileManagerContext']="edit:survey:$surveyid";include('export_resources_zip.php');}
else { include('access_denied.php');}
}
//elseif ($action == 'dumpquestion')
// {
// if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('dumpquestion.php');}
// else { include('access_denied.php');}
// }
//elseif ($action == 'dumpgroup')
// {
// if($surrows['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('dumpgroup.php');}
// else { include('access_denied.php');}
// }
elseif ($action == 'deactivate')
{
if($surrows['activate_survey'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) {include('deactivate.php');}
Expand Down
35 changes: 26 additions & 9 deletions admin/dumpgroup.php
Expand Up @@ -54,12 +54,6 @@
. "# Do not change this header!\n";


header("Content-Type: application/download");
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"); // always modified
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache");

//0: Groups Table
$gquery = "SELECT *
Expand Down Expand Up @@ -149,7 +143,30 @@
AND ({$dbprefix}questions.gid=$gid)";
$qadump = BuildCSVFromQuery($query);

// HTTP/1.0
echo $dumphead, $gdump, $qdump, $adump, $cdump, $lsdump, $ls1dump, $ldump, $l1dump, $qadump;
exit;
if($action=='exportstructureLsrcCsvGroup')
{
include_once($homedir.'/remotecontrol/lsrc.config.php');
$lsrcString = $dumphead. $gdump. $qdump. $adump. $cdump. $lsdump. $ls1dump. $ldump. $l1dump. $qadump;
//Select title as Filename and save
$groupTitleSql = "SELECT group_name
FROM {$dbprefix}groups
WHERE sid=$surveyid AND gid=$gid ";
$groupTitleRs = db_execute_assoc($groupTitleSql);
$groupTitle = $groupTitleRs->FetchRow();
file_put_contents("remotecontrol/".$modDir.substr($groupTitle['group_name'],0,20).".csv",$lsrcString);
}
else
{
// HTTP/1.0
header("Content-Type: application/download");
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"); // always modified
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache");

echo $dumphead, $gdump, $qdump, $adump, $cdump, $lsdump, $ls1dump, $ldump, $l1dump, $qadump;
exit;
}

?>
32 changes: 23 additions & 9 deletions admin/dumpquestion.php
Expand Up @@ -160,13 +160,27 @@ function BuildOutput($Query)
$qadump = BuildCSVFromQuery($query);
$fn = "limesurvey_question_$qid.csv";


header("Content-Type: application/download");
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: cache"); // HTTP/1.0
echo $dumphead, $qdump, $adump, $lsdump, $ls1dump, $ldump, $l1dump, $qadump;
exit;
if($action=='exportstructureLsrcCsvQuestion')
{
include_once($homedir.'/remotecontrol/lsrc.config.php');
$lsrcString = $dumphead. $qdump. $adump. $lsdump. $ls1dump. $ldump. $l1dump. $qadump;
//Select title as Filename and save
$questionTitleSql = "SELECT title
FROM {$dbprefix}questions
WHERE qid=$qid AND sid=$surveyid AND gid=$gid ";
$questionTitleRs = db_execute_assoc($questionTitleSql);
$questionTitle = $questionTitleRs->FetchRow();
file_put_contents("remotecontrol/".$queDir.substr($questionTitle['title'],0,20).".csv",$lsrcString);
}
else
{
header("Content-Type: application/download");
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: cache"); // HTTP/1.0
echo $dumphead, $qdump, $adump, $lsdump, $ls1dump, $ldump, $l1dump, $qadump;
exit;
}
?>
121 changes: 115 additions & 6 deletions admin/html.php
Expand Up @@ -1097,7 +1097,7 @@
if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $sumrows5['export'])
{

$groupsummary .="<a href='$scriptname?action=dumpgroup&amp;sid=$surveyid&amp;gid=$gid' onmouseout=\"hideTooltip()\""
$groupsummary .="<a href='$scriptname?action=exportstructureGroup&amp;sid=$surveyid&amp;gid=$gid' onmouseout=\"hideTooltip()\""
. "title=\"".$clang->gTview("Export current question group")."\" "
. "onmouseover=\"showTooltip(event,'".$clang->gT("Export Current Group", "js")."');return false\">" .
"<img src='$imagefiles/exportcsv.png' title='' alt='' name='ExportGroup' /></a>\n";
Expand Down Expand Up @@ -1251,7 +1251,7 @@

if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $sumrows5['export'])
{
$questionsummary .= "<a href='$scriptname?action=dumpquestion&amp;sid=$surveyid&amp;qid=$qid' onmouseout=\"hideTooltip()\""
$questionsummary .= "<a href='$scriptname?action=exportstructureQuestion&amp;sid=$surveyid&amp;gid=$gid&amp;qid=$qid' onmouseout=\"hideTooltip()\""
. "title=\"".$clang->gTview("Export this Question")."\" "
. "onmouseover=\"showTooltip(event,'".$clang->gT("Export this Question", "js")."');return false\">" .
"<img src='$imagefiles/exportcsv.png' title='' alt='' name='ExportQuestion' /></a>\n";
Expand Down Expand Up @@ -2071,11 +2071,13 @@
.$clang->gT("Export Survey Structure")."\n</td></tr>\n"
."<tr>\n"
."<td style='text-align:center;'>\n";
$exportstructure.="<br /><input type='radio' class='radiobtn' name='type' value='structurecsv' checked='checked' id='surveycsv' onclick=\"this.form.action.value='exportstructurecsv'\";/>"
$exportstructure.="<br /><input type='radio' class='radiobtn' name='type' value='structurecsv' checked='checked' id='surveycsv'
onclick=\"this.form.action.value='exportstructurecsv'\" />"
."<label for='surveycsv'>"
.$clang->gT("LimeSurvey Survey File (*.csv)")."</label><br />\n";

$exportstructure.="<input type='radio' class='radiobtn' name='type' value='structurequeXML' id='queXML' onclick=\"this.form.action.value='exportstructurequexml'\" />"
$exportstructure.="<input type='radio' class='radiobtn' name='type' value='structurequeXML' id='queXML'
onclick=\"this.form.action.value='exportstructurequexml'\" />"
."<label for='queXML'>"
.$clang->gT("queXML Survey XML Format (*.xml)")." "
."</label>\n";
Expand All @@ -2086,7 +2088,8 @@
//echo $export4lsrc;
if($export4lsrc)
{
$exportstructure.="<br/><input type='radio' class='radiobtn' name='type' value='structureLsrcCsv' id='LsrcCsv' onclick=\"this.form.action.value='exportstructureLsrcCsv'\" />"
$exportstructure.="<br/><input type='radio' class='radiobtn' name='type' value='structureLsrcCsv' id='LsrcCsv'
onclick=\"this.form.action.value='exportstructureLsrcCsv'\" />"
."<label for='LsrcCsv'>"
.$clang->gT("Save for Lsrc (*.csv)")." "
."</label>\n";
Expand All @@ -2103,10 +2106,116 @@
."<input type='hidden' name='action' value='exportstructurecsv' />\n"
."</td>\n"
."</tr>\n";
$exportstructure.="</table><br /></from>\n";
$exportstructure.="</table><br /></form>\n";
}
}

// This is the action to export the structure of a group
if($action == "exportstructureGroup")
{
if($export4lsrc === true && ($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $sumrows5['export']))
{
$exportstructure = "<form name='exportstructureGroup' action='$scriptname' method='post'>\n"
."<table width='100%' border='0' >\n<tr><td class='settingcaption'>"
.$clang->gT("Export Group Structure")."\n</td></tr>\n"
."<tr>\n"
."<td style='text-align:center;'>\n";
$exportstructure.="<br /><input type='radio' class='radiobtn' name='type' value='structurecsvGroup' checked='checked' id='surveycsv'
onclick=\"this.form.action.value='exportstructurecsvGroup'\"/>"
."<label for='surveycsv'>"
.$clang->gT("LimeSurvey Group File (*.csv)")."</label><br />\n";

// $exportstructure.="<input type='radio' class='radiobtn' name='type' value='structurequeXMLGroup' id='queXML' onclick=\"this.form.action.value='exportstructurequexml'\" />"
// ."<label for='queXML'>"
// .$clang->gT("queXML Survey XML Format (*.xml)")." "
// ."</label>\n";

// XXX
include("../config.php");

//echo $export4lsrc;
if($export4lsrc)
{
$exportstructure.="<br/><input type='radio' class='radiobtn' name='type' value='structureLsrcCsvGroup' id='LsrcCsv'
onclick=\"this.form.action.value='exportstructureLsrcCsvGroup'\" />"
."<label for='LsrcCsv'>"
.$clang->gT("Save for Lsrc (*.csv)")." "
."</label>\n";
}

$exportstructure.="<br />&nbsp;</td>\n"
."</tr>\n"
."<tr><td height='2' bgcolor='silver'></td></tr>\n"
."<tr>\n"
."<td align='center'>\n"
."<input type='submit' value='"
.$clang->gT("Export To File")."' />\n"
."<input type='hidden' name='sid' value='$surveyid' />\n"
."<input type='hidden' name='gid' value='$gid' />\n"
."<input type='hidden' name='action' value='exportstructurecsvGroup' />\n"
."</td>\n"
."</tr>\n";
$exportstructure.="</table><br /></form>\n";
}
else
{
include('dumpgroup.php');
}
}

// This is the action to export the structure of a question
if($action == "exportstructureQuestion")
{
if($export4lsrc === true && ($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $sumrows5['export']))
{
$exportstructure = "<form name='exportstructureQuestion' action='$scriptname' method='post'>\n"
."<table width='100%' border='0' >\n<tr><td class='settingcaption'>"
.$clang->gT("Export Question Structure")."\n</td></tr>\n"
."<tr>\n"
."<td style='text-align:center;'>\n";
$exportstructure.="<br /><input type='radio' class='radiobtn' name='type' value='structurecsvQuestion' checked='checked' id='surveycsv'
onclick=\"this.form.action.value='exportstructurecsvQuestion'\"/>"
."<label for='surveycsv'>"
.$clang->gT("LimeSurvey Group File (*.csv)")."</label><br />\n";

// $exportstructure.="<input type='radio' class='radiobtn' name='type' value='structurequeXMLGroup' id='queXML' onclick=\"this.form.action.value='exportstructurequexml'\" />"
// ."<label for='queXML'>"
// .$clang->gT("queXML Survey XML Format (*.xml)")." "
// ."</label>\n";

// XXX
include("../config.php");

//echo $export4lsrc;
if($export4lsrc)
{
$exportstructure.="<br/><input type='radio' class='radiobtn' name='type' value='structureLsrcCsvQuestion' id='LsrcCsv'
onclick=\"this.form.action.value='exportstructureLsrcCsvQuestion'\" />"
."<label for='LsrcCsv'>"
.$clang->gT("Save for Lsrc (*.csv)")." "
."</label>\n";
}

$exportstructure.="<br />&nbsp;</td>\n"
."</tr>\n"
."<tr><td height='2' bgcolor='silver'></td></tr>\n"
."<tr>\n"
."<td align='center'>\n"
."<input type='submit' value='"
.$clang->gT("Export To File")."' />\n"
."<input type='hidden' name='sid' value='$surveyid' />\n"
."<input type='hidden' name='gid' value='$gid' />\n"
."<input type='hidden' name='qid' value='$qid' />\n"
."<input type='hidden' name='action' value='exportstructurecsvQuestion' />\n"
."</td>\n"
."</tr>\n";
$exportstructure.="</table><br /></form>\n";
}
else
{
include('dumpquestion.php');
}
}

if($action == "surveysecurity")
{
Expand Down

0 comments on commit 4087e7a

Please sign in to comment.