course publish MDL-19315 improve publication form (add restriction on the top subject selection)

This commit is contained in:
jerome mouneyrac 2010-05-14 07:42:50 +00:00
parent 9f580a84cd
commit 2b52fe433c
2 changed files with 28 additions and 11 deletions

View File

@ -64,7 +64,7 @@ class community_hub_search_form extends moodleform {
$options);
$options = array();
$options['all'] = get_string('all', 'hub');
$options['all'] = get_string('any');
$options[AUDIENCE_EDUCATORS] = get_string('audienceeducators', 'hub');
$options[AUDIENCE_STUDENTS] = get_string('audiencestudents', 'hub');
$options[AUDIENCE_ADMINS] = get_string('audienceadmins', 'hub');
@ -74,7 +74,7 @@ class community_hub_search_form extends moodleform {
$mform->addHelpButton('audience', 'audience', 'hub');
$options = array();
$options['all'] = get_string('all', 'hub');
$options['all'] = get_string('any');
$options[EDULEVEL_PRIMARY] = get_string('edulevelprimary', 'hub');
$options[EDULEVEL_SECONDARY] = get_string('edulevelsecondary', 'hub');
$options[EDULEVEL_TERTIARY] = get_string('eduleveltertiary', 'hub');
@ -96,7 +96,7 @@ class community_hub_search_form extends moodleform {
$option = "    " . $option;
}
}
$options['all'] = get_string('all', 'hub');
$options = array_merge (array('all' => get_string('any')),$options);
$mform->addElement('select', 'subject', get_string('subject', 'hub'), $options);
$mform->setDefault('subject', 'all');
unset($options);
@ -106,7 +106,7 @@ class community_hub_search_form extends moodleform {
$licensemanager = new license_manager();
$licences = $licensemanager->get_licenses();
$options = array();
$options['all'] = get_string('all', 'hub');
$options['all'] = get_string('any');
foreach ($licences as $license) {
$options[$license->shortname] = get_string($license->shortname, 'license');
}
@ -118,7 +118,7 @@ class community_hub_search_form extends moodleform {
$languages = get_string_manager()->get_list_of_languages();
asort($languages, SORT_LOCALE_STRING);
$languages['all'] = get_string('all', 'hub');
$languages = array_merge (array('all' => get_string('any')),$languages);
$mform->addElement('select', 'language',get_string('language'), $languages);
$mform->setDefault('language', 'all');
@ -137,11 +137,6 @@ class community_hub_search_form extends moodleform {
$errors['huburl'] = get_string('nohubselected', 'hub');
}
if (!(strlen($this->_form->_submitValues['subject']) == 12 or $this->_form->_submitValues['subject'] == 'all')) {
$errors['subject'] = get_string('cannotselecttopsubject', 'block_community');
}
return $errors;
}

View File

@ -201,7 +201,7 @@ class course_publication_form extends moodleform {
$mform->setType('description', PARAM_TEXT);
$languages = get_string_manager()->get_list_of_languages();
asort($languages, SORT_LOCALE_STRING);
$mform->addElement('select', 'language',get_string('language'), $languages);
$mform->setDefault('language', $defaultlanguage);
@ -239,6 +239,14 @@ class course_publication_form extends moodleform {
$mform->addHelpButton('licence', 'licence', 'hub');
$options = get_string_manager()->load_component_strings('edufields', current_language());
foreach ($options as $key => &$option) {
$keylength = strlen ( $key );
if ( $keylength == 10) {
$option = "  " . $option;
} else if ( $keylength == 12) {
$option = "    " . $option;
}
}
$mform->addElement('select', 'subject', get_string('subject', 'hub'), $options);
unset($options);
$mform->addHelpButton('subject', 'subject', 'hub');
@ -286,6 +294,20 @@ class course_publication_form extends moodleform {
$this->add_action_buttons(false, $buttonlabel);
}
function validation($data, $files) {
global $CFG;
$errors = array();
if (!(strlen($this->_form->_submitValues['subject']) == 12 or $this->_form->_submitValues['subject'] == 'all')) {
$errors['subject'] = get_string('cannotselecttopsubject', 'block_community');
}
return $errors;
}
}
?>