diff --git a/application/config/config-defaults.php b/application/config/config-defaults.php index 3f7b4facdf7..1fe5ed92145 100644 --- a/application/config/config-defaults.php +++ b/application/config/config-defaults.php @@ -94,7 +94,9 @@ $config['memory_limit'] = '256'; // This sets how much memory LimeSurvey can access in megabytes. 256 MB is the minimum recommended - if you are using PDF functions up to 512 MB may be needed $config['showpopups'] = 1; // Show popup messages if mandatory or conditional questions have not been answered correctly. -// 1=Show popup message, 0=Show message on page instead. +// 1 = Show popup message (default) +// 0 = Show message on page instead; +// -1 = Do not show the message at all (in this case, users will still see the question-specific tips indicating which questions must be answered). $config['maxemails'] = 50; // The maximum number of emails to send in one go (this is to prevent your mail server or script from timeouting when sending mass mail) diff --git a/application/controllers/admin/themes.php b/application/controllers/admin/themes.php index bdb320164c6..e33e3704700 100755 --- a/application/controllers/admin/themes.php +++ b/application/controllers/admin/themes.php @@ -75,7 +75,6 @@ public function templatezip($templatename) } } - /** * Exports a deprecated template * @@ -89,10 +88,39 @@ public function deprecatedtemplatezip($templatename) $templatename = sanitize_dirname($templatename); $usertemplaterootdir = Yii::app()->getConfig("uploaddir").DIRECTORY_SEPARATOR."templates"; $templatePath = $usertemplaterootdir.DIRECTORY_SEPARATOR.$templatename; + $this->folderzip($templatename, $templatePath); + } + /** + * Exports a broken theme + * + * @access public + * @param string $templatename + * @return void + */ + public function brokentemplatezip($templatename) + { + //$oEditedTemplate = Template::model()->getTemplateConfiguration($templatename); + $templatename = sanitize_dirname($templatename); + $templatePath = Yii::app()->getConfig("userthemerootdir").DIRECTORY_SEPARATOR.$templatename; + $this->folderzip($templatename, $templatePath); + } + + /** + * Exports a theme folder + * NOTE: This function must remain private !!! it doesn't sanitize the $templatePath + * This should be done by the proxy function (eg: deprecatedtemplatezip(), brokentemplatezip() ) + * + * @access public + * @param string $templatename + * @return void + */ + private function folderzip($templatename, $templatePath) + { if (!Permission::model()->hasGlobalPermission('templates','export')){ - die('No permission'); + Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error'); + $this->getController()->redirect(array("admin/themeoptions")); } $tempdir = Yii::app()->getConfig('tempdir'); @@ -116,8 +144,8 @@ public function deprecatedtemplatezip($templatename) // Delete the temporary file unlink($zipfile); } - } + } /** * Retrieves a temporary template file from disk @@ -616,10 +644,28 @@ public function delete($templatename) } else { Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error'); } + + // Redirect with default templatename, editfile and screenname $this->getController()->redirect(array("admin/themeoptions")); } + public function deleteBrokenTheme($templatename) + { + // First we check that the theme is really broken + $aBrokenThemes = Template::getBrokenThemes(); + $templatename = sanitize_dirname($templatename); + if (array_key_exists($templatename, $aBrokenThemes)) { + if (rmdirr(Yii::app()->getConfig('userthemerootdir')."/".$templatename)){ + Yii::app()->setFlashMessage(sprintf(gT("Theme '%s' was successfully deleted."), $templatename)); + } + }else{ + Yii::app()->setFlashMessage(gT("Not a broken theme!"), 'error'); + } + + $this->getController()->redirect(array("admin/themeoptions")); + } + /** * Function responsible to save the changes made in CodemMirror editor. * @@ -1185,7 +1231,7 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma $thissurvey['include_content'] = $sContentFile; - + try { $myoutput = Yii::app()->twigRenderer->renderTemplateForTemplateEditor( $sLayoutFile, diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 93f3e2ceff6..25b0fca82d4 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -391,8 +391,8 @@ public function run($surveyid, $args) $bShowpopups = Yii::app()->getConfig('showpopups'); $aErrorHtmlMessage = $this->getErrorHtmlMessage(); - $this->aSurveyInfo['errorHtml']['show'] = !empty($aErrorHtmlMessage); - $this->aSurveyInfo['errorHtml']['hiddenClass'] = $bShowpopups ? "ls-js-hidden " : ""; + $this->aSurveyInfo['errorHtml']['show'] = !empty($aErrorHtmlMessage) && $bShowpopups==0; + $this->aSurveyInfo['errorHtml']['hiddenClass'] = $bShowpopups==1 ? "ls-js-hidden " : ""; $this->aSurveyInfo['errorHtml']['messages'] = $aErrorHtmlMessage; $_gseq = -1; @@ -1420,7 +1420,7 @@ private function getErrorHtmlMessage() } // Question(s) with not valid answer(s) - if ($this->aStepInfo['valid'] && $this->okToShowErrors) { + if (!$this->aStepInfo['valid'] && $this->okToShowErrors) { $aErrorsMandatory[] = gT("One or more questions have not been answered in a valid manner. You cannot proceed until these answers are valid."); } diff --git a/application/models/Assessment.php b/application/models/Assessment.php index 778c0465546..0d3d6e175c1 100644 --- a/application/models/Assessment.php +++ b/application/models/Assessment.php @@ -92,30 +92,31 @@ public function getButtons() { $buttons = "
+ | ||
---|---|---|
+ | getMessage(); ?> |
+ + + + hasGlobalPermission('templates','export') && function_exists("zip_open")):?> + + + + + + + + hasGlobalPermission('templates','delete')):?> + ", "_top")'> + + + + + + | +
" + text + "
" || ""); - $("#bootstrap-alert-box-modal").modal('show'); + if (LSvar.showpopup===1) { + $("#bootstrap-alert-box-modal .modal-header .modal-title").text(title || ""); + $("#bootstrap-alert-box-modal .modal-body").html("" + text + "
" || ""); + $("#bootstrap-alert-box-modal").modal('show'); + } }, /* confirmSurveyDialog @see application/core/package/limesurvey */ confirmSurveyDialog: function (text, title, submits) {