Skip to content

Commit

Permalink
Dev: Factor out activation error to view
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jan 12, 2018
1 parent c928c2e commit bcefe6c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
15 changes: 2 additions & 13 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -798,19 +798,8 @@ public function activate($iSurveyID)
// Special feedback from plugin
$aViewUrls['output'] = $aResult['pluginFeedback'];
} else if (isset($aResult['error'])) {
$aViewUrls['output'] = "<br />\n<div class='messagebox ui-corner-all'>\n";
if ($aResult['error'] == 'surveytablecreation') {
$aViewUrls['output'] .= "<div class='alert alert-warning' role='alert'>".gT("The survey response table could not be created.")." ".gT("Usually this is caused by having too many (sub-)questions in your survey. Please try removing questions from your survey.")."</div>\n";
} else {
$aViewUrls['output'] .= "<div class='alert alert-success' role='alert'>".gT("Timings table could not be created.")."</div>\n";
}
if (App()->getConfig('debug')) {
$aViewUrls['output'] .= "<strong class='text-warning'>".
gT("Database error!!")."\n "."\n".
"<pre>".var_export($aResult['error'], true)."</pre>\n";
}

$aViewUrls['output'] .= "<a href='".Yii::app()->getController()->createUrl("admin/survey/sa/view/surveyid/".$iSurveyID)."'>".gT("Main Admin Screen")."</a>\n</strong><br/>";
$data['result'] = $aResult;
$aViewUrls['output'] = $this->getController()->renderPartial('/admin/survey/_activation_error', $data, true);
} else {
$warning = (isset($aResult['warning'])) ?true:false;
$allowregister = $survey->isAllowRegister;
Expand Down
30 changes: 30 additions & 0 deletions application/views/admin/survey/_activation_error.php
@@ -0,0 +1,30 @@
<?php
/**
* View for the message box when survey activation goes wrong.
*/
?>

<div id="pjax-content" class="ls-flex-column align-items-flex-start align-content-center col-11 ls-flex-item transition-animate-width">
<div id="in_survey_common" class="container-fluid ls-flex-column fill col-12 overflow-enabled">
<div class="row col-12">
<h3 class="pagetitle"><?php eT('Activate survey error'); ?></h3>
<?php if ($result['error'] == 'surveytablecreation'): ?>
<div class='alert alert-warning' role='alert'>
<?php eT("The survey response table could not be created."); ?>
<?php eT("Usually this is caused by having too many (sub-)questions in your survey. Please try removing questions from your survey."); ?>
</div>
<?php else: ?>
<div class='alert alert-warning' role='alert'>
<?php eT("Timings table could not be created."); ?>
</div>
<?php endif; ?>

<?php if (App()->getConfig('debug')): ?>
<p><?php eT('Database error'); ?></p>
<pre>
<?php echo $result['error']; ?>
</pre>
<?php endif; ?>
</div>
</div>
</div>

0 comments on commit bcefe6c

Please sign in to comment.