<div id="primary_header">
	<h1><?php print $this->translate('Authentication Settings')?></h1>

</div>

<div id="back_button" class="savecontact">
	<a href="#">
		<span>
			<?php print $this->translate('Save')?>
			<strong><?php print $this->translate('Settings')?></strong>
		</span>
	</a>
</div>


<div id="primary_content">
	<div id="primary_content_inner">
		<div id="Flash" class="flash_notice">The LDAP Settings have been updated. </div>
		<form id="settingsForm" method="post" action="<?php echo $this->moduleBaseUrl ?>/settings/ldapsave">
			<input type="hidden" name="save" value="1" />
				<table class="settings">
                    <tr>
                        <td class="label"><label for="signature"><?php print $this->translate('Authentication Type')?></label></td>
                        <td>
                                <select name="authType">
									<option value="sql">SQL (Default, recommended)</option>
									<option value="ldap">LDAP</option>
								</select>
                                <small><?php print $this->translate('Specify the authentication used for system accounts.')?></small>
                        </td>
                    </tr>
			</table>
			
			<div class="divider"></div>
			
			<table class="settings">
              <tr>
                     <td class="label"><label for="signature"><?php print $this->translate('LDAP Host')?></label></td>
                     <td>
                             <input type='text' name="fields[ldap_host]" id="ldap_host" value='<?php echo $this->global['ldap_host'] ?>'>
                             <small><?php print $this->translate('Specify the hostname for the LDAP server.')?></small>
                     </td>
              </tr>

                     <tr>
                     <td class="label"><label for="signature"><?php print $this->translate('LDAP Bind DN')?></label></td>
                     <td>
                             <input type='text' name="fields[ldap_binddn]" id="ldap_binddn" value='<?php echo $this->global['ldap_binddn'] ?>'>
                             <small><?php print $this->translate('The Bind DN is used when you need to bind to the LDAP server. This is for setups where you need to fetch the password data to compare against.')?></small>
                     </td>
                     </tr>

                     <tr>
                     <td class="label"><label for="signature"><?php print $this->translate('LDAP Bind Pass')?></label></td>
                     <td>
                             <input type='text' name="fields[ldap_bindpass]" id="ldap_bindpass" value='<?php echo $this->global['ldap_bindpass'] ?>'>
                             <small><?php print $this->translate('Use this field to specify the password used to bind against your LDAP Server.')?></small>
                     </td>
                     </tr>

				</table>
				
				<div class="divider"></div>

				<table class="settings">	
                     <tr>
                     <td class="label"><label for="signature"><?php print $this->translate('LDAP Base DN')?></label></td>
                     <td>
                             <input type='text' name="fields[ldap_basedn]" id="ldap_basedn" value='<?php echo $this->global['ldap_basedn'] ?>'>
                             <small><?php print $this->translate('Specify the Base DN required by your LDAP Server.')?></small>
                     </td>
                     </tr>

                     <tr>
                     <td class="label"><label for="signature"><?php print $this->translate('LDAP Password Field')?></label></td>
                     <td>
                             <input type='text' name="fields[ldap_passwdfield]" id="ldap_passwdfield" value='<?php echo $this->global['ldap_passwdfield'] ?>'>
                             <small><?php print $this->translate('You can define the LDAP attribute that stores the password data of your users.to the CalDAV server. Used for all Calendar functions')?></small>
                     </td>
                     </tr>

                     <tr>
                     <td class="label"><label for="signature"><?php print $this->translate('LDAP Password Filter')?></label></td>
                     <td>
                             <input type='text' name="fields[ldap_passfilter]" id="ldap_passfilter" value='<?php echo $this->global['ldap_passfilter'] ?>'>
                             <small><?php print $this->translate('You can define the LDAP filter to use when searching for passwords. This specifies what object class the users are under.')?></small>
                     </td>
                     </tr>


                     <tr>
                             <td class="label"><label for="replyTo"><?php print $this->translate('Bind Authentication')?></label></td>
                             <td>
                                     <input type='hidden' name='fields[ldap_bindauth]' value='0'/>
                                     <input type="checkbox" value="1" name="fields[ldap_bindauth]" id="ldap_bindauth" <?php echo ($this->global['ldap_bindauth']) ? 'checked' : '' ?> />
                                     <small><?php print $this->translate('Toggle to enable bind authentication. With this method, no lookups are needed. - Atmail will connect to the LDAP server via the username and password.')?></small>
                             </td>
                     </tr>

                     <tr>
                     <td class="label"><label for="signature"><?php print $this->translate('LDAP Bind Authentication DN')?></label></td>
                     <td>
                             <input type='text' name="fields[ldap_bindauthdn]" id="ldap_bindauthdn" value='<?php echo $this->global['ldap_bindauthdn'] ?>'>
                             <small><?php print $this->translate('This field specifies the DN format used for Bind Authentication.')?></small>
                     </td>
                     </tr>

			</table>
		</form>
		<div id="back_button">
			<a href="#">
				<span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span>
			</a>
		</div>
	</div>
</div>

<script type="text/javascript">
$(function() 
{
	// bind to the form's submit event and cancel legacy submit
	$('#settingsForm', '#ldap').submit(function() 
	{
	
		$("#Flash", "#ldap").hide();
		$.php($("#settingsForm", '#ldap').attr("action"),$("#settingsForm", '#ldap').serializeArray());
		return false;
	
	});

	$("#TimeZone option", '#ldap').removeAttr('selected');
	$("#TimeZone option[value=<?php echo $this->global['TimeZone'] ?>]", '#ldap').attr('selected', 'true');

	$("#MsgNum option", '#ldap').removeAttr('selected');
	$("#MsgNum option[value=<?php echo $this->global['MsgNum'] ?>]", '#ldap').attr('selected', 'true');

	$("#Language option", '#ldap').removeAttr('selected');
	$("#Language option[value=<?php echo $this->global['Language'] ?>]", '#ldap').attr('selected', 'true');

	$("#View option", '#ldap').removeAttr('selected');
	$("#View option[value='<?php echo $this->global['DefaultView'] ?>']", '#ldap').attr('selected', 'true');

	$("#ThreadLimit option", '#ldap').removeAttr('selected');
	$("#ThreadLimit option[value=<?php echo $this->global['ThreadLimit'] ?>]", '#ldap').attr('selected', 'true');
	
	$('#back_button a', '#ldap').bind("click", function() { return $('#settingsForm', '#ldap').submit()});
	
	$('#ldap_enable').iphoneStyle();
	$('#ldap_bindauth').iphoneStyle();
	
	$('.stronglastword').each( function() { $(this).stronglastword() });
		
});
</script>
