Skip to content

Commit

Permalink
MDL-38851 Administration: Fixed setType in admin section
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Taneja committed Apr 19, 2013
1 parent 3a8c438 commit 1fe56a2
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 32 deletions.
80 changes: 48 additions & 32 deletions admin/registration/forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public function definition() {
$unregisterlabel = get_string('unregister', 'hub');
$mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
' ' . get_string('unpublishalladvertisedcourses', 'hub'));
$mform->setType('unpublishalladvertisedcourses', PARAM_INT);
$mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
' ' . get_string('unpublishalluploadedcourses', 'hub'));
$mform->setType('unpublishalluploadedcourses', PARAM_INT);

$mform->addElement('hidden', 'confirm', 1);
$mform->setType('confirm', PARAM_INT);
Expand Down Expand Up @@ -82,7 +84,6 @@ public function definition() {
$unregisterlabel = get_string('forceunregister', 'hub');
$mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));


$mform->addElement('hidden', 'confirm', 1);
$mform->setType('confirm', PARAM_INT);
$mform->addElement('hidden', 'unregistration', 1);
Expand Down Expand Up @@ -149,15 +150,18 @@ public function definition() {
if (!empty($hubs)) {
$mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
$options, array("size" => 15));
$mform->setType('publichub', PARAM_URL);
}

$mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));

//Private hub
$mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
array('class' => 'registration_textfield'));
$mform->setType('unlistedurl', PARAM_URL);
$mform->addElement('text', 'password', get_string('password'),
array('class' => 'registration_textfield'));
$mform->setType('password', PARAM_RAW);

