1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2006-2011 Artem Rodygin |
7
|
|
|
// |
8
|
|
|
// This program is free software: you can redistribute it and/or modify |
9
|
|
|
// it under the terms of the GNU General Public License as published by |
10
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
// (at your option) any later version. |
12
|
|
|
// |
13
|
|
|
// This program is distributed in the hope that it will be useful, |
14
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
// GNU General Public License for more details. |
17
|
|
|
// |
18
|
|
|
// You should have received a copy of the GNU General Public License |
19
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
// |
21
|
|
|
//------------------------------------------------------------------------------ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @package eTraxis |
25
|
|
|
* @ignore |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
/**#@+ |
29
|
|
|
* Dependency. |
30
|
|
|
*/ |
31
|
|
|
require_once('../engine/engine.php'); |
32
|
|
|
require_once('../dbo/views.php'); |
33
|
|
|
/**#@-*/ |
34
|
|
|
|
35
|
|
|
init_page(LOAD_INLINE); |
36
|
|
|
|
37
|
|
|
// new view has been submitted |
38
|
|
|
|
39
|
|
|
if (try_request('submitted') == 'createform') |
40
|
|
|
{ |
41
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are submitted.'); |
42
|
|
|
|
43
|
|
|
$view_name = ustrcut($_REQUEST['view_name'], MAX_VIEW_NAME); |
44
|
|
|
|
45
|
|
|
$error = view_validate($view_name); |
46
|
|
|
|
47
|
|
|
if ($error == NO_ERROR) |
48
|
|
|
{ |
49
|
|
|
$error = view_create($_SESSION[VAR_USERID], $view_name); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
switch ($error) |
53
|
|
|
{ |
54
|
|
|
case NO_ERROR: |
55
|
|
|
header('HTTP/1.0 200 OK'); |
56
|
|
|
break; |
57
|
|
|
|
58
|
|
|
case ERROR_INCOMPLETE_FORM: |
59
|
|
|
send_http_error(get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID)); |
60
|
|
|
break; |
61
|
|
|
|
62
|
|
|
case ERROR_ALREADY_EXISTS: |
63
|
|
|
send_http_error(get_html_resource(RES_ALERT_VIEW_ALREADY_EXISTS_ID)); |
64
|
|
|
break; |
65
|
|
|
|
66
|
|
|
default: |
67
|
|
|
send_http_error(get_html_resource(RES_ALERT_UNKNOWN_ERROR_ID)); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
exit; |
71
|
|
|
} |
72
|
|
|
else |
73
|
|
|
{ |
74
|
|
|
debug_write_log(DEBUG_NOTICE, 'Data are being requested.'); |
75
|
|
|
|
76
|
|
|
$error = NO_ERROR; |
77
|
|
|
$view_name = NULL; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
// local JS functions |
81
|
|
|
|
82
|
|
|
$resTitle = get_js_resource(RES_ERROR_ID); |
83
|
|
|
$resOK = get_js_resource(RES_OK_ID); |
84
|
|
|
|
85
|
|
|
$xml = <<<JQUERY |
86
|
|
|
<script> |
87
|
|
|
|
88
|
|
|
function createSuccess () |
89
|
|
|
{ |
90
|
|
|
closeModal(); |
91
|
|
|
reloadTab(); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
function createError (XMLHttpRequest) |
95
|
|
|
{ |
96
|
|
|
jqAlert("{$resTitle}", XMLHttpRequest.responseText, "{$resOK}"); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
</script> |
100
|
|
|
JQUERY; |
101
|
|
|
|
102
|
|
|
// generate page |
103
|
|
|
|
104
|
|
|
$xml .= '<form name="createform" action="create.php" success="createSuccess" error="createError">' |
105
|
|
|
. '<group>' |
106
|
|
|
. '<control name="view_name" required="' . get_html_resource(RES_REQUIRED3_ID) . '">' |
107
|
|
|
. '<label>' . get_html_resource(RES_VIEW_NAME_ID) . '</label>' |
108
|
|
|
. '<editbox maxlen="' . MAX_VIEW_NAME . '">' . ustr2html($view_name) . '</editbox>' |
109
|
|
|
. '</control>' |
110
|
|
|
. '</group>' |
111
|
|
|
. '<note>' . get_html_resource(RES_ALERT_REQUIRED_ARE_EMPTY_ID) . '</note>' |
112
|
|
|
. '</form>'; |
113
|
|
|
|
114
|
|
|
echo(xml2html($xml)); |
115
|
|
|
|
116
|
|
|
?> |
|
|
|
|
117
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.