1 |
<? |
2 |
include_once( "global.php" ); |
3 |
include_once( "dbconnect.php" ); |
4 |
include_once( "$phormationdir/displaytable.php" ); |
5 |
|
6 |
|
7 |
$params["query"] = "select id,title,date,body,pic from community"; |
8 |
$params["defaultsort"] = "id"; |
9 |
$params["editlink"] = "community_detail.php"; |
10 |
$params["newlink"] = "community_detail.php"; |
11 |
$params["addmultiplelink"] = "community_multi.php"; |
12 |
$params["delquery"] = "delete from community where id = "; |
13 |
$params["predelete_hook"] = "my_predelete_fcn"; |
14 |
$params["key"] = "id"; |
15 |
|
16 |
function my_predelete_fcn( $record_id ) |
17 |
{ |
18 |
// since we also have to delete a photo when we delete this record, |
19 |
// we write a short function to do this. We pass the name of the function |
20 |
// to Phormation in the "params" array, so that it will call this |
21 |
// function just before deleting a record from the database. |
22 |
$query = "select pic from community where id = $record_id"; |
23 |
$result = pg_exec( $query ); |
24 |
if( $result ) { |
25 |
$array = pg_fetch_array( $result, 0 ); |
26 |
$filename = "$dir/".trim( $array[0] ); |
27 |
@unlink( $filename ); |
28 |
} |
29 |
} |
30 |
|
31 |
table_index( $fields, $names, $params ); |
32 |
?> |