Beispiel #1
0
        public virtual ActionResult Edit()
        {
            var user   = _intranetUserService.GetCurrentUser();
            var result = MapToEditModel(user);

            return(View(ProfileEditViewPath, result));
        }
Beispiel #2
0
        public NotifierData GetNotifierData <TActivity>(TActivity activity, Enum notificationType)
            where TActivity : IIntranetActivity, IHaveOwner
        {
            var currentUser = _intranetUserService.GetCurrentUser();
            var data        = new NotifierData
            {
                NotificationType = notificationType,
                ActivityType     = activity.Type,
                ReceiverIds      = ReceiverIds(activity, notificationType)
            };

            switch (notificationType)
            {
            case ActivityLikeAdded:
                data.Value = _notifierDataHelper.GetLikesNotifierDataModel(activity, notificationType, currentUser.Id);
                break;

            case BeforeStart:
                data.Value = _notifierDataHelper.GetActivityReminderDataModel(activity, notificationType);
                break;

            case EventHidden:
            case EventUpdated:
                data.Value = _notifierDataHelper.GetActivityNotifierDataModel(activity, notificationType, currentUser.Id);
                break;

            default:
                throw new InvalidOperationException();
            }

            return(data);
        }
Beispiel #3
0
        private NotifierData GetNotifierData(Guid entityId, Enum notificationType)
        {
            var data = new NotifierData
            {
                NotificationType = notificationType,
                ActivityType     = Type
            };

            var currentUser = _intranetUserService.GetCurrentUser();

            switch (notificationType)
            {
            case NotificationTypeEnum.ActivityLikeAdded:
            {
                var bulletinsEntity = Get(entityId);
                data.ReceiverIds = bulletinsEntity.OwnerId.ToEnumerable();
                data.Value       = _notifierDataHelper.GetLikesNotifierDataModel(bulletinsEntity, notificationType, currentUser.Id);
            }
            break;

            case NotificationTypeEnum.CommentAdded:
            case NotificationTypeEnum.CommentEdited:
            {
                var comment         = _commentsService.Get(entityId);
                var bulletinsEntity = Get(comment.ActivityId);
                data.ReceiverIds = bulletinsEntity.OwnerId.ToEnumerable();
                data.Value       = _notifierDataHelper.GetCommentNotifierDataModel(bulletinsEntity, comment, notificationType, comment.UserId);
            }
            break;

            case NotificationTypeEnum.CommentReplied:
            {
                var comment         = _commentsService.Get(entityId);
                var bulletinsEntity = Get(comment.ActivityId);
                data.ReceiverIds = comment.UserId.ToEnumerable();
                data.Value       = _notifierDataHelper.GetCommentNotifierDataModel(bulletinsEntity, comment, notificationType, currentUser.Id);
            }
            break;

            case NotificationTypeEnum.CommentLikeAdded:
            {
                var comment         = _commentsService.Get(entityId);
                var bulletinsEntity = Get(comment.ActivityId);
                data.ReceiverIds = currentUser.Id == comment.UserId
                            ? Enumerable.Empty <Guid>()
                            : comment.UserId.ToEnumerable();

                data.Value = _notifierDataHelper.GetCommentNotifierDataModel(bulletinsEntity, comment, notificationType, currentUser.Id);
            }
            break;

            default:
                return(null);
            }

            return(data);
        }
        protected override IEnumerable <EventBase> GetComingEvents(DateTime endDate)
        {
            var currentUser = _intranetUserService.GetCurrentUser();
            var events      = _eventsService.GetComingEvents(endDate);

            bool IsNotGroupEventOrUserInGroup(Event @event) =>
            [email protected] ||
            _groupMemberService.IsGroupMember(@event.GroupId.Value, currentUser.Id);

            return(events.Where(IsNotGroupEventOrUserInGroup));
        }
