forked from science-ation/science-ation
- Implement judge insert and delete. Still needs work, the "delete" should
only remove the judge from the current year. The editor needs a field to say if the judge is registered for the current year or not. - Delete also needs to somehow express that the judge will be deleted for the current year only. Which means we should probably implement a Purge, to completely wipe a judge out of the system.
This commit is contained in:
parent
e2e1f3433c
commit
3a4d919691
@ -276,6 +276,20 @@ function tableEditorSave($data)
|
||||
|
||||
}
|
||||
|
||||
function tableEditorDelete()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$id = $this->id;
|
||||
|
||||
mysql_query("DELETE FROM judges_teams_link WHERE judges_id='$id' AND year=".$config['FAIRYEAR']."'");
|
||||
mysql_query("DELETE FROM judges_years WHERE judges_id='$id' AND year='".$config['FAIRYEAR']."'");
|
||||
|
||||
echo happy(i18n("Successfully removed judge from this year's fair"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
|
@ -414,7 +414,7 @@ class TableEditor
|
||||
return $editdata;
|
||||
}
|
||||
|
||||
function defaultSave($insert_mode, $editdata)
|
||||
function defaultSave($insert_mode, $keyval, $editdata)
|
||||
{
|
||||
$query = "";
|
||||
if($insert_mmode) {
|
||||
@ -442,13 +442,19 @@ class TableEditor
|
||||
if($insertmode) {
|
||||
$query.=")";
|
||||
} else {
|
||||
$query.=" WHERE {$this->primaryKey}='{$_POST['editsave']}'";
|
||||
$query.=" WHERE {$this->primaryKey}='{$keyval}'";
|
||||
}
|
||||
|
||||
if($this->DEBUG) echo $query;
|
||||
mysql_query($query);
|
||||
}
|
||||
|
||||
function defaultDelete($keyval)
|
||||
{
|
||||
mysql_query("DELETE FROM {$this->table} WHERE {$this->primaryKey}='{$keyval}'");
|
||||
echo happy(i18n("Successfully deleted %1",array($this->recordType)));
|
||||
}
|
||||
|
||||
function execute()
|
||||
{
|
||||
if($_GET['TableEditorAction']=="sort" && $_GET['sort'])
|
||||
@ -458,8 +464,12 @@ class TableEditor
|
||||
|
||||
if($_GET['TableEditorAction']=="delete" && $_GET['delete'])
|
||||
{
|
||||
mysql_query("DELETE FROM {$this->table} WHERE {$this->primaryKey}='{$_GET['delete']}'");
|
||||
echo happy(i18n("Successfully deleted %1",array($this->recordType)));
|
||||
$data = new $this->classname($_GET['delete']);
|
||||
if(method_exists($data, 'tableEditorDelete')) {
|
||||
$data->tableEditorDelete();
|
||||
} else {
|
||||
$this->defaultDelete($_GET['delete']);
|
||||
}
|
||||
}
|
||||
|
||||
if($_GET['TableEditorAction']=="page" && $_GET['page'])
|
||||
@ -470,8 +480,6 @@ class TableEditor
|
||||
if( ($_POST['TableEditorAction']=="editsave" && $_POST['editsave'])
|
||||
|| ($_POST['TableEditorAction']=="addsave") )
|
||||
{
|
||||
|
||||
|
||||
if($_POST['TableEditorAction']=="addsave") {
|
||||
$data = new $this->classname();
|
||||
$insert_mode = 1;
|
||||
@ -595,7 +603,8 @@ class TableEditor
|
||||
if(method_exists($data, 'tableEditorSave')) {
|
||||
$data->tableEditorSave($editdata);
|
||||
} else {
|
||||
$this->defaultSave($insert_mode, $editdata);
|
||||
$keyval = ($insert_mode == 0) ? $_POST['editsave'] : 0;
|
||||
$this->defaultSave($insert_mode, $keyval, $editdata);
|
||||
}
|
||||
|
||||
|
||||
@ -756,10 +765,11 @@ class TableEditor
|
||||
case "multicheck":
|
||||
$ks = array_keys($this->fieldOptions[$f]);
|
||||
foreach($ks as $k) {
|
||||
if(array_key_exists($k, $editdata[$f])) {
|
||||
$ch = ' checked=checked ';
|
||||
} else {
|
||||
$ch = '';
|
||||
$ch = '';
|
||||
if(is_array($editdata[$f])) {
|
||||
if(array_key_exists($k, $editdata[$f])) {
|
||||
$ch = ' checked=checked ';
|
||||
}
|
||||
}
|
||||
echo "<input type=\"checkbox\" name=\"{$f}[$k]\" value=\"1\" $ch> {$this->fieldOptions[$f][$k]}<br>";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user