void AccountMessage_Show(object sender, EventArgs e) { SetTemplate("account_view_message"); List<MailFolder> folders = MailFolder.GetFolders(core, core.Session.LoggedInMember); /*foreach (MailFolder f in folders) { if (f.FolderType == FolderTypes.Inbox) continue; VariableCollection modulesVariableCollection = core.Template.CreateChild("account_links"); ParentModulesVariableCollection.CreateChild("account_links", modulesVariableCollection); Dictionary<string, string> args = new Dictionary<string, string>(); args.Add("folder", f.FolderName); switch (f.FolderType) { case FolderTypes.Draft: modulesVariableCollection.Parse("TITLE", core.Prose.GetString("DRAFTS")); break; case FolderTypes.Outbox: modulesVariableCollection.Parse("TITLE", core.Prose.GetString("OUTBOX")); break; case FolderTypes.SentItems: modulesVariableCollection.Parse("TITLE", core.Prose.GetString("SENT_ITEMS")); break; default: modulesVariableCollection.Parse("TITLE", f.FolderName); break; } modulesVariableCollection.Parse("SUB", Key); modulesVariableCollection.Parse("MODULE", ModuleKey); modulesVariableCollection.Parse("URI", BuildUri("inbox", args)); }*/ long messageId = core.Functions.RequestLong("id", 0); long newestId = 0; try { MessageRecipient recipient = new MessageRecipient(core, core.Session.LoggedInMember, messageId); Message threadStart = new Message(core, messageId); template.Parse("S_ID", threadStart.Id.ToString()); List<Message> messages = threadStart.GetMessages(); if (messages.Count < 3) { RenderMessage(core, template, threadStart); } // IF NOT DELETED THEN foreach (Message message in messages) { RenderMessage(core, template, message); newestId = message.Id; } threadStart.MarkRead(); List<MessageRecipient> recipients = threadStart.GetRecipients(); for (int i = 0; i < recipients.Count; i++) { core.PrimitiveCache.LoadUserProfile(recipients[i].UserId); } for (int i = 0; i < recipients.Count; i++) { VariableCollection recipientVariableCollection = template.CreateChild("recipients"); recipientVariableCollection.Parse("DISPLAY_NAME", core.PrimitiveCache[recipients[i].UserId].DisplayName); if (core.PrimitiveCache[recipients[i].UserId].IsOnline) { recipientVariableCollection.Parse("IS_ONLINE", "TRUE"); } else { recipientVariableCollection.Parse("IS_ONLINE", "FALSE"); } } template.Parse("NEWEST_ID", newestId); } catch (InvalidMessageRecipientException) { // Security, if not a recipeint, cannot see the message. core.Functions.Generate404(); } }
void AccountCompose_ReplySave(object sender, ModuleModeEventArgs e) { AuthoriseRequestSid(); bool ajax = false; try { ajax = bool.Parse(core.Http["ajax"]); } catch { } long messageId = core.Functions.FormLong("id", 0); long newestId = core.Functions.FormLong("newest-id", 0); string text = core.Http.Form["message"]; Message threadStart = new Message(core, messageId); Message newMessage = Message.Reply(core, LoggedInMember, threadStart, text); if (ajax) { Template template = new Template(core.CallingApplication.Assembly, "pane_message"); template.Medium = core.Template.Medium; template.SetProse(core.Prose); MessageRecipient recipient = new MessageRecipient(core, core.Session.LoggedInMember, messageId); template.Parse("S_ID", threadStart.Id.ToString()); List<Message> messages = threadStart.GetMessages(newestId, true); // IF NOT DELETED THEN foreach (Message message in messages) { AccountMessage.RenderMessage(core, template, message); newestId = message.Id; } threadStart.MarkRead(); Dictionary<string, string> returnValues = new Dictionary<string, string>(); returnValues.Add("update", "true"); returnValues.Add("message", newMessage.Text); returnValues.Add("template", template.ToString()); returnValues.Add("newest-id", newestId.ToString()); core.Response.SendDictionary("replySent", returnValues); } else { SetRedirectUri(BuildUri("inbox")); core.Display.ShowMessage("Message sent", "Your mail message has been sent."); } }
void AccountMessage_Poll(object sender, EventArgs e) { AuthoriseRequestSid(); long messageId = core.Functions.RequestLong("id", 0); long newestId = core.Functions.RequestLong("newest-id", 0); try { Template template = new Template(core.CallingApplication.Assembly, "pane_message"); template.Medium = core.Template.Medium; template.SetProse(core.Prose); MessageRecipient recipient = new MessageRecipient(core, core.Session.LoggedInMember, messageId); Message threadStart = new Message(core, messageId); template.Parse("S_ID", threadStart.Id.ToString()); List<Message> messages = threadStart.GetMessages(newestId, true); // IF NOT DELETED THEN foreach (Message message in messages) { RenderMessage(core, template, message); newestId = message.Id; } threadStart.MarkRead(); Dictionary<string, string> returnValues = new Dictionary<string, string>(); returnValues.Add("update", "true"); returnValues.Add("template", template.ToString()); returnValues.Add("newest-id", newestId.ToString()); core.Response.SendDictionary("newMessages", returnValues); } catch (InvalidMessageRecipientException) { // Security, if not a recipeint, cannot see the message. core.Functions.Generate404(); } }