'First Name', 'lastname' => 'Last Name', 'email' => 'Email Address', 'password' => 'Password', 'passwordexpiry' => 'Password Expiry', 'phonehome' => 'Phone (Home)', 'phonecell' => 'Phone (Cell)', 'phonework' => 'Phone (Work)', 'phoneworkext' => 'Phone Ext. (Work)', 'organization' => 'Organization', 'created' => 'Created', 'lastlogin' => 'Last Login', 'address' =>"Address 1", 'address2' =>"Address 2", 'city' => 'City', 'province' => 'Province', 'postalcode' => 'Postal Code', 'deleted' => 'Deleted', 'deleteddatetime' => 'Deleted Date/Time', 'expertise_other' => 'Other Expertise/Notes', 'complete' => "Complete"); class person { var $id; // var $fields; function person($person_id=NULL) { if($person_id == NULL) { print("Empty constructor called\n"); $this->id = FALSE; } else { print("ID $person_id construction called\n"); $this->id = $person_id; } // $this->fields = NULL; } }; class judge extends person { /* Static members for the table editor */ function tableEditorSetup($editor) { global $judges_fields; /* 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_merge($judges_fields, array( 'language' => 'Language(s)', )); $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($judge_id=NULL) { global $judges_fields; person::person($judge_id); // $this->fields = $judges_fields; } function tableEditorLoad() { $id = $this->id; print("Loading Judge ID $id\n"); $q=mysql_query("SELECT judges.* FROM judges WHERE judges.id='$id'"); echo mysql_error(); /* 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; } function tableEditorSave($data) { global $judges_fields; $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 "; } foreach($judges_fields AS $f=>$n) { if($insert_mode) $field = ''; else $field = "`$f`="; $n = $data[$f]; $query .= $field.$n.","; } //rip off the last comma $query=substr($query,0,-1); if($insertmode) { $query.=")"; } else { $query.=" WHERE id='{$this->id}'"; } echo $query; // mysql_query($query); print("data: \n"); print_r($data); print("-- \n"); /* judges_languages */ /* 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); print_r($data['language']); $keys = array_keys($data['language']); foreach($keys as $k) { $query = "INSERT INTO judges_languages (judges_id,languages_lang) VALUES ('{$this->id}','$k')"; print("$query"); // mysql_query($query); } } }; ?>