one of the documented procedures in this installation of the ACS
im_random_employee_blurb   db
What it does:
Returns a random employee's photograph and a little bio
Defined in: /web/philip/tcl/intranet-defs.tcl

Source code:

    # We need a "distinct" because there can be more than one
    # mapping between a user and a group, one for each role.
    set users_with_photos_list  [database_to_tcl_list $db  "select distinct u.user_id
           from users_active u, user_group_map ugm
          where u.user_id = ugm.user_id
            and ugm.group_id = [im_employee_group_id $db]
            and u.portrait is not null"]

    if { [llength $users_with_photos_list] == 0 } {
	return ""

    # get the lucky user 
    #  Thanks to Oscar Bonilla <> who
    #  pointed out that we were previously ignoring the last user
    #  in the list
    set random_num [randomRange [llength $users_with_photos_list]]
    set portrait_user_id [lindex $users_with_photos_list $random_num]

    # We use rownum<2 in case the user is mapped to more than one office
    set selection [ns_db 0or1row $db  "select u.first_names || ' ' || u.last_name as name,, u.skills, 
                    ug.group_name as office, ug.group_id as office_id
               from im_employees_active u, user_groups ug, user_group_map ugm
              where u.user_id = ugm.user_id(+)
                and ug.group_id = ugm.group_id
                and ug.parent_group_id = [im_office_group_id $db]
                and u.user_id = $portrait_user_id
                and rownum < 2"]

    if { [empty_string_p $selection] } {
	return ""

    # **** this should really be smart and look for the actual thumbnail
    # but it isn't and just has the browser smash it down to a fixed width
    return "
<a href=\"/shared/portrait?user_id=$portrait_user_id\"><img width=125 src=\"/shared/portrait-bits.tcl?user_id=$portrait_user_id\"></a>
Name: <a href=users/view?user_id=$portrait_user_id>$name</a>
<br>Office: <a href=offices/view?group_id=$office_id>$office</a>
[util_decode $bio "" "" "<br>Biography: $bio"]
[util_decode $skills "" "" "<br>Special skills: $skills"]