/// <summary> /// 获取用户当前选中的皮肤 /// </summary> /// <param name="ownerId">拥有者Id(如:用户Id、群组Id)</param> /// <returns></returns> public string GetThemeAppearance(long ownerId) { var groupService = new GroupService(); GroupEntity group = groupService.Get(ownerId); if (group == null) return string.Empty; PresentArea pa = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.GroupSpace); if (pa != null && !pa.EnableThemes) { return pa.DefaultThemeKey + "," + pa.DefaultAppearanceKey; } if (group.IsUseCustomStyle) { return "Default,Default"; } else if (!string.IsNullOrEmpty(group.ThemeAppearance)) { var appearance = new ThemeService().GetThemeAppearance(PresentAreaKeysOfBuiltIn.GroupSpace, group.ThemeAppearance); if (appearance != null) return group.ThemeAppearance; } if (pa != null) { return pa.DefaultThemeKey + "," + pa.DefaultAppearanceKey; } return string.Empty; }
void SetStatusInvitationnForJoinGroupEventModule_After(Invitation sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Update()) { InvitationService invitationService = DIContainer.Resolve<InvitationService>(); Invitation invitation = invitationService.Get(sender.Id); if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().InviteJoinGroup() && invitation.Status == InvitationStatus.Accept) { GroupService groupService = new GroupService(); GroupMember member=GroupMember.New(); member.GroupId=sender.RelativeObjectId; member.UserId = sender.UserId; member.IsManager = false; groupService.CreateGroupMember(member); } else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Accept) { GroupService groupService = new GroupService(); GroupMember member = GroupMember.New(); member.GroupId = sender.RelativeObjectId; member.UserId = sender.SenderUserId; member.IsManager = false; groupService.CreateGroupMember(member); IEnumerable<long> a= groupService.GetGroupMemberApplies(sender.RelativeObjectId,GroupMemberApplyStatus.Pending,20,1).Where(n=>n.UserId==sender.SenderUserId).Select(m=>m.Id); groupService.ApproveGroupMemberApply(a,true); } else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Refuse) { GroupService groupService = new GroupService(); IEnumerable<long> a = groupService.GetGroupMemberApplies(sender.RelativeObjectId, GroupMemberApplyStatus.Pending, 20, 1).Where(n => n.UserId == sender.SenderUserId).Select(m => m.Id); groupService.ApproveGroupMemberApply(a,false); } } }
/// <summary> /// 详细页面地址 /// </summary> /// <param name="itemId">推荐内容Id</param> /// <returns></returns> public string RecommendItemDetail(long itemId) { GroupEntity group = new GroupService().Get(itemId); if (group == null) return string.Empty; string userName = UserIdToUserNameDictionary.GetUserName(group.UserId); return SiteUrls.Instance().GroupHome(itemId); }
public WebimPlugin() { userService = DIContainer.Resolve<IUserService>(); groupService = new GroupService(); followService = new FollowService(); }
/// <summary> /// 更新皮肤 /// </summary> /// <param name="ownerId">拥有者Id(如:用户Id、群组Id)</param> /// <param name="isUseCustomStyle">是否使用自定义皮肤</param> /// <param name="themeAppearance">themeKey与appearanceKey用逗号关联</param> public void ChangeThemeAppearance(long ownerId, bool isUseCustomStyle, string themeAppearance) { var groupService = new GroupService(); GroupEntity group = groupService.Get(ownerId); if (group == null) throw new ExceptionFacade("找不到群组"); new ThemeService().ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.GroupSpace, group.IsUseCustomStyle ? string.Empty : group.ThemeAppearance, isUseCustomStyle ? string.Empty : themeAppearance); new GroupService().ChangeThemeAppearance(ownerId, isUseCustomStyle, themeAppearance); }
/// <summary> /// 动态处理程序 /// </summary> /// <param name="groupMember"></param> /// <param name="eventArgs"></param> private void GroupMemberActivityModule_After(GroupMember groupMember, CommonEventArgs eventArgs) { ActivityService activityService = new ActivityService(); if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { //生成动态 if (groupMember == null) return; var group = new GroupService().Get(groupMember.GroupId); if (group == null) return; //生成Owner为群组的动态 Activity actvityOfGroup = Activity.New(); actvityOfGroup.ActivityItemKey = ActivityItemKeys.Instance().CreateGroupMember(); actvityOfGroup.ApplicationId = GroupConfig.Instance().ApplicationId; actvityOfGroup.IsOriginalThread = true; actvityOfGroup.IsPrivate = !group.IsPublic; actvityOfGroup.UserId = groupMember.UserId; actvityOfGroup.ReferenceId = 0; actvityOfGroup.ReferenceTenantTypeId = string.Empty; actvityOfGroup.SourceId = groupMember.Id; actvityOfGroup.TenantTypeId = TenantTypeIds.Instance().User(); actvityOfGroup.OwnerId = group.GroupId; actvityOfGroup.OwnerName = group.GroupName; actvityOfGroup.OwnerType = ActivityOwnerTypes.Instance().Group(); activityService.Generate(actvityOfGroup, false); //生成Owner为用户的动态 Activity actvityOfUser = Activity.New(); actvityOfUser.ActivityItemKey = ActivityItemKeys.Instance().JoinGroup(); actvityOfUser.ApplicationId = actvityOfGroup.ApplicationId; actvityOfUser.HasImage = actvityOfGroup.HasImage; actvityOfUser.HasMusic = actvityOfGroup.HasMusic; actvityOfUser.HasVideo = actvityOfGroup.HasVideo; actvityOfUser.IsOriginalThread = actvityOfGroup.IsOriginalThread; actvityOfUser.IsPrivate = actvityOfGroup.IsPrivate; actvityOfUser.UserId = actvityOfGroup.UserId; actvityOfUser.ReferenceId = actvityOfGroup.ReferenceId; actvityOfGroup.ReferenceTenantTypeId = actvityOfGroup.ReferenceTenantTypeId; actvityOfUser.SourceId = actvityOfGroup.SourceId; actvityOfUser.TenantTypeId = actvityOfGroup.TenantTypeId; actvityOfUser.OwnerId = groupMember.UserId; actvityOfUser.OwnerName = groupMember.User.DisplayName; actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(actvityOfUser, false); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) //删除动态 { activityService.DeleteSource(TenantTypeIds.Instance().User(), groupMember.UserId); } }
/// <summary> /// 获取接收人UserId集合 /// </summary> /// <param name="activityService">动态业务逻辑类</param> /// <param name="activity">动态</param> /// <returns></returns> IEnumerable<long> IActivityReceiverGetter.GetReceiverUserIds(ActivityService activityService, Activity activity) { GroupService groupService = new GroupService(); IEnumerable<long> userIds = groupService.GetUserIdsOfGroup(activity.OwnerId); bool isPublic = false; var group = groupService.Get(activity.OwnerId); if (group != null) isPublic = group.IsPublic; if (userIds == null) return new List<long>(); return userIds.Where(n => IsReceiveActivity(activityService, isPublic, n, activity)); }
ThemeAppearance IThemeResolver.GetRequestTheme(RequestContext controllerContext) { string spaceKey = controllerContext.GetParameterFromRouteDataOrQueryString("SpaceKey"); GroupEntity group = new GroupService().Get(spaceKey); if (group == null) throw new ExceptionFacade("找不到群组"); string themeKey = null; string appearanceKey = null; PresentArea pa = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.GroupSpace); if (pa == null) throw new ExceptionFacade("找不到群组呈现区域"); if (pa.EnableThemes) { if (group.IsUseCustomStyle) { themeKey = "Default"; appearanceKey = "Default"; } else { string[] themeAppearanceArray = group.ThemeAppearance.Split(','); var appearance = new ThemeService().GetThemeAppearance(PresentAreaKeysOfBuiltIn.GroupSpace, group.ThemeAppearance); if (appearance != null && themeAppearanceArray.Count() == 2) { themeKey = themeAppearanceArray[0]; appearanceKey = themeAppearanceArray[1]; } } } if (themeKey == null || appearanceKey == null) { themeKey = pa.DefaultThemeKey; appearanceKey = pa.DefaultAppearanceKey; } return new ThemeService().GetThemeAppearance(PresentAreaKeysOfBuiltIn.GroupSpace, themeKey, appearanceKey); }
/// <summary> /// 设置/取消管理员通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void SetManagerNoticeEventModule_After(GroupMember sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType != EventOperationType.Instance().SetGroupManager() && eventArgs.EventOperationType != EventOperationType.Instance().CancelGroupManager()) return; GroupService groupService = new GroupService(); GroupEntity entity = groupService.Get(sender.GroupId); if (entity == null) return; User senderUser = DIContainer.Resolve<IUserService>().GetFullUser(sender.UserId); if (senderUser == null) return; NoticeService noticeService = DIContainer.Resolve<NoticeService>(); Notice notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActorUserId = 0; notice.LeadingActor = string.Empty; notice.LeadingActorUrl = string.Empty; notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); if (eventArgs.EventOperationType == EventOperationType.Instance().SetGroupManager()) { notice.TemplateName = NoticeTemplateNames.Instance().SetGroupManager(); } else { notice.TemplateName = NoticeTemplateNames.Instance().CannelGroupManager(); } noticeService.Create(notice); }
/// <summary> /// 通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void GroupMemberNoticeModule_After(GroupMember sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType != EventOperationType.Instance().Delete() && eventArgs.EventOperationType != EventOperationType.Instance().Create() && sender != null) return; GroupService groupService = new GroupService(); GroupEntity entity = groupService.Get(sender.GroupId); if (entity == null) return; User senderUser = DIContainer.Resolve<IUserService>().GetFullUser(sender.UserId); if (senderUser == null) return; NoticeService noticeService = DIContainer.Resolve<NoticeService>(); Notice notice; List<long> toUserIds = new List<long>(); toUserIds.Add(entity.UserId); toUserIds.AddRange(entity.GroupManagers.Select(n => n.UserId)); //删除群组成员通知群管理员 if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { foreach (var toUserId in toUserIds) { if (toUserId == sender.UserId) continue; notice = Notice.New(); notice.UserId = toUserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActorUserId = sender.UserId; notice.LeadingActor = senderUser.DisplayName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); notice.TemplateName = NoticeTemplateNames.Instance().MemberQuit(); noticeService.Create(notice); } } else if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) //添加群成员时向群管理员发送通知 { foreach (var toUserId in toUserIds) { if (toUserId == sender.UserId) continue; notice = Notice.New(); notice.UserId = toUserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActorUserId = sender.UserId; notice.LeadingActor = senderUser.DisplayName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); notice.TemplateName = NoticeTemplateNames.Instance().MemberJoin(); noticeService.Create(notice); } //向加入者发送通知 //notice = Notice.New(); //notice.UserId = sender.UserId; //notice.ApplicationId = GroupConfig.Instance().ApplicationId; //notice.TypeId = NoticeTypeIds.Instance().Hint(); //notice.LeadingActorUserId = sender.UserId; //notice.LeadingActor = senderUser.DisplayName; //notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); //notice.RelativeObjectId = sender.GroupId; //notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); //notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); //notice.TemplateName = NoticeTemplateNames.Instance().MemberApplyApproved(); //noticeService.Create(notice); } }
private void AuthorizeCore(AuthorizationContext filterContext) { string spaceKey = UserContext.CurrentSpaceKey(filterContext); if (string.IsNullOrEmpty(spaceKey)) throw new ExceptionFacade("spaceKey为null"); GroupService groupService = new GroupService(); GroupEntity group = groupService.Get(spaceKey); if (group == null) throw new ExceptionFacade("找不到当前群组"); IUser currentUser = UserContext.CurrentUser; //判断访问群组权限 if (!DIContainer.Resolve<Authorizer>().Group_View(group)) { if (currentUser == null) filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(true)); else { if (group.AuditStatus != AuditStatus.Success) { filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel { Title = "无权访问群组!", Body = "该群组还没有通过审核,所以不能访问!", StatusMessageType = StatusMessageType.Hint }, filterContext.HttpContext.Request.RawUrl)/* 跳向无权访问页 */); } else { filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel { Title = "无权访问群组!", Body = "你没有访问该群组的权限", StatusMessageType = StatusMessageType.Hint }, filterContext.HttpContext.Request.RawUrl)/* 跳向无权访问页 */); } } return; } //判断该用户是否有访问该群组管理页面的权限 if (!RequireManager) return; //匿名用户要求先登录跳转 if (currentUser == null) { filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(true)); return; } if (DIContainer.Resolve<Authorizer>().Group_Manage(group)) return; filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel { Title = "无权访问", Body = "您无权访问此页面,只有群主或管理员才能访问", StatusMessageType = StatusMessageType.Hint })/* 跳向无权访问页 */); }
/// <summary> /// 是否具有管理Group的权限 /// </summary> /// <param name="authorizer"></param> /// <param name="groupId"></param> /// <returns></returns> public static bool Group_Manage(this Authorizer authorizer, long groupId) { GroupEntity group = new GroupService().Get(groupId); return Group_Manage(authorizer, group); }
/// <summary> /// 通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void GroupMemberApplyNoticeModule_After(GroupMemberApply sender, CommonEventArgs eventArgs) { GroupService groupService = new GroupService(); GroupEntity entity = groupService.Get(sender.GroupId); if (entity == null) return; User senderUser = DIContainer.Resolve<IUserService>().GetFullUser(sender.UserId); if (senderUser == null) return; InvitationService invitationService = new InvitationService(); Invitation invitation; NoticeService noticeService = DIContainer.Resolve<NoticeService>(); Notice notice; if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { if (sender.ApplyStatus == GroupMemberApplyStatus.Pending) { List<long> toUserIds = new List<long>(); toUserIds.Add(entity.UserId); toUserIds.AddRange(entity.GroupManagers.Select(n => n.UserId)); foreach (var toUserId in toUserIds) { //申请加入群组的请求 if (!groupService.IsMember(sender.GroupId, sender.UserId)) { invitation = Invitation.New(); invitation.ApplicationId = GroupConfig.Instance().ApplicationId; invitation.InvitationTypeKey = InvitationTypeKeys.Instance().ApplyJoinGroup(); invitation.UserId = toUserId; invitation.SenderUserId = sender.UserId; invitation.Sender = senderUser.DisplayName; invitation.SenderUrl = SiteUrls.Instance().SpaceHome(sender.UserId); invitation.RelativeObjectId = sender.GroupId; invitation.RelativeObjectName = entity.GroupName; invitation.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); invitation.Remark = sender.ApplyReason; invitationService.Create(invitation); } } } } string noticeTemplateName = string.Empty; if (eventArgs.EventOperationType == EventOperationType.Instance().Approved()) { if (sender.ApplyStatus == GroupMemberApplyStatus.Approved) { noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyApproved(); } } else if (eventArgs.EventOperationType == EventOperationType.Instance().Disapproved()) { if (sender.ApplyStatus == GroupMemberApplyStatus.Disapproved) { noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyDisapproved(); } } if (string.IsNullOrEmpty(noticeTemplateName)) return; notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); //notice.LeadingActorUserId = UserContext.CurrentUser.UserId; //notice.LeadingActor = UserContext.CurrentUser.DisplayName; //notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(UserContext.CurrentUser.UserId)); notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); notice.TemplateName = noticeTemplateName; noticeService.Create(notice); }
void IThemeResolver.IncludeStyle(RequestContext controllerContext) { string spaceKey = controllerContext.GetParameterFromRouteDataOrQueryString("SpaceKey"); GroupEntity group = new GroupService().Get(spaceKey); if (group == null) return; PresentArea presentArea = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.GroupSpace); if (presentArea == null) return; string themeKey = null; string appearanceKey = null; IPageResourceManager resourceManager = DIContainer.ResolvePerHttpRequest<IPageResourceManager>(); if (!presentArea.EnableThemes) { string themeCssPath = string.Format("{0}/{1}/theme.css", presentArea.ThemeLocation, presentArea.DefaultThemeKey); string appearanceCssPath = string.Format("{0}/{1}/Appearances/{2}/appearance.css", presentArea.ThemeLocation, presentArea.DefaultThemeKey, presentArea.DefaultAppearanceKey); resourceManager.IncludeStyle(themeCssPath); resourceManager.IncludeStyle(appearanceCssPath); return; } if (group.IsUseCustomStyle) { var customStyleEntity = new CustomStyleService().Get(presentArea.PresentAreaKey, group.GroupId); if (customStyleEntity == null) return; CustomStyle customStyle = customStyleEntity.CustomStyle; if (customStyle == null) return; string themeCssPath = string.Format("{0}/Custom/theme{1}.css", presentArea.ThemeLocation, customStyle.IsDark ? "-deep" : ""); string appearanceCssPath = SiteUrls.Instance().CustomStyle(presentArea.PresentAreaKey, group.GroupId); resourceManager.IncludeStyle(themeCssPath); resourceManager.IncludeStyle(appearanceCssPath); StringBuilder builder = new StringBuilder(); builder.AppendLine(".tn-page-bg{"); if (customStyle.IsUseBackgroundImage && !string.IsNullOrEmpty(customStyle.BackgroundImageStyle.Url)) { builder.AppendLine("background-image:url('" + customStyle.BackgroundImageStyle.Url + @"');"); builder.AppendFormat("background-repeat:{0};\n", customStyle.BackgroundImageStyle.IsRepeat ? "repeat" : "no-repeat"); builder.AppendFormat("background-attachment:{0};\n", customStyle.BackgroundImageStyle.IsFix ? "fixed" : "scroll"); string position = "center"; switch (customStyle.BackgroundImageStyle.BackgroundPosition) { case BackgroundPosition.Left: position = "left"; break; case BackgroundPosition.Center: position = "center"; break; case BackgroundPosition.Right: position = "right"; break; default: position = "center"; break; } builder.AppendFormat("background-position:{0} top;\n", position); } builder.AppendLine("}"); resourceManager.RegisterStyleBlock(builder.ToString()); } else { string[] themeAppearanceArray = group.ThemeAppearance.Split(','); var appearance = new ThemeService().GetThemeAppearance(PresentAreaKeysOfBuiltIn.GroupSpace, group.ThemeAppearance); if (appearance != null && themeAppearanceArray.Count() == 2) { themeKey = themeAppearanceArray[0]; appearanceKey = themeAppearanceArray[1]; } else { themeKey = presentArea.DefaultThemeKey; appearanceKey = presentArea.DefaultAppearanceKey; } string themeCssPath = string.Format("{0}/{1}/theme.css", presentArea.ThemeLocation, themeKey); string appearanceCssPath = string.Format("{0}/{1}/Appearances/{2}/appearance.css", presentArea.ThemeLocation, themeKey, appearanceKey); resourceManager.IncludeStyle(themeCssPath); resourceManager.IncludeStyle(appearanceCssPath); } }
/// <summary> /// 是否拥有删除群组成员的权限 /// </summary> /// <param name="authorizer"></param> /// <param name="group"></param> /// <param name="userId">被删除的用户Id</param> /// <returns>是否拥有删除群组成员的权限</returns> public static bool Group_DeleteMember(this Authorizer authorizer, GroupEntity group, long userId) { if (group == null) return false; IUser currentUser = UserContext.CurrentUser; if (currentUser == null) return false; //群主 if (group.UserId == currentUser.UserId) return true; if (authorizer.IsAdministrator(GroupConfig.Instance().ApplicationId)) return true; GroupService groupService = new GroupService(); //群管理员 if (groupService.IsManager(group.GroupId, currentUser.UserId) && !groupService.IsManager(group.GroupId, userId)) { return true; } return false; }
/// <summary> /// 是否具有浏览群组的权限 /// </summary> /// <param name="group"></param> /// <returns></returns> public static bool Group_View(this Authorizer authorizer, GroupEntity group) { if (group == null) return false; if (group.AuditStatus == AuditStatus.Success) { if (group.IsPublic) return true; if (UserContext.CurrentUser == null) return false; if (authorizer.Group_Manage(group)) return true; GroupService groupService = new GroupService(); if (groupService.IsMember(group.GroupId, UserContext.CurrentUser.UserId)) return true; } if (authorizer.IsAdministrator(GroupConfig.Instance().ApplicationId)) return true; return false; }
/// <summary> /// 删除用户在应用中的数据 /// </summary> /// <param name="userId">用户Id</param> /// <param name="takeOverUserName">用于接管删除用户时不能删除的内容(例如:用户创建的群组)</param> /// <param name="isTakeOver">是否接管被删除用户可被接管的内容</param> protected override void DeleteUser(long userId, string takeOverUserName, bool isTakeOver) { GroupService groupService = new GroupService(); groupService.DeleteUser(userId, takeOverUserName, isTakeOver); }
/// <summary> /// 是否具有删除访客记录的权限 /// </summary> /// <param name="authorizer"></param> /// <param name="groupId"></param> /// <param name="userId"></param> /// <returns></returns> public static bool Group_DeleteVisitor(this Authorizer authorizer, long groupId, long userId) { bool result = false; GroupEntity group = new GroupService().Get(groupId); IUser currentUser = UserContext.CurrentUser; if (currentUser != null && currentUser.UserId == userId) { result = true; } else { result = Group_Manage(authorizer, group); } return result; }
/// <summary> /// 是否具有邀请好友加入群组的权限 /// </summary> /// <param name="group"></param> /// <returns></returns> public static bool Group_Invite(this Authorizer authorizer, GroupEntity group) { if (group == null) return false; if (UserContext.CurrentUser == null) return false; GroupService groupService = new GroupService(); if (authorizer.Group_Manage(group)) return true; if (group.EnableMemberInvite && groupService.IsMember(group.GroupId, UserContext.CurrentUser.UserId)) return true; return false; }
/// <summary> /// 转换成groupEntity类型 /// </summary> /// <returns></returns> public GroupEntity AsGroupEntity() { CategoryService categoryService = new CategoryService(); GroupEntity groupEntity = null; //创建群组 if (this.GroupId == 0) { groupEntity = GroupEntity.New(); groupEntity.UserId = UserContext.CurrentUser.UserId; groupEntity.DateCreated = DateTime.UtcNow; groupEntity.GroupKey = this.GroupKey; } //编辑群组 else { GroupService groupService = new GroupService(); groupEntity = groupService.Get(this.GroupId); } groupEntity.IsPublic = this.IsPublic; groupEntity.GroupName = this.GroupName; if (Logo != null) { groupEntity.Logo = this.Logo; } groupEntity.Description = Formatter.FormatMultiLinePlainTextForStorage(this.Description == null ? string.Empty : this.Description, true); groupEntity.AreaCode = this.AreaCode??string.Empty; groupEntity.JoinWay = this.JoinWay; groupEntity.EnableMemberInvite = this.EnableMemberInvite; groupEntity.IsDynamicPermission = this.IsDynamicPermission; if (JoinWay == JoinWay.ByQuestion) { groupEntity.Question = this.Question; groupEntity.Answer = this.Answer; } return groupEntity; }
void IThemeResolver.IncludeCss(RequestContext controllerContext) { string spaceKey = controllerContext.GetParameterFromRouteDataOrQueryString("SpaceKey"); GroupEntity group = new GroupService().Get(spaceKey); if (group == null) { return; } PresentArea presentArea = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.GroupSpace); if (presentArea == null) { return; } string themeKey = null; string appearanceKey = null; IPageResourceManager resourceManager = DIContainer.ResolvePerHttpRequest <IPageResourceManager>(); if (!presentArea.EnableThemes) { string themeCssPath = string.Format("{0}/{1}/theme.css", presentArea.ThemeLocation, presentArea.DefaultThemeKey); string appearanceCssPath = string.Format("{0}/{1}/Appearances/{2}/appearance.css", presentArea.ThemeLocation, presentArea.DefaultThemeKey, presentArea.DefaultAppearanceKey); resourceManager.IncludeCss(themeCssPath, renderPriority: ResourceRenderPriority.Last); resourceManager.IncludeCss(appearanceCssPath, renderPriority: ResourceRenderPriority.Last); return; } if (group.IsUseCustomStyle) { var customStyleEntity = new CustomStyleService().Get(presentArea.PresentAreaKey, group.GroupId); if (customStyleEntity == null) { return; } CustomStyle customStyle = customStyleEntity.CustomStyle; if (customStyle == null) { return; } string themeCssPath = string.Format("{0}/Custom/theme{1}.css", presentArea.ThemeLocation, customStyle.IsDark ? "-deep" : ""); string appearanceCssPath = SiteUrls.Instance().CustomStyle(presentArea.PresentAreaKey, group.GroupId); resourceManager.IncludeCss(themeCssPath, renderPriority: ResourceRenderPriority.Last); resourceManager.IncludeCss(appearanceCssPath, renderPriority: ResourceRenderPriority.Last); StringBuilder builder = new StringBuilder(); builder.AppendLine(".tn-page-bg{"); if (customStyle.IsUseBackgroundImage && !string.IsNullOrEmpty(customStyle.BackgroundImageStyle.Url)) { builder.AppendLine("background-image:url('" + customStyle.BackgroundImageStyle.Url + @"');"); builder.AppendFormat("background-repeat:{0};\n", customStyle.BackgroundImageStyle.IsRepeat ? "repeat" : "no-repeat"); builder.AppendFormat("background-attachment:{0};\n", customStyle.BackgroundImageStyle.IsFix ? "fixed" : "scroll"); string position = "center"; switch (customStyle.BackgroundImageStyle.BackgroundPosition) { case BackgroundPosition.Left: position = "left"; break; case BackgroundPosition.Center: position = "center"; break; case BackgroundPosition.Right: position = "right"; break; default: position = "center"; break; } builder.AppendFormat("background-position:{0} top;\n", position); } builder.AppendLine("}"); resourceManager.RegisterCssBlockAtHead(builder.ToString()); } else { string[] themeAppearanceArray = group.ThemeAppearance.Split(','); var appearance = new ThemeService().GetThemeAppearance(PresentAreaKeysOfBuiltIn.GroupSpace, group.ThemeAppearance); if (appearance != null && themeAppearanceArray.Count() == 2) { themeKey = themeAppearanceArray[0]; appearanceKey = themeAppearanceArray[1]; } else { themeKey = presentArea.DefaultThemeKey; appearanceKey = presentArea.DefaultAppearanceKey; } string themeCssPath = string.Format("{0}/{1}/theme.css", presentArea.ThemeLocation, themeKey); string appearanceCssPath = string.Format("{0}/{1}/Appearances/{2}/appearance.css", presentArea.ThemeLocation, themeKey, appearanceKey); resourceManager.IncludeCss(themeCssPath, renderPriority: ResourceRenderPriority.Last); resourceManager.IncludeCss(appearanceCssPath, renderPriority: ResourceRenderPriority.Last); } }