Skip to content

Commit

Permalink
course publish MDL-19315 improve publication form (add restriction on…
Browse files Browse the repository at this point in the history
… the top subject selection)
  • Loading branch information
mouneyrac committed May 14, 2010
1 parent 9f580a8 commit 2b52fe4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
15 changes: 5 additions & 10 deletions blocks/community/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function definition() {
$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');
Expand All @@ -74,7 +74,7 @@ public function definition() {
$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');
Expand All @@ -96,7 +96,7 @@ public function definition() {
$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);
Expand All @@ -106,7 +106,7 @@ public function definition() {
$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');
}
Expand All @@ -118,7 +118,7 @@ public function definition() {

$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');

Expand All @@ -137,11 +137,6 @@ function validation($data, $files) {
$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;
}

Expand Down
24 changes: 23 additions & 1 deletion course/publish/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function definition() {
$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);

Expand Down Expand Up @@ -239,6 +239,14 @@ public function definition() {
$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');
Expand Down Expand Up @@ -286,6 +294,20 @@ public function definition() {
$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;
}



}

?>

0 comments on commit 2b52fe4

Please sign in to comment.