/// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal CatalogShippingApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _gatewayProviderService = MerchelloContext.Services.GatewayProviderService;
     _storeSettingService = MerchelloContext.Services.StoreSettingService;
     _shipCountryService = ((ServiceContext)MerchelloContext.Services).ShipCountryService;
 }
Ejemplo n.º 2
0
         /// <summary>
		/// Default constructor
		/// </summary>
		/// <param name="umbracoContext"></param>
		protected UmbracoUserControl(UmbracoContext umbracoContext)
		{
            if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
            UmbracoContext = umbracoContext;
            InstanceId = Guid.NewGuid();
            Umbraco = new UmbracoHelper(umbracoContext);
		}
        protected override sealed IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
        {
            var byId = umbracoContext.ContentCache.GetById(_realNodeId);
            if (byId == null) return null;

            return FindContent(requestContext, umbracoContext, byId);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Primary constructor.
 /// </summary>
 /// <param name="context">Umbraco context.</param>
 public FormsController(UmbracoContext context)
     : base(context)
 {
     Persistence = FormPersistence.Current.Manager;
     Entities = EntityPersistence.Current.Manager;
     Validations = ValidationPersistence.Current.Manager;
 }
 /// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal ProductVariantApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _productService = MerchelloContext.Services.ProductService;
     _productVariantService = MerchelloContext.Services.ProductVariantService;
     _warehouseService = MerchelloContext.Services.WarehouseService;
 }