Beispiel #5
0
        public virtual ActionResult LeftNavigationUserMenu()
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            var result = new LeftNavigationUserMenuViewModel
            {
                CurrentUser = currentUser,
                ProfileLink = _profileLinkProvider.GetProfileLink(currentUser.Id)
            };

            return(PartialView(LeftNavigationUserMenuViewPath, result));
        }
        public virtual PartialViewResult PreView(Guid activityId, string link, bool isReadOnly)
        {
            var currentUserId = _intranetUserService.GetCurrentUser().Id;
            var model         = new CommentPreviewModel
            {
                Count               = _commentsService.GetCount(activityId),
                Link                = $"{link}#{GetOverviewElementId(activityId)}",
                IsReadOnly          = isReadOnly,
                IsExistsUserComment = _commentsService.IsExistsUserComment(activityId, currentUserId)
            };

            return(PartialView(PreviewViewPath, model));
        }
        public ActionResult Create(Guid groupId)
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            if (!_groupMemberService.IsGroupMember(groupId, currentUser))
            {
                return(new EmptyResult());
            }

            var activityType = _groupFeedContentContentService.GetCreateActivityType(CurrentPage);
            var viewModel    = GetCreateViewModel(activityType, groupId);

            return(PartialView(CreateViewPath, viewModel));
        }
Beispiel #8
0
        public override ActionResult Edit()
        {
            var user   = _intranetUserService.GetCurrentUser();
            var result = MapToEditModel(user);

            return(PartialView(ProfileEditViewPath, result));
        }
        private NotifierData GetNotifierData(Guid entityId, Enum notificationType)
        {
            var currentUser = _userService.GetCurrentUser();

            var data = new NotifierData()
            {
                NotificationType = notificationType,
                ActivityType     = Type,
            };

            switch (notificationType)
            {
            case NotificationTypeEnum.CommentLikeAdded:
            case NotificationTypeEnum.CommentReplied:
            {
                var comment = _commentsService.Get(entityId);
                data.ReceiverIds = comment.UserId.ToEnumerable();
                var currentContentPage = _umbracoHelper.TypedContent(comment.ActivityId);
                data.Value = _notifierDataHelper.GetCommentNotifierDataModel(currentContentPage, comment, notificationType, currentUser.Id);
            }
            break;

            default: return(null);
            }
            return(data);
        }
Beispiel #10
0
        protected override FeedListViewModel GetFeedListViewModel(GroupFeedListModel model, List <IFeedItem> filteredItems, Enum centralFeedType)
        {
            var result      = base.GetFeedListViewModel(model, filteredItems, centralFeedType);
            var currentUser = _intranetUserService.GetCurrentUser();

            result.IsReadOnly = !currentUser.GroupIds.Contains(model.GroupId);

            return(result);
        }
        public TopNavigationModel Get()
        {
            var result = new TopNavigationModel
            {
                CurrentUser = _intranetUserService.GetCurrentUser()
            };

            return(result);
        }
Beispiel #12
0
        public override bool CanEdit(IIntranetActivity activity)
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            var isWebmaster = _permissionsService.IsUserWebmaster(currentUser);

            if (isWebmaster)
            {
                return(true);
            }

            var ownerId = Get(activity.Id).OwnerId;
            var isOwner = ownerId == currentUser.Id;

            var isUserHasPermissions = _permissionsService.IsRoleHasPermissions(currentUser.Role, Type, IntranetActivityActionEnum.Edit);

            return(isOwner && isUserHasPermissions);
        }
Beispiel #13
0
        public TopNavigationModel Get()
        {
            var result = new TopNavigationModel
            {
                CurrentUser        = _intranetUserService.GetCurrentUser(),
                CentralUserListUrl = _contentPageContentPropvider.GetUserListContentPageFromPicker()?.Url
            };

            return(result);
        }
