forked from science-ation/science-ation
Rewrote the installation script to deal with conferences
Writing UI components to create conferences from within the user interface - still buggy
This commit is contained in:
parent
a3b72f7aa3
commit
00f380483b
@ -220,9 +220,7 @@ function account_add_role($accounts_id, $roles_id, $conferences_id, $password =
|
|||||||
|
|
||||||
// we now have the user id that we need, let's check to see whether or not they
|
// we now have the user id that we need, let's check to see whether or not they
|
||||||
// already have the specified role.
|
// already have the specified role.
|
||||||
if(is_array(mysql_fetch_array(mysql_query(
|
if(mysql_result(mysql_query("SELECT COUNT(*) FROM user_roles WHERE users_id = $users_id AND roles_id = $roles_id"), 0) != 0){
|
||||||
"SELECT * FROM user_roles WHERE users_id = $users_id AND roles_id = $roles_id"
|
|
||||||
)))){
|
|
||||||
// they already have this role. shell_exec("man true");
|
// they already have this role. shell_exec("man true");
|
||||||
return 'ok';
|
return 'ok';
|
||||||
}
|
}
|
||||||
|
@ -193,9 +193,10 @@ if(!$_SESSION['conferences_id']) {
|
|||||||
if($r=mysql_fetch_object($q)) {
|
if($r=mysql_fetch_object($q)) {
|
||||||
$_SESSION['conferences_id']=$r->id;
|
$_SESSION['conferences_id']=$r->id;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
else {
|
else {
|
||||||
echo "No conferences defined!";
|
echo "No conferences defined!";
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchConference($cid) {
|
function switchConference($cid) {
|
||||||
@ -313,6 +314,11 @@ $CWSFDivisions=array(
|
|||||||
9=>"Physical & Mathematical Sciences"
|
9=>"Physical & Mathematical Sciences"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$conference_types = array(
|
||||||
|
'sciencefair' => 'Science Fair',
|
||||||
|
'scienceolympics' => 'Science Olympics'
|
||||||
|
);
|
||||||
|
|
||||||
//take SFIABDIRECTORY off of the current URL
|
//take SFIABDIRECTORY off of the current URL
|
||||||
$pageurl=substr($_SERVER['PHP_SELF'],strlen($config['SFIABDIRECTORY']));
|
$pageurl=substr($_SERVER['PHP_SELF'],strlen($config['SFIABDIRECTORY']));
|
||||||
|
|
||||||
|
@ -255,6 +255,9 @@ if(is_array($_SESSION['roles'])) {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<?
|
<?
|
||||||
|
if($_SESSION['superuser'] == 'yes') {
|
||||||
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/super/\">".i18n("System Setup").'</a></li>';
|
||||||
|
}
|
||||||
if(array_key_exists('users_id', $_SESSION)) {
|
if(array_key_exists('users_id', $_SESSION)) {
|
||||||
/*
|
/*
|
||||||
if(in_array('admin', $_SESSION['roles'])) {
|
if(in_array('admin', $_SESSION['roles'])) {
|
||||||
@ -264,9 +267,6 @@ if(array_key_exists('users_id', $_SESSION)) {
|
|||||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/config/\">".i18n("Configuration").' (old) </a></li>';
|
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/config/\">".i18n("Configuration").' (old) </a></li>';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if($_SESSION['superuser'] == 'yes') {
|
|
||||||
echo "<li><a href=\"{$config['SFIABDIRECTORY']}/super/\">".i18n("System Setup").'</a></li>';
|
|
||||||
}
|
|
||||||
if(in_array('volunteer', $_SESSION['roles'])) {
|
if(in_array('volunteer', $_SESSION['roles'])) {
|
||||||
// echo "<li><a href=\"{$config['SFIABDIRECTORY']}/volunteer_main.php\">".i18n("Volunteer Home").'</a></li>';
|
// echo "<li><a href=\"{$config['SFIABDIRECTORY']}/volunteer_main.php\">".i18n("Volunteer Home").'</a></li>';
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
220
|
221
|
||||||
|
2
db/db.update.221.sql
Normal file
2
db/db.update.221.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE award_types DROP INDEX id;
|
||||||
|
ALTER TABLE `award_types` ADD PRIMARY KEY (`id`, `conferences_id`);
|
@ -62,7 +62,7 @@ mysql_select_db($DBNAME);
|
|||||||
|
|
||||||
echo "Checking for existing SFIAB database... ";
|
echo "Checking for existing SFIAB database... ";
|
||||||
|
|
||||||
$q=@mysql_query("SELECT val FROM config WHERE var='DBVERSION' AND year='0'");
|
$q=@mysql_query("SELECT val FROM config WHERE var='DBVERSION' AND conferences_id='0'");
|
||||||
$r=@mysql_fetch_object($q);
|
$r=@mysql_fetch_object($q);
|
||||||
$dbdbversion=$r->val;
|
$dbdbversion=$r->val;
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ mysql_select_db($DBNAME);
|
|||||||
echo "<b>Done! installed database version $dbcodeversion</b><br />\n";
|
echo "<b>Done! installed database version $dbcodeversion</b><br />\n";
|
||||||
|
|
||||||
//now update the db version in the database
|
//now update the db version in the database
|
||||||
mysql_query("UPDATE config SET val='$dbcodeversion' WHERE var='DBVERSION' AND year='0'");
|
mysql_query("UPDATE config SET val='$dbcodeversion' WHERE var='DBVERSION' AND conferences_id='0'");
|
||||||
|
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
echo "<b>Done!</b><br />";
|
echo "<b>Done!</b><br />";
|
||||||
@ -113,13 +113,13 @@ mysql_select_db($DBNAME);
|
|||||||
echo "<b>Done! installed database version $x</b><br />\n";
|
echo "<b>Done! installed database version $x</b><br />\n";
|
||||||
|
|
||||||
//now update the db version in the database
|
//now update the db version in the database
|
||||||
mysql_query("UPDATE config SET val='$x' WHERE var='DBVERSION' AND year='0'");
|
mysql_query("UPDATE config SET val='$x' WHERE var='DBVERSION' AND conferences_id='0'");
|
||||||
|
|
||||||
echo "<b>Attempting to update database using standard update script to update from $x to $dbcodeversion<br />";
|
echo "<b>Attempting to update database using standard update script to update from $x to $dbcodeversion<br />";
|
||||||
echo "<br />Please scroll to the bottom of this page for the link to the next step of the installation process.<br /></b>";
|
echo "<br />Please scroll to the bottom of this page for the link to the next step of the installation process.<br /></b>";
|
||||||
chdir ("db");
|
chdir ("db");
|
||||||
/* Update the database, but don't update the config variables yet, because
|
/* Update the database, but don't update the config variables yet, because
|
||||||
* We haven't set the FAIRYEAR */
|
* We haven't set the conference id */
|
||||||
$db_update_skip_variables = true;
|
$db_update_skip_variables = true;
|
||||||
include "db_update.php";
|
include "db_update.php";
|
||||||
chdir ("../");
|
chdir ("../");
|
||||||
|
71
install3.php
71
install3.php
@ -46,7 +46,7 @@ mysql_select_db($DBNAME);
|
|||||||
|
|
||||||
echo "Checking for SFIAB database... ";
|
echo "Checking for SFIAB database... ";
|
||||||
|
|
||||||
$q=@mysql_query("SELECT val FROM config WHERE var='DBVERSION' AND year='0'");
|
$q=@mysql_query("SELECT val FROM config WHERE var='DBVERSION' AND conferences_id='0'");
|
||||||
$r=@mysql_fetch_object($q);
|
$r=@mysql_fetch_object($q);
|
||||||
$dbdbversion=$r->val;
|
$dbdbversion=$r->val;
|
||||||
|
|
||||||
@ -57,11 +57,11 @@ if(!$dbdbversion) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//a fresh install should ONLY have DBVERSION defined in the config table. If there are others (FAIRYEAR, SFIABDIRECTORY) then this is NOT fresh
|
//a fresh install should ONLY have DBVERSION defined in the config table. If there are others (SFIABDIRECTORY) then this is NOT fresh
|
||||||
$q=mysql_query("SELECT * FROM config WHERE year='0' AND conferences_id='0' AND ( var='DBVERSION' OR var='FAIRYEAR' OR var='SFIABDIRECTORY') ");
|
$q=mysql_query("SELECT * FROM config WHERE conferences_id='0' AND ( var='DBVERSION' OR var='SFIABDIRECTORY') ");
|
||||||
//we might get an error if the config table does not exist (ie, installer step 2 failed)
|
//we might get an error if the config table does not exist (ie, installer step 2 failed)
|
||||||
if(mysql_error()) {
|
if(mysql_error()) {
|
||||||
//we say all tables, but really only we check for config where year=0;
|
//we say all tables, but really only we check for config where conferences_id=0;
|
||||||
echo "<div class=\"error\">ERROR: No SFIAB tables detected, It seems like step 2 failed. Please go <a href=\"install2.php\">Back to Installation Step 2</a> and try again.</div>";
|
echo "<div class=\"error\">ERROR: No SFIAB tables detected, It seems like step 2 failed. Please go <a href=\"install2.php\">Back to Installation Step 2</a> and try again.</div>";
|
||||||
echo "</body></html>";
|
echo "</body></html>";
|
||||||
exit;
|
exit;
|
||||||
@ -69,7 +69,7 @@ if(mysql_error()) {
|
|||||||
}
|
}
|
||||||
//1 is okay (DBVERSION). More than 1 is bad (already isntalled)
|
//1 is okay (DBVERSION). More than 1 is bad (already isntalled)
|
||||||
if(mysql_num_rows($q)>1) {
|
if(mysql_num_rows($q)>1) {
|
||||||
//we say all tables, but really only we check for config where year=0;
|
//we say all tables, but really only we check for config where conferences_id=0;
|
||||||
echo "<div class=\"error\">ERROR: Detected existing table data, SFIAB Installation Step 3 requires a clean SFIAB database installation.</div>";
|
echo "<div class=\"error\">ERROR: Detected existing table data, SFIAB Installation Step 3 requires a clean SFIAB database installation.</div>";
|
||||||
echo "</body></html>";
|
echo "</body></html>";
|
||||||
exit;
|
exit;
|
||||||
@ -78,10 +78,6 @@ echo "<b>Found!</b><br />";
|
|||||||
|
|
||||||
if($_POST['action']=="save") {
|
if($_POST['action']=="save") {
|
||||||
$err=false;
|
$err=false;
|
||||||
if(!$_POST['fairyear']) {
|
|
||||||
echo "Fair Year is required";
|
|
||||||
$err=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$_POST['email']) {
|
if(!$_POST['email']) {
|
||||||
echo "Superuser email address is required";
|
echo "Superuser email address is required";
|
||||||
@ -98,55 +94,19 @@ if($_POST['action']=="save") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$err) {
|
if(!$err) {
|
||||||
echo "Creating configuration settings... ";
|
|
||||||
mysql_query("INSERT INTO config (var,val,category,ord,year) VALUES ('FAIRYEAR','".$_POST['fairyear']."','Special','0','0')");
|
|
||||||
mysql_query("INSERT INTO config (var,val,category,ord,year) VALUES ('FISCALYEAR','".$_POST['fiscalyear']."','Special','0','0')");
|
|
||||||
mysql_query("INSERT INTO config (var,val,category,ord,year) VALUES ('SFIABDIRECTORY','".$_POST['sfiabdirectory']."','Special','','0')");
|
|
||||||
|
|
||||||
|
echo "Creating configuration settings... ";
|
||||||
|
// mysql_query("INSERT INTO config (var,val,category,ord,conferences_id) VALUES ('FAIRYEAR','".$_POST['fairyear']."','Special','0','0')");
|
||||||
|
mysql_query("INSERT INTO config (var,val,category,ord,conferences_id) VALUES ('FISCALYEAR','".$_POST['fiscalyear']."','Special','0','0')");
|
||||||
|
mysql_query("INSERT INTO config (var,val,category,ord,conferences_id) VALUES ('SFIABDIRECTORY','".$_POST['sfiabdirectory']."','Special','','0')");
|
||||||
|
/*
|
||||||
$year = intval($_POST['fairyear']);
|
$year = intval($_POST['fairyear']);
|
||||||
$config['FAIRYEAR']=$year;
|
$config['FAIRYEAR']=$year;
|
||||||
|
*/
|
||||||
//copy over the config defautls
|
|
||||||
// config_update_variables($year);
|
|
||||||
|
|
||||||
// Update some variables
|
|
||||||
mysql_query("UPDATE config SET
|
|
||||||
val='".mysql_escape_string($_POST['fairname'])."'
|
|
||||||
WHERE var='fairname' AND year='$year'");
|
|
||||||
|
|
||||||
mysql_query("UPDATE config SET
|
|
||||||
val='".mysql_escape_string($_POST['email'])."'
|
|
||||||
WHERE var='fairmanageremail' AND year='$year'");
|
|
||||||
|
|
||||||
//copy over the award_types defautls
|
|
||||||
$q=mysql_query("SELECT * FROM award_types WHERE year='-1'");
|
|
||||||
while($r=mysql_fetch_object($q)) {
|
|
||||||
mysql_query("INSERT INTO award_types (id,type,`order`,year) VALUES ('$r->id','$r->type','$r->order','".$_POST['fairyear']."')");
|
|
||||||
}
|
|
||||||
echo "<b>Done!</b><br />";
|
|
||||||
|
|
||||||
echo "Creating a science fair conference... ";
|
|
||||||
mysql_query("INSERT INTO conferences (`name`,`type`,`status`) VALUES ('".mysql_real_escape_string($_POST['fairname'])."','sciencefair','running')");
|
|
||||||
echo "<b>Done!</b><br />";
|
|
||||||
|
|
||||||
echo "Creating superuser account... ";
|
echo "Creating superuser account... ";
|
||||||
$u = user_create('committee',$_POST['email']);
|
$account = account_create($_POST['email'], $_POST['pass1']);
|
||||||
if($_POST['firstname'] && $_POST['lastname']) {
|
mysql_query("UPDATE accounts SET superuser = 'yes' WHERE id = " . $account['id']);
|
||||||
$u['firstname']=mysql_escape_string($_POST['firstname']);
|
|
||||||
$u['lastname']=mysql_escape_string($_POST['lastname']);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$u['firstname'] = 'Superuser';
|
|
||||||
$u['lastname'] = 'Account';
|
|
||||||
}
|
|
||||||
$u['emailprivate'] = mysql_escape_string($_POST['email']);
|
|
||||||
$u['email'] = mysql_escape_string($_POST['email']);
|
|
||||||
$u['username'] = mysql_escape_string($_POST['email']);
|
|
||||||
$u['password'] = mysql_escape_string($_POST['pass1']);
|
|
||||||
$u['access_admin'] = 'yes';
|
|
||||||
$u['access_config'] = 'yes';
|
|
||||||
$u['access_super'] = 'yes';
|
|
||||||
user_save($u);
|
|
||||||
|
|
||||||
echo "<b>Done!</b><br />";
|
echo "<b>Done!</b><br />";
|
||||||
echo "Installation is now complete! You can now proceed to the following location: <br />";
|
echo "Installation is now complete! You can now proceed to the following location: <br />";
|
||||||
@ -162,9 +122,6 @@ echo "Please enter the following options <br />";
|
|||||||
echo "<br />";
|
echo "<br />";
|
||||||
|
|
||||||
$month=date("m");
|
$month=date("m");
|
||||||
if($month>4) $fairyearsuggest=date("Y")+1;
|
|
||||||
else $fairyearsuggest=date("Y");
|
|
||||||
|
|
||||||
if($month>6) $fiscalyearsuggest=date("Y")+1;
|
if($month>6) $fiscalyearsuggest=date("Y")+1;
|
||||||
else $fiscalyearsuggest=date("Y");
|
else $fiscalyearsuggest=date("Y");
|
||||||
|
|
||||||
@ -174,8 +131,6 @@ echo "<form method=\"post\" action=\"install3.php\">";
|
|||||||
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />";
|
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />";
|
||||||
|
|
||||||
echo "<table>";
|
echo "<table>";
|
||||||
echo "<tr><td>Fair Name</td><td><input size=\"25\" type=\"text\" name=\"fairname\" value=\"\"></td><td>The name of the fair you are installing SFIAB to run</td></tr>";
|
|
||||||
echo "<tr><td>Fair Year</td><td><input size=\"8\" type=\"text\" name=\"fairyear\" value=\"$fairyearsuggest\"></td><td>The year of the fair you are installing SFIAB to run</td></tr>";
|
|
||||||
echo "<tr><td>Fiscal Year</td><td><input size=\"8\" type=\"text\" name=\"fiscalyear\" value=\"$fiscalyearsuggest\"></td><td>The current fiscal year (for fundraising/accounting purposes)</td></tr>";
|
echo "<tr><td>Fiscal Year</td><td><input size=\"8\" type=\"text\" name=\"fiscalyear\" value=\"$fiscalyearsuggest\"></td><td>The current fiscal year (for fundraising/accounting purposes)</td></tr>";
|
||||||
echo "<tr><td>Directory</td><td><input size=\"25\" type=\"text\" name=\"sfiabdirectory\" value=\"$directorysuggest\"></td><td>The directory of this SFIAB installation as seen by the web browser</td></tr>";
|
echo "<tr><td>Directory</td><td><input size=\"25\" type=\"text\" name=\"sfiabdirectory\" value=\"$directorysuggest\"></td><td>The directory of this SFIAB installation as seen by the web browser</td></tr>";
|
||||||
|
|
||||||
|
@ -22,41 +22,818 @@
|
|||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<?
|
<?
|
||||||
require("../common.inc.php");
|
require("../common.inc.php");
|
||||||
require_once("../user.inc.php");
|
require_once("../user.inc.php");
|
||||||
superuser_required();
|
require_once("../config_editor.inc.php");
|
||||||
|
superuser_required();
|
||||||
|
|
||||||
send_header("Conferences Setup",
|
/*
|
||||||
|
Define the steps used in the setup wizard. It's flow is:
|
||||||
|
|
||||||
|
start __
|
||||||
|
|-> selectNameType -> complete
|
||||||
|
|
|
||||||
|
|-> selectConference -> enterName -> complete
|
||||||
|
*/
|
||||||
|
$wizard_steps = array(
|
||||||
|
'start' => array(
|
||||||
|
'title' => i18n('Add a Conference'),
|
||||||
|
'builder' => 'build_start_step',
|
||||||
|
'handler' => 'handle_start_step',
|
||||||
|
'fields' => array(
|
||||||
|
'method'
|
||||||
|
),
|
||||||
|
'actions' => array(
|
||||||
|
'next' => i18n('Next'),
|
||||||
|
'cancel' => i18n('Cancel')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'selectNameType' => array(
|
||||||
|
'title' => i18n('Conference Name and Type'),
|
||||||
|
'builder' => 'build_select_nametype_step',
|
||||||
|
'handler' => 'handle_select_nametype_step',
|
||||||
|
'fields' => array(
|
||||||
|
'name',
|
||||||
|
'type'
|
||||||
|
),
|
||||||
|
'actions' => array(
|
||||||
|
'back' => i18n('Back'),
|
||||||
|
'next' => i18n('Next'),
|
||||||
|
'cancel' => i18n('Cancel')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'selectConference' => array(
|
||||||
|
'title' => i18n('Select a Conference'),
|
||||||
|
'builder' => 'build_select_conference_step',
|
||||||
|
'handler' => 'handle_select_conference_step',
|
||||||
|
'fields' => array(
|
||||||
|
'mastercopy',
|
||||||
|
'endExisting',
|
||||||
|
'rollDates'
|
||||||
|
),
|
||||||
|
'actions' => array(
|
||||||
|
'back' => i18n('Back'),
|
||||||
|
'next' => i18n('Next'),
|
||||||
|
'cancel' => i18n('Cancel')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'enterName' => array(
|
||||||
|
'title' => i18n('Conference Name'),
|
||||||
|
'builder' => 'build_enter_name_step',
|
||||||
|
'handler' => 'handle_enter_name_step',
|
||||||
|
'fields' => array(
|
||||||
|
'name'
|
||||||
|
),
|
||||||
|
'actions' => array(
|
||||||
|
'back' => i18n('Back'),
|
||||||
|
'next' => i18n('Next'),
|
||||||
|
'cancel' => i18n('Cancel')
|
||||||
|
)
|
||||||
|
|
||||||
|
),
|
||||||
|
'complete' => array(
|
||||||
|
'title' => i18n('Confirmation'),
|
||||||
|
'builder' => 'build_complete_step',
|
||||||
|
'handler' => 'handle_complete_step',
|
||||||
|
'fields' => array(),
|
||||||
|
'actions' => array(
|
||||||
|
'back' => i18n('Back'),
|
||||||
|
'ok' => i18n('OK'),
|
||||||
|
'cancel' => i18n('Cancel')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'error' => array(
|
||||||
|
'title' => i18n('Error'),
|
||||||
|
'builder' => null,
|
||||||
|
'handler' => 'wizard_close',
|
||||||
|
'fields' => array(),
|
||||||
|
'actions' => array('close' => i18n('Close'))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// check for a step submitted by the wizard
|
||||||
|
if(array_key_exists('formAction', $_POST)){
|
||||||
|
if(array_key_exists('formStep', $_POST)){
|
||||||
|
$stepName = $_POST['formStep'];
|
||||||
|
$wizard_steps[$stepName]['handler']();
|
||||||
|
}
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for an action by the normal method
|
||||||
|
if(array_key_exists('action', $_GET)){
|
||||||
|
switch($_GET['action']){
|
||||||
|
case 'new': // this is a request to create a new conference
|
||||||
|
$_SESSION['conference_wizard'] = array();
|
||||||
|
wizard_draw_step('start');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
send_header("Conferences Setup",
|
||||||
array('Committee Main' => 'committee_main.php',
|
array('Committee Main' => 'committee_main.php',
|
||||||
'System Setup' => '/super/index.php')
|
'System Setup' => '/super/index.php')
|
||||||
,"configuration"
|
,"configuration"
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
// nothin' yet
|
||||||
|
$('#wizardBackdrop').fadeTo(0, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
function openWizard(){
|
||||||
|
$('#addAnchor').hide();
|
||||||
|
$('#wizardWrapper').css({'display':'block'});
|
||||||
|
$('#wizardBackdrop').css({'display':'block'});
|
||||||
|
$('#wizardBackdrop').fadeTo('slow', 0.8);
|
||||||
|
$('#wizard').load('conferences.php?action=new');
|
||||||
|
$('#wizard').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSubmit(action){
|
||||||
|
var params = {'formAction' : action};
|
||||||
|
var foo = false;
|
||||||
|
for(n in fields){
|
||||||
|
// is it a checked check box?
|
||||||
|
val = $('input:checkbox[name=' + fields[n] + ']:checked').val();
|
||||||
|
if(val == undefined){
|
||||||
|
// is it an unchecked checkbox?
|
||||||
|
val = $('input:checkbox[name=' + fields[n] + ']:unchecked').val();
|
||||||
|
if(val != undefined) val = 'no';
|
||||||
|
}
|
||||||
|
if(val == undefined){
|
||||||
|
// perhaps it's a radio button
|
||||||
|
val = $('input:radio[name=' + fields[n] + ']:checked').val();
|
||||||
|
}
|
||||||
|
if(val == undefined){
|
||||||
|
// other, then?
|
||||||
|
val = $('#' + fields[n]).val();
|
||||||
|
}
|
||||||
|
if(val != undefined){
|
||||||
|
params[fields[n]] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// the relevant parameters have been pulled out of the form, now submit them
|
||||||
|
$.post('conferences.php', params, function(result){
|
||||||
|
$('#wizard').html(result);
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
|
|
||||||
<div id="conferences">
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div id="conferences">
|
||||||
<?
|
<?
|
||||||
|
|
||||||
require("../tableeditor.class.php");
|
require("../tableeditor.class.php");
|
||||||
|
|
||||||
$editor=new TableEditor("conferences",
|
$editor=new TableEditor("conferences",
|
||||||
array(
|
array(
|
||||||
"name"=>"Conference Name",
|
"name"=>"Conference Name",
|
||||||
"type"=>"Type",
|
"type"=>"Type",
|
||||||
|
"status"=>"Status"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$editor->setPrimaryKey("id");
|
$editor->setPrimaryKey("id");
|
||||||
$editor->setDefaultSortField("id");
|
$editor->setDefaultSortField("id");
|
||||||
$editor->setRecordType("Conference");
|
$editor->setRecordType("Conference");
|
||||||
$editor->execute();
|
$editor->execute();
|
||||||
?>
|
?>
|
||||||
|
<br/>
|
||||||
|
<hr/>
|
||||||
|
<a id="addAnchor" href='' onclick="openWizard(); return false;">Add a conference</a>
|
||||||
|
</div>
|
||||||
|
<div id="wizardBackdrop"></div>
|
||||||
|
<div id="wizardWrapper">
|
||||||
|
<div id="wizard" style="position:relative"></div>
|
||||||
|
</div>
|
||||||
|
<?
|
||||||
|
send_footer();
|
||||||
|
|
||||||
</div>
|
/************** Wizard handling functions *************/
|
||||||
<?
|
// draw an individual step in the wizard
|
||||||
send_footer();
|
function wizard_draw_step($step, $message = null){
|
||||||
?>
|
global $wizard_steps;
|
||||||
|
if(array_key_exists($step, $wizard_steps)){
|
||||||
|
// tell the client what fields we expect to have sent back
|
||||||
|
echo "<script type=\"text/javascript\">";
|
||||||
|
if(count($wizard_steps[$step]['fields']) > 0){
|
||||||
|
echo "var fields=['formStep','" . implode("','", $wizard_steps[$step]['fields']) . "'];";
|
||||||
|
}else{
|
||||||
|
echo "var fields=['formStep'];";
|
||||||
|
}
|
||||||
|
echo "</script>";
|
||||||
|
|
||||||
|
// draw the title header
|
||||||
|
echo '<h2>' . $wizard_steps[$step]['title'] . '</h2>';
|
||||||
|
|
||||||
|
if($message != null){
|
||||||
|
// used for error messages (eg. empty field)
|
||||||
|
echo "<div class=\"error\">" . $message . "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw the actual content of this step
|
||||||
|
echo "<div class=\"wizard_content\">";
|
||||||
|
if(function_exists($wizard_steps[$step]['builder'])){
|
||||||
|
$wizard_steps[$step]['builder']();
|
||||||
|
}
|
||||||
|
echo "</div>";
|
||||||
|
|
||||||
|
// add the appropriate buttons at the bottom
|
||||||
|
echo "<div class=\"wizard_buttons\">"; // draw the buttons at the bottom of this step
|
||||||
|
foreach($wizard_steps[$step]['actions'] as $tag => $label){
|
||||||
|
echo "<button name=\"$tag\" onclick=\"handleSubmit('$tag');return false;\">$label</button> ";
|
||||||
|
}
|
||||||
|
echo "</div>";
|
||||||
|
|
||||||
|
echo "<input type=\"hidden\" id=\"formStep\" value=\"$step\"></input>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// close the wizard
|
||||||
|
function wizard_close(){
|
||||||
|
unset($_SESSION['conference_wizard']);
|
||||||
|
echo "
|
||||||
|
<script type=\"text/javascript\">
|
||||||
|
$('#wizardBackdrop').css({'display':'none'}).fadeTo(0, 0);
|
||||||
|
$('#wizardWrapper').css({'display':'none'});
|
||||||
|
$('#wizard').hide().html('');
|
||||||
|
$('#addAnchor').show();
|
||||||
|
</script>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
/************** Functions for drawing and processing individual wizard steps ************/
|
||||||
|
function build_start_step(){
|
||||||
|
echo '<p>' . i18n("This wizard will help you set up a new conference.") . '<p>';
|
||||||
|
// find out if any conferences already exist
|
||||||
|
$tally = mysql_result(mysql_query("SELECT COUNT(*) FROM conferences"), 0);
|
||||||
|
if($tally == 0){
|
||||||
|
// no conferences, so just let them continue
|
||||||
|
echo '<p>' . i18n("Click next to continue") . '</p>';
|
||||||
|
echo '<input type="hidden" id="method" value="create">';
|
||||||
|
}else{
|
||||||
|
$copy_selected = '';
|
||||||
|
$create_selected = 'checked';
|
||||||
|
if(array_key_exists('method', $_SESSION['conference_wizard'])){
|
||||||
|
if($_SESSION['conference_wizard']['method'] == 'copy'){
|
||||||
|
$copy_selected = 'checked';
|
||||||
|
$create_selected = '';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
}
|
||||||
|
echo '<p>' . i18n("What would you like to do?") . '</p>';
|
||||||
|
echo '<input type="radio" name="method" value="create" ' . $create_selected . '>' . i18n('Create a new conference') . '</input><br/>';
|
||||||
|
echo '<input type="radio" name="method" value="copy" ' . $copy_selected . '>' . i18n('Copy an existing conference') . '</input><br/>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_start_step(){
|
||||||
|
if($_POST['formAction'] == 'cancel'){
|
||||||
|
wizard_close();
|
||||||
|
}else{
|
||||||
|
$_SESSION['conference_wizard']['method'] = $_POST['method'];
|
||||||
|
switch($_POST['method']){
|
||||||
|
case 'create':
|
||||||
|
wizard_draw_step('selectNameType');
|
||||||
|
break;
|
||||||
|
case 'copy':
|
||||||
|
wizard_draw_step('selectConference');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wizard_close();
|
||||||
|
$save = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_select_nametype_step(){
|
||||||
|
global $conference_types;
|
||||||
|
echo "<p>" . i18n("Please enter the name and type of this conference.") . "</p>";
|
||||||
|
echo "<table><tr>";
|
||||||
|
echo "<td>" . i18n("Conference Name") . "</td>";
|
||||||
|
$val = '';
|
||||||
|
if(array_key_exists('name', $_SESSION['conference_wizard'])){
|
||||||
|
$val = ' VALUE="' . $_SESSION['conference_wizard']['name'] . '" ';
|
||||||
|
}
|
||||||
|
echo "<td><input type=\"text\" id=\"name\"$val></input></td>";
|
||||||
|
echo "</tr><tr>";
|
||||||
|
echo "<td>" . i18n("Conference Type") . "</td>";
|
||||||
|
echo "<td><select id=\"type\">";
|
||||||
|
if(array_key_exists('type', $_SESSION['conference_wizard'])){
|
||||||
|
$selectedType = $_SESSION['conference_wizard']['type'];
|
||||||
|
}else{
|
||||||
|
$selectedType = 'sciencefair';
|
||||||
|
}
|
||||||
|
foreach($conference_types as $type => $title){
|
||||||
|
if($type == $selectedType) $selected = " SELECTED ";
|
||||||
|
else $selected = "";
|
||||||
|
echo "<option value=\"$type\"$selected>$title</option>";
|
||||||
|
}
|
||||||
|
echo "</select></td>";
|
||||||
|
echo "</tr></table>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_select_nametype_step(){
|
||||||
|
if($_POST['formAction'] == 'cancel'){
|
||||||
|
wizard_close();
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$_SESSION['conference_wizard']['type'] = $_POST['type'];
|
||||||
|
$_SESSION['conference_wizard']['name'] = $_POST['name'];
|
||||||
|
|
||||||
|
if($_POST['formAction'] == 'back'){
|
||||||
|
wizard_draw_step('start');
|
||||||
|
}else{
|
||||||
|
if($_POST['name'] == ''){
|
||||||
|
wizard_draw_step('selectNameType', i18n('A name for the conference is required'));
|
||||||
|
}else{
|
||||||
|
wizard_draw_step('complete');
|
||||||
|
// handle_complete_step();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_select_conference_step(){
|
||||||
|
// get our default/entered values
|
||||||
|
$selectedID = -1;
|
||||||
|
$endchecked = '';
|
||||||
|
$rollchecked = ' checked ';
|
||||||
|
if(array_key_exists('mastercopy', $_SESSION['conference_wizard'])){
|
||||||
|
$selectedID = $_SESSION['conference_wizard']['mastercopy'];
|
||||||
|
if($_SESSION['conference_wizard']['endExisting'] == 'yes'){
|
||||||
|
$endchecked = ' checked ';
|
||||||
|
}
|
||||||
|
if($_SESSION['conference_wizard']['rollDates'] == 'no'){
|
||||||
|
$rollchecked = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<p>" . i18n("Please select the conference that you wish to copy.") . "</p>";
|
||||||
|
echo "<table><tr><td>" . i18n("Conference to Copy:") . "</td><td>";
|
||||||
|
echo "<select id=\"mastercopy\">";
|
||||||
|
$query = mysql_query("SELECT * FROM conferences ORDER BY id DESC");
|
||||||
|
while($row = mysql_fetch_assoc($query)){
|
||||||
|
$id = $row['id'];
|
||||||
|
if($id == $selectedID) $selected = " SELECTED ";
|
||||||
|
else if($selectedID == -1) { $selected = " SELECTED "; $selectedID = -2; } // select the first one
|
||||||
|
else $selected = "";
|
||||||
|
echo "<option $selected value=\"{$row['id']}\">{$row['name']}</option>";
|
||||||
|
}
|
||||||
|
echo "</select>";
|
||||||
|
echo "</td></tr><tr><td>" . i18n("End this conference after copying it:") . "</td><td>";
|
||||||
|
echo "<input type=\"checkbox\" value=\"yes\" name=\"endExisting\" $endchecked ></input>";
|
||||||
|
echo "</td></tr>";
|
||||||
|
|
||||||
|
echo "<tr><td>" . i18n("Increment dates by a year:") . "</td><td>";
|
||||||
|
echo "<input type=\"checkbox\" value=\"yes\" name=\"rollDates\" $rollchecked ></input>";
|
||||||
|
echo "</td></tr>";
|
||||||
|
|
||||||
|
echo "</table>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_select_conference_step(){
|
||||||
|
if($_POST['formAction'] == 'cancel'){
|
||||||
|
wizard_close();
|
||||||
|
}else{
|
||||||
|
$_SESSION['conference_wizard']['mastercopy'] = $_POST['mastercopy'];
|
||||||
|
$_SESSION['conference_wizard']['endExisting'] = $_POST['endExisting'];
|
||||||
|
$_SESSION['conference_wizard']['rollDates'] = $_POST['rollDates'];
|
||||||
|
|
||||||
|
if($_POST['formAction'] == 'back'){
|
||||||
|
wizard_draw_step('start');
|
||||||
|
}else{
|
||||||
|
wizard_draw_step('enterName');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_enter_name_step(){
|
||||||
|
echo "<p>" . i18n("Please enter a name for this conference") . "</p>";
|
||||||
|
echo "<table><tr>";
|
||||||
|
echo "<td>" . i18n("Conference Name") . "</td>";
|
||||||
|
$val = '';
|
||||||
|
if(array_key_exists('name', $_SESSION['conference_wizard'])){
|
||||||
|
// get the value previously answered
|
||||||
|
$val = ' VALUE="' . $_SESSION['conference_wizard']['name'] . '" ';
|
||||||
|
}else if(array_key_exists('mastercopy', $_SESSION['conference_wizard'])){
|
||||||
|
// get the name of the conference we're copying
|
||||||
|
$query = "SELECT name FROM conferences WHERE id = {$_SESSION['conference_wizard']['mastercopy']}";
|
||||||
|
$result = mysql_fetch_assoc(mysql_query($query));
|
||||||
|
$val = ' VALUE="' . $result['name'] . '" ';
|
||||||
|
}
|
||||||
|
echo "<td><input type=\"text\" id=\"name\"$val></input></td>";
|
||||||
|
echo "</tr></table>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_enter_name_step(){
|
||||||
|
if($_POST['formAction'] == 'cancel'){
|
||||||
|
wizard_close();
|
||||||
|
}else{
|
||||||
|
$_SESSION['conference_wizard']['name'] = $_POST['name'];
|
||||||
|
|
||||||
|
if($_POST['formAction'] == 'back'){
|
||||||
|
wizard_draw_step('selectConference');
|
||||||
|
}else{
|
||||||
|
if($_POST['name'] == ''){
|
||||||
|
wizard_draw_step('enterName', i18n('A name for the conference is required'));
|
||||||
|
}else{
|
||||||
|
wizard_draw_step('complete');
|
||||||
|
}
|
||||||
|
// handle_complete_step();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_complete_step(){
|
||||||
|
echo "<p>";
|
||||||
|
echo i18n("All of the required information has been gathered. Click "OK" to complete the process.");
|
||||||
|
echo "</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_complete_step(){
|
||||||
|
// print_r($_SESSION);
|
||||||
|
if($_POST['formAction'] == 'cancel'){
|
||||||
|
wizard_close();
|
||||||
|
}else if($_POST['formAction'] == 'back'){
|
||||||
|
if($_SESSION['conference_wizard']['method'] == 'copy'){
|
||||||
|
wizard_draw_step('enterName');
|
||||||
|
}else{
|
||||||
|
wizard_draw_step('selectNameType');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
switch($_SESSION['conference_wizard']['method']){
|
||||||
|
case 'create':
|
||||||
|
$result = create_conference($_SESSION['conference_wizard']);
|
||||||
|
if(is_numeric($result)){
|
||||||
|
wizard_close();
|
||||||
|
}else{
|
||||||
|
wizard_draw_step('error', $result);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'copy':
|
||||||
|
if(copy_conference($_SESSION['conference_wizard'])){
|
||||||
|
wizard_close();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// returns the id of the created conference if successful, error message otherwise
|
||||||
|
function create_conference($params){
|
||||||
|
$cname = mysql_real_escape_string($params['name']);
|
||||||
|
$ctype = $params['type'];
|
||||||
|
mysql_query("INSERT INTO conferences (oid, name, type, status) VALUES (1, '" . mysql_real_escape_string($cname) . "', '$ctype', 'pending')");
|
||||||
|
$errorMessage = mysql_error();
|
||||||
|
if($errorMessage){
|
||||||
|
return "SQL Error:<br/>$errorMessage";
|
||||||
|
}
|
||||||
|
$conferences_id = mysql_insert_id();
|
||||||
|
|
||||||
|
//copy over the award_types defaults
|
||||||
|
$q=mysql_query("SELECT * FROM award_types WHERE conferences_id='-1'");
|
||||||
|
while($r=mysql_fetch_object($q)) {
|
||||||
|
mysql_query("INSERT INTO award_types (id,type,`order`, conferences_id) VALUES ('$r->id','$r->type','$r->order','".$conferences_id."')");
|
||||||
|
}
|
||||||
|
|
||||||
|
// add this administrator's admin user account for the new conference
|
||||||
|
$u = user_create($_SESSION['accounts_id'], $conferences_id);
|
||||||
|
$q = mysql_query("SELECT id FROM roles WHERE `type` IN('admin', 'config')");
|
||||||
|
while($row = mysql_fetch_assoc($q)){
|
||||||
|
mysql_query("
|
||||||
|
INSERT INTO user_roles (accounts_id, users_id, roles_id, active, complete)
|
||||||
|
VALUES({$_SESSION['accounts_id']}, {$u['id']}, {$row['id']}, 'yes', 'yes')
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
user_add_role($u, 'admin');
|
||||||
|
user_add_role($u, 'config');
|
||||||
|
|
||||||
|
return $conferences_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy users of the specified roles (passed in an array)
|
||||||
|
// return 'ok' on success, error message otherwise
|
||||||
|
function conferences_copy_users($oldConfId, $newConfId, $roles){
|
||||||
|
if(!is_array($roles)) $roles = array($roles);
|
||||||
|
$query = mysql_query("
|
||||||
|
SELECT * FROM users WHERE users.id IN(
|
||||||
|
SELECT DISTINCT(users.id) FROM users
|
||||||
|
JOIN user_roles ON user_roles.users_id = users.id
|
||||||
|
JOIN roles on roles.id = user_roles.roles_id
|
||||||
|
WHERE roles.`type` IN ('" . implode("','", $roles) . "')
|
||||||
|
AND users.conferences_id = $oldConfId
|
||||||
|
)
|
||||||
|
");
|
||||||
|
|
||||||
|
$keys = '';
|
||||||
|
while(mysql_error() == '' && $row = mysql_fetch_assoc($query)){
|
||||||
|
// first we copy the user
|
||||||
|
$oldId = $row['id'];
|
||||||
|
unset($row['id']);
|
||||||
|
if($keys == ''){
|
||||||
|
$keyList = array_keys($row);
|
||||||
|
$keys = "`" . implode("`,`", $keyList) . "`";
|
||||||
|
}
|
||||||
|
$row['conferences_id'] = $newConfId;
|
||||||
|
$values = "'" . implode("','", $row) . "'";
|
||||||
|
// echo("INSERT INTO users ($keys) VALUES ($values)");
|
||||||
|
mysql_query("INSERT INTO users ($keys) VALUES ($values)");
|
||||||
|
$uid = mysql_insert_id();
|
||||||
|
$aid = $row['accounts_id'];
|
||||||
|
// now copy their applicable roles
|
||||||
|
$q2 = mysql_query("
|
||||||
|
SELECT roles_id, active, complete FROM user_roles
|
||||||
|
JOIN roles ON roles.id = user_roles.roles_id
|
||||||
|
WHERE roles.`type` IN('" . implode("','", $roles) . "')
|
||||||
|
");
|
||||||
|
while(mysql_error() == '' && $row2 = mysql_fetch_assoc($q2)){
|
||||||
|
mysql_query("
|
||||||
|
INSERT INTO user_roles(`accounts_id`, `users_id`, `roles_id`, `active`, `complete`)
|
||||||
|
VALUES($aid, $uid, {$row2['roles_id']}, '{$row2['active']}', '{$row2['complete']}')
|
||||||
|
");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mysql_error() != '') return "SQL error :<br/>" . mysql_error();
|
||||||
|
return 'ok';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy a conference - returns true on success, false otherwise. Gives the wizard an error message one occurs
|
||||||
|
function copy_conference($params){
|
||||||
|
/* $params: {
|
||||||
|
mastercopy => id of conf to copy
|
||||||
|
endExisting => end it after copying
|
||||||
|
rollDates => increment the dates by a year
|
||||||
|
name => the new name
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// we'll start by creating the new conference
|
||||||
|
$oldConfId = $params['mastercopy'];
|
||||||
|
$oldConf = mysql_fetch_assoc(mysql_query("SELECT * FROM conferences WHERE id = {$oldConfId}"));
|
||||||
|
|
||||||
|
mysql_query("INSERT INTO conferences (oid, name, type, status) VALUES (1, '" . mysql_real_escape_string($params['name']) . "', '{$oldConf['type']}', 'pending')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error on line #' . (__LINE__ - 1) . ': <br/>' . mysql_error()); return false; }
|
||||||
|
$newConfId = mysql_insert_id();
|
||||||
|
|
||||||
|
// then copy the configuration variables
|
||||||
|
config_update_variables($newConfId, $oldConfId);
|
||||||
|
|
||||||
|
// now the dates
|
||||||
|
if($params['rollDates'] == 'yes'){
|
||||||
|
$q=mysql_query("SELECT DATE_ADD(date,INTERVAL 365 DAY) AS newdate, name, description FROM dates WHERE conferences_id = $oldConfId");
|
||||||
|
}else{
|
||||||
|
$q=mysql_query("SELECT date AS newdate, name, description FROM dates WHERE conferences_id = $oldConfId");
|
||||||
|
}
|
||||||
|
while(mysql_error() == '' && $r = mysql_fetch_object($q))
|
||||||
|
mysql_query("INSERT INTO dates (date,name,description,conferences_id) VALUES (
|
||||||
|
'".mysql_real_escape_string($r->newdate)."',
|
||||||
|
'".mysql_real_escape_string($r->name)."',
|
||||||
|
'".mysql_real_escape_string($r->description)."',
|
||||||
|
'".mysql_real_escape_string($newConfId)."')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// page text
|
||||||
|
$q = mysql_query("SELECT * FROM pagetext WHERE conferences_id = $oldConfId");
|
||||||
|
while(mysql_error() == '' && $r=mysql_fetch_object($q))
|
||||||
|
mysql_query("INSERT INTO pagetext (textname,textdescription,text,lastupdate,conferences_id,lang) VALUES (
|
||||||
|
'".mysql_real_escape_string($r->textname)."',
|
||||||
|
'".mysql_real_escape_string($r->textdescription)."',
|
||||||
|
'".mysql_real_escape_string($r->text)."',
|
||||||
|
'".mysql_real_escape_string($r->lastupdate)."',
|
||||||
|
'".mysql_real_escape_string($newConfId)."',
|
||||||
|
'".mysql_real_escape_string($r->lang)."')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// project categories
|
||||||
|
$q = mysql_query("SELECT * FROM projectcategories WHERE conferences_id = $oldConfId");
|
||||||
|
while(mysql_error() == '' && $r=mysql_fetch_object($q))
|
||||||
|
mysql_query("INSERT INTO projectcategories (id,category,category_shortform,mingrade,maxgrade,conferences_id) VALUES (
|
||||||
|
'".mysql_real_escape_string($r->id)."',
|
||||||
|
'".mysql_real_escape_string($r->category)."',
|
||||||
|
'".mysql_real_escape_string($r->category_shortform)."',
|
||||||
|
'".mysql_real_escape_string($r->mingrade)."',
|
||||||
|
'".mysql_real_escape_string($r->maxgrade)."',
|
||||||
|
'".mysql_real_escape_string($newConfId)."')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// project divisions
|
||||||
|
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id=$oldConfId");
|
||||||
|
while(mysql_error() == '' && $r=mysql_fetch_object($q))
|
||||||
|
mysql_query("INSERT INTO projectdivisions (id,division,division_shortform,cwsfdivisionid,conferences_id) VALUES (
|
||||||
|
'".mysql_real_escape_string($r->id)."',
|
||||||
|
'".mysql_real_escape_string($r->division)."',
|
||||||
|
'".mysql_real_escape_string($r->division_shortform)."',
|
||||||
|
'".mysql_real_escape_string($r->cwsfdivisionid)."',
|
||||||
|
'".mysql_real_escape_string($newConfId)."')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// project subdivisions
|
||||||
|
$q=mysql_query("SELECT * FROM projectsubdivisions WHERE conferences_id=$oldConfId");
|
||||||
|
while(mysql_error() == '' && $r=mysql_fetch_object($q))
|
||||||
|
mysql_query("INSERT INTO projectsubdivisions (id,projectdivisions_id,subdivision,conferences_id) VALUES (
|
||||||
|
'".mysql_real_escape_string($r->id)."',
|
||||||
|
'".mysql_real_escape_string($r->projectsubdivisions_id)."',
|
||||||
|
'".mysql_real_escape_string($r->subdivision)."',
|
||||||
|
'".mysql_real_escape_string($newConfId)."')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// safety questions
|
||||||
|
$q=mysql_query("SELECT * FROM safetyquestions WHERE conferences_id=$oldConfId");
|
||||||
|
while(mysql_error() == '' && $r=mysql_fetch_object($q))
|
||||||
|
mysql_query("INSERT INTO safetyquestions (question,type,required,ord,conferences_id) VALUES (
|
||||||
|
'".mysql_real_escape_string($r->question)."',
|
||||||
|
'".mysql_real_escape_string($r->type)."',
|
||||||
|
'".mysql_real_escape_string($r->required)."',
|
||||||
|
'".mysql_real_escape_string($r->ord)."',
|
||||||
|
'".mysql_real_escape_string($newConfId)."')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// awards
|
||||||
|
$q=mysql_query("SELECT * FROM award_awards WHERE conferences_id=$oldConfId");
|
||||||
|
$errorMessage = mysql_error();
|
||||||
|
while($errorMessage == '' && $r=mysql_fetch_object($q)) {
|
||||||
|
/* Roll the one award */
|
||||||
|
$errorMessage .= roll($oldConfId, $newConfId, 'award_awards', "id='{$r->id}'");
|
||||||
|
$award_awards_id=mysql_insert_id();
|
||||||
|
|
||||||
|
$errorMessage .= roll($oldConfId, $newConfId, 'award_awards_projectcategories', "award_awards_id='{$r->id}'",
|
||||||
|
array('award_awards_id' => $award_awards_id));
|
||||||
|
|
||||||
|
$errorMessage .= roll($oldConfId, $newConfId, 'award_awards_projectdivisions', "award_awards_id='{$r->id}'",
|
||||||
|
array('award_awards_id' => $award_awards_id));
|
||||||
|
echo i18n(" Rolling award prizes")."<br />";
|
||||||
|
$errorMessage .= roll($oldConfId, $newConfId, 'award_prizes', "award_awards_id='{$r->id}'",
|
||||||
|
array('award_awards_id' => $award_awards_id));
|
||||||
|
}
|
||||||
|
if($errorMessage != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . $errorMessage); return false; }
|
||||||
|
|
||||||
|
// award types
|
||||||
|
$q=mysql_query("SELECT * FROM award_types WHERE conferences_id = $oldConfId");
|
||||||
|
while(mysql_error() == '' && $r=mysql_fetch_object($q))
|
||||||
|
mysql_query("INSERT INTO award_types (id,type,`order`,conferences_id) VALUES (
|
||||||
|
'".mysql_real_escape_string($r->id)."',
|
||||||
|
'".mysql_real_escape_string($r->type)."',
|
||||||
|
'".mysql_real_escape_string($r->order)."',
|
||||||
|
'".mysql_real_escape_string($newConfId)."')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// schools
|
||||||
|
$q=mysql_query("SELECT * FROM schools WHERE conferences_id=$oldConfId");
|
||||||
|
while(mysql_error() == '' && $r=mysql_fetch_object($q)) {
|
||||||
|
$puid = ($r->principal_uid == null) ? 'NULL' : ("'".intval($r->principal_uid)."'");
|
||||||
|
$shuid = ($r->sciencehead_uid == null) ? 'NULL' : ("'".intval($r->sciencehead_uid)."'");
|
||||||
|
|
||||||
|
|
||||||
|
mysql_query("INSERT INTO schools (school,schoollang,schoollevel,board,district,phone,fax,address,city,province_code,postalcode,principal_uid,schoolemail,sciencehead_uid,accesscode,lastlogin,junior,intermediate,senior,registration_password,projectlimit,projectlimitper,conferences_id) VALUES (
|
||||||
|
'".mysql_real_escape_string($r->school)."',
|
||||||
|
'".mysql_real_escape_string($r->schoollang)."',
|
||||||
|
'".mysql_real_escape_string($r->schoollevel)."',
|
||||||
|
'".mysql_real_escape_string($r->board)."',
|
||||||
|
'".mysql_real_escape_string($r->district)."',
|
||||||
|
'".mysql_real_escape_string($r->phone)."',
|
||||||
|
'".mysql_real_escape_string($r->fax)."',
|
||||||
|
'".mysql_real_escape_string($r->address)."',
|
||||||
|
'".mysql_real_escape_string($r->city)."',
|
||||||
|
'".mysql_real_escape_string($r->province_code)."',
|
||||||
|
'".mysql_real_escape_string($r->postalcode)."',$puid,
|
||||||
|
'".mysql_real_escape_string($r->schoolemail)."',$shuid,
|
||||||
|
'".mysql_real_escape_string($r->accesscode)."',
|
||||||
|
NULL,
|
||||||
|
'".mysql_real_escape_string($r->junior)."',
|
||||||
|
'".mysql_real_escape_string($r->intermediate)."',
|
||||||
|
'".mysql_real_escape_string($r->senior)."',
|
||||||
|
'".mysql_real_escape_string($r->registration_password)."',
|
||||||
|
'".mysql_real_escape_string($r->projectlimit)."',
|
||||||
|
'".mysql_real_escape_string($r->projectlimitper)."',
|
||||||
|
'".mysql_real_escape_string($newConfId)."')");
|
||||||
|
}
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// questions
|
||||||
|
$q = mysql_query("SELECT * FROM questions WHERE conferences_id = $oldConfId");
|
||||||
|
while($r=mysql_fetch_object($q) && mysql_error() == '')
|
||||||
|
mysql_query("INSERT INTO questions (id,conferences_id,section,db_heading,question,type,required,ord) VALUES (
|
||||||
|
'',
|
||||||
|
'$newConfId',
|
||||||
|
'".mysql_real_escape_string($r->section)."',
|
||||||
|
'".mysql_real_escape_string($r->db_heading)."',
|
||||||
|
'".mysql_real_escape_string($r->question)."',
|
||||||
|
'".mysql_real_escape_string($r->type)."',
|
||||||
|
'".mysql_real_escape_string($r->required)."',
|
||||||
|
'".mysql_real_escape_string($r->ord)."')");
|
||||||
|
if(mysql_error() != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . mysql_error()); return false; }
|
||||||
|
|
||||||
|
// regfee items
|
||||||
|
$errorMessage = roll($oldConfId, $newConfId, 'regfee_items');
|
||||||
|
if($errorMessage != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . $errorMessage); return false; }
|
||||||
|
|
||||||
|
// volunteer positions
|
||||||
|
$errorMessage = roll($oldConfId, $newConfId, 'volunteer_positions');
|
||||||
|
if($errorMessage != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . $errorMessage); return false; }
|
||||||
|
|
||||||
|
// timeslots and rounds
|
||||||
|
$q = mysql_query("SELECT * FROM judges_timeslots WHERE conferences_id='$oldConfId' AND round_id='0'");
|
||||||
|
$errorMessage = mysql_error();
|
||||||
|
while($errorMessage == '' && $r=mysql_fetch_assoc($q)) {
|
||||||
|
if($params['rollDates'] == 'yes'){
|
||||||
|
mysql_query("INSERT INTO judges_timeslots (`conferences_id`,`round_id`,`type`,`date`,`starttime`,`endtime`,`name`)
|
||||||
|
VALUES ('$newConfId','0','{$r['type']}',DATE_ADD('{$r['date']}', INTERVAL 1 YEAR),
|
||||||
|
'{$r['starttime']}','{$r['endtime']}','{$r['name']}')");
|
||||||
|
}else{
|
||||||
|
mysql_query("INSERT INTO judges_timeslots (`conferences_id`,`round_id`,`type`,`date`,`starttime`,`endtime`,`name`)
|
||||||
|
VALUES ('$newConfId','0','{$r['type']}','{$r['date']}',
|
||||||
|
'{$r['starttime']}','{$r['endtime']}','{$r['name']}')");
|
||||||
|
}
|
||||||
|
$errorMessage .= mysql_error();
|
||||||
|
$round_id = mysql_insert_id();
|
||||||
|
$qq = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='{$r['id']}'");
|
||||||
|
if($params['rollDates'] == 'yes'){
|
||||||
|
while($rr=mysql_fetch_assoc($qq) && mysql_error() == '')
|
||||||
|
mysql_query("INSERT INTO judges_timeslots (`conferences_id`,`round_id`,`type`,`date`,`starttime`,`endtime`)
|
||||||
|
VALUES ('$newConfId','$round_id','timeslot',DATE_ADD('{$rr['date']}', INTERVAL 1 YEAR),
|
||||||
|
'{$rr['starttime']}','{$rr['endtime']}')");
|
||||||
|
}else{
|
||||||
|
while($rr=mysql_fetch_assoc($qq) && mysql_error() == '')
|
||||||
|
mysql_query("INSERT INTO judges_timeslots (`conferences_id`,`round_id`,`type`,`date`,`starttime`,`endtime`)
|
||||||
|
VALUES ('$newConfId','$round_id','timeslot','{$rr['date']}',
|
||||||
|
'{$rr['starttime']}','{$rr['endtime']}')");
|
||||||
|
}
|
||||||
|
$errorMessage .= mysql_error();
|
||||||
|
}
|
||||||
|
if($errorMessage != ''){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . $errorMessage); return false; }
|
||||||
|
|
||||||
|
|
||||||
|
// admin, config, and committee users
|
||||||
|
$errorMessage = conferences_copy_users($oldConfId, $newConfId, array('admin', 'config', 'committee'));
|
||||||
|
if($errorMessage != 'ok'){ wizard_draw_step('error', 'SQL error before line #' . __LINE__ . ': <br/>' . $errorMessage); return false; }
|
||||||
|
|
||||||
|
|
||||||
|
// WHEW! If we've made it this far, the conference has successfully been copied
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return empty string on success, error message otherwise
|
||||||
|
function roll($oldConfId, $newConfId, $table, $where='', $replace=array())
|
||||||
|
{
|
||||||
|
/* Field Type Null Key Default Extra
|
||||||
|
* id int(10) unsigned NO PRI NULL auto_increment
|
||||||
|
* sponsors_id int(10) unsigned NO MUL 0
|
||||||
|
* award_source_fairs_id int(10) unsigned YES NULL
|
||||||
|
*/
|
||||||
|
|
||||||
|
$errMessage = '';
|
||||||
|
|
||||||
|
/* Get field list for this table */
|
||||||
|
$q = mysql_query("SHOW COLUMNS IN `$table`");
|
||||||
|
while(($c = mysql_fetch_assoc($q))) {
|
||||||
|
$col[$c['Field']] = $c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Record fields we care about */
|
||||||
|
$fields = array();
|
||||||
|
$keys = array_keys($col);
|
||||||
|
foreach($keys as $k) {
|
||||||
|
/* Skip id field */
|
||||||
|
if($col[$k]['Extra'] == 'auto_increment') continue;
|
||||||
|
/* Skip year field */
|
||||||
|
if($k == 'year') continue;
|
||||||
|
/* Skip conferences_id field */
|
||||||
|
if($k == 'year') continue;
|
||||||
|
|
||||||
|
$fields[] = $k;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($where == '') $where='1';
|
||||||
|
|
||||||
|
/* Get data */
|
||||||
|
$q=mysql_query("SELECT * FROM $table WHERE conferences_id='$oldConfId' AND $where");
|
||||||
|
if(mysql_error() != '') $errMessage .= mysql_error() . "<br/>";
|
||||||
|
|
||||||
|
$names = '`'.join('`,`', $fields).'`';
|
||||||
|
|
||||||
|
/* Process data */
|
||||||
|
while($r=mysql_fetch_assoc($q)) {
|
||||||
|
$vals = '';
|
||||||
|
foreach($fields as $f) {
|
||||||
|
if(array_key_exists($f, $replace))
|
||||||
|
$vals .= ",'".mysql_real_escape_string($replace[$f])."'";
|
||||||
|
else if($col[$f]['Null'] == 'YES' && $r[$f] == NULL)
|
||||||
|
$vals .= ',NULL';
|
||||||
|
else
|
||||||
|
$vals .= ",'".mysql_real_escape_string($r[$f])."'";
|
||||||
|
}
|
||||||
|
mysql_query("INSERT INTO `$table`(`conferences_id`,$names) VALUES ('$newConfId'$vals)");
|
||||||
|
if(mysql_error() != '') $errMessage .= mysql_error() . "<br/>";
|
||||||
|
echo mysql_error();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $errMessage;
|
||||||
|
}
|
||||||
|
@ -757,3 +757,54 @@ ul.conferencenav li a:hover {
|
|||||||
background: #CCFFD5;
|
background: #CCFFD5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#wizardWrapper{
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
#wizardBackdrop{
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: #383878;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wizard {
|
||||||
|
background-color: #E0E0FF;
|
||||||
|
border: 2px solid silver;
|
||||||
|
width: 40em;
|
||||||
|
margin-left:auto;
|
||||||
|
margin-right:auto;
|
||||||
|
top: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wizard h2{
|
||||||
|
background-color: #1B86B7;
|
||||||
|
color: #FFF;
|
||||||
|
text-align:center;
|
||||||
|
padding:0;
|
||||||
|
margin:0;
|
||||||
|
margin-left:auto;
|
||||||
|
margin-right:auto;
|
||||||
|
border-bottom: 1px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wizard p{
|
||||||
|
margin: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard_content{
|
||||||
|
background-color: #E0E0FF;
|
||||||
|
margin: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wizard_buttons{
|
||||||
|
background-color: #1B86B7;
|
||||||
|
padding: 0.25em;
|
||||||
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
require_once("common.inc.php");
|
require_once("common.inc.php");
|
||||||
require_once("user.inc.php");
|
require_once("user.inc.php");
|
||||||
user_auth_required();
|
user_auth_required();
|
||||||
|
/*
|
||||||
// find out if this user actually is in this conference
|
// find out if this user actually is in this conference
|
||||||
$query = "SELECT COUNT(*) FROM users WHERE conferences_id = {$conference['id']}"
|
$query = "SELECT COUNT(*) FROM users WHERE conferences_id = {$conference['id']}"
|
||||||
. " AND accounts_id = " . $_SESSION['accounts_id'];
|
. " AND accounts_id = " . $_SESSION['accounts_id'];
|
||||||
@ -34,7 +35,7 @@ if($data[0] == 0){
|
|||||||
$u = user_create($_SESSION['accounts_id'], $_SESSION['conferences_id']);
|
$u = user_create($_SESSION['accounts_id'], $_SESSION['conferences_id']);
|
||||||
$_SESSION['users_id'] = $u['id'];
|
$_SESSION['users_id'] = $u['id'];
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
$u = user_load($_SESSION['users_id']);
|
$u = user_load($_SESSION['users_id']);
|
||||||
if($u && array_key_exists('action', $_GET)){
|
if($u && array_key_exists('action', $_GET)){
|
||||||
switch($_GET['action']){
|
switch($_GET['action']){
|
||||||
|
Loading…
Reference in New Issue
Block a user