<% local viewtable, viewlibrary, pageinfo, session = ... %>
<% if viewtable and not viewtable.errtxt then %>
Content-Type: Content Type: text/xml

<document type="freeswitch/xml">
  <section name="directory">
    <domain name="<%= viewtable.value.domain.value %>">
      <params>
        <param name="dial-string" value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}" />
      </params>
      <groups>
        <group name="default">
          <users>
	    <user id="<%= viewtable.value.username.value %>">
	      <params>
	        <param name="vm-enable" value="true>" />
	        <% 
		local ignore = {username=true, firstname=true, lastname=true, domain=true, ["vm-password-confirm"]=true }
		for name,val in pairs(viewtable.value) do
			if not ignore[name] then %>
	        <param name="<%= name %>" value="<%= tostring(val.value) %>" />
			<% end %>
		<% end %>
	      </params>
	    </user>
	  </users>
        </group>
      </groups>
    </domain>
  </section>
</document>
<% end %>
