From: skodak Date: Wed, 12 Apr 2006 16:59:51 +0000 (+0000) Subject: general cleanup of xxx_parameter() functions X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f2a365b976b051fe5e0bfea5b94f2ebc3749fa61;p=moodle.git general cleanup of xxx_parameter() functions --- diff --git a/course/teacher.php b/course/teacher.php index e838ed3dd9..dda8222055 100644 --- a/course/teacher.php +++ b/course/teacher.php @@ -5,10 +5,10 @@ define("MAX_USERS_PER_PAGE", 50); - $id = required_param('id',PARAM_INT); // course id - $add = optional_param('add', '', PARAM_INT); - $remove = optional_param('remove', '', PARAM_INT); - $search = optional_param('search', '', PARAM_CLEAN); // search string + $id = required_param('id', PARAM_INT); // course id + $add = optional_param('add', 0, PARAM_INT); + $remove = optional_param('remove', 0, PARAM_INT); + $search = optional_param('search', '', PARAM_RAW); // search string require_login(); @@ -187,8 +187,8 @@ } else { - if ($search) { - echo "

($strsearchresults : $search)

"; + if ($search != '') { + echo "

($strsearchresults : ".s($search).")

"; } if (!$users = get_users(true, $search, true, $teacherlist)) { @@ -209,7 +209,7 @@ print_table($table); } - if ($search or $usercount > MAX_USERS_PER_PAGE) { + if (($search != '') or $usercount > MAX_USERS_PER_PAGE) { echo "
"; echo "
"; echo "id\" />"; diff --git a/course/unenrol.php b/course/unenrol.php index 24fd332a9e..4213ade65e 100644 --- a/course/unenrol.php +++ b/course/unenrol.php @@ -8,9 +8,9 @@ require_once("../config.php"); require_once("lib.php"); - $id = required_param('id',PARAM_INT); //course - $user = optional_param('user', $USER->id, PARAM_INT); //user - $confirm = optional_param('confirm','',PARAM_ALPHA); + $id = required_param('id', PARAM_INT); //course + $user = optional_param('user', $USER->id, PARAM_INT); //user + $confirm = optional_param('confirm', 0, PARAM_BOOL); if (! $course = get_record("course", "id", $id) ) { error("That's an invalid course id"); @@ -29,7 +29,7 @@ error("You are not allowed to unenroll"); } - if (!empty($confirm) and confirm_sesskey()) { + if ($confirm and confirm_sesskey()) { if (! unenrol_student($user->id, $course->id)) { error("An error occurred while trying to unenrol you."); diff --git a/course/user.php b/course/user.php index f44549f3dd..90f8d7861c 100644 --- a/course/user.php +++ b/course/user.php @@ -7,10 +7,10 @@ $modes = array("outline", "complete", "todaylogs", "alllogs"); - $id = required_param('id',PARAM_INT); // course id - $user = required_param('user',PARAM_INT); // user id - $mode = optional_param('mode', "todaylogs", PARAM_ALPHA); - $page = optional_param('page', 0, PARAM_INT); + $id = required_param('id',PARAM_INT); // course id + $user = required_param('user',PARAM_INT); // user id + $mode = optional_param('mode', "todaylogs", PARAM_ALPHA); + $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 100, PARAM_INT); require_login();