示例#1
0
        public IEnumerable <Element> GetChildren(EntityToken entityToken, SearchToken searchToken)
        {
            if (UserValidationFacade.IsLoggedIn() &&
                !DataLocalizationFacade.ActiveLocalizationCultures.Contains(UserSettings.ActiveLocaleCultureInfo))
            {
                return(Enumerable.Empty <Element>());
            }

            if (entityToken is AssociatedDataElementProviderHelperEntityToken associatedData)
            {
                return(_pageAssociatedHelper.GetChildren(associatedData, false));
            }

            if (entityToken is DataGroupingProviderHelperEntityToken dataGrouping)
            {
                return(_pageAssociatedHelper.GetChildren(dataGrouping, false));
            }

            using (new DataScope(DataScopeIdentifier.Administrated))
            {
                var allChildPages = GetChildrenPages(entityToken, searchToken);
                List <KeyValuePair <PageLocaleState, IPage> > childPages = IEnumerableExtensionMethods.ToList(allChildPages, f => new KeyValuePair <PageLocaleState, IPage>(PageLocaleState.Own, f));

                List <Element> childPageElements = GetElements(childPages, entityToken is PageElementProviderEntityToken);

                return(GetChildElements(entityToken, childPageElements));
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            if (!UserValidationFacade.IsLoggedIn())
            {
                context.Response.ContentType = MimeTypeInfo.Text;
                context.Response.Write("No user logged in");
                context.Response.StatusCode = 401;
                return;
            }

            try
            {
                string t = context.Request["t"];
                Verify.That(!t.IsNullOrEmpty(), "Missing query string argument 't'");

                string p = context.Request["p"];
                Verify.That(!p.IsNullOrEmpty(), "Missing query string argument 'p'");

                Guid templateId = Guid.Parse(t);
                Guid pageId     = Guid.Parse(p);


                PageTemplatePreview.GetPreviewInformation(context, pageId, templateId, out string filePath, out _);

                Verify.That(C1File.Exists(filePath), "Preview file missing");
                context.Response.ContentType = "image/png";
                context.Response.WriteFile(filePath);
            }
            catch (Exception ex)
            {
                Log.LogError(nameof(TemplatePreviewHttpHandler), ex);
                throw;
            }
        }
            public void AuthorizeRequest(object sender, EventArgs e)
            {
                if (!SystemSetupFacade.IsSystemFirstTimeInitialized)
                {
                    return;
                }

                HttpApplication application = (HttpApplication)sender;
                HttpContext     context     = application.Context;

                bool adminRootRequest = UrlUtils.IsAdminConsoleRequest(context);

                if (adminRootRequest && UserValidationFacade.IsLoggedIn())
                {
                    _dataScope = new DataScope(DataScopeIdentifier.Administrated, UserSettings.ActiveLocaleCultureInfo);

                    if (!_consoleArtifactsInitialized)
                    {
                        lock (_consoleArtifactsInitializeLock)
                        {
                            if (!_consoleArtifactsInitialized && !SystemSetupFacade.SetupIsRunning)
                            {
                                HookingFacade.EnsureInitialization();
                                FlowControllerFacade.Initialize();
                                ConsoleFacade.Initialize();
                                ElementProviderLoader.LoadAllProviders();
                                _consoleArtifactsInitialized = true;
                            }
                        }
                    }
                }
            }
        private static Dictionary <string, string> GetAvailablePublishingFlowTransitions(EntityToken entityToken)
        {
            if (UserValidationFacade.IsLoggedIn())
            {
                var transitionNames = new Dictionary <string, string>
                {
                    { GenericPublishProcessController.Draft, LocalizationFiles.Composite_Management.PublishingStatus_draft },
                    { GenericPublishProcessController.AwaitingApproval, LocalizationFiles.Composite_Management.PublishingStatus_awaitingApproval }
                };

                var username = UserValidationFacade.GetUsername();
                var userPermissionDefinitions     = PermissionTypeFacade.GetUserPermissionDefinitions(username);
                var userGroupPermissionDefinition = PermissionTypeFacade.GetUserGroupPermissionDefinitions(username);
                var currentPermissionTypes        = PermissionTypeFacade.GetCurrentPermissionTypes(UserValidationFacade.GetUserToken(), entityToken, userPermissionDefinitions, userGroupPermissionDefinition);
                foreach (var permissionType in currentPermissionTypes)
                {
                    if (GenericPublishProcessController.AwaitingPublicationActionPermissionType.Contains(permissionType))
                    {
                        transitionNames.Add(GenericPublishProcessController.AwaitingPublication,
                                            LocalizationFiles.Composite_Management.PublishingStatus_awaitingPublication);
                        break;
                    }
                }

                return(transitionNames);
            }
            else
            {
                return(new Dictionary <string, string>());
            }
        }
        /// <summary>
        /// Appends the c1 meta tags to the head section. Those tag are used later on by SEO assistant.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="xhtmlDocument">The XHTML document.</param>
        public static void AppendC1MetaTags(IPage page, XhtmlDocument xhtmlDocument)
        {
            if (UserValidationFacade.IsLoggedIn())
            {
                bool emitMenuTitleMetaTag = string.IsNullOrEmpty(page.MenuTitle) == false;
                bool emitUrlTitleMetaTag  = string.IsNullOrEmpty(page.UrlTitle) == false;

                if (emitMenuTitleMetaTag || emitUrlTitleMetaTag)
                {
                    xhtmlDocument.Head.Add(
                        new XComment("The C1.* meta tags are only emitted when you are logged in"),
                        new XElement(Namespaces.Xhtml + "link",
                                     new XAttribute("rel", "schema.C1"),
                                     new XAttribute("href", "http://www.composite.net/ns/c1/seoassistant")));

                    if (emitMenuTitleMetaTag)
                    {
                        xhtmlDocument.Head.Add(
                            new XElement(Namespaces.Xhtml + "meta",
                                         new XAttribute("name", "C1.menutitle"),
                                         new XAttribute("content", page.MenuTitle)));
                    }

                    if (emitUrlTitleMetaTag)
                    {
                        xhtmlDocument.Head.Add(
                            new XElement(Namespaces.Xhtml + "meta",
                                         new XAttribute("name", "C1.urltitle"),
                                         new XAttribute("content", page.UrlTitle)));
                    }
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!UserValidationFacade.IsLoggedIn())
     {
         LegacyUrlHandlerFacade.RedirectToLoginPage();
     }
 }
        /// <exclude />
        public List <PackageFragmentValidationResult> Install()
        {
            Verify.IsNotNull(_packageInstaller, "Pre installation did not validate");
            Verify.IsNotNull(_validationResult, "Call validation first");
            if (_validationResult.Count > 0)
            {
                throw new InvalidOperationException("Installation did not validate");
            }
            Verify.IsNull(_installationResult, "Install may only be called once");

            var userName = UserValidationFacade.IsLoggedIn() ? UserValidationFacade.GetUsername() : "<system>";

            Log.LogInformation(LogTitle, $"Installing package: {_packageName}, Version: {_packageVersion}, Id = {_packageId}; User name: '{userName}'");

            PackageFragmentValidationResult result = _packageInstaller.Install(_systemLockingType);

            _installationResult = new List <PackageFragmentValidationResult>();

            if (result != null)
            {
                _installationResult.Add(result);
            }

            _installationResult.AddRange(FinalizeProcess(true));

            return(_installationResult);
        }
示例#8
0
        public void ProcessRequest(HttpContext context)
        {
            if (!UserValidationFacade.IsLoggedIn())
            {
                return;
            }

            try
            {
                string t = context.Request["t"];
                Verify.That(!t.IsNullOrEmpty(), "Missing query string argument 't'");

                string p = context.Request["p"];
                Verify.That(!p.IsNullOrEmpty(), "Missing query string argument 'p'");

                Guid templateId = Guid.Parse(t);
                Guid pageId     = Guid.Parse(p);


                string filePath;

                PageTemplatePreview.PlaceholderInformation[] placeholders;
                PageTemplatePreview.GetPreviewInformation(context, pageId, templateId, out filePath, out placeholders);

                Verify.That(C1File.Exists(filePath), "Preview file missing");
                context.Response.ContentType = "image/png";
                context.Response.WriteFile(filePath);
            }
            catch (Exception ex)
            {
                Log.LogError(this.GetType().ToString(), ex.ToString());
                throw;
            }
        }
示例#9
0
        public override IEnumerable <System.Xml.Linq.XElement> Install()
        {
            // grant Perspective permissions to the current user
            string perspectiveName       = "Composite.Tools.PackageCreator";
            var    entityToken           = new VirtualElementProviderEntityToken("VirtualElementProvider", perspectiveName);
            var    serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            var sitemapPerspective = DataFacade.BuildNew <IUserGroupActivePerspective>();
            var userGroup          = DataFacade.GetData <IUserGroup>().FirstOrDefault(u => u.Name == "Administrator");

            if (userGroup != null)
            {
                sitemapPerspective.UserGroupId           = userGroup.Id;
                sitemapPerspective.SerializedEntityToken = serializedEntityToken;
                sitemapPerspective.Id = Guid.NewGuid();
                DataFacade.AddNew(sitemapPerspective);
                Log.LogInformation("Composite.Tools.PackageCreator", $"Access to the '{perspectiveName}' granted for user group '{userGroup.Name}'.");
            }

            if (UserValidationFacade.IsLoggedIn())
            {
                var activePerspective = DataFacade.BuildNew <IUserActivePerspective>();
                activePerspective.Username = C1Console.Users.UserSettings.Username;
                activePerspective.SerializedEntityToken = serializedEntityToken;
                activePerspective.Id = Guid.NewGuid();

                DataFacade.AddNew <IUserActivePerspective>(activePerspective);
                Log.LogInformation("Composite.Tools.PackageCreator", $"Access to the '{perspectiveName}' granted for user '{C1Console.Users.UserSettings.Username}'.");
            }
            yield break;
        }
        public bool OnAfterBuildNew(IData data)
        {
            ILocalizedControlled localizedData = data as ILocalizedControlled;

            if (localizedData != null)
            {
                if (!LocalizationScopeManager.IsEmpty)
                {
                    localizedData.SourceCultureName = LocalizationScopeManager.CurrentLocalizationScope.Name;
                }
                else
                {
                    CultureInfo cultureInfo = null;

                    if (UserValidationFacade.IsLoggedIn())
                    {
                        cultureInfo = UserSettings.ActiveLocaleCultureInfo;
                    }

                    if (cultureInfo == null)
                    {
                        cultureInfo = DataLocalizationFacade.DefaultLocalizationCulture;
                    }

                    if (cultureInfo != null)
                    {
                        localizedData.SourceCultureName = cultureInfo.Name;
                    }
                }
            }

            return(false);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!UserValidationFacade.IsLoggedIn())
        {
            Response.Redirect("/Composite/Login.aspx?ReturnUrl=" + Request.Url.PathAndQuery);
            return;
        }

        if (!Page.IsPostBack)
        {
            if (Reflection.DefaultDynamicTypeDataProviderName == DynamicSqlDataProviderName)
            {
                lblAlreadySql.Visible  = true;
                wzdSqlMigrator.Visible = false;
                return;
            }

            txtConnectionString.Text = DataFacade.GetDynamicDataProviderNames()
                                       .Where(d => d == DynamicSqlDataProviderName)
                                       .Select(d => Reflection.GetDataProviderConfiguration(d).GetProperty("ConnectionString"))
                                       .FirstOrDefault();

            ddlSourceDataProvider.DataSource = DataFacade.GetDynamicDataProviderNames().Where(d => d == DynamicXmlDataProviderName);
            ddlSourceDataProvider.DataBind();
        }
    }
        private void context_AuthorizeRequest(object sender, EventArgs e)
        {
            var         application = (HttpApplication)sender;
            HttpContext context     = application.Context;

            string currentPath = context.Request.Path.ToLowerInvariant();

            if (_adminRootPath == null || !currentPath.StartsWith(_adminRootPath))
            {
                return;
            }

            if (!_allowC1ConsoleRequests)
            {
                context.Response.StatusCode  = 403;
                context.Response.ContentType = "text/html";
                string iePadding = new String('!', 512);
                context.Response.Write(string.Format(c1ConsoleRequestsNotAllowedHtmlTemplate, iePadding));
                context.Response.End();
                return;
            }

            var url = context.Request.Url;

            // https check
            if (_forceHttps && url.Scheme != "https")
            {
                if (!AlwaysAllowUnsecured(url.LocalPath) && !UserOptedOutOfHttps(context))
                {
                    context.Response.Redirect(
                        $"{unsecureRedirectRelativePath}?fallback={_allowFallbackToHttp.ToString().ToLower()}&httpsport={_customHttpsPortNumber}");
                }
            }

            // access check
            if (currentPath.Length > _adminRootPath.Length && !UserValidationFacade.IsLoggedIn() &&
                !_allAllowedPaths.Any(p => currentPath.StartsWith(p, StringComparison.OrdinalIgnoreCase)))
            {
                if (currentPath.StartsWith(_servicesPath))
                {
                    context.Response.StatusCode = 403;
                    context.Response.End();
                    return;
                }

                Log.LogWarning("Authorization", "DENIED {0} access to {1}", context.Request.UserHostAddress, currentPath);
                string redirectUrl = $"{_loginPagePath}?ReturnUrl={HttpUtility.UrlEncode(url.PathAndQuery, Encoding.UTF8)}";
                context.Response.Redirect(redirectUrl, true);
                return;
            }

            // On authenticated request make sure these resources gets compiled / launched.
            if (IsConsoleOnline)
            {
                BrowserRender.EnsureReadiness();
                BuildManagerHelper.InitializeControlPreLoading();
            }
        }
示例#13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!UserValidationFacade.IsLoggedIn())
        {
            Response.Redirect("/Composite/Login.aspx?ReturnUrl=" + Request.Url.PathAndQuery);
            return;
        }
        ScriptLoader.Render("sub");


        rptCountryList.DataSource = DataFacade.GetData <Country>().Take(10)
                                    .ToArray()
                                    .Select(x =>
        {
            var editLink = new EditLink()
            {
                Label = x.Name
            };

            if (DataScopeManager.CurrentDataScope != DataScopeIdentifier.Administrated)
            {
                editLink.Link = String.Empty;
                return(editLink);
            }

            var teaser = x;

            //var editWorkflowAttribute = teaser.DataSourceId.InterfaceType.GetCustomAttributes(true).OfType<EditWorkflowAttribute>().FirstOrDefault();
            //if (editWorkflowAttribute == null)
            //{
            //    editLink.Link = string.Empty;
            //    return editLink;
            //}


            var page                  = PageManager.GetPageById(Guid.Parse("63ec1a73-b1ed-4ec8-923f-2840448c43ce"));
            var entityToken           = new PageTeaserInstanceEntityToken(page, teaser);
            var serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true);

            var editActionToken       = new WorkflowActionToken(typeof(EditWorkflowAttribute));
            var serializedActionToken = ActionTokenSerializer.Serialize(editActionToken, true);

            var html = String.Format("<a href=\"#\" data-providername='{0}' data-entitytoken='{1}' data-actiontoken=\"{2}\" data-piggybag='{3}' data-piggybaghash='{4}' onclick=\"executeAction(this)\">{5}</a>",
                                     teaser.DataSourceId.ProviderName,
                                     serializedEntityToken,
                                     serializedActionToken,
                                     String.Empty,
                                     HashSigner.GetSignedHash(string.Empty).Serialize(),
                                     "edit");

            editLink.Link = html;
            return(editLink);
        });


        rptCountryList.DataBind();
    }
        public MvcRenderingContext(ControllerContext context)
        {
            _context = context.HttpContext;
            var request = _context.Request;

            if (PageRenderer.CurrentPage == null)
            {
                var response = _context.Response;

                ProfilingEnabled = request.Url.OriginalString.Contains("c1mode=perf");
                if (ProfilingEnabled)
                {
                    if (!UserValidationFacade.IsLoggedIn())
                    {
                        response.Write("You must be logged into <a href=\"" + GetLoginRedirectUrl(request.RawUrl) + "\">C1 console</a> to have the performance view enabled");
                        response.End();

                        return;
                    }

                    Profiler.BeginProfiling();

                    _pagePerfMeasuring = Profiler.Measure("C1 Page");
                }

                Page       = (C1PageRoute.PageUrlData ?? PageUrls.UrlProvider.ParseInternalUrl(request.Url.OriginalString)).GetPage();
                _cachedUrl = request.Url.PathAndQuery;

                ValidateViewUnpublishedRequest();

                if (Page == null)
                {
                    throw new HttpException((int)HttpStatusCode.NotFound, "Page not found - either this page has not been published yet or it has been deleted.");
                }

                if ((Page.DataSourceId.PublicationScope != PublicationScope.Published) || request.IsSecureConnection)
                {
                    CachingDisabled = true;

                    response.Cache.SetCacheability(HttpCacheability.NoCache);
                }

                PageRenderer.CurrentPage     = Page;
                PageRenderer.RenderingReason = new UrlSpace(_context).ForceRelativeUrls ? RenderingReason.C1ConsoleBrowserPageView : RenderingReason.PageView;

                _dataScope = new DataScope(Page.DataSourceId.PublicationScope, Page.DataSourceId.LocaleScope);
            }
            else
            {
                Page = PageRenderer.CurrentPage;
            }

            C1PageRoute.PageUrlData = new PageUrlData(Page);
        }
        private void LogWorkflowChange(string change, WorkflowEventArgs args, bool logUserName, bool workflowDefinitionAvailable, bool error)
        {
            WorkflowInstance instance = null;

            string activityTypeName = null;

            try
            {
                instance = args.WorkflowInstance;
            }
            catch
            {
                // Silent
            }

            if (workflowDefinitionAvailable && instance != null)
            {
                try
                {
                    activityTypeName = instance.GetWorkflowDefinition().GetType().FullName;
                }
                catch
                {
                    // Silent
                }
            }

            var message = new StringBuilder("Workflow ").Append(change);

            if (activityTypeName != null)
            {
                message.Append(", Activity = " + activityTypeName);
            }

            if (instance != null)
            {
                message.Append(", Id = " + instance.InstanceId);
            }

            if (logUserName)
            {
                string identity = UserValidationFacade.IsLoggedIn() ? UserValidationFacade.GetUsername() : "(system process)";
                message.Append(", User = " + identity);
            }

            if (!error)
            {
                Log.LogVerbose(LogTitle, message.ToString());
            }
            else
            {
                Log.LogError(LogTitle, message.ToString());
            }
        }
