Exemple #1
0
        public override ConverterResponseModel MapViewModel(UintraGroupsRoomPageModel node, UintraGroupsRoomPageViewModel viewModel)
        {
            var groupId = _context.ParseQueryString("groupId").TryParseGuid();

            if (!groupId.HasValue)
            {
                return(NotFoundResult());
            }

            var group = _groupService.Get(groupId.Value);

            if (group == null || group.IsHidden)
            {
                return(NotFoundResult());
            }

            viewModel.GroupId     = groupId.Value;
            viewModel.GroupInfo   = _groupHelper.GetGroupViewModel(groupId.Value);
            viewModel.GroupHeader = _groupHelper.GetHeader(groupId.Value);

            viewModel.CreateEventsLink = _permissionsService.Check(PermissionResourceTypeEnum.Events, PermissionActionEnum.Create) ?
                                         _feedLinkService.GetCreateLinks(IntranetActivityTypeEnum.Events).Create?.AddGroupId(groupId.Value)
                : null;
            viewModel.CreateNewsLink = _permissionsService.Check(PermissionResourceTypeEnum.News, PermissionActionEnum.Create) ?
                                       _feedLinkService.GetCreateLinks(IntranetActivityTypeEnum.News).Create.AddGroupId(groupId.Value)
                : null;

            var socialCreateModel = _nodeModelService.AsEnumerable().OfType <SocialCreatePageModel>().First();

            viewModel.SocialCreateModel = _nodeModelService.GetViewModel <SocialCreatePageViewModel>(socialCreateModel);

            return(OkResult());
        }
        private EventCreateDataViewModel GetData(Guid?groupId)
        {
            var model = new EventCreateDataViewModel {
                GroupId = groupId
            };

            var currentMember = _memberService.GetCurrentMember();

            model.CanEditOwner = _permissionsService.Check(PermissionType, PermissionActionEnum.EditOwner);
            model.PinAllowed   = _permissionsService.Check(PermissionType, PermissionActionEnum.CanPin);

            if (model.CanEditOwner)
            {
                model.Members = GetUsersWithAccess(new PermissionSettingIdentity(PermissionActionEnum.Create, PermissionType));
            }

            model.Links = model.GroupId.HasValue ?
                          _feedLinkService.GetCreateLinks(ActivityType, model.GroupId.Value)
                : _feedLinkService.GetCreateLinks(ActivityType);

            var mediaSettings = _eventsService.GetMediaSettings();

            model.AllowedMediaExtensions = mediaSettings.AllowedMediaExtensions;
            model.Tags    = _tagProvider.GetAll();
            model.Creator = currentMember.ToViewModel();

            var now = DateTime.UtcNow;

            model.PublishDate = now;
            model.StartDate   = now;
            model.EndDate     = now.AddHours(8);

            return(model);
        }
        public void Map(HomePageModel node, HomePageViewModel viewModel)
        {
            var groupId = _context.ParseQueryString("groupId").TryParseGuid();

            viewModel.CreateEventsLink =
                _permissionsService.Check(PermissionResourceTypeEnum.Events, PermissionActionEnum.Create)
                    ? _feedLinkService.GetCreateLinks(IntranetActivityTypeEnum.Events).Create
                    : null;
            viewModel.CreateNewsLink =
                _permissionsService.Check(PermissionResourceTypeEnum.News, PermissionActionEnum.Create)
                    ? _feedLinkService.GetCreateLinks(IntranetActivityTypeEnum.News).Create
                    : null;

            if (node.UserListPage.Value.HasValue)
            {
                var userListPage = _nodeModelService.Get(node.UserListPage.Value.Value);
                viewModel.UserListPage = userListPage.Url.ToLinkModel();
            }


            if (groupId.HasValue)
            {
                viewModel.CreateNewsLink   = viewModel.CreateNewsLink?.AddGroupId(groupId.Value);
                viewModel.CreateEventsLink = viewModel.CreateEventsLink?.AddGroupId(groupId.Value);
            }

            var socialCreateModel = _nodeModelService.AsEnumerable().OfType <SocialCreatePageModel>().First();

            viewModel.SocialCreateModel = _nodeModelService.GetViewModel <SocialCreatePageViewModel>(socialCreateModel);
        }
        public bool CanPerform(GroupModel group, Enum action, Enum administrationAction)
        {
            var currentMember = _intranetMemberService.GetCurrentMember();
            var ownerId       = group.CreatorId;
            var isOwner       = ownerId == currentMember.Id;

            var act    = isOwner ? action : administrationAction;
            var result = _permissionsService.Check(currentMember, PermissionSettingIdentity.Of(act, PermissionResourceType));

            return(result);
        }
