//get IP address of the client //from: http://stackoverflow.com/questions/13889463/get-client-ip-address-in-self-hosted-signalr-hub //delete message, need to control public void DeleteMessage(int messageId, int moduleId) { //todo: look to see if we should get user information from DNN somehow - CJH 3/5/2014 var section = (MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey"); var validationKey = section.ValidationKey; var listOfRoles = (string)Clients.Caller.userroles; if (listOfRoles != null) { var roles = listOfRoles.Split(','); var pc = new PortalSecurity(); foreach (var r in roles) { var thisRole = pc.Decrypt(validationKey, r); //TODO: need to remove the hard coded administrators role here, make this a module setting - CJH 3/6/2014 if (thisRole == "Administrators" || thisRole == "SuperUser") { var mc = new MessageController(); mc.DeleteMessage(messageId, moduleId); //get the message and send it back so that we can remove it from the proper room var m = mc.GetMessage(messageId, moduleId); Clients.Group(m.RoomId.ToString()).deleteMessage(m); } } } }
/* * We need to grab the latest 50 chat messages for the channel, should make this configurable. */ public void RestoreHistory(Guid roomId) { //TODO: make sure the user has access to this room try { int moduleId; //int.TryParse(Clients.Caller.moduleid, out moduleId); moduleId = Convert.ToInt32(Clients.Caller.moduleid); var messages = new MessageController().GetRecentMessages(moduleId, 2, 50, roomId); if (messages != null) { foreach (var msg in messages) { //TODO: we need to figure out how to make sure it goes to the right room //msg.PhotoUrl = GetPhotoUrl(msg.AuthorUserId); Clients.Caller.newMessageNoParse(msg); } } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } }
protected void Page_Load(object sender, EventArgs e) { try { //TODO: be sure to check for permissions when enabled if (!Page.IsPostBack) { var sd = Request.QueryString["sd"]; var ed = Request.QueryString["ed"]; var startDate = DateTime.UtcNow.Date; var endDate = DateTime.UtcNow; if (sd != null) { startDate = Convert.ToDateTime(sd); } if (ed != null) { endDate = Convert.ToDateTime(ed); } txtStartDate.Text = startDate.ToString(CultureInfo.InvariantCulture); txtEndDate.Text = endDate.ToString(CultureInfo.InvariantCulture); var mc = new MessageController(); rptMessages.DataSource = mc.GetMessagesByDate(ModuleId, startDate, endDate, RoomId); rptMessages.DataBind(); //if we have any items, don't display the "no results found" message if (rptMessages.Items.Count > 0) { lblNoResults.Visible = false; } BuildArchiveLinks(RoomId); var rc = new RoomController(); var r = rc.GetRoom(RoomId, ModuleId); var tp = (CDefault)Page; var t = new TabController().GetTab(TabId, PortalId, false); tp.Title += string.Format(Localization.GetString("ChatArchiveTitle.Text", LocalResourceFile), t.TabName, r.RoomName, startDate.ToShortDateString(), endDate.ToShortDateString()); lblArchiveTitle.Text = string.Format(Localization.GetString("ChatArchiveContentTitle.Text", LocalResourceFile), r.RoomName, startDate.ToShortDateString(), endDate.ToShortDateString()); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }