Increase domain component length limit
[hcoop/zz_old/portal.git] / contact.mlt
dissimilarity index 95%
index 0dc61d4..905b9c7 100644 (file)
@@ -1,5 +1,94 @@
-<% @header[("title", ["Contact information"])] %>
-
-
-
-<% @footer[] %>
\ No newline at end of file
+<% @header[("title", ["Contact information"])];
+
+ref showNormal = true;
+
+if $"cmd" = "add" then
+       val id = Contact.addContact (Init.getUserId(), Web.stoi ($"knd"), $"v", Contact.privFromInt (Web.stoi ($"priv"))) %>
+       <h3>Contact added</h3>
+
+<% elseif $"mod" <> "" then
+       showNormal := false;
+       val id = Web.stoi ($"mod");
+       val cont = Contact.lookupContact id %>
+
+<h3>Modify contact entry</h3>
+
+<form action="contact" method="post">
+<input type="hidden" name="save" value="<% id %>">
+<table class="blanks">
+<tr> <td>Kind:</td> <td><select name="knd">
+<% foreach kind in Contact.listKinds () do %>
+       <option value="<% #id kind %>"<% if #knd cont = #id kind then %> selected<% end %>><% Web.html (#name kind) %></option>
+<% end %>
+</select></td> </tr>
+<tr> <td>Value:</td> <td><input name="v" value="<% Web.html (#v cont) %>"></td> </tr>
+<tr> <td>Readable by:</td> <td><select name="priv">
+       <option value="0"<% if #priv cont = Contact.PUBLIC then %> selected<% end %>>Anyone</option>
+       <option value="1"<% if #priv cont = Contact.MEMBERS then %> selected<% end %>>Members only</option>
+       <option value="2"<% if #priv cont = Contact.ADMINS then %> selected<% end %>>Admins only</option>
+</select></td> </tr>
+<tr> <td><input type="submit" value="Save"></td> </tr>
+</table>
+</form>
+
+<% elseif $"save" <> "" then
+       val id = Web.stoi ($"save");
+       val cont = Contact.lookupContact id;
+       Contact.modContact {cont with knd = Web.stoi ($"knd"), v = $"v", priv = Contact.privFromInt (Web.stoi ($"priv"))} %>
+       <h3>Contact entry saved</h3>
+
+<% elseif $"del" <> "" then
+       showNormal := false;
+       val id = Web.stoi ($"del");
+       val cont = Contact.lookupContact id %>
+       <h3>Are you sure you want to delete contact entry "<% Web.html (#v cont) %>"?</h3>
+       <a href="contact?del2=<% id %>">Yes, delete "<% Web.html (#v cont) %>"!</a>
+
+<% elseif $"del2" <> "" then
+       val id = Web.stoi ($"del2");
+       val cont = Contact.lookupContact id;
+       Contact.deleteContact id %>
+       <h3>Contact entry "<% Web.html (#v cont) %>" deleted</h3>
+
+<% end;
+
+if showNormal then %>
+
+<h3>Add new contact information</h3>
+
+<form action="contact" method="post">
+<input type="hidden" name="cmd" value="add">
+<table class="blanks">
+<tr> <td>Kind:</td> <td><select name="knd">
+<% foreach kind in Contact.listKinds () do %>
+       <option value="<% #id kind %>"><% Web.html (#name kind) %></option>
+<% end %>
+</select></td> </tr>
+<tr> <td>Value:</td> <td><input name="v"></td> </tr>
+<tr> <td>Readable by:</td> <td><select name="priv">
+       <option value="0">Anyone</option>
+       <option value="1" selected>Members only</option>
+       <option value="2">Admins only</option>
+</select></td> </tr>
+<tr> <td><input type="submit" value="Add"></td> </tr>
+</table>
+</form>
+
+<h3>Your contact information</h3>
+
+<table class="blanks">
+<% foreach (kind, cont) in Contact.listUserContacts (Init.getUserId(), Contact.ADMINS) do %>
+       <tr> <td><% Web.html (#name kind) %>:</td>
+       <td><% Contact.format (kind, cont) %></td>
+       <td><i><% switch #priv cont of
+                 Contact.PUBLIC => %>Public<%
+               | Contact.MEMBERS => %>Members only<%
+               | Contact.ADMINS => %>Admins only<%
+       end %></i></td>
+       <td><a href="contact?mod=<% #id cont %>">[Modify]</a> <a href="contact?del=<% #id cont %>">[Delete]</a></tr>
+<% end %>
+</table>
+
+<% end %>
+
+<% @footer[] %>
\ No newline at end of file