forked from science-ation/science-ation
Fix a bug in loading users (cant call user_load() within any function that is called within user_load itself, like all the individual page checks -- in this case, emergencycontactStatus()
Add special awards display to project/view Add special awards saving to project/edit
This commit is contained in:
parent
b9fbc56372
commit
26e4204015
4
api.php
4
api.php
@ -1056,8 +1056,9 @@ switch($request[0]) {
|
||||
/* APIDOC: project/view
|
||||
description(Displays the current project information)
|
||||
return(project array)
|
||||
object(project: {project_id integer, projectdivisions_id integer, title varchar(255), language char(2), req_electricity enum('no', 'yes'), req_table enum('no', 'yes'), req_special varchar(128), summary text,safetyquestions array of question})
|
||||
object(project: {project_id integer, projectdivisions_id integer, title varchar(255), language char(2), req_electricity enum('no', 'yes'), req_table enum('no', 'yes'), req_special varchar(128), summary text,safetyquestions array of question, specialawards array of specialaward})
|
||||
object(question: {id,question,type,required,ord,answer})
|
||||
object(specialaward: {id,name,criteria,self_nominate,selected})
|
||||
*/
|
||||
case 'view':
|
||||
if($u=user_load($_SESSION['users_id'])) {
|
||||
@ -1081,6 +1082,7 @@ switch($request[0]) {
|
||||
description(Edit an existing project. "language" notes the language a participant wishes to be judged in. "req_electricity" notes whethor or not the project requires an electrical outlet. "req_table" states whether or not the project needs a table. "req_special" is a field for special requirements.)
|
||||
object(project: as per project/view)
|
||||
object(question: for sake of not re-transmitting all the safetyquestion text, the only fields required to save are {id,answer})
|
||||
object(specialaward: for sake of not re-transmitting all the specialaward text, the only fields required to save are {id,selected})
|
||||
return(project array)
|
||||
*/
|
||||
case 'edit':
|
||||
|
@ -104,16 +104,17 @@ function emergencycontactStatus($reg_id="")
|
||||
|
||||
$sq=mysql_query("SELECT id FROM users WHERE registrations_id='$rid' AND conferences_id='".$conference['id']."'");
|
||||
$returnval = 'complete';
|
||||
$fields = array('firstname', 'lastname', 'relation', 'phone1', 'phone2', 'phone3', 'phone4', 'email');
|
||||
while($sr=mysql_fetch_object($sq)) {
|
||||
$u = user_load($sr->id);
|
||||
if(!array_key_exists('emergencycontacts', $u)){
|
||||
$q = mysql_query("SELECT " . implode(',', $fields) . " FROM emergencycontact WHERE users_id = $sr->id ORDER BY id");
|
||||
if(!mysql_num_rows($q)) {
|
||||
$returnval = 'incomplete';
|
||||
break;
|
||||
}
|
||||
$oneValid = false;
|
||||
foreach($u['emergencycontacts'] as $contact){
|
||||
while($contact=mysql_fetch_assoc($q)) {
|
||||
$valid = true;
|
||||
foreach($rquired_fields AS $req){
|
||||
foreach($required_fields AS $req){
|
||||
if(!$contact[$req]) $valid = false;
|
||||
break;
|
||||
}
|
||||
@ -151,10 +152,8 @@ function projectStatus($reg_id="")
|
||||
if(!mysql_num_rows($q))
|
||||
return "empty";
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
foreach ($required_fields AS $req)
|
||||
{
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
foreach ($required_fields AS $req) {
|
||||
if(!$r->$req) {
|
||||
return "incomplete";
|
||||
}
|
||||
|
@ -319,18 +319,19 @@ function getProjectId($registrations_id){
|
||||
|
||||
function getAwardListing($project_id){
|
||||
$returnval = array();
|
||||
$eligibleAwards = getSpecialAwardsEligibleForProject($projectId);
|
||||
$nominatedawards = getSpecialAwardsNominatedForProject($projectId);
|
||||
$eligibleAwards = getSpecialAwardsEligibleForProject($project_id);
|
||||
$nominatedawards = getSpecialAwardsNominatedForProject($project_id);
|
||||
$nominatedawards_list=array();
|
||||
foreach($nominatedawards AS $naward){
|
||||
$nominatedawards_list[] = $naward['id'];
|
||||
}
|
||||
$idx = 0;
|
||||
foreach($eligibleAwards AS $eaward){
|
||||
$returnval[$idx] = $eaward;
|
||||
if(in_array($eaward['id'],$nominatedawards_list)) $returnval[$idx]['selected'] = true;
|
||||
$idx++;
|
||||
|
||||
if(in_array($eaward['id'],$nominatedawards_list))
|
||||
$eaward['selected']=true;
|
||||
else
|
||||
$eaward['selected']=false;
|
||||
|
||||
$returnval[] = $eaward;
|
||||
}
|
||||
return $returnval;
|
||||
}
|
||||
|
@ -334,6 +334,23 @@ function saveProjectData($data){
|
||||
}
|
||||
}
|
||||
|
||||
//and update the special award nominations
|
||||
//but make sure they dont sign up for anything they're not allowed to :p
|
||||
if(is_array($data['specialawards'])) {
|
||||
$eligibleAwards = getSpecialAwardsEligibleForProject($data['project_id']);
|
||||
$eligibleAwardsList=array();
|
||||
foreach($eligibleAwards AS $ea) {
|
||||
$eligibleAwardsList[]=$ea['id'];
|
||||
}
|
||||
mysql_query("DELETE FROM projects_specialawards_link WHERE projects_id='{$data['projects_id']}' AND conferences_id='{$conference['id']}'");
|
||||
|
||||
foreach($data['specialawards'] AS $sa) {
|
||||
if($sa['selected']==true) {
|
||||
mysql_query("INSERT INTO projects_specialawards_link (award_awards_id,projects_id,conferences_id) VALUES ('".intval($sa['id'])."','".intval($data['projects_id'])."','{$conference['id']}')");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($message == ''){
|
||||
$message = 'success';
|
||||
}
|
||||
@ -499,6 +516,10 @@ function getProject($userId){
|
||||
|
||||
$safetyquestions=getSafetyQuestions($regId);
|
||||
$returnval['safetyquestions']=$safetyquestions;
|
||||
|
||||
$specialawards=getAwardListing($returnval['id']);
|
||||
$returnval['specialawards']=$specialawards;
|
||||
|
||||
return $returnval;
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,11 @@ if(array_key_exists('join', $_GET)){
|
||||
|
||||
// this is a request to join this conference
|
||||
// get the corresponding account id to go with this user id
|
||||
if($edit_id == null){
|
||||
if(!$edit_id) {
|
||||
// this will happen if they have no user record
|
||||
$edit_accounts_id = $_SESSION['accounts_id'];
|
||||
}else{
|
||||
$q = mysql_query("SELECT accounts_id FROM users WHERE id=$edit_id");
|
||||
$q = mysql_query("SELECT accounts_id FROM users WHERE id='$edit_id'");
|
||||
if(!$q){
|
||||
echo mysql_error();
|
||||
exit();
|
||||
@ -62,6 +62,11 @@ if(array_key_exists('join', $_GET)){
|
||||
user_save($u);
|
||||
$edit_id = $u['id'];
|
||||
}
|
||||
else {
|
||||
$u=user_load_by_accounts_id($edit_accounts_id);
|
||||
$edit_id=$u['id'];
|
||||
//echo "we have {$data[0]} users already";
|
||||
}
|
||||
}else{
|
||||
$joinConference = false;
|
||||
if($edit_id == ''){
|
||||
@ -87,6 +92,10 @@ if(array_key_exists('join', $_GET)){
|
||||
require_once("user_edit_tabs.inc.php");
|
||||
|
||||
$u = user_load($edit_id);
|
||||
if(!$u) {
|
||||
echo "Could not load user id $edit_id";
|
||||
exit;
|
||||
}
|
||||
$types = array_keys($u['roles']);
|
||||
$selected = $_GET['tab'];
|
||||
if(!array_key_exists($selected, $tabs)) {
|
||||
|
Loading…
Reference in New Issue
Block a user