forked from jbuchbinder/legalcase
/
edit_rep.php
187 lines (143 loc) · 5.83 KB
/
edit_rep.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
/*
This file is part of the Legal Case Management System (LCM).
(C) 2004-2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
$Id: edit_rep.php,v 1.19 2006/08/04 21:18:34 mlutfy Exp $
*/
include('inc/inc.php');
include_lcm('inc_acc');
include_lcm('inc_filters');
if (empty($_SESSION['errors'])) {
// Clear form data
$_SESSION['form_data'] = array();
// Set the returning page
$_SESSION['form_data']['ref_edit_rep'] = _request('ref', $_SERVER['HTTP_REFERER']);
// Read input values
$_SESSION['form_data']['id_report'] = intval(_request('rep'));
// If adding new custom report
$_SESSION['form_data']['filecustom'] = _request('filecustom');
if (_session('id_report')) {
// [ML] NOTE: This is wrong. If count(errors) then this check is skipped?
// + make sure that this test is also done in 'upd_rep.php'
// Check access rights
//if (!allowed($case,'e')) die(_T('error_no_edit_permission'));
$q = "SELECT *
FROM lcm_report
WHERE id_report=" . _session('id_report');
$result = lcm_query($q);
if ($row = lcm_fetch_array($result)) {
foreach ($row as $key => $value) {
$_SESSION['form_data'][$key] = $value;
}
}
//$admin = allowed($case,'a');
} else {
// Set default values for the new report
//$_SESSION['form_data']['public'] = read_meta('case_default_read');
//$_SESSION['form_data']['pub_write'] = read_meta('case_default_write');
//$admin = true;
}
}
// Input validation
if (_session('filecustom')) {
if (! preg_match("/^[-_A-Za-z0-9]+$/", _session('filecustom')))
$_SESSION['errors']['filecustom'] = htmlspecialchars(_session('filecustom'))
. ": " . "Report file name has illegal characters"; // TRAD
elseif (! include_custom_report_exists(_session('filecustom')))
$_SESSION['errors']['filecustom'] = htmlspecialchars(_session('filecustom'))
. ": " . "Report file does not exist"; // TRAD
if ($_SESSION['errors']['filecustom'])
$_SESSION['form_data']['filecustom'] = '';
}
// Start the page with the proper title
if (_session('id_report'))
lcm_page_start(_T('title_rep_edit') . " " . _session('title'), '', '', 'reports_intro');
else
lcm_page_start(_T('title_rep_new'), '', '', 'reports_intro');
echo show_all_errors();
if ($_SESSION['form_data']['filecustom']) {
include_custom_report($_SESSION['form_data']['filecustom']);
$rep_specs = new CustomReportSpecs();
echo '<p class="normal_text">';
if (_session('id_report'))
echo "This report is using the custom report in '" . $_SESSION['form_data']['filecustom'] . "'"; // TRAD
else
echo "This report will use the custom report in '" . $_SESSION['form_data']['filecustom'] . "'"; // TRAD
echo ": " . $rep_specs->getDescription() . "</p>\n";
}
echo "<fieldset class=\"info_box\">\n";
echo "<form action='upd_rep.php' method='post'>\n";
if ($_SESSION['form_data']['filecustom']) {
echo '<input type="hidden" name="filecustom" value="' . $_SESSION['form_data']['filecustom'] . '" />' . "\n";
}
if ($_SESSION['form_data']['id_report']) {
echo "<strong>". _Ti('rep_input_id') . "</strong> " . $_SESSION['form_data']['id_report'] . "
<input type=\"hidden\" name=\"id_report\" value=\"" .
$_SESSION['form_data']['id_report'] . "\">\n";
// [ML] echo " | \n";
}
// Title of report
echo "<p>" . f_err_star('title') ."<strong>". _Ti('rep_input_title') . "</strong><br />";
echo '<input name="title" value="' . clean_output($_SESSION['form_data']['title']) . '" class="search_form_txt"></p>' . "\n";
// Description
echo '<p>' . "<strong>" . _Ti('rep_input_description') . "</strong><br />\n";
echo '<textarea name="description" rows="5" cols="40" class="frm_tarea">';
echo $_SESSION['form_data']['description'];
echo "</textarea></p>\n";
// Notes
echo '<p>' . "<strong>" . _Ti('rep_input_notes') . "</strong><br />\n";
echo '<textarea name="notes" rows="5" cols="40" class="frm_tarea">';
echo $_SESSION['form_data']['notes'];
echo "</textarea></p>\n";
// if ($admin || !read_meta('case_read_always') || !read_meta('case_write_always')) {
// echo "\t<tr><td>" . _T('public') . "</td>
// <td>
// <table>
// <tr>\n";
//
// if (!read_meta('case_read_always') || $admin) echo " <td>" . _T('read') . "</td>\n";
// if (!read_meta('case_write_always') || $admin) echo " <td>" . _T('write') . "</td>\n";
//
// echo "</tr><tr>\n";
//
// if (!read_meta('case_read_always') || $admin) {
// echo ' <td><input type="checkbox" name="public" value="yes"';
// if ($_SESSION['form_data']['public']) echo ' checked';
// echo "></td>\n";
// }
//
// if (!read_meta('case_write_always') || $admin) {
// echo ' <td><input type="checkbox" name="pub_write" value="yes"';
// if ($_SESSION['form_data']['pub_write']) echo ' checked';
// echo "></td>\n";
// }
//? > </tr>
// </table>
// </td>
// </tr>
//
//<?php
// }
//echo "</table>\n";
// Submit button
echo '<input type="hidden" name="ref_edit_rep" value="' . _session('ref_edit_rep') . '">' . "\n";
echo '<button name="submit" type="submit" value="submit" class="simple_form_btn">' . _T('button_validate') . "</button>\n";
echo '</form>' . "\n";
echo "</fieldset>";
// Clear errors
$_SESSION['errors'] = array();
$_SESSION['form_data'] = array();
$_SESSION['rep_data'] = array(); // DEPRECATED LCM 0.7.0
lcm_page_end();
?>