]> git.mjollnir.org Git - moodle.git/commitdiff
Renamed "weeks_topics" to "section_links"
authormoodler <moodler>
Fri, 7 May 2004 02:27:56 +0000 (02:27 +0000)
committermoodler <moodler>
Fri, 7 May 2004 02:27:56 +0000 (02:27 +0000)
blocks/section_links/block_section_links.php [new file with mode: 0644]
blocks/section_links/db/mysql.php [new file with mode: 0644]
blocks/section_links/db/mysql.sql [new file with mode: 0644]
blocks/section_links/db/postgres7.php [new file with mode: 0644]
blocks/section_links/db/postgres7.sql [new file with mode: 0644]

diff --git a/blocks/section_links/block_section_links.php b/blocks/section_links/block_section_links.php
new file mode 100644 (file)
index 0000000..525e2f5
--- /dev/null
@@ -0,0 +1,73 @@
+<?PHP //$Id$
+
+class CourseBlock_section_links extends MoodleBlock {
+
+    function CourseBlock_section_links ($course) {
+        if ($course->format == 'topics') {
+            $this->title = get_string('topics', 'block_section_links');
+        }
+        else if ($course->format == 'weeks') {
+            $this->title = get_string('weeks', 'block_section_links');
+        }
+        else {
+            $this->title = get_string('blockname', 'block_section_links');
+        }
+        $this->content_type = BLOCK_TYPE_TEXT;
+        $this->course = $course;
+        $this->version = 2004050500;
+    }
+    
+    function applicable_formats() {
+        return (COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS);
+    }
+
+    function get_content() {
+        global $CFG, $USER;
+
+        $highlight = 0;
+
+        if($this->content !== NULL) {
+            return $this->content;
+        }
+
+        if ($this->course->format == 'weeks') {
+            $highlight = ceil((time()-$this->course->startdate)/604800);
+            $linktext = get_string('jumptocurrentweek', 'block_section_links');
+        }
+        else if ($this->course->format == 'topics') {
+            $highlight = $this->course->marker;
+            $linktext = get_string('jumptocurrenttopic', 'block_section_links');
+        }
+        $inc = 1;
+        if ($this->course->numsections > 22) {
+            $inc = 2;
+        }
+        if ($this->course->numsections > 40) {
+            $inc = 5;
+        }
+        $courseid = $this->course->id;
+        if ($display = get_field('course_display', 'display', 'course', $courseid, 'userid', $USER->id)) {
+            $link = "$CFG->wwwroot/course/view.php?id=$courseid&amp;topic=all";
+        } else {
+            $link = '';
+        }
+        $text = '<font size=-1>';
+        for ($i = $inc; $i <= $this->course->numsections; $i += $inc) {
+            if ($i == $highlight) {
+                $text .= "<a href=\"$link#$i\"><b>$i</b></a> ";
+            } else {
+                $text .= "<a href=\"$link#$i\">$i</a> ";
+            }
+        }
+        if ($highlight) {
+            $text .= "<br><a href=\"$link#$highlight\">$linktext</a>";
+        }
+        
+        $this->content = New object;
+        $this->content->header = 'Hello';
+        $this->content->footer = '';
+        $this->content->text = $text;
+        return $this->content;
+    }
+}
+?>
diff --git a/blocks/section_links/db/mysql.php b/blocks/section_links/db/mysql.php
new file mode 100644 (file)
index 0000000..897bb30
--- /dev/null
@@ -0,0 +1,33 @@
+<?PHP  //$Id$
+//
+// This file keeps track of upgrades to Moodle's
+// blocks system.
+//
+// Sometimes, changes between versions involve
+// alterations to database structures and other
+// major things that may break installations.
+//
+// The upgrade function in this file will attempt
+// to perform all the necessary actions to upgrade
+// your older installtion to the current version.
+//
+// If there's something it cannot do itself, it
+// will tell you what you need to do.
+//
+// Versions are defined by backup_version.php
+//
+// This file is tailored to MySQL
+
+function section_links_upgrade($oldversion=0) {
+
+    global $CFG;
+    
+    $result = true;
+
+    if ($oldversion < 2004050500 and $result) {
+        $result = true; //Nothing to do
+    }
+
+    //Finally, return result
+    return $result;
+}
diff --git a/blocks/section_links/db/mysql.sql b/blocks/section_links/db/mysql.sql
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/blocks/section_links/db/postgres7.php b/blocks/section_links/db/postgres7.php
new file mode 100644 (file)
index 0000000..e391b81
--- /dev/null
@@ -0,0 +1,33 @@
+<?PHP  //$Id$
+//
+// This file keeps track of upgrades to Moodle's
+// blocks system.
+//
+// Sometimes, changes between versions involve
+// alterations to database structures and other
+// major things that may break installations.
+//
+// The upgrade function in this file will attempt
+// to perform all the necessary actions to upgrade
+// your older installtion to the current version.
+//
+// If there's something it cannot do itself, it
+// will tell you what you need to do.
+//
+// Versions are defined by backup_version.php
+//
+// This file is tailored to PostgreSQL
+
+function section_links_upgrade($oldversion=0) {
+
+    global $CFG;
+    
+    $result = true;
+
+    if ($oldversion < 2004050500 and $result) {
+        $result = true; //Nothing to do
+    }
+
+    //Finally, return result
+    return $result;
+}
diff --git a/blocks/section_links/db/postgres7.sql b/blocks/section_links/db/postgres7.sql
new file mode 100644 (file)
index 0000000..e69de29