From 054fabfbb8765d6fc656639f981852eaf7bc28b3 Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 26 Jul 2008 15:17:03 +0000 Subject: [PATCH] MDL-11844 new option for conditional stripping of tags from activity names; backported from HEAD --- admin/settings/appearance.php | 5 +++++ lang/en_utf8/admin.php | 3 +++ mod/assignment/mod_form.php | 6 +++++- mod/chat/mod_form.php | 6 +++++- mod/choice/mod_form.php | 8 ++++++-- mod/data/mod_form.php | 6 +++++- mod/exercise/mod_form.php | 6 +++++- mod/forum/mod_form.php | 6 +++++- mod/glossary/mod_form.php | 6 +++++- mod/hotpot/mod_form.php | 6 +++++- mod/journal/mod_form.php | 8 ++++++-- mod/lesson/mod_form.php | 8 ++++++-- mod/quiz/mod_form.php | 6 +++++- mod/resource/mod_form.php | 6 +++++- mod/scorm/mod_form.php | 6 +++++- mod/survey/mod_form.php | 6 +++++- version.php | 2 +- 17 files changed, 82 insertions(+), 18 deletions(-) diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index cee6f4e62ac..48aecf40c5c 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -62,6 +62,11 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $temp->add(new admin_setting_emoticons()); $ADMIN->add('appearance', $temp); + // "htmlsettings" settingpage + $temp = new admin_settingpage('htmlsettings', get_string('htmlsettings', 'admin')); + $temp->add(new admin_setting_configcheckbox('formatstringstriptags', get_string('stripalltitletags', 'admin'), get_string('configstripalltitletags', 'admin'), 1)); + $ADMIN->add('appearance', $temp); + // "documentation" settingpage $temp = new admin_settingpage('documentation', get_string('moodledocs')); $temp->add(new admin_setting_configtext('docroot', get_string('docroot', 'admin'), get_string('configdocroot', 'admin'), 'http://docs.moodle.org', PARAM_URL)); diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index 964df2e080c..78937ed2de4 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -231,6 +231,7 @@ $string['configstatsmaxruntime'] = 'Stats processing can be quite intensive, so $string['configstatsmaxruntime2'] = 'Stats processing can be quite intensive, specify maximum time allowed for gathering of one day of statistics. Maximum number of days processed in one cron execution is 3.'; $string['configstatsruntimestart'] = 'What time should the cronjob that does the stats processing start? Please specify different times if there are multiple Moodles on one physical server.'; $string['configstatsuserthreshold'] = 'If you enter a non-zero, non numeric value here, for ranking courses, courses with less than this number of enrolled users (all roles) will be ignored'; +$string['configstripalltitletags'] = 'By default all HTML tags are removed from all titles of activities, posts, blogs, etc. Uncheck this if you want to allow html tags in activity names.'; $string['configsupportemail'] = 'This email address will be published to users of this site as the one to email when they need general help (for example, when new users create their own accounts). If this email is left blank then no such helpful email address is supplied.'; $string['configsupportname'] = 'This is the name of a person or other entity offering general help via the support email or web address.'; $string['configsupportpage'] = 'This web address will be published to users of this site as the one to go to when they need general help (for example, when new users create their own accounts). If this address is left blank then no link will be supplied.'; @@ -395,6 +396,7 @@ $string['hidefromall'] = 'Hide from all users'; $string['hidefromnone'] = 'Hide from nobody'; $string['hidefromstudents'] = 'Hide from students'; $string['htmleditor'] = 'HTML editor'; +$string['htmlsettings'] = 'HTML settings'; $string['http'] = 'HTTP'; $string['httpsecurity'] = 'HTTP security'; $string['iconvrecommended'] = 'Installing the optional ICONV library is highly recommended in order to improve site performance, particularly if your site is supporting non-Latin languages.'; @@ -664,6 +666,7 @@ $string['stickyblockscourseview'] = 'Course page'; $string['stickyblocksduplicatenotice'] = 'If any block you add here is already present in a particular page, it will result in a duplicate.
Only the pinned block will be non-editable, the duplicate will still be editable.'; $string['stickyblocksmymoodle'] = 'My Moodle'; $string['stickyblockspagetype'] = 'Page type to configure'; +$string['stripalltitletags'] = 'Remove HTML tags from all titles'; $string['supportemail'] = 'Support email'; $string['supportname'] = 'Support name'; $string['supportpage'] = 'Support page'; diff --git a/mod/assignment/mod_form.php b/mod/assignment/mod_form.php index 7bf25f53b36..c3bfe2594d7 100644 --- a/mod/assignment/mod_form.php +++ b/mod/assignment/mod_form.php @@ -32,7 +32,11 @@ class mod_assignment_mod_form extends moodleform_mod { // $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment')); $mform->addElement('text', 'name', get_string('assignmentname', 'assignment'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'description', get_string('description', 'assignment')); diff --git a/mod/chat/mod_form.php b/mod/chat/mod_form.php index af8a6032e18..54fb53ac66b 100644 --- a/mod/chat/mod_form.php +++ b/mod/chat/mod_form.php @@ -12,7 +12,11 @@ class mod_chat_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('chatname', 'chat'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'intro', get_string('chatintro', 'chat')); diff --git a/mod/choice/mod_form.php b/mod/choice/mod_form.php index 3f752b34c91..8ca069ae12a 100644 --- a/mod/choice/mod_form.php +++ b/mod/choice/mod_form.php @@ -4,7 +4,7 @@ require_once ($CFG->dirroot.'/course/moodleform_mod.php'); class mod_choice_mod_form extends moodleform_mod { function definition() { - global $CHOICE_SHOWRESULTS, $CHOICE_PUBLISH, $CHOICE_DISPLAY; + global $CFG, $CHOICE_SHOWRESULTS, $CHOICE_PUBLISH, $CHOICE_DISPLAY; $mform =& $this->_form; @@ -12,7 +12,11 @@ class mod_choice_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('choicename', 'choice'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'text', get_string('choicetext', 'choice')); diff --git a/mod/data/mod_form.php b/mod/data/mod_form.php index 2d53ea6f6cf..ce1c94a4914 100644 --- a/mod/data/mod_form.php +++ b/mod/data/mod_form.php @@ -12,7 +12,11 @@ class mod_data_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'intro', get_string('intro', 'data')); diff --git a/mod/exercise/mod_form.php b/mod/exercise/mod_form.php index 10adcf78052..000f09cd6c4 100644 --- a/mod/exercise/mod_form.php +++ b/mod/exercise/mod_form.php @@ -12,7 +12,11 @@ class mod_exercise_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('title', 'exercise'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('static', 'description', get_string('description', 'exercise'), get_string('descriptionofexercise', 'exercise', $COURSE->students)); diff --git a/mod/forum/mod_form.php b/mod/forum/mod_form.php index b16db35dd68..14bda5344b7 100644 --- a/mod/forum/mod_form.php +++ b/mod/forum/mod_form.php @@ -12,7 +12,11 @@ class mod_forum_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('forumname', 'forum'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); diff --git a/mod/glossary/mod_form.php b/mod/glossary/mod_form.php index 86f0f51c28d..d1048dfa399 100644 --- a/mod/glossary/mod_form.php +++ b/mod/glossary/mod_form.php @@ -12,7 +12,11 @@ class mod_glossary_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'intro', get_string('description')); diff --git a/mod/hotpot/mod_form.php b/mod/hotpot/mod_form.php index b20d378f7ca..d698f588808 100644 --- a/mod/hotpot/mod_form.php +++ b/mod/hotpot/mod_form.php @@ -58,7 +58,11 @@ class mod_hotpot_mod_form extends moodleform_mod { $mform->addElement('text', 'name', get_string('name'), array('size' => '40')); } $mform->setType('namesource', PARAM_INT); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } // Location $sitecontext = get_context_instance(CONTEXT_SYSTEM); diff --git a/mod/journal/mod_form.php b/mod/journal/mod_form.php index 8d59999a892..586017da602 100644 --- a/mod/journal/mod_form.php +++ b/mod/journal/mod_form.php @@ -5,14 +5,18 @@ class mod_journal_mod_form extends moodleform_mod { function definition() { - global $COURSE; + global $CFG, $COURSE; $mform =& $this->_form; //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('journalname', 'journal'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'intro', get_string('journalquestion', 'journal')); diff --git a/mod/lesson/mod_form.php b/mod/lesson/mod_form.php index 79b1414c22c..2866772187d 100644 --- a/mod/lesson/mod_form.php +++ b/mod/lesson/mod_form.php @@ -14,7 +14,7 @@ require_once('locallib.php'); class mod_lesson_mod_form extends moodleform_mod { function definition() { - global $LESSON_NEXTPAGE_ACTION, $COURSE; + global $CFG, $LESSON_NEXTPAGE_ACTION, $COURSE; $mform =& $this->_form; @@ -22,7 +22,11 @@ class mod_lesson_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); // Create a text box that can be enabled/disabled for lesson time limit diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index f3c6c71fa46..c3389c5523c 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -15,7 +15,11 @@ class mod_quiz_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'intro', get_string("introduction", "quiz")); diff --git a/mod/resource/mod_form.php b/mod/resource/mod_form.php index ed7a6156904..eba617be178 100644 --- a/mod/resource/mod_form.php +++ b/mod/resource/mod_form.php @@ -31,7 +31,11 @@ class mod_resource_mod_form extends moodleform_mod { // $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'48')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'summary', get_string('summary')); diff --git a/mod/scorm/mod_form.php b/mod/scorm/mod_form.php index dc6e6da4cef..a8153a5f396 100644 --- a/mod/scorm/mod_form.php +++ b/mod/scorm/mod_form.php @@ -14,7 +14,11 @@ class mod_scorm_mod_form extends moodleform_mod { // Name $mform->addElement('text', 'name', get_string('name')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); // Summary diff --git a/mod/survey/mod_form.php b/mod/survey/mod_form.php index 2c0f4696fe1..48242ccc404 100644 --- a/mod/survey/mod_form.php +++ b/mod/survey/mod_form.php @@ -14,7 +14,11 @@ class mod_survey_mod_form extends moodleform_mod { $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); - $mform->setType('name', PARAM_TEXT); + if (!empty($CFG->formatstringstriptags)) { + $mform->setType('name', PARAM_TEXT); + } else { + $mform->setType('name', PARAM_CLEAN); + } $mform->addRule('name', null, 'required', null, 'client'); if (!$options = get_records_menu("survey", "template", 0, "name", "id, name")) { diff --git a/version.php b/version.php index 54e6cafb2c6..a13f0613651 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2007101520.02; // YYYYMMDD = date of the 1.9 branch (don't change) + $version = 2007101520.03; // YYYYMMDD = date of the 1.9 branch (don't change) // X = release number 1.9.[0,1,2,3...] // Y.YY = micro-increments between releases