Exemplo n.º 1
0
        public ActionResult ManageThreads(ManageThreadEditModel model, int pageIndex = 1, string tenantTypeId = null)
        {
            if (string.IsNullOrEmpty(tenantTypeId))
            {
                tenantTypeId = TenantTypeIds.Instance().Bar();
            }

            pageResourceManager.InsertTitlePart("帖子管理");



            List <SelectListItem> SelectListItem_TrueAndFlase = new List <SelectListItem> {
                new SelectListItem {
                    Text = "是", Value = true.ToString()
                }, new SelectListItem {
                    Text = "否", Value = false.ToString()
                }
            };

            ViewData["IsEssential"] = new SelectList(SelectListItem_TrueAndFlase, "Value", "Text", model.IsEssential);
            ViewData["IsSticky"]    = new SelectList(SelectListItem_TrueAndFlase, "Value", "Text", model.IsSticky);

            ViewData["BarThreads"] = barThreadService.Gets(tenantTypeId, model.GetBarThreadQuery(), model.PageSize ?? 20, pageIndex);

            ViewData["TenantType"] = tenantTypeService.Get(tenantTypeId);

            return(View(model));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 重建缩略图
        /// </summary>
        /// <returns></returns>
        public ActionResult RebuildingThumbnails()
        {
            IEnumerable <TenantAttachmentSettings> tenantAttachmentSettings = TenantAttachmentSettings.GetAll();

            ViewData["TenantAttachmentSettings"] = tenantAttachmentSettings;
            ViewData["TenantLogoSettings"]       = TenantLogoSettings.GetAll();

            IStoreProvider storeProvider = DIContainer.Resolve <IStoreProvider>();
            string         rootPath      = WebUtility.GetPhysicalFilePath("~");
            string         uploadsPath   = storeProvider.StoreRootPath;

            if (storeProvider.StoreRootPath.StartsWith(rootPath))
            {
                uploadsPath = uploadsPath.Replace(rootPath, "");
            }
            ViewData["uploadsPath"] = uploadsPath;
            Dictionary <string, string> ApplicationName = new Dictionary <string, string>();

            TenantTypeService        tenantTypeService = new TenantTypeService();
            IEnumerable <TenantType> tenantTypes       = tenantTypeService.Gets(null, null);

            foreach (var item in tenantTypes)
            {
                TenantType type = tenantTypeService.Get(item.TenantTypeId);
                ApplicationName[item.TenantTypeId] = type != null ? type.Name : item.Name;
            }

            ViewData["ApplicationName"] = ApplicationName;

            return(View());
        }
Exemplo n.º 3
0
        /// <summary>
        /// 是否具有编辑友情链接的权限
        /// </summary>
        /// <param name="link">链接实体</param>
        /// <returns></returns>
        public bool Link_Edit(LinkEntity link)
        {
            IUser      currentUser = UserContext.CurrentUser;
            TenantType tenantType  = tenantTypeService.Get(TenantTypeIds.Instance().Link());

            if (currentUser == null)
            {
                return(false);
            }
            if (AuthorizationService.IsSuperAdministrator(currentUser))
            {
                return(true);
            }
            if (AuthorizationService.IsTenantManager(currentUser, tenantType.TenantTypeId, link.OwnerId))
            {
                return(true);
            }
            if (link.OwnerType == OwnerTypes.Instance().User())
            {
                if (AuthorizationService.IsOwner(currentUser, link.OwnerId))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 是否具有管理推荐内容的权限
        /// </summary>
        /// <returns></returns>
        public bool RecommendItem_Manage(string tenantTypeId)
        {
            IUser currentUser = UserContext.CurrentUser;

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

            TenantTypeService tenantTypeService = new TenantTypeService();
            TenantType        tenantType        = tenantTypeService.Get(tenantTypeId);

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

            if (IsAdministrator(tenantType.ApplicationId))
            {
                return(true);
            }

            if (currentUser.IsInRoles("ContentAdministrator"))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 是否具有删除分类的权限
        /// </summary>
        /// <returns></returns>
        public bool Category_Delete(Category category)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }
            TenantTypeService tenantTypeService = new TenantTypeService();
            TenantType        tenantType        = tenantTypeService.Get(category.TenantTypeId);

            if (tenantType == null)
            {
                return(false);
            }
            if (IsAdministrator(tenantType.ApplicationId))
            {
                return(true);
            }
            if (AuthorizationService.IsTenantManager(currentUser, category.TenantTypeId, category.OwnerId))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 是否具有编辑标签的权限
        /// </summary>
        /// <returns></returns>
        public bool Tag_Edit(Tag tag)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }
            TenantTypeService tenantTypeService = new TenantTypeService();
            TenantType        tenantType        = tenantTypeService.Get(tag.TenantTypeId);

            if (tenantType == null)
            {
                return(false);
            }
            if (IsAdministrator(tenantType.ApplicationId))
            {
                return(true);
            }
            if (AuthorizationService.IsTenantManager(currentUser, tag.TenantTypeId, tag.OwnerId))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 是否具有编辑附件的权限
        /// </summary>
        /// <returns></returns>
        public bool Attachment_Edit(Attachment attachment)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }
            TenantTypeService tenantTypeService = new TenantTypeService();
            TenantType        tenantType        = tenantTypeService.Get(attachment.TenantTypeId);

            if (tenantType == null)
            {
                return(false);
            }
            if (IsAdministrator(tenantType.ApplicationId))
            {
                return(true);
            }
            if (AuthorizationService.IsOwner(currentUser, attachment.UserId))
            {
                return(true);
            }
            if (AuthorizationService.IsTenantManager(currentUser, attachment.TenantTypeId, attachment.OwnerId))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 推荐积分处理
        /// </summary>
        /// <param name="sender">推荐实体</param>
        /// <param name="eventArgs">事件参数</param>
        void RecommendPointModule_After(RecommendItem sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType != EventOperationType.Instance().Create())
            {
                return;
            }
            string            pointItemKey      = string.Empty;
            PointService      pointService      = new PointService();
            string            description       = string.Empty;
            TenantTypeService tenantTypeService = new TenantTypeService();

            var urlGetter = RecommendUrlGetterFactory.Get(sender.TenantTypeId);

            NoticeService noticeService = new NoticeService();
            Notice        notice        = Notice.New();

            notice.TypeId = NoticeTypeIds.Instance().Hint();

            //notice.TemplateName = "FollowUser";
            notice.UserId             = sender.UserId;
            notice.LeadingActorUserId = sender.ReferrerId;
            notice.LeadingActor       = sender.ReferrerName;
            notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.ReferrerId));
            notice.RelativeObjectId   = sender.UserId;
            notice.RelativeObjectName = sender.ItemName;
            notice.RelativeObjectUrl  = sender.DetailUrl;

            if (sender.TenantTypeId == TenantTypeIds.Instance().User())
            {
                pointItemKey        = PointItemKeys.Instance().RecommendUser();
                description         = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendUser"));
                notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommendedUser();
            }
            else
            {
                pointItemKey = PointItemKeys.Instance().RecommendContent();
                TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId);
                if (tenantType == null)
                {
                    return;
                }
                description         = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendContent"), tenantType.Name, sender.ItemName);
                notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommended();
            }

            noticeService.Create(notice);
            pointService.GenerateByRole(sender.UserId, pointItemKey, description);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 是否有权限查看评论
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public bool Comment_Show(Comment comment)
        {
            if (!comment.IsPrivate)
            {
                return(true);
            }
            IUser currentUser = UserContext.CurrentUser;

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

            if (comment.OwnerId == currentUser.UserId && comment.ParentId == 0)
            {
                return(true);
            }

            if (comment.ToUserId != 0 && comment.ToUserId == currentUser.UserId)
            {
                return(true);
            }
            if (comment.UserId == currentUser.UserId)
            {
                return(true);
            }
            TenantTypeService tenantTypeService = new TenantTypeService();
            TenantType        tenantType        = tenantTypeService.Get(comment.TenantTypeId);

            if (tenantType == null)
            {
                return(false);
            }
            if (IsAdministrator(tenantType.ApplicationId))
            {
                return(true);
            }
            if (AuthorizationService.IsTenantManager(currentUser, comment.TenantTypeId, comment.OwnerId))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 资讯操作日志事件处理
        /// </summary>
        private void RecommendOperationLogEventModule_After(RecommendItem sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create() ||
                eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                TenantTypeService tenantTypeService = new TenantTypeService();
                TenantType        tenantType        = tenantTypeService.Get(sender.TenantTypeId);
                if (tenantType == null)
                {
                    return;
                }

                OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);
                entry.ApplicationId       = tenantType.ApplicationId;
                entry.Source              = tenantType.Name;
                entry.OperationType       = eventArgs.EventOperationType;
                entry.OperationObjectName = sender.ItemName;
                entry.OperationObjectId   = sender.ItemId;
                entry.Description         = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType), tenantType.Name + "推荐", entry.OperationObjectName);

                OperationLogService logService = Tunynet.DIContainer.Resolve <OperationLogService>();
                logService.Create(entry);
            }
        }
