/// <summary> Refresh the list of ip restriction ranges by pulling the data back from the database </summary> /// <returns> TRUE if successful, otherwise FALSE </returns> public static bool RefreshIP_Restrictions() { try { lock (settingsLock) { lock (ipRestrictionsLock) { DataTable ipRestrictionTbl = Engine_Database.Get_IP_Restriction_Ranges(null); if (ipRestrictionTbl != null) { ipRestrictions = new IP_Restriction_Ranges(); ipRestrictions.Populate_IP_Ranges(ipRestrictionTbl); } } } return(true); } catch { return(false); } }
/// <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 MySobek_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 MySobek_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("MySobek_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("MySobek_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; } Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.My_Sobek_Type) { case My_Sobek_Type_Enum.Home: mySobekViewer = new Home_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.New_Item: mySobekViewer = new New_Group_And_Item_MySobekViewer(user, Current_Mode, itemList, codeManager, iconTable, htmlSkin, translator, Tracer); break; case My_Sobek_Type_Enum.Folder_Management: mySobekViewer = new Folder_Mgmt_MySobekViewer(user, resultsStatistics, pagedResults, codeManager, itemList, currentCollection, htmlSkin, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Saved_Searches: mySobekViewer = new Saved_Searches_MySobekViewer(user, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Preferences: mySobekViewer = new Preferences_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.Logon: mySobekViewer = new Logon_MySobekViewer(Current_Mode, Tracer); break; case My_Sobek_Type_Enum.New_Password: mySobekViewer = new NewPassword_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.Delete_Item: mySobekViewer = new Delete_Item_MySobekViewer(user, Current_Mode, All_Items_Lookup, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Behaviors: mySobekViewer = new Edit_Item_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Metadata: mySobekViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, Tracer); break; case My_Sobek_Type_Enum.File_Management: mySobekViewer = new File_Management_MySobekViewer(user, Current_Mode, Current_Item, itemList, codeManager, iconTable, htmlSkin, translator, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Behaviors: mySobekViewer = new Edit_Group_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy: mySobekViewer = new Edit_Serial_Hierarchy_MySobekViewer(user); break; case My_Sobek_Type_Enum.Group_Add_Volume: // Pull the list of items tied to this group SobekCM_Items_In_Title itemsInTitle = Cached_Data_Manager.Retrieve_Items_In_Title(currentItem.BibID, Tracer); if (itemsInTitle == null) { // Get list of information about this item group and save the item list DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(currentItem.BibID, Tracer); itemsInTitle = new SobekCM_Items_In_Title(itemDetails.Tables[1]); // Store in cache if retrieved Cached_Data_Manager.Store_Items_In_Title(currentItem.BibID, itemsInTitle, Tracer); } mySobekViewer = new Group_Add_Volume_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, itemsInTitle, translator, Tracer); break; case My_Sobek_Type_Enum.Group_AutoFill_Volumes: mySobekViewer = new Group_AutoFill_Volume_MySobekViewer(user); break; case My_Sobek_Type_Enum.Group_Mass_Update_Items: mySobekViewer = new Mass_Update_Items_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.User_Tags: mySobekViewer = new User_Tags_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.User_Usage_Stats: mySobekViewer = new User_Usage_Stats_MySobekViewer(user, Current_Mode, statsDates, Tracer); break; } // Pass in the navigation and translator information mySobekViewer.CurrentMode = Current_Mode; mySobekViewer.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="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()); } }