edu_file_upload_widget db class_id folder_name { default_read " " } { default_write "ta" } { version_notes_p "t" }What it does:
This produces the widget that takes care of the file permissions for classes. It assumes that it is within a table and returns HTML that will fill in two rows of the two column table. An empty string for a role means that public has that permissionDefined in: /web/philip/tcl/education.tcl
Source code:
set role_list [database_to_tcl_list_list $db "select roles.role, pretty_role_plural from user_group_roles roles, edu_role_pretty_role_map map where roles.group_id = $class_id and roles.group_id = map.group_id and lower(roles.role) = lower(map.role) order by priority"] lappend role_list [list "" Public] set folder_id_str $folder_name append folder_id_str "_folder_id" set parent_id [database_to_tcl_string $db "select $folder_id_str from edu_classes where class_id = $class_id"] set version_id [database_to_tcl_string $db "select fs_version_id_seq.nextval from dual"] set html " <tr> <td align=right>URL: </td> <td><input type=input name=url size=40></td> </tr> <tr> <td align=right><EM>or</EM> filename: </td> <td><input type=file name=upload_file size=20> <Br><FONT SIZE=-1>Use the \"Browse...\" button to locate your file, then click \"Open\". </FONT></td> </tr> <tr> <td><Br></td> </tr> " if {[string compare $version_notes_p t] == 0} { append html " <tr> <td valign=top align=right> Version Notes:</td> <td colspan=2><textarea rows=5 cols=50 name=version_description wrap></textarea></td> </tr> " } append html " <tr> <td valign=top align=right> Read Permissions:</td> <td>" set role_to_display_list [list] foreach role $role_list { set role_name [lindex $role 0] lappend role_to_display_list [lindex $role 1] set role_to_display [join $role_to_display_list ", "] if {[string compare [string tolower $default_read] [string tolower $role_name]] == 0 } { append html "<input type=radio name=read_permission value=\"$role_name\" checked> $role_to_display<br>\n" } else { append html "<input type=radio name=read_permission value=\"$role_name\">$role_to_display <br>\n" } } append html " </td> </tr><tr> <td valign=top align=right> Write Permissions:</td> <td> " set role_to_display_list [list] foreach role $role_list { set role_name [lindex $role 0] lappend role_to_display_list [lindex $role 1] set role_to_display [join $role_to_display_list ", "] if {[string compare [string tolower $default_write] [string tolower $role_name]] == 0} { append html "<input type=radio name=write_permission value=\"$role_name\" checked>$role_to_display<br>\n" } else { append html "<input type=radio name=write_permission value=\"$role_name\">$role_to_display<br>\n" } } return " $html</td></tr> [export_form_vars parent_id version_id]"