Ejemplo n.º 1
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            if (moduleID > -1)
            {
                ArrayList pageIDs   = new ArrayList();
                ArrayList sitePages = new ArrayList();
                PopulatePageArray(sitePages);
                List <ModuleDecoratedSiteMapNode> pageList
                    = ModuleDecoratedSiteMapNode.GetDecoratedNodes(sitePages, moduleID);

                foreach (ModuleDecoratedSiteMapNode decoratedPage in pageList)
                {
                    if (decoratedPage.IsPublished)
                    {
                        pageIDs.Add(decoratedPage.PageId);
                    }
                }

                foreach (int p in pageIDs)
                {
                    Module.DeleteModuleInstance(this.moduleID, p);
                    IndexHelper.RebuildPageIndexAsync(new PageSettings(siteSettings.SiteId, p));
                }

                Module           m       = new Module(moduleID);
                ModuleDefinition feature = new ModuleDefinition(m.ModuleDefId);

                if (feature.DeleteProvider.Length > 0)
                {
                    try
                    {
                        ContentDeleteHandlerProvider contentDeleter = ContentDeleteHandlerProviderManager.Providers[feature.DeleteProvider];
                        if (contentDeleter != null)
                        {
                            contentDeleter.DeleteContent(m.ModuleId, m.ModuleGuid);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("Failed to invoke content delete handler " + feature.DeleteProvider, ex);
                    }
                }

                Module.DeleteModule(this.moduleID);
            }

            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetNavigationSiteRoot());
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (module.ModuleId > -1)
            {
                DataTable pageIds = Module.GetPageModulesTable(module.ModuleId);

                foreach (DataRow row in pageIds.Rows)
                {
                    int pageId = Convert.ToInt32(row["PageID"]);
                    Module.DeleteModuleInstance(module.ModuleId, pageId);
                    IndexHelper.RebuildPageIndexAsync(new PageSettings(siteSettings.SiteId, pageId));
                }

                ModuleDefinition feature = new ModuleDefinition(module.ModuleDefId);

                if (feature.DeleteProvider.Length > 0)
                {
                    try
                    {
                        ContentDeleteHandlerProvider contentDeleter = ContentDeleteHandlerProviderManager.Providers[feature.DeleteProvider];
                        if (contentDeleter != null)
                        {
                            contentDeleter.DeleteContent(module.ModuleId, module.ModuleGuid);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("Failed to invoke content delete handler " + feature.DeleteProvider, ex);
                    }
                }

                Module.DeleteModule(module.ModuleId);
                CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
            }


            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }
Ejemplo n.º 3
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            ArrayList pageIDs   = new ArrayList();
            ArrayList sitePages = new ArrayList();

            PopulatePageArray(sitePages);
            List <ModuleDecoratedSiteMapNode> pageList
                = ModuleDecoratedSiteMapNode.GetDecoratedNodes(sitePages, moduleID);

            foreach (ModuleDecoratedSiteMapNode decoratedPage in pageList)
            {
                if (decoratedPage.IsPublished)
                {
                    pageIDs.Add(decoratedPage.PageId);
                }
            }

            foreach (int p in pageIDs)
            {
                Module.DeleteModuleInstance(this.moduleID, p);
                mojoPortal.SearchIndex.IndexHelper.RebuildPageIndexAsync(new PageSettings(siteSettings.SiteId, p));
            }

            Module           m       = new Module(moduleID);
            ModuleDefinition feature = new ModuleDefinition(m.ModuleDefId);

            if (feature.DeleteProvider.Length > 0)
            {
                try
                {
                    ContentDeleteHandlerProvider contentDeleter = ContentDeleteHandlerProviderManager.Providers[feature.DeleteProvider];
                    if (contentDeleter != null)
                    {
                        contentDeleter.DeleteContent(m.ModuleId, m.ModuleGuid);
                    }
                }
                catch (Exception ex)
                {
                    log.Error("Failed to invoke content delete handler " + feature.DeleteProvider, ex);
                }
            }

            if (WebConfigSettings.LogIpAddressForContentDeletions)
            {
                string   userName    = string.Empty;
                SiteUser currentUser = SiteUtils.GetCurrentSiteUser();
                if (currentUser != null)
                {
                    userName = currentUser.Name;
                }

                log.Info("user " + userName + " deleted module " + m.ModuleTitle + " from ip address " + SiteUtils.GetIP4Address());
            }

            Module.DeleteModule(this.moduleID);

            if (hdnReturnUrl.Value.Length > 0)
            {
                if (hdnReturnUrl.Value.Contains("ModuleSettings.aspx"))
                {
                    // redirecting back to module settings for a deleted module cuases an error
                    WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
                    return;
                }

                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetNavigationSiteRoot());
        }