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 $bugsys->input_clean('usergroupid', TYPE_UINT
);
71 $db->query("DELETE FROM " . TABLE_PREFIX
. "permission WHERE usergroupid = " . $bugsys->in
['usergroupid'] . " AND productid = " . $bugsys->input_clean('productid', TYPE_UINT
));
75 $admin->redirect('permission.php?do=modify&usergroupid=' . $bugsys->in
['usergroupid']);
78 // ###################################################################
80 if ($_REQUEST['do'] == 'delete')
82 $admin->page_confirm($lang->string('Are you sure you want to revert this permission mask?'), 'permission.php?do=kill&usergroupid=' . $bugsys->input_clean('usergroupid', TYPE_UINT
) . '&productid=' . $bugsys->input_clean('productid', TYPE_UINT
));
85 // ###################################################################
87 if ($_REQUEST['do'] == 'edit')
89 $bugsys->input_clean_array(array(
90 'usergroupid' => TYPE_UINT
,
91 'productid' => TYPE_UINT
93 $perm = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "permission WHERE usergroupid = " . $bugsys->in
['usergroupid'] . " AND productid = " . $bugsys->in
['productid']);
94 $usergroup = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "usergroup WHERE usergroupid = " . $bugsys->in
['usergroupid']);
95 $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . $bugsys->in
['productid']);
97 if (!$usergroup OR !$product)
99 $admin->error($lang->getlex('error_invalid_id'));
102 $admin->page_start($lang->string('Edit Permissions'));
104 $admin->form_start('permission.php', 'update');
105 $admin->form_hidden_field('usergroupid', $usergroup['usergroupid']);
106 $admin->form_hidden_field('productid', $product['productid']);
108 // determine the value to work off of
111 $mask = $perm['mask'];
115 $mask = $usergroup['permissions'];
119 $admin->table_start();
120 $admin->table_head(sprintf($lang->string('Permissions: %1$s - %2$s'), $usergroup['title'], $product['title']), 2, 'usergroups_permissions_details');
122 foreach ($permissions AS $group => $settings)
124 $admin->row_span($group, 'thead', 'center');
125 foreach ($settings AS $setting => $name)
127 $admin->row_yesno($name, "perm[$setting]", ($mask & $_PERMISSION["$setting"]));
131 $admin->row_submit();
137 // ###################################################################
139 if ($_POST['do'] == 'update')
141 $bugsys->input_clean_array(array(
143 'usergroupid' => TYPE_UINT
,
144 'productid' => TYPE_UINT
146 foreach ($bugsys->in
['perm'] AS $permtitle => $binaryswitch)
148 $permissionvalue +
= $_PERMISSION["$permtitle"] * $binaryswitch;
152 REPLACE INTO " . TABLE_PREFIX
. "permission
153 (usergroupid, productid, mask)
155 (" . $bugsys->in
['usergroupid'] . ",
156 " . $bugsys->in
['productid'] . ",
163 $admin->redirect('permission.php?do=modify&usergroupid=' . $bugsys->in
['usergroupid']);
166 // ###################################################################
168 if ($_REQUEST['do'] == 'modify')
170 $admin->page_start($lang->string('Permission Manager'));
172 $admin->table_start();
173 $admin->table_head($lang->string('Permission Manager'), 2, 'usergroups_permissions');
175 $groups = $db->query("SELECT * FROM " . TABLE_PREFIX
. "usergroup ORDER BY usergroupid ASC");
176 while ($group = $db->fetch_array($groups))
178 $usergroups["$group[usergroupid]"] = $group;
180 $db->free_result($groups);
182 foreach ($usergroups AS $group)
184 $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');
186 if ($bugsys->in
['usergroupid'] == $group['usergroupid'])
188 $permissions_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX
. "permission WHERE usergroupid = $group[usergroupid]");
189 while ($permission = $db->fetch_array($permissions_fetch))
191 $permissions["$permission[productid]"] = $permission['mask'];
194 $products_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE !componentmother ORDER BY displayorder ASC");
195 while ($product = $db->fetch_array($products_fetch))
197 $groupid = $group['usergroupid'];
198 $prodid = $product['productid'];
200 if (!isset($permissions["$product[productid]"]))
202 $statuslink = $lang->string('Inherited From Usergroup Settings: ');
203 $statuslink .= "<a href=\"permission.php?do=edit&usergroupid=$groupid&productid=$prodid\">[" . $lang->string('Customize') . ']</a>';
207 $statuslink = $lang->string('Customized: ');
208 $statuslink .= "<a href=\"permission.php?do=edit&usergroupid=$groupid&productid=$prodid\">[" . $lang->string('Edit') . ']</a>';
209 $statuslink .= " <a href=\"permission.php?do=delete&usergroupid=$groupid&productid=$prodid\">[" . $lang->string('Revert') . ']</a>';
212 $admin->row_text($product['title'], $statuslink);
222 /*=====================================================================*\
223 || ###################################################################
226 || ###################################################################
227 \*=====================================================================*/