Exemple #5
0
        private bool HasPermission(Guid?groupId)
        {
            var hasPermission = _permissionsService.Check(PermissionType, PermissionActionEnum.Create);

            if (groupId.HasValue)
            {
                hasPermission = hasPermission &&
                                _groupMemberService.IsGroupMember(groupId.Value, _memberService.GetCurrentMemberId());
            }

            return(hasPermission);
        }
        public override ConverterResponseModel MapViewModel(UintraNewsEditPageModel node, UintraNewsEditPageViewModel viewModel)
        {
            var id = _context.ParseQueryString("id").TryParseGuid();

            if (!id.HasValue)
            {
                return(NotFoundResult());
            }

            var news = _newsService.Get(id.Value);

            if (news == null || news.IsHidden)
            {
                return(NotFoundResult());
            }

            if (news.GroupId.HasValue)
            {
                var group = _groupService.Get(news.GroupId.Value);
                if (group != null && group.IsHidden)
                {
                    return(NotFoundResult());
                }
            }

            if (!_newsService.CanEdit(id.Value))
            {
                return(ForbiddenResult());
            }

            viewModel.Details                = GetDetails(news);
            viewModel.Links                  = _feedLinkService.GetLinks(news.Id);
            viewModel.CanEditOwner           = _permissionsService.Check(PermissionResourceTypeEnum.News, PermissionActionEnum.EditOwner);
            viewModel.AllowedMediaExtensions = _newsService.GetMediaSettings().AllowedMediaExtensions;
            viewModel.PinAllowed             = _permissionsService.Check(PermissionResourceTypeEnum.News, PermissionActionEnum.CanPin);

            if (viewModel.CanEditOwner)
            {
                viewModel.Members = GetUsersWithAccess(new PermissionSettingIdentity(PermissionActionEnum.Create, PermissionResourceTypeEnum.News));
            }

            var requestGroupId = HttpContext.Current.Request["groupId"];

            if (Guid.TryParse(requestGroupId, out var groupId) && news.GroupId == groupId)
            {
                viewModel.GroupHeader = _groupHelper.GetHeader(groupId);
            }

            return(OkResult());
        }
Exemple #7
0
        public virtual ActionResult OwnerEdit(Guid ownerId, string ownerIdPropertyName, PermissionResourceTypeEnum activityType, IActivityCreateLinks links)
        {
            var model = new IntranetActivityOwnerEditModel
            {
                Owner = _intranetMemberService.Get(ownerId).Map <MemberViewModel>(),
                OwnerIdPropertyName = ownerIdPropertyName,
                Links = links
            };

            model.CanEditOwner = _permissionsService.Check(activityType, PermissionActionEnum.EditOwner);

            if (model.CanEditOwner)
            {
                model.Members = GetUsersWithAccess(PermissionSettingIdentity.Of(PermissionActionEnum.Create, activityType));
            }

            return(PartialView(OwnerEditViewPath, model));
        }
Exemple #8
0
        public bool ValidatePermission(IPublishedContent content)
        {
            if (content.DocumentTypeAlias == GroupsCreatePage)
            {
                return(_permissionsService.Check(PermissionSettingIdentity.Of(PermissionActionEnum.Create, PermissionResourceType)));
            }

            return(true);
        }
        private Event MapToEvent(EventCreateModel createModel)
        {
            var @event = createModel.Map <Event>();

            @event.MediaIds    = @event.MediaIds.Concat(_mediaHelper.CreateMedia(createModel, MediaFolderTypeEnum.NewsContent));
            @event.StartDate   = createModel.StartDate.ToUniversalTime();
            @event.PublishDate = createModel.PublishDate.ToUniversalTime();
            @event.EndDate     = createModel.EndDate.ToUniversalTime();
            @event.EndPinDate  = createModel.EndPinDate?.ToUniversalTime();
            @event.CreatorId   = _intranetMemberService.GetCurrentMemberId();

            if (!_permissionsService.Check(ActivityType, PermissionActionEnum.CanPin))
            {
                @event.EndPinDate = null;
                @event.IsPinned   = false;
            }

            return(@event);
        }
