From 1e2340beb129eeb727d652342e6442aec3ac77f4 Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 16 Nov 2010 19:53:26 +0000 Subject: [PATCH] Some updates on the interface for creating conferences Modified the user object, correcting some issues with judging availability and volunteer availability. --- common.inc.functions.php | 4 +- judge_other.php | 2 +- super/conferences.php | 121 ++++++++++++++++++++++++--------------- theme/default/sfiab.css | 3 +- user.inc.php | 119 ++++++++++++++++++++++++++++++++++---- 5 files changed, 187 insertions(+), 62 deletions(-) diff --git a/common.inc.functions.php b/common.inc.functions.php index f826f63..80a1311 100644 --- a/common.inc.functions.php +++ b/common.inc.functions.php @@ -779,8 +779,8 @@ function projectcategories_load($conferences_id = false) { return $cats; } -// a convenience function for getting the available event timeslots in the given conference -function get_timeslots($conferenceId){ +// a convenience function for getting the available judging timeslots in the given conference +function get_judging_timeslots($conferenceId){ $times = array(); $q = mysql_query("SELECT id,date,starttime,endtime,name FROM judges_timeslots WHERE round_id='0' AND conferences_id='$conferenceId' ORDER BY starttime,type"); $x = 0; diff --git a/judge_other.php b/judge_other.php index dff7f1e..ab47e3c 100644 --- a/judge_other.php +++ b/judge_other.php @@ -40,7 +40,7 @@ else $u = user_load($edit_id); // Load the judging rounds -$times = get_timeslots($conference['id']); +$times = get_judging_timeslots($conference['id']); switch($_GET['action']) { case 'save': diff --git a/super/conferences.php b/super/conferences.php index 72c0c65..3c65bc7 100644 --- a/super/conferences.php +++ b/super/conferences.php @@ -44,8 +44,8 @@ $wizard_steps = array( 'method' ), 'actions' => array( + 'cancel' => i18n('Cancel'), 'next' => i18n('Next'), - 'cancel' => i18n('Cancel') ) ), 'selectNameType' => array( @@ -57,9 +57,9 @@ $wizard_steps = array( 'type' ), 'actions' => array( - 'back' => i18n('Back'), + 'cancel' => i18n('Cancel'), 'next' => i18n('Next'), - 'cancel' => i18n('Cancel') + 'back' => i18n('Back'), ) ), 'selectConference' => array( @@ -72,9 +72,9 @@ $wizard_steps = array( 'rollDates' ), 'actions' => array( - 'back' => i18n('Back'), + 'cancel' => i18n('Cancel'), 'next' => i18n('Next'), - 'cancel' => i18n('Cancel') + 'back' => i18n('Back'), ) ), 'enterName' => array( @@ -85,9 +85,9 @@ $wizard_steps = array( 'name' ), 'actions' => array( - 'back' => i18n('Back'), + 'cancel' => i18n('Cancel'), 'next' => i18n('Next'), - 'cancel' => i18n('Cancel') + 'back' => i18n('Back'), ) ), @@ -97,9 +97,9 @@ $wizard_steps = array( 'handler' => 'handle_complete_step', 'fields' => array(), 'actions' => array( - 'back' => i18n('Back'), + 'cancel' => i18n('Cancel'), 'ok' => i18n('OK'), - 'cancel' => i18n('Cancel') + 'back' => i18n('Back'), ) ), 'error' => array( @@ -138,23 +138,35 @@ send_header("Conferences Setup", ); ?>
+ +
+
+Add a conference +
"; + $query = mysql_query("SELECT * FROM `conferences`"); + while($row = mysql_fetch_assoc($query)){ + echo ""; + echo "{$row['name']}{$row['type']}{$row['status']}"; + echo ""; + echo ""; + echo ""; + } + echo ""; +} +/* require("../tableeditor.class.php"); $editor=new TableEditor("conferences", @@ -201,18 +231,7 @@ $editor->setPrimaryKey("id"); $editor->setDefaultSortField("id"); $editor->setRecordType("Conference"); $editor->execute(); -?> -
-
-Add a conference - -
-
-
-
-"; + + // add the appropriate buttons + echo 'wizard.dialog("option","buttons", {'; + $doneone = false; + foreach($wizard_steps[$step]['actions'] as $tag => $label){ + if($doneone) echo ","; + else $doneone = true; + echo '"' . $label . '":function(){handleSubmit("' . $tag . '");}'; + } + echo '});'; // draw the title header - echo '

