コード例 #1
0
        public override async Task GetInfoAsync(GeMenuItemInput geMenuItemInput)
        {
            var itemDataModel  = geMenuItemInput.ItemDataModel;
            var moduleId       = itemDataModel.Id;
            var currentRequest = geMenuItemInput.CurrentRequest;
            var propertyName   = itemDataModel.PropertyName;

            var isPrivate = NewsItemBusinessModule.IsPrivate(propertyName);

            if (isPrivate && geMenuItemInput.IsSitemap)
            {
                return;
            }

            var menuItem = await NewsItemBusinessModule.GetMenuItemAsync(_urlProvider, itemDataModel, currentRequest, ModuleName, isPrivate);

            if (menuItem != null)
            {
                var expendoMenu = CacheProvider.ToExpando(menuItem);
                {
                    var items =
                        await
                        geMenuItemInput.DataFactory.ItemRepository.GetItemsAsync(itemDataModel.SiteId,
                                                                                 new ItemFilters { ParentId = moduleId });

                    await
                    CacheProvider.GetChildsAsync(_businessModuleFactory, geMenuItemInput.CurrentRequest, items,
                                                 expendoMenu,
                                                 geMenuItemInput.DataFactory);
                }

                ModuleManager.Add(geMenuItemInput.Master, itemDataModel.PropertyName, expendoMenu,
                                  itemDataModel.PropertyType);
            }
        }
コード例 #2
0
        public static async Task CheckAuthorisationAsync(UserService userService, ItemDataModel itemDataModel, string userId)
        {
            var siteId = itemDataModel.SiteId;
            var roles  = new List <SiteUserRole>();

            if (itemDataModel.State == ItemState.Draft)
            {
                roles.Add(SiteUserRole.Administrator);
            }
            else if (NewsItemBusinessModule.IsPrivate(itemDataModel.PropertyName))
            {
                roles.Add(SiteUserRole.PrivateUser);
            }
            var nbRole = roles.Count;

            if (nbRole > 0 && string.IsNullOrEmpty(userId))
            {
                throw new NotAuthentifiedException();
            }

            if (nbRole > 0)
            {
                var canGetData = await UserSecurity.HasRolesAsync(userService, userId, siteId, true, roles.ToArray());

                if (!canGetData)
                {
                    throw new NotAuthentifiedException();
                }
            }
        }