Ejemplo n.º 1
0
        /// <summary>
        /// The TopLevelList_Select server event handler is used to
        /// expand/collapse a selected discussion topic and delte individual items
        /// </summary>
        /// <param name="Sender"></param>
        /// <param name="e">DataListCommandEventAargs e</param>
        /// <returns>void return</returns>
        public void TopLevelListOrDetailList_Select(object Sender, DataListCommandEventArgs e)
        {
            // Determine the command of the button
            string command = ((System.Web.UI.WebControls.CommandEventArgs)(e)).CommandName;

            // Update asp:datalist selection index depending upon the type of command
            // and then rebind the asp:datalist with content
            switch (command)
            {
            case "CollapseThread":
            {
                TopLevelList.SelectedIndex = -1;                         // nothing is selected
                break;
            }

            case "ExpandThread":
            {
                TopLevelList.SelectedIndex = e.Item.ItemIndex;
                DiscussionDB discuss = new DiscussionDB();
                int          ItemID  = Int32.Parse(e.CommandArgument.ToString());
                discuss.IncrementViewCount(ItemID);
                break;
            }

            case "ShowThreadNewWindow":                     // open up the entire thread in a new window
            {
                TopLevelList.SelectedIndex = e.Item.ItemIndex;
                DiscussionDB discuss = new DiscussionDB();
                int          ItemID  = Int32.Parse(e.CommandArgument.ToString());
                discuss.IncrementViewCount(ItemID);
                Response.Redirect(FormatUrlShowThread(ItemID));
                break;
            }

            /*
             *      case "SelectTitle":
             *      TopLevelList.SelectedIndex = e.Item.ItemIndex;
             *      Response.Redirect(FormatUrlShowThread((int)DataBinder.Eval(Container.DataItem, "ItemID")));
             *      break;
             */
            case "delete":                      // the "delete" command can come from the TopLevelList or the DetailList
            {
                DiscussionDB discuss = new DiscussionDB();
                int          ItemID  = Int32.Parse(e.CommandArgument.ToString());
                discuss.DeleteChildren(ItemID);
                // DetailList.DataBind();	// synchronize the control and database after deletion
                break;
            }

            default:
                break;
            }
            BindList();
        }
Ejemplo n.º 2
0
        //*******************************************************
        //
        // The SubmitBtn_Click server event handler on this page is used
        // to handle the scenario where a user clicks the "submit"
        // button after entering a response to a message post.
        //
        //*******************************************************

        void SubmitBtn_Click(Object sender, EventArgs e)
        {
            base.OnUpdate(e);


            // Create new discussion database component
            DiscussionDB discuss = new DiscussionDB();

            // Add new message (updating the "ItemID" on the page)
            ItemID = discuss.AddMessage(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, Server.HtmlEncode(TitleField.Text), BodyField.Text, GetMode());

            // The following code can be used if you want to create new threads
            // and responses in a separate browser window.  If this is the case
            // 1) uncomment the 2 ResponseWrite() lines below and comment the this.RedirectBackToReferringPage() call
            // 2) Make the 3 xxxTarget=_new changes commented in Discussion.ascx
            // 3) Switch the Response.Wrtie() and Redirect...() comments in CancelBtn_Click() in this file
            //
            // refresh the parent window thread and close the edit window
            // Response.Write("<script>window.opener.navigate(window.opener.document.location.href);</script>"); // update the parent window discussions
            // Response.Write("<script>window.close()</script>");  // close the edit window
            this.RedirectBackToReferringPage();
        }
