From 1e12c1203bd37f1202999eca09e190deb87c35f7 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 11 May 2012 10:49:51 +0800 Subject: [PATCH] MDL-30651 libraries: Replaced deprecated PARAM_INTEGER with PARAM_INT --- admin/filters.php | 2 +- admin/roles/define.php | 2 +- admin/settings/plugins.php | 4 ++-- admin/tool/capability/index.php | 2 +- blocks/community/communitycourse.php | 18 +++++++++--------- blocks/glossary_random/edit_form.php | 2 +- blocks/quiz_results/edit_form.php | 4 ++-- blocks/rss_client/edit_form.php | 2 +- blocks/rss_client/editfeed.php | 4 ++-- blocks/rss_client/managefeeds.php | 4 ++-- blocks/rss_client/viewfeed.php | 4 ++-- blocks/tag_flickr/edit_form.php | 2 +- blocks/tag_youtube/edit_form.php | 2 +- group/externallib.php | 2 +- lib/blocklib.php | 10 +++++----- lib/moodlelib.php | 1 + mod/quiz/attempt.php | 4 ++-- mod/quiz/edit.php | 2 +- mod/quiz/settings.php | 4 ++-- question/type/match/question.php | 2 +- question/type/truefalse/question.php | 2 +- user/externallib.php | 6 +++--- user/selector/lib.php | 6 +++--- 23 files changed, 46 insertions(+), 45 deletions(-) diff --git a/admin/filters.php b/admin/filters.php index 0d7faa3c088..21869d92746 100644 --- a/admin/filters.php +++ b/admin/filters.php @@ -68,7 +68,7 @@ switch ($action) { case 'setstate': - if ($newstate = optional_param('newstate', '', PARAM_INTEGER)) { + if ($newstate = optional_param('newstate', '', PARAM_INT)) { filter_set_global_state($filterpath, $newstate); if ($newstate == TEXTFILTER_DISABLED) { filter_set_applies_to_strings($filterpath, false); diff --git a/admin/roles/define.php b/admin/roles/define.php index d2f4eb5f501..60dbade27b0 100644 --- a/admin/roles/define.php +++ b/admin/roles/define.php @@ -38,7 +38,7 @@ throw new moodle_exception('invalidaccess'); } if ($action != 'add') { - $roleid = required_param('roleid', PARAM_INTEGER); + $roleid = required_param('roleid', PARAM_INT); } else { $roleid = 0; } diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index 638aa4009b7..ec274335398 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -264,13 +264,13 @@ if ($hassiteconfig) { 'portfolio_moderate_db_threshold', new lang_string('moderatedbsizethreshold', 'portfolio'), new lang_string('moderatedbsizethresholddesc', 'portfolio'), - 20, PARAM_INTEGER, 3)); + 20, PARAM_INT, 3)); $temp->add(new admin_setting_configtext( 'portfolio_high_db_threshold', new lang_string('highdbsizethreshold', 'portfolio'), new lang_string('highdbsizethresholddesc', 'portfolio'), - 50, PARAM_INTEGER, 3)); + 50, PARAM_INT, 3)); $ADMIN->add('portfoliosettings', $temp); $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url); diff --git a/admin/tool/capability/index.php b/admin/tool/capability/index.php index 7a0f2d64a6e..e7e49d76fbf 100644 --- a/admin/tool/capability/index.php +++ b/admin/tool/capability/index.php @@ -34,7 +34,7 @@ require_capability('moodle/role:manage', $systemcontext); // Get URL parameters. $capability = optional_param('capability', '', PARAM_CAPABILITY); -$roleids = optional_param_array('roles', array('0'), PARAM_INTEGER); +$roleids = optional_param_array('roles', array('0'), PARAM_INT); // Clean the passed in list of role ids. If 'All' selected as an option, or // if none were selected, do all roles. diff --git a/blocks/community/communitycourse.php b/blocks/community/communitycourse.php index dbd9e075d77..3f32ef77f2b 100644 --- a/blocks/community/communitycourse.php +++ b/blocks/community/communitycourse.php @@ -67,8 +67,8 @@ $communitymanager = new block_community_manager(); $renderer = $PAGE->get_renderer('block_community'); /// Check if the page has been called with trust argument -$add = optional_param('add', -1, PARAM_INTEGER); -$confirm = optional_param('confirmed', false, PARAM_INTEGER); +$add = optional_param('add', -1, PARAM_INT); +$confirm = optional_param('confirmed', false, PARAM_INT); if ($add != -1 and $confirm and confirm_sesskey()) { $course = new stdClass(); $course->name = optional_param('coursefullname', '', PARAM_TEXT); @@ -93,8 +93,8 @@ if ($usercandownload and $cancelrestore and confirm_sesskey()) { /// Download $huburl = optional_param('huburl', false, PARAM_URL); -$download = optional_param('download', -1, PARAM_INTEGER); -$downloadcourseid = optional_param('downloadcourseid', '', PARAM_INTEGER); +$download = optional_param('download', -1, PARAM_INT); +$downloadcourseid = optional_param('downloadcourseid', '', PARAM_INT); $coursefullname = optional_param('coursefullname', '', PARAM_ALPHANUMEXT); $backupsize = optional_param('backupsize', 0, PARAM_INT); if ($usercandownload and $download != -1 and !empty($downloadcourseid) and confirm_sesskey()) { @@ -125,8 +125,8 @@ if ($usercandownload and $download != -1 and !empty($downloadcourseid) and confi } /// Remove community -$remove = optional_param('remove', '', PARAM_INTEGER); -$communityid = optional_param('communityid', '', PARAM_INTEGER); +$remove = optional_param('remove', '', PARAM_INT); +$communityid = optional_param('communityid', '', PARAM_INT); if ($remove != -1 and !empty($communityid) and confirm_sesskey()) { $communitymanager->block_community_remove_course($communityid, $USER->id); echo $OUTPUT->header(); @@ -152,8 +152,8 @@ $hubselectorform->set_data($fromformdata); //Retrieve courses by web service $courses = null; -if (optional_param('executesearch', 0, PARAM_INTEGER) and confirm_sesskey()) { - $downloadable = optional_param('downloadable', false, PARAM_INTEGER); +if (optional_param('executesearch', 0, PARAM_INT) and confirm_sesskey()) { + $downloadable = optional_param('downloadable', false, PARAM_INT); $options = new stdClass(); if (!empty($fromformdata['coverage'])) { @@ -178,7 +178,7 @@ if (optional_param('executesearch', 0, PARAM_INTEGER) and confirm_sesskey()) { $options->orderby = $fromformdata['orderby']; //the range of course requested - $options->givememore = optional_param('givememore', 0, PARAM_INTEGER); + $options->givememore = optional_param('givememore', 0, PARAM_INT); //check if the selected hub is from the registered list (in this case we use the private token) $token = 'publichub'; diff --git a/blocks/glossary_random/edit_form.php b/blocks/glossary_random/edit_form.php index 70682bd3e83..6de484cc50a 100644 --- a/blocks/glossary_random/edit_form.php +++ b/blocks/glossary_random/edit_form.php @@ -49,7 +49,7 @@ class block_glossary_random_edit_form extends block_edit_form { $mform->addElement('text', 'config_refresh', get_string('refresh', 'block_glossary_random'), array('size' => 5)); $mform->setDefault('config_refresh', 0); - $mform->setType('config_refresh', PARAM_INTEGER); + $mform->setType('config_refresh', PARAM_INT); // and select quotetypes to put in dropdown box $types = array( diff --git a/blocks/quiz_results/edit_form.php b/blocks/quiz_results/edit_form.php index 1f1db86379b..35231b738cf 100644 --- a/blocks/quiz_results/edit_form.php +++ b/blocks/quiz_results/edit_form.php @@ -54,11 +54,11 @@ class block_quiz_results_edit_form extends block_edit_form { $mform->addElement('text', 'config_showbest', get_string('config_show_best', 'block_quiz_results'), array('size' => 3)); $mform->setDefault('config_showbest', 3); - $mform->setType('config_showbest', PARAM_INTEGER); + $mform->setType('config_showbest', PARAM_INT); $mform->addElement('text', 'config_showworst', get_string('config_show_worst', 'block_quiz_results'), array('size' => 3)); $mform->setDefault('config_showworst', 0); - $mform->setType('config_showworst', PARAM_INTEGER); + $mform->setType('config_showworst', PARAM_INT); $mform->addElement('selectyesno', 'config_usegroups', get_string('config_use_groups', 'block_quiz_results')); diff --git a/blocks/rss_client/edit_form.php b/blocks/rss_client/edit_form.php index aaa36757896..922734a3e24 100644 --- a/blocks/rss_client/edit_form.php +++ b/blocks/rss_client/edit_form.php @@ -40,7 +40,7 @@ class block_rss_client_edit_form extends block_edit_form { $mform->setDefault('config_display_description', 0); $mform->addElement('text', 'config_shownumentries', get_string('shownumentrieslabel', 'block_rss_client'), array('size' => 5)); - $mform->setType('config_shownumentries', PARAM_INTEGER); + $mform->setType('config_shownumentries', PARAM_INT); $mform->addRule('config_shownumentries', null, 'numeric', null, 'client'); if (!empty($CFG->block_rss_client_num_entries)) { $mform->setDefault('config_shownumentries', $CFG->block_rss_client_num_entries); diff --git a/blocks/rss_client/editfeed.php b/blocks/rss_client/editfeed.php index d25e090769d..ce7a09bc2aa 100644 --- a/blocks/rss_client/editfeed.php +++ b/blocks/rss_client/editfeed.php @@ -147,8 +147,8 @@ class feed_edit_form extends moodleform { } $returnurl = optional_param('returnurl', '', PARAM_LOCALURL); -$courseid = optional_param('courseid', 0, PARAM_INTEGER); -$rssid = optional_param('rssid', 0, PARAM_INTEGER); // 0 mean create new. +$courseid = optional_param('courseid', 0, PARAM_INT); +$rssid = optional_param('rssid', 0, PARAM_INT); // 0 mean create new. if ($courseid == SITEID) { $courseid = 0; diff --git a/blocks/rss_client/managefeeds.php b/blocks/rss_client/managefeeds.php index 321aed4d7a1..2e3e3c6978f 100644 --- a/blocks/rss_client/managefeeds.php +++ b/blocks/rss_client/managefeeds.php @@ -29,8 +29,8 @@ require_once($CFG->libdir . '/tablelib.php'); require_login(); $returnurl = optional_param('returnurl', '', PARAM_LOCALURL); -$courseid = optional_param('courseid', 0, PARAM_INTEGER); -$deleterssid = optional_param('deleterssid', 0, PARAM_INTEGER); +$courseid = optional_param('courseid', 0, PARAM_INT); +$deleterssid = optional_param('deleterssid', 0, PARAM_INT); if ($courseid == SITEID) { $courseid = 0; diff --git a/blocks/rss_client/viewfeed.php b/blocks/rss_client/viewfeed.php index 469e621283a..d1235c8fcd3 100644 --- a/blocks/rss_client/viewfeed.php +++ b/blocks/rss_client/viewfeed.php @@ -32,8 +32,8 @@ if (isguestuser()) { } $returnurl = optional_param('returnurl', '', PARAM_LOCALURL); -$courseid = optional_param('courseid', 0, PARAM_INTEGER); -$rssid = required_param('rssid', PARAM_INTEGER); +$courseid = optional_param('courseid', 0, PARAM_INT); +$rssid = required_param('rssid', PARAM_INT); if ($courseid = SITEID) { $courseid = 0; diff --git a/blocks/tag_flickr/edit_form.php b/blocks/tag_flickr/edit_form.php index 51898466f33..4e57f196e17 100644 --- a/blocks/tag_flickr/edit_form.php +++ b/blocks/tag_flickr/edit_form.php @@ -37,7 +37,7 @@ class block_tag_flickr_edit_form extends block_edit_form { $mform->setType('config_title', PARAM_MULTILANG); $mform->addElement('text', 'config_numberofphotos', get_string('numberofphotos', 'block_tag_flickr'), array('size' => 5)); - $mform->setType('config_numberofvideos', PARAM_INTEGER); + $mform->setType('config_numberofvideos', PARAM_INT); $mform->addElement('selectyesno', 'config_includerelatedtags', get_string('includerelatedtags', 'block_tag_flickr')); $mform->setDefault('config_includerelatedtags', 0); diff --git a/blocks/tag_youtube/edit_form.php b/blocks/tag_youtube/edit_form.php index 47b4e581084..5b038a59ddd 100644 --- a/blocks/tag_youtube/edit_form.php +++ b/blocks/tag_youtube/edit_form.php @@ -37,7 +37,7 @@ class block_tag_youtube_edit_form extends block_edit_form { $mform->setType('config_title', PARAM_MULTILANG); $mform->addElement('text', 'config_numberofvideos', get_string('numberofvideos', 'block_tag_youtube'), array('size' => 5)); - $mform->setType('config_numberofvideos', PARAM_INTEGER); + $mform->setType('config_numberofvideos', PARAM_INT); $categorychoices = $this->block->get_categories(); $mform->addElement('select', 'config_category', get_string('category', 'block_tag_youtube'), $categorychoices); diff --git a/group/externallib.php b/group/externallib.php index 39db0871a1f..4e0ad27533b 100644 --- a/group/externallib.php +++ b/group/externallib.php @@ -311,7 +311,7 @@ class core_group_external extends external_api { foreach ($params['groupids'] as $groupid) { // validate params - $groupid = validate_param($groupid, PARAM_INTEGER); + $groupid = validate_param($groupid, PARAM_INT); if (!$group = groups_get_group($groupid, 'id, courseid', IGNORE_MISSING)) { // silently ignore attempts to delete nonexisting groups continue; diff --git a/lib/blocklib.php b/lib/blocklib.php index 1c7097e9246..6094a2b2668 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1108,7 +1108,7 @@ class block_manager { * @return boolean true if anything was done. False if not. */ public function process_url_delete() { - $blockid = optional_param('bui_deleteid', null, PARAM_INTEGER); + $blockid = optional_param('bui_deleteid', null, PARAM_INT); if (!$blockid) { return false; } @@ -1134,9 +1134,9 @@ class block_manager { * @return boolean true if anything was done. False if not. */ public function process_url_show_hide() { - if ($blockid = optional_param('bui_hideid', null, PARAM_INTEGER)) { + if ($blockid = optional_param('bui_hideid', null, PARAM_INT)) { $newvisibility = 0; - } else if ($blockid = optional_param('bui_showid', null, PARAM_INTEGER)) { + } else if ($blockid = optional_param('bui_showid', null, PARAM_INT)) { $newvisibility = 1; } else { return false; @@ -1169,7 +1169,7 @@ class block_manager { public function process_url_edit() { global $CFG, $DB, $PAGE, $OUTPUT; - $blockid = optional_param('bui_editid', null, PARAM_INTEGER); + $blockid = optional_param('bui_editid', null, PARAM_INT); if (!$blockid) { return false; } @@ -1367,7 +1367,7 @@ class block_manager { public function process_url_move() { global $CFG, $DB, $PAGE; - $blockid = optional_param('bui_moveid', null, PARAM_INTEGER); + $blockid = optional_param('bui_moveid', null, PARAM_INT); if (!$blockid) { return false; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index b2c6223bb46..a6bc1fb2711 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -254,6 +254,7 @@ define('PARAM_CLEAN', 'clean'); /** * PARAM_INTEGER - deprecated alias for PARAM_INT + * @deprecated since 2.0 */ define('PARAM_INTEGER', 'int'); diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index bb8c01f1c88..196694c9828 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -26,9 +26,9 @@ require_once(dirname(__FILE__) . '/../../config.php'); require_once($CFG->dirroot . '/mod/quiz/locallib.php'); // Look for old-style URLs, such as may be in the logs, and redirect them to startattemtp.php. -if ($id = optional_param('id', 0, PARAM_INTEGER)) { +if ($id = optional_param('id', 0, PARAM_INT)) { redirect($CFG->wwwroot . '/mod/quiz/startattempt.php?cmid=' . $id . '&sesskey=' . sesskey()); -} else if ($qid = optional_param('q', 0, PARAM_INTEGER)) { +} else if ($qid = optional_param('q', 0, PARAM_INT)) { if (!$cm = get_coursemodule_from_instance('quiz', $qid)) { print_error('invalidquizid', 'quiz'); } diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 1f108bf6138..dae095139f3 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -324,7 +324,7 @@ if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) { $questionid = $matches[2]; // Make sure two questions don't overwrite each other. If we get a second // question with the same position, shift the second one along to the next gap. - $value = clean_param($value, PARAM_INTEGER); + $value = clean_param($value, PARAM_INT); while (array_key_exists($value, $questions)) { $value++; } diff --git a/mod/quiz/settings.php b/mod/quiz/settings.php index 7652dfa8385..78efa460bcd 100644 --- a/mod/quiz/settings.php +++ b/mod/quiz/settings.php @@ -183,10 +183,10 @@ $quizsettings->add(new admin_setting_configtext_with_advanced('quiz/subnet', // Enforced delay between attempts. $quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay1', get_string('delay1st2nd', 'quiz'), get_string('configdelay1st2nd', 'quiz'), - array('value' => 0, 'fix' => true), PARAM_INTEGER)); + array('value' => 0, 'fix' => true), PARAM_INT)); $quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay2', get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'), - array('value' => 0, 'fix' => true), PARAM_INTEGER)); + array('value' => 0, 'fix' => true), PARAM_INT)); // Browser security. $quizsettings->add(new mod_quiz_admin_setting_browsersecurity('quiz/browsersecurity', diff --git a/question/type/match/question.php b/question/type/match/question.php index ab4b36813de..a031c59c8f0 100644 --- a/question/type/match/question.php +++ b/question/type/match/question.php @@ -176,7 +176,7 @@ class qtype_match_question extends question_graded_automatically_with_countback public function get_expected_data() { $vars = array(); foreach ($this->stemorder as $key => $notused) { - $vars[$this->field($key)] = PARAM_INTEGER; + $vars[$this->field($key)] = PARAM_INT; } return $vars; } diff --git a/question/type/truefalse/question.php b/question/type/truefalse/question.php index b68c8212d07..60f3ba029fe 100644 --- a/question/type/truefalse/question.php +++ b/question/type/truefalse/question.php @@ -41,7 +41,7 @@ class qtype_truefalse_question extends question_graded_automatically { public $falseanswerid; public function get_expected_data() { - return array('answer' => PARAM_INTEGER); + return array('answer' => PARAM_INT); } public function get_correct_response() { diff --git a/user/externallib.php b/user/externallib.php index c1d57bc07e7..633771da7c7 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -61,7 +61,7 @@ class core_user_external extends external_api { 'lang' => new external_value(PARAM_SAFEDIR, 'Language code such as "en", must exist on server', VALUE_DEFAULT, $CFG->lang, NULL_NOT_ALLOWED), 'theme' => new external_value(PARAM_PLUGIN, 'Theme name such as "standard", must exist on server', VALUE_OPTIONAL), 'timezone' => new external_value(PARAM_TIMEZONE, 'Timezone code such as Australia/Perth, or 99 for default', VALUE_OPTIONAL), - 'mailformat' => new external_value(PARAM_INTEGER, 'Mail format code is 0 for plain text, 1 for HTML etc', VALUE_OPTIONAL), + 'mailformat' => new external_value(PARAM_INT, 'Mail format code is 0 for plain text, 1 for HTML etc', VALUE_OPTIONAL), 'description' => new external_value(PARAM_TEXT, 'User profile description, no HTML', VALUE_OPTIONAL), 'city' => new external_value(PARAM_NOTAGS, 'Home city of the user', VALUE_OPTIONAL), 'country' => new external_value(PARAM_ALPHA, 'Home country code of the user, such as AU or CZ', VALUE_OPTIONAL), @@ -286,7 +286,7 @@ class core_user_external extends external_api { 'lang' => new external_value(PARAM_SAFEDIR, 'Language code such as "en", must exist on server', VALUE_OPTIONAL, '', NULL_NOT_ALLOWED), 'theme' => new external_value(PARAM_PLUGIN, 'Theme name such as "standard", must exist on server', VALUE_OPTIONAL), 'timezone' => new external_value(PARAM_TIMEZONE, 'Timezone code such as Australia/Perth, or 99 for default', VALUE_OPTIONAL), - 'mailformat' => new external_value(PARAM_INTEGER, 'Mail format code is 0 for plain text, 1 for HTML etc', VALUE_OPTIONAL), + 'mailformat' => new external_value(PARAM_INT, 'Mail format code is 0 for plain text, 1 for HTML etc', VALUE_OPTIONAL), 'description' => new external_value(PARAM_TEXT, 'User profile description, no HTML', VALUE_OPTIONAL), 'city' => new external_value(PARAM_NOTAGS, 'Home city of the user', VALUE_OPTIONAL), 'country' => new external_value(PARAM_ALPHA, 'Home country code of the user, such as AU or CZ', VALUE_OPTIONAL), @@ -471,7 +471,7 @@ class core_user_external extends external_api { 'lang' => new external_value(PARAM_SAFEDIR, 'Language code such as "en", must exist on server', VALUE_OPTIONAL), 'theme' => new external_value(PARAM_PLUGIN, 'Theme name such as "standard", must exist on server', VALUE_OPTIONAL), 'timezone' => new external_value(PARAM_TIMEZONE, 'Timezone code such as Australia/Perth, or 99 for default', VALUE_OPTIONAL), - 'mailformat' => new external_value(PARAM_INTEGER, 'Mail format code is 0 for plain text, 1 for HTML etc', VALUE_OPTIONAL), + 'mailformat' => new external_value(PARAM_INT, 'Mail format code is 0 for plain text, 1 for HTML etc', VALUE_OPTIONAL), 'description' => new external_value(PARAM_RAW, 'User profile description', VALUE_OPTIONAL), 'descriptionformat' => new external_format_value('description', VALUE_OPTIONAL), 'city' => new external_value(PARAM_NOTAGS, 'Home city of the user', VALUE_OPTIONAL), diff --git a/user/selector/lib.php b/user/selector/lib.php index 005762c61a1..35f40658d77 100644 --- a/user/selector/lib.php +++ b/user/selector/lib.php @@ -149,7 +149,7 @@ abstract class user_selector_base { /** * @return array of user objects. The users that were selected. This is a more sophisticated version - * of optional_param($this->name, array(), PARAM_INTEGER) that validates the + * of optional_param($this->name, array(), PARAM_INT) that validates the * returned list of ids against the rules for this user selector. */ public function get_selected_users() { @@ -368,8 +368,8 @@ abstract class user_selector_base { protected function load_selected_users() { // See if we got anything. if ($this->multiselect) { - $userids = optional_param_array($this->name, array(), PARAM_INTEGER); - } else if ($userid = optional_param($this->name, 0, PARAM_INTEGER)) { + $userids = optional_param_array($this->name, array(), PARAM_INT); + } else if ($userid = optional_param($this->name, 0, PARAM_INT)) { $userids = array($userid); } // If there are no users there is nobody to load