private static string Tabs_HTML_Helper(string SkinCode, Search_Type_Enum Search_Type, string Display_Text, SobekCM_Navigation_Object Current_Mode, bool Downward_Tabs) { if (Downward_Tabs) { if ((Current_Mode.Mode == Display_Mode_Enum.Search) && (Current_Mode.Search_Type == Search_Type)) { return("<img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cLD_s.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab_s\"> " + Display_Text + " </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cRD_s.gif\" border=\"0\" class=\"tab_image\" alt=\"\" />" + Environment.NewLine); } Search_Type_Enum currentSearchType = Current_Mode.Search_Type; Display_Mode_Enum currentMode = Current_Mode.Mode; Current_Mode.Search_Type = Search_Type; Current_Mode.Mode = Display_Mode_Enum.Search; string toReturn = "<a href=\"" + Current_Mode.Redirect_URL() + "\"> " + "<img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cLD.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab\"> " + Display_Text + " </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cRD.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /></a>" + Environment.NewLine; Current_Mode.Search_Type = currentSearchType; Current_Mode.Mode = currentMode; return(toReturn); } if ((Current_Mode.Mode == Display_Mode_Enum.Search) && (Current_Mode.Search_Type == Search_Type)) { return("<img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cL_s.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab_s\"> " + Display_Text + " </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cR_s.gif\" border=\"0\" class=\"tab_image\" alt=\"\" />" + Environment.NewLine); } // else... Search_Type_Enum currentSearchType2 = Current_Mode.Search_Type; Display_Mode_Enum currentMode2 = Current_Mode.Mode; Current_Mode.Search_Type = Search_Type; Current_Mode.Mode = Display_Mode_Enum.Search; string toReturn2 = "<a href=\"" + Current_Mode.Redirect_URL() + "\"> <img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cL.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab\"> " + Display_Text + " </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cR.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /> </a>" + Environment.NewLine; Current_Mode.Search_Type = currentSearchType2; Current_Mode.Mode = currentMode2; return(toReturn2); }
private static string Menu_HTML_Helper(string SkinCode, Search_Type_Enum Search_Type, string Display_Text, SobekCM_Navigation_Object Current_Mode) { if (Current_Mode.Is_Robot) { if ((Current_Mode.Mode == Display_Mode_Enum.Search) && (Current_Mode.Search_Type == Search_Type)) { return("<li class=\"selected-sf-menu-item-link\"><a href=\"\">" + Display_Text + "</a></li>" + Environment.NewLine); } else { return("<li><a href=\"\">" + Display_Text + "</a></li>" + Environment.NewLine); } } if ((Current_Mode.Mode == Display_Mode_Enum.Search) && (Current_Mode.Search_Type == Search_Type)) { return("<li class=\"selected-sf-menu-item-link\"><a href=\"" + Current_Mode.Redirect_URL() + "\">" + Display_Text + "</a></li>" + Environment.NewLine); } // else... Search_Type_Enum currentSearchType2 = Current_Mode.Search_Type; Display_Mode_Enum currentMode2 = Current_Mode.Mode; Current_Mode.Search_Type = Search_Type; Current_Mode.Mode = Display_Mode_Enum.Search; string toReturn2 = "<li><a href=\"" + Current_Mode.Redirect_URL() + "\">" + Display_Text + "</a></li>" + Environment.NewLine; Current_Mode.Search_Type = currentSearchType2; Current_Mode.Mode = currentMode2; return(toReturn2); }
/// <summary> Constructor for a new instance of the Web_Content_HtmlSubwriter class </summary> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Static_Web_Content"> Object contains all the basic information about this info display </param> /// <param name="Site_Map"> Optional site map object used to render a navigational tree-view on left side of page</param> public Web_Content_HtmlSubwriter(Item_Aggregation Hierarchy_Object, SobekCM_Navigation_Object Current_Mode, SobekCM_Skin_Object HTML_Skin, HTML_Based_Content Static_Web_Content, SobekCM_SiteMap Site_Map) { base.Hierarchy_Object = Hierarchy_Object; currentMode = Current_Mode; Skin = HTML_Skin; thisStaticBrowseObject = Static_Web_Content; siteMap = Site_Map; // If there is a sitemap, check if this is a robot request and then if the URL // for the sitemap pages is URL restricted if ((siteMap != null) && (siteMap.Is_URL_Restricted_For_Robots) && (currentMode.Is_Robot)) { if (currentMode.Base_URL != siteMap.Restricted_Robot_URL) { currentMode.Base_URL = siteMap.Restricted_Robot_URL; string redirect_url = currentMode.Redirect_URL(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Status = "301 Moved Permanently"; HttpContext.Current.Response.AddHeader("Location", redirect_url); HttpContext.Current.Response.End(); } } }
/// <summary> Constructor for a new instance of the Search object </summary> /// <param name="currentMode"> Current navigation object to save the modal information ( interface, etc..)</param> /// <param name="SessionIP"> IP address which performed this search</param> /// <param name="Search_Type"> Type of search </param> /// <param name="Aggregation"> Aggregation against which this search was performed</param> /// <param name="Search_Terms"> Terms used in the search </param> public Search(SobekCM_Navigation_Object currentMode, string SessionIP, Search_Type_Enum Search_Type, string Aggregation, string Search_Terms) { Time = DateTime.Now.ToShortDateString().Replace("/", "-") + " " + DateTime.Now.ToShortTimeString().Replace(" ", ""); // Save some of the values this.SessionIP = SessionIP; switch (Search_Type) { case Search_Type_Enum.Advanced: this.Search_Type = "Advanced"; break; case Search_Type_Enum.Basic: this.Search_Type = "Basic"; break; case Search_Type_Enum.Newspaper: this.Search_Type = "Newspaper"; break; case Search_Type_Enum.Map: this.Search_Type = "Map"; break; default: this.Search_Type = "Unknown"; break; } // Create the key Key = SessionIP + "_" + this.Search_Type + "_" + Aggregation + "_" + Search_Terms.Replace(" ", "_"); // Save the collection as a link Display_Mode_Enum lastMode = currentMode.Mode; currentMode.Mode = Display_Mode_Enum.Aggregation; currentMode.Aggregation_Type = Aggregation_Type_Enum.Home; this.Aggregation = "<a href=\"" + currentMode.Redirect_URL() + "\">" + Aggregation.Replace("&", "&").Replace("\"", """) + "</a>"; // Save the search terms as a link to the search currentMode.Mode = lastMode; this.Search_Terms = "<a href=\"" + currentMode.Redirect_URL() + "\">" + Search_Terms.Replace("&", "&").Replace("\"", """) + "</a>"; }
private static string HTML_Helper_PageView(string interface_code, string Viewer_Code, string Display_Text, SobekCM_Navigation_Object Current_Mode) { string previousViewerCode = Current_Mode.ViewerCode; Current_Mode.ViewerCode = Viewer_Code; string returnValue = "<a href=\"" + Current_Mode.Redirect_URL() + "\">" + Display_Text + "</a>"; Current_Mode.ViewerCode = previousViewerCode; return(returnValue); }
/// <summary> Constructor for a new instance of the Home_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode">Mode / navigation information for the current request</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Home_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Home_AdminViewer.Constructor", String.Empty); if ((User == null) || ((!User.Is_Portal_Admin) && (!User.Is_System_Admin))) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL(), false); } }
private static string HTML_Helper(string interface_code, string Viewer_Code, string Display_Text, SobekCM_Navigation_Object Current_Mode) { if (Current_Mode.ViewerCode == Viewer_Code) { return("<li id=\"selected-sf-menu-item\">" + Display_Text + "</li>"); } // When rendering for robots, provide the text and image, but not the text if (Current_Mode.Is_Robot) { return("<li class=\"selected-sf-menu-item\">" + Display_Text + "</li>"); } string previousViewerCode = Current_Mode.ViewerCode; Current_Mode.ViewerCode = Viewer_Code; string returnValue = "<li><a href=\"" + Current_Mode.Redirect_URL() + "\">" + Display_Text + "</a></li>"; Current_Mode.ViewerCode = previousViewerCode; return(returnValue); }
/// <summary> Constructor for a new instance of the Preferences_HtmlSubwriter class </summary> public Preferences_HtmlSubwriter(SobekCM_Navigation_Object Current_Mode) { currentMode = Current_Mode; // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["hidden_request"] ?? String.Empty; if (hidden_request == "submit") { NameValueCollection form = HttpContext.Current.Request.Form; string language_option = form["languageDropDown"]; switch (language_option) { case "en": currentMode.Language = Web_Language_Enum.English; break; case "fr": currentMode.Language = Web_Language_Enum.French; break; case "es": currentMode.Language = Web_Language_Enum.Spanish; break; } string defaultViewDropDown = form["defaultViewDropDown"]; HttpContext.Current.Session["User_Default_View"] = defaultViewDropDown; int user_sort = Convert.ToInt32(form["defaultSortDropDown"]); HttpContext.Current.Session["User_Default_Sort"] = user_sort; currentMode.Mode = Display_Mode_Enum.Aggregation_Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), false); } }
/// <summary> Constructor for a new instance of the Builder_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> public Builder_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode) : base(User) { currentMode = Current_Mode; // Ensure the user is the system admin if ((User == null) || (!User.Is_System_Admin)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL(), false); } // If this is a postback, handle any events first if (Current_Mode.isPostBack) { // Pull the hidden value string save_value = HttpContext.Current.Request.Form["admin_builder_tosave"].ToUpper().Trim(); if (save_value.Length > 0) { // Set this value SobekCM_Database.Set_Setting("Builder Operation Flag", save_value); } } }
/// <summary> Constructor for a new instance of the Thematic_Headings_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new thematic heading is handled here in the constructor </remarks> public Thematic_Headings_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, List <Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Thematic_Headings_AdminViewer.Constructor", String.Empty); // Get the current list of thematic headings thematicHeadings = Thematic_Headings; // Save the mode currentMode = Current_Mode; // Set action message to nothing to start actionMessage = String.Empty; // If the user cannot edit this, go back if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Handle any post backs if (currentMode.isPostBack) { try { // Pull the standard values from the form NameValueCollection form = HttpContext.Current.Request.Form; string save_value = form["admin_heading_tosave"]; string action_value = form["admin_heading_action"]; // Switch, depending on the request if (action_value != null) { switch (action_value.Trim().ToLower()) { case "edit": string new_name = form["form_heading_name"]; if (new_name != null) { int id = Convert.ToInt32(save_value); int order = 1 + Thematic_Headings.TakeWhile(thisHeading => thisHeading.ThematicHeadingID != id).Count(); if (SobekCM_Database.Edit_Thematic_Heading(id, order, new_name, Tracer) < 1) { actionMessage = "Unable to edit existing thematic heading"; } else { // For thread safety, lock the thematic headings list lock (Thematic_Headings) { // Repopulate the thematic headings list SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer); } actionMessage = "Thematic heading edits saved"; } } break; case "delete": int thematicDeleteId = Convert.ToInt32(save_value); if (!SobekCM_Database.Delete_Thematic_Heading(thematicDeleteId, Tracer)) { // Set action message actionMessage = "Unable to delete existing thematic heading"; } else { // For thread safety, lock the thematic headings list lock (Thematic_Headings) { // Remove this thematic heading from the list int i = 0; while (i < Thematic_Headings.Count) { if (Thematic_Headings[i].ThematicHeadingID == thematicDeleteId) { Thematic_Headings.RemoveAt(i); } else { i++; } } } // Set action message actionMessage = "Thematic heading deleted"; } break; case "new": int new_order = Thematic_Headings.Count + 1; if (SobekCM_Database.Edit_Thematic_Heading(-1, new_order, save_value, Tracer) < 1) { actionMessage = "Unable to save new thematic heading"; } else { // For thread safety, lock the thematic headings list lock (Thematic_Headings) { // Repopulate the thematic headings list SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer); } actionMessage = "New thematic heading saved"; } break; case "moveup": string[] moveup_split = save_value.Split(",".ToCharArray()); int moveup_id = Convert.ToInt32(moveup_split[0]); int moveup_order = Convert.ToInt32(moveup_split[1]); if (moveup_order > 1) { Thematic_Heading themeHeading = Thematic_Headings[moveup_order - 1]; if (themeHeading.ThematicHeadingID == moveup_id) { // For thread safety, lock the thematic headings list lock (Thematic_Headings) { // Move this thematic heading up Thematic_Headings.Remove(themeHeading); Thematic_Headings.Insert(moveup_order - 2, themeHeading); int current_order = 1; foreach (Thematic_Heading thisTheme in Thematic_Headings) { SobekCM_Database.Edit_Thematic_Heading(thisTheme.ThematicHeadingID, current_order, thisTheme.ThemeName, Tracer); current_order++; } // Repopulate the thematic headings list SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer); } } } break; case "movedown": string[] movedown_split = save_value.Split(",".ToCharArray()); int movedown_id = Convert.ToInt32(movedown_split[0]); int movedown_order = Convert.ToInt32(movedown_split[1]); if (movedown_order < Thematic_Headings.Count) { Thematic_Heading themeHeading = Thematic_Headings[movedown_order - 1]; if (themeHeading.ThematicHeadingID == movedown_id) { // For thread safety, lock the thematic headings list lock (Thematic_Headings) { // Move this thematic heading down Thematic_Headings.Remove(themeHeading); Thematic_Headings.Insert(movedown_order, themeHeading); int current_order = 1; foreach (Thematic_Heading thisTheme in Thematic_Headings) { SobekCM_Database.Edit_Thematic_Heading(thisTheme.ThematicHeadingID, current_order, thisTheme.ThemeName, Tracer); current_order++; } // Repopulate the thematic headings list SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer); } } } break; } } } catch (Exception) { actionMessage = "Unknown error caught while handling your reqeust"; } } }
/// <summary> Constructor for a new instance of the Mass_Update_Items_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Mass_Update_Items_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; // Since this is a mass update, just create a new empty item with the GroupID included // from the provided item SobekCM_Item emptyItem = new SobekCM_Item { BibID = Current_Item.BibID }; emptyItem.Web.GroupID = Current_Item.Web.GroupID; emptyItem.Bib_Info.Source.Code = String.Empty; emptyItem.Behaviors.CheckOut_Required_Is_Null = true; emptyItem.Behaviors.IP_Restriction_Membership_Is_Null = true; emptyItem.Behaviors.Dark_Flag_Is_Null = true; item = emptyItem; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(Current_Item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } const string TEMPLATE_CODE = "massupdate"; template = Cached_Data_Manager.Retrieve_Template(TEMPLATE_CODE, Tracer); if (template != null) { Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + TEMPLATE_CODE + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(TEMPLATE_CODE, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } else if (hidden_request == "save") { // Save these changes to bib template.Save_To_Bib(item, user, 1); // Save the behaviors SobekCM_Database.Save_Behaviors(item, false, true); // Store on the caches (to replace the other) Cached_Data_Manager.Remove_Digital_Resource_Objects(item.BibID, Tracer); // Forward currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } }
/// <summary> Constructor for a new instance of the Skins_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="currentMode"> Mode / navigation information for the current request</param> /// <param name="Web_Skin_Collection"> Contains the collection of all the default skins and the data to create any additional skins on request</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new html skin is handled here in the constructor </remarks> public Skins_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, SobekCM_Skin_Collection Web_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Skins_AdminViewer.Constructor", String.Empty); // Save the mode and settings here base.currentMode = currentMode; skinCollection = Web_Skin_Collection; // Set action message to nothing to start actionMessage = String.Empty; // If the user cannot edit this, go back if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // If this is a postback, handle any events first if (currentMode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; string reset_value = form["admin_interface_reset"].ToLower(); string save_value = form["admin_interface_tosave"].ToUpper().Trim(); string new_interface_code = form["admin_interface_code"].ToUpper().Trim(); // Was this a reset request? if (reset_value.Length > 0) { Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Reset html skin '" + reset_value + "'"); if (Web_Skin_Collection.Remove(reset_value)) { actionMessage = "Removed skin <i>" + reset_value.ToUpper() + "</i> from the semi-permanent skin collection"; } else { int values_cleared = Cached_Data_Manager.Remove_Skin(reset_value, Tracer); if (values_cleared == 0) { actionMessage = "Html skin <i>" + reset_value.ToUpper() + "</i> was not in the application cache"; } else { actionMessage = "Removed " + values_cleared + " values from the cache for <i>" + reset_value.ToUpper() + "</i>"; } } } else { // Or.. was this a save request if (save_value.Length > 0) { Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Save html skin '" + save_value + "'"); bool override_banner = false; bool override_header = false; bool build_on_launch = false; bool suppress_top_nav = false; bool copycurrent = false; object temp_object; // Was this to save a new interface (from the main page) or edit an existing (from the popup form)? if (save_value == new_interface_code) { string new_base_code = form["admin_interface_basecode"].ToUpper().Trim(); string new_banner_link = form["admin_interface_link"].Trim(); string new_notes = form["admin_interface_notes"].Trim(); temp_object = form["admin_interface_banner_override"]; if (temp_object != null) { override_banner = true; } temp_object = form["admin_interface_header_override"]; if (temp_object != null) { override_header = true; } temp_object = form["admin_interface_buildlaunch"]; if (temp_object != null) { build_on_launch = true; } temp_object = form["admin_interface_top_nav"]; if (temp_object != null) { suppress_top_nav = true; } temp_object = form["admin_interface_copycurrent"]; if (temp_object != null) { copycurrent = true; } // Save this new interface if (SobekCM_Database.Save_Web_Skin(save_value, new_base_code, override_banner, override_header, new_banner_link, new_notes, build_on_launch, suppress_top_nav, Tracer)) { // Ensure a folder exists for this, otherwise create one try { string folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + save_value.ToLower(); if (!Directory.Exists(folder)) { // Create this directory and the necessary subdirectories Directory.CreateDirectory(folder); // Create a default stylesheet StreamWriter writer = new StreamWriter(folder + "\\" + save_value.ToLower() + ".css"); writer.WriteLine("/* Skin-specific stylesheet used to override values from the base stylesheets */"); writer.WriteLine(); writer.WriteLine(); writer.Flush(); writer.Close(); // Create the html subdirectory Directory.CreateDirectory(folder + "/html"); // Do the rest differently depending on whether we should copy the current files if (!copycurrent) { // Write the default header file writer = new StreamWriter(folder + "\\html\\header.html"); writer.WriteLine("<div id=\"container-inner\">"); writer.WriteLine(); writer.WriteLine("<!-- Add the standard header buttons -->"); writer.WriteLine("<div style=\"width: 100%; background-color: #eeeeee; color: Black; height:30px;\">"); writer.WriteLine("<%BREADCRUMBS%>"); writer.WriteLine("<div style=\"float: right\"><%MYSOBEK%></div>"); writer.WriteLine("</div>"); writer.WriteLine(); writer.WriteLine("<%BANNER%>"); writer.WriteLine(); writer.WriteLine("<div id=\"pagecontainer\">"); writer.WriteLine(); writer.WriteLine("<!-- Blankets out the rest of the web form when a pop-up form is envoked -->"); writer.WriteLine("<div id=\"blanket_outer\" style=\"display:none;\"></div>"); writer.Flush(); writer.Close(); // Write the default header_item file writer = new StreamWriter(folder + "/html/header_item.html"); writer.WriteLine("<!-- Blankets out the rest of the web form when a pop-up form is envoked -->"); writer.WriteLine("<div id=\"blanket_outer\" style=\"display:none;\"></div>"); writer.WriteLine(); writer.WriteLine("<!-- Add the standard header buttons -->"); writer.WriteLine("<div style=\"width: 100%; background-color: #eeeeee; color: Black; height:30px;\">"); writer.WriteLine("<%BREADCRUMBS%>"); writer.WriteLine("<div style=\"float: right\"><%MYSOBEK%></div>"); writer.WriteLine("</div>"); writer.WriteLine(); writer.WriteLine("<%BANNER%>"); writer.Flush(); writer.Close(); // Write the default footer file writer = new StreamWriter(folder + "/html/footer.html"); writer.WriteLine("</div> <!-- END PAGE CONTAINER DIV -->"); writer.WriteLine(); writer.WriteLine("<!-- Add most the standard footer buttons -->"); writer.WriteLine("<center>"); writer.WriteLine("<a href=\"<%BASEURL%>contact<%?URLOPTS%>\">Contact Us</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>preferences<%?URLOPTS%>\">Preferences</a> | "); writer.WriteLine("<a href=\"http://ufdc.ufl.edu/sobekcm\">Technical Aspects</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>stats<%?URLOPTS%>\">Statistics</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>internal<%?URLOPTS%>\">Internal</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>admin<%?URLOPTS%>\">Admin</a>"); writer.WriteLine("</center>"); writer.WriteLine("<br />"); writer.WriteLine("<br />"); writer.WriteLine("<span style=\"color: Gray; font-size: 0.8em;\">"); writer.WriteLine("To edit this footer or header, edit header.html or footer.html at: " + folder + "\\html\\ <br />"); writer.WriteLine("</span>"); writer.WriteLine(); writer.WriteLine("</div> <!-- END CONTAINER INNER -->"); writer.Flush(); writer.Close(); // Write the default footer item file writer = new StreamWriter(folder + "/html/footer_item.html"); writer.WriteLine("<!-- Add most the standard footer buttons -->"); writer.WriteLine("<center>"); writer.WriteLine("<a href=\"<%BASEURL%>contact<%?URLOPTS%>\">Contact Us</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>preferences<%?URLOPTS%>\">Preferences</a> | "); writer.WriteLine("<a href=\"http://ufdc.ufl.edu/sobekcm\">Technical Aspects</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>stats<%?URLOPTS%>\">Statistics</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>internal<%?URLOPTS%>\">Internal</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>admin<%?URLOPTS%>\">Admin</a>"); writer.WriteLine("</center>"); writer.WriteLine("<br />"); writer.WriteLine("<br />"); writer.WriteLine("<span style=\"color: Gray; font-size: 0.8em;\">"); writer.WriteLine("To edit this footer or header, edit header.html or footer.html at: " + folder + "\\html\\ <br />"); writer.WriteLine("</span>"); writer.Flush(); writer.Close(); } else { // Copy the web skin information over? string current_web_skin = currentMode.Skin; string current_web_folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + current_web_skin; copy_entire_folder(current_web_folder, folder); //if (File.Exists(current_web_folder + "\\" + current_web_skin + ".css")) //{ // File.Copy(current_web_folder + "\\" + current_web_skin + ".css", folder + "\\" + new_interface_code + ".css", true ); //} //if (File.Exists(current_web_folder + "\\html\\header.html")) //{ // File.Copy(current_web_folder + "\\html\\header.html", folder + "\\html\\header.html"); //} //if (File.Exists(current_web_folder + "\\html\\header_item.html")) //{ // File.Copy(current_web_folder + "\\html\\header_item.html", folder + "\\html\\header_item.html"); //} //if (File.Exists(current_web_folder + "\\html\\footer.html")) //{ // File.Copy(current_web_folder + "\\html\\footer.html", folder + "\\html\\footer.html"); //} //if (File.Exists(current_web_folder + "\\html\\footer_item.html")) //{ // File.Copy(current_web_folder + "\\html\\footer_item.html", folder + "\\html\\footer_item.html"); //} if (File.Exists(folder + "\\" + current_web_skin + ".css")) { if (File.Exists(folder + "\\" + new_interface_code + ".css")) { File.Delete(folder + "\\" + new_interface_code + ".css"); } File.Move(folder + "\\" + current_web_skin + ".css", folder + "\\" + new_interface_code + ".css"); } } // Irregardless of the user's choice on whether to copy the current skin, if there is NO base skin // provided and the folder does not exist, then we'll copy over the base skin type of stuff, such // as buttons, tabs, etc... if (new_base_code.Length == 0) { // What is the current base skin folder then? string base_skin_folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + currentMode.Base_Skin; copy_entire_folder(base_skin_folder + "/buttons", folder + "/buttons"); copy_entire_folder(base_skin_folder + "/tabs", folder + "/tabs"); copy_entire_folder(base_skin_folder + "/zoom_controls", folder + "/zoom_controls"); } } } catch (Exception ee) { bool error = false; } // Reload the list of all skins from the database, to include this new skin lock (skinCollection) { SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinCollection, Tracer); } actionMessage = "Saved new html skin <i>" + save_value + "</i>"; } else { actionMessage = "Unable to save new html skin <i>" + save_value + "</i>"; } // Try to create the directory try { if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value)) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value); } if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\html")) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\html"); } if (new_base_code.Length == 0) { if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\buttons")) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\buttons"); } if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\tabs")) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\tabs"); } if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls")) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls"); } } } catch (Exception) { actionMessage = "Error creating all the necessary folders"; } } else { string edit_base_code = form["form_interface_basecode"].ToUpper().Trim(); string edit_banner_link = form["form_interface_link"].Trim(); string edit_notes = form["form_interface_notes"].Trim(); temp_object = form["form_interface_banner_override"]; if (temp_object != null) { override_banner = true; } temp_object = form["form_interface_header_override"]; if (temp_object != null) { override_header = true; } temp_object = form["form_interface_buildlaunch"]; if (temp_object != null) { build_on_launch = true; } temp_object = form["form_interface_top_nav"]; if (temp_object != null) { suppress_top_nav = true; } // Save this existing interface if (SobekCM_Database.Save_Web_Skin(save_value, edit_base_code, override_banner, override_header, edit_banner_link, edit_notes, build_on_launch, suppress_top_nav, Tracer)) { lock (skinCollection) { SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinCollection, Tracer); } Cached_Data_Manager.Remove_Skin(save_value, Tracer); actionMessage = "Edited existing html skin <i>" + save_value + "</i>"; } else { actionMessage = "Unable to edit existing html skin <i>" + save_value + "</i>"; } } } } } catch (Exception) { actionMessage = "Unknown error caught while handing your request."; } } }
/// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Item_Metadata_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Skin_Collection HTML_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; popUpFormsHtml = String.Empty; delayed_popup = String.Empty; base.Translator = Translator; skins = HTML_Skin_Collection; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Is this a project isProject = item.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project; string template_code = user.Edit_Template_Code; if ((isProject) || (item.Contains_Complex_Content) || (item.Using_Complex_Template)) { template_code = user.Edit_Template_MARC_Code; } template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\edit\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // Get the current page number, or default to 1 page = 1; if (currentMode.My_Sobek_SubMode.Length > 0) { if ((currentMode.My_Sobek_SubMode == "preview") || (currentMode.My_Sobek_SubMode == "marc") || (currentMode.My_Sobek_SubMode == "mets")) { page = 0; } else { page = 1; bool isNumber = currentMode.My_Sobek_SubMode.All(Char.IsNumber); if (isNumber) { if (isProject) { Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } else { Double.TryParse(currentMode.My_Sobek_SubMode, out page); } } else if (isProject) { if (Char.IsNumber(currentMode.My_Sobek_SubMode[0])) { Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } } } } // Handle post backs if (Current_Mode.isPostBack) { // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["new_element_requested"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { if (isProject) { Cached_Data_Manager.Remove_Project(user.UserID, item.BibID, null); currentMode.Mode = Display_Mode_Enum.Administrative; currentMode.Admin_Type = Admin_Type_Enum.Default_Metadata; currentMode.My_Sobek_SubMode = String.Empty; currentMode.Redirect(); } else { Cached_Data_Manager.Remove_Digital_Resource_Object(user.UserID, item.BibID, item.VID, null); currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } return; } // Save these changes to bib template.Save_To_Bib(item, user, ((int)page)); // See if the user asked for a new element of a complex form type delayed_popup = String.Empty; switch (hidden_request.Trim()) { case "name": delayed_popup = "name"; item.Bib_Info.Add_Named_Entity(String.Empty).Name_Type = Name_Info_Type_Enum.personal; break; case "title": delayed_popup = "title"; item.Bib_Info.Add_Other_Title(String.Empty, Title_Type_Enum.alternative); break; case "subject": delayed_popup = "subject"; item.Bib_Info.Add_Subject(); break; case "spatial": delayed_popup = "spatial"; item.Bib_Info.Add_Hierarchical_Geographic_Subject(); break; case "relateditem": delayed_popup = "relateditem"; item.Bib_Info.Add_Related_Item(new Related_Item_Info()); break; case "save": Complete_Item_Save(); break; case "complicate": item.Using_Complex_Template = true; HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; return; case "simplify": item.Using_Complex_Template = false; HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; return; } // Was this for a new page? if (hidden_request.IndexOf("newpage") == 0) { string page_requested = hidden_request.Replace("newpage", ""); if (page_requested != currentMode.My_Sobek_SubMode) { // forward to requested page currentMode.My_Sobek_SubMode = page_requested; if (currentMode.My_Sobek_SubMode == "0") { currentMode.My_Sobek_SubMode = "preview"; } if (isProject) { currentMode.My_Sobek_SubMode = page_requested + item.BibID; } HttpContext.Current.Response.Redirect(currentMode.Redirect_URL() + "#template", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; } } } }
/// <summary> Constructor for a new instance of the Aggregations_Mgmt_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="currentMode"> Mode / navigation information for the current request</param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks> public Aggregations_Mgmt_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Aggregations_Mgmt_AdminViewer.Constructor", String.Empty); codeManager = Code_Manager; // Set some defaults actionMessage = String.Empty; enteredCode = String.Empty; enteredParent = String.Empty; enteredType = String.Empty; enteredShortname = String.Empty; enteredName = String.Empty; enteredDescription = String.Empty; enteredIsActive = false; enteredIsHidden = false; // If the user cannot edit this, go back if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // If this is a postback, handle any events first if (currentMode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; string save_value = form["admin_aggr_tosave"].ToUpper().Trim(); string new_aggregation_code = String.Empty; if (form["admin_aggr_code"] != null) { new_aggregation_code = form["admin_aggr_code"].ToUpper().Trim(); } // Check for reset request as well string reset_aggregation_code = String.Empty; if (form["admin_aggr_reset"] != null) { reset_aggregation_code = form["admin_aggr_reset"].ToLower().Trim(); } // If there is a reset request here, purge the aggregation from the cache if (reset_aggregation_code.Length > 0) { Cached_Data_Manager.Remove_Item_Aggregation(reset_aggregation_code, Tracer); } // If there was a save value continue to pull the rest of the data if (save_value.Length > 0) { bool is_active = false; bool is_hidden = false; object temp_object; // Was this to save a new aggregation (from the main page) or edit an existing (from the popup form)? if (save_value == new_aggregation_code) { // Pull the values from the submitted form string new_type = form["admin_aggr_type"]; string new_parent = form["admin_aggr_parent"].Trim(); string new_name = form["admin_aggr_name"].Trim(); string new_shortname = form["admin_aggr_shortname"].Trim(); string new_description = form["admin_aggr_desc"].Trim(); string new_link = form["admin_aggr_link"].Trim(); temp_object = form["admin_aggr_isactive"]; if (temp_object != null) { is_active = true; } temp_object = form["admin_aggr_ishidden"]; if (temp_object != null) { is_hidden = true; } // Convert to the integer id for the parent and begin to do checking List <string> errors = new List <string>(); int parentid = -1; if (new_parent.Length > 0) { try { parentid = Convert.ToInt32(new_parent); } catch { errors.Add("Invalid parent id selected!"); } } else { errors.Add("You must select a PARENT for this new aggregation"); } // Get the list of all aggregations if (new_aggregation_code.Length > 20) { errors.Add("New aggregation code must be twenty characters long or less"); } else { if (codeManager[new_aggregation_code] != null) { errors.Add("New code must be unique... <i>" + new_aggregation_code + "</i> already exists"); } } // Was there a type and name if (new_type.Length == 0) { errors.Add("You must select a TYPE for this new aggregation"); } if (new_description.Length == 0) { errors.Add("You must enter a DESCRIPTION for this new aggregation"); } if (new_name.Length == 0) { errors.Add("You must enter a NAME for this new aggregation"); } else { if (new_shortname.Length == 0) { new_shortname = new_name; } } if (errors.Count > 0) { // Create the error message actionMessage = "ERROR: Invalid entry for new item aggregation<br />"; foreach (string error in errors) { actionMessage = actionMessage + "<br />" + error; } // Save all the values that were entered enteredCode = new_aggregation_code; enteredDescription = new_description; enteredIsActive = is_active; enteredIsHidden = is_hidden; enteredName = new_name; enteredParent = new_parent; enteredShortname = new_shortname; enteredType = new_type; enteredLink = new_link; } else { // Get the correct type string correct_type = "Collection"; switch (new_type) { case "coll": correct_type = "Collection"; break; case "group": correct_type = "Collection Group"; break; case "subcoll": correct_type = "SubCollection"; break; case "inst": correct_type = "Institution"; break; case "exhibit": correct_type = "Exhibit"; break; case "subinst": correct_type = "Institutional Division"; break; } // Make sure inst and subinst start with 'i' if (new_type.IndexOf("inst") >= 0) { if (new_aggregation_code[0] == 'I') { new_aggregation_code = "i" + new_aggregation_code.Substring(1); } if (new_aggregation_code[0] != 'i') { new_aggregation_code = "i" + new_aggregation_code; } } // Try to save the new item aggregation if (SobekCM_Database.Save_Item_Aggregation(new_aggregation_code, new_name, new_shortname, new_description, correct_type, is_active, is_hidden, new_link, parentid, Tracer)) { // Ensure a folder exists for this, otherwise create one try { string folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + new_aggregation_code.ToLower(); if (!Directory.Exists(folder)) { // Create this directory and all the subdirectories Directory.CreateDirectory(folder); Directory.CreateDirectory(folder + "/html"); Directory.CreateDirectory(folder + "/images"); Directory.CreateDirectory(folder + "/html/home"); Directory.CreateDirectory(folder + "/images/buttons"); Directory.CreateDirectory(folder + "/images/banners"); // Create a default home text file StreamWriter writer = new StreamWriter(folder + "/html/home/text.html"); writer.WriteLine("<br />New collection home page text goes here.<br /><br />To edit this, edit the following file: " + folder + "\\html\\home\\text.html.<br /><br />"); writer.Flush(); writer.Close(); // Copy the default banner and buttons from images if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.png")) { File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.png", folder + "/images/buttons/coll.png"); } if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.gif")) { File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.gif", folder + "/images/buttons/coll.gif"); } if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_banner.jpg")) { File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_banner.jpg", folder + "/images/banners/coll.jpg"); } // Now, try to create the item aggregation and write the configuration file Item_Aggregation itemAggregation = Item_Aggregation_Builder.Get_Item_Aggregation(new_aggregation_code, String.Empty, null, false, Tracer); itemAggregation.Write_Configuration_File(SobekCM_Library_Settings.Base_Design_Location + itemAggregation.objDirectory); } } catch { } // Reload the list of all codes, to include this new one and the new hierarchy lock (codeManager) { SobekCM_Database.Populate_Code_Manager(codeManager, Tracer); } actionMessage = "New item aggregation <i>" + new_aggregation_code + "</i> saved successfully"; } else { actionMessage = "ERROR saving the new item aggregation to the database"; } } } } } catch { actionMessage = "General error while reading postback information"; } } }
/// <summary> Constructor for a new instance of the Home_MySobekViewer class </summary> /// <param name="currentMode"> Mode / navigation information for the current request (including interface code) </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Logon_MySobekViewer(SobekCM_Navigation_Object currentMode, Custom_Tracer Tracer) : base(null) { Tracer.Add_Trace("Logon_MySobekViewer.Constructor", String.Empty); CurrentMode = currentMode; errorMessage = String.Empty; // If this is a postback, check to see if the user is valid if (currentMode.isPostBack) { string possible_username = String.Empty; string possible_password = String.Empty; bool remember_me = false; string[] getKeys = HttpContext.Current.Request.Form.AllKeys; foreach (string thisKey in getKeys) { switch (thisKey) { case "logon_username": possible_username = HttpContext.Current.Request.Form[thisKey].Trim(); break; case "logon_password": possible_password = HttpContext.Current.Request.Form[thisKey].Trim(); break; case "rememberme": if (HttpContext.Current.Request.Form[thisKey].Trim() == "rememberme") { remember_me = true; } break; } } if ((!String.IsNullOrEmpty(possible_password)) && (!String.IsNullOrEmpty(possible_username))) { user = SobekCM_Database.Get_User(possible_username, possible_password, Tracer); if (user != null) { // The user was valid here, so save this user information HttpContext.Current.Session["user"] = user; // Should we remember this user via cookies? if (remember_me) { HttpCookie userCookie = new HttpCookie("SobekUser"); userCookie.Values["userid"] = user.UserID.ToString(); userCookie.Values["security_hash"] = user.Security_Hash(HttpContext.Current.Request.UserHostAddress); userCookie.Expires = DateTime.Now.AddDays(14); HttpContext.Current.Response.Cookies.Add(userCookie); } // Forward back to their original URL (unless the original URL was this logon page) string raw_url = HttpContext.Current.Items["Original_URL"].ToString(); if (raw_url.ToLower().IndexOf("my/logon") > 0) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } else { HttpContext.Current.Response.Redirect(raw_url); } } } } }
/// <summary> Constructor for a new instance of the Edit_Group_Behaviors_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Group_Behaviors_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } const string templateCode = "groupbehaviors"; template = Cached_Data_Manager.Retrieve_Template(templateCode, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + templateCode + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(templateCode, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } else if (hidden_request == "save") { // Save these changes to bib template.Save_To_Bib(item, user, 1); // Save the group title SobekCM_Database.Update_Item_Group(item.BibID, item.Behaviors.GroupTitle, item.Bib_Info.sortSafeTitle(item.Behaviors.GroupTitle, true), String.Empty, item.Behaviors.Primary_Identifier.Type, item.Behaviors.Primary_Identifier.Identifier); // Save the interfaces to the group item as well SobekCM_Database.Save_Item_Group_Web_Skins(item.Web.GroupID, item); // Store on the caches (to replace the other) Cached_Data_Manager.Remove_Digital_Resource_Objects(item.BibID, Tracer); // Forward currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } }
/// <summary> Constructor for a new instance of the New_Group_And_Item_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Digital resource selected for file management </param> /// <param name="Item_List"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public File_Management_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Item_Lookup_Object Item_List, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", String.Empty); // Save the parameters codeManager = Code_Manager; itemList = Item_List; iconList = Icon_Table; currentMode = Current_Mode; webSkin = HTML_Skin; this.validationErrors = validationErrors; base.Translator = Translator; item = Current_Item; digitalResourceDirectory = Current_Item.Source_Directory; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // If this is post-back, handle it if (currentMode.isPostBack) { string[] getKeys = HttpContext.Current.Request.Form.AllKeys; string file_name_from_keys = String.Empty; string label_from_keys = String.Empty; foreach (string thisKey in getKeys) { if (thisKey.IndexOf("upload_file") == 0) { file_name_from_keys = HttpContext.Current.Request.Form[thisKey]; } if (thisKey.IndexOf("upload_label") == 0) { label_from_keys = HttpContext.Current.Request.Form[thisKey]; } if ((file_name_from_keys.Length > 0) && (label_from_keys.Length > 0)) { HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + file_name_from_keys.Trim()] = label_from_keys.Trim(); file_name_from_keys = String.Empty; label_from_keys = String.Empty; } if (thisKey == "url_input") { item.Bib_Info.Location.Other_URL = HttpContext.Current.Request.Form[thisKey]; } } string action = HttpContext.Current.Request.Form["action"]; if (action == "delete") { string filename = HttpContext.Current.Request.Form["phase"]; try { if (File.Exists(digitalResourceDirectory + "\\" + filename)) { File.Delete(digitalResourceDirectory + "\\" + filename); } // Forward HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } catch { // Error was caught during attempted delete } } if (action == "next_phase") { int phase = Convert.ToInt32(HttpContext.Current.Request.Form["phase"]); switch (phase) { case 2: // Clear all the file keys in the session state List <string> keys = new List <string>(); foreach (string thisKey in HttpContext.Current.Session.Keys) { if (thisKey.IndexOf("file_" + item.Web.ItemID + "_") == 0) { keys.Add(thisKey); } } foreach (string thisKey in keys) { HttpContext.Current.Session.Remove(thisKey); } // Redirect to the item currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); break; case 9: if (!complete_item_submission(item, null)) { // Clear all the file keys in the session state List <string> keys2 = new List <string>(); foreach (string thisKey in HttpContext.Current.Session.Keys) { if (thisKey.IndexOf("file_" + item.Web.ItemID + "_") == 0) { keys2.Add(thisKey); } } foreach (string thisKey in keys2) { HttpContext.Current.Session.Remove(thisKey); } // Also clear the item from the cache MemoryMgmt.Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, null); // Redirect to the item currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } break; } } } }
/// <summary> Constructor for a new instance of the Projects_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="currentMode"> Mode / navigation information for the current request</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling a new project is handled here in the constructor </remarks> public Projects_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Projects_AdminViewer.Constructor", String.Empty); // Save the mode and settings here base.currentMode = currentMode; // Set action message to nothing to start actionMessage = String.Empty; // If the user cannot edit this, go back if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // If this is a postback, handle any events first if (currentMode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; string save_value = form["admin_project_tosave"].ToUpper().Trim(); string code_value = form["admin_project_code"].ToUpper().Trim(); // Or.. was this a save request if (save_value.Length > 0) { Tracer.Add_Trace("Projects_AdminViewer.Constructor", "Save project '" + save_value + "'"); // Was this to save a new project (from the main page) or rename an existing (from the popup form)? if (save_value == code_value) { string new_base_code = form["admin_project_base"].ToUpper().Trim(); string new_name = form["admin_project_name"].Trim(); // Save this new interface if (SobekCM_Database.Save_Project(save_value.ToUpper(), new_name, Tracer)) { actionMessage = "Saved new project <i>" + save_value + "</i>"; } else { actionMessage = "Unable to save new project <i>" + save_value + "</i>"; } // Try to creating the PMETS file if there was a base PMETS code provided try { if (new_base_code.Length > 0) { string pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + code_value + ".pmets"; string base_pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + new_base_code + ".pmets"; if (File.Exists(base_pmets_file)) { File.Copy(base_pmets_file, pmets_file, true); } } } catch (Exception) { actionMessage = "Error copying new project METS to the project folder"; } } else { string edit_name = form["form_project_name"].Trim(); // Save this existing interface if (SobekCM_Database.Save_Project(save_value.ToUpper(), edit_name, Tracer)) { actionMessage = "Renamed existing project <i>" + save_value + "</i>"; } else { actionMessage = "Unable to rename existing project <i>" + save_value + "</i>"; } } } } catch (Exception) { actionMessage = "Unknown exception occurred while processing your request"; } } }
/// <summary> Constructor for a new instance of the Wordmarks_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from editing an existing wordmark, deleting a wordmark, or creating a new wordmark is handled here in the constructor </remarks> public Wordmarks_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Wordmarks_AdminViewer.Constructor", String.Empty); // Save the mode and settings here currentMode = Current_Mode; // Set action message to nothing to start actionMessage = String.Empty; // If the user cannot edit this, go back if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // If this is a postback, handle any events first if (currentMode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; string delete_value = form["admin_wordmark_code_delete"].ToUpper().Trim(); string save_value = form["admin_wordmark_code_tosave"].ToUpper().Trim(); string new_wordmark_code = form["admin_wordmark_code"].ToUpper().Trim(); // Was this a reset request? if (delete_value.Length > 0) { Tracer.Add_Trace("Wordmarks_AdminViewer.Constructor", "Delete wordmark '" + delete_value + "'"); if (SobekCM_Database.Delete_Icon(delete_value, Tracer)) { actionMessage = "Deleted wordmark <i>" + delete_value + "</i>"; } else { if (SobekCM_Database.Last_Exception == null) { actionMessage = "Unable to delete wordmark <i>" + delete_value + "</i> since it is in use"; } else { actionMessage = "Unknown error while deleting wordmark <i>" + delete_value + "</i>"; } } } else { // Or.. was this a save request if (save_value.Length > 0) { Tracer.Add_Trace("Wordmarks_AdminViewer.Constructor", "Save wordmark '" + save_value + "'"); // Was this to save a new interface (from the main page) or edit an existing (from the popup form)? if (save_value == new_wordmark_code) { string new_file = form["admin_wordmark_file"].Trim(); string new_link = form["admin_wordmark_link"].Trim(); string new_title = form["admin_wordmark_title"].Trim(); // Save this new wordmark if (SobekCM_Database.Save_Icon(new_wordmark_code, new_file, new_link, new_title, Tracer) > 0) { actionMessage = "Saved new wordmark <i>" + save_value + "</i>"; } else { actionMessage = "Unable to save new wordmark <i>" + save_value + "</i>"; } } else { string edit_file = form["form_wordmark_file"].Trim(); string edit_link = form["form_wordmark_link"].Trim(); string edit_title = form["form_wordmark_title"].Trim(); // Save this existing wordmark if (SobekCM_Database.Save_Icon(save_value, edit_file, edit_link, edit_title, Tracer) > 0) { actionMessage = "Edited existing wordmark <i>" + save_value + "</i>"; } else { actionMessage = "Unable to edit existing wordmark <i>" + save_value + "</i>"; } } } } } catch (Exception) { actionMessage = "Unknown error caught while handing request."; } } }
/// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Item_Metadata_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; popUpFormsHtml = String.Empty; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Is this a project isProject = false; if (item.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project) { isProject = true; } string template_code = user.Edit_Template_Code; if ((isProject) || (item.Contains_Complex_Content) || (item.Using_Complex_Template)) { template_code = user.Edit_Template_MARC_Code; } template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // Get the current page number, or default to 1 page = 1; if (currentMode.My_Sobek_SubMode.Length > 0) { if ((currentMode.My_Sobek_SubMode == "preview") || (currentMode.My_Sobek_SubMode == "marc") || (currentMode.My_Sobek_SubMode == "mets")) { page = 0; } else { page = 1; bool isNumber = currentMode.My_Sobek_SubMode.All(Char.IsNumber); if (isNumber) { if (isProject) { Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } else { Double.TryParse(currentMode.My_Sobek_SubMode, out page); } } else if (isProject) { if (Char.IsNumber(currentMode.My_Sobek_SubMode[0])) { Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } } } } }
/// <summary> Constructor for a new instance of the Edit_Item_Behaviors_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Item_Behaviors_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } const string templateCode = "itembehaviors"; template = Cached_Data_Manager.Retrieve_Template(templateCode, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + templateCode + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(templateCode, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } else if (hidden_request == "save") { // Changes to the tracking box require the metadata search citation be rebuilt for this item // so save the old tracking box information first string oldTrackingBox = item.Tracking.Tracking_Box; // Save these changes to bib template.Save_To_Bib(item, user, 1); // Save the behaviors SobekCM_Database.Save_Behaviors(item, item.Behaviors.Text_Searchable, false); // Save the serial hierarchy as well (sort of a behavior) SobekCM_Database.Save_Serial_Hierarchy_Information(item, item.Web.GroupID, item.Web.ItemID); // Did the tracking box change? if (item.Tracking.Tracking_Box != oldTrackingBox) { SobekCM_Database.Create_Full_Citation_Value(item.Web.ItemID); } // Remoe from the caches (to replace the other) Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, Tracer); // Also remove the list of volumes, since this may have changed Cached_Data_Manager.Remove_Items_In_Title(item.BibID, Tracer); // Forward currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } }
/// <summary> Constructor for a new instance of the Contact_HtmlSubwriter class </summary> /// <param name="Last_Mode"> URL for the last mode this user was in before selecting contact us</param> /// <param name="UserHistoryRequestInfo"> Some history and user information to include in the final email </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> public Contact_HtmlSubwriter(string Last_Mode, string UserHistoryRequestInfo, SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object) { // Save the parameters lastMode = Last_Mode; userHistoryRequestInfo = UserHistoryRequestInfo; currentMode = Current_Mode; this.Hierarchy_Object = Hierarchy_Object; // If this is a post back, send email if (HttpContext.Current.Request.Form["item_action"] == null) { return; } string action = HttpContext.Current.Request.Form["item_action"]; if (action == "email") { string notes = HttpContext.Current.Request.Form["notesTextBox"].Trim(); string subject = HttpContext.Current.Request.Form["subjectTextBox"].Trim(); string message_from = SobekCM_Library_Settings.System_Email; string email = HttpContext.Current.Request.Form["emailTextBox"].Trim(); string name = HttpContext.Current.Request.Form["nameTextBox"].Trim(); if ((notes.Length > 0) || (subject.Length > 0)) { // Create the mail message if (email.Length > 0) { message_from = email; } // Start the body StringBuilder builder = new StringBuilder(1000); builder.Append(notes + "\n\n\n\n"); builder.Append("The following information is collected to allow us better serve your needs.\n\n"); builder.Append("PERSONAL INFORMATION\n"); builder.Append("\tName:\t\t\t\t" + name + "\n"); builder.Append("\tEmail:\t\t\t" + email + "\n"); builder.Append(userHistoryRequestInfo); string email_body = builder.ToString(); try { MailMessage myMail = new MailMessage(message_from, base.Hierarchy_Object.Contact_Email.Replace(";", ",")) { Subject = subject + " [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]", Body = email_body }; // Mail this SmtpClient client = new SmtpClient("smtp.ufl.edu"); client.Send(myMail); // Log this string sender = message_from; if (name.Length > 0) { sender = name + " ( " + message_from + " )"; } SobekCM_Database.Log_Sent_Email(sender, base.Hierarchy_Object.Contact_Email.Replace(";", ","), subject + " [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]", email_body, false, true, -1); // Send back to the home for this collection, sub, or group Current_Mode.Mode = Display_Mode_Enum.Contact_Sent; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL(), false); } catch { bool email_error = SobekCM_Database.Send_Database_Email(base.Hierarchy_Object.Contact_Email.Replace(";", ","), subject + " [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]", email_body, false, true, -1); // Send back to the home for this collection, sub, or group if (email_error) { HttpContext.Current.Response.Redirect(SobekCM_Library_Settings.System_Error_URL, false); } else { // Send back to the home for this collection, sub, or group Current_Mode.Mode = Display_Mode_Enum.Contact_Sent; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL(), false); } } } } }
/// <summary> Constructor for a new instance of the Portals_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Portals_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Portal_List URL_Portals, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Portals_AdminViewer.Constructor", String.Empty); portals = URL_Portals; // Save the mode currentMode = Current_Mode; // Set action message to nothing to start actionMessage = String.Empty; // If the user cannot edit this, go back if (!user.Is_System_Admin) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL()); } // Handle any post backs if (Current_Mode.isPostBack) { try { // Pull the standard values from the form NameValueCollection form = HttpContext.Current.Request.Form; string save_value = form["admin_portal_tosave"]; string action_value = form["admin_portal_action"]; // Switch, depending on the request if (action_value != null) { switch (action_value.Trim().ToLower()) { case "edit": // Get the values from the form for this new portal string edit_name = form["form_portal_name"].Trim(); string edit_abbr = form["form_portal_abbr"].Trim(); string edit_skin = form["form_portal_skin"].Trim(); string edit_aggr = form["form_portal_aggregation"].Trim(); string edit_url = form["form_portal_url"].Trim(); string edit_purl = form["form_portal_purl"].Trim(); int portalid = Convert.ToInt32(save_value); // Look for this to see if this was the pre-existing default bool isDefault = false; if (portals.Default_Portal.ID == portalid) { isDefault = true; } // Don't edit if the URL segment is empty and this is NOT default if ((!isDefault) && (edit_url.Trim().Length == 0)) { actionMessage = "ERROR: Non default portals MUST have a url segment associated."; } else { // Now, save this portal information int edit_id = SobekCM_Database.Edit_URL_Portal(portalid, edit_url, true, isDefault, edit_abbr, edit_name, edit_aggr, edit_skin, edit_purl, Tracer); if (edit_id > 0) { actionMessage = "Edited existing URL portal '" + edit_name + "'"; } else { actionMessage = "Error editing URL portal."; } } break; case "delete": actionMessage = SobekCM_Database.Delete_URL_Portal(Convert.ToInt32(save_value), Tracer) ? "URL portal deleted" : "Error deleting the URL portal"; break; case "new": // Get the values from the form for this new portal string new_name = form["admin_portal_name"]; string new_abbr = form["admin_portal_abbr"]; string new_skin = form["admin_portal_skin"]; string new_aggr = form["admin_portal_aggregation"]; string new_url = form["admin_portal_url"]; string new_purl = form["admin_portal_purl"]; // Save this to the database int new_id = SobekCM_Database.Edit_URL_Portal(-1, new_url, true, false, new_abbr, new_name, new_aggr, new_skin, new_purl, Tracer); if (new_id > 0) { actionMessage = "Saved new URL portal '" + new_name + "'"; } else { actionMessage = "Error saving URL portal."; } break; } } } catch (Exception) { actionMessage = "Exception caught while handling request"; } // Reload all the URL portals SobekCM_Database.Populate_URL_Portals(portals, Tracer); } }
/// <summary> Constructor for a new instance of the User_Group_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="currentMode"> Mode / navigation information for the current request</param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from a user group edit is handled here in the constructor </remarks> public User_Group_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("User_Group_AdminViewer.Constructor", String.Empty); // Set the action message to clear initially actionMessage = String.Empty; codeManager = Code_Manager; // Get the user to edit, if there was a user id in the submode int edit_usergroupid = -100; editGroup = null; if (currentMode.My_Sobek_SubMode.Length > 0) { if (currentMode.My_Sobek_SubMode == "new") { edit_usergroupid = -1; } else { if (Int32.TryParse(currentMode.My_Sobek_SubMode.Replace("a", "").Replace("b", "").Replace("c", "").Replace("v", ""), out edit_usergroupid)) { editGroup = SobekCM_Database.Get_User_Group(edit_usergroupid, Tracer); } } } // Determine the mode mode = Users_Group_Admin_Mode_Enum.Error; if ((editGroup != null) || (edit_usergroupid == -1)) { if ((currentMode.My_Sobek_SubMode.IndexOf("v") > 0) && (edit_usergroupid > 0)) { mode = Users_Group_Admin_Mode_Enum.View_User_Group; } else { mode = Users_Group_Admin_Mode_Enum.Edit_User_Group; } } else { currentMode.My_Sobek_SubMode = String.Empty; currentMode.Admin_Type = Admin_Type_Enum.Users; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Set an empty user group object for a new item if (edit_usergroupid < 0) { editGroup = new User_Group(String.Empty, String.Empty, -1); } // Perform post back work if (currentMode.isPostBack) { if ((mode == Users_Group_Admin_Mode_Enum.Edit_User_Group) && (editGroup != null)) { // Get a reference to this form NameValueCollection form = HttpContext.Current.Request.Form; string[] getKeys = form.AllKeys; bool successful_save = true; bool can_editall = editGroup.Editable_Regular_Expressions.Any(thisRegularExpression => thisRegularExpression == "[A-Z]{2}[A-Z|0-9]{4}[0-9]{4}"); bool can_submit = false; bool is_internal = false; bool is_admin = false; bool is_portal = false; string name = editGroup.Name; string description = editGroup.Description; List <string> projects = new List <string>(); List <string> templates = new List <string>(); Dictionary <string, User_Editable_Aggregation> aggregations = new Dictionary <string, User_Editable_Aggregation>(); // Step through each key foreach (string thisKey in getKeys) { switch (thisKey) { case "groupName": name = form[thisKey].Trim(); break; case "groupDescription": description = form[thisKey].Trim(); break; case "admin_user_submit": can_submit = true; break; case "admin_user_internal": is_internal = true; break; case "admin_user_editall": can_editall = true; break; case "admin_user_admin": is_admin = true; break; case "admin_user_portaladmin": is_portal = true; break; default: if (thisKey.IndexOf("admin_user_template_") == 0) { templates.Add(thisKey.Replace("admin_user_template_", "")); } if (thisKey.IndexOf("admin_user_project_") == 0) { projects.Add(thisKey.Replace("admin_user_project_", "")); } if (thisKey.IndexOf("admin_project_onhome_") == 0) { string select_project = thisKey.Replace("admin_project_onhome_", ""); if (aggregations.ContainsKey(select_project)) { aggregations[select_project].OnHomePage = true; } else { aggregations.Add(select_project, new User_Editable_Aggregation(select_project, String.Empty, false, false, false, true)); } } if (thisKey.IndexOf("admin_project_select_") == 0) { string select_project = thisKey.Replace("admin_project_select_", ""); if (aggregations.ContainsKey(select_project)) { aggregations[select_project].CanSelect = true; } else { aggregations.Add(select_project, new User_Editable_Aggregation(select_project, String.Empty, true, false, false, false)); } } if (thisKey.IndexOf("admin_project_edit_") == 0) { string edit_project = thisKey.Replace("admin_project_edit_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanEditItems = true; } else { aggregations.Add(edit_project, new User_Editable_Aggregation(edit_project, String.Empty, false, true, false, false)); } } if (thisKey.IndexOf("admin_project_admin_") == 0) { string admin_project = thisKey.Replace("admin_project_admin_", ""); if (aggregations.ContainsKey(admin_project)) { aggregations[admin_project].IsCurator = true; } else { aggregations.Add(admin_project, new User_Editable_Aggregation(admin_project, String.Empty, false, false, true, false)); } } break; } } // Determine if the projects and templates need to be updated bool update_templates_projects = false; if ((templates.Count != editGroup.Templates.Count) || (projects.Count != editGroup.Projects.Count)) { update_templates_projects = true; } else { // Check all of the templates if (templates.Any(template => !editGroup.Templates.Contains(template))) { update_templates_projects = true; } // Check all the projects if (!update_templates_projects) { if (projects.Any(project => !editGroup.Projects.Contains(project))) { update_templates_projects = true; } } } // Determine if the aggregations need to be edited bool update_aggregations = false; if (aggregations.Count != editGroup.Aggregations.Count) { update_aggregations = true; } else { // Build a dictionary of the user aggregations as well Dictionary <string, User_Editable_Aggregation> existingAggr = editGroup.Aggregations.ToDictionary(thisAggr => thisAggr.Code); // Check all the aggregations foreach (User_Editable_Aggregation adminAggr in aggregations.Values) { if (existingAggr.ContainsKey(adminAggr.Code)) { if ((adminAggr.CanSelect != existingAggr[adminAggr.Code].CanSelect) || (adminAggr.CanEditItems != existingAggr[adminAggr.Code].CanEditItems) || (adminAggr.IsCurator != existingAggr[adminAggr.Code].IsCurator)) { update_aggregations = true; break; } } else { update_aggregations = true; break; } } } // Must have a name to continue if (name.Length > 0) { // Update the basic user information int newid = SobekCM_Database.Save_User_Group(editGroup.UserGroupID, name, description, can_submit, is_internal, can_editall, is_admin, is_portal, false, update_templates_projects, update_aggregations, false, Tracer); if (editGroup.UserGroupID < 0) { editGroup.UserGroupID = newid; } if (editGroup.UserGroupID > 0) { // Update the templates and projects, if requested if (update_templates_projects) { // Update projects, if necessary if (projects.Count > 0) { if (!SobekCM_Database.Update_SobekCM_User_Group_Projects(editGroup.UserGroupID, projects, Tracer)) { successful_save = false; } } // Update templates, if necessary if (templates.Count > 0) { if (!SobekCM_Database.Update_SobekCM_User_Group_Templates(editGroup.UserGroupID, templates, Tracer)) { successful_save = false; } } } // Update the aggregations, if requested if (update_aggregations) { if (aggregations.Count > 0) { List <User_Editable_Aggregation> aggregationList = aggregations.Values.ToList(); if (!SobekCM_Database.Update_SobekCM_User_Group_Aggregations(editGroup.UserGroupID, aggregationList, Tracer)) { successful_save = false; } } } } else { successful_save = false; } } else { actionMessage = "User group's name must have a length greater than zero"; successful_save = false; } // Forward back to the list of users, if this was successful if (successful_save) { currentMode.My_Sobek_SubMode = String.Empty; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } } } }
/// <summary> Constructor for a new instance of the Group_Add_Volume_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Items_In_Title"> List of items within this title </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Group_Add_Volume_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, SobekCM_Items_In_Title Items_In_Title, Language_Support_Info Translator, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; itemsInTitle = Items_In_Title; base.Translator = Translator; // Set some defaults ipRestrict = -1; title = String.Empty; date = String.Empty; level1 = String.Empty; level2 = String.Empty; level3 = String.Empty; level1Order = -1; level2Order = -1; level3Order = -1; hierarchyCopiedFromDate = false; message = String.Empty; trackingBox = String.Empty; bornDigital = false; materialRecdDate = null; materialRecdNotes = String.Empty; dispositionAdvice = -1; dispositionAdviceNotes = String.Empty; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Determine the default template code string template_code = "addvolume"; if (!user.Include_Tracking_In_Standard_Forms) { template_code = "addvolume_notracking"; } // Load this template template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["action"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } else if (hidden_request.IndexOf("save") == 0) { // Get the VID that used as a source for this string vid = HttpContext.Current.Request.Form["base_volume"]; if (string.IsNullOrEmpty(vid)) { message = "<span style=\"color: red\"><strong>No base volume selected!</strong></span>"; } else { try { // Get a new instance of this item SobekCM_Item saveItem = SobekCM_Item_Factory.Get_Item(Current_Mode.BibID, vid, Icon_Table, Tracer); // Clear some values for this item saveItem.VID = String.Empty; saveItem.Divisions.Clear(); saveItem.Behaviors.Serial_Info.Clear(); saveItem.Bib_Info.Series_Part_Info.Clear(); saveItem.Behaviors.Clear_Ticklers(); saveItem.Tracking.Internal_Comments = String.Empty; // Save the template changes to this item template.Save_To_Bib(saveItem, user, 1); // Save this item and copy over complete_item_submission(saveItem, Tracer); // Clear the volume list Cached_Data_Manager.Remove_Items_In_Title(saveItem.BibID, Tracer); // Forward differently depending on request switch (hidden_request) { case "save_edit": currentMode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata; currentMode.VID = saveItem.VID; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); break; case "save_again": // No redirect, but save values date = saveItem.Bib_Info.Origin_Info.Date_Issued; ipRestrict = saveItem.Behaviors.IP_Restriction_Membership; trackingBox = saveItem.Tracking.Tracking_Box; bornDigital = saveItem.Tracking.Born_Digital; dispositionAdvice = saveItem.Tracking.Disposition_Advice; dispositionAdviceNotes = saveItem.Tracking.Disposition_Advice_Notes; materialRecdDate = saveItem.Tracking.Material_Received_Date; materialRecdNotes = saveItem.Tracking.Material_Received_Notes; if (!hierarchyCopiedFromDate) { if (saveItem.Behaviors.Serial_Info.Count > 0) { level1 = saveItem.Behaviors.Serial_Info[0].Display; level1Order = saveItem.Behaviors.Serial_Info[0].Order; } if (saveItem.Behaviors.Serial_Info.Count > 1) { level2 = saveItem.Behaviors.Serial_Info[1].Display; level2Order = saveItem.Behaviors.Serial_Info[1].Order; } if (saveItem.Behaviors.Serial_Info.Count > 2) { level3 = saveItem.Behaviors.Serial_Info[2].Display; level3Order = saveItem.Behaviors.Serial_Info[2].Order; } } message = message + "<span style=\"color: blue\"><strong>Saved new volume ( " + saveItem.BibID + " : " + saveItem.VID + ")</strong></span>"; break; //case "save_addfiles": // break; default: currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.VID = saveItem.VID; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); break; } } catch (Exception ee) { message = message + "<br /><span style=\"color: red\"><strong>EXCEPTION CAUGHT!<br /><br />" + ee.Message + "<br /><br />" + ee.StackTrace.Replace("\n", "<br />") + "</strong></span>"; } } } }
/// <summary> Constructor for a new instance of the Admin_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Admin_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Dictionary <string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, User_Object Current_User, IP_Restriction_Ranges IP_Restrictions, Dictionary <string, Wordmark_Icon> Icon_Table, Portal_List URL_Portals, Statistics_Dates Stats_Date_Range, List <Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; ipRestrictions = IP_Restrictions; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?"); } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; } // If the user is not an admin, and admin was selected, reroute this if ((!Current_User.Is_System_Admin) && (!Current_User.Is_Portal_Admin)) { Current_Mode.Mode = Display_Mode_Enum.My_Sobek; Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; Current_Mode.My_Sobek_SubMode = String.Empty; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL()); } Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.Admin_Type) { case Admin_Type_Enum.Aggregation_Single: adminViewer = new Aggregation_Single_AdminViewer(user, Current_Mode, codeManager, Thematic_Headings, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Home: adminViewer = new Home_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Builder_Status: adminViewer = new Builder_AdminViewer(user, Current_Mode); break; case Admin_Type_Enum.Interfaces: adminViewer = new Skins_AdminViewer(user, Current_Mode, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Forwarding: adminViewer = new Aliases_AdminViewer(user, Current_Mode, Aggregation_Aliases, Tracer); break; case Admin_Type_Enum.Wordmarks: adminViewer = new Wordmarks_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.URL_Portals: adminViewer = new Portals_AdminViewer(user, Current_Mode, URL_Portals, Tracer); break; case Admin_Type_Enum.Users: adminViewer = new Users_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.User_Groups: adminViewer = new User_Group_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.Aggregations_Mgmt: adminViewer = new Aggregations_Mgmt_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.IP_Restrictions: adminViewer = new IP_Restrictions_AdminViewer(user, Current_Mode, ipRestrictions, Tracer); break; case Admin_Type_Enum.Thematic_Headings: adminViewer = new Thematic_Headings_AdminViewer(user, Current_Mode, Thematic_Headings, Tracer); break; case Admin_Type_Enum.Settings: adminViewer = new Settings_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Projects: if (Current_Mode.My_Sobek_SubMode.Length > 1) { string project_code = Current_Mode.My_Sobek_SubMode.Substring(1); Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Checking cache for valid project file"); if (user != null) { SobekCM_Item projectObject = Cached_Data_Manager.Retrieve_Project(user.UserID, project_code, Tracer); if (projectObject != null) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Valid project file found in cache"); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, projectObject, codeManager, iconTable, htmlSkin, Tracer); } else { if (SobekCM_Database.Get_All_Projects_Templates(Tracer).Tables[0].Select("ProjectCode='" + project_code + "'").Length > 0) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building project file from (possible) PMETS"); string pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + Current_Mode.My_Sobek_SubMode.Substring(1) + ".pmets"; SobekCM_Item pmets_item = File.Exists(pmets_file) ? SobekCM_Item.Read_METS(pmets_file) : new SobekCM_Item(); pmets_item.Bib_Info.Main_Title.Title = "Project level metadata for '" + project_code + "'"; pmets_item.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Project; pmets_item.BibID = project_code.ToUpper(); pmets_item.VID = "00001"; pmets_item.Source_Directory = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\"; Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Adding project file to cache"); Cached_Data_Manager.Store_Project(user.UserID, project_code, pmets_item, Tracer); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, pmets_item, codeManager, iconTable, htmlSkin, Tracer); } } } } if (adminViewer == null) { adminViewer = new Projects_AdminViewer(user, Current_Mode, Tracer); } break; } // Pass in the navigation and translator information adminViewer.CurrentMode = Current_Mode; adminViewer.Translator = translator; }
/// <summary> Constructor for a new instance of the Aliases_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="currentMode"> Mode / navigation information for the current request</param> /// <param name="Aggregation_Aliases"> Dictionary of all current item aggregation aliases </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks> public Aliases_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, Dictionary <string, string> Aggregation_Aliases, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Aliases_AdminViewer.Constructor", String.Empty); // Save the mode and settings here base.currentMode = currentMode; aggregationAliases = Aggregation_Aliases; // Set action message to nothing to start actionMessage = String.Empty; // If the user cannot edit this, go back if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // If this is a postback, handle any events first if (currentMode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; string save_value = form["admin_forwarding_tosave"].ToLower().Trim(); string new_alias = form["admin_forwarding_alias"].ToLower().Trim(); // Was this a save request if (save_value.Length > 0) { // If this starts with a '-' this is a delete if (save_value[0] == '-') { if (save_value.Length > 1) { save_value = save_value.Substring(1); Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Delete alias '" + save_value + "'"); if (SobekCM_Database.Delete_Aggregation_Alias(save_value, Tracer)) { if (aggregationAliases.ContainsKey(save_value)) { aggregationAliases.Remove(save_value); } actionMessage = "Deleted existing aggregation alias <i>" + save_value + "</i>"; } } } else { Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Save alias '" + save_value + "'"); // Was this to save a new alias (from the main page) or edit an existing (from the popup form)? if (save_value == new_alias) { string new_code = form["admin_forwarding_code"].ToLower().Trim(); // Save this new forwarding if (SobekCM_Database.Save_Aggregation_Alias(save_value, new_code, Tracer)) { if (aggregationAliases.ContainsKey(save_value)) { aggregationAliases[save_value] = new_code; } else { aggregationAliases.Add(save_value, new_code); } actionMessage = "Saved new aggregation alias <i>" + save_value + "</i>"; } else { actionMessage = "Unable to save new aggregation alias <i>" + save_value + "</i>"; } } else { string edit_code = form["form_forwarding_code"].ToLower().Trim(); // Save this existing forwarding if (SobekCM_Database.Save_Aggregation_Alias(save_value, edit_code, Tracer)) { if (aggregationAliases.ContainsKey(save_value)) { aggregationAliases[save_value] = edit_code; } else { aggregationAliases.Add(save_value, edit_code); } actionMessage = "Edited existing aggregation alias <i>" + save_value + "</i>"; } else { actionMessage = "Unable to save existing aggregation alias <i>" + save_value + "</i>"; } } } } } catch (Exception) { actionMessage = "Unknown error caught while processing request"; } } }
/// <summary> Constructor for a new instance of the Aliases_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="currentMode"> Mode / navigation information for the current request</param> /// <param name="IP_Restrictions"> List of all IP restrictions ranges used in this digital library to restrict access to certain digital resources </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks> public IP_Restrictions_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, IP_Restriction_Ranges IP_Restrictions, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("IP_Restrictions_AdminViewer.Constructor", String.Empty); ipRestrictionInfo = IP_Restrictions; this.currentMode = currentMode; // Ensure the user is the system admin if ((User == null) || (!User.Is_System_Admin)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), false); } // Determine if there is an specific IP address range for editing index = -1; if (currentMode.My_Sobek_SubMode.Length > 0) { if (!Int32.TryParse(currentMode.My_Sobek_SubMode, out index)) { index = -1; } } // If there was an index included, try to pull the information about it thisRange = null; details = null; if ((index >= 1) && (index <= ipRestrictionInfo.Count)) { thisRange = ipRestrictionInfo[index - 1]; if (thisRange != null) { details = SobekCM_Database.Get_IP_Restriction_Range_Details(thisRange.RangeID, Tracer); } } if ((currentMode.isPostBack) && (details != null) && (thisRange != null)) { try { // Get a reference to this form NameValueCollection form = HttpContext.Current.Request.Form; // Pull the main values string title = form["admin_title"].Trim(); string notes = form["admin_notes"].Trim(); string message = form["admin_message"].Trim(); if (title.Length == 0) { title = thisRange.Title; } // Edit the main values in the database SobekCM_Database.Edit_IP_Range(thisRange.RangeID, title, notes, message, Tracer); thisRange.Title = title; thisRange.Notes = notes; thisRange.Item_Restricted_Statement = message; // Now check each individual IP address range string[] getKeys = form.AllKeys; int single_ip_index = 0; foreach (string thisKey in getKeys) { // Is this for a new ip address? if (thisKey.IndexOf("admin_ipstart_") == 0) { // Get the basic information for this single ip address string ip_index = thisKey.Replace("admin_ipstart_", ""); string thisIpStart = form["admin_ipstart_" + ip_index].Trim(); string thisIpEnd = form["admin_ipend_" + ip_index].Trim(); string thisIpNote = form["admin_iplabel_" + ip_index].Trim(); // Does this match an existing IP range? if ((ip_index.IndexOf("new") < 0) && (single_ip_index < details.Tables[1].Rows.Count)) { // Get the pre-existing IP row DataRow ipRow = details.Tables[1].Rows[single_ip_index]; int singleIpId = Convert.ToInt32(ipRow[0]); if (thisIpStart.Length == 0) { SobekCM_Database.Delete_Single_IP(singleIpId, Tracer); } else { // Is this the same? if ((thisIpStart != ipRow[1].ToString().Trim()) || (thisIpEnd != ipRow[2].ToString().Trim()) || (thisIpNote != ipRow[3].ToString().Trim())) { int edit_point_count = thisIpStart.Count(thisChar => thisChar == '.'); if (edit_point_count == 3) { SobekCM_Database.Edit_Single_IP(singleIpId, thisRange.RangeID, thisIpStart, thisIpEnd, thisIpNote, Tracer); } } } // Be ready to look at the next pre-existing IP range single_ip_index++; } else { // Just add this as a new single ip address if (thisIpStart.Length > 0) { int add_point_count = thisIpStart.Count(thisChar => thisChar == '.'); if (add_point_count == 3) { SobekCM_Database.Edit_Single_IP(-1, thisRange.RangeID, thisIpStart, thisIpEnd, thisIpNote, Tracer); } } } } } } catch (Exception) { // Some error caught while handling postback } // Repopulate the restriction table DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer); if (ipRestrictionTbl != null) { IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl); } // Forward back to the main form currentMode.My_Sobek_SubMode = String.Empty; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } }