From 14308b599168b83e9aada6464dce4dcc13eb9a70 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 3 Jun 2010 19:21:27 +0000 Subject: [PATCH] Start of adding 'conferences' and ability to switch between running conferences --- committee_main.php | 29 ++++++----- common.inc.php | 88 +++++++++++++++++++++++++++------- config/index.php | 54 +++++++++++++-------- db/db.code.version.txt | 2 +- db/db.update.172.sql | 7 +++ login.php | 25 +++++----- super/conferences.php | 62 ++++++++++++++++++++++++ super/index.php | 45 ++++++++++++++++++ super/superconfig.php | 103 ++++++++++++++++++++++++++++++++++++++++ theme/classic/sfiab.css | 53 +++++++++++++++++++++ theme/default/sfiab.css | 41 ++++++++++++++++ 11 files changed, 446 insertions(+), 63 deletions(-) create mode 100644 db/db.update.172.sql create mode 100644 super/conferences.php create mode 100644 super/index.php create mode 100644 super/superconfig.php diff --git a/committee_main.php b/committee_main.php index ebfd1d2..4eb2ddc 100644 --- a/committee_main.php +++ b/committee_main.php @@ -35,17 +35,20 @@ echo i18n("Hello %1",array($_SESSION['name'])); echo "
"; echo "
"; - echo ""; - echo " "; - if(committee_auth_has_access('config')) { - echo " "; + //need to know which conference we're managing for these + if(isset($_SESSION['conferenceid'])) { + echo " "; + if(committee_auth_has_access('config')) { + echo " "; + } + if(committee_auth_has_access('admin')) { + echo " "; + echo " "; + } + echo " \n"; } - if(committee_auth_has_access('admin')) { - echo " "; - echo " "; - } - echo " \n"; + //these can exist without knowing which conference echo " \n"; echo " "; echo " "; @@ -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 "
"; - echo "
"; - echo " SFIAB/SOIAB Super Config
"; + if(committee_auth_has_access('super')) { + echo "
"; + echo "
"; + echo " Science In A Box Super Configuration
"; + } send_footer(); diff --git a/common.inc.php b/common.inc.php index 242c584..9d710ef 100644 --- a/common.inc.php +++ b/common.inc.php @@ -37,6 +37,8 @@ define('REQUIREDFIELD','*'); //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 ""; -echo "

".i18n($config['fairname'])."

"; +if(!$_SESSION['conferenceid']) { + echo "

".i18n($config['fairname'])."

"; +} else { + global $conference; + echo "

".i18n($conference['name'])."

"; + +} echo "
"; if(isset($_SESSION['users_type'])) { $types = array('volunteer' => 'Volunteer', 'judge' => 'Judge', @@ -486,6 +510,34 @@ echo "
"; ?>
+"; + if($_SESSION['conferenceid']==0) + $cl="class=\"selected\""; + else + $cl=""; + + echo "
  • ".i18n("Science Fair")."
  • \n"; + while($r=mysql_fetch_object($q)) { + if($_SESSION['conferenceid']==$r->id) + $cl="class=\"selected\""; + else + $cl=""; + echo "
  • id\">$r->name
  • \n"; + } + echo "\n"; + echo "
    "; + } + else { + $_SESSION['conferenceid']=0; + } + ?> + + + + 'committee_main.php') ,"configuration" ); + if($conference['type']=='scienceolympics') { + echo "
    ".theme_icon("configuration")."
    ".i18n("Configure SFIAB")."
    ".theme_icon("configuration")."
    ".i18n("Configuration")."
    ".theme_icon("administration")."
    ".i18n("Administration")."
    ".theme_icon("print/export_reports")."
    ".i18n("My Reports (View/Print/Edit)")."
    ".theme_icon("administration")."
    ".i18n("Administer the Fair")."
    ".theme_icon("print/export_reports")."
    ".i18n("My Reports (View/Print/Edit)")."
    ".theme_icon("edit_profile")."
    ".i18n("Edit My Profile")."
    ".theme_icon("change_password")."
    ".i18n("Change My Password")."
    "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " \n"; + echo " "; + echo "
    ".theme_icon("configuration_variables")."
    ".i18n("Configuration Variables")."
    ".theme_icon("important_dates")."
    ".i18n("Important Dates")."
    ".theme_icon("project_age_categories")."
    ".i18n("Age Categories")."
    \n"; + } + else { + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " \n"; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " \n"; + echo "
    ".theme_icon("configuration_variables")."
    ".i18n("Configuration Variables")."
    ".theme_icon("important_dates")."
    ".i18n("Important Dates")."
    ".theme_icon("project_age_categories")."
    ".i18n("Project Age Categories")."
    ".theme_icon("project_divisions")."
    ".i18n("Project Divisions")."
    ".theme_icon("cwsf_project_divisions")."
    ".i18n("CWSF Project Divisions")."
    ".theme_icon("project_sub_divisions")."
    ".i18n("Project Sub-Divisions")."
    ".theme_icon("page_texts")."
    ".i18n("Page Texts")."
    ".theme_icon("exhibitor_signature_page")."
    ".i18n("Exhibitor Signature Page")."
    ".theme_icon("judge_registration_questions")."
    ".i18n("Judge Registration Questions")."
    ".theme_icon("project_safety_questions")."
    ".i18n("Project Safety Questions")."
    ".theme_icon("images")."
    ".i18n("Images (Fair Logo)")."
    \n"; + } - echo ""; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " \n"; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; - echo " \n"; - echo "
    ".theme_icon("configuration_variables")."
    ".i18n("Configuration Variables")."
    ".theme_icon("important_dates")."
    ".i18n("Important Dates")."
    ".theme_icon("project_age_categories")."
    ".i18n("Project Age Categories")."
    ".theme_icon("project_divisions")."
    ".i18n("Project Divisions")."
    ".theme_icon("cwsf_project_divisions")."
    ".i18n("CWSF Project Divisions")."
    ".theme_icon("project_sub_divisions")."
    ".i18n("Project Sub-Divisions")."
    ".theme_icon("page_texts")."
    ".i18n("Page Texts")."
    ".theme_icon("exhibitor_signature_page")."
    ".i18n("Exhibitor Signature Page")."
    ".theme_icon("judge_registration_questions")."
    ".i18n("Judge Registration Questions")."
    ".theme_icon("project_safety_questions")."
    ".i18n("Project Safety Questions")."
    ".theme_icon("images")."
    ".i18n("Images (Fair Logo)")."
    \n"; echo "
    "; echo ""; echo " "; diff --git a/db/db.code.version.txt b/db/db.code.version.txt index b34c321..730a054 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -171 +172 diff --git a/db/db.update.172.sql b/db/db.update.172.sql new file mode 100644 index 0000000..1552e0b --- /dev/null +++ b/db/db.update.172.sql @@ -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; diff --git a/login.php b/login.php index fd8ee43..1fc4891 100644 --- a/login.php +++ b/login.php @@ -22,33 +22,36 @@ ?> \n"; echo "
    \n"; - echo "

    ".i18n("Participant")."

    \n"; + echo "

    ".i18n("Student Participant")."

    \n"; echo "\n"; - echo "

    ".i18n("Judge")."

    \n"; + echo "

    ".i18n("Teacher/School")."

    \n"; echo "\n"; + //we only have judges for science fairs + if($conference['type']=="sciencefair") { + echo "

    ".i18n("Judge")."

    \n"; + echo "\n"; + } + echo "

    ".i18n("Sponsor")."

    \n"; echo "\n"; - echo "

    ".i18n("Teacher/School")."

    \n"; - echo "\n"; - if($config['volunteer_enable'] == 'yes') { echo "

    ".i18n("Volunteer")."

    \n"; echo "
    "; + echo " "; + echo " "; + echo " \n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
    ".theme_icon("conferences")."
    ".i18n("Conferences Setup")."
    \n"; + + send_footer(); +?> diff --git a/super/superconfig.php b/super/superconfig.php new file mode 100644 index 0000000..58a59ad --- /dev/null +++ b/super/superconfig.php @@ -0,0 +1,103 @@ + + Copyright (C) 2005-2008 James Grant + + 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. +*/ +?> + 'committee_main.php') + ,"configuration" + ); + +?> + + + + + + + +
    +Science Fair +
    + + + +
    ONOFF
    + +
    + +
    +Science Olympics +
    + + + +
    ONOFF
    + +
    + +
    + + + + diff --git a/theme/classic/sfiab.css b/theme/classic/sfiab.css index 1e1fa04..2d20a44 100644 --- a/theme/classic/sfiab.css +++ b/theme/classic/sfiab.css @@ -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; +} + diff --git a/theme/default/sfiab.css b/theme/default/sfiab.css index 576142b..e4dac2a 100644 --- a/theme/default/sfiab.css +++ b/theme/default/sfiab.css @@ -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; +} + +