Esempio n. 1
0
        /// <summary>
        /// 管理栏目
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="folder">栏目</param>
        public static bool CMS_ManageContentFolder(this Authorizer authorizer, ContentFolder folder)
        {
            IUser currentUser = UserContext.CurrentUser;

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

            if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
            {
                return(true);
            }

            if (folder.Moderators.Any(n => n.UserId == currentUser.UserId))
            {
                return(true);
            }

            if (folder.Parents.Any(n => n.Moderators != null && n.Moderators.Any(m => m.UserId == currentUser.UserId)))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
 /// <summary>
 /// 发布内容项
 /// </summary>
 /// <param name="folder">栏目</param>
 /// <param name="authorizer"></param>
 public static bool CMS_CreateContentItem(this Authorizer authorizer, ContentFolder folder)
 {
     if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
     {
         return(true);
     }
     return(authorizer.CMS_ManageContentFolder(folder));
 }
Esempio n. 3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="name">Searcher名称</param>
 /// <param name="indexPath">索引文件所在路径(支持"~/"及unc路径)</param>
 /// <param name="asQuickSearch">是否作为快捷搜索</param>
 /// <param name="displayOrder">显示顺序</param>
 public CmsSearcher(string name, string indexPath, bool asQuickSearch, int displayOrder)
 {
     this.Name           = name;
     this.IndexPath      = Tunynet.Utilities.WebUtility.GetPhysicalFilePath(indexPath);
     this.AsQuickSearch  = asQuickSearch;
     this.DisplayOrder   = displayOrder;
     searchEngine        = SearcherFactory.GetSearchEngine(indexPath);
     publiclyAuditStatus = auditService.GetPubliclyAuditStatus(CmsConfig.Instance().ApplicationId);
 }
Esempio n. 4
0
        /// <summary>
        /// 刪除附件
        /// </summary>
        public static bool CMS_DeleteContentAttachment(this Authorizer authorizer, ContentAttachment contentItem)
        {
            IUser currentUser = UserContext.CurrentUser;

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

            if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
            {
                return(true);
            }

            if (currentUser.UserId == contentItem.UserId)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        /// <summary>
        /// 是否具有前台管理资讯的权限
        /// </summary>
        /// <param name="authorizer"></param>
        /// <returns></returns>
        public static bool CMS_ManageContentItemsForChannel(this Authorizer authorizer)
        {
            IUser currentUser = UserContext.CurrentUser;

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

            if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
            {
                return(true);
            }
            ContentFolderModeratorService contentFolderModeratorService = new ContentFolderModeratorService();
            var folderIds = contentFolderModeratorService.GetModeratedFolderIds(currentUser.UserId);

            if (folderIds.Count() > 0)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
        /// <summary>
        /// 编辑内容项
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="contentItem"></param>
        public static bool CMS_EditContentItem(this Authorizer authorizer, ContentItem contentItem)
        {
            if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
            {
                return(true);
            }

            if (authorizer.CMS_ManageContentFolder(contentItem.ContentFolder))
            {
                return(true);
            }
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }
            if (contentItem.AuditStatus != AuditStatus.Success && contentItem.UserId == currentUser.UserId)
            {
                return(true);
            }
            return(false);
        }