<%!
	from baruwa.forms.domains import DELIVERY_MODES, LANGUAGES, SPAM_ACTIONS, VIRUS_ACTIONS, REPORT_FREQ
	from baruwa.lib.filters import default
	from baruwa.forms.domains import AUTH_PROTOCOLS
	protocols = dict(AUTH_PROTOCOLS)
%>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<ul id="msgops">
		    <li>${h.link_to(_('Domain Settings'), url('domain-settings', domainid=c.domain.id))}</li>
			<li>${h.link_to(_('Edit domain'), url(controller='domains', action='edit', domainid=c.domain.id))}</li>
			<li>${h.link_to(_('Delete domain'), url(controller='domains', action='delete', domainid=c.domain.id))}</li>
		</ul>
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="space-6"></div>
<div class="row-fluid">
	<div class="span1 hidden-phone"></div>
	<div class="span10">
		<div class="grid_16">
			<div class="span12">
				<h3 class="head smaller lighter blue">${_('Domain information')}</h3>
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Domain name')}:
			</div>
			<div class="span6 real-half">
				${c.domain.name}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Status')}:
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.domain.status)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Owners')}:
			</div>
			<div class="span6 real-half">
				<%
				orglinks = []
				for org in c.domain.organizations:
					link = h.link_to(org.name, url('org-detail', orgid=org.id)) if c.user.is_superadmin else org.name
					orglinks.append(link)
				orglinks = ', '.join(orglinks)
				%>
				${orglinks|n}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Multi destination delivery mode')}:
			</div>
			<div class="span6 real-half">
				${dict(DELIVERY_MODES)[str(c.domain.delivery_mode)]}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('What to do with Spam')}:
			</div>
			<div class="span6 real-half">
				${dict(SPAM_ACTIONS)[str(c.domain.spam_actions)]}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('What to do with High Spam')}:
			</div>
			<div class="span6 real-half">
				${dict(SPAM_ACTIONS)[str(c.domain.highspam_actions)]}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('SMTP recipient checks')}
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.domain.smtp_callout)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('LDAP recipient checks')}
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.domain.ldap_callout)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Spam Checks')}
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.domain.spam_checks)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Virus Checks')}
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.domain.virus_checks)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Run Virus checks at SMTP time')}
			</div>
			<div class="span6 real-half">
				${functions.item_status(c.domain.virus_checks_at_smtp)}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('What to do with Virus infected messages')}:
			</div>
			<div class="span6 real-half">
				${dict(VIRUS_ACTIONS)[str(c.domain.virus_actions)]}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Spam low score')}
			</div>
			<div class="span6 real-half">
				${c.domain.low_score|default}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Spam high score')}
			</div>
			<div class="span6 real-half">
				${c.domain.high_score|default}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Maximum Message Size')}
			</div>
			<div class="span6 real-half">
				${c.domain.message_size|default}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Language')}
			</div>
			<div class="span6 real-half">
				${dict(LANGUAGES)[c.domain.language]}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Timezone')}
			</div>
			<div class="span6 real-half">
				${c.domain.timezone}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Site url')}
			</div>
			<div class="span6 real-half">
				${c.domain.site_url}
			</div>
		</div>
		<div class="row-fluid">
			<div class="span6 real-half">
				${_('Send summary reports')}
			</div>
			<div class="span6 real-half">
				${dict(REPORT_FREQ)[str(c.domain.report_every)]}
			</div>
		</div>
		<div class="grid_16">
		    <h3 class="head smaller lighter blue">
				${_('Domain Aliases')}
			</h3>
		</div>
		% for alias in c.domain.aliases:
		<div class="row-fluid">
			<div class="span8">
				${alias.name}
			</div>
			<div class="span1 half">
				${functions.item_status(alias.status)}
			</div>
			<div class="span1 hidden-phone">
				&nbsp;
			</div>
			<div class="span1 half">
				${h.link_to(h.literal('<i class="icon-edit blue"></i>'), url('domains-edit-alias', aliasid=alias.id), title=_("Edit Domain Alias"))}
			</div>
			<div class="span1 half">
				${h.link_to(h.literal('<i class="icon-remove red"></i>'), url('domains-delete-alias', aliasid=alias.id), title=_("Delete Domain Alias"))}
			</div>
		</div>
		% endfor
		% if not c.domain.aliases:
		<div class="row-fluid">
			<div class="span12">${_('No domain aliases configured')}</div>
		</div>
		% endif
		<div class="row-fluid">
			<div class="span12">
			    <h3 class="head smaller lighter blue">
					${_('Delivery Servers')}
				</h3>
			</div>
		</div>
		% for server in c.domain.servers:
		<div class="row-fluid">
			<div class="span8">
				${server.address}:${server.port}
			</div>
			<div class="span1 hidden-phone">
				${functions.item_status(server.enabled)}
			</div>
			<div class="span1 half">
				${h.link_to(h.literal('<i class="icon-exchange blue"></i>'), url('dserver-test', destinationid=server.id), title=_("Test Destination server"))}
			</div>
			<div class="span1 half">
				${h.link_to(h.literal('<i class="icon-edit blue"></i>'), url('dserver-edit', destinationid=server.id), title=_("Edit Destination server"))}
			</div>
			<div class="span1 half">
				${h.link_to(h.literal('<i class="icon-remove red"></i>'), url('dserver-delete', destinationid=server.id), title=_("Delete Destination server"))}
			</div>
		</div>
		% endfor
		% if not c.domain.servers:
		<div class="row-fluid">
			<div class="span12">${_('No delivery servers configured')}</div>
		</div>
		% endif
		<div class="row-fluid">
			<div class="span12">
			    <h3 class="head smaller lighter blue">
					${_('Authentication Servers')}
				</h3>
			</div>
		</div>
		% for server in c.domain.authservers:
		<div class="row-fluid">
			<div class="span8">
				${server.address} Protocol: ${protocols[str(server.protocol)]}
			</div>
			<div class="span1 hidden-phone">
				${functions.item_status(server.enabled)}
			</div>
			<div class="span1 half">
				% if server.protocol in [4, 5, 6, 7]:
				 ${h.link_to(h.literal('<i class="icon-cog blue"></i>'), url('domains-auth-settings-with-protocol', proto=server.protocol, sid=server.id, domainid=c.domain.id), title=_("Manage Settings"))}
				% else:
				  ${h.literal('<i class="icon-cog blue"></i>')}
				% endif
			</div>
			<div class="span1 half">
				 ${h.link_to(h.literal('<i class="icon-edit blue"></i>'), url('domains-edit-auth', authid=server.id), title=_("Edit Authentication server"))}
			</div>
			<div class="span1 half">
				${h.link_to(h.literal('<i class="icon-remove red"></i>'), url('domains-delete-auth', authid=server.id), title=_("Delete Authentication server"))}
			</div>
		</div>
		% endfor
		% if not c.domain.authservers:
		<div class="row-fluid">
			<div class="span12">${_('No authentication servers configured')}</div>
		</div>
		% endif
	</div>
	<div class="span1 hidden-phone"></div>
</div>
<div class="space-6"></div>

<%def name="title()">
${_('Domains :: %s') % c.domain.name}
</%def>

<%def name="heading()">
${_('Domains :: %s') % c.domain.name}
</%def>

<%def name="headers()">
</%def>
<%def name="submenu()"></%def>
<%def name="localscripts()">\
<script type="text/javascript">
$(function() {
	$('.settings-popover').popover();
});
</script>
</%def>
<%namespace name="functions" file="../includes/functions.html"/>
<%inherit file="../base.html"/>
