diff --git a/application/controllers/admin/surveyaction.php b/application/controllers/admin/surveyaction.php
index 132730fffb7..13492cf8706 100644
--- a/application/controllers/admin/surveyaction.php
+++ b/application/controllers/admin/surveyaction.php
@@ -499,22 +499,16 @@ public function getSurveys_json()
$clang = $this->getController()->lang;
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
- $page = Yii::app()->request->getPost('page');
- $limit = Yii::app()->request->getPost('rows');
-
$surveys = Survey::model();
//!!! Is this even possible to execute?
if (empty(Yii::app()->session['USER_RIGHT_SUPERADMIN']))
$surveys->permission(Yii::app()->user->getId());
$surveys = $surveys->with('languagesettings', 'owner')->findAll();
- $aSurveyEntries->page = $page;
- $aSurveyEntries->records = count($surveys);
- $aSurveyEntries->total = ceil($aSurveyEntries->records / $limit);
- for ($i = 0, $j = ($page - 1) * $limit; $i < $limit && $j < $aSurveyEntries->records; $i++, $j++)
+ $aSurveyEntries->page = 1;
+ foreach ($surveys as $rows)
{
$aSurveyEntry = array();
- $rows = $surveys[$j];
$rows = array_merge($rows->attributes, $rows->languagesettings->attributes, $rows->owner->attributes);
// Set status
@@ -557,7 +551,7 @@ public function getSurveys_json()
'' . $rows['sid'] . '';
//Set Title
- $aSurveyEntry[] = '' . $rows['surveyls_title'] . '';
+ $aSurveyEntry[] = '' . $rows['surveyls_title'] . '';
//Set Date
Yii::import('application.libraries.Date_Time_Converter', true);
@@ -618,8 +612,7 @@ public function getSurveys_json()
{
$aSurveyEntry[] = $aSurveyEntry[] = $aSurveyEntry[] = $aSurveyEntry[] = $aSurveyEntry[] = '';
}
- $aSurveyEntries->rows[$i]['id'] = $rows['sid'];
- $aSurveyEntries->rows[$i]['cell'] = $aSurveyEntry;
+ $aSurveyEntries->rows[] = array('id' => $rows['sid'], 'cell' => $aSurveyEntry);
}
echo ls_json_encode($aSurveyEntries);
@@ -659,6 +652,24 @@ public function delete($surveyid, $delete = 'no')
$this->_renderWrappedTemplate($aViewUrls, $aData);
}
+ /**
+ * Takes the edit call from the detailed survey view, which either deletes the survey information
+ */
+ function editSurvey_json()
+ {
+ $operation = Yii::app()->request->getPost('oper');
+ $surveyids = Yii::app()->request->getPost('id');
+ if ($operation == 'del') // If operation is delete , it will delete, otherwise edit it
+ {
+ foreach(explode(',',$surveyids) as $surveyid)
+ {
+ if (bHasSurveyPermission($surveyid, 'survey', 'delete'))
+ {
+ $this->_deleteSurvey($surveyid);
+ }
+ }
+ }
+ }
/**
* Load editing of local settings of a survey screen.
*
diff --git a/application/views/admin/survey/listSurveys_view.php b/application/views/admin/survey/listSurveys_view.php
index 852a7c98e61..3f7cbb75226 100644
--- a/application/views/admin/survey/listSurveys_view.php
+++ b/application/views/admin/survey/listSurveys_view.php
@@ -5,8 +5,8 @@
var delmsg ='eT("Are you sure you want to delete these surveys?",'js');?>';
var sConfirmationExpireMessage='eT("Are you sure you want to expire these surveys?",'js');?>';
var sConfirmationArchiveMessage='eT("This function creates a ZIP archive of several survey archives and can take some time - please be patient! Do you want to continue?",'js');?>';
-var jsonUrl = "getController()->createUrl('admin/survey/getSurveys_json'); ?>";
-var editUrl = "createUrl('admin/survey/surveyactions'); ?>";
+var jsonUrl = "getController()->createUrl('/admin/survey/getSurveys_json'); ?>";
+var editUrl = "createUrl('/admin/survey/editSurvey_json'); ?>";
var colNames = ["eT("Status") ?>","eT("SID") ?>","eT("Survey") ?>","eT("Date created") ?>","eT("Owner") ?>","eT("Access") ?>","eT("Anonymized responses") ?>","eT("Full") ?>","eT("Partial") ?>","eT("Total") ?>","eT("Tokens available") ?>","eT("Response rate") ?>"];
var colModels = [{ "name":"status", "index":"status", "width":15, "align":"center", "sorttype":"string", "sortable": true, "editable":false},
{ "name":"sid", "index":"sid", "sorttype":"int", "sortable": true, "width":25, "align":"center", "editable":false},
diff --git a/scripts/admin/listsurvey.js b/scripts/admin/listsurvey.js
index 755a39f6e42..a770b7f8f0c 100644
--- a/scripts/admin/listsurvey.js
+++ b/scripts/admin/listsurvey.js
@@ -68,7 +68,7 @@ jQuery("#displaysurveys").jqGrid({
pager: "#pager",
caption: "Surveys",
});
-jQuery("#displaysurveys").jqGrid('navGrid','#pager',{ add:false,del:false,edit:false,refresh: false,search: true},{},{},{ msg:delmsg, width : 700 });
+jQuery("#displaysurveys").jqGrid('navGrid','#pager',{ add:false,del:true,edit:false,refresh: false,search: true},{},{},{ msg:delmsg, width : 700 });
jQuery("#displaysurveys").jqGrid('filterToolbar', {searchOnEnter : false});
jQuery("#displaysurveys").jqGrid('navButtonAdd','#pager',{
buttonicon:"ui-icon-refresh",