Beispiel #14
0
        protected override IEnumerable <IFeedItem> GetCentralFeedItems(Enum type)
        {
            var groupIds = _intranetUserService.GetCurrentUser().GroupIds;

            var groupFeed = IsTypeForAllActivities(type)
                ? _groupFeedService.GetFeed(groupIds)
                : _groupFeedService.GetFeed(type, groupIds);

            return(base.GetCentralFeedItems(type)
                   .Concat(groupFeed)
                   .OrderByDescending(item => item.PublishDate));
        }
        protected virtual GroupInfoViewModel GetInfoViewModel(Guid groupId)
        {
            var group = _groupService.Get(groupId);

            var groupInfo   = group.Map <GroupInfoViewModel>();
            var currentUser = _userService.GetCurrentUser();

            groupInfo.IsMember       = _groupMemberService.IsGroupMember(group.Id, currentUser.Id);
            groupInfo.CanUnsubscribe = group.CreatorId != currentUser.Id;

            groupInfo.Creator           = _userService.Get(group.CreatorId);
            groupInfo.MembersCount      = _groupMemberService.GetMembersCount(group.Id);
            groupInfo.CreatorProfileUrl = _profileLinkProvider.GetProfileLink(group.CreatorId);

            if (group.ImageId.HasValue)
            {
                groupInfo.GroupImageUrl = _imageHelper.GetImageWithPreset(Umbraco.TypedMedia(group.ImageId.Value).Url, UmbracoAliases.ImagePresets.GroupImageThumbnail);
            }

            return(groupInfo);
        }
        public virtual bool IsCurrentUserHasAccess(Enum activityType, IntranetActivityActionEnum action, Guid?activityId = null)
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            if (currentUser == null)
            {
                return(false);
            }

            var result = IsUserHasAccess(currentUser, activityType, action, activityId);

            return(result);
        }
        protected virtual IEnumerable <IPublishedContent> ValidateGroupSubNavigationItems(IEnumerable <IPublishedContent> items)
        {
            var role = _intranetUserService.GetCurrentUser().Role;

            foreach (var item in items)
            {
                var validatePermission = _groupPermissionsService.ValidatePermission(item, role);
                if (validatePermission)
                {
                    yield return(item);
                }
            }
        }
        public virtual ActionResult DocumentsTable(Guid groupId, GroupDocumentDocumentField column, Direction direction)
        {
            var groupDocumentsList = _groupDocumentsService.GetByGroup(groupId).ToList();
            var mediaIdsList       = groupDocumentsList.Select(s => s.MediaId).ToList();
            var medias             = _mediaService.GetByIds(mediaIdsList);
            var group        = _groupService.Get(groupId);
            var groupMembers = _groupMemberService.GetGroupMemberByGroup(groupId);
            var currentUser  = _intranetUserService.GetCurrentUser();
            var docs         = medias.Select(s =>
            {
                var intranetCreator = s.GetValue <Guid?>(IntranetConstants.IntranetCreatorId);
                var creator         = intranetCreator.HasValue ? _intranetUserService.Get(intranetCreator.Value) : _intranetUserService.Get(s.CreatorId);
                var document        = groupDocumentsList.First(f => f.MediaId == s.Id);
                var url             = _umbracoHelper.TypedMedia(s.Id).Url;
                var model           = new GroupDocumentTableRowViewModel
                {
                    CanDelete   = CanDelete(currentUser, group, groupMembers, s),
                    Id          = document.Id,
                    CreateDate  = s.CreateDate,
                    Name        = s.Name,
                    Type        = s.GetValue <string>(UmbracoAliases.Media.MediaExtension),
                    CreatorName = creator.DisplayedName,
                    FileUrl     = url
                };
                return(model);
            });

            docs = Sort(docs, column, direction);

            var viewModel = new GroupDocumentsTableViewModel
            {
                Documents = docs,
                GroupId   = groupId,
                Column    = column,
                Direction = direction
            };

            return(PartialView(GroupDocumentsTableViewPath, viewModel));
        }
