From a7d3a997abe4900933a642fe0ced4d5605a07a3d Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Wed, 24 Oct 2012 17:01:35 +0200 Subject: [PATCH] Fixed issue #6745: Bad return url when trying to delete a question with condition Dev: all error_view had to be reworked. Dev: find a way to have question/error_view groups/error_view ... in one file (admin/error_view): put in dev --- application/controllers/AdminController.php | 5 +++-- application/controllers/admin/question.php | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/application/controllers/AdminController.php b/application/controllers/AdminController.php index 367cd22a4b3..0cf1f2b009e 100644 --- a/application/controllers/AdminController.php +++ b/application/controllers/AdminController.php @@ -63,7 +63,8 @@ public function error($message, $url = array()) $clang = $this->lang; $this->_getAdminHeader(); - $output = '
'.$clang->gT('Error').'

'."\n"; + $output = "
\n"; + $output .= '
'.$clang->gT('Error').'

'."\n"; $output .= $message . '

'."\n"; if (!empty($url) && !is_array($url)) { @@ -88,7 +89,7 @@ public function error($message, $url = array()) } $output .= '

'."\n"; $output .= '
'."\n"; - + $output .= ''."\n"; echo $output; $this->_getAdminFooter('http://docs.limesurvey.org', $clang->gT('LimeSurvey online manual')); diff --git a/application/controllers/admin/question.php b/application/controllers/admin/question.php index 66c4e925f52..bb3e5cf1d64 100644 --- a/application/controllers/admin/question.php +++ b/application/controllers/admin/question.php @@ -861,17 +861,24 @@ public function delete($surveyid, $gid, $qid) // Check if any other questions have conditions which rely on this question. Don't delete if there are. // TMSW Conditions->Relevance: Allow such deletes - can warn about missing relevance separately. $ccresult = Conditions::model()->findAllByAttributes(array('cqid' => $qid)); - $cccount = count($ccresult); - foreach ($ccresult as $ccr) - $qidarray[] = $ccr->qid; - - if (isset($qidarray)) - $qidlist = implode(", ", $qidarray); // There are conditions dependent on this question if ($cccount) - $this->getController()->error($clang->gT("Question could not be deleted. There are conditions for other questions that rely on this question. You cannot delete this question until those conditions are removed")); + { + foreach ($ccresult as $ccr) + { + $qidarray[] = $ccr->qid; + } + if (isset($qidarray)) + $qidlist = implode(", ", $qidarray); + $message =$clang->gT("Question could not be deleted. There are conditions for other questions that rely on this question. You cannot delete this question until those conditions are removed."); + $message .="
".$clang->gT("Look at survey logic files")."."; + $this->getController()->error( + $message, + $this->getController()->createUrl("admin/survey/view/surveyid/{$surveyid}/gid/{$gid}/qid/{$qid}") + ); + } else { $row = Questions::model()->findByAttributes(array('qid' => $qid))->attributes;