MDL-39422 mod_forms: prevent long coruse module names

To prevent ugly DB errors.
This commit is contained in:
Dan Poltawski 2013-04-30 17:39:56 +01:00
parent da7b1ecb12
commit 41b2eb8400
18 changed files with 18 additions and 0 deletions

View file

@ -57,6 +57,7 @@ class mod_assign_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'assign'));

View file

@ -45,6 +45,7 @@ class mod_assignment_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'assignment'));

View file

@ -45,6 +45,7 @@ class mod_book_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro, get_string('moduleintro'));
$alloptions = book_get_numbering_types();

View file

@ -22,6 +22,7 @@ class mod_chat_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('chatintro', 'chat'));

View file

@ -22,6 +22,7 @@ class mod_choice_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('chatintro', 'chat'));

View file

@ -22,6 +22,7 @@ class mod_data_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('intro', 'data'));

View file

@ -44,6 +44,7 @@ class mod_feedback_mod_form extends moodleform_mod {
$mform->addElement('text', 'name', get_string('name', 'feedback'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'feedback'));

View file

@ -44,6 +44,7 @@ class mod_folder_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------

View file

@ -22,6 +22,7 @@ class mod_glossary_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true);

View file

@ -45,6 +45,7 @@ class mod_imscp_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------

View file

@ -89,6 +89,7 @@ class mod_lesson_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Create a text box that can be enabled/disabled for lesson time limit
$timedgrp = array();

View file

@ -67,6 +67,7 @@ class mod_lti_mod_form extends moodleform_mod {
$mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Adding the optional "intro" and "introformat" pair of fields
$this->add_intro_editor(false, get_string('basicltiintro', 'lti'));
$mform->setAdvanced('introeditor');

View file

@ -47,6 +47,7 @@ class mod_page_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------

View file

@ -69,6 +69,7 @@ class mod_quiz_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Introduction.
$this->add_intro_editor(false, get_string('introduction', 'quiz'));

View file

@ -55,6 +55,7 @@ class mod_resource_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------

View file

@ -43,6 +43,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Summary
$this->add_intro_editor(true);

View file

@ -45,6 +45,7 @@ class mod_url_mod_form extends moodleform_mod {
$mform->setType('name', PARAM_CLEANHTML);
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
//-------------------------------------------------------

View file

@ -53,6 +53,7 @@ class mod_wiki_mod_form extends moodleform_mod {
$mform->addElement('text', 'name', get_string('wikiname', 'wiki'), array('size' => '64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', $required, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Adding the optional "intro" and "introformat" pair of fields
$this->add_intro_editor(true, get_string('wikiintro', 'wiki'));