2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 require_once('./global.php');
14 require_once('./includes/functions_datastore.php');
16 if (!can_perform('canadmingroups'))
21 // ###################################################################
22 // define permissions as groups
25 $lang->string('General Permissions') => array(
26 'canviewbugs' => $lang->string('Can View Bugs'),
27 'canviewhidden' => $lang->string('Can View Hidden Bugs and Comments'),
28 'cansearch' => $lang->string('Can Search Bugs'),
29 'cansubscribe' => $lang->string('Can Subscribe to Bugs'),
30 'canbeassignedto' => $lang->string('Can Be Assigned Bugs')
33 $lang->string('Posting/Submitting Permissions') => array(
34 'canvote' => $lang->string('Can Vote on Polls'),
35 'cansubmitbugs' => $lang->string('Can Submit Bugs'),
36 'canpostcomments' => $lang->string('Can Post Comments'),
37 'cangetattach' => $lang->string('Can View Attachments'),
38 'canputattach' => $lang->string('Can Upload/Edit Own Attachments'),
39 'caneditattach' => $lang->string('Can Manage All Attachments')
42 $lang->string('Moderation/Managment Permissions') => array(
43 'caneditown' => $lang->string('Can Edit Own Bugs'),
44 'caneditothers' => $lang->string('Can Edit Others\' Bugs'),
45 'caneditinfo' => $lang->string('Can Edit Bug Information'),
46 'canassign' => $lang->string('Can Assign Bugs'),
47 'canchangestatus' => $lang->string('Can Change Status')
50 $lang->string('Administrator Permissions') => array(
51 'canadminpanel' => $lang->string('Can Access Control Panel'),
52 'canadminbugs' => $lang->string('Can Administer Bug Reports'),
53 'canadminfields' => $lang->string('Can Administer Additional Bug Fields'),
54 'canadminversions' => $lang->string('Can Administer Products / Components / Versions'),
55 'canadminusers' => $lang->string('Can Administer Users'),
56 'canadmingroups' => $lang->string('Can Administer Usergroups'),
57 'canadmintools' => $lang->string('Can Administer Settings / Maintenance Tools')
61 // ###################################################################
63 if (empty($_REQUEST['do']))
65 $_REQUEST['do'] = 'modify';
68 // ###################################################################
70 if ($_REQUEST['do'] == 'kill')
72 if ($bugsys->in
['usergroupid'] < 7)
74 $admin->error($lang->string('You can\'t delete a default usergroup.'));
77 $db->query("DELETE FROM " . TABLE_PREFIX
. "usergroup WHERE usergroupid = " . intval($bugsys->in
['usergroupid']));
78 $db->query("UPDATE " . TABLE_PREFIX
. "user SET usergroupid = 2 WHERE usergroupid = " . intval($bugsys->in
['usergroupid']));
83 $admin->redirect('usergroup.php?do=modify');
86 // ###################################################################
88 if ($_REQUEST['do'] == 'delete')
90 if ($bugsys->in
['usergroupid'] < 7)
92 $admin->error($lang->string('You can\'t delete a default usergroup.'));
95 $admin->page_confirm($lang->string('Are you sure you want to delete this usergroup? All users in this group will be set back to the default registered usergroup (id: 2).'), 'usergroup.php?do=kill&usergroupid=' . intval($bugsys->in
['usergroupid']));
98 // ###################################################################
100 if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
102 $add = (($_REQUEST['do'] == 'add') ? true : false);
103 $edit = (($_REQUEST['do'] == 'edit') ? true : false);
105 $admin->page_start(($add ? $lang->string('New Usergroup') : $lang->string('Edit Usergroup')));
107 $admin->form_start('usergroup.php', ($add ? 'insert' : 'update'));
111 $usergroup = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "usergroup WHERE usergroupid = " . intval($bugsys->in
['usergroupid']));
112 if (!is_array($usergroup))
114 $admin->error($lang->getlex('error_invalid_id'));
117 $admin->form_hidden_field('usergroupid', $usergroup['usergroupid']);
121 $usergroup['permissions'] = 319;
125 $admin->table_start();
126 $admin->table_head($lang->string('Usergroup Details'));
127 $admin->row_input($lang->string('Usergroup Title'), 'title', $bugsys->sanitize($usergroup['title']));
128 $admin->row_input($lang->string('Display Title<div><dfn>This is the title that others will be able to see when comments are posted.</dfn></div>'), 'displaytitle', $bugsys->sanitize($usergroup['displaytitle']));
129 $admin->row_input($lang->string('Opening Tag Markup<div><dfn>Place all open HTML tags here that will be wrapped around the username.</dfn></div>'), 'opentag', $bugsys->sanitize($usergroup['opentag']));
130 $admin->row_input($lang->string('Closing Tag Markup<div><dfn>Place all closed HTML tags that will close any open HTML tags entered above.</dfn></div>'), 'closetag', $bugsys->sanitize($usergroup['closetag']));
134 $admin->table_start();
136 $admin->table_head($lang->string('Permission Settings'));
138 foreach ($permissions AS $group => $settings)
140 $admin->row_span($group, 'thead', 'center');
141 foreach ($settings AS $setting => $name)
143 $admin->row_yesno($name, "perm[$setting]", ($usergroup['permissions'] & $_PERMISSION["$setting"]));
149 // custom field permissions
150 $admin->table_start();
151 $admin->table_head($lang->string('Custom Field Permissions'));
155 $perms = $db->query("SELECT fieldid
, mask FROM
" . TABLE_PREFIX . "bugfieldpermission WHERE usergroupid
= $usergroup[usergroupid
]");
156 while ($perm = $db->fetch_array($perms))
158 $permissions["$perm[fieldid
]"] = $perm['mask'];
162 $fields = $db->query("SELECT fieldid
, name FROM
" . TABLE_PREFIX . "bugfield ORDER BY fieldid
");
163 while ($field = $db->fetch_array($fields))
166 $admin->list_item($lang->string('No Permission'), 0, $permissions["$field[fieldid
]"] == 0);
167 $admin->list_item($lang->string('Can View Field'), 1, $permissions["$field[fieldid
]"] == 1);
168 $admin->list_item($lang->string('Can View, Edit Field'), 2, $permissions["$field[fieldid
]"] == 2);
169 $admin->row_list($field['name'], "custom
[$field[fieldid
]]");
175 $admin->table_start();
176 $admin->row_submit();
184 // ###################################################################
186 if ($_POST['do'] == 'insert')
188 foreach ($_POST['perm'] AS $permtitle => $binaryswitch)
190 $permissionvalue += $_PERMISSION["$permtitle"] * $binaryswitch;
194 INSERT INTO " . TABLE_PREFIX
. "usergroup
195 (title, displaytitle, opentag, closetag, permissions)
197 ('" . $bugsys->in
['title'] . "', '" . $bugsys->in
['displaytitle'] . "',
198 '" . $bugsys->in
['opentag'] . "', '" . $bugsys->in
['closetag'] . "',
203 $ugroupid = $db->insert_id();
207 foreach ($_POST['custom'] AS $fieldid => $mask)
209 $values[] = "$ugroupid, " . intval($fieldid) . ", " . intval($mask);
213 INSERT INTO " . TABLE_PREFIX
. "bugfieldpermission
214 (usergroupid, fieldid, mask)
216 (" . implode("\n\t\t\t", $values) . "
220 $admin->redirect('usergroup.php?do=modify');
223 // ###################################################################
225 if ($_POST['do'] == 'update')
227 foreach ($_POST['perm'] AS $permtitle => $binaryswitch)
229 $permissionvalue +
= $_PERMISSION["$permtitle"] * $binaryswitch;
233 UPDATE
" . TABLE_PREFIX . "usergroup
234 SET title
= '" . $bugsys->in['title
'] . "',
235 displaytitle
= '" . $bugsys->in['displaytitle
'] . "',
236 opentag
= '" . $bugsys->unsanitize($bugsys->in['opentag
']) . "',
237 closetag
= '" . $bugsys->unsanitize($bugsys->in['closetag
']) . "',
238 permissions
= $permissionvalue
239 WHERE usergroupid
= " . intval($bugsys->in['usergroupid'])
245 $ugroupid = intval($bugsys->in['usergroupid']);
246 foreach ($_POST['custom'] AS $fieldid => $mask)
248 $values[] = "$ugroupid, " . intval($fieldid) . ", " . intval($mask);
252 REPLACE INTO
" . TABLE_PREFIX . "bugfieldpermission
253 (usergroupid
, fieldid
, mask
)
255 (" . implode("),\n\t\t\t(", $values) . ")"
259 $admin->redirect('usergroup.php?do=modify');
262 // ###################################################################
264 if ($_REQUEST['do'] == 'modify')
266 $admin->page_start($lang->string('Usergroup Manager'));
268 $admin->form_start('usergroup.php', 'null');
269 $admin->table_start();
270 $admin->table_head($lang->string('Usergroup Manager'), 3);
272 $groups = $db->query("SELECT
* FROM
" . TABLE_PREFIX . "usergroup ORDER BY usergroupid ASC
");
273 while ($group = $db->fetch_array($groups))
275 $usergroups["$group[usergroupid
]"] = $group;
277 $db->free_result($groups);
279 $groups = $db->query("
280 SELECT
COUNT(user
.userid
) AS total
, user
.usergroupid
281 FROM
" . TABLE_PREFIX . "user
AS user
282 LEFT JOIN
" . TABLE_PREFIX . "usergroup
AS usergroup
USING (usergroupid
)
283 GROUP BY usergroup
.usergroupid
284 ORDER BY usergroup
.usergroupid
"
286 while ($group = $db->fetch_array($groups))
288 $usergroups["$group[usergroupid
]"]['total'] = $group['total'];
291 $admin->table_column_head(array($lang->string('Usergroup'), $lang->string('Number of Users'), $lang->string('Action')));
292 foreach ($usergroups AS $group)
294 $admin->row_multi_item(array("<a href
=\"usergroup
.php
?do=edit
&
;usergroupid
=$group[usergroupid
]\">$group[title
]</a
>" => 'l', ((!$group['total']) ? '-' : $group['total']) => 'c', "<a href
=\"usergroup
.php
?do=edit
&
;usergroupid
=$group[usergroupid
]\">[" . $lang->string('Edit') . "]</a
>" . (($group['usergroupid'] > 6) ? "<a href
=\"usergroup
.php
?do=delete
&
;usergroupid
=$group[usergroupid
]\">[" . $lang->string('Delete') . "]</a
>" : '') => 'c'));
297 $admin->row_span('<a href="usergroup
.php
?do=add
">[' . $lang->string('Add New Usergroup') . ']</a>', 'tfoot', 'center', 3);
304 /*=====================================================================*\
305 || ###################################################################
308 || ###################################################################
309 \*=====================================================================*/