Skip to content

Commit

Permalink
general cleanup of xxx_parameter() functions + fixed several register…
Browse files Browse the repository at this point in the history
… globals problems
  • Loading branch information
skodak committed Apr 11, 2006
1 parent 4458276 commit 0cdae0d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 36 deletions.
7 changes: 5 additions & 2 deletions course/format/lams/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -17,7 +20,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
Expand Down Expand Up @@ -269,7 +272,7 @@

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);
Expand Down
6 changes: 4 additions & 2 deletions course/format/topics/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -198,7 +200,7 @@

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);
Expand Down
6 changes: 4 additions & 2 deletions course/format/weeks/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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])) {
Expand Down Expand Up @@ -198,7 +200,7 @@
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);
Expand Down
6 changes: 4 additions & 2 deletions course/format/weekscss/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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])) {
Expand Down Expand Up @@ -226,7 +228,7 @@
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);
Expand Down
30 changes: 16 additions & 14 deletions course/mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,7 +31,7 @@
$mod = (object)$_POST;
}

if (isset($cancel)) {
if ($cancel) {
if (!empty($SESSION->returnpage)) {
$return = $SESSION->returnpage;
unset($SESSION->returnpage);
Expand Down
29 changes: 15 additions & 14 deletions course/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -69,31 +70,31 @@
}

// 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;
$USER->activitycopycourse = NULL;
}
}

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');
}

Expand Down

0 comments on commit 0cdae0d

Please sign in to comment.