<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"      prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-html"     prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean"     prefix="bean" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"       prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<h2>Verwaltung (Admin)</h2>

<hr>
<h3>Export</h3>

<c:choose>
	<c:when test="${applicationScope.ConsensusFoundation.ontologyManager.exportHandlerCount > 0}">
		<ul>
		<c:forEach items="${applicationScope.ConsensusFoundation.ontologyManager.exportHandlers}" var="i">
			<li><html:link action="export?format=${i.extension}&amp;internals=true">${i.extension} (komplett inkl. interner Typen)</html:link>
			    &nbsp;/&nbsp;
			    <html:link action="export?format=${i.extension}">${i.extension} (ohne interne Typen)</html:link>
			</li>
		</c:forEach>
		</ul>
	</c:when>
	<c:otherwise>
		<p>Nicht verf&uuml;gbar.</p>
	</c:otherwise>
</c:choose>


<c:if test="${sessionScope.User.superAdmin}">
	<hr>
	<h3>Import / Merge</h3>
	<c:choose>
		<c:when test="${applicationScope.ConsensusFoundation.ontologyManager.mergeHandlerCount > 0}">
			<div class="FORMULAR">
				<html:form action="merge" enctype="multipart/form-data">
				<html:file property="formfile" size="50"/>
				<p><html:submit>Upload &amp; Merge</html:submit></p>
				</html:form>
			</div>
		</c:when>
		<c:otherwise>
			<p>Nicht verf&uuml;gbar.</p>
		</c:otherwise>
	</c:choose>


	<hr>
	<h3>Reorganisation</h3>
	<p><html:link action="reorg">Starten</html:link><br>${requestScope.Message}</p>


	<hr>
	<h3>Benutzerrechte</h3>
	
	<table border="1" cellpadding="2" cellspacing="2">
		<tr>
			<th>&nbsp;</th> <th>Username</th> <th>Nachname</th> <th>Vorname</th> <th>E-Mail</th> <th>Rollen</th> <th>&#x2205; Fremdbewertungen</th> <th>&#x2205; eigene Bewertungen</th> <th>Kommentar</th>
		</tr>

		<c:forEach items="${applicationScope.ConsensusFoundation.userManager.users}" var="user" varStatus="nr">
			<tr>
				<td align="right"> ${nr.count} </td>
				<td> ${user.username} </td>
				<td> ${user.lastname} </td>
				<td> ${user.firstname} </td>
				<td> ${user.email} </td>
				<td>
					<html:link action="edituser?username=${user.username}">&auml;ndern</html:link>
					<c:forEach items="${user.roles}" var="role">
						&nbsp; ${role.rolename}
					</c:forEach>
				</td>
				<td align="right"> <fmt:formatNumber value="${user.averageRatingValue}" minFractionDigits="2" maxFractionDigits="2"/> </td>
				<td align="right"> <fmt:formatNumber value="${user.averageOwnRatingsValue}" minFractionDigits="2" maxFractionDigits="2"/> </td>
				<td> ${fn:substring(user.comment,0,50)}<c:if test="${fn:length(user.comment) > 50}">...</c:if> </td>
			</tr>
		</c:forEach>

	</table>
</c:if>
