diff options
-rwxr-xr-x | GradeBook_lib.tcl | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 89a1190..ddd3e49 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -137,6 +137,8 @@ proc CreateAccessRightsTable {db} { AddAccessRightNonWeb updatecourseinfo 1 0 0 0 AddAccessRightNonWeb editnewuserinfo 1 0 0 0 AddAccessRightNonWeb addnewuserinfo 1 0 0 0 + AddAccessRightNonWeb choosenewpassword 1 1 1 0 + AddAccessRightNonWeb setnewpassword 1 1 1 0 } proc htmlErrorMsg { msg } { @@ -446,6 +448,9 @@ proc ChoseAction {action permission_list user} { editnewuserinfo { EditNewUserInfo db $permission_list $user } addnewuserinfo { AddNewUserInfo db $permission_list $user htmlDefaultView $permission_list $user } + choosenewpassword { ChooseNewPassword db $permission_list $user } + setnewpassword { SetNewPassword db $permission_list $user + htmlDefaultView $permission_list $user } defaultview { htmlDefaultView $permission_list $user } default { htmlErrorMsg "requested action <b>$action</b> is granted but not implemented yet" } } @@ -455,6 +460,40 @@ proc ChoseAction {action permission_list user} { } } +proc ChooseNewPassword {db permission_list user } { + global script_name + + puts "<div class=choosenewpassword>" + puts "<form name=\"input\" action=\"$script_name\" method=\"post\" />" + puts "Please type new password: <input type=\"password\" name=\"newpassword\" ><br>" + puts {<input type="hidden" name="action" value="setnewpassword"/>} + puts {<input type="submit" name="subaction" value="Submit" />} + puts {<input type="submit" name="subaction" value="Cancel" />} + puts {</form>} + puts "</div>" +} + +proc SetNewPassword {db permission_list user } { + global script_name + + set subaction [::ncgi::value subaction {}] + set newpassword [::ncgi::value newpassword {}] + + if { $subaction eq "Cancel" } { + return + } + + if { $newpassword eq "" } { + htmlErrorMsg "Empty passwords are not permitted" + return + } + + if { $subaction eq "Submit" } { + UpdateColValue4UserNameNonWeb PasswordHash $user [::md5::md5 -hex $newpassword] + } +} + + proc AddNewUserInfo {db permission_list user } { set subaction [::ncgi::value subaction {}] set first_name [::ncgi::value first_name {}] @@ -875,7 +914,7 @@ proc ShowControls { permission_list user } { global script_name dbg "outputing contol list" puts "<div class=\"controls\">" - set action_list [ list defaultview "Refresh" addcolumnrequest "Add Column" logoff "Logoff" editcourseinfo "Edit Course Info" editnewuserinfo "Add new user"] + set action_list [ list defaultview "Refresh" addcolumnrequest "Add Column" logoff "Logoff" editcourseinfo "Edit Course Info" editnewuserinfo "Add new user" choosenewpassword "Choose new password"] set separator { } foreach {act act_label} $action_list { if { [isActionGranted $act $permission_list $user] } { |