示例#16
0
        private void ValidateViewUnpublishedRequest(HttpContext httpContext)
        {
            bool isPreviewingUrl   = httpContext.Request.Url.OriginalString.Contains(DefaultPageUrlProvider.UrlMarker_RelativeUrl);
            bool isUnpublishedPage = Page != null && Page.DataSourceId.PublicationScope != PublicationScope.Published;

            if ((isUnpublishedPage || isPreviewingUrl) &&
                !UserValidationFacade.IsLoggedIn())
            {
                string redirectUrl = GetLoginRedirectUrl(httpContext.Request.Url.OriginalString);

                httpContext.Response.Redirect(redirectUrl, true);
            }
        }
        private void ValidateViewUnpublishedRequest()
        {
            var isRelative = _context.Request.Url.OriginalString.Contains("/c1mode(relative)");

            if ((((Page == null) || (Page.DataSourceId.PublicationScope == PublicationScope.Published)) && !isRelative) ||
                UserValidationFacade.IsLoggedIn())
            {
                return;
            }

            var loginRedirectUrl = GetLoginRedirectUrl(_context.Request.Url.OriginalString);

            _context.Response.Redirect(loginRedirectUrl, true);
        }
        private static void AuthenticateRequest(object sender, EventArgs e)
        {
            if (!SystemSetupFacade.IsSystemFirstTimeInitialized)
            {
                return;
            }

            HttpContext context = ((HttpApplication)sender).Context;

            bool adminRootRequest = UrlUtils.IsAdminConsoleRequest(context);

            if (adminRootRequest && UserValidationFacade.IsLoggedIn())
            {
                var dataScope = new DataScope(DataScopeIdentifier.Administrated, UserSettings.ActiveLocaleCultureInfo);
                context.Items[HttpContextItemsKey] = dataScope;
            }
        }
