From 2f5bd0976a27eaa6c8b4bff78449beb26373677a Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Wed, 2 Feb 2011 12:56:25 -0500 Subject: added code to change user group category Ignore-this: b5eb6cb83de39ab8f8071abee043e0b4 darcs-hash:20110202175625-067c0-8f4d44c8e4afb97f426b3d44c6b102f9a63d9dd3.gz --- GradeBook_lib.tcl | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) (limited to 'GradeBook_lib.tcl') diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 509f8b8..26ff60a 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -4,7 +4,7 @@ exec tclsh "$0" "$@" # internal version of this code -set VERSION 1.0 +set VERSION 1.1 # ########################## procs begin ################################# proc dbg {msg {level 1}} { @@ -139,6 +139,8 @@ proc CreateAccessRightsTable {db} { AddAccessRightNonWeb addnewuserinfo 1 0 0 0 AddAccessRightNonWeb choosenewpassword 1 1 1 0 AddAccessRightNonWeb setnewpassword 1 1 1 0 + AddAccessRightNonWeb changegroupname 1 0 0 0 + AddAccessRightNonWeb setgroupname 1 0 0 0 AddAccessRightNonWeb resetforgottenpassword 0 0 0 1 } @@ -261,12 +263,28 @@ proc htmlDBout {db permission_list user {sort_col {}}} { } else { puts "" } + + if { [info exist v(UserName)] } { + set user_shown [htmlReplaceEmptyString $v(UserName)] + } else { + set user_shown "_UNSET_" + } foreach index $v(*) { if { $index != "*" } { # detect what column category it is set category [SelectColValue4User $index _Col_Category_] set col_value [htmlReplaceEmptyString $v($index)] - puts -nonewline "$col_value" + switch $index { + GroupName { + if { [isActionGranted changegroupname $permission_list $user] && ($user_shown ne "_UNSET_") } { + set action_html_code "$separatorChange" + } else { + set action_html_code {} + } + puts -nonewline "$col_value $action_html_code" + } + default {puts -nonewline "$col_value"} + } } } puts "" @@ -508,6 +526,9 @@ proc ChoseAction {action permission_list user} { setnewpassword { SetNewPassword db $permission_list $user htmlDefaultView $permission_list $user } resetforgottenpassword { ResetForgottenPassword $permission_list $user } + changegroupname { ChangeGroupName $permission_list $user } + setgroupname { SetGroupName $permission_list $user + htmlDefaultView $permission_list $user } defaultview { htmlDefaultView $permission_list $user } default { htmlErrorMsg "requested action $action is granted but not implemented yet" } } @@ -517,6 +538,62 @@ proc ChoseAction {action permission_list user} { } } +proc ChangeGroupName {permission_list user } { + global script_name + set modified_user [::ncgi::value user2modify {}] + + set current_group_name [SelectColValue4User GroupName $modified_user] + set FirstName [SelectColValue4User FirstName $modified_user] + set LastName [SelectColValue4User LastName $modified_user] + puts "
" + puts "New group name for $FirstName $LastName $modified_user" + puts "
" + puts {GroupName:
} + puts {} + puts "" + puts {} + puts {} + puts {
} + puts "
" +} + +proc SetGroupName { permission_list user } { + set subaction [::ncgi::value subaction {}] + set modified_user [::ncgi::value user2modify {}] + set new_group_name [::ncgi::value groupname {}] + + if { $subaction eq "Cancel" } { + return + } + + if { $new_group_name eq "" } { + htmlErrorMsg "Empty groupname are not permitted" + return + } + + if { $subaction eq "Submit" } { + UpdateColValue4UserNameNonWeb GroupName $modified_user $new_group_name + } +} + + proc ChooseNewPassword {db permission_list user } { global script_name @@ -988,7 +1065,7 @@ proc ShowControls { permission_list user } { } } # hide user groups - set user_groups_for_hide [list inforow student ta instructor] + set user_groups_for_hide [list inforow student ta instructor dropped] set currently_hidden_groups [SelectColValue4User UserHiddenGroups $user] # remove already hidden group from offering foreach grp $currently_hidden_groups { -- cgit v1.2.3