public bool DeleteContent(string newsId) { try { SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); News news = new News(siteSettings.SiteId, Convert.ToInt32(newsId)); if (news != null && news.NewsID != -1) { NewsHelper.DeleteFolder(siteSettings.SiteId, news.NewsID); ContentMedia.DeleteByContent(news.NewsGuid); var listAtributes = ContentAttribute.GetByContentAsc(news.NewsGuid); foreach (ContentAttribute item in listAtributes) { ContentLanguage.DeleteByContent(item.Guid); } ContentAttribute.DeleteByContent(news.NewsGuid); ContentLanguage.DeleteByContent(news.NewsGuid); news.Delete(); FriendlyUrl.DeleteByPageGuid(news.NewsGuid); FileAttachment.DeleteByItem(news.NewsGuid); } } catch (Exception) { return(false); } return(true); }
private void btnDelete_Click(Object sender, ImageClickEventArgs e) { if (lbPages.SelectedIndex > -1) { ContentMetaRespository metaRepository = new ContentMetaRespository(); foreach (mojoSiteMapNode page in sitePages) { if ((page.PageId.ToString() == lbPages.SelectedValue) && ((canEditAnything) || (WebUser.IsInRoles(page.EditRoles)))) { if (WebConfigSettings.LogIpAddressForContentDeletions) { log.Info("user deleted page " + page.Url + " from ip address " + SiteUtils.GetIP4Address()); } PageSettings pageSettings = new PageSettings(siteSettings.SiteId, page.PageId); metaRepository.DeleteByContent(page.PageGuid); Module.DeletePageModules(page.PageId); PageSettings.DeletePage(page.PageId); FriendlyUrl.DeleteByPageGuid(page.PageGuid); mojoPortal.SearchIndex.IndexHelper.ClearPageIndexAsync(pageSettings); } } CacheHelper.ResetSiteMapCache(); WebUtils.SetupRedirect(this, Request.RawUrl); } else { // no page selected litWarning.Text = Resource.PagesNoSelectionWarning; } }
public override void DeleteContent(int moduleId, Guid moduleGuid) { Blog.DeleteByModule(moduleId); ContentMetaRespository metaRepository = new ContentMetaRespository(); metaRepository.DeleteByModule(moduleGuid); FriendlyUrl.DeleteByPageGuid(moduleGuid); }
public void DeleteBlogPost(int postId) { Blog blog = new Blog(postId); blog.ContentChanged += new ContentChangedEventHandler(blog_ContentChanged); blog.Delete(); FriendlyUrl.DeleteByPageGuid(blog.BlogGuid); SiteUtils.QueueIndexing(); }
public bool DeleteContent(string productId) { try { SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); Product product = new Product(siteSettings.SiteId, Convert.ToInt32(productId)); if (product != null && product.ProductId != -1) { ProductHelper.DeleteFolder(siteSettings.SiteId, product.ProductId); ContentMedia.DeleteByContent(product.ProductGuid); ShoppingCartItem.DeleteByProduct(product.ProductId); var listAtributes = ContentAttribute.GetByContentAsc(product.ProductGuid); foreach (ContentAttribute item in listAtributes) { ContentLanguage.DeleteByContent(item.Guid); } ContentAttribute.DeleteByContent(product.ProductGuid); ContentLanguage.DeleteByContent(product.ProductGuid); ProductProperty.DeleteByProduct(product.ProductId); FriendlyUrl.DeleteByPageGuid(product.ProductGuid); ProductComment.DeleteByProduct(product.ProductId); TagItem.DeleteByItem(product.ProductGuid); FileAttachment.DeleteByItem(product.ProductGuid); RelatedItem.DeleteByItem(product.ProductGuid); product.Delete(); } } catch (Exception) { return(false); } return(true); }
private void btnDelete_Click(object sender, EventArgs e) { Product p = new Product(productGuid); if (WebConfigSettings.LogIpAddressForContentDeletions) { log.Info("user deleted product " + p.Name + " from ip address " + SiteUtils.GetIP4Address()); } FriendlyUrl.DeleteByPageGuid(p.Guid); ContentChangedEventArgs args = new ContentChangedEventArgs(); args.IsDeleted = true; product_ContentChanged(p, args); Product.Delete( productGuid, siteUser.UserGuid, SiteUtils.GetIP4Address()); SiteUtils.QueueIndexing(); WebUtils.SetupRedirect(this, GetReturnUrl()); }
private void HandleDelete() { PageActionResult result = new PageActionResult(); if (!context.Request.IsAuthenticated) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("rejected page delete request for anonymous user"); return; } int delNodeId = -1; if (context.Request.Form["delNode"] != null) { int.TryParse(context.Request.Form["delNode"], out delNodeId); } if (delNodeId == -1) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("no pageid provided for delete command"); return; } //log.Info("node to delete " + delNodeId); LoadSiteMapSettings(); mojoSiteMapNode deleteNode = SiteUtils.GetSiteMapNodeForPage(rootNode, delNodeId); if (deleteNode == null) { result.Success = false; result.Message = PageManagerResources.InvalidRequest; RenderPageActionResult(result); log.Info("node not found for delete command"); return; } if (!WebUser.IsInRoles(deleteNode.EditRoles)) { result.Success = false; result.Message = string.Format( CultureInfo.InvariantCulture, PageManagerResources.DeletePageNotAllowedFormat, deleteNode.Title); RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.DeletePageDeniedLogFormat, currentUserName, deleteNode.Title, deleteNode.PageId ) ); } return; } if (deleteNode.ChildNodes.Count > 0) { if (!WebUser.IsInRoles(siteSettings.RolesThatCanCreateRootPages)) { // child pages would be orphaned to becomne root level // but user does not have permission to create root pages result.Success = false; result.Message = PageManagerResources.CantOrphanPagesWarning; RenderPageActionResult(result); log.Info("delete would orphan child pages to root but user does not have permission"); return; } } ContentMetaRespository metaRepository = new ContentMetaRespository(); PageSettings pageSettings = new PageSettings(siteSettings.SiteId, deleteNode.PageId); metaRepository.DeleteByContent(deleteNode.PageGuid); Module.DeletePageModules(deleteNode.PageId); PageSettings.DeletePage(deleteNode.PageId); FriendlyUrl.DeleteByPageGuid(deleteNode.PageGuid); mojoPortal.SearchIndex.IndexHelper.ClearPageIndexAsync(pageSettings); CacheHelper.ResetSiteMapCache(); result.Success = true; result.Message = "Success"; RenderPageActionResult(result); if (logAllActions) { log.Info( string.Format( CultureInfo.InvariantCulture, PageManagerResources.DeletePageSuccessLogFormat, currentUserName, deleteNode.Title, deleteNode.PageId ) ); } }