protected void delete_Click(object sender, EventArgs e)
        {
            // delete group
               Document group = new Document(this.SelectedNodeID);
               group.delete(true);

            //Response.Redirect("MembershipManagement.aspx?memgsearch=" + this.txtSearchMembergroup.Text + "&memsearch=" + this.txtSearchMember.Text + "&groupid=" + this.SelectedNodeID + "&documenttype=" + Request.QueryString["documenttype"].ToString());
        }
Exemple #2
0
        public bool Delete()
        {
            var d = new cms.businesslogic.web.Document(ParentID);

            d.delete();

            // Log
            Log.Add(LogTypes.Delete, User.GetCurrent(), d.Id, "");

            return true;

        }
        public string Delete(int wikiId)
        {
            var currentMemberId = Members.GetCurrentMember().Id;

            if (Xslt.IsMemberInGroup("admin", currentMemberId) || Xslt.IsMemberInGroup("wiki editor", currentMemberId))
            {
                var document = new Document(wikiId);

                umbraco.library.UnPublishSingleNode(document.Id);
                document.delete();
            }

            return "";
        }
Exemple #4
0
        public bool Delete()
        {
            cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(ParentID);

            // Log
            BasePages.UmbracoEnsuredPage bp = new BasePages.UmbracoEnsuredPage();
            BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, bp.getUser(), d.Id, "");

            library.UnPublishSingleNode(d.Id);

            d.delete();

            return true;
        }
Exemple #5
0
        public bool Delete()
        {
            cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(ParentID);

            // Log
            BusinessLogic.Log.Add(BusinessLogic.LogTypes.Delete, User.GetCurrent(), d.Id, "");

            library.UnPublishSingleNode(d.Id);

            d.delete();

            return true;

        }
 /// <summary>On event, after moving document to trash.</summary>
 protected void Document_AfterMoveToTrash(Document sender, MoveToTrashEventArgs e)
 {
     // Validate document have a relation and is trashed.
     if(sender.Relations.Length > 0) {
     foreach(var r in sender.Relations) {
         // Validate document is from "Main Site" sender and relation type.
         if(r.Parent.Id == sender.Id && r.RelType.Alias == "relateDocumentOnCopy") {
             // Get document from relation object.
             var doc = new Document(r.Child.Id);
             // Append log, audit trail.
             Log.Add(LogTypes.Delete, doc.ParentId, String.Format("Document (name:{0} id:{1}) related to document (name:{2} id:{3}) moved to trash.", r.Child.Text, r.Child.Id, sender.Text, sender.Id));
             // Unpublish and move document (that is child related) to trash.
             doc.delete();
         }
     }
     }
 }
 /// <summary>
 /// Handles the <c>MessageReceived</c> event of the manager.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 protected override void Manager_MessageReceived(object sender, MesssageReceivedArgs e)
 {
     switch (e.Type)
     {
         case "deletecontent":
             Document currentPage = new Document(int.Parse(UmbracoContext.Current.PageId.ToString()));
             string redirectUrl = "/";
             try
             {
                 redirectUrl = library.NiceUrl(currentPage.Parent.Id);
             }
             catch { }
             currentPage.delete();
             Page.Response.Redirect(redirectUrl);
             break;
     }
 }
