/[corp_html]/back/news/global.inc
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /back/news/global.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Thu Apr 11 12:53:48 2002 UTC (22 years ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +7 -1 lines
news type in separate file

1 <?
2
3 $phormationdir = "../phormation";
4 $DB = "pgsql";
5
6 //-------------------------------------------------------------------
7
8 $table="news";
9
10 $params["query"] = "select id,visible,title,town_date,date,body,pic,more,pdf,priority,type,newsletter from $table";
11 $params["defaultsort"] = "priority desc,date desc";
12 $params["key"] = "id";
13 $params["delquery"] = "delete from $table where ".$params["key"]." = ";
14
15 // delete record in database
16
17 $params["predelete_hook"] = "my_predelete_fcn";
18
19 function my_predelete_fcn( $record_id ) {
20 global $conn, $more_dir, $pdf_dir, $comm_dir;
21 $query = "select more,pdf,pic,origpic from news where id = $record_id";
22 $debug = 1;
23 $result = dbi_exec( $conn, $query );
24 if( $result && dbi_numrows( $result ) > 0 ) {
25 $array = dbi_fetch_array( $result, 0 );
26 @unlink( "$more_dir/".trim( $array[0] ) );
27 @unlink( "$pdf_dir/".trim( $array[1] ) );
28 @unlink( "$comm_dir/".trim( $array[2] ) );
29 }
30 }
31
32 // select clear file
33
34 $opts["delete_hook"] = "my_delete_fcn";
35 function my_delete_fcn( $tablename, $tablekey, $record_id ) {
36
37 my_predelete_fcn( $record_id );
38
39 deleterecord( $tablename, $tablekey, $record_id );
40 }
41
42 //-------------------------------------------------------------------
43
44 $comm_dir="/data/corp_html/comm";
45 $more_dir="/data/corp_html/news";
46 $pdf_dir="/data/corp_html/pdf";
47
48 $fields[] = "visible"; $names[] = "Visible";
49 $types[]="type=boolean&default=1";
50
51 $fields[] = "title"; $names[] = "Title";
52 $types[]="type=text&width=50&height=2&length=200&required=1";
53
54 $fields[] = "town_date"; $names[] = "Town, Date";
55 $types[]="type=text&width=50&length=100&required=1";
56
57 $fields[] = "date"; $names[] = "Date (real)";
58 $types[]="type=date&yearspan=8&default=now";
59
60 $fields[] = "priority"; $names[] = "Priority";
61 $types[]="type=text&length=2&default=0";
62
63 $fields[] = "type"; $names[] = "Type";
64 include_once("/data/corp_html/inc/news_type.inc");
65 $tmp="type=select";
66 while (list ($k, $v) = each ($news_type)) {
67 $tmp.="&map[".$k."]=".$v;
68 }
69 $tmp.="&selecttype=dropdown";
70 $types[]=$tmp;
71
72 $fields[] = "body"; $names[] = "Short text";
73 $types[]="type=text&height=10&width=50&length=5000&required=1";
74
75 $fields[] = "pic"; $names[] = "Picture";
76 $types[]="type=myfile&targetdir=$comm_dir&showfilename=1&imagemode=1&serverdir=/comm";
77
78 $fields[] = "more"; $names[] = "HTML file:";
79 $types[]="type=myfile&targetdir=$more_dir&showfilename=1";
80
81 $fields[] = "pdf"; $names[] = "PDF or PPT file:";
82 $types[]="type=myfile&targetdir=$pdf_dir&showfilename=1";
83
84 $fields[] = "newsletter"; $names[] = "Send as newsletter";
85 $types[]="type=boolean&default=1";
86
87 //-------------------------------------------------------------------
88
89 $conn = pg_connect( "dbname=corp user=dpavlin" );
90 if( !$conn ) {
91 echo "Couldn't connect to database!<BR>";
92 } else {
93 $result=pg_Exec($conn,"set datestyle = 'german'");
94 }
95
96 //-------------------------------------------------------------------
97
98 ?>

  ViewVC Help
Powered by ViewVC 1.1.26