<?php
/*****************************************************************************
IP Reg, a PHP/MySQL IPAM tool
Copyright (C) 2007-2009 Wietse Warendorff (up to v0.5)
Copyright (C) 2011-2023 Thomas Hooge

SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/

include("includes.php");

if (($_SESSION['suser_role_admin'] == 0) and ($_SESSION['suser_role_manage'] == 0)) {
    header_location('comments.php?comments=accessdenied');
}

include("header.php");

$sql = "SELECT user_id AS id, user_name AS name,
            user_displayname AS  displayname, user_realm AS realm,
            user_role AS role
	FROM user
	ORDER BY user_name";
$sth = $dbh->query($sql);

// role: convert db set to array
$users = $sth->fetchAll(PDO::FETCH_ASSOC);
for($i = 0; $i < count($users); $i++) {
    $users[$i]['role'] = explode(',', $users[$i]['role'] );
}

$smarty->assign("users", $users);

$smarty->display("user.tpl");
		
include("footer.php");
?>