Ejemplo n.º 3
0
        /// <summary> ThreadList_Select processes user events to add, edit, and delete topics </summary>
        /// <param name="Sender"></param>
        /// <param name="e">DataListCommandEventAargs e</param>
        /// <returns>returns nothing</returns>
        public void ThreadList_Select(object Sender, DataListCommandEventArgs e)
        {
            // Determine the command of the button
            string command = ((System.Web.UI.WebControls.CommandEventArgs)(e)).CommandName;

            switch (command)
            {
            case "delete":
                DiscussionDB discuss = new DiscussionDB();
                int          ItemID  = Int32.Parse(e.CommandArgument.ToString());
                discuss.DeleteChildren(ItemID);
                break;

            case "return_to_discussion_list":
                RedirectBackToReferringPage();
                break;

            default:
                break;
            }
            BindList(GetItemID());
            return;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The Page_Load server event handler on this page is used
        /// to obtain the ModuleID and ItemID of the discussion list,
        /// and to then display the message contents.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Page_Load(object sender, System.EventArgs e)
        {
            //Translations on the buttons, it doesn't appear there is a
            //		tra:LinkButton style supported
            submitButton.Text = Esperantus.Localize.GetString("SUBMIT");
            cancelButton.Text = Esperantus.Localize.GetString("CANCEL");

            // Populate message contents if this is the first visit to the page
            if (Page.IsPostBack == false)
            {
                DiscussionDB  discuss;
                SqlDataReader dr;

                switch (GetMode())
                {
                case "REPLY":
                    if (PortalSecurity.HasAddPermissions(ModuleID) == false)
                    {
                        PortalSecurity.AccessDeniedEdit();
                    }

                    DiscussionEditInstructions.Text = Esperantus.Localize.GetString("DS_REPLYTHISMSG");

                    // Load fields for the item that we are replying to
                    discuss = new DiscussionDB();
                    dr      = discuss.GetSingleMessage(ItemID);
                    try
                    {
                        if (dr.Read())
                        {
                            // Update labels with message contents
                            Title.Text         = (string)dr["Title"];
                            Body.Text          = (string)dr["Body"];
                            CreatedByUser.Text = (string)dr["CreatedByUser"];
                            CreatedDate.Text   = string.Format("{0:d}", dr["CreatedDate"]);
                            TitleField.Text    = string.Empty;                                          // don't give users a default subject for their reply
                            // encourage them to title their response
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (CreatedByUser.Text == "unknown")
                            {
                                CreatedByUser.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                        }
                    }
                    finally
                    {
                        dr.Close();
                    }
                    break;

                case "ADD":
                    if (PortalSecurity.HasAddPermissions(ModuleID) == false)
                    {
                        PortalSecurity.AccessDeniedEdit();
                    }

                    // hide the 'previous message' controls
                    OriginalMessagePanel.Visible = false;
                    break;


                case "EDIT":
                {
                    string itemUserEmail = string.Empty;
                    // hide the 'parent message' controls
                    OriginalMessagePanel.Visible    = false;
                    DiscussionEditInstructions.Text = Esperantus.Localize.GetString("EDIT");

                    // Bind the data to the control
                    // Obtain the selected item from the Discussion table
                    discuss = new DiscussionDB();
                    dr      = discuss.GetSingleMessage(ItemID);

                    try
                    {
                        // Load first row from database
                        if (dr.Read())
                        {
                            // Update edit fields with message contents
                            TitleField.Text = (string)dr["Title"];
                            BodyField.Text  = (string)dr["Body"];
                            itemUserEmail   = (string)dr["CreatedByUser"];
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (itemUserEmail == "unknown")
                            {
                                itemUserEmail = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                        }
                    }
                    finally
                    {
                        dr.Close();
                    }

                    if (DiscussionPermissions.HasEditPermissions(ModuleID, itemUserEmail) == false)
                    {
                        PortalSecurity.AccessDeniedEdit();
                    }
                }
                break;

                /* case "DELETE":
                 *      if (PortalSecurity.HasDeletePermissions(ModuleID) == false)
                 *              PortalSecurity.AccessDeniedEdit();
                 *      break;
                 */

                default:
                    // invalid mode specified
                    PortalSecurity.AccessDeniedEdit();
                    break;
                }
            }
        }