Start of adding 'conferences' and ability to switch between running conferences

This commit is contained in:
james 2010-06-03 19:21:27 +00:00
parent d779a6ea27
commit 14308b5991
11 changed files with 446 additions and 63 deletions

View File

@ -35,17 +35,20 @@
echo i18n("Hello <b>%1</b>",array($_SESSION['name']));
echo "<br />";
echo "<br />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
if(committee_auth_has_access('config')) {
echo " <td><a href=\"config/index.php\">".theme_icon("configuration")."<br />".i18n("Configure SFIAB")."</a></td>";
//need to know which conference we're managing for these
if(isset($_SESSION['conferenceid'])) {
echo " <tr>";
if(committee_auth_has_access('config')) {
echo " <td><a href=\"config/index.php\">".theme_icon("configuration")."<br />".i18n("Configuration")."</a></td>";
}
if(committee_auth_has_access('admin')) {
echo " <td><a href=\"admin/index.php\">".theme_icon("administration")."<br />".i18n("Administration")."</a></td>";
echo " <td><a href=\"admin/reports.php\">".theme_icon("print/export_reports")."<br />".i18n("My Reports (View/Print/Edit)")."</a></td>";
}
echo " </tr>\n";
}
if(committee_auth_has_access('admin')) {
echo " <td><a href=\"admin/index.php\">".theme_icon("administration")."<br />".i18n("Administer the Fair")."</a></td>";
echo " <td><a href=\"admin/reports.php\">".theme_icon("print/export_reports")."<br />".i18n("My Reports (View/Print/Edit)")."</a></td>";
}
echo " </tr>\n";
//these can exist without knowing which conference
echo " <tr>\n";
echo " <td><a href=\"user_personal.php\">".theme_icon("edit_profile")."<br />".i18n("Edit My Profile")."</a></td>";
echo " <td><a href=\"user_password.php\">".theme_icon("change_password")."<br />".i18n("Change My Password")."</a></td>";
@ -55,9 +58,11 @@
//this is temporary just so i can put it somewhere to be clicked on to demo tomorrow
//it wont be here for good :)
echo "<br />";
echo "<br />";
echo " <a href=\"config/superconfig.php\">SFIAB/SOIAB Super Config</a><br />";
if(committee_auth_has_access('super')) {
echo "<br />";
echo "<br />";
echo " <a href=\"super/index.php\">Science In A Box Super Configuration</a><br />";
}
send_footer();

View File

@ -37,6 +37,8 @@ define('REQUIREDFIELD','<span class="requiredfield">*</span>');
//figure out the directory to prepend to directoroy names, depending on if we are in a subdirectory or not
if(substr(getcwd(),-6)=="/admin")
$prependdir="../";
else if(substr(getcwd(),-6)=="/super")
$prependdir="../";
else if(substr(getcwd(),-7)=="/config")
$prependdir="../";
else if(substr(getcwd(),-3)=="/db")
@ -229,25 +231,19 @@ if(stristr($_SERVER['HTTP_USER_AGENT'],"MSIE"))
else
$config['icon_extension']="png";
//now get the languages, and make sure we have at least one active language
$q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname");
if(mysql_num_rows($q)==0)
{
if(mysql_num_rows($q)==0) {
echo "No active languages defined, defaulting to English";
$config['languages']['en']="English";
}
else
{
while($r=mysql_fetch_object($q))
{
else {
while($r=mysql_fetch_object($q)) {
$config['languages'][$r->lang]=$r->langname;
}
}
//now if no language has been set yet, lets set it to the default language
if(!$_SESSION['lang'])
{
if(!$_SESSION['lang']) {
//first try the default language, if that doesnt work, use "en"
if($config['default_language'])
$_SESSION['lang']=$config['default_language'];
@ -255,21 +251,43 @@ if(!$_SESSION['lang'])
$_SESSION['lang']="en";
}
if(isset($_GET['switchconference'])) {
//make sure its good
$cid=intval($_GET['switchconference']);
// echo "cid=$cid";
if($cid==0) {
//default for old science fair system
$_SESSION['conferenceid']=0;
}
else {
$q=mysql_query("SELECT * FROM conferences WHERE id='$cid' AND status='running'");
if($r=mysql_fetch_object($q)) {
$_SESSION['conferenceid']=$cid;
}
}
}
if($_SESSION['conferenceid']) {
$q=mysql_query("SELECT * FROM conferences WHERE id='".$_SESSION['conferenceid']."'");
$conference=mysql_fetch_assoc($q);
}
else {
$conference['id']=0;
$conference['name']=$config['fairname'];
$conference['type']="sciencefair";
}
//only allow debug to get set if we're using a development version (odd numbered ending)
if(substr($config['version'], -1) % 2 != 0)
if($_GET['debug']) $_SESSION['debug']=$_GET['debug'];
//if the user has switched languages, go ahead and switch the session variable
if($_GET['switchlanguage'])
{
if($_GET['switchlanguage']) {
//first, make sure its a valid language:
if($config['languages'][$_GET['switchlanguage']])
{
if($config['languages'][$_GET['switchlanguage']]) {
$_SESSION['lang']=$_GET['switchlanguage'];
}
else
{
else {
//invalid language, dont do anything
}
}
@ -434,7 +452,13 @@ if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config")
if(file_exists($prependdir."data/logo-100.gif"))
echo "<img align=\"left\" height=\"50\" src=\"".$config['SFIABDIRECTORY']."/data/logo-100.gif\">";
echo "<h1>".i18n($config['fairname'])."</h1>";
if(!$_SESSION['conferenceid']) {
echo "<h1>".i18n($config['fairname'])."</h1>";
} else {
global $conference;
echo "<h1>".i18n($conference['name'])."</h1>";
}
echo "<div align=\"right\" style=\"font-size: 0.75em;\">";
if(isset($_SESSION['users_type'])) {
$types = array('volunteer' => 'Volunteer', 'judge' => 'Judge',
@ -486,6 +510,34 @@ echo "</div>";
?>
<div id="left">
<?
$q=mysql_query("SELECT * FROM conferences WHERE status='running'");
if(mysql_num_rows($q)) {
echo "<ul class=\"conferencenav\">";
if($_SESSION['conferenceid']==0)
$cl="class=\"selected\"";
else
$cl="";
echo "<li $cl><a $cl href=\"".$_SERVER['PHP_SELF']."?switchconference=0\">".i18n("Science Fair")."</a></li>\n";
while($r=mysql_fetch_object($q)) {
if($_SESSION['conferenceid']==$r->id)
$cl="class=\"selected\"";
else
$cl="";
echo "<li $cl><a $cl href=\"".$_SERVER['PHP_SELF']."?switchconference=$r->id\">$r->name</a></li>\n";
}
echo "</ul>\n";
echo "<br />";
}
else {
$_SESSION['conferenceid']=0;
}
?>
<?
if(is_array($nav)) {
$navkeys=array_keys($nav);

View File

@ -26,32 +26,44 @@
require_once("../user.inc.php");
user_auth_required('committee', 'config');
send_header("SFIAB Configuration",
send_header("Configuration",
array('Committee Main' => 'committee_main.php')
,"configuration"
);
if($conference['type']=='scienceolympics') {
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"variables.php\">".theme_icon("configuration_variables")."<br />".i18n("Configuration Variables")."</a></td>";
echo " <td><a href=\"dates.php\">".theme_icon("important_dates")."<br />".i18n("Important Dates")."</a></td>";
echo " <td><a href=\"categories.php\">".theme_icon("project_age_categories")."<br />".i18n("Age Categories")."</a></td>";
echo " <td></td>\n";
echo " </tr>";
echo "</table>\n";
}
else {
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"variables.php\">".theme_icon("configuration_variables")."<br />".i18n("Configuration Variables")."</a></td>";
echo " <td><a href=\"dates.php\">".theme_icon("important_dates")."<br />".i18n("Important Dates")."</a></td>";
echo " <td><a href=\"categories.php\">".theme_icon("project_age_categories")."<br />".i18n("Project Age Categories")."</a></td>";
echo " <td><a href=\"divisions.php\">".theme_icon("project_divisions")."<br />".i18n("Project Divisions")."</a></td>";
echo " </tr>";
echo " <tr>";
echo " <td><a href=\"divisions_cwsf.php\">".theme_icon("cwsf_project_divisions")."<br />".i18n("CWSF Project Divisions")."</a></td>";
echo " <td><a href=\"subdivisions.php\">".theme_icon("project_sub_divisions")."<br />".i18n("Project Sub-Divisions")."</a></td>";
echo " <td><a href=\"pagetexts.php\">".theme_icon("page_texts")."<br />".i18n("Page Texts")."</a></td>";
echo " <td><a href=\"signaturepage.php\">".theme_icon("exhibitor_signature_page")."<br />".i18n("Exhibitor Signature Page")."</a></td>";
echo " </tr>\n";
echo " <tr>";
echo " <td><a href=\"judges_questions.php\">".theme_icon("judge_registration_questions")."<br />".i18n("Judge Registration Questions")."</a></td>";
echo " <td><a href=\"safetyquestions.php\">".theme_icon("project_safety_questions")."<br />".i18n("Project Safety Questions")."</a></td>";
echo " <td><a href=\"images.php\">".theme_icon("images")."<br />".i18n("Images (Fair Logo)")."</a></td>";
echo " <td></td>";
echo " </tr>\n";
echo "</table>\n";
}
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"variables.php\">".theme_icon("configuration_variables")."<br />".i18n("Configuration Variables")."</a></td>";
echo " <td><a href=\"dates.php\">".theme_icon("important_dates")."<br />".i18n("Important Dates")."</a></td>";
echo " <td><a href=\"categories.php\">".theme_icon("project_age_categories")."<br />".i18n("Project Age Categories")."</a></td>";
echo " <td><a href=\"divisions.php\">".theme_icon("project_divisions")."<br />".i18n("Project Divisions")."</a></td>";
echo " </tr>";
echo " <tr>";
echo " <td><a href=\"divisions_cwsf.php\">".theme_icon("cwsf_project_divisions")."<br />".i18n("CWSF Project Divisions")."</a></td>";
echo " <td><a href=\"subdivisions.php\">".theme_icon("project_sub_divisions")."<br />".i18n("Project Sub-Divisions")."</a></td>";
echo " <td><a href=\"pagetexts.php\">".theme_icon("page_texts")."<br />".i18n("Page Texts")."</a></td>";
echo " <td><a href=\"signaturepage.php\">".theme_icon("exhibitor_signature_page")."<br />".i18n("Exhibitor Signature Page")."</a></td>";
echo " </tr>\n";
echo " <tr>";
echo " <td><a href=\"judges_questions.php\">".theme_icon("judge_registration_questions")."<br />".i18n("Judge Registration Questions")."</a></td>";
echo " <td><a href=\"safetyquestions.php\">".theme_icon("project_safety_questions")."<br />".i18n("Project Safety Questions")."</a></td>";
echo " <td><a href=\"images.php\">".theme_icon("images")."<br />".i18n("Images (Fair Logo)")."</a></td>";
echo " <td></td>";
echo " </tr>\n";
echo "</table>\n";
echo "<hr />";
echo "<table class=\"adminconfigtable\">";
echo " <tr>";

View File

@ -1 +1 @@
171
172

7
db/db.update.172.sql Normal file
View File

@ -0,0 +1,7 @@
CREATE TABLE `conferences` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 128 ) NOT NULL ,
`type` ENUM( 'sciencefair', 'scienceolympics' ) NOT NULL ,
`status` ENUM( 'pending', 'running', 'ended' ) NOT NULL
) ENGINE = MYISAM ;
ALTER TABLE `config` ADD `conferences_id` INT NULL DEFAULT NULL;

View File

@ -22,33 +22,36 @@
?>
<?
require_once("common.inc.php");
send_header("Login/Register");
send_header(i18n("Login/Register for the %1",array($conference['name'])),true);
echo i18n("Please choose one of the following:");
echo "<br />\n";
echo "<br />\n";
echo "<h4>".i18n("Participant")."</h4>\n";
echo "<h4>".i18n("Student Participant")."</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"register_participants.php\">".i18n("I am a participant")."</a></li>\n";
echo "<li><a href=\"register_participants.php\">".i18n("I am a student participant")."</a></li>\n";
echo "</ul>\n";
echo "<h4>".i18n("Judge")."</h4>\n";
echo "<h4>".i18n("Teacher/School")."</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"user_login.php?type=judge\">".i18n("I am a judge and I already have an account")."</a></li>\n";
echo "<li><a href=\"user_new.php?type=judge\">".i18n("I am a new judge and would like to register to judge")."</a></li>\n";
echo "<li><a href=\"schoolaccess.php\">".i18n("I am a teacher or science coordinator at a school")."</a></li>\n";
echo "</ul>\n";
//we only have judges for science fairs
if($conference['type']=="sciencefair") {
echo "<h4>".i18n("Judge")."</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"user_login.php?type=judge\">".i18n("I am a judge and I already have an account")."</a></li>\n";
echo "<li><a href=\"user_new.php?type=judge\">".i18n("I am a new judge and would like to register to judge")."</a></li>\n";
echo "</ul>\n";
}
echo "<h4>".i18n("Sponsor")."</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"user_login.php?type=sponsor\">".i18n("I am an existing sponsor")."</a></li>\n";
echo "<li><a href=\"user_new.php?type=sponsor\">".i18n("I would like to become a sponsor")."</a></li>\n";
echo "</ul>\n";
echo "<h4>".i18n("Teacher/School")."</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";
echo "<li><a href=\"schoolaccess.php\">".i18n("I am a teacher or science fair coordinator at a school")."</a></li>\n";
echo "</ul>\n";
if($config['volunteer_enable'] == 'yes') {
echo "<h4>".i18n("Volunteer")."</h4>\n";
echo "<ul style=\"margin-top: 0px;\">";

62
super/conferences.php Normal file
View File

@ -0,0 +1,62 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005-2006 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005-2008 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.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'super');
send_header("Conferences Setup",
array('Committee Main' => 'committee_main.php',
'Science In A Box Super Configuration' => '/super/index.php')
,"configuration"
);
?>
<script type="text/javascript">
$(document).ready(function() {
};
</script>
<div id="conferences">
<?
require("../tableeditor.class.php");
$editor=new TableEditor("conferences",
array(
"name"=>"Conference Name",
"type"=>"Type",
)
);
$editor->setPrimaryKey("id");
$editor->setDefaultSortField("id");
$editor->setRecordType("Conference");
$editor->execute();
?>
</div>
<?
send_footer();
?>

45
super/index.php Normal file
View File

@ -0,0 +1,45 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005-2006 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005-2008 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.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'super');
send_header("Science In A Box Super Configuration",
array('Committee Main' => 'committee_main.php')
,"configuration"
);
echo "<table class=\"adminconfigtable\">";
echo " <tr>";
echo " <td><a href=\"conferences.php\">".theme_icon("conferences")."<br />".i18n("Conferences Setup")."</a></td>";
echo " <td></td>\n";
echo " <td></td>\n";
echo " <td></td>\n";
echo " </tr>";
echo "</table>\n";
send_footer();
?>

103
super/superconfig.php Normal file
View File

@ -0,0 +1,103 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005-2006 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005-2008 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.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'config');
send_header("SFIAB/SOIAB Super Configuration",
array('Committee Main' => 'committee_main.php')
,"configuration"
);
?>
<script type="text/javascript">
var sciencefair=1;
var scienceolympics=1;
function toggleSwitch(s) {
// alert(s+' '+sciencefair+' '+scienceolympics);
if(s=="sciencefair" && sciencefair==1) {
$("#sciencefairon").removeClass('switchon');
$("#sciencefairoff").addClass('switchoff');
sciencefair=0;
}
else if(s=="sciencefair" && sciencefair==0) {
$("#sciencefairon").addClass('switchon');
$("#sciencefairoff").removeClass('switchoff');
sciencefair=1;
}
if(s=="scienceolympics" && scienceolympics==1) {
$("#scienceolympicson").removeClass('switchon');
$("#scienceolympicsoff").addClass('switchoff');
scienceolympics=0;
}
else if(s=="scienceolympics" && scienceolympics==0) {
$("#scienceolympicson").addClass('switchon');
$("#scienceolympicsoff").removeClass('switchoff');
scienceolympics=1;
}
}
</script>
<table style="width: 100%;" cellpadding=20>
<tr><td align=center>
<span style="font-size: 2.5em; font-weight: bold;">Science Fair</span>
<br />
<table onclick="return toggleSwitch('sciencefair')" cellpadding=5 style="border-collapse: collapse; border: 2px solid black; margin: 10px; cursor: pointer;">
<tr><td id="sciencefairon" width=80 style="text-align: center; font-size: 1.5em; font-weight: bold;" class="switchon">ON</td>
<td id="sciencefairoff" width=80 style="text-align: center; font-size: 1.5em; font-weight: bold;">OFF</td></tr>
</table>
<br />
<img src="../images/sciencefair-250.jpg">
</td>
<td align=center>
<span style="font-size: 2.5em; font-weight: bold;">Science Olympics</span>
<br />
<table onclick="return toggleSwitch('scienceolympics')" cellpadding=5 style="border-collapse: collapse; border: 2px solid black; margin: 10px; cursor: pointer;">
<tr><td id="scienceolympicson" width=80 style="text-align: center; font-size: 1.5em; font-weight: bold;" class="switchon" >ON</td>
<td id="scienceolympicsoff" width=80 style="text-align: center; font-size: 1.5em; font-weight: bold;">OFF</td></tr>
</table>
<br />
<img src="../images/scienceolympics-250.gif">
</td>
</tr>
</table>
<?
send_footer();
?>

View File

@ -439,6 +439,59 @@ div.ui-tabs ul.ui-tabs-nav {
color: #c0c0c0;
}
.judging_score {
text-align: right;
}
.switchon {
background-color: green;
color: white;
}
.switchoff {
background-color: red;
color: white;
}
ul.conferencenav {
list-style : none;
margin : 0;
padding : 0;
background-color : #d6d6d6;
width: 165px;
}
ul.conferencenav li {
display : block;
border-top : 1px solid #a5b5c6;
}
ul.conferencenav li a {
display : block;
margin : 0;
padding : 6px;
background-color : #5C6F90;
font : bold 0.9em/1.5em Arial, sans-serif;
color : #fff;
text-decoration : none;
}
ul.conferencenav li a.selected {
display : block;
margin : 0;
padding : 6px;
background-color : #1F6DFF;
font : bold 0.9em/1.5em Arial, sans-serif;
color : #fff;
text-decoration : none;
}
ul.conferencenav li a:hover {
background-color : #63616b;
color : #eee;
text-decoration: none;
}

View File

@ -452,3 +452,44 @@ div.ui-tabs ul.ui-tabs-nav {
background-color: red;
color: white;
}
ul.conferencenav {
list-style : none;
margin : 0;
padding : 0;
background-color : #d6d6d6;
width: 165px;
}
ul.conferencenav li {
display : block;
border-top : 1px solid #a5b5c6;
}
ul.conferencenav li a {
display : block;
margin : 0;
padding : 6px;
background-color : #5C6F90;
font : bold 0.9em/1.5em Arial, sans-serif;
color : #fff;
text-decoration : none;
}
ul.conferencenav li a.selected {
display : block;
margin : 0;
padding : 6px;
background-color : #1F6DFF;
font : bold 0.9em/1.5em Arial, sans-serif;
color : #fff;
text-decoration : none;
}
ul.conferencenav li a:hover {
background-color : #63616b;
color : #eee;
text-decoration: none;
}