<%
if (!user.getAuthenticated()) {
%>You must log in to view your addressbook<%
} else {
PetNameDB names = user.getPetNameDB();
String action = request.getParameter("action");
if ( (action != null) && ("Change".equals(action)) ) {
String oldPetname = request.getParameter("petname");
PetName cur = names.getByName(oldPetname);
if (cur != null) {
cur.setName(request.getParameter("name"));
cur.setNetwork(request.getParameter("network"));
cur.setProtocol(request.getParameter("protocol"));
cur.setIsPublic(null != request.getParameter("isPublic"));
cur.setLocation(request.getParameter("location"));
cur.setGroups(request.getParameter("groups"));
names.removeName(oldPetname);
names.add(cur);
names.store(user.getAddressbookLocation());
if ( ("syndiearchive".equals(cur.getProtocol())) && (BlogManager.instance().authorizeRemote(user)) ) {
if (null != request.getParameter("scheduleSyndication")) {
BlogManager.instance().scheduleSyndication(cur.getLocation());
BlogManager.instance().writeConfig();
} else {
BlogManager.instance().unscheduleSyndication(cur.getLocation());
BlogManager.instance().writeConfig();
}
}
%>Address updated<%
}
} else if ( (action != null) && ("Add".equals(action)) ) {
PetName cur = names.getByName(request.getParameter("name"));
if (cur != null) { %>Address already exists<% } else {
cur = new PetName();
cur.setName(request.getParameter("name"));
cur.setNetwork(request.getParameter("network"));
cur.setProtocol(request.getParameter("protocol"));
cur.setIsPublic(null != request.getParameter("isPublic"));
cur.setLocation(request.getParameter("location"));
cur.setGroups(request.getParameter("groups"));
names.add(cur);
names.store(user.getAddressbookLocation());
if ( ("syndiearchive".equals(cur.getProtocol())) && (BlogManager.instance().authorizeRemote(user)) ) {
if (null != request.getParameter("scheduleSyndication")) {
BlogManager.instance().scheduleSyndication(cur.getLocation());
BlogManager.instance().writeConfig();
}
}
%>Address added<%
}
} else if ( (action != null) && ("Delete".equals(action)) ) {
PetName cur = names.getByName(request.getParameter("name"));
if (cur != null) {
if ( ("syndiearchive".equals(cur.getProtocol())) && (BlogManager.instance().authorizeRemote(user)) ) {
BlogManager.instance().unscheduleSyndication(cur.getLocation());
BlogManager.instance().writeConfig();
}
names.removeName(cur.getName());
names.store(user.getAddressbookLocation());
%>Address removed<%
}
} else if ( (action != null) && ("Export".equals(action)) ) {
%><%=BlogManager.instance().exportHosts(user)%><%
}
TreeSet sorted = new TreeSet(names.getNames());
%>
<%
StringBuffer buf = new StringBuffer(128);
for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
PetName name = names.getByName((String)iter.next());
buf.append(" ");
out.write(buf.toString());
buf.setLength(0);
}
String net = request.getParameter("network");
String proto = request.getParameter("protocol");
String name = request.getParameter("name");
String loc = request.getParameter("location");
boolean active = (request.getParameter("action") != null);
if (net == null || active) net = "";
if (proto == null || active) proto = "";
if (name == null || active) name = "";
if (loc == null || active) loc= "";
%>
<%
}
%>
|