Skip to content

Commit

Permalink
Deleting survey now possible!
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10365 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
sachdeva-shubham committed Jun 28, 2011
1 parent 82a2af4 commit 43eb775
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 2 deletions.
119 changes: 119 additions & 0 deletions application/controllers/admin/survey.php
Expand Up @@ -34,10 +34,124 @@ function view($surveyid)
self::_showadminmenu();
self::_surveybar($surveyid);
self::_surveysummary($surveyid);
$editsurvey = self::_loadEndScripts();

//echo $editsurvey;
$finaldata['display'] = $editsurvey;
$this->load->view('survey_view',$finaldata);
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));
}
}

function delete()
{
$css_admin_includes[] = $this->config->item('styleurl')."admin/default/superfish.css";
$this->config->set_item("css_admin_includes", $css_admin_includes);
self::_getAdminHeader();
self::_showadminmenu();
self::_surveybar($this->input->post('sid'));
$data['surveyid'] = $surveyid = $this->input->post('sid');
if(bHasSurveyPermission($surveyid,'survey','delete'))
{
$data['deleteok'] = $deleteok = $this->input->post('deleteok');
$data['clang'] = $this->limesurvey_lang;

$data['link'] = site_url("admin/survey/delete");
if (!(!isset($deleteok) || !$deleteok))
{
$this->load->dbforge();
if (tableExists("survey_$surveyid")) //delete the survey_$surveyid table
{
//$dsquery = $dict->DropTableSQL("{$dbprefix}survey_$surveyid");
//$dict->ExecuteSQLArray($sqlarray); $dict->ExecuteSQLArray($dsquery)
$dsresult = $this->dbforge->drop_table('survey_'.$surveyid) or safe_die ("Couldn't drop table survey_".$surveyid." in survey.php");
}

if (tableExists("survey_{$surveyid}_timings")) //delete the survey_$surveyid_timings table
{
//$dsquery = $dict->DropTableSQL("{$dbprefix}survey_{$surveyid}_timings");
//$dict->ExecuteSQLArray($sqlarraytimings);
$dsresult = $this->dbforge->drop_table('survey_'.$surveyid.'_timings') or safe_die ("Couldn't drop table survey_".$surveyid."_timings in survey.php");
}

if (tableExists("tokens_$surveyid")) //delete the tokens_$surveyid table
{
//$dsquery = $dict->DropTableSQL("{$dbprefix}tokens_$surveyid");
$dsresult = $this->dbforge->drop_table('tokens_'.$surveyid) or safe_die ("Couldn't drop table token_".$surveyid." in survey.php");
}

$dsquery = "SELECT qid FROM ".$this->db->dbprefix."questions WHERE sid=$surveyid";
$dsresult = db_execute_assoc($dsquery) or safe_die ("Couldn't find matching survey to delete<br />$dsquery<br />");
while ($dsrow = $dsresult->result_array())
{
//$asdel = "DELETE FROM {$dbprefix}answers WHERE qid={$dsrow['qid']}";
//$asres = $connect->Execute($asdel);
$this->db->delete('answers', array('qid' => $dsrow['qid']));
$this->db->delete('conditions', array('qid' => $dsrow['qid']));
$this->db->delete('question_attributes', array('qid' => $dsrow['qid']));
/**
$cddel = "DELETE FROM {$dbprefix}conditions WHERE qid={$dsrow['qid']}";
$cdres = $connect->Execute($cddel) or safe_die ("Delete conditions failed<br />$cddel<br />".$connect->ErrorMsg());
$qadel = "DELETE FROM {$dbprefix}question_attributes WHERE qid={$dsrow['qid']}";
$qares = $connect->Execute($qadel); */
}

//$qdel = "DELETE FROM {$dbprefix}questions WHERE sid=$surveyid";
//$qres = $connect->Execute($qdel);
$this->db->delete('questions', array('sid' => $surveyid));

//$scdel = "DELETE FROM {$dbprefix}assessments WHERE sid=$surveyid";
//$scres = $connect->Execute($scdel);
$this->db->delete('assessments', array('sid' => $surveyid));

//$gdel = "DELETE FROM {$dbprefix}groups WHERE sid=$surveyid";
//$gres = $connect->Execute($gdel);
$this->db->delete('groups', array('sid' => $surveyid));

//$slsdel = "DELETE FROM {$dbprefix}surveys_languagesettings WHERE surveyls_survey_id=$surveyid";
//$slsres = $connect->Execute($slsdel);
$this->db->delete('surveys_languagesettings', array('surveyls_survey_id' => $surveyid));

//$srdel = "DELETE FROM {$dbprefix}survey_permissions WHERE sid=$surveyid";
//$srres = $connect->Execute($srdel);
$this->db->delete('survey_permissions', array('sid' => $surveyid));

//$srdel = "DELETE FROM {$dbprefix}saved_control WHERE sid=$surveyid";
//$srres = $connect->Execute($srdel);
$this->db->delete('saved_control', array('sid' => $surveyid));

//$sdel = "DELETE FROM {$dbprefix}surveys WHERE sid=$surveyid";
//$sres = $connect->Execute($sdel);
$this->db->delete('surveys', array('sid' => $surveyid));

$sdel = "DELETE ".$this->db->dbprefix."quota_languagesettings FROM ".$this->db->dbprefix."quota_languagesettings, ".$this->db->dbprefix."quota WHERE ".$this->db->dbprefix."quota_languagesettings.quotals_quota_id=".$this->db->dbprefix."quota.id and sid=$surveyid";
$sres = db_execute_assoc($sdel);
//$sres = $connect->Execute($sdel);
//$this->db->delete('assessments', array('sid' => $surveyid));

//$sdel = "DELETE FROM {$dbprefix}quota WHERE sid=$surveyid";
//$sres = $connect->Execute($sdel);
$this->db->delete('quota', array('sid' => $surveyid));

//$sdel = "DELETE FROM {$dbprefix}quota_members WHERE sid=$surveyid;";
//$sres = $connect->Execute($sdel);
$this->db->delete('quota_members', array('sid' => $surveyid));
}
$this->load->view('admin/Survey/deleteSurvey_view',$data);
}
else {
//include('access_denied.php');
$finaldata['display'] = access_denied("editsurvey",$surveyid);
$this->load->view('survey_view',$finaldata);
}
$editsurvey = self::_loadEndScripts();

//echo $editsurvey;
$finaldata['display'] = $editsurvey;
$this->load->view('survey_view',$finaldata);
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));
}

