//TODO: Redo html
if (!check_perms('admin_manage_permissions')) { error(403); }
if(!isset($_REQUEST['userid']) || !is_number($_REQUEST['userid'])){ error(404); }
include(SERVER_ROOT."/classes/permissions_form.php");
list($UserID, $Username, $PermissionID) = array_values(user_info($_REQUEST['userid']));
$DB->query("SELECT
u.CustomPermissions
FROM users_main AS u
WHERE u.ID='$UserID'");
list($Customs)=$DB->next_record(MYSQLI_NUM, false);
$Defaults = get_permissions_for_user($UserID, array());
$Delta=array();
if (isset($_POST['action'])) {
authorize();
foreach ($PermissionsArray as $Perm => $Explaination) {
$Setting = (isset($_POST['perm_'.$Perm]))?1:0;
$Default = (isset($Defaults[$Perm]))?1:0;
if ($Setting != $Default) {
$Delta[$Perm] = $Setting;
}
}
$Cache->begin_transaction('user_info_heavy_'.$UserID);
$Cache->update_row(false, array('CustomPermissions' => $Delta));
$Cache->commit_transaction(0);
$DB->query("UPDATE users_main SET CustomPermissions='".db_string(serialize($Delta))."' WHERE ID='$UserID'");
} elseif (!empty($Customs)) {
$Delta = unserialize($Customs);
}
$Permissions = array_merge($Defaults,$Delta);
function display_perm($Key,$Title) {
global $Defaults, $Permissions;
$Perm='
';
echo $Perm;
}
show_header($Username.' > Permissions');
?>