<?php

// tady můžete nastavit práva (1 - 3)
// here you can set the rights (1 - 3)
if ($rights>=3):

if ($a=="change_rights" AND $id!="") {

$sql=mysql_query("UPDATE kcms_users SET rights='".$_POST["rights"]."' WHERE id='".addslashes($id)."'", $dbserver);

echo "<div class=\"popup-success\">$lang_alert_success</div>";

}

if ($a=="delete_account" AND $id!="") {

$sql=mysql_query("DELETE FROM kcms_users WHERE id='".addslashes($id)."'", $dbserver);

echo "<div class=\"popup-success\">$lang_alert_success</div>";

}

?>

<h2><?php echo($lang_users); ?></h2>

<table>
<th><?php echo($lang_form_user); ?></th>
<th><?php echo($lang_form_registration_date); ?></th>
<th><?php echo($lang_form_last_visit); ?></th>
<th><?php echo($lang_form_rights); ?></th>
<th><?php echo($lang_form_options); ?></th>
<?php

$print=mysql_query("SELECT id, login, rights, regdate, lastvisit FROM kcms_users ORDER by rights DESC");
while (list($id, $login, $rights, $regdate, $lastvisit) = mysql_fetch_row($print)) {

echo "<form action=\"./admin.php?f=users&amp;a=change_rights&amp;id=$id\" method=\"post\">
<tr>
<td><a href=\"/profiles/$login/\">$login</a></td>
<td>".date("d.m.Y, H:i", $regdate)."</td>
<td>".date("d.m.Y, H:i", $lastvisit)."</td>
<td><select name=\"rights\">";

for ($i=0; $i<4; $i++) {

echo "<option value=\"$i\"";
if ($rights==$i) { echo " selected=\"selected\""; }
echo ">$i</option>\n";

}

echo "</select></td>
<td><input type=\"submit\" value=\"$lang_button_save\" /> <input type=\"button\" value=\"$lang_button_delete\" onclick=\"if (!confirm('$lang_alert_sure')) return false; parent.location='./admin.php?f=users&amp;a=delete_account&amp;id=$id';\" /></td>
</tr>
</form>\n";

}
?>
</table>

<?php else: $access_denied=1; endif; ?>