MDL-24316 adding support for stealth sections on course edit page - work in progress...
authorPetr Skoda <skodak@moodle.org>
Wed, 13 Oct 2010 20:17:56 +0000 (20:17 +0000)
committerPetr Skoda <skodak@moodle.org>
Wed, 13 Oct 2010 20:17:56 +0000 (20:17 +0000)
course/format/topics/format.php
course/format/weeks/format.php

index be93c5d..8edf36a 100644 (file)
@@ -25,6 +25,8 @@
  * @package
  */
 
+defined('MOODLE_INTERNAL') || die();
+
 require_once($CFG->libdir.'/filelib.php');
 
 $topic = optional_param('topic', -1, PARAM_INT);
@@ -87,6 +89,7 @@ if (ismoving($course->id)) {
 
 $section = 0;
 $thissection = $sections[$section];
+unset($sections[0]);
 
 if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
 
@@ -249,8 +252,41 @@ while ($section <= $course->numsections) {
         echo "</li>\n";
     }
 
+    unset($sections[$section]);
     $section++;
 }
+
+if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
+    // print stealth sections if present
+    $modinfo = get_fast_modinfo($course);
+    foreach ($sections as $section=>$thissection) {
+        if (empty($modinfo->sections[$section])) {
+            continue;
+        }
+
+        $strstealth = 'Invisible topic'; //TODO: MDL-24316 to be localised after we decide how to call this (skodak)
+
+        echo '<li id="section-'.$section.'" class="section main clearfix stealth hidden">'; //'<div class="left side">&nbsp;</div>';
+
+        echo '<div class="left side">';
+        echo $strstealth;
+        echo '</div>';
+        // Note, 'right side' is BEFORE content.
+        echo '<div class="right side">';
+        echo $strstealth;
+        echo '</div>';
+        echo '<div class="content">';
+        print_section($course, $thissection, $mods, $modnamesused);
+        echo '<br />';
+        if ($PAGE->user_is_editing()) {
+            print_section_add_menus($course, $section, $modnames);
+        }
+        echo '</div>';
+        echo "</li>\n";
+    }
+}
+
+
 echo "</ul>\n";
 
 if (!empty($sectionmenu)) {
index 472725a..e7c3520 100644 (file)
@@ -24,6 +24,8 @@
  * @package
  */
 
+defined('MOODLE_INTERNAL') || die();
+
     require_once($CFG->libdir.'/filelib.php');
 
     $week = optional_param('week', -1, PARAM_INT);
@@ -79,6 +81,7 @@
 
     $section = 0;
     $thissection = $sections[$section];
+    unset($sections[0]);
 
     if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
 
             echo "</li>\n";
         }
 
+        unset($sections[$section]);
         $section++;
         $weekdate = $nextweekdate;
     }
+
+    if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
+        // print stealth sections if present
+        $modinfo = get_fast_modinfo($course);
+        foreach ($sections as $section=>$thissection) {
+            if (empty($modinfo->sections[$section])) {
+                continue;
+            }
+
+            $strstealth = 'Invisible week'; //TODO: MDL-24316 to be localised after we decide how to call this (skodak)
+
+            echo '<li id="section-'.$section.'" class="section main clearfix stealth hidden">'; //'<div class="left side">&nbsp;</div>';
+
+            echo '<div class="left side">';
+            echo $strstealth;
+            echo '</div>';
+            // Note, 'right side' is BEFORE content.
+            echo '<div class="right side">';
+            echo $strstealth;
+            echo '</div>';
+            echo '<div class="content">';
+            print_section($course, $thissection, $mods, $modnamesused);
+            echo '<br />';
+            if ($PAGE->user_is_editing()) {
+                print_section_add_menus($course, $section, $modnames);
+            }
+            echo '</div>';
+            echo "</li>\n";
+        }
+    }
+
     echo "</ul>\n";
 
     if (!empty($sectionmenu)) {