Exemple #10
0
        protected virtual bool CanPerform(IIntranetActivity activity, PermissionActionEnum action, PermissionActionEnum administrationAction)
        {
            var currentMember = _intranetMemberService.GetCurrentMember();
            var ownerId       = ((IHaveOwner)activity).OwnerId;
            var isOwner       = ownerId == currentMember.Id;

            var act    = isOwner ? action : administrationAction;
            var result = _permissionsService.Check(currentMember, new PermissionSettingIdentity(act, PermissionActivityType));

            return(result);
        }
Exemple #11
0
        protected virtual GroupFeedOverviewModel GetOverviewModel(Guid groupId)
        {
            var currentMember = _intranetMemberService.GetCurrentMember();
            var tabType       = _groupFeedContentContentService.GetFeedTabType(CurrentPage);

            var tabs         = _groupFeedContentContentService.GetActivityTabs(CurrentPage, currentMember, groupId);
            var activityTabs = tabs.Where(t => t.Type != null).Map <List <ActivityFeedTabViewModel> >();

            var model = new GroupFeedOverviewModel
            {
                Tabs = activityTabs,
                TabsWithCreateUrl = GetTabsWithCreateUrl(activityTabs).Where(tab =>
                                                                             _permissionsService.Check(tab.Type, PermissionActionEnum.Create)),
                CurrentType       = tabType,
                GroupId           = groupId,
                IsGroupMember     = _groupMemberService.IsGroupMember(groupId, currentMember),
                CanCreateBulletin = _permissionsService.Check(PermissionResourceTypeEnum.Bulletins, PermissionActionEnum.Create)
            };

            return(model);
        }
        protected virtual CentralFeedOverviewModel GetOverviewModel()
        {
            var tabType          = _centralFeedContentService.GetFeedTabType(CurrentPage);
            var centralFeedState = _feedFilterStateService.GetFiltersState();

            var activityTabs = GetActivityTabs().Map <List <ActivityFeedTabViewModel> >();

            var model = new CentralFeedOverviewModel
            {
                Tabs = activityTabs,
                TabsWithCreateUrl = GetTabsWithCreateUrl(activityTabs)
                                    .Where(tab => _permissionsService.Check(
                                               _permissionResourceTypeProvider[tab.Type.ToInt()],
                                               PermissionActionEnum.Create)),
                CurrentType       = tabType,
                IsFiltersOpened   = centralFeedState.IsFiltersOpened,
                CanCreateBulletin = _permissionsService.Check(
                    PermissionResourceTypeEnum.Bulletins,
                    PermissionActionEnum.Create)
            };

            return(model);
        }
        private CentralFeedFilterCommand GetPermissionCommand()
        {
            var activities = EnumHelper.ToEnumerable <PermissionResourceTypeEnum>();

            var list = new List <CentralFeedFilterPermissionModel>();

            foreach (var activity in activities)
            {
                var canView = _permissionsService.Check(activity, PermissionActionEnum.View);

                list.Add(new CentralFeedFilterPermissionModel(canView, activity));
            }

            return(new CentralFeedFilterCommand(list));
        }
        public override ConverterResponseModel MapViewModel(EventDetailsPageModel node,
                                                            EventDetailsPageViewModel viewModel)
        {
            var idStr = HttpUtility.ParseQueryString(_baselineRequestContext.NodeRequestParams.NodeUrl.Query)
                        .TryGetQueryValue <string>("id");

            if (!Guid.TryParse(idStr, out var id))
            {
                return(NotFoundResult());
            }

            var @event = _eventsService.Get(id);

            if (@event == null || @event.IsHidden)
            {
                return(NotFoundResult());
            }

            if (@event.GroupId.HasValue)
            {
                var group = _groupService.Get(@event.GroupId.Value);
                if (group != null && group.IsHidden)
                {
                    return(NotFoundResult());
                }
            }

            if (!_permissionsService.Check(PermissionResourceTypeEnum.Events, PermissionActionEnum.View))
            {
                return(ForbiddenResult());
            }

            var member = _memberService.GetCurrentMember();

            viewModel.Details       = GetDetails(@event);
            viewModel.Tags          = _userTagService.Get(id);
            viewModel.CanEdit       = _eventsService.CanEdit(id);
            viewModel.IsGroupMember = [email protected] || member.GroupIds.Contains(@event.GroupId.Value);

            var groupIdStr = HttpContext.Current.Request["groupId"];

            if (Guid.TryParse(groupIdStr, out var groupId) && @event.GroupId == groupId)
            {
                viewModel.GroupHeader = _groupHelper.GetHeader(groupId);
            }

            return(OkResult());
        }
        public override ConverterResponseModel MapViewModel(SocialDetailsPageModel node, SocialDetailsPageViewModel viewModel)
        {
            var id = _context.ParseQueryString("id").TryParseGuid();

            if (!id.HasValue)
            {
                return(NotFoundResult());
            }

            var social = _socialService.Get(id.Value);

            if (social == null)
            {
                return(NotFoundResult());
            }

            if (social.GroupId.HasValue)
            {
                var group = _groupService.Get(social.GroupId.Value);
                if (group != null && group.IsHidden)
                {
                    return(NotFoundResult());
                }
            }

            if (!_permissionsService.Check(PermissionResourceTypeEnum.Social, PermissionActionEnum.View))
            {
                return(ForbiddenResult());
            }

            var member = _memberService.GetCurrentMember();

            viewModel.Details       = GetViewModel(social);
            viewModel.Tags          = _userTagService.Get(id.Value);
            viewModel.CanEdit       = _socialService.CanEdit(id.Value);
            viewModel.IsGroupMember = !social.GroupId.HasValue || member.GroupIds.Contains(social.GroupId.Value);

            var groupIdStr = HttpContext.Current.Request["groupId"];

            if (Guid.TryParse(groupIdStr, out var groupId) && social.GroupId == groupId)
            {
                viewModel.GroupHeader = _groupHelper.GetHeader(groupId);
            }

            return(OkResult());
        }
