]> git.mjollnir.org Git - moodle.git/commitdiff
Modularised some of the processing for "extra" information such as
authormoodler <moodler>
Wed, 22 Oct 2003 13:14:56 +0000 (13:14 +0000)
committermoodler <moodler>
Wed, 22 Oct 2003 13:14:56 +0000 (13:14 +0000)
information for popup windows on resources and labels

course/lib.php
mod/label/lib.php
mod/resource/lib.php

index 05efc5089971a7cd3b2b6eef3e73fe982e48e98d..af82da58a4af47d43dfb2d7dbbdb8d6d5defbd06 100644 (file)
@@ -361,6 +361,8 @@ function get_array_of_activities($courseid) {
 //  visible - is the instance visible or not
 //  extra - contains extra string to include in any link
 
+    global $CFG;
+
     $mod = array();
 
     if (!$rawmods = get_course_mods($courseid)) {
@@ -381,21 +383,15 @@ function get_array_of_activities($courseid) {
                    $mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance));
                    $mod[$seq]->visible = $rawmods[$seq]->visible;
                    $mod[$seq]->extra = "";
-                   
-                   // This part is an ugly hack that doesn't belong here//
-                   if ($mod[$seq]->mod == "resource") {
-                       if ($resource = get_record("resource", "id", $rawmods[$seq]->instance)) {
-                           if (($resource->type == 3 or $resource->type == 5) and !empty($resource->alltext)) {
-                               $mod[$seq]->extra = urlencode("target=\"resource$resource->id\" onClick=\"return ".
-                                                   "openpopup('/mod/resource/view.php?inpopup=true&id=".
-                                                   $mod[$seq]->cm.
-                                                   "','resource$resource->id','$resource->alltext');\"");
-                           }
-                       }
-                   }
-                   if ($mod[$seq]->mod == "label") {
-                       if ($label = get_record("label", "id", $rawmods[$seq]->instance)) {
-                           $mod[$seq]->extra = urlencode($label->content);
+
+                   $modname = $mod[$seq]->mod;
+                   $functionname = $modname."_get_coursemodule_info";
+
+                   include_once("$CFG->dirroot/mod/$modname/lib.php");
+
+                   if (function_exists($functionname)) {
+                       if ($extra = $functionname($rawmods[$seq])) {
+                           $mod[$seq]->extra = $extra;
                        }
                    }
                }
index c01d7f78691205e440f0fd9110cfc810d3b872aa..f6f9c0519e1b7be20d05407a4436f4ebfb633332 100644 (file)
@@ -79,4 +79,18 @@ function label_get_participants($labelid) {
     return false;
 }
 
+function label_get_coursemodule_info($coursemodule) {
+/// Given a course_module object, this function returns any 
+/// "extra" information that may be needed when printing
+/// this activity in a course listing.
+///
+/// See get_array_of_activities() in course/lib.php
+
+   if ($label = get_record("label", "id", $coursemodule->instance)) {
+       return urlencode($label->content);
+   }
+
+   return false;
+}
+
 ?>
index 4c781866ce1f899ba245eff3cf63d212322a2214..2cc390f0c4eee0ca453b4acb679d16a7b852b509 100644 (file)
@@ -133,4 +133,25 @@ function resource_get_participants($resourceid) {
     return false;
 }
 
+function resource_get_coursemodule_info($coursemodule) {
+/// Given a course_module object, this function returns any 
+/// "extra" information that may be needed when printing
+/// this activity in a course listing.
+///
+/// See get_array_of_activities() in course/lib.php
+///
+
+   if ($resource = get_record("resource", "id", $coursemodule->instance)) {
+       if (($resource->type == UPLOADEDFILE or $resource->type == WEBLINK) and !empty($resource->alltext)) {
+           return urlencode("target=\"resource$resource->id\" onClick=\"return ".
+                            "openpopup('/mod/resource/view.php?inpopup=true&id=".
+                            $coursemodule->id.
+                            "','resource$resource->id','$resource->alltext');\"");
+       }
+   }
+
+   return false;
+}
+
+
 ?>