Exemplo n.º 11
0
        public ActionResult _RecommendItem(string tenantTypeId, long itemId = 0, string itemName = null, string recommendItemTypeId = null, bool showLink = false, long recommendId = 0, bool showInList = true, long userId = 0)
        {
            RecommendItem recommendItem = null;

            if (recommendId > 0)
            {
                recommendItem = recommendService.Get(recommendId);
                if (recommendItem == null)
                {
                    return(HttpNotFound());
                }
                tenantTypeId                  = recommendItem.TenantTypeId;
                itemId                        = recommendItem.ItemId;
                recommendItemTypeId           = recommendItem.TypeId;
                ViewData["RecommendTypeName"] = recommendItem.RecommendItemType.Name;
                ViewData["RecommendTypeId"]   = recommendItem.TypeId;
            }
            if (!authorizer.RecommendItem_Manage(tenantTypeId))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Body = "没有管理推荐内容的权限",
                    Title = "没有权限",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }
            IEnumerable <RecommendItemType> itemTypes      = recommendService.GetRecommendTypes(tenantTypeId);
            IEnumerable <RecommendItem>     recommendItems = recommendService.Gets(itemId, tenantTypeId);

            //已修改
            RecommendItemEditModel itemEditModel = new RecommendItemEditModel();

            ViewData["recommendItems"] = recommendItems;

            //已修改
            ViewData["TypeId"] = new SelectList(itemTypes, "TypeId", "Name", recommendItemTypeId);
            if (recommendId != 0)
            {
                itemEditModel = recommendItem.AsEditModel();
                ViewData["HasFeaturedImage"] = recommendItem.RecommendItemType.HasFeaturedImage;
            }
            else
            {
                if (itemTypes != null && itemTypes.Count() > 0 && string.IsNullOrEmpty(recommendItemTypeId))
                {
                    //已修改
                    recommendItemTypeId = itemTypes.First().TypeId;
                }
                if (!string.IsNullOrEmpty(recommendItemTypeId))
                {
                    recommendItem = recommendService.Get(itemId, recommendItemTypeId);
                    RecommendItemType recommendType = recommendService.GetRecommendType(recommendItemTypeId);
                    ViewData["HasFeaturedImage"]  = recommendType.HasFeaturedImage;
                    ViewData["RecommendTypeName"] = recommendType.Name;
                    ViewData["RecommendTypeId"]   = recommendType.TypeId;
                    if (recommendItem != null && !recommendItem.IsLink)
                    {
                        ViewData["ExpiredDate"] = recommendItem.ExpiredDate;
                        itemEditModel           = recommendItem.AsEditModel();
                    }
                    else
                    {
                        RecommendItem newItem = RecommendItem.New();
                        newItem.ItemName     = itemName;
                        newItem.ItemId       = itemId;
                        newItem.TenantTypeId = tenantTypeId;
                        newItem.ExpiredDate  = DateTime.UtcNow.AddMonths(1);
                        newItem.UserId       = userId;
                        itemEditModel        = newItem.AsEditModel();
                    }
                }

                else
                {
                    StatusMessageData message           = null;
                    TenantTypeService tenantTypeService = new TenantTypeService();
                    TenantType        tenantType        = tenantTypeService.Get(tenantTypeId);

                    if (tenantType == null)
                    {
                        message = new StatusMessageData(StatusMessageType.Hint, "没有推荐类别");
                    }
                    else
                    {
                        message = new StatusMessageData(StatusMessageType.Hint, tenantType.Name + "下没有推荐类别");
                    }
                    ViewData["statusMessageData"] = message;
                }
            }
            ViewData["showLink"]   = showLink || itemEditModel.IsLink;
            ViewData["showInList"] = showInList;
            return(View(itemEditModel));
        }