Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
        void WebsiteAdmin_OnAdminRequest(AdminInterface admin, HandleFlag handled)
        {
            if (SprocketPath.Sections[0] != "admin")
            {
                return;
            }

            switch (SprocketPath.Value)
            {
            case "admin/dbsetup":
                Result result = DatabaseManager.DatabaseEngine.Initialise();
                if (result.Succeeded)
                {
                    admin.AddContentSection(new RankedString("<p style=\"color:green\" class=\"standalone-message\">Database setup completed.</p>", 1));
                }
                else
                {
                    admin.AddContentSection(new RankedString("<strong style=\"color:red\" class=\"standalone-message\">Unable to Initialise Database</strong><p>" + result.Message + "</p>", 1));
                }
                break;

            case "admin/clearcache":
                ContentCache.ClearCache();
                admin.AddContentSection(new RankedString("<p style=\"color:green\" class=\"standalone-message\">The cache has been cleared.</p>", 1));
                break;

            case "admin":
                break;

            default:
                return;
            }

            admin.ContentHeading = "Current Overview";
            admin.AddContentSection(new RankedString("<div class=\"standalone-message\">" +
                                                     "<a href=\"" + WebUtility.BasePath + "admin/dbsetup\">Run database setup</a> | " +
                                                     "<a href=\"" + WebUtility.BasePath + "admin/clearcache\">Clear page cache</a>" +
                                                     "</div>", 0));
            handled.Set();
        }
        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();
        }
Ejemplo n.º 4
0
        void OnAdminRequest(AdminInterface admin, string sprocketPath, string[] pathSections, HandleFlag handled)
        {
            // build the "current user" block
            User user = User.Select(SecurityProvider.ClientSpaceID, WebAuthentication.Instance.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 = CurrentClientSpace.Name;

            if (!SecurityProvider.CurrentUser.HasPermission(PermissionType.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.Security.CMS.security.js")
                    .Replace("50,//{defaultMaxFilterMatches}", defaultMaxFilterMatches.ToString() + ",")
                    .Replace("if(true)//{ifUserCanAccessRoleManagement}",
                        SecurityProvider.CurrentUser.HasPermission(PermissionType.RoleAdministrator) ? "" : "if(false)");
                admin.AddInterfaceScript(new RankedString(scr, 0));
                admin.AddBodyOnLoadScript(new RankedString("SecurityInterface.Run()", 0));

                admin.ContentHeading = "Users and Roles";

                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 WebsiteAdmin_OnAdminRequest(AdminInterface admin, HandleFlag handled)
		{
			if (SprocketPath.Sections[0] != "admin") return;

			switch (SprocketPath.Value)
			{
				case "admin/dbsetup":
					Result result = DatabaseManager.DatabaseEngine.Initialise();
					if (result.Succeeded)
						admin.AddContentSection(new RankedString("<p style=\"color:green\" class=\"standalone-message\">Database setup completed.</p>", 1));
					else
						admin.AddContentSection(new RankedString("<strong style=\"color:red\" class=\"standalone-message\">Unable to Initialise Database</strong><p>" + result.Message + "</p>", 1));
					break;

				case "admin/clearcache":
					ContentCache.ClearCache();
					admin.AddContentSection(new RankedString("<p style=\"color:green\" class=\"standalone-message\">The cache has been cleared.</p>", 1));
					break;

				case "admin":
					break;

				default:
					return;
			}

			admin.ContentHeading = "Current Overview";
			admin.AddContentSection(new RankedString("<div class=\"standalone-message\">" +
				"<a href=\"" + WebUtility.BasePath + "admin/dbsetup\">Run database setup</a> | " +
				"<a href=\"" + WebUtility.BasePath + "admin/clearcache\">Clear page cache</a>" +
				"</div>", 0));
			handled.Set();
		}
Ejemplo n.º 6
0
 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();
 }