\n"; #Here we have to deal with the special cases of peoples' names containing apostrophes/single quotes my $rawname = param($necbn); my $i1 = index($rawname, " "); #Index of first space (right after 'Edit'); #Index of LAST apostrophe--peoples' names can have apostrophes in them! #I hope no one's name ever contains the string below! my $i2 = index($rawname, "'s note"); my $uname = substr($rawname, $i1 + 1, $i2 - ($i1 + 1)); $uname =~ s/'/''/g; #for those special cases where the user's name has an apostrophe. my $note = param($netan); #print "note is +$note+"; $note =~ s/'/''/g; #print "note is +$note+"; #print " raw: $note
escaped: ", escapeHTML($note), "
";# unescaped: ",unescapeHTML($note), "
"; #set "Tracking Info"--OK to use
because it's only ever stored and displayed my $ti = localtime(time()) . "
$editor"; my $ss = "update $table set Note='$note', Last_Edit = '$ti' where Name = '$uname'"; #"SQL Statement!" $dbh->do($ss) || die $dbh->errstr; #Now let's vacuum the database since a change has been made; could be an addition or could be a deletion. #Keeps the DB file from growing larger than necessary. TTT 9/26/06 #maybe dying here is a little extreme? $dbh->do("VACUUM") || die $dbh->errstr; #have to do this little bit because it makes more sense to return the user to the section view rather #than the main view so they can view their handiwork $ss = "select Section from wbmain where Name = '$uname'"; my $href = $dbh->selectall_hashref($ss, 'Section') || die $dbh->errstr; #(that's going to be a hash with one key) my @sec = keys(%$href); #print Dumper($href); #print "select statement was $ss."; #print 'you just updated the note for $uname to read:'; #print '@@@',fixtextforbrowser(param($netan)),'@@@.'; #print "The SQL statement used was:"; #print "@@@",fixtextforbrowser($ss),"@@@."; #shortcut to get us back to section page (not main page) #The name could well stop at the apostrophe but this is OK. #Also, we didn't uppercase the section mnemonic because it gets lowercased later. #This is a dummy param to get us back to the section view #it's used before reload to no need for a hidden field to make it persist past the next submit/reload param(-name => $sbn, -value => "View $sec[0]'s whiteboard"); }## end if (param($necbn)) if (!param($ebn) && !param($sbn)) { #Default main page with just the general notes for each section; general note for MA (program direction) section #is main note for all of MA Division #Create some space between the masthead and the table print br(), p(); my $dgroup = $groups[0]; my $aref = $dbh->selectall_arrayref( "select * from $table where Name like '%General' order by length(Section), Section, Name") || die $dbh->errstr; #commented table options -width => '85%', print start_table({-cellpadding => 1, -cellspacing => 1, -border => 2, -frame => 'box'}); my $headref = $dbh->selectall_arrayref("PRAGMA table_info($table)") || die $dbh->errstr; my @header; foreach my $col (@{$headref}) { push @header, $col->[1]; } push @header, "Section whiteboard"; print th(\@header); foreach my $user (@$aref) { #we do this so if people type or whatever in the note it doesn't mess things up #AND to properly display line breaks in the note $user->[3] = fixtextforbrowser($user->[3]); #The default page is just a listing of sections so we're "pushing" submit buttons for viewing each of the sections $user->[ scalar(@$user) ] = submit($sbn, "View $user->[1]'s whiteboard"); print Tr({-align => 'center',-valign => 'top'}, td($user)); } print end_table(); } ## end if (!param($ebn) && !param($sbn)) #Section view is probably more common than editing someone's note so it comes next in the order elsif (param($sbn)) { #user wants to view a specific section web page, #or just edited a person's Note, #or just canceled out of editing a person's note #and is back to page for that person's section my $rawsec = param($sbn); #the "Raw" section name my $i1 = index($rawsec, " "); #Index of first space (right after Edit); my $i2 = index($rawsec, "'"); #Index of first (and only) apostrophe my $sec = lc(substr($rawsec, $i1 + 1, $i2 - ($i1 + 1))); #Could well be coming in upper case print h1("$sec section whiteboard"); #Another button to get web user back to main page (more easily seen when notes make table go past bottom of screen) print h6(submit(-name => "dummy", -value => "Back to MA Division whiteboard")); my $info2 = $dbh->selectall_arrayref("PRAGMA table_info($table)") || die $dbh->errstr; my @cols; foreach my $colref (@$info2) { #this little conditional eliminates the Section column from the select statement and thus the table ($colref->[1] ne 'Section') && push @cols, $colref->[1]; } my @header = @cols; #Now construc my $ss = 'select ' . join(",", @cols) . " from $table where Section = '$sec' order by length(UserID)"; #print $ss; my $aref = $dbh->selectall_arrayref($ss) || die $dbh->errstr; #my @header = &getcols; #this is the "big if" here if ($groups =~ /(^|\s+)$sec($|\s+)/) { push @header, "Edit"; } print start_table({-cellpadding => 1, -cellspacing => 1, -border => 2, -frame => 'box'}); print "
/g;#yeah? #Now the default page is just a listing of sections so we're not pushing submit buttons, but links #this is the "big if" here if ($groups =~ /(^|\s+)$sec($|\s+)/) { #this used to be "Edit $user->[0]'s note" for user name but changing to m1 id as per comment at top TTT 9/25/06 $user->[ scalar(@$user) ] = submit(-name => $ebn, -value => "Edit $user->[1]'s note", -align => 'center'); #{-align=>'center'}, } print Tr({-align => 'center',-valign => 'top'}, td($user)); } ## end foreach my $user (@{$aref}) print end_table(); print h1(submit(-name => "dummy", -value => "Back to MA Division whiteboard")); } ## end elsif (param($sbn)) [ if (!param($ebn) && !param($sbn)) elsif (param($ebn)) { #Someone wants to edit someone's note. #no table so no header here #Changing this to sniff the UserID out of the $ my $rawuid = param($ebn); my $i1 = index($rawuid, " "); #Index of first space (right after Edit); #Index of LAST apostrophe--oops, peoples' names can have apostrophes in them! #I hope no one's name ever contains the string below! #Now it doesn't matter since we're going by m1 id, which never has apostrophes, but it doesn't hurt #(much) TTT 9/25/06 my $i2 = index($rawuid, "'s note"); my $uid = substr($rawuid, $i1 + 1, $i2 - ($i1 + 1)); #now we have to do the select before this part to get the Name for the UserID we just got! #Added UserID to the select so I can key off that in the resulting hash; added Section so I can use that #to get back to Section page if Cancel button is hit. TTT 9/25/06 my $st = "select Name, Note, UserID, Section from $table where UserID = '$uid'"; my $href = $dbh->selectall_hashref($st, "UserID") || die $dbh->errstr; my $uname = $href->{$uid}->{Name}; print h4("You are editing the note that will be displayed on the contingency whiteboard for"); print h1($uname); #This gets all but the first and last single-quotes, hard-coded into query below my $inlist = join("','", @groups); #print "Select statement is:$st
"; #print "select statement:
^$st^
returned:"; #print Dumper(%$href); my $note = $href->{$uid}->{Note}; print textarea(-name => $netan, -default => $note, -rows => $netar, -columns => $netac); #just putting in an h1 gives the same spacing as "
", which is more cumbersome. print h1(submit(-name => $necbn, -value => "Commit ${uname}'s note"), submit($cbn,$cbn)); #put in a clear button? submit('Clear','Clear'), TTT 9/26/06 #This is a dummy param to get us back to the section view if the user cancels (works the similarly to the #same line at the end of the conditional block for if the Commit button was pressed) TTT 9/25/06 print hidden(-name => $sbn, -value => "View $href->{$uid}->{Section}'s whiteboard"); #Note that the noteeditbutton param ($netan) will also be passed, but the $necbn commit button won't #So no database changes will be made! } ## end elsif (param($ebn)) [ if (!param($ebn) && !param($sbn)) print end_form(); print ""; #closing the main div with align=center #print Dump(); print end_html();