]> git.mjollnir.org Git - moodle.git/commitdiff
Added new "Program" resource type, which allows Moodle to cooperate
authormoodler <moodler>
Tue, 24 Dec 2002 07:01:03 +0000 (07:01 +0000)
committermoodler <moodler>
Tue, 24 Dec 2002 07:01:03 +0000 (07:01 +0000)
with external web applications by passing info about the current
session to them.

Code contributed by Mark Kimes.

mod/resource/details.php
mod/resource/lib.php
mod/resource/view.php

index d63dda078fabf7f493c990bb2c644a423d8548d5..cdc2720f61288a18c4713fd2b55901e94905bed0 100644 (file)
@@ -68,6 +68,7 @@
 
             case WEBPAGE:
             case WEBLINK:
+            case PROGRAM:
                 $strexampleurl = get_string("exampleurl", "resource");
                 ?>
                 <TR VALIGN=top>
@@ -75,7 +76,7 @@
                         <P><B><?=$strtypename?>:</B></P>
                     </TD>
                     <TD>
-                        <INPUT NAME="reference" SIZE=60 VALUE="<? p($form->reference) ?>">
+                        <INPUT NAME="reference" SIZE=\"100\" VALUE="<? p($form->reference) ?>">
                     </TD>
                 </TR>
                 <TR VALIGN=top>
index c3f65ca52203f3ec038a75d77f29ed9fed4793c0..c7595dc45047f6bb4c97d2406e0f0a8302f50623 100644 (file)
@@ -6,13 +6,15 @@ define("UPLOADEDFILE","3");
 define("PLAINTEXT",   "4");
 define("WEBLINK",     "5");
 define("HTML",        "6");
+define("PROGRAM",     "7");
 
 $RESOURCE_TYPE = array (REFERENCE    => get_string("resourcetype1", "resource"),
                         WEBPAGE      => get_string("resourcetype2", "resource"),
                         UPLOADEDFILE => get_string("resourcetype3", "resource"),
                         PLAINTEXT    => get_string("resourcetype4", "resource"),
                         WEBLINK      => get_string("resourcetype5", "resource"),
-                        HTML         => get_string("resourcetype6", "resource") );
+                        HTML         => get_string("resourcetype6", "resource"),
+                        PROGRAM      => get_string("resourcetype7", "resource") );
 
 function resource_list_all_resources($courseid=0, $sort="name ASC", $recent=0) {
     // Returns list of all resource links in an array of strings
index e495c07a8011bce5c15fff84e6950ae627ba3e32..95768270f6f635b8ad695f24c5bffb8e144ed205 100644 (file)
             print_footer($course);
             break;
 
+        case PROGRAM:   // Code provided by Mark Kimes <hectorp@buckfoodsvc.com>
+            add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
+
+            $temptime = gmdate("YmdHis",time());
+
+            $temproot = $CFG->wwwroot . "/mod/resource/";
+
+            // I tried to get around this.  I really did.  But here we
+            // are, redefining the navigation resources specifically anyway.
+            // On the plus side, you can change the format of the navigation
+            // strings above without worrying what it'll do to this code.  On
+            // the negative side, you'll have to update this code if you
+            // change the structure of the navigation completely.  Bonus
+            // is that now we can have a chain of cooperative sites, each
+            // adding to the navigation string as it moves down the line,
+            // which could be quite cool.  -- Mark
+
+            if ($course->category) {
+                $tempref = "<$course->shortname><" . $temproot . "../../course/view.php?id=$course->id>" .
+                           "<$strresources><" . $temproot . "index.php?id=$course->id>";
+            } else {
+                $tempref = "<$strresources><index.php?id=$course->id>";
+            }
+
+            $tempurl = trim($resource->reference);
+
+            if ($tempquerystring = strstr($tempurl,'?')) {
+                $tempquerystring = substr($tempquerystring,1);
+                $tempurl = substr($tempurl,0,strlen($tempurl) - strlen($tempquerystring));
+            }
+            if (!empty($tempquerystring)) {
+                $tempquerystring = preg_replace("/(.*=)([^&]*)/e", 
+                                                "'\\1' . urlencode('\\2')", 
+                                                $tempquerystring);
+            }
+            $temp = $tempurl . $tempquerystring .
+                    ((strstr($tempurl,'?')) ? "&amp;" : "?") .
+                    "extern_nav=" . urlencode($tempref) .
+                    "&amp;extern_usr=" . 
+                    urlencode($USER->username) .
+                    "&amp;extern_nam=" . urlencode("$USER->firstname $USER->lastname") .
+                    "&amp;extern_tim=" . urlencode($temptime) .
+                    "&amp;extern_pwd=" .
+                    urlencode(md5($temptime . $USER->password));
+            redirect($temp);
+            break;
+
         default:
             print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
                          "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
             break;
     }
 
-
 ?>