]> git.mjollnir.org Git - moodle.git/commitdiff
general cleanup of xxx_parameter() functions + fixed several register globals problems
authorskodak <skodak>
Tue, 11 Apr 2006 21:41:21 +0000 (21:41 +0000)
committerskodak <skodak>
Tue, 11 Apr 2006 21:41:21 +0000 (21:41 +0000)
course/format/lams/format.php
course/format/topics/format.php
course/format/weeks/format.php
course/format/weekscss/format.php
course/mod.php
course/view.php

index d5bc25d2b7d30f5e37b15ee1b503a7174d4ff898..c0b74a248827909edeb3524b28fefde466655efb 100644 (file)
@@ -6,6 +6,9 @@
 require_once($CFG->dirroot.'/mod/forum/lib.php');
 require_once($CFG->dirroot.'/mod/lams/constants.php');
 require_once($CFG->dirroot.'/lib/weblib.php');
+
+$topic = optional_param('topic', -1, PARAM_INT);
+
 // Bounds for block widths
 define('BLOCK_L_MIN_WIDTH', 100);
 define('BLOCK_L_MAX_WIDTH', 210);
@@ -17,7 +20,7 @@ $preferred_width_left  = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_widt
 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 
                                         BLOCK_R_MAX_WIDTH);
 
