aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xGradeBook.tcl28
1 files changed, 16 insertions, 12 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl
index 7f396bb..b366adc 100755
--- a/GradeBook.tcl
+++ b/GradeBook.tcl
@@ -71,12 +71,16 @@ proc CreateGradesTable {db} {
}
proc CreateAccessRightsTable {db} {
- db eval {CREATE TABLE AccessRightsTable(GroupName text, showgrades integer, sort integer, addcolumnrequest integer, addcolumn integer, deletecolumn integer, renamecolumn integer, editcolumn integer, showcontrols integer)}
- db eval {INSERT INTO AccessRightsTable VALUES('instructor', 1, 1, 1, 1, 1, 1, 1, 1)}
- db eval {INSERT INTO AccessRightsTable VALUES('ta', 1, 1, 1, 1, 1, 1, 1, 1)}
- db eval {INSERT INTO AccessRightsTable VALUES('student', 1, 0, 0, 0, 0, 0, 0, 0)}
+ db eval {CREATE TABLE AccessRightsTable(actionname text, instructor integer, ta integer, student integer, guest integer)}
# guest should have no rights make sure that 0 is evereywhere
- db eval {INSERT INTO AccessRightsTable VALUES('guest', 0, 0, 0, 0, 0, 0, 0, 0)}
+ db eval {INSERT INTO AccessRightsTable VALUES('showgrades', 1, 1, 1, 0)}
+ db eval {INSERT INTO AccessRightsTable VALUES('sort', 1, 1, 0, 0)}
+ db eval {INSERT INTO AccessRightsTable VALUES('addcolumnrequest', 1, 1, 0, 0)}
+ db eval {INSERT INTO AccessRightsTable VALUES('addcolumn', 1, 1, 0, 0)}
+ db eval {INSERT INTO AccessRightsTable VALUES('deletecolumn', 1, 1, 0, 0)}
+ db eval {INSERT INTO AccessRightsTable VALUES('renamecolumn', 1, 1, 0, 0)}
+ db eval {INSERT INTO AccessRightsTable VALUES('editcolumn', 1, 1, 0, 0)}
+ db eval {INSERT INTO AccessRightsTable VALUES('showcontrols', 1, 1, 0, 0)}
}
proc htmlDBout {db permission_list {sort_col {}}} {
@@ -293,11 +297,11 @@ proc AccessGroupRights {db user password } {
set group guest
}
dbg "Detected group is $group"
- set eval_str [list SELECT * FROM AccessRightsTable WHERE GroupName='$group']
- db eval $eval_str permissions {}
- array unset permissions {\*}
- dbg "permissions for user $user belonging to the group $group are: [array get permissions]"
- return [array get permissions]
+ set eval_str [list SELECT actionname,$group FROM AccessRightsTable ]
+ set permission_list [list GroupName $group]
+ db eval $eval_str permissions { lappend permission_list $permissions(actionname) $permissions($group) }
+ dbg "permissions for user $user belonging to the group $group are: $permission_list"
+ return $permission_list
}
proc htmlStudentGrades { db user } {
@@ -368,8 +372,8 @@ set timestamp [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]
#CreateAccessRightsTable db
dbg [::ncgi::names] 4
# logon and logoff actions are granted to everyone
-if { $action == "logon" } { LogMeOn; set action none }
-if { $action == "logoff" } { LogMeOff; set action none }
+if { $action == "logon" } { LogMeOn; set action defaultview }
+if { $action == "logoff" } { LogMeOff; set action defaultview }
dbg "===== Connection at $timestamp for user $user ====="
set permission_list [AccessGroupRights db $user $password]