diff --git a/admin/judges_manager.php b/admin/judges_manager.php
index 077e988..ef6e279 100644
--- a/admin/judges_manager.php
+++ b/admin/judges_manager.php
@@ -53,6 +53,7 @@ function openjudgeinfo(id)
$icon_exitension = $config['icon_extension'];
$editor = new TableEditor('judge');
+
$editor->setDebug(true);
$editor->execute();
diff --git a/judge.class.php b/judge.class.php
index 81b6fb1..07a7de3 100644
--- a/judge.class.php
+++ b/judge.class.php
@@ -1,6 +1,6 @@
-
+/* Just the fields in the judges table, we use this twice */
$judges_fields = array( 'firstname' => 'First Name',
'lastname' => 'Last Name',
'email' => 'Email Address',
@@ -24,10 +24,8 @@ $judges_fields = array( 'firstname' => 'First Name',
'complete' => "Complete");
-
class person {
var $id;
-// var $fields;
function person($person_id=NULL)
{
@@ -38,10 +36,7 @@ function person($person_id=NULL)
print("ID $person_id construction called\n");
$this->id = $person_id;
}
-// $this->fields = NULL;
}
-
-
};
@@ -51,6 +46,16 @@ class judge extends person {
function tableEditorSetup($editor)
{
global $judges_fields;
+ global $config;
+
+ $cat = array();
+ $catf = array();
+ $q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
+ while($r=mysql_fetch_object($q)) {
+ $cat[$r->id]=$r->category;
+ $catf["catpref_{$r->id}"] = "Category Preference ({$r->category})";
+ }
+
/* Setup the table editor with the fields we want to display
* when displaying a list of judges, and also the type of each
* field where required */
@@ -63,22 +68,45 @@ function tableEditorSetup($editor)
* will be the same for all person groups */
$e = array_merge($judges_fields,
array( 'language' => 'Language(s)',
-
));
+
+ $e = array_merge($e, $catf);
$editor->setTable('judges');
$editor->setListFields($l);
$editor->setEditFields($e);
+ print_r($e);
+ print("
\n");
/* Build an array of langauges that we support */
$langs = array();
$q=mysql_query("SELECT * FROM languages WHERE active='Y'");
while($r=mysql_fetch_object($q)) {
$langs[$r->lang] = $r->langname;
}
-
$editor->setFieldOptions('language', $langs);
$editor->setFieldInputType('language', 'multicheck');
+
+// $div = array();
+// $q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
+// while($r=mysql_fetch_object($q)) {
+// $divshort[$r->id]=$r->division_shortform;
+// $div[$r->id]=$r->division;
+// }
+
+ /* Pulled these out of register_judges.inc.php */
+ $preferencechoices=array(
+ array('key' => -2, 'val' => "Very Low"),
+ array('key' => -1, 'val' => "Low"),
+ array('key' => 0, 'val' => "Indifferent"),
+ array('key' => 1, 'val' => "Medium"),
+ array('key' => 2, 'val' => "High") );
+
+ foreach($cat as $cid=>$category) {
+ $editor->setFieldOptions("catpref_$cid", $preferencechoices);
+ $editor->setFieldInputType("catpref_$cid", 'select');
+ }
+
}
/* Functions for $this */
@@ -88,11 +116,12 @@ function judge($judge_id=NULL)
{
global $judges_fields;
person::person($judge_id);
-// $this->fields = $judges_fields;
}
function tableEditorLoad()
{
+ global $config;
+
$id = $this->id;
print("Loading Judge ID $id\n");
@@ -112,8 +141,21 @@ function tableEditorLoad()
$q=mysql_query("SELECT languages_lang
FROM judges_languages
WHERE judges_id='$id'");
- while($r=mysql_fetch_object($q)) {
- $j['language'][$r->languages_lang] = 1;
+ $j['language'] = array();
+ if(mysql_num_rows($q)) {
+ while($r=mysql_fetch_object($q)) {
+ $j['language'][$r->languages_lang] = 1;
+ }
+ }
+
+ $q=mysql_query("SELECT *
+ FROM judges_catpref
+ WHERE judges_id='$id'
+ AND year='{$config['FAIRYEAR']}'");
+ if(mysql_num_rows($q)) {
+ while($r=mysql_fetch_object($q)) {
+ $j["catpref_{$r->projectcategories_id}"] = $r->rank;
+ }
}
print_r($j);
@@ -123,44 +165,34 @@ function tableEditorLoad()
function tableEditorSave($data)
{
+ /* If $this->id == false, then we need to INSERT a new record.
+ * if it's a number, then we want an UPDATE statement */
global $judges_fields;
+ global $config;
$query = "";
- $insert_mode = ($this->id == false) ? 1 : 0;
-
- if($insert_mode) {
- $query="INSERT INTO judges (";
- //create list of fields to insert
- foreach($data AS $f=>$n)
- $query.="`$f`,";
- //rip off the last comma
- $query=substr($query,0,-1);
- $query.=") VALUES (";
- } else {
- $query="UPDATE `judges` SET ";
+ /* Construct an insert query if we have to */
+ if($this->id == false) {
+ $query = "INSERT INTO judges (id) VALUES ('')";
+ mysql_query($query);
+ $this->id = mysql_insert_id();
}
- foreach($judges_fields AS $f=>$n)
- {
- if($insert_mode) $field = '';
- else $field = "`$f`=";
+ /* Now just update the record */
+ $query="UPDATE `judges` SET ";
+ foreach($judges_fields AS $f=>$n) {
$n = $data[$f];
-
- $query .= $field.$n.",";
+ $query .= "`$f`=$n,";
}
//rip off the last comma
$query=substr($query,0,-1);
- if($insertmode) {
- $query.=")";
- } else {
- $query.=" WHERE id='{$this->id}'";
- }
+ $query .= " WHERE id='{$this->id}'";
-echo $query;
-// mysql_query($query);
+ echo $query;
+ mysql_query($query);
print("data: \n");
print_r($data);
@@ -170,7 +202,7 @@ echo $query;
/* First delete all the languages, then insert the ones the judge
* has selected */
$query = "DELETE FROM judges_languages WHERE judges_id='{$this->id}'";
-//mysql_query($query);
+ mysql_query($query);
print_r($data['language']);
$keys = array_keys($data['language']);
@@ -179,11 +211,28 @@ echo $query;
judges_languages (judges_id,languages_lang)
VALUES ('{$this->id}','$k')";
print("$query");
-// mysql_query($query);
-
+ mysql_query($query);
+ }
+
+ /* judges_catpref */
+ $query = "DELETE FROM judges_catpref WHERE judges_id='{$this->id}'";
+ print($query);
+ mysql_query($query);
+
+ /* Find all the catpref_[number] keys */
+ $keys = array_keys($data);
+ foreach($keys as $k) {
+ if(ereg("^catpref_([0-9]*)$", $k, $regs)) {
+ if($data[$k] == "''") continue;
+ $query = "INSERT INTO judges_catpref
+ (judges_id,projectcategories_id,rank,year)
+ values ('{$this->id}','{$regs[1]}',{$data[$k]},'{$config['FAIRYEAR']}')";
+ print($query."
\n");
+ mysql_query($query);
+
+ }
}
-
}
};
diff --git a/tableeditor.class.php b/tableeditor.class.php
index 590a64b..74b2b6b 100644
--- a/tableeditor.class.php
+++ b/tableeditor.class.php
@@ -695,12 +695,12 @@ class TableEditor
{
if(is_array($opt))
{
- if($opt['key'] == $editdata[$f]) $sel="selected=\"selected\""; else $sel="";
+ if("{$opt['key']}" == "{$editdata[$f]}") $sel="selected=\"selected\""; else $sel="";
echo "\n";
}
else
{
- if($opt == $editdata[$f]) $sel="selected=\"selected\""; else $sel="";
+ if("{$opt}" == "{$editdata[$f]}") $sel="selected=\"selected\""; else $sel="";
echo "\n";
}
}
diff --git a/tableeditor.css b/tableeditor.css
index a4904a2..f9290cb 100644
--- a/tableeditor.css
+++ b/tableeditor.css
@@ -38,7 +38,7 @@ input {
font-weight: bold;
text-align: center;
color: #FFFFFF;
- background-color: #880000;
+ background-color: #5C6F90;
padding: 3px;
}
@@ -53,7 +53,6 @@ input {
}
.tableedit {
- border-collapse: collapse;
border-spacing: 1px;
color: black;
margin-left: 20px;
@@ -63,16 +62,16 @@ input {
}
.tableedit td {
- border: 0px solid #880000;
+ border: 0px solid #5C6F90;
padding: 2px;
}
.tableedit th {
- border: 1px solid #880000;
+ border: 1px solid #5C6F90;
font-weight: bold;
text-align: left;
color: #FFFFFF;
- background-color: #880000;
+ background-color: #5C6F90;
padding: 2px;
}