本文整理汇总了C#中umbraco.BusinessLogic.User.IsAdmin方法的典型用法代码示例。如果您正苦于以下问题:C# User.IsAdmin方法的具体用法?C# User.IsAdmin怎么用?C# User.IsAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.BusinessLogic.User
的用法示例。
在下文中一共展示了User.IsAdmin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
int UID = int.Parse(Request.QueryString["id"]);
u = BusinessLogic.User.GetUser(UID);
// do initial check for edit rights
if (u.Id == 0 && CurrentUser.Id != 0)
{
throw new Exception("Only the root user can edit the 'root' user (id:0)");
}
else if (u.IsAdmin() && !CurrentUser.IsAdmin())
{
throw new Exception("Admin users can only be edited by admins");
}
// check if canvas editing is enabled
DefaultToLiveEditing.Visible = UmbracoSettings.EnableCanvasEditing;
// Populate usertype list
foreach (UserType ut in UserType.getAll)
{
if (CurrentUser.IsAdmin() || ut.Alias != "admin")
{
ListItem li = new ListItem(ui.Text("user", ut.Name.ToLower(), base.getUser()), ut.Id.ToString());
if (ut.Id == u.UserType.Id)
li.Selected = true;
userType.Items.Add(li);
}
}
// Populate ui language lsit
foreach (
string f in
Directory.GetFiles(IOHelper.MapPath(SystemDirectories.Umbraco + "/config/lang"), "*.xml")
)
{
XmlDocument x = new XmlDocument();
x.Load(f);
ListItem li =
new ListItem(x.DocumentElement.Attributes.GetNamedItem("intName").Value,
x.DocumentElement.Attributes.GetNamedItem("alias").Value);
if (x.DocumentElement.Attributes.GetNamedItem("alias").Value == u.Language)
li.Selected = true;
userLanguage.Items.Add(li);
}
// Console access and disabling
NoConsole.Checked = u.NoConsole;
Disabled.Checked = u.Disabled;
DefaultToLiveEditing.Checked = u.DefaultToLiveEditing;
PlaceHolder medias = new PlaceHolder();
mediaPicker.AppAlias = "media";
mediaPicker.TreeAlias = "media";
if (u.StartMediaId > 0)
mediaPicker.Value = u.StartMediaId.ToString();
else
mediaPicker.Value = "-1";
medias.Controls.Add(mediaPicker);
PlaceHolder content = new PlaceHolder();
contentPicker.AppAlias = "content";
contentPicker.TreeAlias = "content";
if (u.StartNodeId > 0)
contentPicker.Value = u.StartNodeId.ToString();
else
contentPicker.Value = "-1";
content.Controls.Add(contentPicker);
// Add password changer
passw.Controls.Add(new UserControl().LoadControl(SystemDirectories.Umbraco + "/controls/passwordChanger.ascx"));
pp.addProperty(ui.Text("user", "username", base.getUser()), uname);
pp.addProperty(ui.Text("user", "loginname", base.getUser()), lname);
pp.addProperty(ui.Text("user", "password", base.getUser()), passw);
pp.addProperty(ui.Text("email", base.getUser()), email);
pp.addProperty(ui.Text("user", "usertype", base.getUser()), userType);
pp.addProperty(ui.Text("user", "language", base.getUser()), userLanguage);
//Media / content root nodes
Pane ppNodes = new Pane();
ppNodes.addProperty(ui.Text("user", "startnode", base.getUser()), content);
ppNodes.addProperty(ui.Text("user", "mediastartnode", base.getUser()), medias);
//Generel umrbaco access
Pane ppAccess = new Pane();
if (UmbracoSettings.EnableCanvasEditing)
{
ppAccess.addProperty(ui.Text("user", "defaultToLiveEditing", base.getUser()), DefaultToLiveEditing);
}
ppAccess.addProperty(ui.Text("user", "noConsole", base.getUser()), NoConsole);
ppAccess.addProperty(ui.Text("user", "disabled", base.getUser()), Disabled);
//.........这里部分代码省略.........
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
int UID = int.Parse(Request.QueryString["id"]);
u = BusinessLogic.User.GetUser(UID);
//the true admin can only edit the true admin
if (u.Id == 0 && CurrentUser.Id != 0)
{
throw new Exception("Only the root user can edit the 'root' user (id:0)");
}
//only another admin can edit another admin (who is not the true admin)
if (u.IsAdmin() && CurrentUser.IsAdmin() == false)
{
throw new Exception("Admin users can only be edited by admins");
}
// Populate usertype list
foreach (UserType ut in UserType.getAll)
{
if (CurrentUser.IsAdmin() || ut.Alias != "admin")
{
ListItem li = new ListItem(ui.Text("user", ut.Name.ToLower(), UmbracoUser), ut.Id.ToString());
if (ut.Id == u.UserType.Id)
li.Selected = true;
userType.Items.Add(li);
}
}
// Populate ui language lsit
foreach (
string f in
Directory.GetFiles(IOHelper.MapPath(SystemDirectories.Umbraco + "/config/lang"), "*.xml")
)
{
XmlDocument x = new XmlDocument();
x.Load(f);
ListItem li =
new ListItem(x.DocumentElement.Attributes.GetNamedItem("intName").Value,
x.DocumentElement.Attributes.GetNamedItem("alias").Value);
if (x.DocumentElement.Attributes.GetNamedItem("alias").Value == u.Language)
li.Selected = true;
userLanguage.Items.Add(li);
}
// Console access and disabling
NoConsole.Checked = u.NoConsole;
Disabled.Checked = u.Disabled;
PlaceHolder medias = new PlaceHolder();
mediaPicker.AppAlias = Constants.Applications.Media;
mediaPicker.TreeAlias = "media";
if (u.StartMediaId > 0)
mediaPicker.Value = u.StartMediaId.ToString();
else
mediaPicker.Value = "-1";
medias.Controls.Add(mediaPicker);
PlaceHolder content = new PlaceHolder();
contentPicker.AppAlias = Constants.Applications.Content;
contentPicker.TreeAlias = "content";
if (u.StartNodeId > 0)
contentPicker.Value = u.StartNodeId.ToString();
else
contentPicker.Value = "-1";
content.Controls.Add(contentPicker);
// Add password changer
var passwordChanger = (passwordChanger) LoadControl(SystemDirectories.Umbraco + "/controls/passwordChanger.ascx");
passwordChanger.MembershipProviderName = UmbracoSettings.DefaultBackofficeProvider;
//This is a hack to allow the admin to change a user's password to whatever they want - this will only work if we are using the
// default umbraco membership provider.
// See the notes below in the ChangePassword method.
if (BackOfficeProvider is UsersMembershipProvider)
{
passwordChanger.ShowOldPassword = false;
}
//Add a custom validation message for the password changer
var passwordValidation = new CustomValidator
{
ID = "PasswordChangerValidator"
};
var validatorContainer = new HtmlGenericControl("div")
{
Visible = false,
EnableViewState = false
};
validatorContainer.Attributes["class"] = "alert alert-error";
validatorContainer.Style.Add(HtmlTextWriterStyle.MarginTop, "10px");
validatorContainer.Style.Add(HtmlTextWriterStyle.Width, "300px");
//.........这里部分代码省略.........
示例3: AppendUser
/// <summary>
/// Appends the user to the XML document.
/// </summary>
/// <param name="xd">The XML document.</param>
/// <param name="user">The user.</param>
internal static void AppendUser(XmlDocument xd, User user)
{
var node = XmlHelper.AddTextNode(xd, "User", string.Empty);
node.Attributes.Append(XmlHelper.AddAttribute(xd, "id", user.Id.ToString()));
node.Attributes.Append(XmlHelper.AddAttribute(xd, "name", user.Name));
node.Attributes.Append(XmlHelper.AddAttribute(xd, "loginName", user.LoginName));
node.Attributes.Append(XmlHelper.AddAttribute(xd, "email", user.Email));
node.Attributes.Append(XmlHelper.AddAttribute(xd, "language", user.Language));
node.Attributes.Append(XmlHelper.AddAttribute(xd, "userTypeAlias", user.UserType.Alias));
node.Attributes.Append(XmlHelper.AddAttribute(xd, "isAdmin", user.IsAdmin().ToString()));
node.Attributes.Append(XmlHelper.AddAttribute(xd, "startNodeId", user.StartNodeId.ToString()));
node.Attributes.Append(XmlHelper.AddAttribute(xd, "startMediaId", user.StartMediaId.ToString()));
// add the user node to the XmlDocument.
if (xd.DocumentElement != null)
{
xd.DocumentElement.AppendChild(node);
}
else
{
xd.AppendChild(node);
}
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//set the user and check access
SimpleFormsCore.Authorize();
currentUser = umbraco.BusinessLogic.User.GetCurrent();
userCanPublish = currentUser.GetPermissions(formDocument.Path).Contains('R');
//handle any postbacks
if (Page.IsPostBack)
{
HandlePostback();
}
//get the form schema
formSchema = new FormSchema(template.Alias);
h2 = new HtmlGenericControl("h2");
h2.InnerHtml = "<a class='formFields' href='#'>" + t("Form Fields") + "</a>";
if (currentUser.IsAdmin())
{
settings.Controls.Add(h2);
BuildFieldTable();
}
formIDBox.Text = formSchema.ID.ToString();
formName.Text = formSchema.Name;
BuildDocumentButtons();
//update the url
string niceurl = umbraco.library.NiceUrl(formDocument.Id);
string url = "<a target='_blank' href='" + niceurl + "'>" + niceurl + "</a>";
urlTD.InnerHtml = url;
BuildSubmissionsUI();
BuildSubmissionsTable();
}