1 |
<? |
2 |
include_once( "global.php" ); |
3 |
include_once( "dbconnect.php" ); |
4 |
include_once( "$phormationdir/form.php" ); |
5 |
include_once( "$phormationdir/file_upload.php" ); |
6 |
|
7 |
function html_before_form() |
8 |
{ |
9 |
?> |
10 |
<HTML> |
11 |
<HEAD> |
12 |
<link rel="stylesheet" type="text/css" href="styles.css"> |
13 |
</HEAD> |
14 |
<BODY bgcolor="#FFFFFF"> |
15 |
<? |
16 |
} |
17 |
function html_after_form() |
18 |
{ |
19 |
?> |
20 |
</BODY> |
21 |
</HTML> |
22 |
<? |
23 |
} |
24 |
|
25 |
$opts = array(); |
26 |
$opts["delete_hook"] = "my_delete_fcn"; |
27 |
$url = array(); |
28 |
$url["home"] = "index.php"; |
29 |
|
30 |
function my_delete_fcn( $tablename, $tablekey, $record_id ) |
31 |
{ |
32 |
// since we also have to delete a photo when we delete this record, |
33 |
// we write a short function to do this. We pass the name of this function |
34 |
// to Phormation in the "opts" array, so that it will call this |
35 |
// function instead of its own function for deleting the record |
36 |
$query = "select pic from news where id = $record_id"; |
37 |
$result = pg_exec( $query ); |
38 |
if( $result ) { |
39 |
$array = pg_fetch_array( $result, 0 ); |
40 |
$filename = "$dir/".trim( $array[0] ); |
41 |
@unlink( "$comm_dir/".trim( $array[0] )); |
42 |
@unlink( "$more_dir/".trim( $array[0] )); |
43 |
@unlink( "$pdf_dir/".trim( $array[0] )); |
44 |
} |
45 |
|
46 |
// now we call phormation's delete function to delete the database |
47 |
// record |
48 |
deleterecord( $tablename, $tablekey, $record_id ); |
49 |
} |
50 |
|
51 |
form_main( "news", "id", $fields, $names, $types, $record_id, $url, $opts ); |
52 |
?> |