コード例 #1
0
        /// <summary>
        /// 是否具有管理友情链接的权限
        /// </summary>
        /// <param name="link">链接实体</param>
        /// <returns></returns>
        public bool Link_Manage(int ownerType, long ownerId)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }
            if (AuthorizationService.IsSuperAdministrator(currentUser))
            {
                return(true);
            }
            if (ownerType == OwnerTypes.Instance().User())
            {
                if (AuthorizationService.IsOwner(currentUser, ownerId))
                {
                    return(true);
                }
            }
            else if (ownerType == OwnerTypes.Instance().Group())
            {
                if (AuthorizationService.IsTenantManager(currentUser, TenantTypeIds.Instance().Group(), ownerId))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: LinkRepository.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 获取站点友情链接(后台管理)
        /// </summary>
        /// <param name="categoryId">分页标识</param>
        /// <param name="pageSize">分页大小</param>
        /// <param name="pageIndex">页码</param>
        /// <returns></returns>
        public IEnumerable <LinkEntity> GetsOfSiteForAdmin(long?categoryId)
        {
            Sql sql = Sql.Builder.Append("select * from spb_Links");

            if (categoryId.HasValue)
            {
                sql.InnerJoin("tn_ItemsInCategories")
                .On("spb_Links.LinkId=tn_ItemsInCategories.ItemId")
                .Where("categoryId=@0 and ownerType=@1", categoryId.Value, OwnerTypes.Instance().Site())
                .OrderBy("displayorder");
            }
            else
            {
                sql.Where("ownerType=@0", OwnerTypes.Instance().Site())
                .OrderBy("displayorder");
            }

            return(GetPagingEntities(1000, 1, sql));
        }