Exemple #8
0
        public static string Delete(int ID)
        {
            int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;

            if (Xslt.IsMemberInGroup("admin", _currentMember) || Xslt.IsMemberInGroup("wiki editor", _currentMember))
            {
                Document d = new Document(ID);

                if (d != null)
                {
                    umbraco.library.UnPublishSingleNode(d.Id);
                    d.delete();
                }
            }

            return "";
        }
        private void DeletePost()
        {
            // Make sure we have a post id available to us
            int? pId = null;
            if (Request.QueryString["p"] != null)
                pId = Request.QueryString["p"].ToInt32();

            // get the referring page
            var previouspage = HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Split('?')[0];

            if (pId != null && MembershipHelper.IsAuthenticated())
            {
                var postID = pId.ToInt32();
                // great we have a postid, now check the user is allowed to delete it
                var posttodelete = Mapper.MapForumPost(new Node(postID));

                if (posttodelete.Owner.MemberId == CurrentMember.MemberId | CurrentMember.MemberIsAdmin)
                {
                    // These are used either way
                    var topic = new Document(posttodelete.ParentId.ToInt32());

                    // We know we can delete this, but if its a topic starter then delete entire topic
                    if(posttodelete.IsTopicStarter)
                    {
                        var topicId = topic.Id;
                        // Its a topic starter so delete entire topic
                        if (topic.Published)
                        {
                            topic.UnPublish();
                            library.UnPublishSingleNode(topicId);
                        }
                        topic.delete();

                        library.RefreshContent();

                        // Redirect and show message
                        Response.Redirect(string.Concat(Settings.Url, "?nf=true&m=", library.GetDictionaryItem("DeletedText")));
                    }
                    else
                    {
                        // Its just a normal post, delete it
                        var p = new Document(postID);
                        if (p.Published)
                        {
                            p.UnPublish();
                            library.UnPublishSingleNode(postID);
                        }
                        p.delete();

                        // Little bit of a hack to update the topic with the new latest post date
                        Factory.UpdateTopicWithLastPostDate(topic.Id);

                        library.RefreshContent();

                        // Redirect and show message
                        Response.Redirect(string.Concat(previouspage, "?nf=true&m=", library.GetDictionaryItem("DeletedText")));
                    }
                }

            }
            //Error so just redirect back to the page
            Response.Redirect(previouspage);
        }
Exemple #10
0
        /// <summary>
        /// Completely remove the document, this will first recycle it and then delete it (the api doesn't directly support deleting completey in one step)
        /// </summary>
        /// <param name="d"></param>
        internal static void RecycleAndDelete(Document d)
        {
            if (d == null)
            {
                return;
            }

            var id = d.Id;

            //check if it is already trashed
            var alreadyTrashed = d.IsTrashed;

            if (!alreadyTrashed)
            {
                //now recycle it
                d.delete();

                Assert.IsTrue(d.IsTrashed);                
            }

            //now permanently delete
            d.delete(true);
            Assert.IsFalse(Document.IsNode(id));

            //check with sql that it is gone
            var count = Application.SqlHelper.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoNode WHERE id=@id",
                Application.SqlHelper.CreateParameter("@id", id));

            Assert.AreEqual(0, count);
        }
 private void UnpublishAndTrashDocument(Document document)
 {
     if (document.Published)
     {
         document.UnPublish();
         umbraco.library.UnPublishSingleNode(document.Id);
     }
     document.delete();
 }
        public void delete(int id, string username, string password)
        {
            Authenticate(username, password);

            // Some validation, to prevent deletion of system-documents.. (nessecary?)
            if (id < 0)
            {
                throw new Exception("Cannot delete documents with id lower than 1");
            }

            // We load the document
            Document doc = null;
            try
            {
                doc = new Document(id);
            }
            catch
            { }

            if (doc == null)
                throw new Exception("Document not found");

            try
            {
                doc.delete();
            }
            catch (Exception ex)
            {
                throw new Exception("Document could not be deleted" + ex.Message);
            }
        }
Exemple #13
0
        /// <summary>
        /// Handles the <c>MessageReceived</c> event of the manager.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        protected override void Manager_MessageReceived(object sender, MesssageReceivedArgs e)
        {
            switch (e.Type)
            {
                case "deletecontent":
                    Document currentPage = new Document(int.Parse(UmbracoContext.Current.PageId.ToString()));
                    string redirectUrl = "/";
                    try
                    {
                        redirectUrl = library.NiceUrl(currentPage.Parent.Id);
                    }
                    catch { }
                    library.UnPublishSingleNode(currentPage.Id);
                    currentPage.delete();
                    //Unpublish (triphulcas way)
                    currentPage.SetProperty("public", 0);

                    //disable live editing:
                    UmbracoContext.Current.LiveEditingContext.Enabled = false;

                    Page.Response.Redirect(redirectUrl);
                    break;
            }
        }