|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
|
4
|
|
|
// |
|
5
|
|
|
// eTraxis - Records tracking web-based system |
|
6
|
|
|
// Copyright (C) 2005-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/projects.php'); |
|
33
|
|
|
require_once('../dbo/templates.php'); |
|
34
|
|
|
/**#@-*/ |
|
35
|
|
|
|
|
36
|
|
|
init_page(LOAD_TAB); |
|
37
|
|
|
|
|
38
|
|
|
if (get_user_level() != USER_LEVEL_ADMIN) |
|
39
|
|
|
{ |
|
40
|
|
|
debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.'); |
|
41
|
|
|
exit; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
// check that requested template exists |
|
45
|
|
|
|
|
46
|
|
|
$id = ustr2int(try_request('id')); |
|
47
|
|
|
$template = template_find($id); |
|
48
|
|
|
|
|
49
|
|
|
if (!$template) |
|
|
|
|
|
|
50
|
|
|
{ |
|
51
|
|
|
debug_write_log(DEBUG_NOTICE, 'Template cannot be found.'); |
|
52
|
|
|
exit; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
// local JS functions |
|
56
|
|
|
|
|
57
|
|
|
$resTitle = ustrprocess(get_js_resource(RES_TEMPLATE_X_ID), ustr2js($template['template_name'])); |
|
58
|
|
|
$resClone = get_js_resource(RES_CLONE_ID); |
|
59
|
|
|
$resOK = get_js_resource(RES_OK_ID); |
|
60
|
|
|
$resCancel = get_js_resource(RES_CANCEL_ID); |
|
61
|
|
|
|
|
62
|
|
|
$xml = <<<JQUERY |
|
63
|
|
|
<script> |
|
64
|
|
|
|
|
65
|
|
|
function templateModify () |
|
66
|
|
|
{ |
|
67
|
|
|
jqModal("{$resTitle}", "tmodify.php?id={$id}", "{$resOK}", "{$resCancel}", "$('#modifyform').submit()"); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
function templateClone () |
|
71
|
|
|
{ |
|
72
|
|
|
jqModal("{$resClone}", "tclone.php?id={$id}", "{$resOK}", "{$resCancel}", "$('#cloneform').submit()"); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
function templateLock () |
|
76
|
|
|
{ |
|
77
|
|
|
$.post("tlock.php?id={$id}", function() { |
|
78
|
|
|
reloadTab(); |
|
79
|
|
|
}); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
</script> |
|
83
|
|
|
JQUERY; |
|
84
|
|
|
|
|
85
|
|
|
// generate buttons |
|
86
|
|
|
$rs = dal_query('templates/count.sql'); |
|
87
|
|
|
|
|
88
|
|
|
$xml .= '<button url="view.php?id=' . $template['project_id'] . '&tab=3">' . get_html_resource(RES_BACK_ID) . '</button>' |
|
89
|
|
|
. '<button url="texport.php?id=' . $id . '">' . get_html_resource(RES_EXPORT_ID) . '</button>' |
|
90
|
|
|
. '<buttonset>' |
|
91
|
|
|
. '<button action="templateModify()">' . get_html_resource(RES_MODIFY_ID) . '</button>' |
|
92
|
|
|
. (MAX_TEMPLATES_NUMBER == 0 || $rs->fetch(0) < MAX_TEMPLATES_NUMBER |
|
93
|
|
|
? '<button action="templateClone()">' |
|
94
|
|
|
: '<button disabled="true">') |
|
95
|
|
|
. get_html_resource(RES_CLONE_ID) |
|
96
|
|
|
. '</button>' |
|
97
|
|
|
. (is_template_removable($id) && $template['is_locked'] |
|
98
|
|
|
? '<button url="tdelete.php?id=' . $id . '" prompt="' . get_html_resource(RES_CONFIRM_DELETE_TEMPLATE_ID) . '">' |
|
99
|
|
|
: '<button disabled="false">') |
|
100
|
|
|
. get_html_resource(RES_DELETE_ID) |
|
101
|
|
|
. '</button>' |
|
102
|
|
|
. '<button action="templateLock()">' |
|
103
|
|
|
. get_html_resource($template['is_locked'] ? RES_UNLOCK_ID : RES_LOCK_ID) |
|
104
|
|
|
. '</button>' |
|
105
|
|
|
. '</buttonset>'; |
|
106
|
|
|
|
|
107
|
|
|
// generate template information |
|
108
|
|
|
|
|
109
|
|
|
$xml .= '<group title="' . get_html_resource(RES_TEMPLATE_INFO_ID) . '">' |
|
110
|
|
|
. '<text label="' . get_html_resource(RES_TEMPLATE_NAME_ID) . '">' . ustr2html($template['template_name']) . '</text>' |
|
111
|
|
|
. '<text label="' . get_html_resource(RES_TEMPLATE_PREFIX_ID) . '">' . ustr2html($template['template_prefix']) . '</text>' |
|
112
|
|
|
. '<text label="' . get_html_resource(RES_CRITICAL_AGE_ID) . '">' . (is_null($template['critical_age']) ? get_html_resource(RES_NONE_ID) : $template['critical_age']) . '</text>' |
|
113
|
|
|
. '<text label="' . get_html_resource(RES_FROZEN_TIME_ID) . '">' . (is_null($template['frozen_time']) ? get_html_resource(RES_NONE_ID) : $template['frozen_time']) . '</text>' |
|
114
|
|
|
. '<text label="' . get_html_resource(RES_DESCRIPTION_ID) . '">' . ustr2html($template['description']) . '</text>' |
|
115
|
|
|
. '<text label="' . get_html_resource(RES_GUEST_ACCESS_ID) . '">' . get_html_resource($template['guest_access'] ? RES_YES_ID : RES_NO_ID) . '</text>' |
|
116
|
|
|
. '<text label="' . get_html_resource(RES_STATUS_ID) . '">' . get_html_resource($template['is_locked'] ? RES_LOCKED_ID : RES_ACTIVE_ID) . '</text>' |
|
117
|
|
|
. '</group>'; |
|
118
|
|
|
|
|
119
|
|
|
echo(xml2html($xml)); |
|
120
|
|
|
|
|
121
|
|
|
?> |
|
|
|
|
|
|
122
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.