Hi All
I made a little thing to download members details, and currently have it working by just plopping the aspx file in the umbraco directory, and accessing it with http://localhost/umbraco/downloadMembers.aspx (I include the code below just in case it's of any use to anyone / anyone knows of a nicer way of doing it!)
It currently works rather cheesily, as you can see, by making the user enter a hardcoded password and then spitting out the file. What I'd really like is to integrate it into the umbraco admin somewhere, so I could have a little icon, or even just a text link, in the sections bit at the bottom left, or perhaps a link in the members section to let the admins download it from there, without having to put in another password (ie. using their existing authenticated state as a logged in admin user).
I guess I have 2 questions really:
1) How to add a link to this page from within the admin somewhere
2) How to detect if they are a logged in admin user
Thanks!
Dan
Code:
<%@ Page Language="C#" %>
<%@ Import Namespace="umbraco.cms.businesslogic.member" %>
<script runat="server">
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (txtPassword.Text == "blahblah")
{
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/csv";
Response.AppendHeader("Content-Disposition", "attachment; filename=newsletter_subscribers.csv");
foreach (Member tempMember in Member.GetAll)
{
Response.Write(tempMember.Email + "\r\n");
}
Response.End();
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<asp:Panel id="pnlPassword" DefaultButton="btnSubmit" runat="server">
<form id="passwordForm" runat="server">
<asp:label id="Label1" runat="server" text="Please enter the password: "></asp:label>
<asp:textbox id="txtPassword" runat="server" TextMode="Password"></asp:textbox>
<asp:button id="btnSubmit" runat="server" onclick="btnSubmit_Click" text="Download" />
</form>
</asp:Panel>
</body>
</html>