1 |
dpavlin |
1.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,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 |
|
|
|
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 news 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 |
|
|
?> |