Esempio n. 1
0
 /// <summary>
 /// System to extend the known context by more information if we're running inside a block
 /// </summary>
 /// <param name="newContext"></param>
 /// <returns></returns>
 internal CmsContext Update(IContextOfSite newContext)
 {
     Context = newContext;
     _page   = null;
     _module = null;
     return(this);
 }
Esempio n. 2
0
        public void DoInsidePublishing(IContextOfSite context, Action <VersioningActionInfo> action)
        {
            var possibleContextOfBlock = context as IContextOfBlock;
            var enabled    = possibleContextOfBlock?.Publishing.ForceDraft ?? false;
            var instanceId = possibleContextOfBlock?.Module.Id ?? Eav.Constants.IdNotInitialized;
            var userId     = (context.User as DnnUser)?.UnwrappedContents.UserID ?? Eav.Constants.IdNotInitialized;

            Log.Add($"DoInsidePublishing(module:{instanceId}, user:{userId}, enabled:{enabled})");

            if (enabled)
            {
                var moduleVersionSettings = new DnnPagePublishing.ModuleVersions(instanceId, Log);

                // Get an new version number and submit it to DNN
                // The submission must be made every time something changes, because a "discard" could have happened
                // in the meantime.
                TabChangeTracker.Instance.TrackModuleModification(
                    moduleVersionSettings.ModuleInfo,
                    moduleVersionSettings.IncreaseLatestVersion(),
                    userId
                    );
            }

            var versioningActionInfo = new VersioningActionInfo();

            action.Invoke(versioningActionInfo);
            Log.Add("/DoInsidePublishing");
        }
Esempio n. 3
0
        public ViewsBackend(Lazy <CmsManager> cmsManagerLazy, IContextOfSite context) : base("Bck.Views")
        {
            _cmsManagerLazy = cmsManagerLazy;

            _site = context.Site;
            _user = context.User;
        }
Esempio n. 4
0
        public void DoInsidePublishing(IContextOfSite context, Action <VersioningActionInfo> action)
        {
            var wrapLog = Log.Call();
            var versioningActionInfo = new VersioningActionInfo();

            action.Invoke(versioningActionInfo);
            wrapLog(null);
        }
Esempio n. 5
0
        public ViewsExportImport(IServerPaths serverPaths,
                                 TemplateHelpers appHelpers,
                                 IEnvironmentLogger envLogger,
                                 Lazy <CmsManager> cmsManagerLazy,
                                 Lazy <JsonBundleSerializer> jsonBundleLazy,
                                 IContextOfSite context) : base("Bck.Views")
        {
            _serverPaths    = serverPaths;
            _appHelpers     = appHelpers;
            _envLogger      = envLogger;
            _cmsManagerLazy = cmsManagerLazy;
            _jsonBundleLazy = jsonBundleLazy;

            _site = context.Site;
            _user = context.User;
        }
Esempio n. 6
0
        private Dictionary <string, IEnumerable <Dictionary <string, object> > > BuildQueryAndRun(
            IApp app,
            string name,
            string stream,
            bool includeGuid,
            IContextOfSite context,
            bool userMayEdit,
            AppQueryParameters more)
        {
            var wrapLog = Log.Call($"name:{name}, stream:{stream}, withModule:{(context as IContextOfBlock)?.Module.Id}");
            var query   = app.GetQuery(name);

            if (query == null)
            {
                var msg = $"query '{name}' not found";
                wrapLog(msg);
                throw new HttpExceptionAbstraction(HttpStatusCode.NotFound, msg, "query not found");
            }

            var permissionChecker = context.ServiceProvider.Build <AppPermissionCheck>()
                                    .ForItem(context, app, query.Definition.Entity, Log);
            var readExplicitlyAllowed = permissionChecker.UserMay(GrantSets.ReadSomething);

            var isAdmin = context.User.IsAdmin;

            // Only return query if permissions ok
            if (!(readExplicitlyAllowed || isAdmin))
            {
                var msg = $"Request not allowed. User does not have read permissions for query '{name}'";
                wrapLog(msg);
                throw new HttpExceptionAbstraction(HttpStatusCode.Unauthorized, msg, "Request not allowed");
            }

            var serializer = new DataToDictionary(userMayEdit)
            {
                WithGuid = includeGuid
            };

            if (stream == AllStreams)
            {
                stream = null;
            }
            var result = serializer.Convert(query, stream?.Split(','), more?.Guids);

            wrapLog(null);
            return(result);
        }
