Ejemplo n.º 1
0
        public void DeleteTabs(IEnumerable <PageItem> tabs, StringBuilder errors, bool deleteDescendants = false)
        {
            if (tabs == null || !tabs.Any())
            {
                return;
            }

            foreach (
                var tab in
                tabs.OrderByDescending(t => t.Level)
                .Select(page => _tabController.GetTab(page.Id, PortalSettings.PortalId)))
            {
                if (tab == null)
                {
                    continue;
                }

                if (TabPermissionController.CanDeletePage(tab) && tab.IsDeleted)
                {
                    if (tab.HasChildren)
                    {
                        errors.Append(string.Format(LocalizeString("Service_RemoveTabError"), tab.TabName));
                    }
                    else
                    {
                        HardDeleteTab(tab, deleteDescendants);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage MakePageTranslatable([FromUri] int tabId)
        {
            try
            {
                if (!_securityService.CanManagePage(tabId))
                {
                    return(GetForbiddenResponse());
                }

                var currentTab = _tabController.GetTab(tabId, PortalId, false);
                if (currentTab == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "InvalidTab"));
                }

                var defaultLocale = _localeController.GetDefaultLocale(PortalId);
                _tabController.LocalizeTab(currentTab, defaultLocale, true);
                _tabController.AddMissingLanguages(PortalId, tabId);
                _tabController.ClearCache(PortalId);
                return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true }));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }
Ejemplo n.º 3
0
        public override ConsoleResultModel Run()
        {
            var lst = new List <PageModel>();
            var tab = PageId != -1
                ? _tabController.GetTab(PageId, PortalId)
                : (ParentId > 0
                    ? _tabController.GetTabByName(PageName, PortalId, ParentId)
                    : _tabController.GetTabByName(PageName, PortalId));

            if (tab != null)
            {
                if (!_securityService.CanManagePage(PageId))
                {
                    return(new ConsoleErrorResultModel(LocalizeString("MethodPermissionDenied")));
                }

                if (_contentVerifier.IsContentExistsForRequestedPortal(tab.PortalID, PortalSettings))
                {
                    lst.Add(new PageModel(tab));
                    return(new ConsoleResultModel {
                        Data = lst, Records = lst.Count, Output = LocalizeString("Prompt_PageFound")
                    });
                }
            }

            return(new ConsoleErrorResultModel(LocalizeString("Prompt_PageNotFound")));
        }
Ejemplo n.º 4
0
        private void SerializeTab(PageTemplate template, XmlDocument xmlTemplate, XmlNode nodeTabs)
        {
            var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
            var tab            = _tabController.GetTab(template.TabId, portalSettings.PortalId, false);
            var xmlTab         = new XmlDocument();
            var nodeTab        = TabController.SerializeTab(xmlTab, tab, template.IncludeContent);

            nodeTabs.AppendChild(xmlTemplate.ImportNode(nodeTab, true));
        }
Ejemplo n.º 5
0
 public void DeleteTabs(IEnumerable <PageItem> tabs, StringBuilder errors, bool deleteDescendants = false)
 {
     if (tabs != null)
     {
         foreach (var tab in tabs.OrderByDescending(t => t.Level))
         {
             var tabInfo = _tabController.GetTab(tab.Id, PortalSettings.PortalId);
             if (tabInfo == null)
             {
                 errors.AppendFormat(LocalizeString("PageNotFound"), tab.Id);
             }
             else
             {
                 HardDeleteTab(tabInfo, deleteDescendants, errors);
             }
         }
     }
 }
Ejemplo n.º 6
0
        public override ConsoleResultModel Run()
        {
            TabInfo tab;
            string  message = string.Format(LocalizeString("PageNotFound"), PageId);

            if (PageId > 0)
            {
                tab = _tabController.GetTab(PageId, PortalId);
                if (tab == null)
                {
                    return(new ConsoleErrorResultModel(message));
                }
            }
            else if (!string.IsNullOrEmpty(PageName))
            {
                tab = ParentId > 0
                    ? _tabController.GetTabByName(PageName, PortalId, ParentId)
                    : _tabController.GetTabByName(PageName, PortalId);

                if (tab == null)
                {
                    message = string.Format(LocalizeString("PageNotFoundWithName"), PageName);
                    return(new ConsoleErrorResultModel(message));
                }
            }
            else
            {
                return(new ConsoleErrorResultModel(LocalizeString("Prompt_RestorePageNoParams")));
            }

            if (!_contentVerifier.IsContentExistsForRequestedPortal(tab.PortalID, PortalSettings))
            {
                return(new ConsoleErrorResultModel(message));
            }

            _recyclebinController.RestoreTab(tab, out message);

            if (string.IsNullOrEmpty(message))
            {
                var successMessage = string.Format(
                    LocalizeString("Prompt_PageRestoredSuccessfully"),
                    tab.TabID,
                    tab.TabName
                    );
                return(new ConsoleResultModel(successMessage)
                {
                    Records = 1
                });
            }
            else
            {
                return(new ConsoleErrorResultModel(message));
            }
        }
