Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!Page.IsPostBack)
         {
             if (EntryId > 0)
             {
                 if (UserId == -1)
                 {
                     throw new Exception("Anonymous users cannot edit messages");
                 }
                 var entry = EntryController.GetEntry(EntryId, ModuleId);
                 if (!CanEdit)
                 {
                     if (entry.CreatedByUserID != UserId)
                     {
                         throw new Exception("You cannot edit someone else's message");
                     }
                 }
                 txtMessage.Text = entry.Message;
             }
             divApproveWarning.Visible = !Settings.AutoApprove;
         }
     }
     catch (Exception exc)             //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
Example #2
0
 protected void rpGuestbook_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         var entry = EntryController.GetEntry(Convert.ToInt32(e.CommandArgument), ModuleId);
         if (entry != null)
         {
             EntryController.DeleteEntry(entry);
         }
     }
     if (e.CommandName == "Approve")
     {
         var entry = EntryController.GetEntry(Convert.ToInt32(e.CommandArgument), ModuleId);
         if (entry != null)
         {
             EntryController.Approve(entry);
         }
     }
     Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
 }
Example #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var entry = new EntryInfo();

            if (EntryId > 0)
            {
                if (UserId == -1)
                {
                    throw new Exception("Anonymous users cannot edit messages");
                }
                entry = EntryController.GetEntry(EntryId, ModuleId);
                if (!CanEdit)
                {
                    if (entry.CreatedByUserID != UserId)
                    {
                        throw new Exception("You cannot edit someone else's message");
                    }
                }
            }
            else
            {
                entry.Approved = Settings.AutoApprove;
                entry.ModuleId = ModuleId;
            }

            entry.Message = (new PortalSecurity()).InputFilter(txtMessage.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoSQL | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets);

            if (EntryId > 0)
            {
                EntryController.UpdateEntry(entry, UserId);
            }
            else
            {
                EntryController.AddEntry(entry, UserId);
            }
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }