diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-12-05 13:30:38 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-12-05 13:30:38 -0500 |
commit | cec462dc2788366474d5e33c8802cbe85bb0939e (patch) | |
tree | e73797cfbee37f5679d4929d5935744384f28b55 /GradeBook_lib.tcl | |
parent | 5998264920fc194a2cb6f6e2c22ed872a63d9acd (diff) | |
download | GradeBook-cec462dc2788366474d5e33c8802cbe85bb0939e.tar.gz GradeBook-cec462dc2788366474d5e33c8802cbe85bb0939e.zip |
More general url for photos, which uses server locally cached files
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-x | GradeBook_lib.tcl | 35 |
1 files 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} "<td class=\"$category\">"] {} ] - 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} "<img src='$url_photo_album/$col_str_value.jpg' height='$photo_img_height' width='$photo_img_width'>"] {} ] + set photo_img_width $GradebookServerConfig(photo_img_width) + set photo_img_height $GradebookServerConfig(photo_img_height) + set html_str [join [list ${html_str} "<img src='${photo_url}' height='$photo_img_height' width='$photo_img_width'>"] {} ] } set html_str [join [list ${html_str} "$col_str_value</td>"] {} ] } |