|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
|
4
|
|
|
// |
|
5
|
|
|
// eTraxis - Records tracking web-based system |
|
6
|
|
|
// Copyright (C) 2005-2010 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/groups.php'); |
|
33
|
|
|
require_once('../dbo/projects.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 project exists |
|
45
|
|
|
|
|
46
|
|
|
$id = ustr2int(try_request('id')); |
|
47
|
|
|
$project = project_find($id); |
|
48
|
|
|
|
|
49
|
|
|
if (!$project) |
|
|
|
|
|
|
50
|
|
|
{ |
|
51
|
|
|
debug_write_log(DEBUG_NOTICE, 'Project cannot be found.'); |
|
52
|
|
|
exit; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
// local JS functions |
|
56
|
|
|
|
|
57
|
|
|
$resTitle = get_js_resource(RES_NEW_GROUP_ID); |
|
58
|
|
|
$resOK = get_js_resource(RES_OK_ID); |
|
59
|
|
|
$resCancel = get_js_resource(RES_CANCEL_ID); |
|
60
|
|
|
|
|
61
|
|
|
$xml = <<<JQUERY |
|
62
|
|
|
<script> |
|
63
|
|
|
|
|
64
|
|
|
function groupCreate () |
|
65
|
|
|
{ |
|
66
|
|
|
jqModal("{$resTitle}", "gcreate.php?id={$id}", "{$resOK}", "{$resCancel}", "$('#createform').submit()"); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
</script> |
|
70
|
|
|
JQUERY; |
|
71
|
|
|
|
|
72
|
|
|
// get list of groups |
|
73
|
|
|
|
|
74
|
|
|
$sort = $page = NULL; |
|
75
|
|
|
$list = groups_list($id, $sort, $page); |
|
76
|
|
|
|
|
77
|
|
|
$from = $to = 0; |
|
78
|
|
|
|
|
79
|
|
|
// generate buttons |
|
80
|
|
|
|
|
81
|
|
|
$xml .= '<button action="groupCreate()">' . get_html_resource(RES_CREATE_ID) . '</button>'; |
|
82
|
|
|
|
|
83
|
|
|
// generate list of groups |
|
84
|
|
|
|
|
85
|
|
|
if ($list->rows != 0) |
|
|
|
|
|
|
86
|
|
|
{ |
|
87
|
|
|
$bookmarks = gen_xml_bookmarks($page, $list->rows, $from, $to, 'gindex.php?id=' . $id . '&'); |
|
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
$sort1 = ($sort == 1 ? 3 : 1); |
|
90
|
|
|
$sort2 = ($sort == 2 ? 4 : 2); |
|
91
|
|
|
|
|
92
|
|
|
$xml .= '<list>' |
|
93
|
|
|
. '<hrow>' |
|
94
|
|
|
. "<hcell url=\"gindex.php?id={$id}&sort={$sort1}\">" . get_html_resource(RES_GROUP_NAME_ID) . '</hcell>' |
|
95
|
|
|
. "<hcell/>" |
|
96
|
|
|
. "<hcell url=\"gindex.php?id={$id}&sort={$sort2}\">" . get_html_resource(RES_DESCRIPTION_ID) . '</hcell>' |
|
97
|
|
|
. '</hrow>'; |
|
98
|
|
|
|
|
99
|
|
|
$list->seek($from - 1); |
|
100
|
|
|
|
|
101
|
|
|
for ($i = $from; $i <= $to; $i++) |
|
102
|
|
|
{ |
|
103
|
|
|
$row = $list->fetch(); |
|
104
|
|
|
|
|
105
|
|
|
$xml .= "<row url=\"gview.php?pid={$id}&id={$row['group_id']}\">" |
|
106
|
|
|
. '<cell>' . ustr2html($row['group_name']) . '</cell>' |
|
107
|
|
|
. '<cell>' . get_html_resource($row['is_global'] ? RES_GLOBAL_ID : RES_LOCAL_ID) . '</cell>' |
|
108
|
|
|
. '<cell>' . ustr2html($row['description']) . '</cell>' |
|
109
|
|
|
. '</row>'; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
$xml .= '</list>' |
|
113
|
|
|
. $bookmarks; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
echo(xml2html($xml)); |
|
117
|
|
|
|
|
118
|
|
|
?> |
|
|
|
|
|
|
119
|
|
|
|
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.