/
addedit.php
61 lines (54 loc) · 1.57 KB
/
addedit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/* $Id: addedit.php,v 1.7 2004/06/08 15:17:19 mdeepwel Exp $ */
/* $Source: /code/convert/cvsroot/infrastructure/rats/addedit.php,v $ */
include './header.inc.php';
$perm = v('perm','add');
include 'lib/commontable.inc.php';
if($tablePerm[$perm]) {
?>
<form action="submit.php" method="POST" class="dataform">
<?php
$editData = NULL;
if($perm == 'edit') {
$idEdit = v('id');
$tableEdit = v('table');
$cols = MySQL_arrayToSequence($tableData[$tableName]['_view_cols'],FALSE,FALSE);
if(empty($tableData[$tableName]['_idkey'])) {
die("Trying to edit a table $tableName without any ID key!\n");
}
$query = $tableData[$tableName]['_view_sql_all'].' WHERE '.$tableData[$tableName]['_idkey'].'='.MySQL_quote($idEdit);
if(dodbg()) echo 'Query: '.$query."<br />\n";
global $MySQL_singleton_abort;
$editData = MySQL_singletonassoc($query);
if($editData === $MySQL_singleton_abort) {
die("Data abort! Query: $query\n");
}
echo hiddeninput(fieldName($tableName,$tableData[$tableName]['_idkey']),$idEdit);
}
echo hiddeninput('table',$tableName);
echo hiddeninput('perm',$perm);
echo "\n";
?>
<table class="dataform">
<?php
$data = NULL;
if($editData !== NULL) {
$data = $editData;
}
foreach($tableData[$tableName]['_view_cols'] as $itemkey) {
formelement($tableName,$tableData,$itemkey,$data);
}
?>
</table>
<?php
echo submitinput('submit','Submit')."\n";
?>
</form>
<?php
//TODO
} else {
echo __FILE__.' permission denied';
}
include './footer.inc.php';
/* vim: set ft=php expandtab shiftwidth=4 softtabstop=4 tabstop=4: */
?>