diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2010-12-15 20:19:53 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2010-12-15 20:19:53 -0500 |
commit | 37c04b28a6fcc52dbf9ef4c47d426bedb73671b6 (patch) | |
tree | 68fd643e1e0c422e9a8243c393c289d26226e007 /GradeBook.tcl | |
parent | 95fa28c130488e6fd58a9cc27dd9fca47e1c9771 (diff) | |
download | GradeBook-37c04b28a6fcc52dbf9ef4c47d426bedb73671b6.tar.gz GradeBook-37c04b28a6fcc52dbf9ef4c47d426bedb73671b6.zip |
added column action permissions
darcs-hash:20101216011953-067c0-807e291a1e9309f688efd300e96aaec8daf735b3.gz
Diffstat (limited to 'GradeBook.tcl')
-rwxr-xr-x | GradeBook.tcl | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl index 3ba5ab4..05adb75 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -1,6 +1,6 @@ #!/bin/sh # FILE: "/home/evmik/src/my_src/GradeBook/GradeBook.tcl" -# LAST MODIFICATION: "Wed, 15 Dec 2010 17:23:52 -0500 (evmik)" +# LAST MODIFICATION: "Wed, 15 Dec 2010 20:19:00 -0500 (evmik)" # (C) 2010 by Eugeniy Mikhailov, <evgmik@gmail.com> # $Id:$ # vim:set ft=tcl: \ @@ -71,17 +71,16 @@ proc CreateGradesTable {db} { } proc CreateAccessRightsTable {db} { - db eval {CREATE TABLE AccessRightsTable(GroupName text, sort integer, addcolumn integer, deletecolumn integer)} - db eval {INSERT INTO AccessRightsTable VALUES('instructor', 1, 1, 1)} - db eval {INSERT INTO AccessRightsTable VALUES('ta', 1, 1, 1)} - db eval {INSERT INTO AccessRightsTable VALUES('student', 1, 0, 0)} + db eval {CREATE TABLE AccessRightsTable(GroupName text, sort integer, addcolumn integer, deletecolumn integer, renamecolumn integer, editcolumn integer)} + db eval {INSERT INTO AccessRightsTable VALUES('instructor', 1, 1, 1, 1, 1)} + db eval {INSERT INTO AccessRightsTable VALUES('ta', 1, 1, 1, 1, 1)} + db eval {INSERT INTO AccessRightsTable VALUES('student', 1, 0, 0, 0, 0)} # guest should have no rights make sure that 0 is evereywhere - db eval {INSERT INTO AccessRightsTable VALUES('guest', 0, 0, 0)} + db eval {INSERT INTO AccessRightsTable VALUES('guest', 0, 0, 0, 0, 0)} } -proc htmlDBout {db {sort_col {}}} { - #set x [db eval {SELECT * FROM GradesTable ORDER BY a}] - #puts $x +proc htmlDBout {db permission_list {sort_col {}}} { + array set permission $permission_list global script_name set defSortCol LastName @@ -109,10 +108,15 @@ proc htmlDBout {db {sort_col {}}} { puts "<tr>" foreach col $v(*) { puts -nonewline "<th><a href=$script_name?action=sort&sortCol=$col>$col</a>" - set action_list [list edit edit delete delete] + # below list has action and action_label pairs + set action_list [list editcolumn edit deletecolumn delete renamecolumn rename] set separator {<br>} foreach {act act_label} $action_list { - puts -nonewline "$separator<a href=$script_name?action=$act&sortCol=$col>$act_label</a>" + if { [info exist permission($act) ] } { + if { $permission($act) } { + puts -nonewline "$separator<a href=$script_name?action=$act&sortCol=$col>$act_label</a>" + } + } } puts -nonewline "</th>" } @@ -283,11 +287,11 @@ proc htmlStudentGrades { db user } { proc htmlGradesTable {db permission_list sortCol user} { array set permission $permission_list switch $permission(GroupName) { - guest { } - student { htmlStudentGrades db $user} - ta { htmlDBout db $sortCol} - instructor {htmlDBout db $sortCol} - default { } + guest { } + student { htmlStudentGrades db $user} + ta { htmlDBout db $permission_list $sortCol} + instructor { htmlDBout db $permission_list $sortCol} + default { } } } |