From d2b23346c9eba54380eb1b45d0df844bdb4a9d7a Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 23 Apr 2006 20:58:06 +0000 Subject: [PATCH] block editing now uses PARAM_BOOL --- course/view.php | 10 +++++----- lib/weblib.php | 8 ++++---- mod/chat/view.php | 14 +++++--------- mod/data/view.php | 9 +++------ mod/quiz/view.php | 14 +++++--------- mod/resource/lib.php | 11 +++++------ my/index.php | 12 ++++-------- 7 files changed, 31 insertions(+), 47 deletions(-) diff --git a/course/view.php b/course/view.php index f58e65218b..d9afd08fd0 100644 --- a/course/view.php +++ b/course/view.php @@ -62,7 +62,7 @@ $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH); if (!isset($USER->editing)) { - $USER->editing = false; + $USER->editing = 0; } if (!isset($USER->studentview)) { @@ -76,9 +76,9 @@ if ($PAGE->user_allowed_editing()) { if (($edit == 1) and confirm_sesskey()) { - $USER->editing = true; + $USER->editing = 1; } else if (($edit == 0) and confirm_sesskey()) { - $USER->editing = false; + $USER->editing = 0; if(!empty($USER->activitycopy) && $USER->activitycopycourse == $course->id) { $USER->activitycopy = false; $USER->activitycopycourse = NULL; @@ -87,7 +87,7 @@ if (($studentview == 1) and confirm_sesskey()) { $USER->studentview = true; - $USER->editing = false; + $USER->editing = 0; } if ($hide && confirm_sesskey()) { @@ -106,7 +106,7 @@ } } } else { - $USER->editing = false; + $USER->editing = 0; } $SESSION->fromdiscussion = $CFG->wwwroot .'/course/view.php?id='. $course->id; diff --git a/lib/weblib.php b/lib/weblib.php index c65d345693..a86b59902d 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3372,10 +3372,10 @@ function update_course_icon($courseid) { if (isteacheredit($courseid)) { if (!empty($USER->editing)) { $string = get_string('turneditingoff'); - $edit = 'off'; + $edit = '0'; } else { $string = get_string('turneditingon'); - $edit = 'on'; + $edit = '1'; } return "
framename\" method=\"get\" action=\"$CFG->wwwroot/course/view.php\">". "". @@ -3429,10 +3429,10 @@ function update_mymoodle_icon() { if (!empty($USER->editing)) { $string = get_string('updatemymoodleoff'); - $edit = 'off'; + $edit = '0'; } else { $string = get_string('updatemymoodleon'); - $edit = 'on'; + $edit = '1'; } return "framename\" method=\"get\" action=\"$CFG->wwwroot/my/index.php\">". "". diff --git a/mod/chat/view.php b/mod/chat/view.php index 80f51bfc68..e6f73a1279 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -7,9 +7,9 @@ require_once($CFG->libdir.'/blocklib.php'); require_once('pagelib.php'); - $id = optional_param('id', 0, PARAM_INT); - $c = optional_param('c', 0, PARAM_INT); - $edit = optional_param('edit', ''); + $id = optional_param('id', 0, PARAM_INT); + $c = optional_param('c', 0, PARAM_INT); + $edit = optional_param('edit', -1, PARAM_BOOL); if ($id) { if (! $cm = get_record('course_modules', 'id', $id)) { @@ -57,12 +57,8 @@ $strcurrentusers = get_string('currentusers', 'chat'); $strnextsession = get_string('nextsession', 'chat'); - if (!empty($edit) && $PAGE->user_allowed_editing()) { - if ($edit == 'on') { - $USER->editing = true; - } else if ($edit == 'off') { - $USER->editing = false; - } + if (($edit != -1) and $PAGE->user_allowed_editing()) { + $USER->editing = $edit; } $PAGE->print_header($course->shortname.': %fullname%'); diff --git a/mod/data/view.php b/mod/data/view.php index 5f0fa85e3a..4eca3b4406 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -37,6 +37,7 @@ $mode = optional_param('mode', '', PARAM_ALPHA); // Force the browse mode ('single') + $edit = optional_param('edit', -1, PARAM_BOOL); /// These can be added to perform an action on a record $approve = optional_param('approve', 0, PARAM_INT); //approval recordid @@ -142,12 +143,8 @@ $pageblocks = blocks_setup($PAGE); $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210); - if (!empty($edit) && $PAGE->user_allowed_editing()) { - if ($edit == 'on') { - $USER->editing = true; - } else if ($edit == 'off') { - $USER->editing = false; - } + if (($edit != -1) and $PAGE->user_allowed_editing()) { + $USER->editing = $edit; } /// RSS and CSS meta diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 74257d0859..d408728d3c 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -7,9 +7,9 @@ require_once($CFG->libdir.'/blocklib.php'); require_once('pagelib.php'); - $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or - $q = optional_param('q', 0, PARAM_INT); // quiz ID - $edit = optional_param('edit', ''); + $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or + $q = optional_param('q', 0, PARAM_INT); // quiz ID + $edit = optional_param('edit', -1, PARAM_BOOL); if ($id) { if (! $cm = get_record("course_modules", "id", $id)) { @@ -56,12 +56,8 @@ // Print the page header - if (!empty($edit) && $PAGE->user_allowed_editing()) { - if ($edit == 'on') { - $USER->editing = true; - } else if ($edit == 'off') { - $USER->editing = false; - } + if (($edit != -1) and $PAGE->user_allowed_editing()) { + $USER->editing = $edit; } //only check pop ups if the user is not a teacher, and popup is set diff --git a/mod/resource/lib.php b/mod/resource/lib.php index eb53723f68..9c515d5447 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -148,13 +148,12 @@ function display_course_blocks_start() { /// Print the page header - if (!empty($edit) && $PAGE->user_allowed_editing()) { - if ($edit == 'on') { - $USER->editing = true; - } else if ($edit == 'off') { - $USER->editing = false; - } + $edit = optional_param('edit', -1, PARAM_BOOL); + + if (($edit != -1) and $PAGE->user_allowed_editing()) { + $USER->editing = $edit; } + $morebreadcrumbs = array($this->strresources => 'index.php?id='.$this->course->id, $this->resource->name => ''); diff --git a/my/index.php b/my/index.php index 5721d8dc30..7467250144 100644 --- a/my/index.php +++ b/my/index.php @@ -24,19 +24,15 @@ } - $edit = optional_param('edit', ''); - $blockaction = optional_param('blockaction'); + $edit = optional_param('edit', -1, PARAM_BOOL); + $blockaction = optional_param('blockaction', '', PARAM_ALPHA); $PAGE = page_create_instance($USER->id); $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH); - if (!empty($edit) && $PAGE->user_allowed_editing()) { - if ($edit == 'on') { - $USER->editing = true; - } else if ($edit == 'off') { - $USER->editing = false; - } + if (($edit != -1) and $PAGE->user_allowed_editing()) { + $USER->editing = $edit; } $PAGE->print_header($mymoodlestr); -- 2.39.5