' . $wizard_steps[$step]['title'] . '

'; + echo 'wizard.dialog("option", "title", "' . $wizard_steps[$step]['title'] . '");'; + echo ""; if($message != null){ // used for error messages (eg. empty field) @@ -242,13 +271,6 @@ function wizard_draw_step($step, $message = null){ } echo ""; - // add the appropriate buttons at the bottom - echo "
"; // draw the buttons at the bottom of this step - foreach($wizard_steps[$step]['actions'] as $tag => $label){ - echo " "; - } - echo "
"; - echo ""; } } @@ -258,9 +280,7 @@ function wizard_close(){ unset($_SESSION['conference_wizard']); echo " "; @@ -518,10 +538,18 @@ function create_conference($params){ return $conferences_id; } -// copy users of the specified roles (passed in an array) +// copy users of the specified roles from conference oldConfId to conference newConfId +// roles can be passed as a single comma delimited string, or as an array of strings // return 'ok' on success, error message otherwise function conferences_copy_users($oldConfId, $newConfId, $roles){ - if(!is_array($roles)) $roles = array($roles); + if(!is_array($roles)){ + // they must have been passed as a string + $roles = explode(',', $roles); + foreach($roles as $idx => $val){ + $roles[$idx] = trim($val); + } + } + $query = mysql_query(" SELECT * FROM users WHERE users.id IN( SELECT DISTINCT(users.id) FROM users @@ -543,7 +571,6 @@ function conferences_copy_users($oldConfId, $newConfId, $roles){ } $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']; @@ -552,6 +579,7 @@ function conferences_copy_users($oldConfId, $newConfId, $roles){ SELECT roles_id, active, complete FROM user_roles JOIN roles ON roles.id = user_roles.roles_id WHERE roles.`type` IN('" . implode("','", $roles) . "') + AND user_roles.users_id = $oldId "); while(mysql_error() == '' && $row2 = mysql_fetch_assoc($q2)){ mysql_query(" @@ -719,7 +747,7 @@ function copy_conference($params){ // questions $q = mysql_query("SELECT * FROM questions WHERE conferences_id = $oldConfId"); - while($r=mysql_fetch_object($q) && mysql_error() == '') + while(mysql_error() == '' && $r=mysql_fetch_object($q)) mysql_query("INSERT INTO questions (id,conferences_id,section,db_heading,question,type,required,ord) VALUES ( '', '$newConfId', @@ -781,8 +809,7 @@ function copy_conference($params){ } // return empty string on success, error message otherwise -function roll($oldConfId, $newConfId, $table, $where='', $replace=array()) -{ +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 @@ -830,7 +857,7 @@ function roll($oldConfId, $newConfId, $table, $where='', $replace=array()) else $vals .= ",'".mysql_real_escape_string($r[$f])."'"; } - mysql_query("INSERT INTO `$table`(`conferences_id`,$names) VALUES ('$newConfId'$vals)"); + mysql_query("INSERT INTO `$table` (`conferences_id`, $names) VALUES ('$newConfId'$vals)"); if(mysql_error() != '') $errMessage .= mysql_error() . "
"; echo mysql_error(); } diff --git a/theme/default/sfiab.css b/theme/default/sfiab.css index 2c380bf..5537a0c 100644 --- a/theme/default/sfiab.css +++ b/theme/default/sfiab.css @@ -756,7 +756,7 @@ ul.conferencenav li a:hover { .scheduleevent_tour { background: #CCFFD5; } - +/* #wizardWrapper{ display: none; position: absolute; @@ -808,3 +808,4 @@ ul.conferencenav li a:hover { background-color: #1B86B7; padding: 0.25em; } +*/ diff --git a/user.inc.php b/user.inc.php index d0c04da..b553ede 100644 --- a/user.inc.php +++ b/user.inc.php @@ -204,7 +204,7 @@ function user_load($users_id, $accounts_id = false) case 'available_times': // a rather complicated match-up, as they're linked by time values, not by record id's - $times = get_timeslots($u['conferences_id']); + $times = get_judging_timeslots($u['conferences_id']); $q = mysql_query("SELECT * FROM judges_availability WHERE users_id=\"{$u['id']}\""); $sel = array(); @@ -227,6 +227,42 @@ function user_load($users_id, $accounts_id = false) } $u['available_times'] = $items; break; + + case 'available_events': + $q1 = mysql_query("SELECT schedule_id FROM `schedule_users_availability_link` sual JOIN schedule ON schedule.id = sual.schedule_id WHERE users_id = {$u['id']} AND schedule.conferences_id = '{$u['conferences_id']}'"); + $ids = array(); + while($row = mysql_fetch_assoc($q1)){ + $ids[] = $row['schedule_id']; + } + $q2 = mysql_query("SELECT id FROM schedule WHERE schedule.conferences_id='{$u['conferences_id']}'"); + $items = array(); + while($row = mysql_fetch_assoc($q2)){ + if(in_array($row['id'], $ids)){ + $items[$row['id']] = 'yes'; + }else{ + $items[$row['id']] = 'no'; + } + } + $u['available_events'] = $items; + break; + + case 'volunteer_positions': + $q1 = mysql_query("SELECT volunteer_positions_id AS vpid FROM volunteer_positions_signup WHERE users_id = {$u['id']} AND conferences_id = {$u['conferences_id']}"); + $ids = array(); + while($row = mysql_fetch_assoc($q1)){ + $ids[] = $row['vpid']; + } + $q2 = mysql_query("SELECT id FROM volunteer_positions WHERE conferences_id = {$u['conferences_id']}"); + $items = array(); + while($row = mysql_fetch_assoc($q2)){ + if(in_array($row['id'], $ids)){ + $items[$row['id']] = 'yes'; + }else{ + $items[$row['id']] = 'no'; + } + } + $u['volunteer_positions'] = $items; + break; } } @@ -294,7 +330,8 @@ function user_get_role_fields($role){ } function user_get_field_info(){ - return array( + global $conference; + $returnval = array( 'salutation' => array('label' => 'Salutation', 'group' => 'Personal Information'), 'firstname' => array('label' => 'First Name', 'group' => 'Personal Information'), 'lastname' => array('label' => 'Last Name', 'group' => 'Personal Information'), @@ -329,11 +366,22 @@ function user_get_field_info(){ 'primary' => array('label' => 'Primary Contact', 'group' => 'Sponsors'), 'position' => array('label' => 'Position', 'group' => 'Sponsors'), 'notes' => array('label' => 'Notes', 'group' => 'Sponsors'), - 'schools_id' => array('label' => 'School', 'group' => 'Personal'), + 'schools_id' => array('label' => 'School', 'group' => 'Personal Information'), 'grade' => array('label' => 'Grade', 'group' => 'Personal Information'), 'special_awards' => array('label' => 'Special Awards', 'group' => 'Judges'), - 'available_times' => array('label' => 'Times Available', 'group' => 'Judges,Volunteers') + 'volunteer_positions' => array('label' => 'Volunteer Positions', 'group' => 'Volunteers') ); + switch($conference['type']){ + case 'sciencefair': + $returnval['available_times'] = array('label' => 'Times Available', 'group' => 'Judges'); + $returnval['available_events'] = array('label' => 'Event Availability', 'group' => 'Volunteers'); + break; + case 'scienceolympics': + $returnval['available_events'] = array('label' => 'Event Availability', 'group' => 'Judges,Volunteers'); + break; + } + + return $returnval; } function user_role_field_required($role, $fieldname){ @@ -505,16 +553,33 @@ function user_get_fields($userRoles = null){ } /******* Now we add fields that are not stored directly in the users table ********/ - $specialFieldRoles = array( - 'special_awards' => array('judge', 'student'), - 'available_times' => array('judge', 'volunteer') - ); + switch($conference['type']){ + case 'sciencefair': + $specialFieldRoles = array( + 'special_awards' => array('judge', 'student'), + 'available_times' => array('judge'), + 'available_events' => array('volunteer'), + 'volunteer_positions' => array('volunteer') + ); + break; + case 'scienceolympics': + $specialFieldRoles = array( + 'special_awards' => array(), + 'available_times' => array(), + 'available_events' => array('judge', 'volunteer'), + 'volunteer_positions' => array('volunteer') + ); + break; + default: + $specialFieldRoles = array(); + } // get the special_awards info if necessary if(count(array_intersect($specialFieldRoles['special_awards'], $userRoles)) > 0){ $fields['special_awards'] = array(); $fields['special_awards']['field'] = 'special_awards'; - $fields['special_awards']['display'] = $fieldInfo['special_awards']['label']; + $fields['special_awards']['display'] = i18n($fieldInfo['special_awards']['label']); + $fields['special_awards']['group'] = i18n($fieldInfo['special_awards']['group']); $fields['special_awards']['type'] = 'multiselectlist'; $fields['special_awards']['options'] = array('yes' => 'Yes', 'no' => 'No'); $fields['special_awards']['entries'] = get_special_awards($conference['id']); @@ -524,15 +589,47 @@ function user_get_fields($userRoles = null){ if(count(array_intersect($specialFieldRoles['available_times'], $userRoles)) > 0){ $fields['available_times'] = array(); $fields['available_times']['field'] = 'available_times'; - $fields['available_times']['display'] = $fieldInfo['available_times']; + $fields['available_times']['display'] = i18n($fieldInfo['available_times']['label']); + $fields['available_times']['group'] = i18n($fieldInfo['available_times']['group']); $fields['available_times']['type'] = 'multiselectlist'; $fields['available_times']['options'] = array('yes' => 'Yes', 'no' => 'No'); $fields['available_times']['entries'] = array(); - $timeslots = get_timeslots($conference['id']); + $timeslots = get_judging_timeslots($conference['id']); foreach($timeslots as $slot){ $fields['available_times']['entries'][$slot['id']] = trim($slot['name'] . ' (' . $slot['date'] . ' ' . $slot['starttime'] . ' - ' . $slot['endtime'] . ')'); } } + + // get the available_events if available + if(count(array_intersect($specialFieldRoles['available_events'], $userRoles)) > 0){ + $fields['available_events'] = array(); + $fields['available_events']['field'] = 'available_events'; + $fields['available_events']['display'] = i18n($fieldInfo['available_events']['label']); + $fields['available_events']['group'] = i18n($fieldInfo['available_events']['group']); + $fields['available_events']['type'] = 'multiselectlist'; + $fields['available_events']['options'] = array('yes' => 'Yes', 'no' => 'No'); + $fields['available_events']['entries'] = array(); + $q=mysql_query("SELECT schedule.id, schedule.date, schedule.hour, schedule.minute, schedule.duration, events.name FROM schedule JOIN events ON schedule.events_id=events.id WHERE schedule.conferences_id='{$conference['id']}'"); + while($row = mysql_fetch_assoc($q)){ + $fields['available_events']['entries'][$row['id']] = $row['name'] . ' ' . $row['date'] . ', ' . $row['hour'] . ':' . $row['minute'] . ':00 (' . $row['duration'] . ' ' . i18n('minutes') . ')'; + } + } + + // get the available volunteer positions as well + if(count(array_intersect($specialFieldRoles['volunteer_positions'], $userRoles)) > 0){ + $fields['volunteer_positions'] = array(); + $fields['volunteer_positions']['field'] = 'volunteer_positions'; + $fields['volunteer_positions']['display'] = i18n($fieldInfo['volunteer_positions']['label']); + $fields['volunteer_positions']['group'] = i18n($fieldInfo['volunteer_positions']['group']); + $fields['volunteer_positions']['type'] = 'multiselectlist'; + $fields['volunteer_positions']['options'] = array('yes' => 'Yes', 'no' => 'No'); + $fields['volunteer_positions']['entries'] = array(); + $q = mysql_query("SELECT id, name FROM volunteer_positions WHERE conferences_id = {$conference['id']}"); + while($row = mysql_fetch_assoc($q)){ + $fields['volunteer_positions']['entries'][$row['id']] = $row['name']; + } + } + return $fields; }