Esempio n. 7
0
        public void DoInsidePublishing(IContextOfSite context, Action <VersioningActionInfo> action)
        {
            var containerId = (context as IContextOfBlock)?.Module.Id ?? Eav.Constants.IdNotInitialized;
            var userId      = 0;
            var enabled     = false;// IsEnabled(containerId);

            Log.Add($"DoInsidePublishing(module:{containerId}, user:{userId}, enabled:{enabled})");
            if (enabled)
            {
                /* ignore */
            }

            var versioningActionInfo = new VersioningActionInfo();

            action.Invoke(versioningActionInfo);
            Log.Add("/DoInsidePublishing");
        }
Esempio n. 8
0
 public AppsBackend(CmsZones cmsZones, IContextOfSite context, IServiceProvider serviceProvider) : base(serviceProvider, "Bck.Apps")
 {
     _cmsZones = cmsZones;
     _context  = context;
 }
Esempio n. 9
0
 public Dependencies(IContextOfSite siteCtx, JsContextLanguage jsCtx, Apps.App appToLaterInitialize)
 {
     SiteCtx = siteCtx;
     JsCtx   = jsCtx;
     AppToLaterInitialize = appToLaterInitialize;
 }
Esempio n. 10
0
 public OqtUiContextBuilder(ILinkPaths linkPaths, IContextOfSite ctx, Dependencies deps) : base(deps)
 {
     _linkPaths = linkPaths;
     _context   = ctx;
 }
Esempio n. 11
0
        // note: not sure yet where the best place for this method is, so it's here for now
        // will probably move again some day
        internal LookUpEngine GetConfigProviderForModule(IContextOfSite context, IApp appForLookup, IBlock blockForLookup)
        {
            var modId = (context as ContextOfBlock)?.Module.Id ?? 0;

            var wrapLog = Log.Call <LookUpEngine>($"{modId}, ..., ...");


            // Find the standard DNN property sources if PortalSettings object is available
            var envLookups = _getEngineLazy.Value.Init(Log).GetLookUpEngine(modId);

            Log.Add($"Environment provided {envLookups.Sources.Count} sources");

            var provider = new LookUpEngine(envLookups, Log);

            // Add QueryString etc. when running inside an http-context. Otherwise leave them away!
            var http = _httpLazy.Value;

            if (http.Current != null)
            {
                Log.Add("Found Http-Context, will ty to add params for querystring, server etc.");

                // new
                var paramList   = new NameValueCollection();
                var ctxWithPage = context as IContextOfBlock;
                if (ctxWithPage?.Page.Parameters != null)
                {
                    foreach (var pair in ctxWithPage.Page.Parameters)
                    {
                        paramList.Add(pair.Key, pair.Value);
                    }
                }
                else
                {
                    paramList = http.QueryStringParams;
                }
                provider.Add(new LookUpInNameValueCollection("querystring", paramList));

                // old
#if NET451
                provider.Add(new LookUpInNameValueCollection("server", http.Request.ServerVariables));
                provider.Add(new LookUpInNameValueCollection("form", http.Request.Form));
#else
                // "Not Yet Implemented in .net standard #TodoNetStandard" - might not actually support this
#endif
            }
            else
            {
                Log.Add("No Http-Context found, won't add http params to look-up");
            }


            provider.Add(new LookUpInAppProperty("app", appForLookup));

            // add module if it was not already added previously
            if (!provider.HasSource(CmsBlock.InstanceLookupName))
            {
                var modulePropertyAccess = new LookUpInDictionary(CmsBlock.InstanceLookupName);
                modulePropertyAccess.Properties.Add(CmsBlock.InstanceIdKey, modId.ToString(CultureInfo.InvariantCulture));
                provider.Add(modulePropertyAccess);
            }

            // provide the current SxcInstance to the children where necessary
            if (!provider.HasSource(LookUpConstants.InstanceContext) && blockForLookup != null)
            {
                var blockBuilderLookUp = new LookUpCmsBlock(LookUpConstants.InstanceContext, blockForLookup);
                provider.Add(blockBuilderLookUp);
            }
            return(wrapLog("ok", provider));
        }
Esempio n. 12
0
        public void DoInsidePublishing(IContextOfSite context, Action <VersioningActionInfo> action)
        {
            var info = new VersioningActionInfo();

            action.Invoke(info);
        }
Esempio n. 13
0
 /// <summary>
 /// DI Constructor
 /// </summary>
 public CmsContext(IPlatform platform, IContextOfSite context)
 {
     Context  = context;
     Platform = platform;
 }