示例#19
0
            public void AuthenticateRequest(object sender, EventArgs e)
            {
                if (SystemSetupFacade.IsSystemFirstTimeInitialized == false)
                {
                    return;
                }

                HttpApplication application = (HttpApplication)sender;
                HttpContext     context     = application.Context;

                bool adminRootRequest = UrlUtils.IsAdminConsoleRequest(context);

                if (adminRootRequest && UserValidationFacade.IsLoggedIn())
                {
                    _dataScope = new DataScope(DataScopeIdentifier.Administrated, UserSettings.ActiveLocaleCultureInfo);
                }
            }
 protected void SetCultureInfo()
 {
     if (UserValidationFacade.IsLoggedIn())
     {
         Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = UserSettings.ActiveLocaleCultureInfo;
     }
     else
     {
         using (var data = new DataConnection())
         {
             var activeLocales = data.Get <ISystemActiveLocale>().ToList();
             if (activeLocales.Count == 1)
             {
                 Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo(activeLocales[0].CultureName);
             }
         }
     }
 }
        private void SetWorkflowInstanceStatus(Guid instanceId, WorkflowInstanceStatus workflowInstanceStatus, bool newlyCreateOrLoaded)
        {
            using (_resourceLocker.Locker)
            {
                var resources = _resourceLocker.Resources;

                Action releaseIdleWaitSemaphore = () =>
                {
                    if (resources.WorkflowIdleWaitSemaphores.TryGetValue(instanceId, out var semaphore))
                    {
                        semaphore.Release();
                        resources.WorkflowIdleWaitSemaphores.Remove(instanceId);
                    }
                };

                switch (workflowInstanceStatus)
                {
                case WorkflowInstanceStatus.Idle:
                    releaseIdleWaitSemaphore();

                    resources.WorkflowStatusDictionary[instanceId] = WorkflowInstanceStatus.Idle;

                    PersistFormData(instanceId);

                    break;

                case WorkflowInstanceStatus.Running:
                    resources.WorkflowStatusDictionary[instanceId] = WorkflowInstanceStatus.Running;
                    break;

                case WorkflowInstanceStatus.Terminated:
                    releaseIdleWaitSemaphore();
                    resources.WorkflowStatusDictionary.Remove(instanceId);
                    break;

                default:
                    throw new InvalidOperationException("This line should not be reachable.");
                }
            }

            string identity = UserValidationFacade.IsLoggedIn() ? UserValidationFacade.GetUsername() : "(system process)";

            Log.LogVerbose(LogTitle, $"Workflow instance status changed to {workflowInstanceStatus}. Id = {instanceId}, User = {identity}");
        }
    protected void Page_Init(object sender, EventArgs e)
    {
        if (!SystemSetupFacade.IsSystemFirstTimeInitialized)
        {
            Response.Redirect("/Composite");
            return;
        }

        if (UserValidationFacade.IsLoggedIn())
        {
            RedirectToReturnUrl();
            return;
        }

        if (Request.RequestType == "POST")
        {
            OnPost();
        }
    }
