string('General Permissions') => array(
'canviewbugs' => $lang->string('Can View Bugs'),
'canviewhidden' => $lang->string('Can View Hidden Bugs and Comments'),
'cansubscribe' => $lang->string('Can Subscribe to Bugs'),
),
$lang->string('Posting/Submitting Permissions') => array(
'canvote' => $lang->string('Can Vote on Polls'),
'cansubmitbugs' => $lang->string('Can Submit Bugs'),
'canpostcomments' => $lang->string('Can Post Comments'),
'cangetattach' => $lang->string('Can View Attachments'),
'canputattach' => $lang->string('Can Upload/Edit Own Attachments'),
'caneditattach' => $lang->string('Can Manage All Attachments')
),
$lang->string('Moderation/Managment Permissions') => array(
'caneditown' => $lang->string('Can Edit Own Bugs'),
'caneditother' => $lang->string('Can Edit Others\' Bugs'),
'caneditownreply' => $lang->string('Can Edit Own Comments'),
'caneditotherreply' => $lang->string('Can Edit Others\' Comments'),
'canassign' => $lang->string('Can Assign Bugs'),
'canchangestatus' => $lang->string('Can Change Status')
)
);
// ###################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'modify';
}
// ###################################################################
if ($_REQUEST['do'] == 'kill')
{
$db->query("DELETE FROM " . TABLE_PREFIX . "permission WHERE usergroupid = " . intval($bugsys->in['usergroupid']) . " AND productid = " . intval($bugsys->in['productid']));
build_permissions();
$admin->redirect('permission.php?do=modify&usergroupid=' . intval($bugsys->in['usergroupid']));
}
// ###################################################################
if ($_REQUEST['do'] == 'delete')
{
$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']));
}
// ###################################################################
if ($_REQUEST['do'] == 'edit')
{
$perm = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "permission WHERE usergroupid = " . intval($bugsys->in['usergroupid']) . " AND productid = " . intval($bugsys->in['productid']));
$usergroup = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "usergroup WHERE usergroupid = " . intval($bugsys->in['usergroupid']));
$product = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = " . intval($bugsys->in['productid']));
if (!$usergroup OR !$product)
{
$admin->error($lang->getlex('error_invalid_id'));
}
$admin->page_start($lang->string('Edit Permissions'));
$admin->form_start('permission.php', 'update');
$admin->form_hidden_field('usergroupid', $usergroup['usergroupid']);
$admin->form_hidden_field('productid', $product['productid']);
// determine the value to work off of
if ($perm)
{
$mask = $perm['mask'];
}
else
{
$mask = $usergroup['permissions'];
}
// Permission
$admin->table_start();
$admin->table_head(sprintf($lang->string('Permissions: %1$s - %2$s'), $usergroup['title'], $product['title']), 2, 'usergroups_permissions_details');
foreach ($permissions AS $group => $settings)
{
$admin->row_span($group, 'thead', 'center');
foreach ($settings AS $setting => $name)
{
$admin->row_yesno($name, "perm[$setting]", ($mask & $_PERMISSION["$setting"]));
}
}
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_POST['do'] == 'update')
{
foreach ($_POST['perm'] AS $permtitle => $binaryswitch)
{
$permissionvalue += $_PERMISSION["$permtitle"] * $binaryswitch;
}
$db->query("
REPLACE INTO " . TABLE_PREFIX . "permission
(usergroupid, productid, mask)
VALUES
(" . intval($bugsys->in['usergroupid']) . ",
" . intval($bugsys->in['productid']) . ",
$permissionvalue
)"
);
build_permissions();
$ugroupid = intval($bugsys->in['usergroupid']);
$admin->redirect('permission.php?do=modify&usergroupid=' . $ugroupid);
}
// ###################################################################
if ($_REQUEST['do'] == 'modify')
{
$admin->page_start($lang->string('Permission Manager'));
$admin->table_start();
$admin->table_head($lang->string('Permission Manager'), 2, 'usergroups_permissions');
$groups = $db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup ORDER BY usergroupid ASC");
while ($group = $db->fetch_array($groups))
{
$usergroups["$group[usergroupid]"] = $group;
}
$db->free_result($groups);
foreach ($usergroups AS $group)
{
$admin->row_text($group['title'], ($bugsys->in['usergroupid'] != $group['usergroupid'] ? "[" . $lang->string('Expand') . "]" : ''), 'top', 2, 'alt3');
if ($bugsys->in['usergroupid'] == $group['usergroupid'])
{
$permissions_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "permission WHERE usergroupid = $group[usergroupid]");
while ($permission = $db->fetch_array($permissions_fetch))
{
$permissions["$permission[productid]"] = $permission['mask'];
}
$products_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !componentmother ORDER BY displayorder ASC");
while ($product = $db->fetch_array($products_fetch))
{
$groupid = $group['usergroupid'];
$prodid = $product['productid'];
if (!isset($permissions["$product[productid]"]))
{
$statuslink = $lang->string('Inherited From Usergroup Settings: ');
$statuslink .= "[" . $lang->string('Customize') . ']';
}
else
{
$statuslink = $lang->string('Customized: ');
$statuslink .= "[" . $lang->string('Edit') . ']';
$statuslink .= " [" . $lang->string('Revert') . ']';
}
$admin->row_text($product['title'], $statuslink);
}
}
}
$admin->table_end();
$admin->page_end();
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>