From: martin Date: Tue, 6 Aug 2002 09:21:14 +0000 (+0000) Subject: Performance enhancement for user listing (caching of language strings) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=cd052f8ccc3917c6571b1752fc0a22fb9100ba31;p=moodle.git Performance enhancement for user listing (caching of language strings) --- diff --git a/user/index.php b/user/index.php index eabeed9d13..f1fc62d815 100644 --- a/user/index.php +++ b/user/index.php @@ -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 "

".$course->teacher."s

"; foreach ($teachers as $teacher) { - print_user($teacher, $course); + print_user($teacher, $course, $string); } } if ($students = get_course_students($course->id)) { echo "

".$course->student."s

"; 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 "
"; - echo ""; - echo "
"; - echo "id&course=$course->id\">"; - if ($user->picture) { - echo "id/f1.jpg\">"; - } else { - echo ""; - } - echo ""; - echo ""; - echo ""; - echo "$user->firstname $user->lastname"; - echo "

"; - echo get_string("email").": email\">$user->email
"; - echo get_string("location").": $user->city, ".$COUNTRIES["$user->country"]."
"; - echo get_string("lastaccess").": ".userdate($user->lastaccess); - echo "  (".format_time(time() - $user->lastaccess).")"; - echo "

"; - - echo ""; - if (isteacher($course->id)) { - $timemidnight = usergetmidnight(time()); - echo "id&user=$user->id\">".get_string("activity")."
"; - echo "id&user=$user->id\">".get_string("unenrol")."
"; - if (isstudent($course->id, $user->id)) { - echo "id&user=$user->id\">".get_string("loginas")."
"; - } - } - echo "id&course=$course->id\">".get_string("fullprofile")."..."; - echo "
"; - - echo "
"; -} - ?> diff --git a/user/lib.php b/user/lib.php index 07eafa7cba..a6efe6a7c1 100644 --- a/user/lib.php +++ b/user/lib.php @@ -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 "
"; + echo ""; + echo "
"; + echo "id&course=$course->id\">"; + if ($user->picture) { + echo "id/f1.jpg\">"; + } else { + echo ""; + } + echo ""; + echo ""; + echo ""; + echo "$user->firstname $user->lastname"; + echo "

"; + echo "$string->email: email\">$user->email
"; + echo "$string->location: $user->city, ".$COUNTRIES["$user->country"]."
"; + echo "$string->lastaccess: ".userdate($user->lastaccess); + echo "  (".format_time(time() - $user->lastaccess).")"; + echo "

"; + + echo ""; + if (isteacher($course->id)) { + $timemidnight = usergetmidnight(time()); + echo "id&user=$user->id\">$string->activity
"; + echo "id&user=$user->id\">$string->unenrol
"; + if (isstudent($course->id, $user->id)) { + echo "id&user=$user->id\">$string->loginas
"; + } + } + echo "id&course=$course->id\">$string->fullprofile..."; + echo "
"; + + echo "
"; +} ?>