本文整理汇总了C#中IUser.HasSpecialEditPermissions方法的典型用法代码示例。如果您正苦于以下问题:C# IUser.HasSpecialEditPermissions方法的具体用法?C# IUser.HasSpecialEditPermissions怎么用?C# IUser.HasSpecialEditPermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUser
的用法示例。
在下文中一共展示了IUser.HasSpecialEditPermissions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModerateArticle
/// <summary>
/// Checks to see if the article needs to be placed in the moderation system
/// </summary>
/// <param name="articleOwner">The user who owns the article.</param>
/// <param name="site">The site that the article was created in</param>
/// <param name="h2g2ID">The h2g2id of the article you want to moderate</param>
/// <param name="profanitiesFound">A flag that states whether or not a profanity was found</param>
/// <returns>True if the article was placed in the moderation queue, False if not</returns>
public bool ModerateArticle(IUser articleOwner, ISite site, int h2g2ID, bool profanitiesFound)
{
// Check to see if the user is immune from moderation
if (!articleOwner.HasSpecialEditPermissions(h2g2ID))
{
// Now do some simple checks on the site and user
bool siteModerated = (int)site.ModerationStatus > 1;
bool userModerated = articleOwner.IsPreModerated;
bool userInSinBin = articleOwner.IsAutoSinBin;
bool articleModerated = IsArticleModerated(h2g2ID);
// If anything came back as being moderated, then queue the article for moderation
if (siteModerated || userInSinBin || userModerated || articleModerated || profanitiesFound)
{
// Queue the article for moderation
using (IDnaDataReader reader = _appContext.CreateDnaDataReader("QueueArticleForModeration"))
{
// Check to see what triggered the moderation
int triggerID = (int)ModerationTriggers.Automatic;
if (profanitiesFound)
{
triggerID = (int)ModerationTriggers.Profanities;
}
// Create the notes for the moderation decision
string notes = "Created/Edited by user U" + articleOwner.UserID.ToString();
// Add the article to the queue
reader.AddParameter("h2g2ID", h2g2ID);
reader.AddParameter("TriggerID", triggerID);
reader.AddParameter("TriggeredBy", articleOwner.UserID);
reader.AddParameter("Notes", notes);
reader.AddIntOutputParameter("ModID");
reader.Execute();
while (reader.Read()) { }
// Get the new mod id for the article
int modID = 0;
reader.TryGetIntOutputParameter("ModeID", out modID);
}
// Article was moderated
return true;
}
}
// Article was not moderated
return false;
}
示例2: HasEditPermission
/// <summary>
/// Checks to see if a user has edit permissions for the current guide entry
/// </summary>
/// <param name="user">The user you want to check against</param>
/// <returns>True if they are able to edit, false if not</returns>
public bool HasEditPermission(IUser user)
{
// Check to see if we've got special permissions
bool editable = user.HasSpecialEditPermissions(_h2g2ID);
// Make sure the h2g2id is valid
if (!editable && ValidateH2G2ID())
{
// Guide Entry is editable if it is a valid article, the user is the same as the
// editor, and the status of the entry is either 2, 3, 4, or 7 => i.e. it is a
// user entry that is private or public, or is awaiting consideration or has been
// deleted
// only give editors edit permission on all entries on the admin version
// give moderators edit permission if they have entry locked for moderation
if (Status == 1 && user.IsGuardian)
{
editable = true;
}
// If the user is the editor of the entry and the status is correct, then they can edit
if (AuthorsUserID == user.UserID)
{
if ((Status > 1 && Status < 5) || Status == 7)
{
editable = true;
}
}
}
return editable;
}