<%@ page language="java"%>
<%@ page import="vkc.db.entities.VKCAclType"%>

<%@ taglib uri="struts-bean"  prefix="bean"  %>
<%@ taglib uri="struts-html"  prefix="html"  %>
<%@ taglib uri="struts-logic" prefix="logic" %>
<%@ taglib uri="vkc-taglib"   prefix="vkc"   %>

<vkc:checkLogin/>
<vkc:init/>

<html:html locale="true">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="cache" content="no-cache">
    <meta http-equiv="expires" content="0">

    <title><vkc:message key="vkc.aclManager"/></title>

    <vkc:cssinclude />
    <script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'/>"></script>

	<script type="text/javascript">
	function addAccessor(elem) {
		var form = document.forms[0];
        disableAllButtons(elem);
		top.opener.addAccessor(form.accessorType.value,form.accessorSelect.value);
	}
	</script>
</head>
<body style="margin: 0 0 0 0;" class="color_dialogborder">
<html:form action="/addAccessorAcl" method="post">
  <bean:define id="form" name="addAccessorAclForm" scope="request" type="vkc.view.form.AddAccessorAclForm"/>

  <table class="color_dialogborder" cellspacing="0" cellpadding="3" border="0" width="100%" height="100%">
    <tr>
      <td colspan="2" class="color_titlebar" align="center">
        <font style="font-family:sans-serif; font-size:12pt; color:white;"><b><i>
          <logic:equal name="form" property="accessorType" value="<%= Integer.toString(VKCAclType.USER_TYPE) %>">
            <vkc:message key="vkc.acl.add_user"/>
          </logic:equal>
          <logic:equal name="form" property="accessorType" value="<%= Integer.toString(VKCAclType.GROUP_TYPE) %>">
            <vkc:message key="vkc.acl.add_group"/>
          </logic:equal>
        </i></b></font>
        <%-- Hidden field accessorType --%>
        <html:hidden property="accessorType"/>
      </td>
    </tr>
    <logic:notPresent name="vkc.acl.accessorListEmpty">
    <tr><td colspan="2">&nbsp;</td></tr>
    <tr>
      <td width="1%">
        <nobr><vkc:message key="vkc.acl.select_entry"/>:</nobr>
      </td>
      <td width="99%">
        <bean:define property="accessors" name="form" id="accessorsCollection"/>     
        <html:select property="accessorSelect" size="1" style="width:100%">
          <logic:equal name="form" property="accessorType" value="<%= Integer.toString(VKCAclType.USER_TYPE) %>">
            <vkc:options collection="accessorsCollection" property="userId" labelProperty="lastnameLabel"/>
          </logic:equal>
          <logic:equal name="form" property="accessorType" value="<%= Integer.toString(VKCAclType.GROUP_TYPE) %>">
            <vkc:options collection="accessorsCollection" property="groupId" labelProperty="name"/>
          </logic:equal>
          <%--html:options collection="accessorsCollection" property="accessorId" labelProperty="accessorName"/--%>
        </html:select>
      </td>
    </tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    <tr height="100%">
      <td colspan="2" align="center" height="100%">
        <vkc:button property="add" onclick="javascript:addAccessor(this);">
          <vkc:message key="vkc.acl.btn_add"/>
        </vkc:button>
        <vkc:button property="cancel"  onclick="javascript:disableAllButtons(this);window.close();">
          <vkc:message key="vkc.acl.btn_cancel"/>
        </vkc:button>
      </td>
    </tr>
    </logic:notPresent>
    <logic:present name="vkc.acl.accessorListEmpty">
    <tr height="100%" height="100%">
      <td colspan="2" bgcolor="red" align="center">
      	<font color="white"><b><vkc:message key="vkc.acl.noMoreAccessors"/></b></font>
      </td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="red" align="center">
        <vkc:button property="cancel" onclick="javascript:disableAllButtons(this);window.close();">
         <vkc:message key="vkc.acl.btn_cancel"/>
        </vkc:button>
      </td>
    </tr>
    </logic:present>
  </table>

</html:form>
</body>
</html:html>