2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 require_once('./global.php');
23 require_once('./includes/functions_datastore.php');
25 if (!can_perform('canadmingroups'))
30 // ###################################################################
31 // define permissions as groups
34 $lang->string('General Permissions') => array(
35 'canviewbugs' => $lang->string('Can View Bugs'),
36 'canviewhidden' => $lang->string('Can View Hidden Bugs and Comments'),
37 'cansubscribe' => $lang->string('Can Subscribe to Bugs'),
40 $lang->string('Posting/Submitting Permissions') => array(
41 'canvote' => $lang->string('Can Vote on Polls'),
42 'cansubmitbugs' => $lang->string('Can Submit Bugs'),
43 'canpostcomments' => $lang->string('Can Post Comments'),
44 'cangetattach' => $lang->string('Can View Attachments'),
45 'canputattach' => $lang->string('Can Upload/Edit Own Attachments'),
46 'caneditattach' => $lang->string('Can Manage All Attachments')
49 $lang->string('Moderation/Managment Permissions') => array(
50 'caneditown' => $lang->string('Can Edit Own Bugs'),
51 'caneditother' => $lang->string('Can Edit Others\' Bugs'),
52 'caneditownreply' => $lang->string('Can Edit Own Comments'),
53 'caneditotherreply' => $lang->string('Can Edit Others\' Comments'),
54 'canassign' => $lang->string('Can Assign Bugs'),
55 'canchangestatus' => $lang->string('Can Change Status')
59 // ###################################################################
61 if (empty($_REQUEST['do']))
63 $_REQUEST['do'] = 'modify';
66 // ###################################################################
68 if ($_REQUEST['do'] == 'kill')
70 $db->query("DELETE FROM " . TABLE_PREFIX
. "permission WHERE usergroupid = " . intval($bugsys->in
['usergroupid']) . " AND productid = " . intval($bugsys->in
['productid']));
74 $admin->redirect('permission.php?do=modify&usergroupid=' . intval($bugsys->in
['usergroupid']));
77 // ###################################################################
79 if ($_REQUEST['do'] == 'delete')
81 $admin->page_confirm($lang->string('Are you sure you want to revert this permission mask?'), 'permission.php?do=kill&usergroupid=' . intval($bugsys->in
['usergroupid']) . '&productid=' . intval($bugsys->in
['productid']));
84 // ###################################################################
86 if ($_REQUEST['do'] == 'edit')
88 $perm = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "permission WHERE usergroupid = " . intval($bugsys->in
['usergroupid']) . " AND productid = " . intval($bugsys->in
['productid']));
89 $usergroup = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "usergroup WHERE usergroupid = " . intval($bugsys->in
['usergroupid']));
90 $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']));
92 if (!$usergroup OR !$product)
94 $admin->error($lang->getlex('error_invalid_id'));
97 $admin->page_start($lang->string('Edit Permissions'));
99 $admin->form_start('permission.php', 'update');
100 $admin->form_hidden_field('usergroupid', $usergroup['usergroupid']);
101 $admin->form_hidden_field('productid', $product['productid']);
103 // determine the value to work off of
106 $mask = $perm['mask'];
110 $mask = $usergroup['permissions'];
114 $admin->table_start();
115 $admin->table_head(sprintf($lang->string('Permissions: %1$s - %2$s'), $usergroup['title
'], $product['title
']), 2, 'usergroups_permissions_details
');
117 foreach ($permissions AS $group => $settings)
119 $admin->row_span($group, 'thead
', 'center
');
120 foreach ($settings AS $setting => $name)
122 $admin->row_yesno($name, "perm[$setting]", ($mask & $_PERMISSION["$setting"]));
126 $admin->row_submit();
132 // ###################################################################
134 if ($_POST['do'] == 'update
')
136 foreach ($_POST['perm
'] AS $permtitle => $binaryswitch)
138 $permissionvalue += $_PERMISSION["$permtitle"] * $binaryswitch;
142 REPLACE INTO " . TABLE_PREFIX . "permission
143 (usergroupid, productid, mask)
145 (" . intval($bugsys->in['usergroupid
']) . ",
146 " . intval($bugsys->in['productid
']) . ",
153 $ugroupid = intval($bugsys->in['usergroupid
']);
155 $admin->redirect('permission
.php
?do=modify
&usergroupid
=' . $ugroupid);
158 // ###################################################################
160 if ($_REQUEST['do'] == 'modify
')
162 $admin->page_start($lang->string('Permission Manager
'));
164 $admin->table_start();
165 $admin->table_head($lang->string('Permission Manager
'), 2, 'usergroups_permissions
');
167 $groups = $db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup ORDER BY usergroupid ASC");
168 while ($group = $db->fetch_array($groups))
170 $usergroups["$group[usergroupid]"] = $group;
172 $db->free_result($groups);
174 foreach ($usergroups AS $group)
176 $admin->row_text($group['title
'], ($bugsys->in['usergroupid
'] != $group['usergroupid
'] ? "<a href=\"permission.php?do=modify&usergroupid=$group[usergroupid]\">[" . $lang->string('Expand
') . "]</a>" : ''), 'top
', 2, 'alt3
');
178 if ($bugsys->in['usergroupid
'] == $group['usergroupid
'])
180 $permissions_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "permission WHERE usergroupid = $group[usergroupid]");
181 while ($permission = $db->fetch_array($permissions_fetch))
183 $permissions["$permission[productid]"] = $permission['mask
'];
186 $products_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !componentmother ORDER BY displayorder ASC");
187 while ($product = $db->fetch_array($products_fetch))
189 $groupid = $group['usergroupid
'];
190 $prodid = $product['productid
'];
192 if (!isset($permissions["$product[productid]"]))
194 $statuslink = $lang->string('Inherited From Usergroup Settings
: ');
195 $statuslink .= "<a href=\"permission.php?do=edit&usergroupid=$groupid&productid=$prodid\">[" . $lang->string('Customize
') . ']</a
>';
199 $statuslink = $lang->string('Customized
: ');
200 $statuslink .= "<a href=\"permission.php?do=edit&usergroupid=$groupid&productid=$prodid\">[" . $lang->string('Edit
') . ']</a
>';
201 $statuslink .= " <a href=\"permission.php?do=delete&usergroupid=$groupid&productid=$prodid\">[" . $lang->string('Revert
') . ']</a
>';
204 $admin->row_text($product['title
'], $statuslink);
214 /*=====================================================================*\
215 || ###################################################################
218 || ###################################################################
219 \*=====================================================================*/