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()));
            }
        }
Beispiel #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);
        }
Beispiel #3
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.ClearCache(portalId);
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
        }