Fixing the date entry that I broke when adding the tables
[koha.git] / edithelp.pl
blob0d20d7d7d0de0bfe557425bde5babd32b910307a
1 #!/usr/bin/perl
3 # Copyright 2007 Liblime Ltd
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
20 use strict;
21 use C4::Output;
22 use C4::Auth;
23 use CGI;
25 my $input = new CGI;
27 my $type = $input->param('type');
28 my $referer = $input->param('referer');
29 my $oldreferer = $referer;
30 my $help = $input->param('help');
31 my $error;
33 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35 template_name => "help/edithelp.tmpl",
36 query => $input,
37 type => "intranet",
38 authnotrequired => 0,
39 flagsrequired => {
40 catalogue => 1,
41 circulate => 1,
42 parameters => 1,
43 borrowers => 1,
44 permissions => 1,
45 reserveforothers => 1,
46 borrow => 1,
47 reserveforself => 1,
48 editcatalogue => 1,
49 updatecharges => 1,
51 debug => 1,
55 if ( $type eq 'addnew' ) {
56 $type = 'create';
58 elsif ( $type eq 'create' || $type eq 'save' ) {
59 $referer =~ /.*koha\/(.*)\.pl.*/;
60 my $from = "help/$1.tmpl";
61 my $htdocs = C4::Context->config('intrahtdocs');
62 # my ( $theme, $lang ) = themelanguage( $htdocs, $from, "intranet" );
63 my $theme = C4::Context->preference('template');
64 my $lang = C4::Context->preference('language') || 'en';
66 # if (! -e "$htdocs/$theme/$lang/$from") {
67 # doesnt exist
68 eval {
69 open( OUTFILE, ">$htdocs/$theme/$lang/modules/$from" ) || die "Can't open file";
71 if ($@) {
72 $error = "Cant open file $htdocs/$theme/$lang/modules/$from";
74 else {
76 # file is open write to it
77 print OUTFILE "<!-- TMPL_INCLUDE name=\"help-top.inc\" -->\n";
78 if ($type eq 'create'){
79 print OUTFILE "<div class=\"main\">\n";
81 print OUTFILE "$help\n";
82 if ($type eq 'create'){
83 print OUTFILE "</div>\n";
85 print OUTFILE "<!-- TMPL_INCLUDE name=\"help-bottom.inc\" -->\n";
86 close OUTFILE;
87 print $input->redirect("/cgi-bin/koha/help.pl?url=$oldreferer");
91 # }
94 elsif ( $type eq 'modify' ) {
96 # open file load data, kill include calls, pass data to the template
97 $referer =~ /.*koha\/(.*)\.pl.*/;
98 my $from = "help/$1.tmpl";
99 my $htdocs = C4::Context->config('intrahtdocs');
100 my ( $theme, $lang ) = themelanguage( $htdocs, $from, "intranet" );
101 eval {
102 open( INFILE, "$htdocs/$theme/$lang/modules/$from" ) || die "Can't open file";
104 if ($@) {
105 $error = "Cant open file $htdocs/$theme/$lang/modules/$from";
107 my $help;
108 while ( my $inp = <INFILE> ) {
109 if ( $inp =~ /TMPL\_INCLUDE/ ) {
111 else {
112 $help .= $inp;
115 close INFILE;
116 $template->param( 'help' => $help );
118 $type = 'save';
121 $template->param(
122 'referer' => $referer,
123 'type' => $type,
124 'error' => $error,
128 output_html_with_http_headers $input, "", $template->output;