示例#23
0
        /// <summary>
        /// Appends the c1 meta tags to the head section. Those tag are used later on by SEO assistant.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="xhtmlDocument">The XHTML document.</param>
        public static void AppendC1MetaTags(IPage page, XhtmlDocument xhtmlDocument)
        {
            if (UserValidationFacade.IsLoggedIn())
            {
                bool emitMenuTitleMetaTag = string.IsNullOrEmpty(page.MenuTitle) == false;
                bool emitUrlMetaTag       = string.IsNullOrEmpty(page.UrlTitle) == false;

                if (emitMenuTitleMetaTag || emitUrlMetaTag)
                {
                    xhtmlDocument.Head.Add(
                        new XComment("The C1.* meta tags are only emitted when you are logged in"),
                        new XElement(Namespaces.Xhtml + "link",
                                     new XAttribute("rel", "schema.C1"),
                                     new XAttribute("href", "http://www.composite.net/ns/c1/seoassistant")));

                    if (emitMenuTitleMetaTag)
                    {
                        xhtmlDocument.Head.Add(
                            new XElement(Namespaces.Xhtml + "meta",
                                         new XAttribute("name", "C1.menutitle"),
                                         new XAttribute("content", page.MenuTitle)));
                    }

                    if (emitUrlMetaTag)
                    {
                        var editPreview = PageRenderer.RenderingReason == RenderingReason.PreviewUnsavedChanges;

                        string url = PageUrls.BuildUrl(page) ?? PageUrls.BuildUrl(page, UrlKind.Internal);

                        var pageUrl = string.Format("{0}{1}{2}",
                                                    url.Replace("/c1mode(unpublished)", "").Replace("/c1mode(relative)", ""),
                                                    editPreview ? "/" + page.UrlTitle : C1PageRoute.GetPathInfo(),
                                                    editPreview ? "" : HttpContext.Current.Request.Url.Query);

                        xhtmlDocument.Head.Add(
                            new XElement(Namespaces.Xhtml + "meta",
                                         new XAttribute("name", "C1.urlseowords"),
                                         new XAttribute("content", pageUrl)));
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!UserValidationFacade.IsLoggedIn())
            {
                Response.Redirect("~/Composite/Login.aspx?ReturnUrl=" + Request.RawUrl);
            }

            if (HttpContext.Current.Request.QueryString["badURL"] == null)
            {
                return;
            }

            _badURL = HttpContext.Current.Request.QueryString["badURL"].ToString(CultureInfo.InvariantCulture);

            if (!Page.IsPostBack && HttpContext.Current.Request.QueryString["badURL"] != null && txtBadURL != null)
            {
                var uri = new System.Uri(_badURL);
                txtBadURL.Text = uri.AbsolutePath;
            }
        }
        private static void SetCreationHistoryInformation(object sender, DataEventArgs dataEventArgs)
        {
            ICreationHistory data = dataEventArgs.Data as ICreationHistory;

            if (data != null)
            {
                data.CreationDate = DateTime.Now;

                try
                {
                    if (UserValidationFacade.IsLoggedIn())
                    {
                        data.CreatedBy = UserValidationFacade.GetUsername();
                    }
                }
                catch
                {
                    // silent
                }
            }
        }
示例#26
0
        private static void SetChangeHistoryInformation(object sender, DataEventArgs dataEventArgs)
        {
            IData data = dataEventArgs.Data;

            if (data != null && data is IChangeHistory)
            {
                (data as IChangeHistory).ChangeDate = DateTime.Now;

                try
                {
                    if (UserValidationFacade.IsLoggedIn())
                    {
                        (data as IChangeHistory).ChangedBy = UserValidationFacade.GetUsername();
                    }
                }
                catch
                {
                    // silent
                }
            }
        }
示例#27
0
        void context_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpApplication application = (HttpApplication)sender;
            HttpContext     context     = application.Context;

            bool adminRootRequest = UrlUtils.IsAdminConsoleRequest(context);

            if (adminRootRequest)
            {
                if (UserValidationFacade.IsLoggedIn())
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture   = C1Console.Users.UserSettings.CultureInfo;
                    System.Threading.Thread.CurrentThread.CurrentUICulture = C1Console.Users.UserSettings.C1ConsoleUiLanguage;
                }
                else
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(Composite.Core.Configuration.GlobalSettingsFacade.DefaultCultureName);
                    System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Composite.Core.Configuration.GlobalSettingsFacade.DefaultCultureName);
                }
            }
        }
