string('General Permissions') => array(
'canviewbugs' => $lang->string('Can View Bugs'),
'canviewhidden' => $lang->string('Can View Hidden Bugs and Comments'),
'cansearch' => $lang->string('Can Search Bugs'),
'cansubscribe' => $lang->string('Can Subscribe to Bugs'),
'canbeassignedto' => $lang->string('Can Be Assigned 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'),
'caneditothers' => $lang->string('Can Edit Others\' Bugs'),
'caneditinfo' => $lang->string('Can Edit Bug Information'),
'canassign' => $lang->string('Can Assign Bugs'),
'canchangestatus' => $lang->string('Can Change Status')
),
$lang->string('Administrator Permissions') => array(
'canadminpanel' => $lang->string('Can Access Control Panel'),
'canadminbugs' => $lang->string('Can Administer Bug Reports'),
'canadminfields' => $lang->string('Can Administer Additional Bug Fields'),
'canadminversions' => $lang->string('Can Administer Products / Components / Versions'),
'canadminusers' => $lang->string('Can Administer Users'),
'canadmingroups' => $lang->string('Can Administer Usergroups'),
'canadmintools' => $lang->string('Can Administer Settings / Maintenance Tools')
)
);
// ###################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'modify';
}
// ###################################################################
if ($_REQUEST['do'] == 'kill')
{
if ($bugsys->in['usergroupid'] < 7)
{
$admin->error($lang->string('You can\'t delete a default usergroup.'));
}
$db->query("DELETE FROM " . TABLE_PREFIX . "usergroup WHERE usergroupid = " . intval($bugsys->in['usergroupid']));
$db->query("UPDATE " . TABLE_PREFIX . "user SET usergroupid = 2 WHERE usergroupid = " . intval($bugsys->in['usergroupid']));
build_usergroups();
build_assignedto();
$admin->redirect('usergroup.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'delete')
{
if ($bugsys->in['usergroupid'] < 7)
{
$admin->error($lang->string('You can\'t delete a default usergroup.'));
}
$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']));
}
// ###################################################################
if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
{
$add = (($_REQUEST['do'] == 'add') ? true : false);
$edit = (($_REQUEST['do'] == 'edit') ? true : false);
$admin->page_start(($add ? $lang->string('New Usergroup') : $lang->string('Edit Usergroup')));
$admin->form_start('usergroup.php', ($add ? 'insert' : 'update'));
if ($edit)
{
$usergroup = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "usergroup WHERE usergroupid = " . intval($bugsys->in['usergroupid']));
if (!is_array($usergroup))
{
$admin->error($lang->getlex('error_invalid_id'));
}
$admin->form_hidden_field('usergroupid', $usergroup['usergroupid']);
}
else
{
$usergroup['permissions'] = 319;
}
// Details
$admin->table_start();
$admin->table_head($lang->string('Usergroup Details'));
$admin->row_input($lang->string('Usergroup Title'), 'title', $bugsys->sanitize($usergroup['title']));
$admin->row_input($lang->string('Display Title
This is the title that others will be able to see when comments are posted.
'), 'displaytitle', $bugsys->sanitize($usergroup['displaytitle']));
$admin->row_input($lang->string('Opening Tag MarkupPlace all open HTML tags here that will be wrapped around the username.
'), 'opentag', $bugsys->sanitize($usergroup['opentag']));
$admin->row_input($lang->string('Closing Tag MarkupPlace all closed HTML tags that will close any open HTML tags entered above.
'), 'closetag', $bugsys->sanitize($usergroup['closetag']));
$admin->table_end();
// Permission
$admin->table_start();
$admin->table_head($lang->string('Permission Settings'));
foreach ($permissions AS $group => $settings)
{
$admin->row_span($group, 'thead', 'center');
foreach ($settings AS $setting => $name)
{
$admin->row_yesno($name, "perm[$setting]", ($usergroup['permissions'] & $_PERMISSION["$setting"]));
}
}
$admin->table_end();
// custom field permissions
$admin->table_start();
$admin->table_head($lang->string('Custom Field Permissions'));
if ($edit)
{
$perms = $db->query("SELECT fieldid, mask FROM " . TABLE_PREFIX . "bugfieldpermission WHERE usergroupid = $usergroup[usergroupid]");
while ($perm = $db->fetch_array($perms))
{
$permissions["$perm[fieldid]"] = $perm['mask'];
}
}
$fields = $db->query("SELECT fieldid, name FROM " . TABLE_PREFIX . "bugfield ORDER BY fieldid");
while ($field = $db->fetch_array($fields))
{
unset($listitem);
$admin->list_item($lang->string('No Permission'), 0, $permissions["$field[fieldid]"] == 0);
$admin->list_item($lang->string('Can View Field'), 1, $permissions["$field[fieldid]"] == 1);
$admin->list_item($lang->string('Can View, Edit Field'), 2, $permissions["$field[fieldid]"] == 2);
$admin->row_list($field['name'], "custom[$field[fieldid]]");
}
$admin->table_end();
// Submit
$admin->table_start();
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_POST['do'] == 'insert')
{
foreach ($_POST['perm'] AS $permtitle => $binaryswitch)
{
$permissionvalue += $_PERMISSION["$permtitle"] * $binaryswitch;
}
$db->query("
INSERT INTO " . TABLE_PREFIX . "usergroup
(title, displaytitle, opentag, closetag, permissions)
VALUES
('" . $bugsys->in['title'] . "', '" . $bugsys->in['displaytitle'] . "',
'" . $bugsys->in['opentag'] . "', '" . $bugsys->in['closetag'] . "',
$permissionvalue
)"
);
$ugroupid = $db->insert_id();
build_usergroups();
foreach ($_POST['custom'] AS $fieldid => $mask)
{
$values[] = "$ugroupid, " . intval($fieldid) . ", " . intval($mask);
}
$db->query("
INSERT INTO " . TABLE_PREFIX . "bugfieldpermission
(usergroupid, fieldid, mask)
VALUES
(" . implode("\n\t\t\t", $values) . "
)"
);
$admin->redirect('usergroup.php?do=modify');
}
// ###################################################################
if ($_POST['do'] == 'update')
{
foreach ($_POST['perm'] AS $permtitle => $binaryswitch)
{
$permissionvalue += $_PERMISSION["$permtitle"] * $binaryswitch;
}
$db->query("
UPDATE " . TABLE_PREFIX . "usergroup
SET title = '" . $bugsys->in['title'] . "',
displaytitle = '" . $bugsys->in['displaytitle'] . "',
opentag = '" . $bugsys->unsanitize($bugsys->in['opentag']) . "',
closetag = '" . $bugsys->unsanitize($bugsys->in['closetag']) . "',
permissions = $permissionvalue
WHERE usergroupid = " . intval($bugsys->in['usergroupid'])
);
build_usergroups();
build_assignedto();
$ugroupid = intval($bugsys->in['usergroupid']);
foreach ($_POST['custom'] AS $fieldid => $mask)
{
$values[] = "$ugroupid, " . intval($fieldid) . ", " . intval($mask);
}
$db->query("
REPLACE INTO " . TABLE_PREFIX . "bugfieldpermission
(usergroupid, fieldid, mask)
VALUES
(" . implode("),\n\t\t\t(", $values) . ")"
);
$admin->redirect('usergroup.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'modify')
{
$admin->page_start($lang->string('Usergroup Manager'));
$admin->form_start('usergroup.php', 'null');
$admin->table_start();
$admin->table_head($lang->string('Usergroup Manager'), 3);
$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);
$groups = $db->query("
SELECT COUNT(user.userid) AS total, user.usergroupid
FROM " . TABLE_PREFIX . "user AS user
LEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup USING (usergroupid)
GROUP BY usergroup.usergroupid
ORDER BY usergroup.usergroupid"
);
while ($group = $db->fetch_array($groups))
{
$usergroups["$group[usergroupid]"]['total'] = $group['total'];
}
$admin->table_column_head(array($lang->string('Usergroup'), $lang->string('Number of Users'), $lang->string('Action')));
foreach ($usergroups AS $group)
{
$admin->row_multi_item(array("$group[title]" => 'l', ((!$group['total']) ? '-' : $group['total']) => 'c', "[" . $lang->string('Edit') . "]" . (($group['usergroupid'] > 6) ? "[" . $lang->string('Delete') . "]" : '') => 'c'));
}
$admin->row_span('[' . $lang->string('Add New Usergroup') . ']', 'tfoot', 'center', 3);
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>