Beispiel #1
0
    public void Delete_Click(object sender, EventArgs e)
    {
        int PMID = (int)Util.Val(Request.QueryString["pmid"]);

        PrivateMessageRepository Message = new PrivateMessageRepository();
        Message.LyricUserID = UserIdentity.UserID;
        Message.ID = PMID;

        Message.Delete(Message);

        Response.Redirect("confirmupdateprivatemsg.aspx?mode=delete&pid=" + PMID);
    }
    private void DeleteSentPM()
    {
        if (Authentication.IsUserAuthenticated)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["pmid"]) && Utility.IsNumeric(Request.QueryString["pmid"]))
            {
                PrivateMessageRepository SentMessage = new PrivateMessageRepository();
                SentMessage.SenderUserID = UserIdentity.UserID;
                SentMessage.ID = int.Parse(Request.QueryString["pmid"]);

                SentMessage.DeleteSentPM(SentMessage);

                SentMessage = null;

                Response.Write(" ");
            }
        }
        else
        {
            Response.Write("Not Authorized.");
        }
    }
    private void DeleteInBoxPM()
    {
        if (Authentication.IsUserAuthenticated)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["pmid"]) && Utility.IsNumeric(Request.QueryString["pmid"]))
            {
                PrivateMessageRepository Message = new PrivateMessageRepository();
                Message.LyricUserID = UserIdentity.UserID;
                Message.ID = int.Parse(Request.QueryString["pmid"]);

                Message.Delete(Message);

                Message = null;

                Response.Write(" ");
            }
        }
        else
        {
            Response.Write("Không có quyền.");
        }
    }
Beispiel #4
0
    public void SendPM_Click(Object s, EventArgs e)
    {
        if (Authentication.IsUserAuthenticated)
        {
            if (Page.IsValid)
            {
                PrivateMessageRepository Message = new PrivateMessageRepository();

                string mode = Request.QueryString["method"];

                if (mode == "newmsg")
                {
                    Message.Subject = Util.FormatTextForInput(Request.Form["PMSubject"]);
                    Message.LyricUserName = Util.FormatTextForInput(Request.Form["PMSendTo"]).Trim();
                }
                if (mode == "reply")
                {
                    Message.Subject = "RE: " + Server.UrlDecode(Request.QueryString["subject"]).Trim();
                    Message.LyricUserName = Server.UrlDecode(Request.QueryString["replyto"]).Trim();
                }
                if (mode == "forward")
                {
                    Message.Subject = "FW: " + Server.UrlDecode(Request.QueryString["subject"]).Trim();
                    Message.LyricUserName = Util.FormatTextForInput(Request.Form["PMSendTo"]).Trim();
                }

                Message.SenderUserID = UserIdentity.UserID;
                Message.Message = Request.Form["Content"];

                #region Input Validation

                if (Blogic.IsUsernameAvailable(Message.LyricUserName))
                {
                    lbvalenght.Text = "<br>Error: The recipient username " + Message.LyricUserName + " does not exist.";
                    lbvalenght.Visible = true;
                    return;
                }

                //Check if sender is blocked by the recipient from sending a PM.
                if (Blogic.IsUserBlockedByLyric(Message.LyricUserName, UserIdentity.UserID))
                {
                    lbvalenght.Text = "<br>Error: " + Message.LyricUserName + " Had Blocked You From Sending a PM.";
                    lbvalenght.Visible = true;
                    return;
                }

                //Get the userID
                int GetUserID = Blogic.GetUserIDByUsername(Message.LyricUserName);
                UserFeaturesConfiguration.Fetch(GetUserID);

                if (!UserFeaturesConfiguration.IsUserChooseToReceivePM)
                {
                    lbvalenght.Text = "<br>Error: " + Message.LyricUserName + " opted not to receive a private message.";
                    lbvalenght.Visible = true;
                    return;
                }
                if (Message.Subject.Length == 0)
                {
                    lbvalenght.Text = "<br>Error: The subject is empty.";
                    lbvalenght.Visible = true;
                    return;
                }
                if (Message.Subject.Length > 65)
                {
                    lbvalenght.Text = "<br>Error: The subject is too long. Maximum of 65 characters.";
                    lbvalenght.Visible = true;
                    return;
                }
                if (Message.Message.Length == 0)
                {
                    lbvalenght.Text = "<br>Error: Message is empty.";
                    lbvalenght.Visible = true;
                    return;
                }
                if (Message.Message.Length > 5000)
                {
                    lbvalenght.Text = "<br>Error: The message is too long. Maximum of 5000 characters including HTML formatting.";
                    lbvalenght.Visible = true;
                    return;
                }

                #endregion

                if (Message.Add(Message) != 0)
                {
                    JSLiteral.Text = "An error occured while processing your request.";
                    return;
                }

                if (UserFeaturesConfiguration.IsUserChooseToReceiveEmailAlertReceivePM)
                {
                    SendPMEmailNotification(GetUserID, Message.Subject);
                }

                Response.Redirect("confirmpmsent.aspx?to=" + Message.LyricUserName);

                Message = null;
            }
        }
    }