示例#28
0
        private void DoUninstallWithoutTransaction()
        {
            var userName = UserValidationFacade.IsLoggedIn() ? UserValidationFacade.GetUsername() : "<system>";

            Log.LogInformation(LogTitle, $"Uninstalling package '{PackageInformation.Name}', Id = {PackageInformation.Id}. User name: '{userName}'");

            try
            {
                foreach (IPackageFragmentUninstaller packageFragmentUninstaller in _packageFramentUninstallers)
                {
                    packageFragmentUninstaller.Uninstall();
                }
            }
            catch (Exception ex)
            {
                Log.LogError(LogTitle, ex);
                throw;
            }

            Log.LogInformation(LogTitle, "Package uninstalled successfully.");
        }
示例#29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!UserValidationFacade.IsLoggedIn())
        {
            Response.Redirect(string.Format("Composite/Login.aspx?ReturnUrl={0}", HttpUtility.HtmlEncode(Request.Url.PathAndQuery)));
        }

        var backupFile = Request[BackupFilename];

        if (backupFile != null)
        {
            TransmitBackup(Path.Combine(BackupDirectory, Path.GetFileName(backupFile)));
        }

        if (Page.IsPostBack)
        {
            string commandName = Request["commandName"];
            if (commandName == "delete")
            {
                string deleteXMLBackupFile = Request["deleteXMLBackupFile"];
                if (!string.IsNullOrWhiteSpace(deleteXMLBackupFile))
                {
                    try
                    {
                        C1File.Delete(Path.Combine(BackupDirectory, deleteXMLBackupFile));
                    }
                    catch (Exception ex)
                    {
                        this.Validators.Add(new ErrorSummary(ex.Message));
                    }
                }
            }

            if (commandName == "create")
            {
                CreateBackup();
            }
        }
    }
        public override FormValidationRule CreateRule(FormField field)
        {
            var value    = (string)field.Value;
            var password = (string)field.OwningForm.Fields.Get(_passwordField).Value;

            return(CreateRule(field, new[] { field.Name, _passwordField }, () =>
            {
                var isValid = false;

                if (!isValid && CheckUserName)
                {
                    var user = Membership.GetUser(value);

                    isValid = IsValid(user);
                }

                if (!isValid && CheckEmail)
                {
                    var username = Membership.GetUserNameByEmail(value);
                    if (username != null)
                    {
                        var user = Membership.GetUser(username);
                        if (user != null)
                        {
                            isValid = IsValid(user);
                            value = username;
                        }
                    }
                }

                if (!isValid)
                {
                    return false;
                }

                return UserValidationFacade.IsLoggedIn() || Membership.ValidateUser(value, password);
            }));
        }