Ejemplo n.º 7
0
        public bool IsWorkflowEnabled(int portalId, int tabId)
        {
            if (!IsWorkflowEnabled(portalId))
            {
                return(false);
            }

            var tabInfo  = _tabController.GetTab(tabId, portalId);
            var settings = _tabController.GetTabSettings(tabId);

            return(!_tabController.IsHostOrAdminPage(tabInfo) && (settings[TabWorkflowEnableKey] == null || Convert.ToBoolean(settings[TabWorkflowEnableKey])));
        }
Ejemplo n.º 8
0
        public bool IsValidTabPath(TabInfo tab, string newTabPath, string newTabName, out string errorMessage)
        {
            var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
            var valid          = true;

            errorMessage = string.Empty;

            //get default culture if the tab's culture is null
            var cultureCode = tab != null ? tab.CultureCode : string.Empty;

            if (string.IsNullOrEmpty(cultureCode))
            {
                cultureCode = portalSettings.DefaultLanguage;
            }

            //Validate Tab Path
            var tabId = TabController.GetTabByTabPath(portalSettings.PortalId, newTabPath, cultureCode);

            if (tabId != Null.NullInteger && (tab == null || tabId != tab.TabID))
            {
                var existingTab = _tabController.GetTab(tabId, portalSettings.PortalId, false);
                if (existingTab != null && existingTab.IsDeleted)
                {
                    errorMessage = Localization.GetString("TabRecycled");
                }
                else
                {
                    errorMessage = Localization.GetString("TabExists");
                }

                valid = false;
            }

            //check whether have conflict between tab path and portal alias.
            if (TabController.IsDuplicateWithPortalAlias(portalSettings.PortalId, newTabPath))
            {
                errorMessage = string.Format(Localization.GetString("PathDuplicateWithAlias"), newTabName, newTabPath);
                valid        = false;
            }

            return(valid);
        }
Ejemplo n.º 9
0
        public override ConsoleResultModel Run()
        {
            var tabInfo = _tabController.GetTab(PageId, PortalSettings.PortalId);

            if (tabInfo == null ||
                !_contentVerifier.IsContentExistsForRequestedPortal(tabInfo.PortalID, PortalSettings))
            {
                return(new ConsoleErrorResultModel(string.Format(LocalizeString("PageNotFound"), PageId)));
            }
            var errors = new StringBuilder();

            _recyclebinController.DeleteTabs(new List <TabInfo> {
                tabInfo
            }, errors, DeleteChildren);

            return(errors.Length > 0
                ? new ConsoleErrorResultModel(string.Format(LocalizeString("Service_RemoveTabError"), errors))
                : new ConsoleResultModel(string.Format(LocalizeString("Prompt_PagePurgedSuccessfully"), PageId))
            {
                Records = 1
            });
        }
Ejemplo n.º 10
0
        private void NotifyWorkflowAboutChanges(int portalId, int tabId, int userId)
        {
            try
            {
                var tabInfo = _tabController.GetTab(tabId, portalId);
                if (tabInfo != null && !tabInfo.IsDeleted && _workflowEngine.IsWorkflowCompleted(tabInfo))
                {
                    var workflow = GetCurrentOrDefaultWorkflow(tabInfo, portalId);
                    if (workflow == null)
                    {
                        Logger.Warn("Current Workflow and Default workflow are not found on NotifyWorkflowAboutChanges");
                        return;
                    }

                    _workflowEngine.StartWorkflow(workflow.WorkflowID, tabInfo.ContentItemId, userId);
                    _tabController.RefreshCache(portalId, tabId);
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
        }
Ejemplo n.º 11
0
        public void SetupFirstVersionForExistingTab(int portalId, int tabId)
        {
            if (!_tabVersionSettings.IsVersioningEnabled(portalId, tabId))
            {
                return;
            }

            // Check if already exist at least one version for the tab
            if (_tabVersionController.GetTabVersions(tabId).Any())
            {
                return;
            }

            var tab     = _tabController.GetTab(tabId, portalId);
            var modules = _moduleController.GetTabModules(tabId).Where(m => m.Value.IsDeleted == false).Select(m => m.Value).ToArray();

            // Check if the page has modules
            if (!modules.Any())
            {
                return;
            }

            CreateFirstTabVersion(tabId, tab, modules);
        }
Ejemplo n.º 12
0
        private TabInfo GetTabById(int pageId)
        {
            var portalSettings = PortalController.Instance.GetCurrentPortalSettings();

            return(pageId <= 0 ? new TabInfo() : _tabController.GetTab(pageId, portalSettings.PortalId, false));
        }