forked from science-ation/science-ation
- Implemented save functionality in the judge class
- Moved the tableeditor class to accept a generic class, no longer a person class - Restored the original functionality where everything is specified in the constructor, but added a 'class' which can be a dummy class to return to the original tableeditor functionality. The tableeditor checks for class->tableEditorLoad() now, and if that exists it calls it. If it doesn't then it calls a default Load() routine which contains the original code from the tableeditor. Same with save. Still needs work, but it's getting there.
This commit is contained in:
parent
4a5bc27532
commit
1a2b3d7faf
104
judge.class.php
104
judge.class.php
@ -1,21 +1,33 @@
|
|||||||
<?
|
<?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class person {
|
class person {
|
||||||
var $id;
|
var $id;
|
||||||
|
// var $fields;
|
||||||
|
|
||||||
function person($person_id) {
|
function person($person_id=NULL)
|
||||||
$this->id = $person_id;
|
{
|
||||||
|
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 {
|
class judge extends person {
|
||||||
|
|
||||||
/* Static members for the table editor */
|
/* Static members for the table editor */
|
||||||
function editor_setup($editor)
|
function tableEditorSetup($editor)
|
||||||
{
|
{
|
||||||
|
global $judges_fields;
|
||||||
/* Setup the table editor with the fields we want to display
|
/* Setup the table editor with the fields we want to display
|
||||||
* when displaying a list of judges, and also the type of each
|
* when displaying a list of judges, and also the type of each
|
||||||
* field where required */
|
* field where required */
|
||||||
@ -23,14 +35,14 @@ function editor_setup($editor)
|
|||||||
'firstname' => 'First Name',
|
'firstname' => 'First Name',
|
||||||
'lastname' => 'Last Name'
|
'lastname' => 'Last Name'
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Most of these should be moved to the base class, as they
|
/* Most of these should be moved to the base class, as they
|
||||||
* will be the same for all person groups */
|
* will be the same for all person groups */
|
||||||
$e = array( 'firstname' => 'First Name',
|
$e = array( 'firstname' => 'First Name',
|
||||||
'lastname' => 'Last Name',
|
'lastname' => 'Last Name',
|
||||||
'email' => 'Email Address',
|
'email' => 'Email Address',
|
||||||
'address' =>"Address 1",
|
'address' =>"Address 1",
|
||||||
'address2' =>"Address 2",
|
'address2' =>"Address 2",
|
||||||
'city' => 'City',
|
'city' => 'City',
|
||||||
'province' => 'Province',
|
'province' => 'Province',
|
||||||
'postalcode' => 'Postal Code',
|
'postalcode' => 'Postal Code',
|
||||||
@ -39,7 +51,7 @@ function editor_setup($editor)
|
|||||||
'organization' => 'Organization',
|
'organization' => 'Organization',
|
||||||
'language' => 'Language(s)',
|
'language' => 'Language(s)',
|
||||||
'complete' => "Complete" );
|
'complete' => "Complete" );
|
||||||
|
|
||||||
$editor->setTable('judges');
|
$editor->setTable('judges');
|
||||||
$editor->setListFields($l);
|
$editor->setListFields($l);
|
||||||
$editor->setEditFields($e);
|
$editor->setEditFields($e);
|
||||||
@ -58,13 +70,14 @@ function editor_setup($editor)
|
|||||||
/* Functions for $this */
|
/* Functions for $this */
|
||||||
|
|
||||||
|
|
||||||
function judge($judge_id)
|
function judge($judge_id=NULL)
|
||||||
{
|
{
|
||||||
|
global $judges_fields;
|
||||||
person::person($judge_id);
|
person::person($judge_id);
|
||||||
|
// $this->fields = $judges_fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
function load()
|
function tableEditorLoad()
|
||||||
{
|
{
|
||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
|
|
||||||
@ -94,8 +107,79 @@ function load()
|
|||||||
return $j;
|
return $j;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save()
|
function tableEditorSave($data)
|
||||||
{
|
{
|
||||||
|
$judges_fields = 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',
|
||||||
|
'complete' => "Complete" );
|
||||||
|
|
||||||
|
$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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,6 @@ if(!$icon_extension)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main class
|
* The main class
|
||||||
* @package tableeditor
|
* @package tableeditor
|
||||||
@ -132,7 +131,7 @@ class TableEditor
|
|||||||
* @param array $editfields
|
* @param array $editfields
|
||||||
* @param array $hiddenfields
|
* @param array $hiddenfields
|
||||||
*/
|
*/
|
||||||
function TableEditor($classname)//,$listfields,$editfields=null,$hiddenfields=null)
|
function TableEditor($classname,$listfields=null,$editfields=null,$hiddenfields=null)
|
||||||
{
|
{
|
||||||
//set defaults
|
//set defaults
|
||||||
$this->timeformat="12hrs";
|
$this->timeformat="12hrs";
|
||||||
@ -147,20 +146,23 @@ class TableEditor
|
|||||||
//grab the table
|
//grab the table
|
||||||
$this->classname=$classname;
|
$this->classname=$classname;
|
||||||
|
|
||||||
/* //grab the list fields
|
if(method_exists($this->classname, 'tableEditorSetup')) {
|
||||||
$this->listfields=$listfields;
|
call_user_func(array($this->classname, 'tableEditorSetup'), $this);
|
||||||
|
} else {
|
||||||
|
//grab the list fields
|
||||||
|
$this->listfields=$listfields;
|
||||||
|
|
||||||
|
//grab the edit fields, if there arent any, then edit==list
|
||||||
|
if($editfields)
|
||||||
|
$this->editfields=$editfields;
|
||||||
|
else
|
||||||
|
$this->editfields=$listfields;
|
||||||
|
|
||||||
|
if($hiddenfields)
|
||||||
|
$this->hiddenfields=$hiddenfields;
|
||||||
|
}
|
||||||
|
|
||||||
//grab the edit fields, if there arent any, then edit==list
|
|
||||||
if($editfields)
|
|
||||||
$this->editfields=$editfields;
|
|
||||||
else
|
|
||||||
$this->editfields=$listfields;
|
|
||||||
|
|
||||||
if($hiddenfields)
|
|
||||||
$this->hiddenfields=$hiddenfields;
|
|
||||||
*/
|
|
||||||
|
|
||||||
call_user_func(array($this->classname, editor_setup), $this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setListFields($f)
|
function setListFields($f)
|
||||||
@ -173,6 +175,10 @@ class TableEditor
|
|||||||
{
|
{
|
||||||
$this->editfields = $f;
|
$this->editfields = $f;
|
||||||
}
|
}
|
||||||
|
function setHiddenFields($f)
|
||||||
|
{
|
||||||
|
$this->hiddenfields = $f;
|
||||||
|
}
|
||||||
function setTable($t)
|
function setTable($t)
|
||||||
{
|
{
|
||||||
$this->table = $t;
|
$this->table = $t;
|
||||||
@ -395,6 +401,54 @@ class TableEditor
|
|||||||
return array($inputtype, $inputmaxlen, $inputsize);
|
return array($inputtype, $inputmaxlen, $inputsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defaultLoad()
|
||||||
|
{
|
||||||
|
$query="SELECT {$this->primaryKey}";
|
||||||
|
foreach($this->editfields AS $f=>$n)
|
||||||
|
$query.=", `$f`";
|
||||||
|
$query.=" FROM `{$this->table}`";
|
||||||
|
$query.=" WHERE {$this->primaryKey}='{$_GET['edit']}'";
|
||||||
|
if($this->DEBUG) echo $query;
|
||||||
|
$editquery=mysql_query($query);
|
||||||
|
$editdata=mysql_fetch_assoc($editquery);
|
||||||
|
return $editdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultSave($insert_mode, $editdata)
|
||||||
|
{
|
||||||
|
$query = "";
|
||||||
|
if($insert_mmode) {
|
||||||
|
$query="INSERT INTO `{$this->table}` (";
|
||||||
|
//create list of fields to insert
|
||||||
|
foreach($editdata AS $f=>$n)
|
||||||
|
$query.="`$f`,";
|
||||||
|
//rip off the last comma
|
||||||
|
$query=substr($query,0,-1);
|
||||||
|
$query.=") VALUES (";
|
||||||
|
} else {
|
||||||
|
$query="UPDATE `{$this->table}` SET ";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($this->editfields AS $f=>$n)
|
||||||
|
{
|
||||||
|
if($insert_mode) $field = '';
|
||||||
|
else $field = "`$f`=";
|
||||||
|
|
||||||
|
$query .= $field.$n.",";
|
||||||
|
}
|
||||||
|
//rip off the last comma
|
||||||
|
$query=substr($query,0,-1);
|
||||||
|
|
||||||
|
if($insertmode) {
|
||||||
|
$query.=")";
|
||||||
|
} else {
|
||||||
|
$query.=" WHERE {$this->primaryKey}='{$_POST['editsave']}'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->DEBUG) echo $query;
|
||||||
|
mysql_query($query);
|
||||||
|
}
|
||||||
|
|
||||||
function execute()
|
function execute()
|
||||||
{
|
{
|
||||||
if($_GET['TableEditorAction']=="sort" && $_GET['sort'])
|
if($_GET['TableEditorAction']=="sort" && $_GET['sort'])
|
||||||
@ -417,35 +471,21 @@ class TableEditor
|
|||||||
|| ($_POST['TableEditorAction']=="addsave") )
|
|| ($_POST['TableEditorAction']=="addsave") )
|
||||||
{
|
{
|
||||||
|
|
||||||
if($_POST['TableEditorAction']=="addsave") {
|
|
||||||
$query="INSERT INTO `{$this->table}` (";
|
|
||||||
//create list of fields to insert
|
|
||||||
foreach($this->editfields AS $f=>$n)
|
|
||||||
$query.="`$f`,";
|
|
||||||
if(count($this->hiddenfields)) {
|
|
||||||
foreach($this->hiddenfields AS $f=>$n) {
|
|
||||||
$query.="`$f`,";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//rip off the last comma
|
if($_POST['TableEditorAction']=="addsave") {
|
||||||
$query=substr($query,0,-1);
|
$data = new $this->classname();
|
||||||
$query.=") VALUES (";
|
|
||||||
$insert_mode = 1;
|
$insert_mode = 1;
|
||||||
} else {
|
} else {
|
||||||
$query="UPDATE `{$this->table}` SET ";
|
print("Insesrt mode=0\n");
|
||||||
|
$data = new $this->classname($_POST['editsave']);
|
||||||
$insert_mode = 0;
|
$insert_mode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$editdata = array();
|
||||||
|
|
||||||
print_r($_POST);
|
print_r($_POST);
|
||||||
foreach($this->editfields AS $f=>$n)
|
foreach($this->editfields AS $f=>$n)
|
||||||
{
|
{
|
||||||
if($insert_mode) {
|
|
||||||
$field = '';
|
|
||||||
} else {
|
|
||||||
$field = "`$f`=";
|
|
||||||
}
|
|
||||||
|
|
||||||
$inputtype = '';
|
$inputtype = '';
|
||||||
if(isset($_POST['tableeditor_fieldtype'])) {
|
if(isset($_POST['tableeditor_fieldtype'])) {
|
||||||
if(array_key_exists($f, $_POST['tableeditor_fieldtype'])) {
|
if(array_key_exists($f, $_POST['tableeditor_fieldtype'])) {
|
||||||
@ -453,44 +493,48 @@ class TableEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* //figure out what kind of input this should be
|
|
||||||
$q=mysql_query("SHOW COLUMNS FROM `{$this->table}` LIKE '$f'");
|
|
||||||
$r=mysql_fetch_object($q);
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($inputtype == 'date') //r->Type=="date")
|
if($inputtype == 'date') //r->Type=="date")
|
||||||
{
|
{
|
||||||
if($_POST[$f."_year"] && $_POST[$f."_month"] && $_POST[$f."_day"])
|
if($_POST[$f."_year"] && $_POST[$f."_month"] && $_POST[$f."_day"]) {
|
||||||
{
|
$editdata[$f] = "'".mysql_escape_string(stripslashes($_POST[$f."_year"]))."-".
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes($_POST[$f."_year"]))."-".
|
mysql_escape_string(stripslashes($_POST[$f."_month"]))."-".
|
||||||
mysql_escape_string(stripslashes($_POST[$f."_month"]))."-".
|
mysql_escape_string(stripslashes($_POST[$f."_day"]))."'";
|
||||||
mysql_escape_string(stripslashes($_POST[$f."_day"]))."',";
|
} else {
|
||||||
|
$editdata[$f] = 'NULL';
|
||||||
}
|
}
|
||||||
else
|
|
||||||
$query.="${field}null,";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if($inputtype == 'time') //r->Type=="time")
|
else if($inputtype == 'time') //r->Type=="time")
|
||||||
{
|
{
|
||||||
if($_POST[$f."_hour"]!="" && $_POST[$f."_minute"]!="")
|
if($_POST[$f."_hour"]!="" && $_POST[$f."_minute"]!="") {
|
||||||
{
|
$editdata[$f] = "'".mysql_escape_string(stripslashes($_POST[$f."_hour"])).":".
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes($_POST[$f."_hour"])).":".
|
mysql_escape_string(stripslashes($_POST[$f."_minute"])).":00'";
|
||||||
mysql_escape_string(stripslashes($_POST[$f."_minute"])).":00',";
|
} else {
|
||||||
|
$editdata[$f] = 'NULL';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($inputtype == 'multicheck')
|
||||||
|
{
|
||||||
|
/* This one has no direct quoted translation, hope the user specified
|
||||||
|
* a save routine to handle this */
|
||||||
|
$editdata[$f] = array();
|
||||||
|
if($_POST[$f]) {
|
||||||
|
$a = $_POST[$f];
|
||||||
|
foreach($a as $k=>$val) {
|
||||||
|
$editdata[$f][$k] = $val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
$query.="${field}null,";
|
|
||||||
}
|
}
|
||||||
else if(substr($f,0,4)=="sel_")
|
else if(substr($f,0,4)=="sel_")
|
||||||
{
|
{
|
||||||
//chose the text field first, if its been filled in, otherwise, go with the select box
|
//chose the text field first, if its been filled in, otherwise, go with the select box
|
||||||
if($_POST[$f."_text"])
|
if($_POST[$f."_text"])
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes($_POST[$f."_text"]))."',";
|
$editdata[$f] = "'".mysql_escape_string(stripslashes($_POST[$f."_text"]))."'";
|
||||||
else if($_POST[$f."_select"])
|
else if($_POST[$f."_select"])
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes($_POST[$f."_select"]))."',";
|
$editdata[$f] = "'".mysql_escape_string(stripslashes($_POST[$f."_select"]))."'";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//maybe the options were over-wridden, if so, just check the field name
|
//maybe the options were over-wridden, if so, just check the field name
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes($_POST[$f]))."',";
|
$editdata[$f] = "'".mysql_escape_string(stripslashes($_POST[$f]))."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -500,9 +544,9 @@ class TableEditor
|
|||||||
//but allow them to enter http:// or https:// themselves.
|
//but allow them to enter http:// or https:// themselves.
|
||||||
//if no protocol is given, assume http://
|
//if no protocol is given, assume http://
|
||||||
if(substr(strtolower($_POST[$f]),0,4)=="http")
|
if(substr(strtolower($_POST[$f]),0,4)=="http")
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes($_POST[$f]))."',";
|
$editdata[$f] = "'".mysql_escape_string(stripslashes($_POST[$f]))."'";
|
||||||
else
|
else
|
||||||
$query.="${field}'http://".mysql_escape_string(stripslashes($_POST[$f]))."',";
|
$editdata[$f] = "'http://".mysql_escape_string(stripslashes($_POST[$f]))."'";
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(substr($f,0,8)=="filename" && $this->uploadPath)
|
else if(substr($f,0,8)=="filename" && $this->uploadPath)
|
||||||
@ -513,7 +557,7 @@ class TableEditor
|
|||||||
if(file_exists($this->uploadPath."/".$_FILES[$f]['name']))
|
if(file_exists($this->uploadPath."/".$_FILES[$f]['name']))
|
||||||
echo error(i18n("A file with that filename already exists, it will be overwritten"));
|
echo error(i18n("A file with that filename already exists, it will be overwritten"));
|
||||||
move_uploaded_file($_FILES[$f]['tmp_name'],$this->uploadPath."/".$_FILES[$f]['name']);
|
move_uploaded_file($_FILES[$f]['tmp_name'],$this->uploadPath."/".$_FILES[$f]['name']);
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes($_FILES[$f]['name']))."',";
|
$editdata[$f] = "'".mysql_escape_string(stripslashes($_FILES[$f]['name']))."'";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -521,7 +565,7 @@ class TableEditor
|
|||||||
if(is_array($_POST['clear']))
|
if(is_array($_POST['clear']))
|
||||||
{
|
{
|
||||||
if(in_array($f,$_POST['clear']))
|
if(in_array($f,$_POST['clear']))
|
||||||
$query.="${field}NULL,";
|
$editdata[$f] = 'NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -529,9 +573,9 @@ class TableEditor
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($this->fieldValidation[$f])
|
if($this->fieldValidation[$f])
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes(ereg_replace($this->fieldValidation[$f],"",$_POST[$f])))."',";
|
$editdata[$f] = "'".mysql_escape_string(stripslashes(ereg_replace($this->fieldValidation[$f],"",$_POST[$f])))."'";
|
||||||
else
|
else
|
||||||
$query.="${field}'".mysql_escape_string(stripslashes($_POST[$f]))."',";
|
$editdata[$f] = "'".mysql_escape_string(stripslashes($_POST[$f]))."'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,26 +586,28 @@ class TableEditor
|
|||||||
{
|
{
|
||||||
//well well... sometimes we want to use a function here, such as NOW(), so if thats the case then we dont want the ' ' around the value, so, lets check for NOW() and handle it differently
|
//well well... sometimes we want to use a function here, such as NOW(), so if thats the case then we dont want the ' ' around the value, so, lets check for NOW() and handle it differently
|
||||||
if(strtolower($n)=="now()")
|
if(strtolower($n)=="now()")
|
||||||
$query.="${field}$n,";
|
$editdata[$f] = "$n";
|
||||||
else
|
else
|
||||||
$query.="${field}'$n',";
|
$editdata[$f] = "'$n'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//rip off the last comma
|
if(method_exists($data, 'tableEditorSave')) {
|
||||||
$query=substr($query,0,-1);
|
$data->tableEditorSave($editdata);
|
||||||
|
} else {
|
||||||
|
$this->defaultSave($insert_mode, $editdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if($insertmode) {
|
if($insertmode) {
|
||||||
$query.=")";
|
|
||||||
$text_error = "adding new";
|
$text_error = "adding new";
|
||||||
$text_happy = "added new";
|
$text_happy = "added new";
|
||||||
} else {
|
} else {
|
||||||
$query.=" WHERE {$this->primaryKey}='{$_POST['editsave']}'";
|
|
||||||
$text_error = "saving";
|
$text_error = "saving";
|
||||||
$text_happy = "saved";
|
$text_happy = "saved";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->DEBUG) echo $query;
|
// if($this->DEBUG) echo $query;
|
||||||
|
|
||||||
// mysql_query($query);
|
// mysql_query($query);
|
||||||
if(mysql_error())
|
if(mysql_error())
|
||||||
@ -598,17 +644,14 @@ class TableEditor
|
|||||||
echo "<h2>".i18n("Edit %1",array($this->recordType))."</h2>";
|
echo "<h2>".i18n("Edit %1",array($this->recordType))."</h2>";
|
||||||
echo "<input type=\"hidden\" name=\"TableEditorAction\" value=\"editsave\">";
|
echo "<input type=\"hidden\" name=\"TableEditorAction\" value=\"editsave\">";
|
||||||
echo "<input type=\"hidden\" name=\"editsave\" value=\"{$_GET['edit']}\">";
|
echo "<input type=\"hidden\" name=\"editsave\" value=\"{$_GET['edit']}\">";
|
||||||
$person = new $this->classname($_GET['edit']);
|
|
||||||
$e = $person->load();
|
$data = new $this->classname($_GET['edit']);
|
||||||
/* $query="SELECT {$this->primaryKey}";
|
|
||||||
foreach($this->editfields AS $f=>$n)
|
if(method_exists($data, 'tableEditorLoad')) {
|
||||||
$query.=", `$f`";
|
$editdata = $data->tableEditorLoad();
|
||||||
$query.=" FROM `{$this->table}`";
|
} else {
|
||||||
$query.=" WHERE {$this->primaryKey}='{$_GET['edit']}'";
|
$editdata = $this->defaultLoad();
|
||||||
if($this->DEBUG) echo $query;
|
}
|
||||||
$editquery=mysql_query($query);
|
|
||||||
$editdata=mysql_fetch_object($editquery);*/
|
|
||||||
$editdata = $e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<table class=\"tableedit\">";
|
echo "<table class=\"tableedit\">";
|
||||||
@ -713,6 +756,7 @@ class TableEditor
|
|||||||
}
|
}
|
||||||
echo "<input type=\"checkbox\" name=\"{$f}[$k]\" value=\"1\" $ch> {$this->fieldOptions[$f][$k]}<br>";
|
echo "<input type=\"checkbox\" name=\"{$f}[$k]\" value=\"1\" $ch> {$this->fieldOptions[$f][$k]}<br>";
|
||||||
}
|
}
|
||||||
|
echo "<input type=\"hidden\" name=\"tableeditor_fieldtype[$f]\" value=\"multicheck\">";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "date":
|
case "date":
|
||||||
|
Loading…
Reference in New Issue
Block a user