edu_group_user_role_select_widget db select_name group_id { user_id " " }What it does:
This returns a select box that allows an administrator to select a role for a user.Defined in: /web/philip/tcl/education.tcl
Source code:
if {[empty_string_p $user_id]} { set default "" } else { set default [database_to_tcl_string_or_null $db "select lower(role) from user_group_map where group_id = $group_id and user_id = $user_id"] } set widget_value "<select name=\"$select_name\">\n" if { $default == "" } { append widget_value "<option value=\"\" SELECTED>Choose a Role</option>\n" } set selection [ns_db select $db "select roles.role, pretty_role from user_group_roles roles, edu_role_pretty_role_map map where roles.group_id = $group_id and lower(roles.role) = lower(map.role) and roles.group_id = map.group_id order by sort_key"] set count 0 while {[ns_db getrow $db $selection]} { set_variables_after_query incr count if { [string compare $default [string tolower $role]] == 0 } { append widget_value "<option value=\"$role\" SELECTED>$pretty_role</option>\n" } else { append widget_value "<option value=\"$role\">$pretty_role</option>\n" } } if {$count == 0} { set role_list [database_to_tcl_list $db "select role from user_group_roles where group_id = $group_id"] if {[llength $role_list] == 0} { # we just want to have the list of admin and member set role_list [list administrator member] } foreach role $role_list { if { [string compare $default $role] == 0 } { append widget_value "<option value=\"$role\" SELECTED>[capitalize $role]</option>\n" } else { append widget_value "<option value=\"$role\">[capitalize $role]</option>\n" } } } append widget_value "</select>\n" return $widget_value