]> git.mjollnir.org Git - moodle.git/commitdiff
Performance enhancement for user listing (caching of language strings)
authormartin <martin>
Tue, 6 Aug 2002 09:21:14 +0000 (09:21 +0000)
committermartin <martin>
Tue, 6 Aug 2002 09:21:14 +0000 (09:21 +0000)
user/index.php
user/lib.php

index eabeed9d13d3a051dd30d30ae2730a3da28c1dab..f1fc62d815640f2b006ff3def7a71a78fe4ee454 100644 (file)
                       get_string("participants"), "");
     }
 
+    $string->email       = get_string("email");
+    $string->location    = get_string("location");
+    $string->lastaccess  = get_string("lastaccess");
+    $string->activity    = get_string("activity");
+    $string->unenrol     = get_string("unenrol");
+    $string->loginas     = get_string("loginas");
+    $string->fullprofile = get_string("fullprofile");
 
     if ( $teachers = get_course_teachers($course->id)) {
         echo "<H2 align=center>".$course->teacher."s</H2>";
         foreach ($teachers as $teacher) {
-            print_user($teacher, $course);
+            print_user($teacher, $course, $string);
         }
     }
 
     if ($students = get_course_students($course->id)) {
         echo "<H2 align=center>".$course->student."s</H2>";
         foreach ($students as $student) {
-            print_user($student, $course);
+            print_user($student, $course, $string);
         }
     } 
 
     print_footer($course);
 
-/// FUNCTIONS //////////////////
-
-function print_user($user, $course) {
-
-    global $USER, $COUNTRIES;
-    
-    echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
-    echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>";
-    echo "<TD WIDTH=100 BGCOLOR=#FFFFFF VALIGN=top>";
-    echo "<A HREF=\"view.php?id=$user->id&course=$course->id\">";
-    if ($user->picture) {
-        echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"pix.php/$user->id/f1.jpg\">";
-    } else {
-        echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"default/f1.jpg\">";
-    }
-    echo "</A>";
-    echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF VALIGN=top>";
-    echo "<FONT SIZE=-1>";
-    echo "<FONT SIZE=3><B>$user->firstname $user->lastname</B></FONT>";
-    echo "<P>";
-    echo get_string("email").": <A HREF=\"mailto:$user->email\">$user->email</A><BR>";
-    echo get_string("location").": $user->city, ".$COUNTRIES["$user->country"]."<BR>";
-    echo get_string("lastaccess").": ".userdate($user->lastaccess);
-    echo "&nbsp (".format_time(time() - $user->lastaccess).")";
-    echo "</TD><TD VALIGN=bottom BGCOLOR=#FFFFFF NOWRAP>";
-
-    echo "<FONT SIZE=1>";
-    if (isteacher($course->id)) {
-        $timemidnight = usergetmidnight(time());
-        echo "<A HREF=\"../course/user.php?id=$course->id&user=$user->id\">".get_string("activity")."</A><BR>";
-        echo "<A HREF=\"../course/unenrol.php?id=$course->id&user=$user->id\">".get_string("unenrol")."</A><BR>";
-        if (isstudent($course->id, $user->id)) {
-            echo "<A HREF=\"../course/loginas.php?id=$course->id&user=$user->id\">".get_string("loginas")."</A><BR>";
-        }
-    } 
-    echo "<A HREF=\"view.php?id=$user->id&course=$course->id\">".get_string("fullprofile")."...</A>";
-    echo "</FONT>";
-
-    echo "</TD></TR></TABLE></TD></TR></TABLE>";
-}
-
 ?>
index 07eafa7cba0f8cc38b5d0b56bf150c4f2dd10a55..a6efe6a7c1348749e56b931ff12c9a842846a4d4 100644 (file)
@@ -45,5 +45,43 @@ function ImageCopyBicubic ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $
     } 
 }
 
+function print_user($user, $course, $string) {
+
+    global $USER, $COUNTRIES;
+    
+    echo "<TABLE WIDTH=80% ALIGN=CENTER BORDER=0 CELLPADDING=1 CELLSPACING=1><TR><TD BGCOLOR=#888888>";
+    echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR>";
+    echo "<TD WIDTH=100 BGCOLOR=#FFFFFF VALIGN=top>";
+    echo "<A HREF=\"view.php?id=$user->id&course=$course->id\">";
+    if ($user->picture) {
+        echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"pix.php/$user->id/f1.jpg\">";
+    } else {
+        echo "<IMG BORDER=0 ALIGN=left WIDTH=100 SRC=\"default/f1.jpg\">";
+    }
+    echo "</A>";
+    echo "</TD><TD WIDTH=100% BGCOLOR=#FFFFFF VALIGN=top>";
+    echo "<FONT SIZE=-1>";
+    echo "<FONT SIZE=3><B>$user->firstname $user->lastname</B></FONT>";
+    echo "<P>";
+    echo "$string->email: <A HREF=\"mailto:$user->email\">$user->email</A><BR>";
+    echo "$string->location: $user->city, ".$COUNTRIES["$user->country"]."<BR>";
+    echo "$string->lastaccess: ".userdate($user->lastaccess);
+    echo "&nbsp (".format_time(time() - $user->lastaccess).")";
+    echo "</TD><TD VALIGN=bottom BGCOLOR=#FFFFFF NOWRAP>";
+
+    echo "<FONT SIZE=1>";
+    if (isteacher($course->id)) {
+        $timemidnight = usergetmidnight(time());
+        echo "<A HREF=\"../course/user.php?id=$course->id&user=$user->id\">$string->activity</A><BR>";
+        echo "<A HREF=\"../course/unenrol.php?id=$course->id&user=$user->id\">$string->unenrol</A><BR>";
+        if (isstudent($course->id, $user->id)) {
+            echo "<A HREF=\"../course/loginas.php?id=$course->id&user=$user->id\">$string->loginas</A><BR>";
+        }
+    } 
+    echo "<A HREF=\"view.php?id=$user->id&course=$course->id\">$string->fullprofile...</A>";
+    echo "</FONT>";
+
+    echo "</TD></TR></TABLE></TD></TR></TABLE>";
+}
 
 ?>