Beispiel #19
0
        protected virtual NewsCreateModel GetCreateModel(IActivityCreateLinks links)
        {
            var mediaSettings = _newsService.GetMediaSettings();
            var model         = new NewsCreateModel
            {
                PublishDate  = DateTime.UtcNow,
                OwnerId      = _intranetUserService.GetCurrentUser().Id,
                ActivityType = _activityTypeProvider[ActivityTypeId],
                Links        = links,
                MediaRootId  = mediaSettings.MediaRootId
            };

            return(model);
        }
Beispiel #20
0
        public virtual IEnumerable <IFeedItem> ApplyFilters(IEnumerable <IFeedItem> items, FeedFilterStateModel filterState, FeedSettings settings)
        {
            if (filterState.ShowSubscribed.GetValueOrDefault() && settings.HasSubscribersFilter)
            {
                items = items.Where(i =>
                                    i is ISubscribable subscribable &&
                                    _subscribeService.IsSubscribed(_intranetUserService.GetCurrentUser().Id, subscribable));
            }

            if (filterState.ShowPinned.GetValueOrDefault() && settings.HasPinnedFilter)
            {
                items = items.Where(i => i.IsPinned);
            }

            items = ApplyAdditionalFilters(items);
            return(items);
        }
        protected virtual BulletinCreateModel GetCreateFormModel(IActivityCreateLinks links)
        {
            var currentUser   = _userService.GetCurrentUser();
            var mediaSettings = _bulletinsService.GetMediaSettings();

            var result = new BulletinCreateModel
            {
                Title                  = currentUser.DisplayedName,
                ActivityType           = _activityTypeProvider[ActivityTypeId],
                Dates                  = DateTime.UtcNow.ToDateFormat().ToEnumerable(),
                Creator                = currentUser,
                Links                  = links,
                AllowedMediaExtensions = mediaSettings.AllowedMediaExtensions,
                MediaRootId            = mediaSettings.MediaRootId
            };

            return(result);
        }
Beispiel #22
0
        private bool CanPerform(IIntranetActivity cached, IntranetActivityActionEnum action)
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            var isWebmaster = _permissionsService.IsUserWebmaster(currentUser);

            if (isWebmaster)
            {
                return(true);
            }

            var ownerId = Get(cached.Id).OwnerId;
            var isOwner = ownerId == currentUser.Id;

            var isUserHasPermissions = _permissionsService.IsRoleHasPermissions(currentUser.Role, Type, action);

            return(isOwner && isUserHasPermissions);
        }
Beispiel #23
0
        public virtual ActionResult OwnerEdit(Guid ownerId, string ownerIdPropertyName, IntranetActivityTypeEnum activityType, IActivityCreateLinks links)
        {
            var model = new IntranetActivityOwnerEditModel
            {
                Owner = _intranetUserService.Get(ownerId),
                OwnerIdPropertyName = ownerIdPropertyName,
                Links = links
            };

            var currentUser = _intranetUserService.GetCurrentUser();

            model.CanEditOwner = _permissionsService.IsRoleHasPermissions(currentUser.Role, PermissionConstants.CanEditOwner);
            if (model.CanEditOwner)
            {
                model.Users = GetUsersWithAccess(activityType, IntranetActivityActionEnum.Create);
            }

            return(PartialView(OwnerEditViewPath, model));
        }
