4 * This page will present the HTML form to edit an entry
5 * in the cal_report table, and this page will also process the
7 * This is only used for editing the custom header/trailer.
8 * The report_id is always 0.
11 * type - "header" or "trailer"
14 * Admin permissions are checked in connect.php.
16 include_once $gfplugins.'webcalendar/www/includes/init.php';
21 $type = getValue ( "type", "S|H|T", true );
25 // Get existing value.
26 $res = dbi_query ( "SELECT cal_template_text " .
27 "FROM webcal_report_template " .
28 "WHERE cal_template_type = '$type' AND caL_report_id = 0" );
30 if ( $row = dbi_fetch_row ( $res ) ) {
34 dbi_free_result ( $res );
37 if ( empty ( $REQUEST_METHOD ) )
38 $REQUEST_METHOD = $_SERVER['REQUEST_METHOD'];
40 // Handle form submission
41 if ( $REQUEST_METHOD == 'POST' ) {
42 $template = getPostValue ( "template" );
43 //echo "Template: " . $template . "<br />\n"; exit;
45 $sql = "UPDATE webcal_report_template " .
46 "SET cal_template_text = '$template' " .
47 "WHERE cal_template_type = '$type' AND cal_report_id = 0";
49 $sql = "INSERT INTO webcal_report_template " .
50 "( cal_template_type, cal_report_id, cal_template_text ) " .
51 "VALUES ( '$type', 0, '$template' )";
53 if ( ! dbi_query ( $sql ) ) {
54 $error = translate("Database error") . ": " . dbi_error ();
56 //echo "SQL: $sql <br />\n";
57 echo "<html>\n<head>\n</head>\n<body onload=\"window.close();\">\nDone</body>\n</html>";
62 print_header( '', '', '', true );
63 //echo "report_id: $report_id <br />\n";
64 //echo "report_name: $report_name <br />\n";
65 //echo "report_user: $report_user <br />\n";
70 etranslate("Edit Custom Script/Stylesheet");
71 else if ( $type == 'H' )
72 etranslate("Edit Custom Header");
74 etranslate("Edit Custom Trailer");
78 if ( ! empty ( $error ) ) {
79 echo "<h2>" . translate("Error") . "</h2>\n" .
83 <form action="edit_template.php" method="post" name="reportform">
85 <input type="hidden" name="type" value="<?php echo $type;?>" />
86 <textarea rows="15" cols="60" name="template"><?php echo htmlspecialchars ( $cur )?></textarea>
89 <input type="button" value="<?php etranslate("Cancel")?>" onclick="window.close();" />
90 <input type="submit" value="<?php etranslate("Save")?>" />
94 print_trailer ( false, true, true );