From b322dd885e403492f818a5110a9a7957a6b304ce Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Sun, 23 Jan 2011 21:59:11 -0500 Subject: Added condition which checks against empty column least for GradesTable Ignore-this: bee0512330d11599d088cc2364ee669b darcs-hash:20110124025911-067c0-10a27efcbc51056bb4ce9ffa14af29b10270c85e.gz --- GradeBook.tcl | 108 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 52 deletions(-) (limited to 'GradeBook.tcl') diff --git a/GradeBook.tcl b/GradeBook.tcl index 916ce47..078db4f 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -187,65 +187,69 @@ proc htmlDBout {db permission_list user {sort_col {}}} { guest { dbg "Guest must not be allowed to set table view port. Aborting. This line is never executed" 0; exit } default { dbg "Default must not be allowed to set table view port. Aborting. This line is never executed." 0; exit } } - # get all allowed columns and rows - set eval_str [concat SELECT $sql_column_str FROM GradesTable $where_statement ORDER BY $sort_col] - set err [catch { - db eval $eval_str v { - if { $show_header } { - set show_header 0 - puts {} - puts "" - foreach col $v(*) { - # detect what column category it is - set category [SelectColValue4User $col _Col_Category_] - puts -nonewline "
$col" - # below list has action and action_label pairs - set action_list {userhidecolumn hide} - switch $col { - FirstName { lappend action_list changefirstname "change first name" } - LastName { lappend action_list changelastname "change last name" } - UserName { lappend action_list changeusername "change user name" } - PasswordHash { } - UserHiddenColums { } - UserHiddenGroups { } - IdNum { } - GroupName { } - SectionNum { } - default { - lappend action_list changegrades "change grades" deletecolumn delete changecolumn "change column" + if { $sql_column_str ne "" } { + # get all allowed columns and rows + set eval_str [concat SELECT $sql_column_str FROM GradesTable $where_statement ORDER BY $sort_col] + set err [catch { + db eval $eval_str v { + if { $show_header } { + set show_header 0 + puts {} + puts "" + foreach col $v(*) { + # detect what column category it is + set category [SelectColValue4User $col _Col_Category_] + puts -nonewline "" + puts "" } - set separator {
} - foreach {act act_label} $action_list { - if { [isActionGranted $act $permission_list $user] } { - puts -nonewline "$separator$act_label" - } + puts "" + puts "" + } else { + puts "" + } + foreach index $v(*) { + if { $index != "*" } { + # detect what column category it is + set category [SelectColValue4User $index _Col_Category_] + set col_value [htmlReplaceEmptyString $v($index)] + puts -nonewline "" } - puts -nonewline "" - puts "" } puts "" - puts "" - } else { - puts "" } - foreach index $v(*) { - if { $index != "*" } { - # detect what column category it is - set category [SelectColValue4User $index _Col_Category_] - set col_value [htmlReplaceEmptyString $v($index)] - puts -nonewline "" - } - } - puts "" - } - } errStat ] - if { $err } { - dbg "we should never be here if $sortCol exist in the table" 1 - dbg $errStat 1 - htmlErrorMsg $errStat + } errStat ] + if { $err } { + dbg "we should never be here if $sortCol exist in the table" 1 + dbg $errStat 1 + htmlErrorMsg $errStat + } + puts "
$col" + # below list has action and action_label pairs + set action_list {userhidecolumn hide} + switch $col { + FirstName { lappend action_list changefirstname "change first name" } + LastName { lappend action_list changelastname "change last name" } + UserName { lappend action_list changeusername "change user name" } + PasswordHash { } + UserHiddenColums { } + UserHiddenGroups { } + IdNum { } + GroupName { } + SectionNum { } + default { + lappend action_list changegrades "change grades" deletecolumn delete changecolumn "change column" + } + } + set separator {
} + foreach {act act_label} $action_list { + if { [isActionGranted $act $permission_list $user] } { + puts -nonewline "$separator$act_label" + } } + puts -nonewline "
$col_value
$col_value
" + } else { + puts {There is no grades yet.} } - puts "
" puts {} } -- cgit v1.2.3