science-ation/judge.class.php
dave 373b876b1b Hacked up the editor a bit more.
- Added a "multicheck" input type for languages (english, french)
- Added a proof of concept cross reference to the judge class, it pulls the
  languages out of the judges_language database
- Completely broke the save mechanism.
- Converted the tableeditor edit routines to read from the input class
- Converted the tableeditor edit routines to use assoc arrays, instead of ->
  (easier to pull from mysql and then add cross references to it.
2006-10-11 07:21:35 +00:00

91 lines
2.0 KiB
PHP

<?
class person {
};
class judge extends person {
/* Static members for the table editor */
function editor_setup($editor)
{
/* 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 */
$l = array( 'id' => 'ID',
'firstname' => 'First Name',
'lastname' => 'Last Name'
);
/* Most of these should be moved to the base class, as they
* will be the same for all person groups */
$e = array( 'firstname' => 'First Name',
'lastname' => 'Last Name',
'email' => 'Email Address',
'address' =>"Address 1",
'address2' =>"Address 2",
'city' => 'City',
'province' => 'Province',
'postalcode' => 'Postal Code',
'phonework' => 'Phone (Work)',
'phonecell' => 'Phone (Cell)',
'organization' => 'Organization',
'language' => 'Language(s)',
'complete' => "Complete" );
$editor->setTable('judges');
$editor->setListFields($l);
$editor->setEditFields($e);
/* 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');
}
/* Functions for $this */
function judge()
{
}
function load($id)
{
$q=mysql_query("SELECT judges.*
FROM judges
WHERE judges.id='$id'");
echo mysql_error();
print("Loading Judge ID $id\n");
/* We assume that the field names in the array we want to return
* are the same as those in the database, so we'll turn the entire
* query into a single associative array */
$j = mysql_fetch_assoc($q);
/* Now turn on the ones this judge has selected */
$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;
}
print_r($j);
return $j;
}
};
?>