]> git.mjollnir.org Git - moodle.git/commitdiff
moodle_page: MDL-12212 reimplement user_is_editing, deprecate isediting
authortjhunt <tjhunt>
Wed, 6 May 2009 08:59:29 +0000 (08:59 +0000)
committertjhunt <tjhunt>
Wed, 6 May 2009 08:59:29 +0000 (08:59 +0000)
23 files changed:
admin/pagelib.php
admin/settings.php
blocks/admin/block_admin.php
blocks/course_summary/block_course_summary.php
blocks/site_main_menu/block_site_main_menu.php
blocks/social_activities/block_social_activities.php
blog/blogpage.php
blog/index.php
blog/lib.php
course/category.php
course/format/topics/format.php
course/format/weeks/format.php
course/index.php
course/lib.php
course/search.php
lib/adminlib.php
lib/moodlelib.php
lib/pagelib.php
lib/simpletest/testpagelib_moodlepage.php
lib/weblib.php
mod/scorm/locallib.php
my/pagelib.php
tag/pagelib.php

index 374b1aa959e81353c465575b0652fc653c995405..4514bba90d0f6def98a73a7553f7421184c891fc 100644 (file)
@@ -31,12 +31,6 @@ class page_admin extends page_base {
         return has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM));
     }
 
-    // has to be fixed. i know there's a "proper" way to do this
-    function user_is_editing() {
-        global $USER;
-        return $USER->adminediting;
-    }
-
     /**
      * Use this to pass extra HTML that is added after the turn blocks editing on/off button.
      *
index 4be54055109be5bf5490708d6a35fb8819e3f4f2..1e9d4a7e23a384966e9e953aeeb9ac75fd804e83 100644 (file)
@@ -58,16 +58,8 @@ $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id numb
 $PAGE->set_pagetype('admin-setting-' . $section);
 $PAGE->init_extra($section);
 
-if (!isset($USER->adminediting)) {
-    $USER->adminediting = false;
-}
-
-if ($PAGE->user_allowed_editing()) {
-    if ($adminediting == 1) {
-        $USER->adminediting = true;
-    } elseif ($adminediting == 0) {
-        $USER->adminediting = false;
-    }
+if ($PAGE->user_allowed_editing() && $adminediting != -1) {
+    $USER->editing = $adminediting;
 }
 
 
index 1b7a92d1cdb66851112034cbccaece62bf546760..0b78486b3f5be2d5be41e63341ad00f0d32ad60f 100644 (file)
@@ -8,7 +8,7 @@ class block_admin extends block_list {
 
     function get_content() {
 
-        global $CFG, $USER, $SITE, $COURSE, $DB;
+        global $CFG, $USER, $SITE, $COURSE, $DB, $PAGE;
 
         if ($this->content !== NULL) {
             return $this->content;
@@ -57,7 +57,7 @@ class block_admin extends block_list {
 
         if ($course->id !== SITEID and has_capability('moodle/course:update', $context)) {
             $this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" class="icon" alt="" />';
-            if (isediting($this->instance->pageid)) {
+            if ($PAGE->user_is_editing()) {
                 $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=off&amp;sesskey='.sesskey().'">'.get_string('turneditingoff').'</a>';
             } else {
                 $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&amp;edit=on&amp;sesskey='.sesskey().'">'.get_string('turneditingon').'</a>';
index 2846cb3fec41d911e2a8d0e2fe595417904697b4..8ffc2448d8d54e09fe1cfe81a02c088b2408254f 100644 (file)
@@ -14,7 +14,7 @@ class block_course_summary extends block_base {
     }
 
     function get_content() {
-        global $CFG, $COURSE;
+        global $CFG, $COURSE, $PAGE;
 
         if($this->content !== NULL) {
             return $this->content;
@@ -28,7 +28,7 @@ class block_course_summary extends block_base {
         $options = new object();
         $options->noclean = true;    // Don't clean Javascripts etc
         $this->content->text = format_text($COURSE->summary, FORMAT_HTML, $options);
-        if (isediting($COURSE->id)) { // ?? courseid param not there??
+        if ($PAGE->user_is_editing()) {
             if($COURSE->id == SITEID) {
                 $editpage = $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=frontpagesettings';
             } else {
index 31f958b4005a8082159ebf121877bdd92e72a9e2..144a6640d2e44445ac95106b990f51f68fba6097 100644 (file)
@@ -11,7 +11,7 @@ class block_site_main_menu extends block_list {
     }
 
     function get_content() {
-        global $USER, $CFG, $COURSE, $DB;
+        global $USER, $CFG, $COURSE, $DB, $PAGE;
 
         if ($this->content !== NULL) {
             return $this->content;
@@ -35,8 +35,8 @@ class block_site_main_menu extends block_list {
         require_once($CFG->dirroot.'/course/lib.php');
 
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
-        $isediting = isediting($this->instance->pageid) && has_capability('moodle/course:manageactivities', $context);
-        $modinfo =& get_fast_modinfo($course);
+        $isediting = $PAGE->user_is_editing() && has_capability('moodle/course:manageactivities', $context);
+        $modinfo = get_fast_modinfo($course);
 
 /// extra fast view mode
         if (!$isediting) {
index 65d5c2c84e2fbb60425a4206d87d9f199e41afdd..06f29dfde35e4be1cfd610241e75cfbb5a9934d7 100644 (file)
@@ -11,7 +11,7 @@ class block_social_activities extends block_list {
     }
 
     function get_content() {
-        global $USER, $CFG, $COURSE, $DB;
+        global $USER, $CFG, $COURSE, $DB, $PAGE;
 
         if ($this->content !== NULL) {
             return $this->content;
@@ -35,7 +35,7 @@ class block_social_activities extends block_list {
         require_once($CFG->dirroot.'/course/lib.php');
 
         $context = get_context_instance(CONTEXT_COURSE, $course->id);
-        $isediting = isediting($this->instance->pageid) && has_capability('moodle/course:manageactivities', $context);
+        $isediting = $PAGE->user_is_editing() && has_capability('moodle/course:manageactivities', $context);
         $modinfo = get_fast_modinfo($course);
 
 /// extra fast view mode
index 2f3e952dd5049b2567c7b9832ce3514001b7eb90..19c8635c1ba661ba11adc4478461566149ac60bb 100644 (file)
@@ -56,18 +56,6 @@ class page_blog extends page_base {
         return false;
     }
 
-    // Also, admins are considered to have "always on" editing (I wanted to avoid duplicating
-    // the code that turns editing on/off here; you can roll your own or copy course/view.php).
-    function user_is_editing() {
-        global $SESSION;
-
-        if (isloggedin() && !isguest()) {
-            $this->editing = !empty($SESSION->blog_editing_enabled);
-            return $this->editing;
-        }
-        return false;
-    }
-
     //over-ride parent method's print_header because blog already passes more than just the title along
     function print_header($pageTitle='', $pageHeading='', $pageNavigation='', $pageFocus='', $pageMeta='') {
         global $USER;
@@ -82,18 +70,18 @@ class page_blog extends page_base {
 
     /////////// Blog page specific functions
     function get_extra_header_string() {
-        global $SESSION, $CFG, $USER;
+        global $CFG, $USER;
 
         $editformstring = '';
         if ($this->user_allowed_editing()) {
-            if (!empty($SESSION->blog_editing_enabled)) {
+            if ($this->user_is_editing()) {
                 $editingString = get_string('turneditingoff');
             } else {
                 $editingString = get_string('turneditingon');
             }
 
             $params = $this->url->params();
-            $params['edit'] = empty($SESSION->blog_editing_enabled) ? 1 : 0;
+            $params['edit'] = $this->user_is_editing() ? 0 : 1;
             $paramstring = '';
             foreach ($params as $key=>$val) {
                 $paramstring .= '<input type="hidden" name="'.$key.'" value="'.s($val).'" />';
index 565d1ca8996f41c1622b89f3e0c60cffa6b967e4..f06fadf0bf994b7cff298e248adb38b21275f58b 100755 (executable)
@@ -29,10 +29,9 @@ if (empty($CFG->bloglevel)) {
 
 $sitecontext = get_context_instance(CONTEXT_SYSTEM);
 
-
 // change block edit staus if not guest and logged in
 if (isloggedin() and !isguest() and $edit != -1) {
-    $SESSION->blog_editing_enabled = $edit;
+    $USER->editing = $edit;
 }
 
 if (empty($filtertype)) {
index 8d9026375cf1cd28a2aecfb0aa04a82efaace86e..8f0fbc1c5ecf21ecdcd27b4b282ddf975f74dd3e 100755 (executable)
     }
 
 
-    /**
-     * Adaptation of isediting in moodlelib.php for blog module
-     * @return bool
-     */
-    function blog_isediting() {
-        global $SESSION;
-
-        return !empty($SESSION->blog_editing_enabled);
-    }
-
-
     /**
      *  This function is in lib and not in BlogInfo because entries being searched
      *   might be found in any number of blogs rather than just one.
index 73f88ccbe5202f7a662463f603eaab7228b326ae..394a769e36f6a4965ace57b8ac0a1195cd3390d5 100644 (file)
@@ -39,9 +39,9 @@
 
     if (update_category_button($category->id)) {
         if ($categoryedit !== -1) {
-            $USER->categoryediting = $categoryedit;
+            $USER->editing = $categoryedit;
         }
-        $editingon = !empty($USER->categoryediting);
+        $editingon = $PAGE->user_is_editing();
         $navbaritem = update_category_button($category->id); // Must call this again after updating the state.
     } else {
         $navbaritem = print_course_search('', true, 'navbar');
index c1cdd512baddd3de03eb9ce1816164136b0d8a73..6971c2d5a61faf8e9c94afb0fe4b045332e7bd24 100644 (file)
     $section = 0;
     $thissection = $sections[$section];
 
-    if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
+    if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
 
         // Note, no need for a 'left side' cell or DIV.
         // Note, 'right side' is BEFORE content.
         $summaryformatoptions->noclean = true;
         echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions);
 
-        if (isediting($course->id) && has_capability('moodle/course:update', $coursecontext)) {
+        if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $coursecontext)) {
             echo '<a title="'.$streditsummary.'" '.
                  ' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
                  ' class="icon edit" alt="'.$streditsummary.'" /></a>';
         
         print_section($course, $thissection, $mods, $modnamesused);
 
-        if (isediting($course->id)) {
+        if ($PAGE->user_is_editing()) {
             print_section_add_menus($course, $section, $modnames);
         }
 
                      '<img src="'.$CFG->pixpath.'/i/one.gif" class="icon" alt="'.$strshowonlytopic.'" /></a><br />';
             }
 
-            if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
+            if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
 
                if ($course->marker == $section) {  // Show the "light globe" on/off
                            echo '<a href="view.php?id='.$course->id.'&amp;marker=0&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.'<img src="'.$CFG->pixpath.'/i/marked.gif" alt="'.$strmarkedthistopic.'" /></a><br />';
                   echo '&nbsp;';
                }
 
-                if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
+                if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
                     echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
                          '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
                 }
 
                 print_section($course, $thissection, $mods, $modnamesused);
 
-                if (isediting($course->id)) {
+                if ($PAGE->user_is_editing()) {
                     print_section_add_menus($course, $section, $modnames);
                 }
             }
index 4eaa588c3afd32eb7b3191ac92a8f7cbf5288fd2..25143e7ab221bd5f84fc176aa6b4108e636377b5 100644 (file)
     $section = 0;
     $thissection = $sections[$section];
 
-    if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
+    if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
 
         // Note, 'right side' is BEFORE content.
         echo '<li id="section-0" class="section main" >';
         $summaryformatoptions->noclean = true;
         echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions);
 
-        if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
+        if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
             echo '<p><a title="'.$streditsummary.'" '.
                  ' href="editsection.php?id='.$thissection->id.'"><img src="'.$CFG->pixpath.'/t/edit.gif" '.
                  ' class="icon edit" alt="'.$streditsummary.'" /></a></p>';
         
         print_section($course, $thissection, $mods, $modnamesused);
 
-        if (isediting($course->id)) {
+        if ($PAGE->user_is_editing()) {
             print_section_add_menus($course, $section, $modnames);
         }
 
                      '<img src="'.$CFG->pixpath.'/i/one.gif" class="icon wkone" alt="'.$strshowonlyweek.'" /></a><br />';
             }
 
-            if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
+            if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
                 if ($thissection->visible) {        // Show the hide/show eye
                     echo '<a href="view.php?id='.$course->id.'&amp;hide='.$section.'&amp;sesskey='.sesskey().'#section-'.$section.'" title="'.$strweekhide.'">'.
                          '<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
                 $summaryformatoptions->noclean = true;
                 echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
 
-                if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
+                if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
                     echo ' <a title="'.$streditsummary.'" href="editsection.php?id='.$thissection->id.'">'.
                          '<img src="'.$CFG->pixpath.'/t/edit.gif" class="icon edit" alt="'.$streditsummary.'" /></a><br /><br />';
                 }
 
                 print_section($course, $thissection, $mods, $modnamesused);
 
-                if (isediting($course->id)) {
+                if ($PAGE->user_is_editing()) {
                     print_section_add_menus($course, $section, $modnames);
                 }
             }
index 0613b082c6f2ed8b9f92963ad18bfe3c04941f91..5ad01563455feeb7a750426746b5a2de2eb5733f 100644 (file)
@@ -26,9 +26,9 @@
 
     if (update_category_button()) {
         if ($categoryedit !== -1) {
-            $USER->categoryediting = $categoryedit;
+            $USER->editing = $categoryedit;
         }
-        $adminediting = !empty($USER->categoryediting);
+        $adminediting = $PAGE->user_is_editing();
     } else {
         $adminediting = false;
     }
index ac584e7af8f254ac2e1064f8e25cfa0c8d845cfa..82a5044172d1aa18fe4369b9e6025168aed8d006 100644 (file)
@@ -1367,7 +1367,7 @@ function set_section_visible($courseid, $sectionnumber, $visibility) {
  * Prints a section full of activity modules
  */
 function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%", $hidecompletion=false) {
