protected void DebateList_ItemCommand(object source, TreeListCommandEventArgs e) { if (e.CommandName == "replyMessage") { if (e.Item is TreeListDetailTemplateItem) { TreeListDetailTemplateItem itm = e.Item as TreeListDetailTemplateItem; if (!Request.IsAuthenticated) { needLoginLblTop.Visible = true; needLoginLblBottom.Visible = true; needLoginLblTop.Text = "<div class='dnnFormMessage dnnFormWarning'>" + Localization.GetString("LoggedIn", LocalResourceFile) + " <a href='" + ConfigurationManager.AppSettings["DomainName"] + /*"/" + * System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/ "/login.aspx?returnurl=" + HttpUtility.UrlEncode(Request.Url.PathAndQuery) + "'>" + Localization.GetString("Login", LocalResourceFile) + "</a></div>"; needLoginLblBottom.Text = needLoginLblTop.Text; } else { itm.CssClass = "whiteBack"; LinkButton newPostBtn = (LinkButton)itm.FindControl("newPostBtn"); newPostBtn.CssClass = "newPostActive"; TreeListDataItem parentPost = itm.ParentItem; parentPost.IsChildInserted = true; DebateList.Rebind(); } } } }
private void FindAndSelectItem(int id) { //first check if the item is not already in the Items collection foreach (var item in DebateList.Items) { if ((int)item.GetDataKeyValue("ID") == id) { item.Selected = true; return; } } //save the previously expanded indexes var expandedIndexes = new TreeListHierarchyIndex[DebateList.ExpandedIndexes.Count]; DebateList.ExpandedIndexes.CopyTo(expandedIndexes); //add newly expanded indexes here var newIndexes = new List <TreeListHierarchyIndex>(); //cause all items to expand to reveal all data DebateList.ExpandAllItems(); //loop through all the items and search for the target by its key value foreach (var item in DebateList.Items) { if ((int)item.GetDataKeyValue("ID") == id) { //select the item item.Selected = true; //expand all parents of the item var parent = item.ParentItem; while (parent != null) { newIndexes.Add(parent.HierarchyIndex); parent = parent.ParentItem; } } } //shrink back the treelist DebateList.CollapseAllItems(); //restore the previously expanded indexes DebateList.ExpandedIndexes.AddRange(expandedIndexes); //add the newly expanded indexes that will reveal the selected item foreach (var index in newIndexes) { if (!DebateList.ExpandedIndexes.Contains(index)) { DebateList.ExpandedIndexes.Add(index); } } //rebind to reflect the changes DebateList.Rebind(); }
protected void DebateList_InsertCommand(object sender, TreeListCommandEventArgs e) { string ConnString = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString; string commandText = @"INSERT INTO uDebate_Forum_Posts (ThreadID, ParentID, UserID, PostLevel, SortOrder, Subject, Message, PostDate, IsPublished, PostType, Active, Published_Date, Complaint_Count, ModuleID) VALUES (@ThreadID, @ParentID, " + UserInfo.UserID + @", 1, 1, @Subject, @Message, getDate(), 1, @PostType,1,getDate(),0," + ModuleId + ")"; SqlConnection conn = new SqlConnection(ConnString); SqlCommand command = new SqlCommand(commandText, conn); Hashtable table = new Hashtable(); TreeListEditFormInsertItem item = e.Item as TreeListEditFormInsertItem; table["Subject"] = (item.FindControl("txtSubjectPost") as TextBox).Text; table["Message"] = (item.FindControl("txtReply") as DotNetNuke.Web.UI.WebControls.DnnEditor).GetHtml(EditorStripHtmlOptions.None).Replace("'", "\""); RadioButton Issue = (item.FindControl("IssueRadio") as RadioButton); RadioButton Alter = (item.FindControl("AlterRadio") as RadioButton); RadioButton Pro = (item.FindControl("ProRadio") as RadioButton); RadioButton Con = (item.FindControl("ConRadio") as RadioButton); RadioButton Comment = (item.FindControl("CommentRadio") as RadioButton); String selection = String.Empty; if (Issue.Checked) { selection = "1"; } else if (Alter.Checked) { selection = "2"; } else if (Pro.Checked) { selection = "3"; } else if (Con.Checked) { selection = "4"; } else if (Comment.Checked) { selection = "8"; } table["PostType"] = selection; command.Parameters.AddWithValue("ThreadID", Thread_ID); command.Parameters.AddWithValue("Subject", table["Subject"]); command.Parameters.AddWithValue("Message", table["Message"]); command.Parameters.AddWithValue("PostType", table["PostType"]); object parentValue; if (item.ParentItem != null) { parentValue = item.ParentItem.GetDataKeyValue("ID"); } else { parentValue = "0"; } command.Parameters.AddWithValue("ParentID", parentValue); conn.Open(); try { command.ExecuteNonQuery(); /*if the new post is a reply we have to disable edit mode of parent and expand it */ if (item.ParentItem != null) { item.ParentItem.Expanded = true; item.ParentItem.IsChildInserted = false; } DebateList.IsItemInserted = false; DebateList.Rebind(); DataRow lastPost = getLatestPostOfThread(Thread_ID); if (lastPost != null) { FindAndSelectItem(Convert.ToInt32(lastPost["ID"])); } } finally { conn.Close(); } /* If a user posts to a thread we add him to the notification list*/ AddUserToNotified(Thread_ID); notifyCheck.Checked = true; string fromAddress = "*****@*****.**"; string subject = "OGP Ireland - New Post"; string body = "Hi, <br /><br/>A new post has been submitted to the OGP Ireland thread \"<b>" + getDescription(Thread_ID) + "\"</b>.<br /> To see this post, visit " + ConfigurationManager.AppSettings["DomainName"] +/* "/" + * System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/ "/udebatediscussion.aspx?Thread=" + Thread_ID + "<br /><br/>Kind Regards,<br /><br/>" + PortalSettings.PortalName + "<br /><a href='" + PortalSettings.DefaultPortalAlias + "'>" + PortalSettings.DefaultPortalAlias + "</a>" + "<br /><br />" + "<img src='http://" + PortalSettings.DefaultPortalAlias + "/Portals/0/pbp_logo270.jpg'/>"; SendTokenizedBulkEmail mailer = new SendTokenizedBulkEmail(); /* Notify moderators of the new post*/ switch (getPostLanguageByThread(Thread_ID).ToLower()) { case "el-gr": Entities.Users.UserInfo user = new Entities.Users.UserInfo(); user.Email = "*****@*****.**"; mailer.AddAddressedUser(user); break; /* case "es-es": * Entities.Users.UserInfo user3 = new Entities.Users.UserInfo(); * user3.Email = "*****@*****.**"; * mailer.AddAddressedUser(user3); * Entities.Users.UserInfo user4 = new Entities.Users.UserInfo(); * user4.Email = "*****@*****.**"; * mailer.AddAddressedUser(user4); * Entities.Users.UserInfo user5 = new Entities.Users.UserInfo(); * user5.Email = "*****@*****.**"; * mailer.AddAddressedUser(user5); * break; * case "it-it": * Entities.Users.UserInfo user7 = new Entities.Users.UserInfo(); * user7.Email = "*****@*****.**"; * mailer.AddAddressedUser(user7); * break; * case "hu-hu": * Entities.Users.UserInfo user9 = new Entities.Users.UserInfo(); * user9.Email = "*****@*****.**"; * mailer.AddAddressedUser(user9); * break; * case "en-gb": * Entities.Users.UserInfo user11 = new Entities.Users.UserInfo(); * user11.Email = "*****@*****.**"; * mailer.AddAddressedUser(user11); * Entities.Users.UserInfo user12 = new Entities.Users.UserInfo(); * user12.Email = "*****@*****.**"; * mailer.AddAddressedUser(user12); * break;*/ default: break; } Entities.Users.UserInfo user14 = new Entities.Users.UserInfo(); user14.Email = "*****@*****.**"; mailer.AddAddressedUser(user14); mailer.Priority = DotNetNuke.Services.Mail.MailPriority.Normal; mailer.AddressMethod = DotNetNuke.Services.Mail.SendTokenizedBulkEmail.AddressMethods.Send_TO; Entities.Users.UserInfo senderUser = new Entities.Users.UserInfo(); senderUser.Email = "*****@*****.**"; mailer.SendingUser = senderUser; mailer.ReportRecipients = false; mailer.Subject = subject; mailer.Body = body; mailer.BodyFormat = DotNetNuke.Services.Mail.MailFormat.Html; Thread objThread = new Thread(mailer.Send); objThread.Start(); /* Send an email to all the subscribed users of this thread*/ string subjectNotify = "OGP Ireland - There is a new post in the thread you are following"; string bodyNotify = "Hi, <br /><br/>A new post has been submitted to the OGP Ireland thread \"<b>" + getDescription(Thread_ID) + "\"</b>.<br /> To see this post, visit " + ConfigurationManager.AppSettings["DomainName"] + /*"/" + * System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/ "/udebatediscussion.aspx?Thread=" + Thread_ID + "<br /><br/>Kind Regards,<br /><br/>" + PortalSettings.PortalName + "<br /><a href='" + PortalSettings.DefaultPortalAlias + "'>" + PortalSettings.DefaultPortalAlias + "</a>" + "<br /><br />" + "<img src='http://" + PortalSettings.DefaultPortalAlias + "/Portals/0/pbp_logo270.jpg'/>"; string SQL_notified = "SELECT userID,userEmail FROM uDebate_Forum_Notifications where threadID=" + Thread_ID; try { DataSet ds = ATC.Database.sqlExecuteDataSet(SQL_notified); if (ds.Tables[0].Rows.Count > 0) { SendTokenizedBulkEmail notificationMailer = new SendTokenizedBulkEmail(); foreach (DataRow row in ds.Tables[0].Rows) { // Only send email to users different than the current one (the post writer) if (UserId != Int32.Parse(row["userID"].ToString())) { int numRecs = 100; ArrayList findEmailinRegistered = Entities.Users.UserController.GetUsersByEmail(PortalId, row["userEmail"].ToString(), 0, 10, ref numRecs, false, false); //Check that the user is still registered if (findEmailinRegistered.Count > 0) { Entities.Users.UserInfo newUser = new Entities.Users.UserInfo(); newUser.Email = row["userEmail"].ToString(); notificationMailer.AddAddressedUser(newUser); } //if no, remove him from the list of notified users else { RemoveUserFromNotified(row["userEmail"].ToString()); } } } notificationMailer.Priority = DotNetNuke.Services.Mail.MailPriority.Normal; notificationMailer.AddressMethod = DotNetNuke.Services.Mail.SendTokenizedBulkEmail.AddressMethods.Send_TO; Entities.Users.UserInfo sendingUser = new Entities.Users.UserInfo(); sendingUser.Email = "*****@*****.**"; notificationMailer.SendingUser = sendingUser; notificationMailer.ReportRecipients = true; notificationMailer.Subject = subjectNotify; notificationMailer.Body = bodyNotify; notificationMailer.BodyFormat = DotNetNuke.Services.Mail.MailFormat.Html; Thread objThread1 = new Thread(notificationMailer.Send); objThread1.Start(); } } catch (Exception ex) { Response.Write(ex.Message); } }
protected void newDiscussionBtn_Click(Object sender, EventArgs e) { DebateList.IsItemInserted = true; DebateList.Rebind(); }
protected void expandLink_Click(Object sender, EventArgs e) { DebateList.ExpandAllItems(); }