Пример #1
0
        private void HardDeleteTab(TabInfo tab, bool deleteDescendants)
        {
            //get tab modules before deleting page
            var tabModules = _moduleController.GetTabModules(tab.TabID);

            //hard delete the tab
            _tabController.DeleteTab(tab.TabID, tab.PortalID, deleteDescendants);

            //delete modules that do not have other instances
            foreach (var kvp in tabModules)
            {
                //check if all modules instances have been deleted
                var delModule = _moduleController.GetModule(kvp.Value.ModuleID, Null.NullInteger, false);
                if (delModule == null || delModule.TabID == Null.NullInteger)
                {
                    try
                    {
                        _moduleController.DeleteModule(kvp.Value.ModuleID);
                    }
                    catch (Exception exc)
                    {
                        Logger.Error(exc);
                    }
                }
            }
        }
Пример #2
0
        public virtual int AddTab(PageSettings pageSettings)
        {
            var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
            var portalId       = portalSettings.PortalId;
            var tab            = new TabInfo {
                PortalID = portalId
            };

            UpdateTabInfoFromPageSettings(tab, pageSettings);

            if (portalSettings.ContentLocalizationEnabled)
            {
                tab.CultureCode = portalSettings.CultureCode;
            }

            SavePagePermissions(tab, pageSettings.Permissions);

            var tabId = _tabController.AddTab(tab);

            tab = _tabController.GetTab(tabId, portalId);

            CreateOrUpdateContentItem(tab);

            if (pageSettings.TemplateTabId > 0)
            {
                CopyContentFromSourceTab(tab, pageSettings.TemplateTabId);
            }

            if (pageSettings.TemplateId > 0)
            {
                try
                {
                    _templateController.CreatePageFromTemplate(pageSettings.TemplateId, tab, portalId);
                }
                catch (PageException)
                {
                    _tabController.DeleteTab(tab.TabID, portalId);
                    throw;
                }
            }

            SaveTabUrl(tab, pageSettings);

            MovePageIfNeeded(pageSettings, tab);

            _tabController.ClearCache(portalId);
            return(tab.TabID);
        }
Пример #3
0
        private void HardDeleteTab(TabInfo tab, bool deleteDescendants, StringBuilder errors)
        {
            if (TabPermissionController.CanDeletePage(tab) && tab.IsDeleted)
            {
                if (tab.HasChildren && !deleteDescendants)
                {
                    errors.Append(string.Format(LocalizeString("Service_RemoveTabWithChildError"), tab.TabName));
                    return;
                }
                //get tab modules before deleting page
                var tabModules = _moduleController.GetTabModules(tab.TabID);

                //hard delete the tab
                _tabController.DeleteTab(tab.TabID, tab.PortalID, deleteDescendants);

                //delete modules that do not have other instances
                foreach (var kvp in tabModules)
                {
                    //check if all modules instances have been deleted
                    var delModule = _moduleController.GetModule(kvp.Value.ModuleID, Null.NullInteger, false);
                    if (delModule == null || delModule.TabID == Null.NullInteger)
                    {
                        try
                        {
                            _moduleController.DeleteModule(kvp.Value.ModuleID);
                        }
                        catch (Exception exc)
                        {
                            Logger.Error(exc);
                        }
                    }
                }
            }
            else
            {
                errors.AppendFormat(!tab.IsDeleted ? LocalizeString("TabNotSoftDeleted") : LocalizeString("CanNotDeleteTab"), tab.TabID);
            }
        }