-if (isset($topic)) {
+if ($topic != -1) {
     $displaysection = course_set_display($course->id, $topic);
 } else {
     if (isset($USER->display[$course->id])) {       // for admins, mostly
@@ -269,7 +272,7 @@ while ($section <= $course->numsections) {
 
         echo '<td class="right side">';
         if ($displaysection == $section) {      // Show the zoom boxes
-            echo '<a href="view.php?id='.$course->id.'&amp;topic=all#section-'.$section.'" title="'.$strshowalltopics.'">'.
+            echo '<a href="view.php?id='.$course->id.'&amp;topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
                 '<img src="'.$CFG->pixpath.'/i/all.gif" height="25" width="16" border="0" /></a><br />';
         } else {
             $strshowonlytopic = get_string('showonlytopic', '', $section);
index 8f76d1d75ebc07f9b4272e679a045286750f8539..1beb7c08e7c5dbfad270f6177012019bc3b2c59b 100644 (file)
@@ -8,6 +8,8 @@
 
     require_once($CFG->dirroot.'/mod/forum/lib.php');
 
+    $topic = optional_param('topic', -1, PARAM_INT);
+
     // Bounds for block widths
     define('BLOCK_L_MIN_WIDTH', 100);
     define('BLOCK_L_MAX_WIDTH', 210);
@@ -19,7 +21,7 @@
     $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 
                                             BLOCK_R_MAX_WIDTH);
 
-    if (isset($topic)) {
+    if ($topic != -1) {
         $displaysection = course_set_display($course->id, $topic);
     } else {
         if (isset($USER->display[$course->id])) {       // for admins, mostly
 
             echo '<td class="right side">';
             if ($displaysection == $section) {      // Show the zoom boxes
-                echo '<a href="view.php?id='.$course->id.'&amp;topic=all#section-'.$section.'" title="'.$strshowalltopics.'">'.
+                echo '<a href="view.php?id='.$course->id.'&amp;topic=0#section-'.$section.'" title="'.$strshowalltopics.'">'.
                      '<img src="'.$CFG->pixpath.'/i/all.gif" height="25" width="16" border="0" alt="'.$strshowalltopics.'" /></a><br />';
             } else {
                 $strshowonlytopic = get_string('showonlytopic', '', $section);
index 2c1be8c1a33b20f771906b6f3e2e975b4991fedb..b20ea63b818fd43f90eea06e665808be324f9719 100644 (file)
@@ -4,6 +4,8 @@
 
     require_once("$CFG->dirroot/mod/forum/lib.php");
 
+    $week = optional_param('week', -1, PARAM_INT);
+
     // Bounds for block widths
     define('BLOCK_L_MIN_WIDTH', 100);
     define('BLOCK_L_MAX_WIDTH', 210);
@@ -15,7 +17,7 @@
     $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 
                                             BLOCK_R_MAX_WIDTH);
 
-    if (isset($week)) {
+    if ($week != -1) {
         $displaysection = course_set_display($course->id, $week);
     } else {
         if (isset($USER->display[$course->id])) {
             echo '<td class="right side">';
 
             if ($displaysection == $section) {
-                echo '<a href="view.php?id='.$course->id.'&amp;week=all#section-'.$section.'" title="'.$strshowallweeks.'">'.
+                echo '<a href="view.php?id='.$course->id.'&amp;week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
                      '<img src="'.$CFG->pixpath.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
             } else {
                 $strshowonlyweek = get_string("showonlyweek", "", $section);
index 0fad3ca1625b705435dc63495649fbf1e0162c13..12d44ba49235c85f4e5be7026d896cd86d45e4ed 100644 (file)
@@ -27,6 +27,8 @@
 
     require_once("$CFG->dirroot/mod/forum/lib.php");
 
+    $week = optional_param('week', -1, PARAM_INT);
+
     // Bounds for block widths; in PIXELS.
     define('BLOCK_L_MIN_WIDTH', 100);
     define('BLOCK_L_MAX_WIDTH', 210);
@@ -47,7 +49,7 @@
     $min_max_block= 'min-width:100px; max-width:210px; ';
     $min_max_main = 'min-width:25em; max-width:37em; '; //33em
 
-    if (isset($week)) {
+    if ($week != -1) {
         $displaysection = course_set_display($course->id, $week);
     } else {
         if (isset($USER->display[$course->id])) {
             echo '</div><div class="right side">';
             
             if ($displaysection == $section) {
-                echo '<a href="view.php?id='.$course->id.'&amp;week=all#section-'.$section.'" title="'.$strshowallweeks.'">'.
+                echo '<a href="view.php?id='.$course->id.'&amp;week=0#section-'.$section.'" title="'.$strshowallweeks.'">'.
                      '<img src="'.$CFG->pixpath.'/i/all.gif" class="icon wkall" alt="'.$strshowallweeks.'" /></a><br />';
             } else {
                 $strshowonlyweek = get_string("showonlyweek", "", $section);
index 4e6330a1601b662212c11f97a4faceb06ebf2fca..d5f7b5376b692f32e98fec164bb0d7b6c0b93a55 100644 (file)
@@ -8,19 +8,21 @@
     require_login();
 
     $sectionreturn = optional_param('sr', '', PARAM_INT);
-    $add = optional_param( 'add','',PARAM_ALPHA );
-    $type = optional_param( 'type','',PARAM_ALPHA );
-    $indent = optional_param( 'indent',0,PARAM_INT );
-    $update = optional_param( 'update',0,PARAM_INT );
-    $hide = optional_param( 'hide',0,PARAM_INT );
-    $show = optional_param( 'show',0,PARAM_INT );
-    $copy = optional_param( 'copy',0,PARAM_INT );
-    $moveto = optional_param( 'moveto',0,PARAM_INT );
-    $movetosection = optional_param( 'movetosection',0,PARAM_INT );
-    $delete = optional_param( 'delete',0,PARAM_INT );
-    $course = optional_param( 'course',0,PARAM_INT );
-    $groupmode = optional_param( 'groupmode',-1,PARAM_INT );
-    $duplicate = optional_param( 'duplicate',0,PARAM_INT );
+    $add           = optional_param('add','', PARAM_ALPHA);
+    $type          = optional_param('type', '', PARAM_ALPHA);
+    $indent        = optional_param('indent', 0, PARAM_INT);
+    $update        = optional_param('update', 0, PARAM_INT);
+    $hide          = optional_param('hide', 0, PARAM_INT);
+    $show          = optional_param('show', 0, PARAM_INT);
+    $copy          = optional_param('copy', 0, PARAM_INT);
+    $moveto        = optional_param('moveto', 0, PARAM_INT);
+    $movetosection = optional_param('movetosection', 0, PARAM_INT);
+    $delete        = optional_param('delete', 0, PARAM_INT);
+    $course        = optional_param('course', 0, PARAM_INT);
+    $groupmode     = optional_param('groupmode', -1, PARAM_INT);
+    $duplicate     = optional_param('duplicate', 0, PARAM_INT);
+    $cancel        = optional_param('cancel', 0, PARAM_BOOL);
+    $cancelcopy    = optional_param('cancelcopy', 0, PARAM_BOOL);
 
     if (isset($SESSION->modform)) {   // Variables are stored in the session
         $mod = $SESSION->modform;
@@ -29,7 +31,7 @@
         $mod = (object)$_POST;
     }
 
-    if (isset($cancel)) {
+    if ($cancel) {
         if (!empty($SESSION->returnpage)) {
             $return = $SESSION->returnpage;
             unset($SESSION->returnpage);
index 3235ee6d178f68a1d8b6539d1e2801aa32f248d4..f58e65218b7360422be30a1f534226d0d9f233c6 100644 (file)
@@ -7,14 +7,15 @@
     require_once($CFG->libdir.'/blocklib.php');
 
     $id          = optional_param('id', 0, PARAM_INT);
-    $name        = optional_param('name');
-    $edit        = optional_param('edit','',PARAM_ALPHA);
-    $idnumber    = optional_param('idnumber');
-    $topic       = optional_param('topic',0,PARAM_INT);
-    $studentview = optional_param('studentview','',PARAM_ALPHA);
-    $section     = optional_param('section',0,PARAM_INT);
-    $move        = optional_param('move',0,PARAM_INT);
-    $marker      = optional_param('marker',0,PARAM_INT);
+    $name        = optional_param('name', '', PARAM_RAW);
+    $edit        = optional_param('edit', -1, PARAM_BOOL);
+    $hide        = optional_param('hide', 0, PARAM_INT);
+    $show        = optional_param('show', 0, PARAM_INT);
+    $idnumber    = optional_param('idnumber', '', PARAM_RAW);
+    $studentview = optional_param('studentview', -1, PARAM_BOOL);
+    $section     = optional_param('section', 0, PARAM_INT);
+    $move        = optional_param('move', 0, PARAM_INT);
+    $marker      = optional_param('marker',0 , PARAM_INT);
 
 
     if (empty($id) && empty($name) && empty($idnumber)) {
     }
 
     // need to check this here, as studentview=on disables edit allowed (where 'on' is checked)
-    if (($studentview == 'off') and confirm_sesskey()) {
+    if (($studentview == 0) and confirm_sesskey()) {
         $USER->studentview = false;
     }
 
     if ($PAGE->user_allowed_editing()) {
-        if (($edit == 'on') and confirm_sesskey()) {
+        if (($edit == 1) and confirm_sesskey()) {
             $USER->editing = true;
-        } else if (($edit == 'off') and confirm_sesskey()) {
+        } else if (($edit == 0) and confirm_sesskey()) {
             $USER->editing = false;
             if(!empty($USER->activitycopy) && $USER->activitycopycourse == $course->id) {
                 $USER->activitycopy       = false;
             }
         }
 
-        if (($studentview == 'on') and confirm_sesskey()) {
+        if (($studentview == 1) and confirm_sesskey()) {
             $USER->studentview = true;
             $USER->editing = false;
         }
 
-        if (isset($hide) && confirm_sesskey()) {
+        if ($hide && confirm_sesskey()) {
             set_section_visible($course->id, $hide, '0');
         }
 
-        if (isset($show) && confirm_sesskey()) {
+        if ($show && confirm_sesskey()) {
             set_section_visible($course->id, $show, '1');
         }