return array('status' => true);
}
-function delete_or_copy($mask)
+function delete_or_copy_row($table,$id)
{
- if (empty($_POST['id']))
- return array('error' => 'Missing ID');
-
- if (!empty($mask['edit_table']))
- return array('error' => 'Cannot handle deletion for secondary table');
-
if (DELETE_COPY === true) {
$sql = sprintf("INSERT INTO %s_deleted SELECT * FROM %s WHERE id = %d",
- $mask['table'], $mask['table'], $_POST['id']);
+ $table, $table, $id);
$sth = pg_query($sql);
}
$sql = sprintf("UPDATE %s_deleted SET sys_user='%s',sys_edit=now() WHERE id = %d",
- $mask['table'], $_SESSION['sys']['login'], $_POST['id']);
+ $table, $_SESSION['sys']['login'], $id);
$sth = pg_query($sql);
}
}
- $sql = sprintf("DELETE FROM %s WHERE id = %d", $mask['table'], $_POST['id']);
+ $sql = sprintf("DELETE FROM %s WHERE id = %d", $table, $_POST['id']);
$sth = pg_query($sql);
return array('status' => true);
}
+function delete_or_copy($mask)
+{
+ if (empty($_POST['id']))
+ return array('error' => 'Missing ID');
+
+ if (array_key_exists('delete', $mask))
+ return $mask['delete']($mask);
+
+ if (!empty($mask['edit_table']))
+ return array('error' => 'Cannot handle deletion for secondary table');
+
+ return delete_or_copy_row($mask['table'],$_POST['id']);
+}
+
function set_variable($name,$mask)
{
if (!array_key_exists('variables',$mask))