Ejemplo n.º 6
0
 public XmlRssHandler()
 {
     umbContext = UmbracoContext.Current;
     appContext = ApplicationContext.Current;
     services = appContext.Services;
     helper = new UmbracoHelper( umbContext );
 }
        /// <summary>
        /// The crawl.
        /// </summary>
        /// <param name="site">
        /// The site.
        /// </param>
        /// <param name="doc">
        /// The doc.
        /// </param>
        public void Crawl(UmbracoContext site, XmlDocument doc)
        {
            /*
             *  We're going to crawl the site layer-by-layer which will put the upper levels
             *  of the site nearer the top of the sitemap.xml document as opposed to crawling
             *  the tree by parent/child relationships, which will go deep on each branch before
             *  crawling the entire site.
             */

            var helper = new UmbracoHelper(UmbracoContext.Current);
            var siteRoot = helper.TypedContentAtRoot().First();
            var node = SitemapGenerator.CreateNode(siteRoot, site);
            if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
            {
                SitemapGenerator.AppendUrlElement(doc, node);
            }

            var items = siteRoot.Descendants();
            if (items != null)
            {
                foreach (var item in items)
                {
                    node = SitemapGenerator.CreateNode(item, site);

                    if (node.IsPage && node.IsListedInNavigation && node.ShouldIndex)
                    {
                        SitemapGenerator.AppendUrlElement(doc, node);
                    }
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OrderApiController"/> class.
 /// </summary>
 /// <param name="merchelloContext">
 /// The merchello context.
 /// </param>
 /// <param name="umbracoContext">
 /// The umbraco context.
 /// </param>
 internal OrderApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base(merchelloContext, umbracoContext)
 {
     _orderService = merchelloContext.Services.OrderService;
     _invoiceService = merchelloContext.Services.InvoiceService;
     _merchello = new MerchelloHelper(merchelloContext.Services);
 }
Ejemplo n.º 9
0
		/// <summary>
		/// Begins to process a request.
		/// </summary>
		/// <param name="httpContext"></param>
		void BeginRequest(HttpContextBase httpContext)
		{
			// do not process if client-side request
			if (IsClientSideRequest(httpContext.Request.Url))
				return;			

			// ok, process

			// create the LegacyRequestInitializer
			// and initialize legacy stuff
			var legacyRequestInitializer = new LegacyRequestInitializer(httpContext.Request.Url, httpContext);
			legacyRequestInitializer.InitializeRequest();

			// create the UmbracoContext singleton, one per request, and assign
			var umbracoContext = new UmbracoContext(
				httpContext,
				ApplicationContext.Current,
				RoutesCacheResolver.Current.RoutesCache);
			UmbracoContext.Current = umbracoContext;

			// create the nice urls provider
			var niceUrls = new NiceUrlProvider(PublishedContentStoreResolver.Current.PublishedContentStore, umbracoContext);

			// create the RoutingContext, and assign
			var routingContext = new RoutingContext(
				umbracoContext,
				DocumentLookupsResolver.Current.DocumentLookups,
				LastChanceLookupResolver.Current.LastChanceLookup,
				PublishedContentStoreResolver.Current.PublishedContentStore,
				niceUrls);
			umbracoContext.RoutingContext = routingContext;
		}
Ejemplo n.º 10
0
		public void SetUp()
		{
			TestHelper.SetupLog4NetForTests();
			Umbraco.Core.Configuration.UmbracoSettings.UseLegacyXmlSchema = false;
			_httpContextFactory = new FakeHttpContextFactory("~/Home");
			//ensure the StateHelper is using our custom context
			StateHelper.HttpContext = _httpContextFactory.HttpContext;
			
			_umbracoContext = new UmbracoContext(_httpContextFactory.HttpContext, 
				new ApplicationContext(), 
				new DefaultRoutesCache(false));

			_umbracoContext.GetXmlDelegate = () =>
				{
					var xDoc = new XmlDocument();

					//create a custom xml structure to return

					xDoc.LoadXml(GetXml());
					//return the custom x doc
					return xDoc;
				};

			_publishedContentStore = new DefaultPublishedContentStore();			
		}
        protected override sealed IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
        {
            //determine if it's for a particular domain
            int realNodeId;
            if (_hostsAndIds.Count == 1)
            {
                realNodeId = _hostsAndIds[0].Item2;
            }
            else
            {
                if (requestContext.HttpContext.Request.Url == null)
                {
                    if (_hostsAndIds.Count > 0)
                    {
                        //cannot be determined
                        realNodeId = _hostsAndIds[0].Item2;
                    }
                    else
                    {
                        LogHelper.Warn<ArticulateVirtualNodeByIdRouteHandler>("No entries found to map hosts and IDs");
                        return null;
                    }
                }
                else if (requestContext.HttpContext.Request.Url.Host.InvariantEquals("localhost")
                    && !UmbracoConfig.For.UmbracoSettings().RequestHandler.UseDomainPrefixes)
                {
                    //TODO: Why is this checking for UseDomainPrefixes + localhost? I can't figure that part out (even though i wrote that)

                    var found = _hostsAndIds.FirstOrDefault(x => x.Item1 == string.Empty);
                    if (found != null)
                    {
                        realNodeId = found.Item2;
                    }
                    else
                    {
                        LogHelper.Warn<ArticulateVirtualNodeByIdRouteHandler>("No entries found in hosts/IDs map with an empty Host value. Values: " + DebugHostIdsCollection());
                        return null;
                    }
                }
                else
                {
                    var found = _hostsAndIds.FirstOrDefault(x => x.Item1.InvariantEquals(requestContext.HttpContext.Request.Url.Host));
                    if (found != null)
                    {
                        realNodeId = found.Item2;
                    }
                    else
                    {
                        LogHelper.Warn<ArticulateVirtualNodeByIdRouteHandler>("No entries found in hosts/IDs map with a Host value of " + requestContext.HttpContext.Request.Url.Host + ". Values: " + DebugHostIdsCollection());
                        return null;
                    }
                }
            }

            var byId = umbracoContext.ContentCache.GetById(realNodeId);
            if (byId == null) return null;

            return FindContent(requestContext, umbracoContext, byId);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MarketingApiController"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The merchello context.
        /// </param>
        /// <param name="umbracoContext">
        /// The umbraco context.
        /// </param>
        internal MarketingApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
            : base(merchelloContext, umbracoContext)
        {
            _offerSettingsService = merchelloContext.Services.OfferSettingsService;

            // TODO - this need to be fixed to make testable
            this._providerResolver = OfferProviderResolver.Current;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Shared with PublishMediaStoreTests
 /// </summary>
 /// <param name="id"></param>
 /// <param name="umbracoContext"></param>
 /// <returns></returns>
 internal static IPublishedContent GetNode(int id, UmbracoContext umbracoContext)
 {
     var ctx = umbracoContext;
     var cache = new ContextualPublishedMediaCache(new PublishedMediaCache(), ctx);
     var doc = cache.GetById(id);
     Assert.IsNotNull(doc);
     return doc;
 }
Ejemplo n.º 14
0
		/// <summary>
		/// Shared with PublishMediaStoreTests
		/// </summary>
		/// <param name="id"></param>
		/// <param name="umbracoContext"></param>
		/// <returns></returns>
		internal static IPublishedContent GetNode(int id, UmbracoContext umbracoContext)
		{
			var ctx = umbracoContext;
			var mediaStore = new DefaultPublishedMediaStore();
			var doc = mediaStore.GetDocumentById(ctx, id);
			Assert.IsNotNull(doc);
			return doc;
		}
Ejemplo n.º 15
0
 /// <summary>
 /// This is a helper contructor for unit testing
 /// </summary>
 internal ShipmentApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
     : base((MerchelloContext) merchelloContext, umbracoContext)
 {
     _shipmentService = merchelloContext.Services.ShipmentService;
     _invoiceService = merchelloContext.Services.InvoiceService;
     _orderService = merchelloContext.Services.OrderService;
     _shipMethodService = ((ServiceContext)merchelloContext.Services).ShipMethodService;
 }
Ejemplo n.º 16
0
        protected MerchelloApiController(MerchelloContext merchelloContext, UmbracoContext umbracoContext)
            : base(umbracoContext)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");

            MerchelloContext = merchelloContext;
            InstanceId = Guid.NewGuid();
        }
 ///Constructors needed for testability and DI
 public MemberRegisterSurfaceController(UmbracoContext umbracoContext,
     IMemberTypeService _memberTypeService,
     IMemberService _memberService)
     : base(umbracoContext)
 {
     this._memberTypeService = _memberTypeService;
     this._memberService = _memberService;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Gets the nice url of a custom routed published content item
 /// </summary>        
 public string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
 {
     if (umbracoContext.PublishedContentRequest == null) return null;
     if (umbracoContext.PublishedContentRequest.PublishedContent == null) return null;
     var virtualPage = umbracoContext.PublishedContentRequest.PublishedContent as DialogueVirtualPage;
     if (virtualPage == null) return null;
     //if the ids match, then return the assigned url
     return id == virtualPage.Id ? virtualPage.Url : null;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DetachedContentApiController"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The <see cref="IMerchelloContext"/>.
        /// </param>
        /// <param name="umbracoContext">
        /// The <see cref="UmbracoContext"/>.
        /// </param>
        public DetachedContentApiController(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
            : base(merchelloContext, umbracoContext)
        {
            if (ApplicationContext == null) throw new NotFiniteNumberException("Umbraco ApplicationContext is null");

            _contentTypeService = ApplicationContext.Services.ContentTypeService;

            _detachedContentTypeService = ((ServiceContext)merchelloContext.Services).DetachedContentTypeService;
        }
 //Constructors needed for testability and DI
 public MembersWallController(UmbracoContext umbracoContext,
     IMemberService _memberService,
     IRelationService _relationService,
     IMyHelper _myHelper)
     : base(umbracoContext)
 {
     this._memberService = _memberService;
     this._relationService = _relationService;
     this._myHelper = _myHelper;
 }
 ///Constructors needed for testability and DI
 public CommentSurfaceController(UmbracoContext umbracoContext, 
     IContentService _contentService, 
     IMemberService _memberService, 
     IRelationService _relationServices)
     : base(umbracoContext)
 {
     this._contentService = _contentService;
     this._memberService = _memberService;
     this._relationService = _relationServices;
 }
Ejemplo n.º 22
0
        internal CustomerContext(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(umbracoContext, "umbracoContext");

            _umbracoContext = umbracoContext;
            _customerService = merchelloContext.Services.CustomerService;
            _cache = merchelloContext.Cache;

            Initialize();
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomerContextBase"/> class.
        /// </summary>
        /// <param name="merchelloContext">
        /// The <see cref="IMerchelloContext"/>.
        /// </param>
        /// <param name="umbracoContext">
        /// The <see cref="UmbracoContext"/>.
        /// </param>
        protected CustomerContextBase(IMerchelloContext merchelloContext, UmbracoContext umbracoContext)
        {
            Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
            Mandate.ParameterNotNull(umbracoContext, "umbracoContext");

            this._merchelloContext = merchelloContext;
            this._umbracoContext = umbracoContext;
            this._customerService = merchelloContext.Services.CustomerService;
            this._cache = merchelloContext.Cache;
            this.Initialize();
        }
        public string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
        {
            var content = umbracoContext.ContentCache.GetById(id);
            if (content != null && content.DocumentTypeAlias == "Home" && content.Parent != null)
            {
                //The home node will have / instead of /home/.
                return content.Parent.Url;
            }

            return null;
        }
        public ContextMocker()
        {
            ILogger loggerMock = Mock.Of<ILogger>();
            IProfiler profilerMock = Mock.Of<IProfiler>();
            HttpContextBase contextBaseMock = Mock.Of<HttpContextBase>();
            WebSecurity webSecurityMock = new Mock<WebSecurity>(null, null).Object;
            IUmbracoSettingsSection umbracoSettingsSectionMock = Mock.Of<IUmbracoSettingsSection>();

            this.ApplicationContextMock = new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(loggerMock, profilerMock));
            this.UmbracoContextMock = UmbracoContext.EnsureContext(contextBaseMock, this.ApplicationContextMock, webSecurityMock, umbracoSettingsSectionMock, Enumerable.Empty<IUrlProvider>(), true);
        }
Ejemplo n.º 26
0
 public static MvcForm BeginUmbracoForm(this IHtmlHelper html, 
     UmbracoContext umbCtx,
     string action, 
     string controllerName, 
     string area = null,
     object additionalRouteVals = null,
     IDictionary<string, object> htmlAttributes = null,
     FormMethod method = FormMethod.Post)
 {
     var formAction = umbCtx.OriginalRequestUri.AbsolutePath;
     return html.RenderForm(formAction, method, htmlAttributes, controllerName, action, area, additionalRouteVals);
 }
        protected override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext, IPublishedContent baseContent)
        {
            var urlNames = _urlNames.Single(x => x.NodeId == baseContent.Id);

            var controllerName = requestContext.RouteData.GetRequiredString("controller");
            var rootUrl = baseContent.Url;

            return new ArticulateVirtualPage(
                baseContent,
                urlNames.SearchPageName,
                controllerName,
                urlNames.SearchUrlName);
        }
Ejemplo n.º 28
0
		public IEnumerable<IPublishedContent> GetRootDocuments(UmbracoContext umbracoContext)
		{
			var rootMedia = global::umbraco.cms.businesslogic.media.Media.GetRootMedias();
			var result = new List<IPublishedContent>();
			//TODO: need to get a ConvertFromMedia method but we'll just use this for now.
			foreach (var media in rootMedia
				.Select(m => global::umbraco.library.GetMedia(m.Id, true))
				.Where(media => media != null && media.Current != null))
			{
				media.MoveNext();
				result.Add(ConvertFromXPathNavigator(media.Current));
			}
			return result;
		}
Ejemplo n.º 29
0
 ///Constructors needed for testability and DI
 public MyHelper(UmbracoContext _umbracoContext,
     IContentService _contentService,
     IMemberService _memberService,
     IMediaService _mediaService,
     IRelationService _relationServices,
     Database _database)
 {
     this._contentService = _contentService;
     this._memberService = _memberService;
     this._mediaService = _mediaService;
     this._relationService = _relationServices;
     this._database = _database;
     this._umbracoContext = _umbracoContext;
 }
Ejemplo n.º 30
0
        private void MakePropertiesReadOnly(ContentItemDisplay contentItemDisplay, UmbracoContext context)
        {
            var usergroups = context.Security.CurrentUser.Groups.ToList();

            if (contentItemDisplay.ContentTypeAlias == HomePage.ModelTypeAlias && !usergroups.Exists(x => x.Alias == "admin"))
            {
                var settingsTab = contentItemDisplay.Tabs.FirstOrDefault(x => x.Label == "Settings");

                if (settingsTab != null)
                {
                    settingsTab.Properties.First(x => x.Alias == "brandName").View      = "readonlyvalue";
                    settingsTab.Properties.First(x => x.Alias == "isResellerSite").View = "readonlyvalue";
                }
            }
        }
        private void InitializeUmbracoContext()
        {
            RouteData routeData = null;

            var caches = CreatePublishedContent();

            var httpContext = GetHttpContextFactory("http://umbraco.local/", routeData).HttpContext;
            var ctx = new UmbracoContext(
                httpContext,
                ApplicationContext,
                caches,
                new WebSecurity(httpContext, ApplicationContext));

            UmbracoContext.Current = ctx;
        }
Ejemplo n.º 32
0
        internal static void SendNotification(this INotificationService service, IUser sender, IUmbracoEntity entity, IAction action, UmbracoContext umbracoContext, ApplicationContext applicationContext)
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (umbracoContext == null)
            {
                throw new ArgumentNullException("umbracoContext");
            }
            if (applicationContext == null)
            {
                throw new ArgumentNullException("applicationContext");
            }


            applicationContext.Services.NotificationService.SendNotifications(
                sender,
                entity,
                action.Letter.ToString(CultureInfo.InvariantCulture),
                ui.Text("actions", action.Alias),
                umbracoContext.HttpContext,
                (mailingUser, strings) => ui.Text("notifications", "mailSubject", strings, mailingUser),
                (mailingUser, strings) => UmbracoConfig.For.UmbracoSettings().Content.DisableHtmlEmail
                                              ? ui.Text("notifications", "mailBody", strings, mailingUser)
                                              : ui.Text("notifications", "mailBodyHtml", strings, mailingUser));
        }
Ejemplo n.º 33
0
        /// <summary>
        /// This is a helper method which is called to ensure that the singleton context is created
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="applicationContext"></param>
        /// <param name="webSecurity"></param>
        /// <param name="umbracoSettings"></param>
        /// <param name="urlProviders"></param>
        /// <param name="replaceContext">
        /// if set to true will replace the current singleton with a new one, this is generally only ever used because
        /// during application startup the base url domain will not be available so after app startup we'll replace the current
        /// context with a new one in which we can access the httpcontext.Request object.
        /// </param>
        /// <param name="preview"></param>
        /// <returns>
        /// The Singleton context object
        /// </returns>
        /// <remarks>
        /// This is created in order to standardize the creation of the singleton. Normally it is created during a request
        /// in the UmbracoModule, however this module does not execute during application startup so we need to ensure it
        /// during the startup process as well.
        /// See: http://issues.umbraco.org/issue/U4-1890, http://issues.umbraco.org/issue/U4-1717
        /// </remarks>
        public static UmbracoContext EnsureContext(
            HttpContextBase httpContext,
            ApplicationContext applicationContext,
            WebSecurity webSecurity,
            IUmbracoSettingsSection umbracoSettings,
            IEnumerable <IUrlProvider> urlProviders,
            bool replaceContext,
            bool?preview = null)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (applicationContext == null)
            {
                throw new ArgumentNullException("applicationContext");
            }
            if (webSecurity == null)
            {
                throw new ArgumentNullException("webSecurity");
            }
            if (umbracoSettings == null)
            {
                throw new ArgumentNullException("umbracoSettings");
            }
            if (urlProviders == null)
            {
                throw new ArgumentNullException("urlProviders");
            }

            if (UmbracoContext.Current != null)
            {
                if (replaceContext == false)
                {
                    return(UmbracoContext.Current);
                }
                UmbracoContext.Current._replacing = true;
            }

            var umbracoContext = new UmbracoContext(
                httpContext,
                applicationContext,
                new Lazy <IPublishedCaches>(() => PublishedCachesResolver.Current.Caches, false),
                webSecurity,
                preview);

            // create the RoutingContext, and assign
            var routingContext = new RoutingContext(
                umbracoContext,

                //TODO: Until the new cache is done we can't really expose these to override/mock
                new Lazy <IEnumerable <IContentFinder> >(() => ContentFinderResolver.Current.Finders),
                new Lazy <IContentFinder>(() => ContentLastChanceFinderResolver.Current.Finder),

                // create the nice urls provider
                // there's one per request because there are some behavior parameters that can be changed
                new Lazy <UrlProvider>(
                    () => new UrlProvider(
                        umbracoContext,
                        umbracoSettings.WebRouting,
                        urlProviders),
                    false));

            //assign the routing context back
            umbracoContext.RoutingContext = routingContext;

            //assign the singleton
            UmbracoContext.Current = umbracoContext;
            return(UmbracoContext.Current);
        }
 public UmbracoComponentRenderer(UmbracoContext umbracoContext)
 {
     _umbracoContext = umbracoContext;
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Informs the context that content has changed.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <remarks>
 /// <para>The contextual caches may, although that is not mandatory, provide an immutable snapshot of
 /// the content over the duration of the context. If you make changes to the content and do want to have
 /// the caches update their snapshot, you have to explicitely ask them to do so by calling ContentHasChanged.</para>
 /// <para>The context informs the contextual caches that content has changed.</para>
 /// </remarks>
 public static void ContentHasChanged(this UmbracoContext context)
 {
     context.ContentCache.ContentHasChanged();
     context.MediaCache.ContentHasChanged();
 }
Ejemplo n.º 36
0
 public static IHtmlString EnableCanvasDesigner(this HtmlHelper html,
                                                UrlHelper url,
                                                UmbracoContext umbCtx, string canvasdesignerConfigPath)
 {
     return(html.EnableCanvasDesigner(url, umbCtx, canvasdesignerConfigPath, string.Empty));
 }
Ejemplo n.º 37
0
 public virtual IPublishedContent GetDocumentById(UmbracoContext umbracoContext, int nodeId)
 {
     return(GetUmbracoMedia(nodeId));
 }
Ejemplo n.º 38
0
        internal static void SendNotification(this INotificationService service, IUmbracoEntity entity, IAction action, UmbracoContext umbracoContext, ApplicationContext applicationContext)
        {
            if (umbracoContext == null)
            {
                LogHelper.Warn(typeof(NotificationServiceExtensions), "Cannot send notifications, there is no current UmbracoContext");
                return;
            }

            var user = umbracoContext.Security.CurrentUser;

            //if there is no current user, then use the admin
            if (user == null)
            {
                LogHelper.Debug(typeof(NotificationServiceExtensions), "There is no current Umbraco user logged in, the notifications will be sent from the administrator");
                user = applicationContext.Services.UserService.GetUserById(0);
                if (user == null)
                {
                    LogHelper.Warn(typeof(NotificationServiceExtensions), "Noticiations can not be sent, no admin user with id 0 could be resolved");
                    return;
                }
            }
            service.SendNotification(user, entity, action, umbracoContext, applicationContext);
        }
 public IEnumerable <IPublishedContent> GetRootDocuments(UmbracoContext umbracoContext)
 {
     return((from XmlNode x in GetXml(umbracoContext).SelectNodes(XPathStrings.RootDocuments) select ConvertToDocument(x)).ToList());
 }
Ejemplo n.º 40
0
        /// <summary>
        /// If there are event messages in the current request this will return them , otherwise it will return null
        /// </summary>
        /// <param name="umbracoContext"></param>
        /// <returns></returns>
        public static EventMessages GetCurrentEventMessages(this UmbracoContext umbracoContext)
        {
            var eventMessagesFactory = umbracoContext.Application.Services.EventMessagesFactory as ScopeLifespanMessagesFactory;

            return(eventMessagesFactory == null ? null : eventMessagesFactory.TryGet());
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UmbracoHelper"/> class with an Umbraco context
 /// and a specific content item.
 /// </summary>
 /// <param name="umbracoContext">An Umbraco context.</param>
 /// <param name="content">A content item.</param>
 /// <param name="services">A services context.</param>
 /// <remarks>Sets the current page to the supplied content item.</remarks>
 public UmbracoHelper(UmbracoContext umbracoContext, ServiceContext services, IPublishedContent content)
     : this(umbracoContext, services)
 {
     _currentPage = content ?? throw new ArgumentNullException(nameof(content));
 }
Ejemplo n.º 42
0
 protected UmbracoAuthorizedHttpHandler(UmbracoContext umbracoContext, ServiceContext services)
     : base(umbracoContext, services)
 {
 }
Ejemplo n.º 43
0
 internal static void SendNotification(this INotificationService service, IUmbracoEntity entity, IAction action, UmbracoContext umbracoContext)
 {
     if (umbracoContext == null)
     {
         LogHelper.Warn(typeof(NotificationServiceExtensions), "Cannot send notifications, there is no current UmbracoContext");
         return;
     }
     service.SendNotification(entity, action, umbracoContext, umbracoContext.Application);
 }