本文整理汇总了C#中Article.HasEditPermission方法的典型用法代码示例。如果您正苦于以下问题:C# Article.HasEditPermission方法的具体用法?C# Article.HasEditPermission怎么用?C# Article.HasEditPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article.HasEditPermission方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveArticle
private Article SaveArticle(ISite site, CallingUser callingUser, Article article, string siteName, bool isNewArticle, int h2g2Id)
{
// Check: does user have edit permission
if ((!isNewArticle) && !article.HasEditPermission(callingUser))
{
throw new DnaWebProtocolException(ApiException.GetError(ErrorType.UserDoesNotHavePermissionToEditArticle));
}
// Check: profanities
bool moderateProfanities = false;
string matchingProfanity;
List<Term> terms = null;
CheckForProfanities(site, article.Subject + " " + article.GuideMLAsString, out moderateProfanities, out matchingProfanity, out terms);
// Check: url filter
if ((siteList.GetSiteOptionValueBool(site.SiteID, "General", "IsURLFiltered")) && !((callingUser.IsUserA(UserTypes.Editor) || callingUser.IsUserA(UserTypes.Notable))))
{
List<string> nonAllowedMatches = new List<string>();
UrlFilter urlFilter = new UrlFilter();
UrlFilter.FilterState result = urlFilter.CheckForURLs(article.Subject + " " + article.GuideMLAsString, nonAllowedMatches, site.SiteID, readerCreator);
if (result == UrlFilter.FilterState.Fail)
{
throw new DnaWebProtocolException(ApiException.GetError(ErrorType.ArticleContainsURLs));
}
}
// Check: email filter
if ((siteList.GetSiteOptionValueBool(site.SiteID, "Forum", "EmailAddressFilter")) && !((callingUser.IsUserA(UserTypes.Editor) || callingUser.IsUserA(UserTypes.Notable))))
{
if (EmailAddressFilter.CheckForEmailAddresses(article.Subject + " " + article.GuideMLAsString))
{
throw new DnaWebProtocolException(ApiException.GetError(ErrorType.ArticleContainsEmailAddress));
}
}
if (isNewArticle)
{
article.CreateNewArticle(cacheManager, readerCreator, callingUser.UserID, site.SiteID);
//Users subscribed to this author should have their subscribed content updated.
callingUser.UpdateUserSubscriptions(readerCreator, article.H2g2Id);
}
else // existing article
{
//Don't overwrite the existing editor of the article
int editorId = 0;
try
{
editorId = article.ArticleInfo.PageAuthor.Editor.user.UserId;
if (editorId == 0)
{
editorId = callingUser.UserID;
}
}
catch
{
editorId = callingUser.UserID;
}
article.UpdateArticle(cacheManager, readerCreator, editorId);
}
// set the archive status
if (callingUser.IsUserA(UserTypes.Editor))
{
article.SetArticleForumArchiveStatus(readerCreator, false);
}
// moderate isUserImmuneFromModeration needed
bool isSiteModerated = !(site.ModerationStatus == BBC.Dna.Moderation.Utils.ModerationStatus.SiteStatus.UnMod);
bool isUserModerated = (callingUser.IsPreModerated || callingUser.IsPostModerated);
bool isArticleModerated = ((article.ArticleInfo.ModerationStatus == BBC.Dna.Moderation.Utils.ModerationStatus.ArticleStatus.PreMod) || article.ArticleInfo.ModerationStatus == BBC.Dna.Moderation.Utils.ModerationStatus.ArticleStatus.PostMod);
bool isArticleInModeration = article.IsArticleIsInModeration(readerCreator);
bool isUserInSinbin = (callingUser.IsAutoSinBin == 1);
bool isUserImmuneFromModeration = callingUser.HasSpecialEditPermissions(article.H2g2Id);
// Queue, update moderation status and hide the guide entry.
int modID = 0;
if (!isUserImmuneFromModeration)
{
if (isSiteModerated || isUserModerated || isArticleModerated || isArticleInModeration || moderateProfanities || isUserInSinbin)
{
if (!String.IsNullOrEmpty(matchingProfanity)) { matchingProfanity = "Profanities: " + matchingProfanity; }
article.QueueForModeration(readerCreator, matchingProfanity, ref modID);
}
}
if (article.HiddenStatus == (int)BBC.Dna.Moderation.Utils.CommentStatus.Hidden.NotHidden)
{
//visible
article.UnhideArticle(readerCreator, 0, 0, callingUser.UserID);
}
else
{
//.........这里部分代码省略.........
示例2: GetPageUi
static public PageUi GetPageUi(IDnaDataReaderCreator creator, Article guide, BBC.Dna.Objects.User viewingUser)
{
PageUi pageUi = new PageUi(viewingUser.UserId);
// Update the edit link if the user is allowed
bool editable = false;
string editableLink = "/UserEdit";
if (!guide.IsDeleted && guide.HasEditPermission(viewingUser))
{
editable = true;
editableLink += guide.H2g2Id.ToString();
}
// Now set the recommended link
string recommendLink = "RecommendEntry?h2g2ID=" + guide.H2g2Id.ToString() + "&mode=POPUP";
bool recommendable = guide.ArticleInfo.Status.Type == 3 &&
viewingUser.UserId > 0 &&
(viewingUser.IsEditor || viewingUser.IsScout);
// If this is a sub editors copy of a recommended entry, and the viewer is
// the sub editor, then give them a button to say they have finished subbing
// it and want to return the entry to the editors
string subbedLink = "SubmitSubbedEntry?h2g2ID=" + guide.ArticleInfo.H2g2Id.ToString() + "&mode=POPUP";
bool subeditor = viewingUser.UserId > 0 &&
(viewingUser.IsEditor || viewingUser.IsSubEditor) &&
guide.CheckIsSubEditor(viewingUser, creator);
// Setup the discuss UI
string discussLink = "AddThread?forum=" + guide.ArticleInfo.ForumId.ToString() + "&article=" + guide.ArticleInfo.H2g2Id.ToString();
bool discussable = !guide.IsDeleted &&
guide.ArticleInfo.ForumId > 0 &&
viewingUser.UserId > 0;
pageUi.EditPage = new PageUiElement(editableLink, editable);
pageUi.RecommendEntry = new PageUiElement(recommendLink, recommendable);
pageUi.EntrySubbed = new PageUiElement(subbedLink, subeditor);
pageUi.Discuss = new PageUiElement(discussLink, discussable);
pageUi.SiteHome = new PageUiElement("/", true);
pageUi.DontPanic = new PageUiElement("/DONTPANIC", true);
pageUi.Search = new PageUiElement("/Search", true);
return pageUi;
}