From 67599974aa966eadfbcf743701424c2c5dfe7999 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Thu, 16 Dec 2010 23:30:26 -0500 Subject: permission database to more readable form darcs-hash:20101217043026-067c0-46471c4f3ec6aa0cd0c966a749593261bd98772a.gz --- GradeBook.tcl | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'GradeBook.tcl') 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] -- cgit v1.2.3