protected void modifyForum(object sender, CommandEventArgs e)
        {
            int pId = 0;
            if (!string.IsNullOrEmpty(Request.QueryString["id"]) && int.TryParse(Request.QueryString["id"], out pId) && umbraco.library.IsLoggedOn()) {

                Member m = Member.GetCurrentMember();
                Document d = new Document(pId);
                Document fnode = null;

                if (e.CommandName == "edit") {
                    int fId = int.Parse(e.CommandArgument.ToString());
                    fnode = new Document(fId);

                } else if(e.CommandName == "create") {

                    fnode = Document.MakeNew(tb_name.Text, DocumentType.GetByAlias("Forum"), new umbraco.BusinessLogic.User(0), d.Id);

                } else if(e.CommandName == "delete"){

                    int fId = int.Parse(e.CommandArgument.ToString());

                    if (Document.IsDocument(fId))
                    {
                        fnode = new Document(fId);
                    }

                    if (fnode != null)
                    {
                        if ((int)d.getProperty("owner").Value == m.Id && fnode.ParentId == d.Id)
                        {
                            fnode.delete();

                            //if still not dead it's because it's in the trashcan and should be deleted once more.
                            if (fnode.ParentId == -20)
                                fnode.delete();

                        }

                        if (fnode.ParentId == -20)
                            fnode.delete();

                        fnode = null;

                    }

                    var forum = new uForum.Businesslogic.Forum(fId);
                    if (forum.Exists)
                    {
                        forum.Delete();
                    }

                }

                if (fnode != null && (int)d.getProperty("owner").Value == m.Id && fnode.ParentId == d.Id) {
                    fnode.Text = tb_name.Text;
                    fnode.getProperty("forumDescription").Value = tb_desc.Text;
                    fnode.getProperty("forumAllowNewTopics").Value = true;
                    fnode.Publish(new umbraco.BusinessLogic.User(0));
                    fnode.Save();
                    umbraco.library.UpdateDocumentCache(fnode.Id);
                }

                Response.Redirect(Node.GetCurrent().NiceUrl + "?id=" + pId.ToString());

            }
        }
Exemplo n.º 2
0
        protected void modifyForum(object sender, CommandEventArgs e)
        {
            int pId = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["id"]) && int.TryParse(Request.QueryString["id"], out pId) && umbraco.library.IsLoggedOn())
            {
                Member   m     = Member.GetCurrentMember();
                Document d     = new Document(pId);
                Document fnode = null;

                if (e.CommandName == "edit")
                {
                    int fId = int.Parse(e.CommandArgument.ToString());
                    fnode = new Document(fId);
                }
                else if (e.CommandName == "create")
                {
                    fnode = Document.MakeNew(tb_name.Text, DocumentType.GetByAlias("Forum"), new umbraco.BusinessLogic.User(0), d.Id);
                }
                else if (e.CommandName == "delete")
                {
                    int fId = int.Parse(e.CommandArgument.ToString());

                    if (Document.IsDocument(fId))
                    {
                        fnode = new Document(fId);
                    }



                    if (fnode != null)
                    {
                        if ((int)d.getProperty("owner").Value == m.Id && fnode.ParentId == d.Id)
                        {
                            fnode.delete();

                            //if still not dead it's because it's in the trashcan and should be deleted once more.
                            if (fnode.ParentId == -20)
                            {
                                fnode.delete();
                            }
                        }

                        if (fnode.ParentId == -20)
                        {
                            fnode.delete();
                        }

                        fnode = null;
                    }

                    var forum = new uForum.Businesslogic.Forum(fId);
                    if (forum.Exists)
                    {
                        forum.Delete();
                    }
                }

                if (fnode != null && (int)d.getProperty("owner").Value == m.Id && fnode.ParentId == d.Id)
                {
                    fnode.Text = tb_name.Text;
                    fnode.getProperty("forumDescription").Value    = tb_desc.Text;
                    fnode.getProperty("forumAllowNewTopics").Value = true;
                    fnode.Publish(new umbraco.BusinessLogic.User(0));
                    fnode.Save();
                    umbraco.library.UpdateDocumentCache(fnode.Id);
                }


                Response.Redirect(Node.GetCurrent().NiceUrl + "?id=" + pId.ToString());
            }
        }