aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook_lib.tcl173
1 files changed, 136 insertions, 37 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index f75025b..63eeef1 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -766,49 +766,148 @@ proc AddAccessRightNonWeb { action instructor_right ta_right student_right dropp
}
}
+proc AddDefaultAccessRight { action instructor_right ta_right student_right dropped_student_right guest_right } {
+ global defaultAccessRights
+ if { ![info exist defaultAccessRights] } {
+ set defaultAccessRights {}
+ }
+ # check if such action and its access table exists and remove it
+ # so it will be replaced with a new one
+ if { $action in $defaultAccessRights } {
+ set indx [lsearch -all -exact $defaultAccessRights $action]
+ foreach i $indx {
+ set defaultAccessRights [lreplace $defaultAccessRights $i $i]
+ # we do it one more time to remove the access table for removed action
+ set defaultAccessRights [lreplace $defaultAccessRights $i $i]
+ }
+ }
+ # finally we adding new action with it access table
+ lappend defaultAccessRights $action [list instructor $instructor_right ta $ta_right student $student_right dropped $dropped_student_right guest $guest_right]
+}
+
+proc FillDefaultAccessRights {} {
+ # guest should have no rights make sure that 0 is everywhere except logon
+ # actionname instructor ta student dropped guest
+ AddDefaultAccessRight logon 1 1 1 1 1
+ AddDefaultAccessRight showgrades 1 1 1 1 0
+ AddDefaultAccessRight sort 1 1 0 0 0
+ AddDefaultAccessRight addcolumnrequest 1 1 0 0 0
+ AddDefaultAccessRight addcolumn 1 1 0 0 0
+ AddDefaultAccessRight deletecolumn 1 1 0 0 0
+ AddDefaultAccessRight showcontrols 1 1 1 1 0
+ AddDefaultAccessRight changegrades 1 1 0 0 0
+ AddDefaultAccessRight updategrades 1 1 0 0 0
+ AddDefaultAccessRight edit_grades_categories 1 0 0 0 0
+ AddDefaultAccessRight update_grades_categories 1 0 0 0 0
+ AddDefaultAccessRight changecolumn 1 1 0 0 0
+ AddDefaultAccessRight updatecolumn 1 1 0 0 0
+ AddDefaultAccessRight logoff 1 1 1 1 0
+ AddDefaultAccessRight changefirstname 1 0 0 0 0
+ AddDefaultAccessRight changelastname 1 0 0 0 0
+ AddDefaultAccessRight changeusername 1 0 0 0 0
+ AddDefaultAccessRight userhidecolumn 1 1 1 1 0
+ AddDefaultAccessRight userunhidecolumn 1 1 1 1 0
+ AddDefaultAccessRight userhidegroup 1 0 0 0 0
+ AddDefaultAccessRight userunhidegroup 1 0 0 0 0
+ AddDefaultAccessRight userhidegradecategory 1 0 0 0 0
+ AddDefaultAccessRight userunhidegradecategory 1 0 0 0 0
+ AddDefaultAccessRight editcourseinfo 1 0 0 0 0
+ AddDefaultAccessRight updatecourseinfo 1 0 0 0 0
+ AddDefaultAccessRight editnewuserinfo 1 0 0 0 0
+ AddDefaultAccessRight addnewuserinfo 1 0 0 0 0
+ AddDefaultAccessRight choosenewpassword 1 1 1 1 0
+ AddDefaultAccessRight setnewpassword 1 1 1 1 0
+ AddDefaultAccessRight changegroupname 1 0 0 0 0
+ AddDefaultAccessRight setgroupname 1 0 0 0 0
+ AddDefaultAccessRight hidecolfromstudents 1 1 0 0 0
+ AddDefaultAccessRight unhidecolfromstudents 1 1 0 0 0
+ AddDefaultAccessRight resetforgottenpassword 0 0 0 0 1
+ AddDefaultAccessRight update_grades_stats 1 0 0 0 0
+}
+
+proc getDefaultPermission { action group } {
+ global defaultAccessRights
+ if { ![info exist defaultAccessRights] } {
+ FillDefaultAccessRights
+ }
+ if { $action ni $defaultAccessRights } {
+ # unknown action is always forbidden
+ return 0
+ }
+
+ # find permissions for action
+ set indx [lsearch -all -exact $defaultAccessRights $action]
+ # increment index since permissions follows action element
+ incr indx
+ set permissions [lindex $defaultAccessRights $indx]
+
+ if { $group ni $permissions } {
+ # unknown groups have no rights
+ return 0
+ }
+
+ # find permission for the group
+ set indx [lsearch -all -exact $permissions $group]
+ # increment index since permission follows group element
+ incr indx
+ return [lindex $permissions $indx]
+}
+
+proc AddDefaultAccessRightToTableForActionNonWeb { action } {
+ global defaultAccessRights
+ if { ![info exist defaultAccessRights] } {
+ FillDefaultAccessRights
+ }
+ set instructor_right [getDefaultPermission $action instructor]
+ set ta_right [getDefaultPermission $action ta]
+ set student_right [getDefaultPermission $action student]
+ set dropped_student_right [getDefaultPermission $action dropped]
+ set guest_right [getDefaultPermission $action guest]
+ AddAccessRightNonWeb $action $instructor_right $ta_right $student_right $dropped_student_right $guest_right
+}
+
proc CreateAccessRightsTable {db} {
set err [catch {db eval {CREATE TABLE AccessRightsTable(actionname text, instructor integer, ta integer, student integer, dropped integer, guest integer)} } errStat]
if { $err } {
htmlErrorMsg $errStat
dbg "the following error happen: $errStat" msg_level_critical
}
- # guest should have no rights make sure that 0 is everywhere except logon
- # actionname instructor ta student dropped guest
- AddAccessRightNonWeb logon 1 1 1 1 1
- AddAccessRightNonWeb showgrades 1 1 1 1 0
- AddAccessRightNonWeb sort 1 1 0 0 0
- AddAccessRightNonWeb addcolumnrequest 1 1 0 0 0
- AddAccessRightNonWeb addcolumn 1 1 0 0 0
- AddAccessRightNonWeb deletecolumn 1 1 0 0 0
- AddAccessRightNonWeb showcontrols 1 1 1 1 0
- AddAccessRightNonWeb changegrades 1 1 0 0 0
- AddAccessRightNonWeb updategrades 1 1 0 0 0
- AddAccessRightNonWeb edit_grades_categories 1 0 0 0 0
- AddAccessRightNonWeb update_grades_categories 1 0 0 0 0
- AddAccessRightNonWeb changecolumn 1 1 0 0 0
- AddAccessRightNonWeb updatecolumn 1 1 0 0 0
- AddAccessRightNonWeb logoff 1 1 1 1 0
- AddAccessRightNonWeb changefirstname 1 0 0 0 0
- AddAccessRightNonWeb changelastname 1 0 0 0 0
- AddAccessRightNonWeb changeusername 1 0 0 0 0
- AddAccessRightNonWeb userhidecolumn 1 1 1 1 0
- AddAccessRightNonWeb userunhidecolumn 1 1 1 1 0
- AddAccessRightNonWeb userhidegroup 1 0 0 0 0
- AddAccessRightNonWeb userunhidegroup 1 0 0 0 0
- AddAccessRightNonWeb userhidegradecategory 1 0 0 0 0
- AddAccessRightNonWeb userunhidegradecategory 1 0 0 0 0
- AddAccessRightNonWeb editcourseinfo 1 0 0 0 0
- AddAccessRightNonWeb updatecourseinfo 1 0 0 0 0
- AddAccessRightNonWeb editnewuserinfo 1 0 0 0 0
- AddAccessRightNonWeb addnewuserinfo 1 0 0 0 0
- AddAccessRightNonWeb choosenewpassword 1 1 1 1 0
- AddAccessRightNonWeb setnewpassword 1 1 1 1 0
- AddAccessRightNonWeb changegroupname 1 0 0 0 0
- AddAccessRightNonWeb setgroupname 1 0 0 0 0
- AddAccessRightNonWeb hidecolfromstudents 1 1 0 0 0
- AddAccessRightNonWeb unhidecolfromstudents 1 1 0 0 0
- AddAccessRightNonWeb resetforgottenpassword 0 0 0 0 1
- AddAccessRightNonWeb update_grades_stats 1 0 0 0 0
+ FillDefaultAccessRights
+ AddDefaultAccessRightToTableForActionNonWeb logon
+ AddDefaultAccessRightToTableForActionNonWeb showgrades
+ AddDefaultAccessRightToTableForActionNonWeb sort
+ AddDefaultAccessRightToTableForActionNonWeb addcolumnrequest
+ AddDefaultAccessRightToTableForActionNonWeb addcolumn
+ AddDefaultAccessRightToTableForActionNonWeb deletecolumn
+ AddDefaultAccessRightToTableForActionNonWeb showcontrols
+ AddDefaultAccessRightToTableForActionNonWeb changegrades
+ AddDefaultAccessRightToTableForActionNonWeb updategrades
+ AddDefaultAccessRightToTableForActionNonWeb edit_grades_categories
+ AddDefaultAccessRightToTableForActionNonWeb update_grades_categories
+ AddDefaultAccessRightToTableForActionNonWeb changecolumn
+ AddDefaultAccessRightToTableForActionNonWeb updatecolumn
+ AddDefaultAccessRightToTableForActionNonWeb logoff
+ AddDefaultAccessRightToTableForActionNonWeb changefirstname
+ AddDefaultAccessRightToTableForActionNonWeb changelastname
+ AddDefaultAccessRightToTableForActionNonWeb changeusername
+ AddDefaultAccessRightToTableForActionNonWeb userhidecolumn
+ AddDefaultAccessRightToTableForActionNonWeb userunhidecolumn
+ AddDefaultAccessRightToTableForActionNonWeb userhidegroup
+ AddDefaultAccessRightToTableForActionNonWeb userunhidegroup
+ AddDefaultAccessRightToTableForActionNonWeb userhidegradecategory
+ AddDefaultAccessRightToTableForActionNonWeb userunhidegradecategory
+ AddDefaultAccessRightToTableForActionNonWeb editcourseinfo
+ AddDefaultAccessRightToTableForActionNonWeb updatecourseinfo
+ AddDefaultAccessRightToTableForActionNonWeb editnewuserinfo
+ AddDefaultAccessRightToTableForActionNonWeb addnewuserinfo
+ AddDefaultAccessRightToTableForActionNonWeb choosenewpassword
+ AddDefaultAccessRightToTableForActionNonWeb setnewpassword
+ AddDefaultAccessRightToTableForActionNonWeb changegroupname
+ AddDefaultAccessRightToTableForActionNonWeb setgroupname
+ AddDefaultAccessRightToTableForActionNonWeb hidecolfromstudents
+ AddDefaultAccessRightToTableForActionNonWeb unhidecolfromstudents
+ AddDefaultAccessRightToTableForActionNonWeb resetforgottenpassword
+ AddDefaultAccessRightToTableForActionNonWeb update_grades_stats
}
proc htmlErrorMsg { msg {loc ""} } {