Skip to content

Commit

Permalink
Fixed issue #6745: Bad return url when trying to delete a question wi…
Browse files Browse the repository at this point in the history
…th 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
  • Loading branch information
Shnoulle committed Oct 24, 2012
1 parent ea71543 commit a7d3a99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
5 changes: 3 additions & 2 deletions application/controllers/AdminController.php
Expand Up @@ -63,7 +63,8 @@ public function error($message, $url = array())
$clang = $this->lang;

$this->_getAdminHeader();
$output = '<div class="warningheader">'.$clang->gT('Error').'</div><br />'."\n";
$output = "<div class='messagebox ui-corner-all'>\n";
$output .= '<div class="warningheader">'.$clang->gT('Error').'</div><br />'."\n";
$output .= $message . '<br /><br />'."\n";
if (!empty($url) && !is_array($url))
{
Expand All @@ -88,7 +89,7 @@ public function error($message, $url = array())
}
$output .= '<input type="submit" value="'.$title.'" onclick=\'window.open("'.$url.'", "_top")\' /><br /><br />'."\n";
$output .= '</div>'."\n";

$output .= '</div>'."\n";
echo $output;

$this->_getAdminFooter('http://docs.limesurvey.org', $clang->gT('LimeSurvey online manual'));
Expand Down
21 changes: 14 additions & 7 deletions application/controllers/admin/question.php
Expand Up @@ -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 .="<br /><a href='". $this->getController()->createUrl("admin/expressions/survey_logic_file/sid/{$surveyid}")."' >".$clang->gT("Look at survey logic files")."</a>.";
$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;
Expand Down

0 comments on commit a7d3a99

Please sign in to comment.