#!/usr/bin/perl # Copyright 2001-2009 Leslie Richardson # This file is part of Open Admin for Schools. # Open Admin for Schools is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. my %lex = ('Edit Term(s)' => 'Edit Term(s)', 'Main' => 'Main', 'Report Card' => 'Report Card', 'Multi-Track Mode' => 'Multi-Track Mode', 'Cannot open the term file' => 'Cannot open the term file', 'Term(s) Updated' => 'Term(s) Updated', 'Term settings for schools that have different grade levels' => 'Term settings for schools that have different grade levels', 'with different term numbers and dates' => 'with different term numbers and dates', 'Term' => 'Term', 'Term values must contain digits only' => 'Term values must contain digits only', 'Error' => 'Error', ); use CGI; my $self = 'termed.pl'; eval require "../../etc/admin.conf"; if ( $@ ) { print $lex{Error}. ": $@
\n"; die $lex{Error}. ": $@\n"; } my $q = new CGI; print $q->header( -charset, $charset ); my %arr = $q->Vars; # Multi-Track mode: different grades have a different term (K-6,7-12) if ($multiTrack){ # read all multitrack values foreach my $type (sort values %g_termtype){ # %g_termtype def'd in admin.conf $termtype{$type} = 0; # nominally 'e' and 'h' } } # Print start of page print "$doctype\n". $lex{'Edit Term(s)'}. " $chartype\n\n"; print "[ ". $lex{Main}. " |\n"; print "". $lex{'Report Card'}. " ]\n"; print "

". $lex{'Edit Term(s)'}. "

\n"; # Write updates if ( $arr{flag} ) { updateTerms(); } # Open term file and get values, push into @terms open(TERM, "../../etc/term") || die $lex{'Cannot open the term file'}; while (my $trm = ){ # read all lines if more than one... push @terms, $trm; } my $term = $terms[0]; # Build %termfile hash for other values, if present. for (1..$#terms){ if ($terms[$_]){ # if we have a value my ($key,$val) = split /:/,$terms[$_]; $termfile{$key} = $val; } } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($multiTrack){ print "\n"; foreach my $type (keys %termtype){ print "\n"; print "\n"; } } # Print Ending Submit. print "
". $lex{Term}. "
". $lex{'Multi-Track Mode'}; print ":\n"; print $lex{'Term settings for schools that have different grade levels'}; print "
\n"; print $lex{'with different term numbers and dates'}. ".
$type"; print "
"; print "
\n"; #-------------- sub updateTerms { #-------------- delete $arr{flag}; my $term = $arr{term}; delete $arr{term}; # Term is value on first line; # following lines, if any are for multitrack schools and have form of # track:value; open(TERM, ">../../etc/term") || die "Can't open the term file!"; print TERM "$term\n"; # write main term value. foreach my $key (keys %arr ){ #print "K:$key V:$arr{$key}
\n"; # Warn if not a digit. if ($arr{$key} =~ m/^\D+$/){ print "$key - "; print $lex{'Term values must contain digits only'}; print ".
\n"; } print TERM "$key:$arr{$key}\n"; } close TERM; print "". $lex{'Term(s) Updated'}. ".\n"; print "\n"; exit; }