<?php
// +-------------------------------------------------+
// © 2002-2005 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: request.class.php,v 1.8.12.1 2025/08/14 07:51:02 dbellamy Exp $

if (stristr($_SERVER['REQUEST_URI'], ".class.php")) {
    die("no access");
}

global $include_path;

require_once  $include_path . '/parser.inc.php';
require_once  $include_path . '/templates/requests.tpl.php';

class request
{

    /**
     * Retourne un formulaire pour les autorisations d'une requete ou les autorisations par defaut si requete non creee
     *
     *@return string
     */
    static public function getAutorisationsForm()
    {
        global $charset;
        global $req_auth;
        $aut = array(
            '1'
        );

        // recuperation des utilisateurs
        $q = "SELECT userid, username FROM users ";
        $r = pmb_mysql_query($q);
        $p_user = array();
        while (($row = pmb_mysql_fetch_row($r))) {
            $p_user[$row[0]] = $row[1];
        }

        $form = "";
        $id_check_list = '';
        foreach ($p_user as $userid => $username) {

            $form .= $req_auth;
            $form = str_replace('!!user_name!!', htmlentities($username, ENT_QUOTES, $charset), $form);
            $form = str_replace('!!user_id!!', $userid, $form);
            if (in_array($userid, $aut)) {
                $chk = 'checked=\'checked\'';
            } else {
                $chk = '';
            }
            $form = str_replace('!!checked!!', $chk, $form);

            $id_check = "user_aut[" . $userid . "]";
            if ($id_check_list)
                $id_check_list .= '|';
            $id_check_list .= $id_check;
        }
        $form .= "<input type='hidden' id='auto_id_list' name='auto_id_list' value='$id_check_list' >";
        return $form;
    }
}