function editlocalsettings($surveyid)
{
$clang = $this->limesurvey_lang;
Expand Down Expand Up @@ -168,6 +282,11 @@ function editlocalsettings($surveyid)
$this->load->view('survey_view',$finaldata);

}
$editsurvey = self::_loadEndScripts();

//echo $editsurvey;
$finaldata['display'] = $editsurvey;
$this->load->view('survey_view',$finaldata);
self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));

}
Expand Down
43 changes: 43 additions & 0 deletions application/views/admin/Survey/deleteSurvey_view.php
@@ -0,0 +1,43 @@
<br/>
<div class='messagebox ui-corner-all'>
<div class='header ui-widget-header'><?php echo $clang->gT("Delete survey"); ?>
</div>

<?php if (!isset($surveyid) || !$surveyid)
{ ?>
<font color='red'><strong><?php echo $clang->gT("Error"); ?></strong></font>
<?php echo $clang->gT("You have not selected a survey to delete"); ?>
<br /><br />
<input type='submit' value='<?php echo $clang->gT("Main Admin Screen"); ?>' onclick="window.open('<?php echo site_url("admin"); ?>', '_top')"/>
</td></tr></table>
</body></html>
<?php return;
}

if (!isset($deleteok) || !$deleteok)
{ ?>
<div class='warningheader'><?php echo $clang->gT("Warning"); ?></div><br />
<strong><?php echo $clang->gT("You are about to delete this survey"); ?> (<?php echo $surveyid; ?>)</strong><br /><br />
<?php echo $clang->gT("This process will delete this survey, and all related groups, questions answers and conditions."); ?><br /><br />
<?php echo $clang->gT("We recommend that before you delete this survey you export the entire survey from the main administration screen.");

if (tableExists("survey_$surveyid"))
{ ?>
<br /><br /><?php echo $clang->gT("This survey is active and a responses table exists. If you delete this survey, these responses will be deleted. We recommend that you export the responses before deleting this survey."); ?><br /><br />
<?php }

if (tableExists("tokens_$surveyid"))
{ ?>
<?php echo $clang->gT("This survey has an associated tokens table. If you delete this survey this tokens table will be deleted. We recommend that you export or backup these tokens before deleting this survey."); ?><br /><br />
<?php } ?>

<p>
<input type='submit' value='<?php echo $clang->gT("Delete survey"); ?>' onclick="<?php echo get2post("$link?action=deletesurvey&amp;sid=$surveyid&amp;deleteok=Y"); ?>" />
<input type='submit' value='<?php echo $clang->gT("Cancel"); ?>' onclick="window.open('<?php echo site_url("admin/survey/view/$surveyid"); ?>', '_top')" />
<?php }
else
{ ?>
<p><?php echo $clang->gT("This survey has been deleted."); ?><br /><br />
<input type='submit' value='<?php echo $clang->gT("Main Admin Screen"); ?>' onclick="window.open('<?php echo site_url("admin"); ?>', '_top')" />
<?php } ?>
</div><br />&nbsp;
2 changes: 1 addition & 1 deletion application/views/admin/Survey/surveybar.php
Expand Up @@ -93,7 +93,7 @@
<li><a href="#">
<img src='<?php echo $imageurl;?>/tools.png' name='SorveyTools' alt='<?php echo $clang->gT("Tools");?>' /></a><ul>
<?php if ($surveydelete) { ?>
<li><a href="#" onclick="<?php echo get2post(site_url("admin/database/index/deletesurvey")."?action=deletesurvey&amp;sid={$surveyid}");?>">
<li><a href="#" onclick="<?php echo get2post(site_url("admin/survey/delete")."?action=deletesurvey&amp;sid={$surveyid}");?>">
<img src='<?php echo $imageurl;?>/delete_30.png' name='DeleteSurvey' /> <?php echo $clang->gT("Delete survey");?></a></li>
<?php } ?>
<?php if ($surveytranslate) {
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/endScripts_view.php
Expand Up @@ -10,7 +10,7 @@
document.forms[i].appendChild(el);
}

function addHiddenElement(theform,thename,thevalue)"
function addHiddenElement(theform,thename,thevalue)
{
var myel = document.createElement('input');
myel.type = 'hidden';
Expand Down

0 comments on commit 43eb775

Please sign in to comment.