Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38132

Moodle 2.x doesn't allow course fullnames with HTML tags

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a bug
    • Icon: Minor Minor
    • None
    • 2.3.4
    • Course
    • MOODLE_23_STABLE

      In Moodle 1.9 we had courses link colors based on their categories. Each teacher could see his course with diferent colors and this helped them. We can't do this anymore, because HTML tags on course fullname on 2.3 prevent course to be imported. There's a fix for this from this thread:
      https://moodle.org/mod/forum/discuss.php?d=218603#p951855

      vi course/edit_form.php and find lines

      $mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="50"');
      $mform->addHelpButton('fullname', 'fullnamecourse');
      $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
      $mform->setType('fullname', PARAM_TEXT);
      

      Change the last line to

      $mform->setType('fullname', PARAM_CLEANHTML);
      

      and you can save the course and category names like before in moodle 1.9.

      Moodle 1.9 was using PARAM_MULTILANG but for some reason this was changed to PARAM_TEXT. In moodle 2 PARAM_CLEANHTML is defined in lib/moodlelib.php with

      case PARAM_CLEANHTML:    // clean html fragment
                  $param = fix_utf8($param);
                  $param = clean_text($param, FORMAT_HTML);     // Sweep for scripts, etc
                  return trim($param);
      

      and you could also use a longer version like in activities with

              if (!empty($CFG->formatstringstriptags)) {
                  $mform->setType('fullname', PARAM_TEXT);
              } else {
                  $mform->setType('fullname', PARAM_CLEANHTML);
              }
      

      (that would check if formatstringstriptags is set in administration menu and choose the PARAM_X according to selection)

      OBS.: Is there another way to do this(more elegant way)? Could be a fix for this in a next release?

            poltawski Dan Poltawski
            raickonen Luciano Silva
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.