$this->add_action_buttons(false, get_string('selecthub', 'hub'));
}
Expand All @@ -171,11 +175,8 @@ function validation($data, $files) {

$unlistedurl = $this->_form->_submitValues['unlistedurl'];

if (!empty($unlistedurl)) {
$unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
if (empty($unlistedurltotest)) {
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
}
if (empty($unlistedurl)) {
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
}

return $errors;
Expand Down Expand Up @@ -272,6 +273,7 @@ public function definition() {
$options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
$mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
$mform->setDefault('privacy', $privacy);
$mform->setType('privacy', PARAM_ALPHA);
$mform->addHelpButton('privacy', 'privacy', 'hub');
unset($options);

Expand Down Expand Up @@ -305,11 +307,13 @@ public function definition() {
$countries = get_string_manager()->get_list_of_countries();
$mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
$mform->setDefault('countrycode', $country);
$mform->setType('countrycode', PARAM_ALPHANUMEXT);
$mform->addHelpButton('countrycode', 'sitecountry', 'hub');

$mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
array('class' => 'registration_textfield'));
$mform->setDefault('geolocation', $geolocation);
$mform->setType('geolocation', PARAM_RAW);
$mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');

$mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
Expand All @@ -327,7 +331,7 @@ public function definition() {
$mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
array('class' => 'registration_textfield'));
$mform->addRule('contactemail', $strrequired, 'required', null, 'client');
$mform->setType('contactemail', PARAM_TEXT);
$mform->setType('contactemail', PARAM_EMAIL);
$mform->setDefault('contactemail', $contactemail);
$mform->addHelpButton('contactemail', 'siteemail', 'hub');

Expand All @@ -336,6 +340,7 @@ public function definition() {
$options[1] = get_string("registrationcontactyes");
$mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
$mform->setDefault('contactable', $contactable);
$mform->setType('contactable', PARAM_INT);
$mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
unset($options);

Expand All @@ -344,6 +349,7 @@ public function definition() {
$options[1] = get_string("registrationyes");
$mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
$mform->setDefault('emailalert', $emailalert);
$mform->setType('emailalert', PARAM_INT);
$mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
unset($options);

Expand Down Expand Up @@ -381,79 +387,89 @@ public function definition() {
if (HUB_MOODLEORGHUBURL != $huburl) {
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
" " . get_string('coursesnumber', 'hub', $coursecount));
$mform->setDefault('courses', true);
$mform->setDefault('courses', 1);
$mform->setType('courses', PARAM_INT);
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');

$mform->addElement('checkbox', 'users', '',
" " . get_string('usersnumber', 'hub', $usercount));
$mform->setDefault('users', true);
$mform->setDefault('users', 1);
$mform->setType('users', PARAM_INT);

$mform->addElement('checkbox', 'roleassignments', '',
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
$mform->setDefault('roleassignments', true);
$mform->setDefault('roleassignments', 1);
$mform->setType('roleassignments', PARAM_INT);

$mform->addElement('checkbox', 'posts', '',
" " . get_string('postsnumber', 'hub', $postcount));
$mform->setDefault('posts', true);
$mform->setDefault('posts', 1);
$mform->setType('posts', PARAM_INT);

$mform->addElement('checkbox', 'questions', '',
" " . get_string('questionsnumber', 'hub', $questioncount));
$mform->setDefault('questions', true);
$mform->setDefault('questions', 1);
$mform->setType('questions', PARAM_INT);

$mform->addElement('checkbox', 'resources', '',
" " . get_string('resourcesnumber', 'hub', $resourcecount));
$mform->setDefault('resources', true);
$mform->setDefault('resources', 1);
$mform->setType('resources', PARAM_INT);

$mform->addElement('checkbox', 'badges', '',
" " . get_string('badgesnumber', 'hub', $badges));
$mform->setDefault('badges', true);
$mform->setDefault('badges', 1);
$mform->setType('resources', PARAM_INT);

$mform->addElement('checkbox', 'issuedbadges', '',
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
$mform->setDefault('issuedbadges', true);
$mform->setDefault('issuedbadges', 1);
$mform->setType('resources', PARAM_INT);

$mform->addElement('checkbox', 'participantnumberaverage', '',
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
$mform->setDefault('participantnumberaverage', true);
$mform->setDefault('participantnumberaverage', 1);
$mform->setType('participantnumberaverage', PARAM_FLOAT);

$mform->addElement('checkbox', 'modulenumberaverage', '',
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
$mform->setDefault('modulenumberaverage', true);
$mform->setDefault('modulenumberaverage', 1);
$mform->setType('modulenumberaverage', PARAM_FLOAT);
} else {
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
" " . get_string('coursesnumber', 'hub', $coursecount));
$mform->addElement('hidden', 'courses', true);
$mform->setType('courses', PARAM_FLOAT);
$mform->addElement('hidden', 'courses', 1);
$mform->setType('courses', PARAM_INT);
$mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');

$mform->addElement('static', 'userslabel', '',
" " . get_string('usersnumber', 'hub', $usercount));
$mform->addElement('hidden', 'users', true);
$mform->setType('users', PARAM_FLOAT);
$mform->addElement('hidden', 'users', 1);
$mform->setType('users', PARAM_INT);

$mform->addElement('static', 'roleassignmentslabel', '',
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
$mform->addElement('hidden', 'roleassignments', true);
$mform->setType('roleassignments', PARAM_FLOAT);
$mform->addElement('hidden', 'roleassignments', 1);
$mform->setType('roleassignments', PARAM_INT);

$mform->addElement('static', 'postslabel', '',
" " . get_string('postsnumber', 'hub', $postcount));
$mform->addElement('hidden', 'posts', true);
$mform->setType('posts', PARAM_FLOAT);
$mform->addElement('hidden', 'posts', 1);
$mform->setType('posts', PARAM_INT);

$mform->addElement('static', 'questionslabel', '',
" " . get_string('questionsnumber', 'hub', $questioncount));
$mform->addElement('hidden', 'questions', true);
$mform->setType('questions', PARAM_FLOAT);
$mform->addElement('hidden', 'questions', 1);
$mform->setType('questions', PARAM_INT);

$mform->addElement('static', 'resourceslabel', '',
" " . get_string('resourcesnumber', 'hub', $resourcecount));
$mform->addElement('hidden', 'resources', true);
$mform->setType('resources', PARAM_FLOAT);
$mform->addElement('hidden', 'resources', 1);
$mform->setType('resources', PARAM_INT);

$mform->addElement('static', 'badgeslabel', '',
" " . get_string('badgesnumber', 'hub', $badges));
$mform->addElement('hidden', 'badges', true);
$mform->addElement('hidden', 'badges', 1);
$mform->setType('badges', PARAM_INT);

$mform->addElement('static', 'issuedbadgeslabel', '',
Expand All @@ -463,12 +479,12 @@ public function definition() {

$mform->addElement('static', 'participantnumberaveragelabel', '',
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
$mform->addElement('hidden', 'participantnumberaverage', true);
$mform->addElement('hidden', 'participantnumberaverage', 1);
$mform->setType('participantnumberaverage', PARAM_FLOAT);

$mform->addElement('static', 'modulenumberaveragelabel', '',
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
$mform->addElement('hidden', 'modulenumberaverage', true);
$mform->addElement('hidden', 'modulenumberaverage', 1);
$mform->setType('modulenumberaverage', PARAM_FLOAT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function definition() {
$mform->addElement('header', 'general', get_string('batchoperations', 'tool_assignmentupgrade'));
// Visible elements.
$mform->addElement('hidden', 'selectedassignments', '', array('class'=>'selectedassignments'));
$mform->setType('selectedassignments', PARAM_SEQUENCE);

$mform->addElement('submit', 'upgradeselected', get_string('upgradeselected', 'tool_assignmentupgrade'));
$mform->addElement('submit', 'upgradeall', get_string('upgradeall', 'tool_assignmentupgrade'));
Expand Down
1 change: 1 addition & 0 deletions admin/tool/dbtransfer/database_export_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function definition() {

$mform->addElement('header', 'database', get_string('dbexport', 'tool_dbtransfer'));
$mform->addElement('textarea', 'description', get_string('description'), array('rows'=>5, 'cols'=>60));
$mform->setType('description', PARAM_TEXT);

$this->add_action_buttons(false, get_string('exportdata', 'tool_dbtransfer'));
}
Expand Down
16 changes: 16 additions & 0 deletions admin/tool/dbtransfer/database_transfer_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,32 @@ protected function definition() {
$drivers = array_reverse($drivers, true);

$mform->addElement('select', 'driver', get_string('dbtype', 'install'), $drivers);
$mform->setType('driver', PARAM_RAW);

$mform->addElement('text', 'dbhost', get_string('databasehost', 'install'));
$mform->setType('dbhost', PARAM_HOST);

$mform->addElement('text', 'dbname', get_string('databasename', 'install'));
$mform->setType('dbname', PARAM_ALPHANUMEXT);

$mform->addElement('text', 'dbuser', get_string('databaseuser', 'install'));
$mform->setType('dbuser', PARAM_ALPHANUMEXT);

$mform->addElement('passwordunmask', 'dbpass', get_string('databasepass', 'install'));
$mform->setType('dbpass', PARAM_RAW);

$mform->addElement('text', 'prefix', get_string('dbprefix', 'install'));
$mform->setType('prefix', PARAM_ALPHANUMEXT);

$mform->addElement('text', 'dbport', get_string('dbport', 'install'));
$mform->setType('dbport', PARAM_INT);

if ($CFG->ostype !== 'WINDOWS') {
$mform->addElement('text', 'dbsocket', get_string('databasesocket', 'install'));
} else {
$mform->addElement('hidden', 'dbsocket');
}
$mform->setType('dbsocket', PARAM_RAW);

$mform->addRule('driver', get_string('required'), 'required', null);
$mform->addRule('dbhost', get_string('required'), 'required', null);
Expand All @@ -76,6 +91,7 @@ protected function definition() {
$mform->addElement('header', 'database', get_string('options', 'tool_dbtransfer'));

$mform->addElement('advcheckbox', 'enablemaintenance', get_string('enablemaintenance', 'tool_dbtransfer'));
$mform->setType('enablemaintenance', PARAM_BOOL);
$mform->addHelpButton('enablemaintenance', 'enablemaintenance', 'tool_dbtransfer');

$this->add_action_buttons(false, get_string('transferdata', 'tool_dbtransfer'));
Expand Down
4 changes: 4 additions & 0 deletions admin/tool/qeupgradehelper/cronsetup_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@ public function definition() {

$mform->addElement('selectyesno', 'cronenabled',
get_string('cronenabled', 'tool_qeupgradehelper'));
$mform->setType('cronenabled', PARAM_BOOL);

$mform->addElement('select', 'starthour',
get_string('cronstarthour', 'tool_qeupgradehelper'), range(0, 23));
$mform->setType('starthour', PARAM_INT);

$mform->addElement('select', 'stophour',
get_string('cronstophour', 'tool_qeupgradehelper'),
array_combine(range(1, 24), range(1, 24)));
$mform->setType('stophour', PARAM_INT);
$mform->setDefault('stophour', 24);

$mform->addElement('duration', 'procesingtime',
get_string('cronprocesingtime', 'tool_qeupgradehelper'));
$mform->setType('procesingtime', PARAM_INT);
$mform->setDefault('procesingtime', 60);

$mform->disabledIf('starthour', 'cronenabled', 'eq', 0);
Expand Down
11 changes: 11 additions & 0 deletions admin/tool/qeupgradehelper/extracttestcase_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,23 @@ public function definition() {

$mform->addElement('header', 'h1', 'Either extract a specific question_session');
$mform->addElement('text', 'attemptid', 'Quiz attempt id', array('size' => '10'));
$mform->setType('attemptid', PARAM_INT);

$mform->addElement('text', 'questionid', 'Question id', array('size' => '10'));
$mform->setType('questionid', PARAM_INT);

$mform->addElement('header', 'h2', 'Or find and extract an example by type');
$mform->addElement('select', 'behaviour', 'Behaviour', $behaviour);
$mform->setType('behaviour', PARAM_ALPHA);

$mform->addElement('text', 'statehistory', 'State history', array('size' => '10'));
$mform->setType('statehistory', PARAM_RAW);

$mform->addElement('select', 'qtype', 'Question type', $qtypes);
$mform->setType('qtype', PARAM_PLUGIN);

$mform->addElement('text', 'extratests', 'Extra conditions', array('size' => '50'));
$mform->setType('extratests', PARAM_RAW);
$this->add_action_buttons(false, 'Create test case');
}
}
9 changes: 9 additions & 0 deletions mod/lti/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ public function definition() {
} else {
$mform->addElement('hidden', 'lti_coursevisible', '1');
}
$mform->setType('lti_coursevisible', PARAM_BOOL);

$mform->addElement('hidden', 'typeid');
$mform->setType('typeid', PARAM_INT);

$launchoptions=array();
$launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
Expand All @@ -100,6 +102,7 @@ public function definition() {
$mform->addElement('select', 'lti_launchcontainer', get_string('default_launch_container', 'lti'), $launchoptions);
$mform->setDefault('lti_launchcontainer', LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);
$mform->addHelpButton('lti_launchcontainer', 'default_launch_container', 'lti');
$mform->setType('lti_launchcontainer', PARAM_INT);

// Add privacy preferences fieldset where users choose whether to send their data
$mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
Expand All @@ -110,10 +113,12 @@ public function definition() {
$options[2] = get_string('delegate', 'lti');

$mform->addElement('select', 'lti_sendname', get_string('share_name_admin', 'lti'), $options);
$mform->setType('lti_sendname', PARAM_INT);
$mform->setDefault('lti_sendname', '2');
$mform->addHelpButton('lti_sendname', 'share_name_admin', 'lti');

$mform->addElement('select', 'lti_sendemailaddr', get_string('share_email_admin', 'lti'), $options);
$mform->setType('lti_sendemailaddr', PARAM_INT);
$mform->setDefault('lti_sendemailaddr', '2');
$mform->addHelpButton('lti_sendemailaddr', 'share_email_admin', 'lti');

Expand All @@ -122,6 +127,7 @@ public function definition() {

// Add grading preferences fieldset where the tool is allowed to return grades
$mform->addElement('select', 'lti_acceptgrades', get_string('accept_grades_admin', 'lti'), $options);
$mform->setType('lti_acceptgrades', PARAM_INT);
$mform->setDefault('lti_acceptgrades', '2');
$mform->addHelpButton('lti_acceptgrades', 'accept_grades_admin', 'lti');

Expand All @@ -131,6 +137,7 @@ public function definition() {
//$mform->addHelpButton('lti_allowroster', 'share_roster_admin', 'lti');

$mform->addElement('checkbox', 'lti_forcessl', ' ', ' ' . get_string('force_ssl', 'lti'), $options);
$mform->setType('lti_forcessl', PARAM_BOOL);
$mform->setDefault('lti_forcessl', '0');
$mform->addHelpButton('lti_forcessl', 'force_ssl', 'lti');

Expand Down Expand Up @@ -165,9 +172,11 @@ public function definition() {

$tab = optional_param('tab', '', PARAM_ALPHAEXT);
$mform->addElement('hidden', 'tab', $tab);
$mform->setType('tab', PARAM_ALPHAEXT);

$courseid = optional_param('course', 1, PARAM_INT);
$mform->addElement('hidden', 'course', $courseid);
$mform->setType('course', PARAM_INT);

//-------------------------------------------------------------------------------
// Add standard buttons, common to all modules
Expand Down
Loading

0 comments on commit 1fe56a2

Please sign in to comment.