From ec94245e7ebf9ef64b41af2fe109941fb5d1fe14 Mon Sep 17 00:00:00 2001
From: David Drummond <david@catalyst.net.nz>
Date: Tue, 21 Oct 2008 13:18:10 +0100
Subject: [PATCH] hook for a local my moodle

---
 local/lib.php |    7 +++++-
 my/index.php  |   58 ++++++++++++++++++++++++++++++++++++--------------------
 2 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/my/index.php b/my/index.php
index 449a954..0a0f7e9 100644
--- a/my/index.php
+++ b/my/index.php
@@ -63,33 +63,49 @@
     print_container_start(TRUE);
 
 /// The main overview in the middle of the page
-    
-    // limits the number of courses showing up
-    $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, 21);
-    $site = get_site();
-    $course = $site; //just in case we need the old global $course hack
 
-    if (array_key_exists($site->id,$courses)) {
-        unset($courses[$site->id]);
+    // look for a custom handler
+
+    $locallib = $CFG->dirroot . '/local/lib.php';
+
+    if (file_exists($locallib)) {
+         require_once($locallib);
     }
 
-    foreach ($courses as $c) {
-        if (isset($USER->lastcourseaccess[$c->id])) {
-            $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
-        } else {
-            $courses[$c->id]->lastaccess = 0;
+    if (function_exists('local_my_moodle') ) {
+
+        local_my_moodle();
+
+    } else {
+    
+        // limits the number of courses showing up
+        $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, 21);
+        $site = get_site();
+        $course = $site; //just in case we need the old global $course hack
+
+        if (array_key_exists($site->id,$courses)) {
+            unset($courses[$site->id]);
+        }
+
+        foreach ($courses as $c) {
+            if (isset($USER->lastcourseaccess[$c->id])) {
+                $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
+            } else {
+                $courses[$c->id]->lastaccess = 0;
+            }
         }
-    }
     
-    if (empty($courses)) {
-        print_simple_box(get_string('nocourses','my'),'center');
-    } else {
-        print_overview($courses);
-    }
+        if (empty($courses)) {
+            print_simple_box(get_string('nocourses','my'),'center');
+        } else {
+            print_overview($courses);
+        }
     
-    // if more than 20 courses
-    if (count($courses) > 20) {
-        echo '<br />...';  
+        // if more than 20 courses
+        if (count($courses) > 20) {
+            echo '<br />...';  
+        }
+
     }
     
     print_container_end();
-- 
1.5.6.5

