function api_oauth2_access_tokens_enable(&$token)
{
    $update = array('disabled' => 0);
    return api_oauth2_access_tokens_update($token, $update);
}
    exit;
} else {
    if (post_isset('done') && crumb_check($crumb_key)) {
        $perms = post_str("perms");
        if (!api_oauth2_access_tokens_is_valid_permission($perms)) {
            $GLOBALS['smarty']->assign("error", "bad_perms");
        } else {
            $update = array('perms' => $perms);
            if ($update_ttl = post_isset("update_ttl")) {
                $ttl = post_str("update_ttl");
                $ttl = $ttl == '' ? -1 : intval($ttl);
                if ($ttl >= 0) {
                    $update['expires'] = $ttl ? time() + $ttl : 0;
                }
            }
            $update_rsp = api_oauth2_access_tokens_update($token_row, $update);
            $GLOBALS['smarty']->assign_by_ref("update_rsp", $update_rsp);
            if ($update_rsp['ok']) {
                $token_row = $update_rsp['token'];
            }
        }
    } else {
    }
}
$GLOBALS['smarty']->assign_by_ref("token", $token_row);
$perms_map = api_oauth2_access_tokens_permissions_map();
$GLOBALS['smarty']->assign_by_ref("permissions", $perms_map);
$ttl_map = api_oauth2_access_tokens_ttl_map();
$GLOBALS['smarty']->assign_by_ref("ttl_map", $ttl_map);
$GLOBALS['smarty']->display("page_api_oauth2_token.txt");
exit;