-    global $CFG, $USER, $DB;
+    global $CFG, $USER, $DB, $PAGE;
 
     static $initialised;
 
@@ -1385,7 +1385,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
     if (!isset($initialised)) {
         $groupbuttons     = ($course->groupmode or (!$course->groupmodeforce));
         $groupbuttonslink = (!$course->groupmodeforce);
-        $isediting        = isediting($course->id);
+        $isediting        = $PAGE->user_is_editing();
         $ismoving         = $isediting && ismoving($course->id);
         if ($ismoving) {
             $strmovehere  = get_string("movehere");
@@ -2181,7 +2181,7 @@ function print_course_request_buttons($systemcontext) {
  *      to see it.
  */
 function update_category_button($categoryid = 0) {
-    global $CFG, $USER;
+    global $CFG, $PAGE;
 
     // Check permissions.
     $context = get_category_or_system_context($categoryid);
@@ -2190,7 +2190,7 @@ function update_category_button($categoryid = 0) {
     }
 
     // Work out the appropriate action.
-    if (!empty($USER->categoryediting)) {
+    if ($PAGE->user_is_editing()) {
         $label = get_string('turneditingoff');
         $edit = 'off';
     } else {
index 31f97c8c6cc80cad4554f7d2aba2b51f31a4116f..a15762c6a6adfc9227ac2eeb4c27b4703fbd1a8f 100644 (file)
@@ -35,9 +35,9 @@
 
     if (update_category_button()) {
         if ($edit !== -1) {
-            $USER->categoryediting = $edit;
+            $USER->editing = $edit;
         }
-        $adminediting = !empty($USER->categoryediting);
+        $adminediting = $PAGE->user_is_editing();
     } else {
         $adminediting = false;
     }
index 418f48e15f0c1f6cbd6b1f02b6120946db40d50d..b0a325883e053c34b2b7f1fba71bc2358117c41f 100644 (file)
@@ -3931,17 +3931,8 @@ function admin_externalpage_setup($section, $extrabutton = '',
     }
 
     $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
-
-    if (!isset($USER->adminediting)) {
-        $USER->adminediting = false;
-    }
-
-    if ($PAGE->user_allowed_editing()) {
-        if ($adminediting == 1) {
-            $USER->adminediting = true;
-        } elseif ($adminediting == 0) {
-            $USER->adminediting = false;
-        }
+    if ($PAGE->user_allowed_editing() && $adminediting != -1) {
+        $USER->editing = $adminediting;
     }
 }
 
index 532ef40b620a78f3f6b84b92ad9b28058a31e00d..05bc958566a2668d532c9b8916058bfb3b5a46e8 100644 (file)
@@ -2628,6 +2628,7 @@ function isguestuser($user=NULL) {
 }
 
 /**
+ * @deprecated since Moodle 2.0 - use $PAGE->user_is_editing() instead.
  * Determines if the currently logged in user is in editing mode.
  * Note: originally this function had $userid parameter - it was not usable anyway
  *
@@ -2635,14 +2636,9 @@ function isguestuser($user=NULL) {
  * @return bool
  */
 function isediting() {
-    global $USER, $PAGE;
-
-    if (empty($USER->editing)) {
-        return false;
-    } elseif (is_object($PAGE) && method_exists($PAGE,'user_allowed_editing')) {
-        return $PAGE->user_allowed_editing();
-    }
-    return true;//false;
+    global $PAGE;
+    debugging('call to deprecated function isediting(). Please use $PAGE->user_is_editing() instead', DEBUG_DEVELOPER);
+    return $PAGE->user_is_editing();
 }
 
 /**
index abde579d0c73fbd5fe54c7394e8d344d6c190691..b2d5b392c30bfeebc7e4adc0df75ec0bbc3d2175 100644 (file)
@@ -211,6 +211,25 @@ class moodle_page {
         }
     }
 
+/// Other information getting methods ==========================================
+
+    /**
+     * @return boolean should the current user see this page in editing mode.
+     * That is, are they allowed to edit this page, and are they currently in
+     * editing mode.
+     */
+    public function user_is_editing() {
+        global $USER;
+        return !empty($USER->editing) && $this->user_allowed_editing();
+    }
+
+    /**
+     * @return boolean does the user have permission to see this page in editing mode.
+     */
+    public function user_allowed_editing() {
+        return true; // TODO
+    }
+
 /// Setter methods =============================================================
 
     /**
@@ -738,20 +757,6 @@ class page_base extends moodle_page {
 
 /// Class Functions
 
-    // USER-RELATED THINGS
-
-    // By default, no user is editing anything and none CAN edit anything. Developers
-    // will have to override these settings to let Moodle know when it should grant
-    // editing rights to the user viewing the page.
-    function user_allowed_editing() {
-        trigger_error('Page class does not implement method <strong>user_allowed_editing()</strong>', E_USER_WARNING);
-        return false;
-    }
-    function user_is_editing() {
-        trigger_error('Page class does not implement method <strong>user_is_editing()</strong>', E_USER_WARNING);
-        return false;
-    }
-
     // HTML OUTPUT SECTION
 
     // We have absolutely no idea what derived pages are all about
@@ -860,15 +865,6 @@ class page_course extends page_base {
         }
     }
 
-    // Is the user actually editing this course page or "sticky page" right now?
-    function user_is_editing() {
-        if (has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM)) && defined('ADMIN_STICKYBLOCKS')) {
-            //always in edit mode on sticky page
-            return true;
-        }
-        return isediting($this->id);
-    }
-
     // HTML OUTPUT SECTION
 
     // This function prints out the common part of the page's header.
@@ -994,11 +990,6 @@ class page_generic_activity extends page_base {
         return has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_MODULE, $this->modulerecord->id));
     }
 
-    function user_is_editing() {
-        $this->init_full();
-        return isediting($this->modulerecord->course);
-    }
-
     function print_header($title, $morenavlinks = NULL, $bodytags = '', $meta = '') {
         global $USER, $CFG;
 
index 7e2e3001dcf86d8073ce7d0559f84b1ca87cdc91..0240d0a4d9e049de7258311edbeb3bed3f896c97 100644 (file)
@@ -453,4 +453,39 @@ class moodle_page_categories_test extends UnitTestCaseUsingDatabase {
     }
 }
 
+/**
+ * Test functions that affect filter_active table with contextid = $syscontextid.
+ */
+class moodle_page_editing_test extends UnitTestCase {
+    protected $testpage;
+    protected $originaluserediting;
+
+    public function setUp() {
+        global $USER;
+        $this->originaluserediting = !empty($USER->editing);
+        $this->testpage = new testable_moodle_page();
+    }
+
+    public function tearDown() {
+        global $USER;
+        $this->testpage = NULL;
+        $USER->editing = $this->originaluserediting;
+    }
+
+    public function test_user_is_editing_on() {
+        // Setup fixture
+        global $USER;
+        $USER->editing = true;
+        // Validate
+        $this->assertTrue($this->testpage->user_is_editing());
+    }
+
+    public function test_user_is_editing_off() {
+        // Setup fixture
+        global $USER;
+        $USER->editing = false;
+        // Validate
+        $this->assertFalse($this->testpage->user_is_editing());
+    }
+}
 ?>
index 3bc59d1cbfe10a83641a020cfea856d54d4e76b7..ab3c3d074b4748d13131b8af7f7a895c4dc8cd3b 100644 (file)
@@ -5091,11 +5091,11 @@ function update_module_button($cmid, $ignored, $string) {
  */
 
 function update_categories_search_button($search,$page,$perpage) {
-    global $CFG, $USER;
+    global $CFG, $PAGE;
 
     // not sure if this capability is the best  here
     if (has_capability('moodle/category:manage', get_context_instance(CONTEXT_SYSTEM))) {
-        if (!empty($USER->categoryediting)) {
+        if ($PAGE->user_is_editing()) {
             $string = get_string("turneditingoff");
             $edit = "off";
             $perpage = 30;
index 2d071bac23c5be43b1d6e862c0d7db7bb1c82904..529ac124816a7cea49d05b014ab259b818848beb 100755 (executable)
@@ -665,7 +665,7 @@ function scorm_get_last_attempt($scormid, $userid) {
 }
 
 function scorm_course_format_display($user,$course) {
-    global $CFG, $DB;
+    global $CFG, $DB, $PAGE;
 
     $strupdate = get_string('update');
     $strmodule = get_string('modulename','scorm');
@@ -681,7 +681,7 @@ function scorm_course_format_display($user,$course) {
         $colspan = '';
         $headertext = '<table width="100%"><tr><td class="title">'.get_string('name').': <b>'.format_string($scorm->name).'</b>';
         if (has_capability('moodle/course:manageactivities', $context)) {
-            if (isediting($course->id)) {
+            if ($PAGE->user_is_editing()) {
                 // Display update icon
                 $path = $CFG->wwwroot.'/course';
                 $headertext .= '<span class="commands">'.
index 1c43a18280dfdc10b659319bb572f38ddf03bfc3..a7a718bca72e71ac15b7f1f4e240f89ccb6458bf 100644 (file)
@@ -13,14 +13,6 @@ class page_my_moodle extends page_base {
         return false;
     }
 
-    function user_is_editing() {
-        global $USER;
-        if (has_capability('moodle/my:manageblocks', get_context_instance(CONTEXT_SYSTEM)) && defined('ADMIN_STICKYBLOCKS')) {
-            return true;
-        }
-        return (!empty($USER->editing));
-    }
-
     function print_header($title) {
 
         global $USER, $CFG;
index 658dc00074a47430209eb2dda984cc6378716d50..44de6ad0bdd7da916aba19a3d3dee09681eb0322 100644 (file)
@@ -15,12 +15,6 @@ class page_tag extends page_base {
         return has_capability('moodle/tag:editblocks', $systemcontext);        
     }
 
-    function user_is_editing() {
-        global $USER;
-
-        return (!empty($USER->editing));
-    }
-
     //-----------  printing funtions -----------
 
     function print_header() {