Browse Source

Add configuration setting to hide edition options for surveys - refs BT#13203

Angel Fernando Quiroz Campos 7 years ago
parent
commit
971c73cc6a
2 changed files with 19 additions and 1 deletions
  1. 3 0
      main/install/configuration.dist.php
  2. 16 1
      main/survey/surveyUtil.class.php

+ 3 - 0
main/install/configuration.dist.php

@@ -467,6 +467,9 @@ ALTER TABLE c_survey_question ADD is_required TINYINT(1) DEFAULT 0 NOT NULL;
 //$_configuration['allow_required_survey_questions'] = false;
 // Hide Survey Reporting button
 //$_configuration['hide_survey_reporting_button'] = false;
+// Hide survey edition tools for all or some surveys.
+//Set an asterisk to hide for all, otherwise set an array with the survey codes in which the options will be blocked
+//$_configuration['hide_survey_edition'] = ['codes' => []];
 // ------
 
 // Allow career diagram, requires a DB change:

+ 16 - 1
main/survey/surveyUtil.class.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+use Chamilo\CourseBundle\Entity\CSurvey;
 
 /**
  * This class offers a series of general utility functions for survey querying and display
@@ -2662,7 +2663,21 @@ class SurveyUtil
      */
     public static function modify_filter($survey_id, $drh = false)
     {
-        $survey_id = Security::remove_XSS($survey_id);
+        /** @var CSurvey $survey */
+        $survey = Database::getManager()->find('ChamiloCourseBundle:CSurvey', $survey_id);
+        $hideSurveyEdition = api_get_configuration_value('hide_survey_edition');
+
+        if (false !== $hideSurveyEdition) {
+            if ('*' === $hideSurveyEdition['codes']) {
+                return '';
+            }
+
+            if (in_array($survey->getCode(), $hideSurveyEdition['codes'])) {
+                return '';
+            }
+        }
+
+        $survey_id = $survey->getSurveyId();
         $return = '';
         $hideReportingButton = api_get_configuration_value('hide_survey_reporting_button');