Permalink
Browse files

Performance enhancement for user listing (caching of language strings)

  • Loading branch information...
1 parent 1ebede3 commit cd052f8ccc3917c6571b1752fc0a22fb9100ba31 martin committed Aug 6, 2002
Showing with 47 additions and 44 deletions.
  1. +9 −44 user/index.php
  2. +38 −0 user/lib.php
View
@@ -25,63 +25,28 @@
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>";
-}
-
?>
View
@@ -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>";
+}
?>

0 comments on commit cd052f8

Please sign in to comment.