From 64dba39a57d6f6ee751f9a0fa74fc8f0c7ddac87 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 26 Sep 2009 20:39:52 +0000 Subject: [PATCH] - fixup availablity and special awards selection --- judge_availability.php | 74 +++++++++++++++++++++------------- judge_special_awards.php | 85 ++++++++++++++++++++++++---------------- 2 files changed, 98 insertions(+), 61 deletions(-) diff --git a/judge_availability.php b/judge_availability.php index cd25455..4407166 100644 --- a/judge_availability.php +++ b/judge_availability.php @@ -27,14 +27,22 @@ require_once('common.inc.php'); require_once('user.inc.php'); require_once('judge.inc.php'); -if($_SESSION['embed'] == true) { - user_auth_required('committee'); - $u = user_load($_SESSION['embed_edit_id']); -} else { - user_auth_required('judge'); - $u = user_load($_SESSION['users_id']); +/* Sort out who we're editting */ +if($_POST['users_id']) + $eid = intval($_POST['users_id']); /* From a save form */ +else if(array_key_exists('embed_edit_id', $_SESSION)) + $eid = $_SESSION['embed_edit_id']; /* From the embedded editor */ +else + $eid = $_SESSION['users_id']; /* Regular entry */ + +if($eid != $_SESSION['users_id']) { + /* Not editing ourself, we had better be + * a committee member */ + user_auth_required('committee','admin'); } +$u = user_load($eid); + $times = array(); /* Load the judging rounds */ @@ -58,7 +66,8 @@ while($r = mysql_fetch_object($q)) { } } -if($_POST['action']=='save') { +switch($_GET['action']) { +case 'save': mysql_query("DELETE FROM judges_availability WHERE users_id='{$u['id']}'"); if(is_array($_POST['time']) ) { @@ -71,13 +80,13 @@ if($_POST['action']=='save') { '{$times[$x]['starttime']}','{$times[$x]['endtime']}')"); } } - message_push(notice(i18n("Time Availability preferences successfully saved"))); + happy_("Time Availability preferences successfully saved"); + exit; } if($_SESSION['embed'] == true) { - echo "
"; display_messages(); - echo "

".i18n('Time Availability')."

"; + echo "

".i18n('Time Availability')."

"; echo "
"; } else { //send the header @@ -86,6 +95,17 @@ if($_SESSION['embed'] == true) { ); } +?> + +\n"; - -echo "\n"; - -echo "
"; - +?> +
+ +
+ +\n"; foreach($times as $x=>$t) { $ch = $sel[$x] == true ? 'checked="checked"' : ''; echo ""; echo ""; } - -echo "
"; @@ -127,14 +145,14 @@ foreach($times as $x=>$t) { echo "

{$t['name']}

"; -echo "
"; -echo "
"; - -echo "\n"; -echo "
"; - -if($_SESSION['embed'] != true) send_footer(); - +?> + +
+
+ +" /> + + + diff --git a/judge_special_awards.php b/judge_special_awards.php index dab6f85..da95ce4 100644 --- a/judge_special_awards.php +++ b/judge_special_awards.php @@ -26,14 +26,24 @@ require_once('user.inc.php'); require_once('judge.inc.php'); - if($_SESSION['embed'] == true) { - $u = user_load($_SESSION['embed_edit_id']); - } else { - $u = user_load($_SESSION['users_id']); - } +/* Sort out who we're editting */ +if($_POST['users_id']) + $eid = intval($_POST['users_id']); /* From a save form */ +else if(array_key_exists('embed_edit_id', $_SESSION)) + $eid = $_SESSION['embed_edit_id']; /* From the embedded editor */ +else + $eid = $_SESSION['users_id']; /* Regular entry */ +if($eid != $_SESSION['users_id']) { + /* Not editing ourself, we had better be + * a committee member */ + user_auth_required('committee','admin'); +} - if($_POST['action']=="save") { +$u = user_load($eid); + +switch($_GET['action']) { +case 'save': //first delete all their old associations for this year.. mysql_query("DELETE FROM judges_specialaward_sel WHERE users_id='{$u['id']}'"); @@ -43,13 +53,13 @@ VALUES ('{$u['id']}','$aid')"); } } - message_push(notice(i18n("Special Award preferences successfully saved"))); + happy_("Special Award preferences successfully saved"); + exit; } if($_SESSION['embed'] == true) { - echo "
"; display_messages(); - echo "

".i18n('Special Awards')."

"; + echo "

".i18n('Special Awards')."

"; echo "
"; } else { //send the header @@ -57,6 +67,15 @@ array('Judge Registration' => 'judge_main.php') ); } +?> + +\n"; -} else { - echo "
\n"; -} - echo "\n"; +?> + + + + +"; - $ch = (in_array($r->id,$spawards)) ? "checked=\"checked\"" : ""; - echo "id}\" />"; - echo ""; - echo "{$r->name} ({$r->organization})"; - echo ""; - echo ""; - echo "{$r->criteria}"; - echo "

"; - echo ""; + ?> + + id,$spawards)) ? "checked=\"checked\"" : ""; ?> + type="checkbox" name="spaward[]" value="id?>" /> + + name?> (organization?>) + + criteria?> +

+ + "; - - echo "\n"; - echo "
"; - - - if($_SESSION['embed'] != true) send_footer(); - +?> + +" /> + + +