Exemple #16
0
        public GroupLeftNavigationMenuViewModel GroupNavigation()
        {
            var rootGroupPage = _nodeModelService.AsEnumerable().OfType <UintraGroupsPageModel>().First();

            var groupPageChildren = _nodeModelService.AsEnumerable().Where(x =>
                                                                           x is IGroupNavigationComposition navigation && navigation.GroupNavigation.ShowInMenu &&
                                                                           x.ParentId == rootGroupPage.Id);

            groupPageChildren = groupPageChildren.Where(x =>
            {
                if (x is UintraGroupsCreatePageModel)
                {
                    return(_permissionsService.Check(new PermissionSettingIdentity(PermissionActionEnum.Create,
                                                                                   PermissionResourceTypeEnum.Groups)));
                }

                return(true);
            });

            var menuItems = groupPageChildren.OrderBy(x => ((IGroupNavigationComposition)x).GroupNavigation.SortOrder.Value).Select(x => new GroupLeftNavigationItemViewModel
            {
                Title = ((IGroupNavigationComposition)x).GroupNavigation.NavigationTitle,
                Link  = x.Url.ToLinkModel()
            });

            var result = new GroupLeftNavigationMenuViewModel
            {
                Items         = menuItems,
                GroupPageItem = new GroupLeftNavigationItemViewModel
                {
                    Link  = rootGroupPage.Url.ToLinkModel(),
                    Title = ((IGroupNavigationComposition)rootGroupPage).GroupNavigation.NavigationTitle
                }
            };

            return(result);
        }
Exemple #17
0
 public bool CanCreate()
 {
     return(_permissionsService.Check(new PermissionSettingIdentity(PermissionActionEnum.Create, PermissionResourceTypeEnum.Groups)));
 }
 protected virtual bool IsPinAllowed()
 {
     return(_permissionsService.Check(ActivityType, PermissionActionEnum.CanPin));
 }
Exemple #19
0
 protected bool IsAllowView(Enum type)
 {
     return(_permissionsService.Check((PermissionResourceTypeEnum)type.ToInt(), PermissionActionEnum.View));
 }
 private bool IsPinAllowed()
 {
     return(_permissionsService.Check(ActivityType, PermissionActionEnum.CanPin));
 }