Beispiel #24
0
        protected virtual MyLinkDTO GetLinkDTO(int contentId, string queryString)
        {
            var model = new MyLinkDTO
            {
                ContentId   = contentId,
                UserId      = _intranetUserService.GetCurrentUser().Id,
                QueryString = queryString
            };

            if (IsActivityLink(contentId))
            {
                model.ActivityId = GetActivityLinkFromQuery(queryString);
            }

            if (IsGroupPage(contentId))
            {
                model.ActivityId = GetActivityLinkFromQuery(queryString);
            }

            return(model);
        }
        public override IEnumerable <MyLinkItemModel> GetMenu()
        {
            var links = _myLinksService
                        .GetMany(_intranetUserService.GetCurrentUser().Id)
                        .OrderByDescending(link => link.CreatedDate)
                        .ToList();

            var contents = _umbracoHelper.TypedContent(links.Select(el => el.ContentId));

            var models = links.Join(contents,
                                    link => link.ContentId,
                                    content => content.Id,
                                    (link, content) => new MyLinkItemModel
            {
                Id   = link.Id,
                Name = link.ActivityId.HasValue ? GetLinkName(link.ActivityId.Value) : GetNavigationName(content),
                Url  = GetUrl(link, content)
            });

            return(models.Distinct(_myLinkItemModelComparer));
        }
Beispiel #26
0
        private IEnumerable <GroupLeftNavigationItemViewModel> GetMenuItems(IPublishedContent rootGroupPage)
        {
            var isPageActive = GetIsPageActiveFunc(_umbracoHelper.AssignedContentItem);
            var role         = _intranetUserService.GetCurrentUser().Role;

            var groupPageChildren = rootGroupPage.Children.Where(el => el.IsShowPageInSubNavigation()).ToList();

            foreach (var subPage in groupPageChildren)
            {
                if (subPage.IsShowPageInSubNavigation())
                {
                    if (_groupPermissionsService.ValidatePermission(subPage, role))
                    {
                        yield return(MapToLeftNavigationItem(subPage, isPageActive));
                    }
                }
                else
                {
                    yield return(MapToLeftNavigationItem(subPage, isPageActive));
                }
            }
        }
Beispiel #27
0
        public virtual ActionResult LoginToUmbraco()
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            if (!currentUser.UmbracoId.HasValue)
            {
                return(Redirect(DefaultRedirectUrl));
            }

            var umbracoUser = _userService.GetUserById(currentUser.UmbracoId.Value);

            if (umbracoUser == null ||
                umbracoUser.IsLockedOut ||
                !umbracoUser.IsApproved)
            {
                return(Redirect(DefaultRedirectUrl));
            }

            UmbracoContext.Security.PerformLogin(umbracoUser.Id);

            return(Redirect(UmbracoRedirectUrl));
        }
        private ActionResult RenderGroupNavigation()
        {
            var groupId = Request.QueryString.GetGroupId();

            if (!groupId.HasValue)
            {
                return(new EmptyResult());
            }
            var group = _groupService.Get(groupId.Value);

            if (group == null)
            {
                return(new EmptyResult());
            }

            var groupNavigationModel = new GroupNavigationViewModel {
                GroupTitle = @group.Title
            };

            if (!group.IsHidden)
            {
                groupNavigationModel.GroupUrl = _groupLinkProvider.GetGroupLink(group.Id);

                groupNavigationModel.ActivityTabs = _groupFeedContentService
                                                    .GetMainFeedTab(CurrentPage, groupId.Value)
                                                    .ToEnumerable()
                                                    .Map <IEnumerable <GroupNavigationActivityTabViewModel> >();

                var currentUser   = _intranetUserService.GetCurrentUser();
                var groupEditPage = _groupContentProvider.GetEditPage();
                groupNavigationModel.PageTabs = _groupFeedContentService
                                                .GetPageTabs(CurrentPage, currentUser, groupId.Value)
                                                .Select(t => MapToGroupPageTabViewModel(t, groupEditPage));
            }


            return(PartialView(GroupNavigationViewPath, groupNavigationModel));
        }
        public void Update(NotifierTypeEnum type, bool isEnabled)
        {
            var currentUser = _intranetUserService.GetCurrentUser();

            _memberNotifiersSettingsService.SetForMember(currentUser.Id, type, isEnabled);
        }
        public static Guid GetCurrentUserId(this IIntranetUserService <IIntranetUser> intranetUserService)
        {
            var currentUser = intranetUserService.GetCurrentUser();

            return(currentUser.Id);
        }