2005-01-24 18:00:03 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
Copyright ( C ) 2005 Sci - Tech Ontario Inc < info @ scitechontario . org >
Copyright ( C ) 2005 James Grant < james @ lightbox . org >
This program 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 , version 2.
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; see the file COPYING . If not , write to
the Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
?>
2004-12-20 16:00:43 +00:00
< ?
require ( " ../common.inc.php " );
2007-11-21 17:04:35 +00:00
require_once ( " ../user.inc.php " );
2006-08-11 18:53:10 +00:00
require_once ( " ../config_editor.inc.php " );
2007-11-19 00:33:38 +00:00
user_auth_required ( 'committee' , 'config' );
2004-12-20 16:00:43 +00:00
2024-11-25 23:06:33 +00:00
$q = $pdo -> prepare ( " SELECT * FROM config WHERE year='-1' " );
$q -> execute ();
while ( $r = $q -> fetch ( PDO :: FETCH_OBJ )) {
$q = $pdo -> prepare ( " INSERT INTO config (var,val,category,type,type_values,ord,description,year) VALUES (
'".$r->var."' ,
'".$r->val."' ,
'".$r->category."' ,
'".$r->type."' ,
'".$r->type_values."' ,
'".$r->ord."' ,
'".$r->description."' ,
2005-11-24 20:12:06 +00:00
'".$config[' FAIRYEAR ']."' ) " );
}
2006-08-11 18:53:10 +00:00
//for the Special category
2024-12-18 16:48:09 +00:00
if ( get_value_from_array ( $_POST , 'action' ) == 'save' ) {
2024-12-17 06:34:35 +00:00
if ( get_value_from_array ( $_POST , 'specialconfig' )) {
2009-10-22 17:03:27 +00:00
foreach ( $_POST [ 'specialconfig' ] as $key => $val ) {
2024-12-11 00:40:23 +00:00
$stmt = $pdo -> prepare ( " UPDATE config SET val=' " . stripslashes ( $val ) . " ' WHERE year='0' AND var=' $key ' " );
$stmt -> execute ();
2004-12-20 16:00:43 +00:00
}
}
2009-09-09 00:26:12 +00:00
message_push ( happy ( i18n ( " Configuration successfully saved " )));
2006-08-11 18:53:10 +00:00
}
2004-12-20 16:00:43 +00:00
2006-08-11 18:53:10 +00:00
//get the category, and if nothing is chosen, default to Global
2024-12-17 06:34:35 +00:00
if ( get_value_from_array ( $_GET , 'category' )) $category = $_GET [ 'category' ];
else if ( get_value_from_array ( $_POST , 'category' )) $category = $_POST [ 'category' ];
2006-08-11 18:53:10 +00:00
else $category = " Global " ;
2004-12-20 16:00:43 +00:00
2009-09-09 00:26:12 +00:00
$action = config_editor_handle_actions ( $category , $config [ 'FAIRYEAR' ], " var " );
if ( $action == 'update' ) {
header ( " Location: variables.php?category= $category " );
exit ;
}
send_header ( " Configuration Variables " ,
array ( 'Committee Main' => 'committee_main.php' ,
'SFIAB Configuration' => 'config/index.php' )
, " configuration_variables "
);
2024-11-25 23:06:33 +00:00
$q = $pdo -> prepare ( " SELECT DISTINCT(category) AS cat FROM config ORDER BY cat " );
$q -> execute ();
2007-12-17 21:57:26 +00:00
echo " \n <table valign= \" top \" cellspacing=0 cellpadding=5 border=0> " ;
2007-12-17 19:31:09 +00:00
2007-12-17 21:57:26 +00:00
echo " <tr><td width= \" 120 \" style= \" border-right: 1px solid black; \" > " ;
echo " <table cellspacing=0 cellpadding=3 border=0> " ;
2007-12-17 22:25:54 +00:00
$trclass = 'odd' ;
2024-11-25 23:06:33 +00:00
while ( $r = $q -> fetch ( PDO :: FETCH_ASSOC )) {
2007-12-17 22:25:54 +00:00
$trclass = ( $trclass == 'odd' ) ? 'even' : 'odd' ;
echo " <tr class= \" $trclass\ " > " ;
2007-12-17 21:57:26 +00:00
echo " <td align= \" right \" > " ;
2024-12-13 06:49:54 +00:00
if ( $r [ 'cat' ] == $category )
echo " <b> " . i18n ( $r [ 'cat' ]) . " </b> " ;
2005-06-06 17:07:35 +00:00
else
2024-12-13 06:49:54 +00:00
echo " <a href= \" " . $_SERVER [ 'PHP_SELF' ] . " ?category= " . urlencode ( $r [ 'cat' ]) . " \" > " . i18n ( $r [ 'cat' ]) . " </a> " ;
2006-08-11 18:53:10 +00:00
echo " </td> " ;
2007-12-17 19:31:09 +00:00
echo " </tr> \n " ;
2004-12-20 16:00:43 +00:00
}
2006-08-11 18:53:10 +00:00
echo " </table> " ;
2007-12-17 19:31:09 +00:00
echo " </td><td> " ;
2004-12-20 16:00:43 +00:00
2009-10-22 17:03:27 +00:00
if ( $category ) {
if ( $category == " Special " ) {
2007-12-17 21:57:26 +00:00
echo " <h3> " . i18n ( " Special Configuration Settings " ) . " </h3> " ;
2006-08-11 18:53:10 +00:00
echo " <form method= \" post \" action= \" variables.php \" > " ;
echo " <input type= \" hidden \" name= \" action \" value= \" save \" > \n " ;
echo " <input type= \" hidden \" name= \" category \" value= \" Special \" > \n " ;
echo " <table cellpadding= \" 3 \" > " ;
2024-12-11 00:40:23 +00:00
$q = $pdo -> prepare ( " SELECT * FROM config WHERE year=0 ORDER BY var " );
$q -> execute ();
2006-08-11 18:53:10 +00:00
echo " <tr><td colspan= \" 2 \" > " ;
echo i18n ( " Warning, modifying values on this configuration variables page could cause your SFIAB to stop working. Only change anything on this page if you really know what you are doing " );
echo " </td></tr> " ;
2024-12-11 00:40:23 +00:00
while ( $r = $q -> fetch ( PDO :: FETCH_OBJ )) {
2009-10-22 17:03:27 +00:00
if ( $r -> var == " FAIRYEAR " || $r -> var == " DBVERSION " || $r -> var == " FISCALYEAR " ) {
2006-08-11 18:53:10 +00:00
echo " <tr><td><b> $r->var </b> - " . i18n ( $r -> description ) . " </td><td> $r->val </td></tr> " ;
}
2009-10-22 17:03:27 +00:00
else {
2006-08-11 18:53:10 +00:00
echo " <tr><td><b> $r->var </b> - " . i18n ( $r -> description ) . " </td><td><input type= \" text \" name= \" specialconfig[ $r->var ] \" value= \" $r->val\ " /></ td ></ tr > " ;
}
}
echo " </table> " ;
echo " <input type= \" submit \" value= \" " . i18n ( " Save Configuration " ) . " \" /> \n " ;
echo " </form> " ;
}
2009-10-22 17:03:27 +00:00
else {
2024-12-18 16:48:09 +00:00
// echo "<h3>".i18n("Configuration settings ftegory']or fair year %1",array($config['FAIRYEAR']),array("fair year"))."</h3>";
2007-12-17 21:57:26 +00:00
echo " <h3> " . i18n ( $category ) . " ( { $config [ 'FAIRYEAR' ] } )</h3> " ;
2004-12-20 16:00:43 +00:00
2006-08-11 18:53:10 +00:00
config_editor ( $category , $config [ 'FAIRYEAR' ], " var " , $_SERVER [ 'PHP_SELF' ]);
}
}
2009-10-22 17:03:27 +00:00
else {
2006-08-11 18:53:10 +00:00
echo i18n ( " Please choose a configuration category " );
}
2004-12-20 16:00:43 +00:00
2007-12-17 19:31:09 +00:00
echo " </td></tr></table> " ;
2004-12-20 16:00:43 +00:00
send_footer ();
?>