From cec462dc2788366474d5e33c8802cbe85bb0939e Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Fri, 5 Dec 2014 13:30:38 -0500 Subject: More general url for photos, which uses server locally cached files --- GradeBook_lib.tcl | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 904c4b0..0978fcb 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -1159,8 +1159,31 @@ proc htmlFormatTheStatsForGradeRaw { stats_needed sql_column_str hidden_columns return $html_str } +proc getPhotoUrl { IdNum } { + # generate url pointing to a photo of a user with the given IdNum + global GradebookServerConfig + set photo_album_base_url $GradebookServerConfig(photo_album_base_url) + set photo_album_cache $GradebookServerConfig(photo_album_cache) + set photo_file "${IdNum}.jpg" + set cached_photo_file "$photo_album_cache/${photo_file}" + if { ${IdNum} eq "" } { + # useless/invalid IdNum + return "" + } + if { [file exist "$cached_photo_file"] } { + # return link to locally cached file + set url "$cached_photo_file" + } else { + # return link to the main WM photobase + set url "$photo_album_base_url/${photo_file}" + #cachePhoto $url + } + return $url +} + proc htmlFormatColVal { col_value columnname user user_shown permission_list {font_style {}} } { global script_name + global GradebookServerConfig set html_str {} set font_style_strt {} set font_style_end {} @@ -1227,13 +1250,13 @@ proc htmlFormatColVal { col_value columnname user user_shown permission_list {fo } IdNum { set html_str [join [list ${html_str} ""] {} ] - if { $col_value ne "" } { - # add photo of the user with non void IdNum - set url_photo_album "https://bbphotos.wm.edu/idphotos" + set IdNum $col_value + set photo_url [ getPhotoUrl $IdNum ] + if { $photo_url ne "" } { # 90x90 is WM default - set photo_img_width 90 - set photo_img_height 90 - set html_str [join [list ${html_str} ""] {} ] + set photo_img_width $GradebookServerConfig(photo_img_width) + set photo_img_height $GradebookServerConfig(photo_img_height) + set html_str [join [list ${html_str} ""] {} ] } set html_str [join [list ${html_str} "$col_str_value"] {} ] } -- cgit v1.2.3