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