void TestBox_OnAdminRequest(AdminInterface admin, string sprocketPath, string[] pathSections, HandleFlag handled) { //admin.AddMainMenuLink(new AdminMenuLink("Test Box", WebUtility.MakePath("admin/testbox"), 1000)); if (sprocketPath != "admin/testbox") return; handled.Set(); admin.AddInterfaceScript(new RankedString(ResourceLoader.LoadTextResource(typeof(AjaxForm).Assembly, "Sprocket.Web.Controls.AjaxForm.js"), 0)); admin.AddHeadSection(new RankedString(CSS, 0)); admin.ContentHeading = "Test Box"; admin.AddContentSection(new RankedString("blah", -1000)); AjaxFormFieldBlock b = new AjaxFormFieldBlock("UserDetails", "Main User Details"); b.Add(new AjaxFormStandardField( "Username", "Username", "<input type=\"text\" id=\"Username\" />", null, "function(value) { return value.length == 0 ? 'Please enter a username' : false }", true, 1)); b.Add(new AjaxFormStandardField("First Name", "FirstName", "<input type=\"text\" />", null, "", true, 0)); AjaxFormFieldBlock b2 = new AjaxFormFieldBlock("RandomCrap", "Random Crap"); b2.Add(new AjaxFormField("stuff", null, null, -1)); AjaxFormFieldBlockList bl = new AjaxFormFieldBlockList(); bl.Add(b); bl.Add(b2); admin.AddContentSection(new RankedString(bl, 1001)); }
void OnAdminRequest(AdminInterface admin, string sprocketPath, string[] pathSections, HandleFlag handled) { // build the "current user" block WebAuthentication auth = (WebAuthentication)Core.Instance["WebAuthentication"]; SecurityProvider.User user = SecurityProvider.User.Load(WebsiteClientID, auth.CurrentUsername); string block = "<div id=\"currentuser-block\">" + "You are currently logged in as <b>{0}</b>." + "</div>"; admin.AddLeftColumnSection(new RankedString( string.Format(block, (user.FirstName + " " + user.Surname).Trim()), -100)); admin.WebsiteName = WebsiteClient.Name; if (!CurrentUser.HasPermission(SecurityProvider.PermissionTypeCodes.UserAdministrator)) { return; } admin.AddMainMenuLink(new AdminMenuLink("Users and Roles", WebUtility.MakeFullPath("admin/security"), 0)); // build the security interface if it has been requested if (sprocketPath.StartsWith("admin/security")) { handled.Set(); int defaultMaxFilterMatches; try { defaultMaxFilterMatches = int.Parse(SprocketSettings.GetValue("WebSecurityDefaultUserFilterMatches")); } catch { defaultMaxFilterMatches = 50; } admin.AddInterfaceScript(WebControlScript.TabStrip); admin.AddInterfaceScript(WebControlScript.Fader); admin.AddInterfaceScript(WebControlScript.AjaxForm); string scr = ResourceLoader.LoadTextResource("Sprocket.Web.CMS.Security.security.js") .Replace("50,//{defaultMaxFilterMatches}", defaultMaxFilterMatches.ToString() + ",") .Replace("if(true)//{ifUserCanAccessRoleManagement}", CurrentUser.HasPermission("ROLEADMINISTRATOR") ? "" : "if(false)"); admin.AddInterfaceScript(new RankedString(scr, 0)); admin.AddBodyOnLoadScript(new RankedString("SecurityInterface.Run()", 0)); admin.ContentHeading = "Users and Roles"; SecurityProvider security = (SecurityProvider)Core.Instance["SecurityProvider"]; string html = "<div id=\"user-admin-container\"></div>"; admin.AddContentSection(new RankedString(html, 0)); admin.AddHeadSection(new RankedString("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + WebUtility.MakeFullPath("resources/admin/security.css") + "\" />", 0)); } }
void OnAdminRequest(AdminInterface admin, string sprocketPath, string[] pathSections, HandleFlag handled) { admin.AddMainMenuLink(new AdminMenuLink("Website Pages", WebUtility.MakeFullPath("admin/pages"), 0)); if (handled.Handled) { return; } switch (sprocketPath) { case "admin/pages": admin.ContentHeading = "Website Page List"; admin.AddContentSection(new RankedString(GetPageList(), 0)); break; default: return; } handled.Set(); }
void WebsiteAdmin_OnAdminRequest(AdminInterface admin, string sprocketPath, string[] pathSections, HandleFlag handled) { if (sprocketPath != "admin") return; admin.ContentHeading = "Current Overview"; admin.AddContentSection(new RankedString("<div class=\"standalone-message\">Overview information under construction.</div>", 0)); handled.Set(); }
void OnAdminRequest(AdminInterface admin, string sprocketPath, string[] pathSections, HandleFlag handled) { // build the "current user" block WebAuthentication auth = (WebAuthentication)SystemCore.Instance["WebAuthentication"]; SecurityProvider.User user = SecurityProvider.User.Load(WebsiteClientID, auth.CurrentUsername); string block = "<div id=\"currentuser-block\">" + "You are currently logged in as <b>{0}</b>." + "</div>"; admin.AddLeftColumnSection(new RankedString( string.Format(block, (user.FirstName + " " + user.Surname).Trim()), -100)); admin.WebsiteName = WebsiteClient.Name; if (!CurrentUser.HasPermission(SecurityProvider.PermissionTypeCodes.UserAdministrator)) return; admin.AddMainMenuLink(new AdminMenuLink("Users and Roles", WebUtility.MakeFullPath("admin/security"), 0)); // build the security interface if it has been requested if (sprocketPath.StartsWith("admin/security")) { handled.Set(); int defaultMaxFilterMatches; try { defaultMaxFilterMatches = int.Parse(SprocketSettings.GetValue("WebSecurityDefaultUserFilterMatches")); } catch { defaultMaxFilterMatches = 50; } admin.AddInterfaceScript(WebControlScript.TabStrip); admin.AddInterfaceScript(WebControlScript.Fader); admin.AddInterfaceScript(WebControlScript.AjaxForm); string scr = ResourceLoader.LoadTextResource("Sprocket.Web.CMS.Security.security.js") .Replace("50,//{defaultMaxFilterMatches}", defaultMaxFilterMatches.ToString() + ",") .Replace("if(true)//{ifUserCanAccessRoleManagement}", CurrentUser.HasPermission("ROLEADMINISTRATOR") ? "" : "if(false)"); admin.AddInterfaceScript(new RankedString(scr, 0)); admin.AddBodyOnLoadScript(new RankedString("SecurityInterface.Run()", 0)); admin.ContentHeading = "Users and Roles"; SecurityProvider security = (SecurityProvider)SystemCore.Instance["SecurityProvider"]; string html = "<div id=\"user-admin-container\"></div>"; admin.AddContentSection(new RankedString(html, 0)); admin.AddHeadSection(new RankedString("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + WebUtility.MakeFullPath("resources/admin/security.css") + "\" />", 0)); } }