aboutsummaryrefslogtreecommitdiff
path: root/GradeBook.tcl
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2010-12-16 23:30:26 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2010-12-16 23:30:26 -0500
commit67599974aa966eadfbcf743701424c2c5dfe7999 (patch)
tree9d148ca785e12079e43a61101e1959d56de16372 /GradeBook.tcl
parentb57b80cc8a9e0394a07a4a7becbeb42f2b9ec344 (diff)
downloadGradeBook-67599974aa966eadfbcf743701424c2c5dfe7999.tar.gz
GradeBook-67599974aa966eadfbcf743701424c2c5dfe7999.zip
permission database to more readable form
darcs-hash:20101217043026-067c0-46471c4f3ec6aa0cd0c966a749593261bd98772a.gz
Diffstat (limited to 'GradeBook.tcl')
-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]