]> git.mjollnir.org Git - moodle.git/commitdiff
general cleanup of xxx_parameter() functions
authorskodak <skodak>
Wed, 12 Apr 2006 16:59:51 +0000 (16:59 +0000)
committerskodak <skodak>
Wed, 12 Apr 2006 16:59:51 +0000 (16:59 +0000)
course/teacher.php
course/unenrol.php
course/user.php

index e838ed3dd98425c57121d73b650b411e2b7b70fe..dda82220555fbcb2da7d5560d189136153b74252 100644 (file)
@@ -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();
 
 
     } else {
 
-        if ($search) {
-            echo "<p align=\"center\">($strsearchresults : $search)</p>";
+        if ($search != '') {
+            echo "<p align=\"center\">($strsearchresults : ".s($search).")</p>";
         }
 
         if (!$users = get_users(true, $search, true, $teacherlist)) {
         print_table($table);
     }
 
-    if ($search or $usercount > MAX_USERS_PER_PAGE) {
+    if (($search != '') or $usercount > MAX_USERS_PER_PAGE) {
         echo "<center>";
         echo "<form action=\"teacher.php\" method=\"get\">";
         echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
index 24fd332a9e12a37730942c750da35927d58a84f5..4213ade65e5397699f66819798508bb0dd6db69e 100644 (file)
@@ -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.");
index f44549f3ddd43fa1122f34b4742cfd5c3f6ceb40..90f8d7861c9f9430f51b0921e865d79d440a0612 100644 (file)
@@ -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();