/// <summary> Constructor for a new instance of the Static_Pages_Builder class </summary> /// <param name="Primary_Web_Server_URL"> URL for the primary web server </param> /// <param name="Static_Data_Location"> Network location for the data directory </param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Application_State.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> public Static_Pages_Builder(string Primary_Web_Server_URL, string Static_Data_Location, Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Dictionary<string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin) { primaryWebServerUrl = Primary_Web_Server_URL; staticSobekcmDataLocation = Static_Data_Location; tracer = new Custom_Tracer(); assistant = new SobekCM_Assistant(); // marcWriter = new MARC_Writer(); // Save all the objects needed by the UFDC Library iconList = Icon_Table; translations = Translator; codeManager = Code_Manager; itemList = All_Items_Lookup; ufdcInterface = HTML_Skin; dlocInterface = HTML_Skin; // Create the mode object currentMode = new SobekCM_Navigation_Object { ViewerCode = "citation", Skin = "UFDC", Mode = Display_Mode_Enum.Item_Display, Language = Web_Language_Enum.English, Base_URL = primaryWebServerUrl }; }
/// <summary> Refreshes the item list and aggregation/greenstone code information from the database on a regular basis </summary> /// <param name="Code_Manager"> [REF] List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library </param> /// <returns> TRUE if successful, otherwise FALSE </returns> public static bool Refresh_Item_List_And_Aggregation_Codes(ref Aggregation_Code_Manager Code_Manager, ref Item_Lookup_Object All_Items_Lookup) { try { // Load SobekCM Codes to Greenstone Codes conversion again if (Code_Manager != null) { lock (Code_Manager) { SobekCM_Database.Populate_Code_Manager(Code_Manager, null); } } else { Code_Manager = new Aggregation_Code_Manager(); SobekCM_Database.Populate_Code_Manager(Code_Manager, null); } //lock (item_list_lock_object) //{ // if (All_Items_Lookup == null) // All_Items_Lookup = new Item_Lookup_Object(); // // Have the database popoulate the little bit of bibid/vid information we retain // SobekCM_Database.Populate_Item_Lookup_Object(true, All_Items_Lookup, null); //} return(true); } catch { return(false); } }
/// <summary> Constructor for a new instance of the Static_Pages_Builder class </summary> /// <param name="Primary_Web_Server_URL"> URL for the primary web server </param> /// <param name="Static_Data_Location"> Network location for the data directory </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin_Collection"> HTML Web skin collection 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="Default_Skin"> Default skin code </param> public Static_Pages_Builder(string Primary_Web_Server_URL, string Static_Data_Location, Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, Dictionary<string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Collection HTML_Skin_Collection, string Default_Skin) { primaryWebServerUrl = Primary_Web_Server_URL; staticSobekcmDataLocation = Static_Data_Location; staticSobekcmLocation = String.Empty; tracer = new Custom_Tracer(); assistant = new SobekCM_Assistant(); // Save all the objects needed by the SobekCM Library iconList = Icon_Table; translations = Translator; codeManager = Code_Manager; skinsCollection = HTML_Skin_Collection; defaultSkin = Default_Skin; // Create the mode object currentMode = new SobekCM_Navigation_Object { ViewerCode = "citation", Skin = String.Empty, Mode = Display_Mode_Enum.Item_Display, Language = Web_Language_Enum.English, Base_URL = primaryWebServerUrl }; }
/// <summary> Constructor for a new instance of the Citation_ItemViewer class </summary> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="User_Can_Edit_Item"> Flag indicates if the current user can edit the citation information </param> public Citation_ItemViewer(Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, bool User_Can_Edit_Item ) { translator = Translator; this.Code_Manager = Code_Manager; userCanEditItem = User_Can_Edit_Item; citationType = Citation_Type.Standard; }
/// <summary> Constructor for a new instancee of the Print_Item_HtmlSubwriter class </summary> /// <param name="Current_Item">Current item to display </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</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> public Print_Item_HtmlSubwriter(SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode ) { currentMode = Current_Mode; currentItem = Current_Item; codeManager = Code_Manager; translations = Translator; }
/// <summary> Constructor for a new instance of the Search_Results_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, 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="Translator"> Language support object which handles simple translational duties </param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Current_User"> Currently logged on user </param> public Search_Results_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Language_Support_Info Translator, Item_Lookup_Object All_Items_Lookup, User_Object Current_User) { currentUser = Current_User; pagedResults = Paged_Results; resultsStatistics = Results_Statistics; translations = Translator; codeManager = Code_Manager; allItemsTable = All_Items_Lookup; }
/// <summary> Constructor for a new instance of the DataSet_Browse_Info_AggregationViewer class </summary> /// <param name="Browse_Object"> Browse or information object to be displayed </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Code_Manager"> Code manager object maintains mapping between SobekCM codes and greenstone codes (used by result_dataset_html_subwriter)</param> /// <param name="Item_List"> Object for pulling additional information about each item during display </param> /// <param name="Current_User"> Currently logged on user, or NULL </param> public DataSet_Browse_Info_AggregationViewer(Item_Aggregation_Browse_Info Browse_Object, Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object Item_List, User_Object Current_User) : base(null, null) { browseObject = Browse_Object; codeManager = Code_Manager; itemList = Item_List; currentUser = Current_User; resultsStatistics = Results_Statistics; pagedResults = Paged_Results; }
/// <summary> Constructor for a new instance of the SobekCM_Navigation_Object which stores /// all of the information about an individual request. </summary> /// <param name="QueryString">Query string information for analysis</param> /// <param name="Base_URL"> Requested base URL (without query string, etc..)</param> /// <param name="User_Languages"> Languages preferred by user, per their browser settings </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library</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 SobekCM_Navigation_Object(NameValueCollection QueryString, string Base_URL, string[] User_Languages, Aggregation_Code_Manager Code_Manager, Dictionary<string, string> Aggregation_Aliases, ref Item_Lookup_Object All_Items_Lookup, Portal_List URL_Portals, Custom_Tracer Tracer ) { // Do general item construction Constructor_Helper(); // If there is a mode value or an aggregation value, use the legacy query string analyzer if ((QueryString["m"] != null) || (QueryString["a"] != null) || (QueryString["c"] != null) || (QueryString["s"] != null) || (QueryString["g"] != null) || (QueryString["h"] != null) || (QueryString["i"] != null)) { // Use the legacy query string analyzer SobekCM_QueryString_Analyzer_Legacy analyzerLegacy = new SobekCM_QueryString_Analyzer_Legacy(); analyzerLegacy.Parse_Query(QueryString, this, Base_URL, User_Languages, Code_Manager, Aggregation_Aliases, ref All_Items_Lookup, URL_Portals, Tracer); } else { // Analyze the query string with the default analyzer SobekCM_QueryString_Analyzer analyzer = new SobekCM_QueryString_Analyzer(); analyzer.Parse_Query(QueryString, this, Base_URL, User_Languages, Code_Manager, Aggregation_Aliases, ref All_Items_Lookup, URL_Portals, Tracer); } }
/// <summary> Verifies that each global object is built and builds them upon request </summary> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Reload_All"> Flag indicates if everything should be reloaded/repopulated</param> /// <param name="Skins"> [REF] Collection of all the web skins </param> /// <param name="Translator"> [REF] Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> [REF] List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Icon_Dictionary"> [REF] Dictionary of information about every wordmark/icon in this digital library </param> /// <param name="Stats_Date_Range"> [REF] Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> [REF] Headings under which all the highlighted collections on the main home page are organized </param> /// <param name="Aggregation_Aliases"> [REF] List of all existing aliases for existing aggregations </param> /// <param name="IP_Restrictions"> [REF] List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> [REF] List of all web portals into this system </param> /// <param name="Mime_Types">[REF] Dictionary of MIME types by extension</param> public static void Build_Application_State(Custom_Tracer Tracer, bool Reload_All, ref SobekCM_Skin_Collection Skins, ref Language_Support_Info Translator, ref Aggregation_Code_Manager Code_Manager, ref Item_Lookup_Object All_Items_Lookup, ref Dictionary<string, Wordmark_Icon> Icon_Dictionary, ref Statistics_Dates Stats_Date_Range, ref List<Thematic_Heading> Thematic_Headings, ref Dictionary<string, string> Aggregation_Aliases, ref IP_Restriction_Ranges IP_Restrictions, ref Portal_List URL_Portals, ref Dictionary<string, Mime_Type_Info> Mime_Types, ref List<string> Item_Viewer_Priority ) { // Should we reload the data from the exteral configuraiton file? if (Reload_All) { SobekCM_Library_Settings.Read_Configuration_File(); if ( SobekCM_Library_Settings.Database_Connections.Count > 0 ) SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connections[0].Connection_String; SobekCM_Library_Settings.Refresh(SobekCM_Database.Get_Settings_Complete(null)); } // If there is no database connection string, there is a problem if ((SobekCM_Library_Settings.Database_Connections.Count == 0) || (String.IsNullOrEmpty(SobekCM_Library_Settings.Database_Connections[0].Connection_String))) { throw new ApplicationException("Missing database connection string!"); } // Set the database connection strings Resource_Object.Database.SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connections[0].Connection_String; SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connections[0].Connection_String; // Set the workflow and disposition types if ((SobekCM_Library_Settings.Need_Workflow_And_Disposition_Types) || ( Reload_All )) { SobekCM_Library_Settings.Set_Workflow_And_Disposition_Types(SobekCM_Database.All_WorkFlow_Types, SobekCM_Database.All_Possible_Disposition_Types); } // Set the metadata types if ((SobekCM_Library_Settings.Need_Metadata_Types) || ( Reload_All )) { SobekCM_Library_Settings.Set_Metadata_Types(SobekCM_Database.Get_Metadata_Fields(null) ); } // Set the search stop words if ((SobekCM_Library_Settings.Need_Search_Stop_Words) || (Reload_All)) { SobekCM_Library_Settings.Search_Stop_Words = SobekCM_Database.Search_Stop_Words(Tracer); } // Check the list of thematic headings if ((Thematic_Headings == null) || (Reload_All)) { if (Thematic_Headings != null) { lock (Thematic_Headings) { if (!SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer)) { Thematic_Headings = null; throw SobekCM_Database.Last_Exception; } } } else { Thematic_Headings = new List<Thematic_Heading>(); if (!SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer)) { Thematic_Headings = null; throw SobekCM_Database.Last_Exception; } } } // Check the list of forwardings if ((Aggregation_Aliases == null) || (Reload_All)) { if (Aggregation_Aliases != null) { lock (Aggregation_Aliases) { SobekCM_Database.Populate_Aggregation_Aliases(Aggregation_Aliases, Tracer); } } else { Aggregation_Aliases = new Dictionary<string, string>(); SobekCM_Database.Populate_Aggregation_Aliases(Aggregation_Aliases, Tracer); } } // Check the list of constant skins if ((Skins == null) || (Skins.Count == 0) || (Reload_All)) { if (Skins != null) { lock (Skins) { SobekCM_Skin_Collection_Builder.Populate_Default_Skins(Skins, Tracer); } } else { Skins = new SobekCM_Skin_Collection(); SobekCM_Skin_Collection_Builder.Populate_Default_Skins(Skins, Tracer); } } // Check the list of all web portals if ((URL_Portals == null) || (URL_Portals.Count == 0) || (Reload_All)) { if (URL_Portals != null) { lock (URL_Portals) { SobekCM_Database.Populate_URL_Portals(URL_Portals, Tracer); } } else { URL_Portals = new Portal_List(); SobekCM_Database.Populate_URL_Portals(URL_Portals, Tracer); } } // Check the translation table has been loaded if (( Translator == null) || (Reload_All)) { // Get the translation hashes into memory if (Translator != null) { lock (Translator) { SobekCM_Database.Populate_Translations(Translator, Tracer); } } else { Translator = new Language_Support_Info(); SobekCM_Database.Populate_Translations(Translator, Tracer); } } // Check that the conversion from SobekCM Codes to Greenstone Codes has been loaded if ((Code_Manager == null) || (Reload_All)) { if (Code_Manager != null) { lock (Code_Manager) { SobekCM_Database.Populate_Code_Manager(Code_Manager, Tracer); } } else { Code_Manager = new Aggregation_Code_Manager(); SobekCM_Database.Populate_Code_Manager(Code_Manager, Tracer); } } // Check the statistics date range information if ((Stats_Date_Range == null) || (Reload_All)) { if (Stats_Date_Range != null) { // Get the translation hashes into memory lock (Stats_Date_Range) { SobekCM_Database.Populate_Statistics_Dates(Stats_Date_Range, Tracer); } } else { Stats_Date_Range = new Statistics_Dates(); SobekCM_Database.Populate_Statistics_Dates(Stats_Date_Range, Tracer); } } // Get the Icon list if ((Icon_Dictionary == null) || ( Reload_All )) { if (Icon_Dictionary != null) { // Get the translation hashes into memory lock (Icon_Dictionary) { SobekCM_Database.Populate_Icon_List(Icon_Dictionary, Tracer); } } else { Icon_Dictionary = new Dictionary<string, Wordmark_Icon>(); SobekCM_Database.Populate_Icon_List(Icon_Dictionary, Tracer); } } // Check the list of ip range restrictions if ((IP_Restrictions == null) || (Reload_All)) { if (IP_Restrictions != null) { lock (IP_Restrictions) { DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer); if (ipRestrictionTbl != null) { IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl); } } } else { DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer); if (ipRestrictionTbl != null) { IP_Restrictions = new IP_Restriction_Ranges(); IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl); } } } // Get the MIME type list if ((Mime_Types == null) || (Reload_All)) { if (Mime_Types != null) { // Get the translation hashes into memory lock (Mime_Types) { SobekCM_Database.Populate_MIME_List(Mime_Types, Tracer); } } else { Mime_Types = new Dictionary<string, Mime_Type_Info>(); SobekCM_Database.Populate_MIME_List(Mime_Types, Tracer); } } // Check the list of forwardings if ((Item_Viewer_Priority == null) || (Reload_All)) { if (Item_Viewer_Priority != null) { lock (Item_Viewer_Priority) { Item_Viewer_Priority = SobekCM_Database.Get_Viewer_Priority(Tracer); } } else { Item_Viewer_Priority = SobekCM_Database.Get_Viewer_Priority(Tracer); } } // Check the IE hack CSS is loaded if ((HttpContext.Current.Application["NonIE_Hack_CSS"] == null) || (Reload_All)) { string css_file = HttpContext.Current.Server.MapPath("default/SobekCM_NonIE.css"); if (File.Exists(css_file)) { try { StreamReader reader = new StreamReader(css_file); HttpContext.Current.Application["NonIE_Hack_CSS"] = reader.ReadToEnd().Trim(); reader.Close(); } catch (Exception) { HttpContext.Current.Application["NonIE_Hack_CSS"] = "/* ERROR READING FILE: default/SobekCM_NonIE.css */"; throw; } } else { HttpContext.Current.Application["NonIE_Hack_CSS"] = String.Empty; } } }
/// <summary> Refreshes the item list and aggregation/greenstone code information from the database on a regular basis </summary> /// <param name="Code_Manager"> [REF] List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library </param> /// <returns> TRUE if successful, otherwise FALSE </returns> public static bool Refresh_Item_List_And_Aggregation_Codes(ref Aggregation_Code_Manager Code_Manager, ref Item_Lookup_Object All_Items_Lookup ) { try { // Load SobekCM Codes to Greenstone Codes conversion again if (Code_Manager != null) { lock (Code_Manager) { SobekCM_Database.Populate_Code_Manager(Code_Manager, null); } } else { Code_Manager = new Aggregation_Code_Manager(); SobekCM_Database.Populate_Code_Manager(Code_Manager, null); } //lock (item_list_lock_object) //{ // if (All_Items_Lookup == null) // All_Items_Lookup = new Item_Lookup_Object(); // // Have the database popoulate the little bit of bibid/vid information we retain // SobekCM_Database.Populate_Item_Lookup_Object(true, All_Items_Lookup, null); //} return true; } catch { return false; } }
/// <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> Sets the list of all valid codes for this element from the main aggregation table </summary> /// <param name="codeManager"> Code manager with list of all aggregations </param> internal void Add_Codes(Aggregation_Code_Manager codeManager) { codeToNameDictionary = new Dictionary<string, string>(); if (possible_select_items.Count <= 2) { SortedList<string, string> tempItemList = new SortedList<string, string>(); foreach (string thisType in codeManager.All_Types) { if (thisType.IndexOf("Institution") >= 0) { ReadOnlyCollection<Item_Aggregation_Related_Aggregations> matchingAggr = codeManager.Aggregations_By_Type(thisType); foreach (Item_Aggregation_Related_Aggregations thisAggr in matchingAggr) { if (thisAggr.Code.Length > 1) { if ((thisAggr.Code[0] == 'i') || (thisAggr.Code[0] == 'I')) { if (!tempItemList.ContainsKey(thisAggr.Code.Substring(1))) { codeToNameDictionary[thisAggr.Code.Substring(1).ToUpper()] = thisAggr.Name; tempItemList.Add(thisAggr.Code.Substring(1), thisAggr.Code.Substring(1)); } } else { if (!tempItemList.ContainsKey(thisAggr.Code)) { codeToNameDictionary[thisAggr.Code.ToUpper()] = thisAggr.Name; tempItemList.Add(thisAggr.Code, thisAggr.Code); } } } } } } IList<string> keys = tempItemList.Keys; foreach (string thisKey in keys) { possible_select_items.Add(tempItemList[thisKey].ToUpper()); } } }
/// <summary> Sets the list of all valid codes for this element from the main aggregation table </summary> /// <param name="codeManager"> Code manager with list of all aggregations </param> internal void Add_Codes(Aggregation_Code_Manager codeManager) { if (items.Count == 0) { SortedList<string, string> tempItemList = new SortedList<string, string>(); ReadOnlyCollection<Item_Aggregation_Related_Aggregations> subcollections = codeManager.All_Aggregations; foreach (Item_Aggregation_Related_Aggregations thisAggr in subcollections) { if (!tempItemList.ContainsKey(thisAggr.Code)) { tempItemList.Add(thisAggr.Code, thisAggr.Code); } } IList<string> keys = tempItemList.Keys; foreach (string thisKey in keys) { items.Add(tempItemList[thisKey].ToUpper()); } } }
/// <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="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 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, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Aliases_AdminViewer.Constructor", String.Empty); // Save the mode and settings here 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 == null ) || ((!user.Is_System_Admin) && ( !user.Is_Portal_Admin ))) { CurrentMode.Mode = Display_Mode_Enum.My_Sobek; CurrentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; CurrentMode.Redirect(); return; } // 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 (( user.Is_System_Admin ) && ( 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(); // Validate the code if (new_code.Length > 20) { actionMessage = "New alias code must be twenty characters long or less"; } else if (new_code.Length == 0) { actionMessage = "You must enter a CODE for this aggregation alias"; } else if (Code_Manager[new_code.ToUpper()] != null) { actionMessage = "Aggregation with this code already exists"; } else if (SobekCM_Library_Settings.Reserved_Keywords.Contains(new_code.ToLower())) { actionMessage = "That code is a system-reserved keyword. Try a different code."; } // 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 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; currentMode.Redirect(); return; } const string TEMPLATE_CODE = "itembehaviors"; template = Cached_Data_Manager.Retrieve_Template(TEMPLATE_CODE, 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\\" + 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; currentMode.Redirect(); } 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; currentMode.Redirect(); } }
/// <summary> Constructor creates a new instance of the Aggregation_HtmlSubwriter class </summary> /// <param name="Current_Aggregation"> 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="Translator"> Language support object which handles simple translational duties </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Paged_Results"> Paged results to display within a browse or search result </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </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="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Current_User"> Currently logged on user (or object representing the unlogged on user's preferences) </param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Aggregation_HtmlSubwriter(Item_Aggregation Current_Aggregation, SobekCM_Navigation_Object Current_Mode, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, Item_Aggregation_Child_Page Browse_Object, Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, List<Thematic_Heading> Thematic_Headings, User_Object Current_User, HTML_Based_Content Static_Web_Content, Custom_Tracer Tracer ) { currentUser = Current_User; base.Current_Aggregation = Current_Aggregation; currentMode = Current_Mode; Skin = HTML_Skin; translator = Translator; thisBrowseObject = Browse_Object; thisStaticBrowseObject = Static_Web_Content; codeManager = Code_Manager; itemList = All_Items_Lookup; thematicHeadings = Thematic_Headings; resultsStatistics = Results_Statistics; pagedResults = Paged_Results; leftButtons = String.Empty; rightButtons = String.Empty; // Check to see if the user should be able to edit the home page if ((currentMode.Mode == Display_Mode_Enum.Aggregation) && (currentMode.Aggregation_Type == Aggregation_Type_Enum.Home_Edit)) { if ( currentUser == null ) currentMode.Aggregation_Type = Aggregation_Type_Enum.Home; else { if ((!currentUser.Is_System_Admin) && (!currentUser.Is_Portal_Admin) && (!currentUser.Is_Aggregation_Admin(Current_Aggregation.Code))) { currentMode.Aggregation_Type = Aggregation_Type_Enum.Home; } } } else if ( currentMode.Aggregation_Type == Aggregation_Type_Enum.Home_Edit ) currentMode.Aggregation_Type = Aggregation_Type_Enum.Home; NameValueCollection form = HttpContext.Current.Request.Form; if ( form["item_action"] != null) { string action = form["item_action"].ToLower().Trim(); if ((action == "add_aggregation") && ( currentUser != null )) { SobekCM_Database.User_Set_Aggregation_Home_Page_Flag(currentUser.UserID, base.Current_Aggregation.Aggregation_ID, true, Tracer); currentUser.Set_Aggregation_Home_Page_Flag(base.Current_Aggregation.Code, base.Current_Aggregation.Name, true); HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", "Added aggregation to your home page"); } if (( action == "remove_aggregation") && ( currentUser != null )) { int removeAggregationID = base.Current_Aggregation.Aggregation_ID; string remove_code = base.Current_Aggregation.Code; string remove_name = base.Current_Aggregation.Name; if ((form["aggregation"] != null) && (form["aggregation"].Length > 0)) { Item_Aggregation_Related_Aggregations aggrInfo = codeManager[form["aggregation"]]; if (aggrInfo != null) { remove_code = aggrInfo.Code; removeAggregationID = aggrInfo.ID; } } SobekCM_Database.User_Set_Aggregation_Home_Page_Flag(currentUser.UserID, removeAggregationID, false, Tracer); currentUser.Set_Aggregation_Home_Page_Flag(remove_code, remove_name, false); if (currentMode.Home_Type != Home_Type_Enum.Personalized) { HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", "Removed aggregation from your home page"); } } if ((action == "private_folder") && ( currentUser != null )) { User_Folder thisFolder = currentUser.Get_Folder(form["aggregation"]); if (SobekCM_Database.Edit_User_Folder(thisFolder.Folder_ID, currentUser.UserID, -1, thisFolder.Folder_Name, false, String.Empty, Tracer) >= 0) thisFolder.isPublic = false; } if ((action == "email") && ( currentUser != null )) { string address = form["email_address"].Replace(";", ",").Trim(); string comments = form["email_comments"].Trim(); string format = form["email_format"].Trim().ToUpper(); if (address.Length > 0) { // Determine the email format bool is_html_format = format != "TEXT"; // CC: the user, unless they are already on the list string cc_list = currentUser.Email; if (address.ToUpper().IndexOf(currentUser.Email.ToUpper()) >= 0) cc_list = String.Empty; // Send the email string any_error = URL_Email_Helper.Send_Email(address, cc_list, comments, currentUser.Full_Name, currentMode.SobekCM_Instance_Abbreviation, is_html_format, HttpContext.Current.Items["Original_URL"].ToString(), base.Current_Aggregation.Name, "Collection", currentUser.UserID); HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", any_error.Length > 0 ? any_error : "Your email has been sent"); currentMode.isPostBack = true; // Do this to force a return trip (cirumnavigate cacheing) string original_url = HttpContext.Current.Items["Original_URL"].ToString(); if (original_url.IndexOf("?") < 0) HttpContext.Current.Response.Redirect(original_url + "?p=" + DateTime.Now.Millisecond, false); else HttpContext.Current.Response.Redirect(original_url + "&p=" + DateTime.Now.Millisecond, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Current_Mode.Request_Completed = true; return; } } } if (( currentMode.Aggregation_Type == Aggregation_Type_Enum.Home_Edit ) && ( form["sbkAghsw_HomeTextEdit"] != null)) { string aggregation_folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + Current_Aggregation.Code + "\\"; string file = aggregation_folder + Current_Aggregation.Home_Page_File(currentMode.Language); // Make a backup from today, if none made yet if (File.Exists(file)) { DateTime lastWrite = (new FileInfo(file)).LastWriteTime; string new_file = file.ToLower().Replace(".txt", "").Replace(".html", "").Replace(".htm", "") + lastWrite.Year + lastWrite.Month.ToString().PadLeft(2, '0') + lastWrite.Day.ToString() .PadLeft(2, '0')+ ".bak"; if (File.Exists(new_file)) File.Delete(new_file); File.Move(file, new_file); } // Write to the file now StreamWriter homeWriter = new StreamWriter(file, false); homeWriter.WriteLine(form["sbkAghsw_HomeTextEdit"]); homeWriter.Flush(); homeWriter.Close(); // Also save this change SobekCM_Database.Save_Item_Aggregation_Milestone(Current_Aggregation.Code, "Home page edited (" + Web_Language_Enum_Converter.Enum_To_Name(currentMode.Language) + ")", currentUser.Full_Name); // Clear this aggreation from the cache Cached_Data_Manager.Remove_Item_Aggregation(Current_Aggregation.Code, Tracer); // If this is all, save the new text as well. if (String.Compare("all", Current_Aggregation.Code, StringComparison.OrdinalIgnoreCase) == 0) { HttpContext.Current.Application["SobekCM_Home"] = form["sbkAghsw_HomeTextEdit"]; } // Forward along currentMode.Aggregation_Type = Aggregation_Type_Enum.Home; string redirect_url = currentMode.Redirect_URL(); if (redirect_url.IndexOf("?") > 0) redirect_url = redirect_url + "&refresh=always"; else redirect_url = redirect_url + "?refresh=always"; currentMode.Request_Completed = true; HttpContext.Current.Response.Redirect(redirect_url, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } // If this is a search, verify it is a valid search type if (currentMode.Mode == Display_Mode_Enum.Search) { // Not every collection has every search type... ReadOnlyCollection<Search_Type_Enum> possibleSearches = base.Current_Aggregation.Search_Types; if (!possibleSearches.Contains(currentMode.Search_Type)) { bool found_valid = false; if ((currentMode.Search_Type == Search_Type_Enum.Full_Text) && (possibleSearches.Contains(Search_Type_Enum.dLOC_Full_Text))) { found_valid = true; currentMode.Search_Type = Search_Type_Enum.dLOC_Full_Text; } if ((!found_valid) && (currentMode.Search_Type == Search_Type_Enum.Basic) && (possibleSearches.Contains(Search_Type_Enum.Newspaper))) { found_valid = true; currentMode.Search_Type = Search_Type_Enum.Newspaper; } if (( !found_valid ) && ( possibleSearches.Count > 0 )) { found_valid = true; currentMode.Search_Type = possibleSearches[0]; } if ( !found_valid ) { currentMode.Mode = Display_Mode_Enum.Aggregation; currentMode.Aggregation_Type = Aggregation_Type_Enum.Home; } } } if (currentMode.Mode == Display_Mode_Enum.Search) { collectionViewer = AggregationViewer_Factory.Get_Viewer(currentMode.Search_Type, base.Current_Aggregation, currentMode, currentUser); } if (currentMode.Mode == Display_Mode_Enum.Aggregation) { switch (currentMode.Aggregation_Type) { case Aggregation_Type_Enum.Home: case Aggregation_Type_Enum.Home_Edit: collectionViewer = AggregationViewer_Factory.Get_Viewer(base.Current_Aggregation.Views_And_Searches[0], base.Current_Aggregation, currentMode); break; case Aggregation_Type_Enum.Browse_Info: if (resultsStatistics == null) { collectionViewer = new Static_Browse_Info_AggregationViewer(thisBrowseObject, thisStaticBrowseObject, Current_Aggregation, currentMode, Current_User); } else { collectionViewer = new DataSet_Browse_Info_AggregationViewer(thisBrowseObject, resultsStatistics, pagedResults, codeManager, itemList, currentUser); } break; case Aggregation_Type_Enum.Child_Page_Edit: collectionViewer = new Static_Browse_Info_AggregationViewer(thisBrowseObject, thisStaticBrowseObject, Current_Aggregation, currentMode, Current_User); break; case Aggregation_Type_Enum.Browse_By: collectionViewer = new Metadata_Browse_AggregationViewer(Current_Mode, Current_Aggregation, Tracer); break; case Aggregation_Type_Enum.Browse_Map: collectionViewer = new Map_Browse_AggregationViewer(Current_Mode, Current_Aggregation, Tracer); break; case Aggregation_Type_Enum.Browse_Map_Beta: collectionViewer = new Map_Browse_AggregationViewer_Beta(Current_Mode, Current_Aggregation, Tracer); break; case Aggregation_Type_Enum.Item_Count: collectionViewer = new Item_Count_AggregationViewer(Current_Mode, Current_Aggregation); break; case Aggregation_Type_Enum.Usage_Statistics: collectionViewer = new Usage_Statistics_AggregationViewer(Current_Mode, Current_Aggregation); break; case Aggregation_Type_Enum.Private_Items: collectionViewer = new Private_Items_AggregationViewer(Current_Mode, Current_Aggregation, Tracer); break; } } // If execution should end, do it now if (currentMode.Request_Completed) return; if (collectionViewer != null) { collectionViewer.Translator = translator; collectionViewer.HTML_Skin = HTML_Skin; collectionViewer.CurrentMode = Current_Mode; collectionViewer.CurrentObject = Current_Aggregation; collectionViewer.Current_User = Current_User; // Pull the standard values switch (collectionViewer.Selection_Panel_Display) { case Selection_Panel_Display_Enum.Selectable: if (form["show_subaggrs"] != null) { string show_subaggrs = form["show_subaggrs"].ToUpper(); if (show_subaggrs == "TRUE") currentMode.Show_Selection_Panel = true; } break; case Selection_Panel_Display_Enum.Always: currentMode.Show_Selection_Panel = true; break; } } }
/// <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 Users_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 edit or from reseting a user's password is handled here in the constructor </remarks> public Users_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Users_AdminViewer.Constructor", String.Empty); this.currentMode = currentMode; // Ensure the user is the system admin if ((User == null) || (!User.Is_System_Admin)) { currentMode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } // 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 editUser = null; if (currentMode.My_Sobek_SubMode.Length > 0) { try { int edit_userid = Convert.ToInt32(currentMode.My_Sobek_SubMode.Replace("a", "").Replace("b", "").Replace("c", "").Replace("v", "")); // Check this admin's session for this user object Object sessionEditUser = HttpContext.Current.Session["Edit_User_" + edit_userid]; if (sessionEditUser != null) editUser = (User_Object)sessionEditUser; else { editUser = SobekCM_Database.Get_User(edit_userid, Tracer); editUser.Should_Be_Able_To_Edit_All_Items = false; if (editUser.Editable_Regular_Expressions.Any(thisRegularExpression => thisRegularExpression == "[A-Z]{2}[A-Z|0-9]{4}[0-9]{4}")) { editUser.Should_Be_Able_To_Edit_All_Items = true; } } } catch (Exception) { actionMessage = "Error while handing your request"; } } // Determine the mode mode = Users_Admin_Mode_Enum.List_Users_And_Groups; if (editUser != null) { mode = currentMode.My_Sobek_SubMode.IndexOf("v") > 0 ? Users_Admin_Mode_Enum.View_User : Users_Admin_Mode_Enum.Edit_User; } else { currentMode.My_Sobek_SubMode = String.Empty; } // Perform post back work if (currentMode.isPostBack) { if (mode == Users_Admin_Mode_Enum.List_Users_And_Groups) { try { string reset_value = HttpContext.Current.Request.Form["admin_user_reset"]; if (reset_value.Length > 0) { int userid = Convert.ToInt32(reset_value); User_Object reset_user = SobekCM_Database.Get_User(userid, Tracer); // Create the random password StringBuilder passwordBuilder = new StringBuilder(); Random randomGenerator = new Random(DateTime.Now.Millisecond); while (passwordBuilder.Length < 12) { switch (randomGenerator.Next(0, 3)) { case 0: int randomNumber = randomGenerator.Next(65, 91); if ((randomNumber != 79) && (randomNumber != 75)) // Omit the 'O' and the 'K', confusing passwordBuilder.Append((char)randomNumber); break; case 1: int randomNumber2 = randomGenerator.Next(97, 123); if ((randomNumber2 != 111) && (randomNumber2 != 108) && (randomNumber2 != 107)) // Omit the 'o' and the 'l' and the 'k', confusing passwordBuilder.Append((char)randomNumber2); break; case 2: // Zero and one is omitted in this range, confusing int randomNumber3 = randomGenerator.Next(50, 58); passwordBuilder.Append((char)randomNumber3); break; } } string password = passwordBuilder.ToString(); // Reset this password if (!SobekCM_Database.Reset_User_Password(userid, password, true, Tracer)) { actionMessage = "ERROR reseting password"; } else { if (SobekCM_Database.Send_Database_Email(reset_user.Email, "my" + currentMode.SobekCM_Instance_Abbreviation.ToUpper() + " Password Reset", reset_user.Full_Name + ",\n\nYour my" + currentMode.SobekCM_Instance_Abbreviation.ToUpper() + " password has been reset to a temporary password. The first time you logon, you will be required to change it.\n\n\tUsername: "******"\n\tPassword: "******"\n\nYour password is case-sensitive and must be entered exactly as it appears above when logging on.\n\nIf you have any questions or problems logging on, feel free to contact us at " + SobekCM_Library_Settings.System_Email + ", or reply to this email.\n\n" + currentMode.Base_URL + "my/home\n", false, false, -1, -1)) { if ((user.UserID == 1) || (user.UserID == 2)) actionMessage = "Reset of password (" + password + ") for '" + reset_user.Full_Name + "' complete"; else actionMessage = "Reset of password for '" + reset_user.Full_Name + "' complete"; } else { if ((user.UserID == 1) || (user.UserID == 2)) actionMessage = "ERROR while sending new password (" + password + ") to '" + reset_user.Full_Name + "'!"; else actionMessage = "ERROR while sending new password to '" + reset_user.Full_Name + "'!"; } } } } catch { actionMessage = "ERROR while checking postback"; } } if ((mode == Users_Admin_Mode_Enum.Edit_User) && (editUser != null)) { // Determine which page you are on int page = 1; if (currentMode.My_Sobek_SubMode.IndexOf("b") > 0) page = 2; else if (currentMode.My_Sobek_SubMode.IndexOf("c") > 0) page = 3; // Get a reference to this form NameValueCollection form = HttpContext.Current.Request.Form; string[] getKeys = form.AllKeys; // Get the curret action string action = form["admin_user_save"]; bool successful_save = true; switch (page) { case 1: string editTemplate = "Standard"; List<string> projects = new List<string>(); List<string> templates = new List<string>(); // First, set some flags to FALSE editUser.Can_Submit = false; editUser.Is_Internal_User = false; editUser.Should_Be_Able_To_Edit_All_Items = false; editUser.Is_System_Admin = false; editUser.Is_Portal_Admin = false; editUser.Include_Tracking_In_Standard_Forms = false; // Step through each key foreach (string thisKey in getKeys) { switch (thisKey) { case "admin_user_submit": editUser.Can_Submit = true; break; case "admin_user_internal": editUser.Is_Internal_User = true; break; case "admin_user_editall": editUser.Should_Be_Able_To_Edit_All_Items = true; break; case "admin_user_deleteall": editUser.Can_Delete_All = true; break; case "admin_user_sysadmin": editUser.Is_System_Admin = true; break; case "admin_user_portaladmin": editUser.Is_Portal_Admin = true; break; case "admin_user_includetracking": editUser.Include_Tracking_In_Standard_Forms = true; break; case "admin_user_edittemplate": editTemplate = form["admin_user_edittemplate"]; break; case "admin_user_organization": editUser.Organization = form["admin_user_organization"]; break; case "admin_user_college": editUser.College = form["admin_user_college"]; break; case "admin_user_department": editUser.Department = form["admin_user_department"]; break; case "admin_user_unit": editUser.Unit = form["admin_user_unit"]; break; case "admin_user_org_code": editUser.Organization_Code = form["admin_user_org_code"]; 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_", "")); } break; } } // Determine the name for the actual edit templates from the combo box selection editUser.Edit_Template_Code = "edit"; editUser.Edit_Template_MARC_Code = "editmarc"; if (editTemplate == "internal") { editUser.Edit_Template_Code = "edit_internal"; editUser.Edit_Template_MARC_Code = "editmarc_internal"; } // Determine if the projects and templates need to be updated bool update_templates_projects = false; if ((templates.Count != editUser.Templates.Count) || (projects.Count != editUser.Default_Metadata_Sets.Count)) { update_templates_projects = true; } else { // Check all of the templates if (templates.Any(template => !editUser.Templates.Contains(template))) { update_templates_projects = true; } // Check all the projects if (!update_templates_projects) { if (projects.Any(project => !editUser.Default_Metadata_Sets.Contains(project))) { update_templates_projects = true; } } } // Update the templates and projects, if requested if (update_templates_projects) { // Get the last defaults string default_project = String.Empty; string default_template = String.Empty; if (editUser.Default_Metadata_Sets.Count > 0) default_project = editUser.Default_Metadata_Sets[0]; if (editUser.Templates.Count > 0) default_template = editUser.Templates[0]; // Now, set the user's template and projects editUser.Clear_Default_Metadata_Sets(); editUser.Clear_Templates(); foreach (string thisProject in projects) { editUser.Add_Default_Metadata_Set(thisProject, false); } foreach (string thisTemplate in templates) { editUser.Add_Template(thisTemplate, false); } // Try to add back the defaults, which won't do anything if // the old defaults aren't in the new list editUser.Set_Current_Default_Metadata(default_project); editUser.Set_Default_Template(default_template); } break; case 2: // Check the user groups for update bool update_user_groups = false; DataTable userGroup = SobekCM_Database.Get_All_User_Groups(Tracer); List<string> newGroups = new List<string>(); foreach (DataRow thisRow in userGroup.Rows) { if (form["group_" + thisRow["UserGroupID"]] != null) { newGroups.Add(thisRow["GroupName"].ToString()); } } // Should we add the new user groups? Did it change? if (newGroups.Count != editUser.User_Groups.Count) { update_user_groups = true; } else { foreach (string thisGroup in newGroups) { if (!editUser.User_Groups.Contains(thisGroup)) { update_user_groups = true; break; } } } if (update_user_groups) { editUser.Clear_UserGroup_Membership(); foreach (string thisUserGroup in newGroups) editUser.Add_User_Group(thisUserGroup); } break; case 3: Dictionary<string, User_Editable_Aggregation> aggregations = new Dictionary<string, User_Editable_Aggregation>(); // Step through each key foreach (string thisKey in getKeys) { 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, false)); } } 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, false)); } } if (thisKey.IndexOf("admin_project_editall_") == 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, false)); } } if (thisKey.IndexOf("admin_project_edit_metadata_") == 0) { string edit_project = thisKey.Replace("admin_project_edit_metadata_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanEditMetadata = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanEditMetadata = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_edit_behavior_") == 0) { string edit_project = thisKey.Replace("admin_project_edit_behavior_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanEditBehaviors = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanEditBehaviors = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_perform_qc_") == 0) { string edit_project = thisKey.Replace("admin_project_perform_qc_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanPerformQc = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanPerformQc = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_upload_files_") == 0) { string edit_project = thisKey.Replace("admin_project_upload_files_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanUploadFiles = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanUploadFiles = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_change_visibility_") == 0) { string edit_project = thisKey.Replace("admin_project_change_visibility_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanChangeVisibility = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanChangeVisibility = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_can_delete_") == 0) { string edit_project = thisKey.Replace("admin_project_can_delete_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanDelete = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanDelete = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_curator_") == 0) { string admin_project = thisKey.Replace("admin_project_curator_", ""); 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, false)); } } if (thisKey.IndexOf("admin_project_admin_") == 0) { string admin_project = thisKey.Replace("admin_project_admin_", ""); if (aggregations.ContainsKey(admin_project)) { aggregations[admin_project].IsAdmin = true; } else { aggregations.Add(admin_project, new User_Editable_Aggregation(admin_project, String.Empty, false, false, false, false, true)); } } } // Determine if the aggregations need to be edited bool update_aggregations = false; if (aggregations.Count != editUser.Aggregations.Count) { update_aggregations = true; } else { // Build a dictionary of the user aggregations as well Dictionary<string, User_Editable_Aggregation> existingAggr = editUser.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.CanEditMetadata != existingAggr[adminAggr.Code].CanEditMetadata) || (adminAggr.CanEditBehaviors != existingAggr[adminAggr.Code].CanEditBehaviors) || (adminAggr.CanPerformQc != existingAggr[adminAggr.Code].CanPerformQc) || (adminAggr.CanUploadFiles != existingAggr[adminAggr.Code].CanUploadFiles) || (adminAggr.CanChangeVisibility != existingAggr[adminAggr.Code].CanChangeVisibility) || (adminAggr.CanDelete != existingAggr[adminAggr.Code].CanDelete) || (adminAggr.IsCurator != existingAggr[adminAggr.Code].IsCurator) || (adminAggr.OnHomePage != existingAggr[adminAggr.Code].OnHomePage)) { update_aggregations = true; break; } } else { update_aggregations = true; break; } } } // Update the aggregations, if requested if (update_aggregations) { editUser.Clear_Aggregations(); if (aggregations.Count > 0) { foreach (User_Editable_Aggregation dictionaryAggregation in aggregations.Values) { editUser.Add_Aggregation(dictionaryAggregation.Code, dictionaryAggregation.Name, dictionaryAggregation.CanSelect, dictionaryAggregation.CanEditMetadata, dictionaryAggregation.CanEditBehaviors, dictionaryAggregation.CanPerformQc, dictionaryAggregation.CanUploadFiles, dictionaryAggregation.CanChangeVisibility, dictionaryAggregation.CanDelete, dictionaryAggregation.IsCurator, dictionaryAggregation.OnHomePage, dictionaryAggregation.IsAdmin, false); } } } break; } // Should this be saved to the database? if (action == "save") { // Save this user SobekCM_Database.Save_User(editUser, String.Empty, user.Authentication_Type, Tracer); // Update the basic user information SobekCM_Database.Update_SobekCM_User(editUser.UserID, editUser.Can_Submit, editUser.Is_Internal_User, editUser.Should_Be_Able_To_Edit_All_Items, editUser.Can_Delete_All, editUser.Is_System_Admin, editUser.Is_Portal_Admin, editUser.Include_Tracking_In_Standard_Forms, editUser.Edit_Template_Code, editUser.Edit_Template_MARC_Code, true, true, true, Tracer); // Update projects, if necessary if (editUser.Default_Metadata_Sets.Count > 0) { if (!SobekCM_Database.Update_SobekCM_User_DefaultMetadata(editUser.UserID, editUser.Default_Metadata_Sets, Tracer)) { successful_save = false; } } // Update templates, if necessary if (editUser.Templates.Count > 0) { if (!SobekCM_Database.Update_SobekCM_User_Templates(editUser.UserID, editUser.Templates, Tracer)) { successful_save = false; } } // Save the aggregations linked to this user if (!SobekCM_Database.Update_SobekCM_User_Aggregations(editUser.UserID, editUser.Aggregations, Tracer)) { successful_save = false; } // Save the user group links DataTable userGroup = SobekCM_Database.Get_All_User_Groups(Tracer); Dictionary<string, int> groupnames_to_id = new Dictionary<string, int>(); foreach (DataRow thisRow in userGroup.Rows) { groupnames_to_id[thisRow["GroupName"].ToString()] = Convert.ToInt32(thisRow["UserGroupID"]); } foreach (string userGroupName in editUser.User_Groups) { SobekCM_Database.Link_User_To_User_Group(editUser.UserID, groupnames_to_id[userGroupName]); } // Forward back to the list of users, if this was successful if (successful_save) { // Clear the user from the sessions HttpContext.Current.Session["Edit_User_" + editUser.UserID] = null; // Redirect the user currentMode.My_Sobek_SubMode = String.Empty; currentMode.Redirect(); } } else { // Save to the admins session HttpContext.Current.Session["Edit_User_" + editUser.UserID] = editUser; currentMode.My_Sobek_SubMode = action; currentMode.Redirect(); } } } }
/// <summary> Constructor for a new instance of the SobekCM_Navigation_Object which stores /// all of the information about an individual request. </summary> /// <param name="QueryString">Query string information for analysis</param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library</param> /// <param name="URL_Portals"> List of all web portals into this system </param> public SobekCM_Navigation_Object(NameValueCollection QueryString, Aggregation_Code_Manager Code_Manager, Dictionary<string, string> Aggregation_Aliases, ref Item_Lookup_Object All_Items_Lookup, Portal_List URL_Portals) { // Do general item construction Constructor_Helper(); // Analyze the query string with the default analyzer SobekCM_QueryString_Analyzer analyzer = new SobekCM_QueryString_Analyzer(); analyzer.Parse_Query(QueryString, this, String.Empty, null, Code_Manager, Aggregation_Aliases, ref All_Items_Lookup, URL_Portals, null); }
/// <summary> Constructor for a new instance of the SobekCM_Navigation_Object which stores /// all of the information about an individual request. </summary> /// <param name="QueryString">Query string information for analysis</param> /// <param name="Base_URL"> Requested base URL (without query string, etc..)</param> /// <param name="User_Languages"> Languages preferred by user, per their browser settings </param> /// <param name="Analyzer">Object to user for the URL analysis</param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library</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 SobekCM_Navigation_Object(NameValueCollection QueryString, string Base_URL, string[] User_Languages, iSobekCM_QueryString_Analyzer Analyzer, Aggregation_Code_Manager Code_Manager, Dictionary<string, string> Aggregation_Aliases, ref Item_Lookup_Object All_Items_Lookup, Portal_List URL_Portals, Custom_Tracer Tracer ) { // Do general item construction Constructor_Helper(); // Analyze the query string with the provided analyzer Analyzer.Parse_Query(QueryString, this, Base_URL, User_Languages, Code_Manager, Aggregation_Aliases, ref All_Items_Lookup, URL_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; currentMode.Redirect(); return; } // 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; bool is_sobek_default = false; bool is_shibboleth_default = false; bool is_ldap_default = false; 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, false)); } } 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, false)); } } if (thisKey.IndexOf("admin_project_editall_") == 0) { string edit_project = thisKey.Replace("admin_project_editall_", ""); 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, false)); } } if (thisKey.IndexOf("admin_project_edit_metadata_") == 0) { string edit_project = thisKey.Replace("admin_project_edit_metadata_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanEditMetadata = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanEditMetadata = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_edit_behavior_") == 0) { string edit_project = thisKey.Replace("admin_project_edit_behavior_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanEditBehaviors = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanEditBehaviors = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_perform_qc_") == 0) { string edit_project = thisKey.Replace("admin_project_perform_qc_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanPerformQc = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanPerformQc = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_upload_files_") == 0) { string edit_project = thisKey.Replace("admin_project_upload_files_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanUploadFiles = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanUploadFiles = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_change_visibility_") == 0) { string edit_project = thisKey.Replace("admin_project_change_visibility_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanChangeVisibility = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanChangeVisibility = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_can_delete_") == 0) { string edit_project = thisKey.Replace("admin_project_can_delete_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanDelete = true; } else { User_Editable_Aggregation thisAggrLink = new User_Editable_Aggregation(edit_project, String.Empty, false, false, false, false, false); thisAggrLink.CanDelete = true; aggregations.Add(edit_project, thisAggrLink); } } if (thisKey.IndexOf("admin_project_curator_") == 0) { string admin_project = thisKey.Replace("admin_project_curator_", ""); 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, false)); } } if (thisKey.IndexOf("admin_project_admin_") == 0) { string admin_project = thisKey.Replace("admin_project_admin_", ""); if (aggregations.ContainsKey(admin_project)) { aggregations[admin_project].IsAdmin = true; } else { aggregations.Add(admin_project, new User_Editable_Aggregation(admin_project, String.Empty, false, false, false, false, true)); } } 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.Default_Metadata_Sets.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.Default_Metadata_Sets.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.CanEditMetadata != existingAggr[adminAggr.Code].CanEditMetadata) || (adminAggr.CanEditBehaviors != existingAggr[adminAggr.Code].CanEditBehaviors) || (adminAggr.CanPerformQc != existingAggr[adminAggr.Code].CanPerformQc) || (adminAggr.CanUploadFiles != existingAggr[adminAggr.Code].CanUploadFiles) || (adminAggr.CanChangeVisibility != existingAggr[adminAggr.Code].CanChangeVisibility) || (adminAggr.CanDelete != existingAggr[adminAggr.Code].CanDelete) || (adminAggr.IsCurator != existingAggr[adminAggr.Code].IsCurator) || (adminAggr.OnHomePage != existingAggr[adminAggr.Code].OnHomePage)) { 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, is_sobek_default, is_shibboleth_default, is_ldap_default, 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_DefaultMetadata(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; currentMode.Redirect(); } } } }
/// <summary> Constructor for a new instance of the Tracking_ItemViewer class </summary> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="User_Can_Edit_Item"> Flag indicates if the current user can edit the citation information </param> public Tracking_ItemViewer(Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, bool User_Can_Edit_Item) { translator = Translator; this.Code_Manager = Code_Manager; userCanEditItem = User_Can_Edit_Item; }
/// <summary> Constructor creates a new instance of the Aggregation_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="Translator"> Language support object which handles simple translational duties </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Paged_Results"> Paged results to display within a browse or search result </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </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="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="IP_Restrictions"> IP restrictions, used to determine if a user has access to a particular item </param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Aggregation_HtmlSubwriter(Item_Aggregation Hierarchy_Object, SobekCM_Navigation_Object Current_Mode, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, Item_Aggregation_Browse_Info Browse_Object, Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, List<Thematic_Heading> Thematic_Headings, User_Object Current_User, IP_Restriction_Ranges IP_Restrictions, HTML_Based_Content Static_Web_Content, Custom_Tracer Tracer ) { currentUser = Current_User; base.Hierarchy_Object = Hierarchy_Object; currentMode = Current_Mode; Skin = HTML_Skin; translator = Translator; thisBrowseObject = Browse_Object; thisStaticBrowseObject = Static_Web_Content; codeManager = Code_Manager; itemList = All_Items_Lookup; thematicHeadings = Thematic_Headings; ipRestrictions = IP_Restrictions; resultsStatistics = Results_Statistics; pagedResults = Paged_Results; NameValueCollection form = HttpContext.Current.Request.Form; if (form["item_action"] != null) { string action = form["item_action"].ToLower().Trim(); if (action == "add_aggregation") { SobekCM_Database.User_Set_Aggregation_Home_Page_Flag(currentUser.UserID, base.Hierarchy_Object.Aggregation_ID, true, Tracer); currentUser.Set_Aggregation_Home_Page_Flag(base.Hierarchy_Object.Code, base.Hierarchy_Object.Name, true); HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", "Added aggregation to your home page"); } if (action == "remove_aggregation") { int removeAggregationID = base.Hierarchy_Object.Aggregation_ID; string remove_code = base.Hierarchy_Object.Code; string remove_name = base.Hierarchy_Object.Name; if ((form["aggregation"] != null) && (form["aggregation"].Length > 0)) { Item_Aggregation_Related_Aggregations aggrInfo = codeManager[form["aggregation"]]; if (aggrInfo != null) { remove_code = aggrInfo.Code; removeAggregationID = aggrInfo.ID; } } SobekCM_Database.User_Set_Aggregation_Home_Page_Flag(currentUser.UserID, removeAggregationID, false, Tracer); currentUser.Set_Aggregation_Home_Page_Flag(remove_code, remove_name, false); if (currentMode.Home_Type != Home_Type_Enum.Personalized) { HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", "Removed aggregation from your home page"); } } if (action == "private_folder") { User_Folder thisFolder = currentUser.Get_Folder(form["aggregation"]); if (SobekCM_Database.Edit_User_Folder(thisFolder.Folder_ID, currentUser.UserID, -1, thisFolder.Folder_Name, false, String.Empty, Tracer) >= 0) thisFolder.isPublic = false; } if (action == "email") { string address = form["email_address"].Replace(";", ",").Trim(); string comments = form["email_comments"].Trim(); string format = form["email_format"].Trim().ToUpper(); if (address.Length > 0) { // Determine the email format bool is_html_format = true; if (format == "TEXT") is_html_format = false; // CC: the user, unless they are already on the list string cc_list = currentUser.Email; if (address.ToUpper().IndexOf(currentUser.Email.ToUpper()) >= 0) cc_list = String.Empty; // Send the email string any_error = URL_Email_Helper.Send_Email(address, cc_list, comments, currentUser.Full_Name, currentMode.SobekCM_Instance_Abbreviation, is_html_format, HttpContext.Current.Items["Original_URL"].ToString(), base.Hierarchy_Object.Name, "home"); HttpContext.Current.Session.Add("ON_LOAD_MESSAGE", any_error.Length > 0 ? any_error : "Your email has been sent"); currentMode.isPostBack = true; // Do this to force a return trip (cirumnavigate cacheing) string original_url = HttpContext.Current.Items["Original_URL"].ToString(); if (original_url.IndexOf("?") < 0) HttpContext.Current.Response.Redirect(original_url + "?p=" + DateTime.Now.Millisecond, false); else HttpContext.Current.Response.Redirect(original_url + "&p=" + DateTime.Now.Millisecond, false); } } } // If this is a search, verify it is a valid search type if (currentMode.Mode == Display_Mode_Enum.Search) { // Not every collection has every search type... ReadOnlyCollection<Search_Type_Enum> possibleSearches = base.Hierarchy_Object.Search_Types; if (!possibleSearches.Contains(currentMode.Search_Type)) { bool found_valid = false; if ((currentMode.Search_Type == Search_Type_Enum.Full_Text) && (possibleSearches.Contains(Search_Type_Enum.dLOC_Full_Text))) { found_valid = true; currentMode.Search_Type = Search_Type_Enum.dLOC_Full_Text; } if ((!found_valid) && (currentMode.Search_Type == Search_Type_Enum.Basic) && (possibleSearches.Contains(Search_Type_Enum.Newspaper))) { found_valid = true; currentMode.Search_Type = Search_Type_Enum.Newspaper; } if (( !found_valid ) && ( possibleSearches.Count > 0 )) { found_valid = true; currentMode.Search_Type = possibleSearches[0]; } if ( !found_valid ) { currentMode.Mode = Display_Mode_Enum.Aggregation_Home; } } } if (currentMode.Mode == Display_Mode_Enum.Search) { collectionViewer = AggregationViewer_Factory.Get_Viewer(currentMode.Search_Type, base.Hierarchy_Object, currentMode, currentUser); } if (currentMode.Mode == Display_Mode_Enum.Aggregation_Home) { collectionViewer = AggregationViewer_Factory.Get_Viewer(base.Hierarchy_Object.Views_And_Searches[0], base.Hierarchy_Object, currentMode); } if (currentMode.Mode == Display_Mode_Enum.Aggregation_Browse_Info) { if ( resultsStatistics == null ) { collectionViewer = new Static_Browse_Info_AggregationViewer(thisBrowseObject, thisStaticBrowseObject); } else { collectionViewer = new DataSet_Browse_Info_AggregationViewer(thisBrowseObject, resultsStatistics, pagedResults, codeManager, itemList, currentUser ); } } if (currentMode.Mode == Display_Mode_Enum.Aggregation_Browse_By) { collectionViewer = new Metadata_Browse_AggregationViewer( Current_Mode, Hierarchy_Object, Tracer ); } if (currentMode.Mode == Display_Mode_Enum.Aggregation_Browse_Map) { collectionViewer = new Map_Browse_AggregationViewer(Current_Mode, Hierarchy_Object, Tracer); } if (currentMode.Mode == Display_Mode_Enum.Aggregation_Item_Count) { collectionViewer = new Item_Count_AggregationViewer(Current_Mode, Hierarchy_Object); } if (currentMode.Mode == Display_Mode_Enum.Aggregation_Usage_Statistics) { collectionViewer = new Usage_Statistics_AggregationViewer(Current_Mode, Hierarchy_Object); } if (currentMode.Mode == Display_Mode_Enum.Aggregation_Private_Items) { collectionViewer = new Private_Items_AggregationViewer(Current_Mode, Hierarchy_Object, Tracer); } if (currentMode.Mode == Display_Mode_Enum.Aggregation_Admin_View) { collectionViewer = new Admin_AggregationViewer(Hierarchy_Object); } if (collectionViewer != null) { collectionViewer.Translator = translator; collectionViewer.HTML_Skin = HTML_Skin; collectionViewer.CurrentMode = Current_Mode; collectionViewer.CurrentObject = Hierarchy_Object; collectionViewer.Current_User = Current_User; // Pull the standard values switch (collectionViewer.Selection_Panel_Display) { case Selection_Panel_Display_Enum.Selectable: if (form["show_subaggrs"] != null) { string show_subaggrs = form["show_subaggrs"].ToUpper(); if (show_subaggrs == "TRUE") currentMode.Show_Selection_Panel = true; } break; case Selection_Panel_Display_Enum.Always: currentMode.Show_Selection_Panel = true; break; } } }
/// <summary> Verifies that each global object is built and builds them upon request </summary> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Reload_All"> Flag indicates if everything should be reloaded/repopulated</param> /// <param name="Skins"> [REF] Collection of all the web skins </param> /// <param name="Translator"> [REF] Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> [REF] List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Icon_Dictionary"> [REF] Dictionary of information about every wordmark/icon in this digital library </param> /// <param name="Stats_Date_Range"> [REF] Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> [REF] Headings under which all the highlighted collections on the main home page are organized </param> /// <param name="Aggregation_Aliases"> [REF] List of all existing aliases for existing aggregations </param> /// <param name="IP_Restrictions"> [REF] List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> [REF] List of all web portals into this system </param> /// <param name="Mime_Types">[REF] Dictionary of MIME types by extension</param> public static void Build_Application_State(Custom_Tracer Tracer, bool Reload_All, ref SobekCM_Skin_Collection Skins, ref Language_Support_Info Translator, ref Aggregation_Code_Manager Code_Manager, ref Item_Lookup_Object All_Items_Lookup, ref Dictionary <string, Wordmark_Icon> Icon_Dictionary, ref Statistics_Dates Stats_Date_Range, ref List <Thematic_Heading> Thematic_Headings, ref Dictionary <string, string> Aggregation_Aliases, ref IP_Restriction_Ranges IP_Restrictions, ref Portal_List URL_Portals, ref Dictionary <string, Mime_Type_Info> Mime_Types) { // Should we reload the data from the exteral configuraiton file? if (Reload_All) { SobekCM_Library_Settings.Read_Configuration_File(); SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connection_String; SobekCM_Library_Settings.Refresh(SobekCM_Database.Get_Settings_Complete(null)); } // If there is no database connection string, there is a problem if (String.IsNullOrEmpty(SobekCM_Library_Settings.Database_Connection_String)) { throw new ApplicationException("Missing database connection string!"); } // Set the database connection strings Resource_Object.Database.SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connection_String; SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connection_String; // Set the workflow and disposition types if ((SobekCM_Library_Settings.Need_Workflow_And_Disposition_Types) || (Reload_All)) { SobekCM_Library_Settings.Set_Workflow_And_Disposition_Types(SobekCM_Database.All_WorkFlow_Types, SobekCM_Database.All_Possible_Disposition_Types); } // Set the metadata types if ((SobekCM_Library_Settings.Need_Metadata_Types) || (Reload_All)) { SobekCM_Library_Settings.Set_Metadata_Types(SobekCM_Database.Get_Metadata_Fields(null)); } // Set the search stop words if ((SobekCM_Library_Settings.Need_Search_Stop_Words) || (Reload_All)) { SobekCM_Library_Settings.Search_Stop_Words = SobekCM_Database.Search_Stop_Words(Tracer); } // Check the list of thematic headings if ((Thematic_Headings == null) || (Reload_All)) { if (Thematic_Headings != null) { lock (Thematic_Headings) { if (!SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer)) { Thematic_Headings = null; throw SobekCM_Database.Last_Exception; } } } else { Thematic_Headings = new List <Thematic_Heading>(); if (!SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer)) { Thematic_Headings = null; throw SobekCM_Database.Last_Exception; } } } // Check the list of forwardings if ((Aggregation_Aliases == null) || (Reload_All)) { if (Aggregation_Aliases != null) { lock (Aggregation_Aliases) { SobekCM_Database.Populate_Aggregation_Aliases(Aggregation_Aliases, Tracer); } } else { Aggregation_Aliases = new Dictionary <string, string>(); SobekCM_Database.Populate_Aggregation_Aliases(Aggregation_Aliases, Tracer); } } // Check the list of constant skins if ((Skins == null) || (Skins.Count == 0) || (Reload_All)) { if (Skins != null) { lock (Skins) { SobekCM_Skin_Collection_Builder.Populate_Default_Skins(Skins, Tracer); } } else { Skins = new SobekCM_Skin_Collection(); SobekCM_Skin_Collection_Builder.Populate_Default_Skins(Skins, Tracer); } } // Check the list of all web portals if ((URL_Portals == null) || (URL_Portals.Count == 0) || (Reload_All)) { if (URL_Portals != null) { lock (URL_Portals) { SobekCM_Database.Populate_URL_Portals(URL_Portals, Tracer); } } else { URL_Portals = new Portal_List(); SobekCM_Database.Populate_URL_Portals(URL_Portals, Tracer); } } // Check the translation table has been loaded if ((Translator == null) || (Reload_All)) { // Get the translation hashes into memory if (Translator != null) { lock (Translator) { SobekCM_Database.Populate_Translations(Translator, Tracer); } } else { Translator = new Language_Support_Info(); SobekCM_Database.Populate_Translations(Translator, Tracer); } } // Check that the conversion from SobekCM Codes to Greenstone Codes has been loaded if ((Code_Manager == null) || (Reload_All)) { if (Code_Manager != null) { lock (Code_Manager) { SobekCM_Database.Populate_Code_Manager(Code_Manager, Tracer); } } else { Code_Manager = new Aggregation_Code_Manager(); SobekCM_Database.Populate_Code_Manager(Code_Manager, Tracer); } } // Check the statistics date range information if ((Stats_Date_Range == null) || (Reload_All)) { if (Stats_Date_Range != null) { // Get the translation hashes into memory lock (Stats_Date_Range) { SobekCM_Database.Populate_Statistics_Dates(Stats_Date_Range, Tracer); } } else { Stats_Date_Range = new Statistics_Dates(); SobekCM_Database.Populate_Statistics_Dates(Stats_Date_Range, Tracer); } } // Get the Icon list if ((Icon_Dictionary == null) || (Reload_All)) { if (Icon_Dictionary != null) { // Get the translation hashes into memory lock (Icon_Dictionary) { SobekCM_Database.Populate_Icon_List(Icon_Dictionary, Tracer); } } else { Icon_Dictionary = new Dictionary <string, Wordmark_Icon>(); SobekCM_Database.Populate_Icon_List(Icon_Dictionary, Tracer); } } // Check the list of ip range restrictions if ((IP_Restrictions == null) || (Reload_All)) { if (IP_Restrictions != null) { lock (IP_Restrictions) { DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer); if (ipRestrictionTbl != null) { IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl); } } } else { DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer); if (ipRestrictionTbl != null) { IP_Restrictions = new IP_Restriction_Ranges(); IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl); } } } // Get the MIME type list if ((Mime_Types == null) || (Reload_All)) { if (Mime_Types != null) { // Get the translation hashes into memory lock (Mime_Types) { SobekCM_Database.Populate_MIME_List(Mime_Types, Tracer); } } else { Mime_Types = new Dictionary <string, Mime_Type_Info>(); SobekCM_Database.Populate_MIME_List(Mime_Types, Tracer); } } }
/// <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="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </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, SobekCM_Skin_Collection HTML_Skin_Collection, 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; skins = HTML_Skin_Collection; // 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; currentMode.Redirect(); return; } // 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; currentMode.Redirect(); } 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, null, 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; saveItem.Bib_Info.Location.PURL = String.Empty; saveItem.Behaviors.Main_Thumbnail = String.Empty; saveItem.METS_Header.Create_Date = DateTime.Now; saveItem.METS_Header.Modify_Date = saveItem.METS_Header.Create_Date; saveItem.METS_Header.Creator_Software = "SobekCM Web - Online add a volume (derived from VID " + vid + ")"; saveItem.METS_Header.Clear_Creator_Individual_Notes(); saveItem.METS_Header.Creator_Individual = user.Full_Name; saveItem.Bib_Info.Location.Other_URL = String.Empty; saveItem.Bib_Info.Location.Other_URL_Display_Label = String.Empty; saveItem.Bib_Info.Location.Other_URL_Note = 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; currentMode.Redirect(); 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": currentMode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.File_Management; currentMode.VID = saveItem.VID; currentMode.Redirect(); break; default: currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.VID = saveItem.VID; currentMode.Redirect(); 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 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="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 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, Aggregation_Code_Manager Code_Manager, 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.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } // 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; int newid = SobekCM_Database.Edit_Thematic_Heading(-1, new_order, save_value, Tracer); if ( newid < 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); } // Add this blank thematic heading to the code manager Code_Manager.Add_Blank_Thematic_Heading(newid); 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 Text_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Item_List"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Search_History"> List of recent searches performed against this digital library </param> /// <param name="Icon_Dictionary"> Dictionary of information about every wordmark/icon in this digital library, used to build the wordmarks subpage </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the main home page are organized </param> /// <param name="Public_Folder"> Object contains the information about the public folder to display </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="Checked_Items"> List of all items which are currently checked out for single fair use and the IP address currently viewing the item</param> /// <param name="IP_Restrictions"> Any possible restriction on item access by IP ranges </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Site_Map"> Optional site map object used to render a navigational tree-view on left side of static web content pages </param> /// <param name="Items_In_Title"> List of items within the current title ( used for the Item Group display )</param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Html_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Item_Aggregation_Child_Page Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, SobekCM_Skin_Object HTML_Skin, User_Object Current_User, Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object Item_List, Statistics_Dates Stats_Date_Range, Recent_Searches Search_History, Dictionary<string, Wordmark_Icon> Icon_Dictionary, List<Thematic_Heading> Thematic_Headings, Public_User_Folder Public_Folder, Dictionary<string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, Checked_Out_Items_List Checked_Items, IP_Restriction_Ranges IP_Restrictions, Portal_List URL_Portals, SobekCM_SiteMap Site_Map, SobekCM_Items_In_Title Items_In_Title, HTML_Based_Content Static_Web_Content, Custom_Tracer Tracer ) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, Static_Web_Content) { // Save parameters htmlSkin = HTML_Skin; translator = Translator; codeManager = Code_Manager; itemList = Item_List; statsDateRange = Stats_Date_Range; searchHistory = Search_History; currentUser = Current_User; iconList = Icon_Dictionary; thematicHeadings = Thematic_Headings; publicFolder = Public_Folder; aggregationAliases = Aggregation_Aliases; webSkins = Web_Skin_Collection; checkedItems = Checked_Items; ipRestrictionInfo = IP_Restrictions; urlPortals = URL_Portals; siteMap = Site_Map; itemsInTitle = Items_In_Title; // Set some defaults // Handle basic events which may be fired by the internal header if (HttpContext.Current.Request.Form["internal_header_action"] != null) { // Pull the action value string internalHeaderAction = HttpContext.Current.Request.Form["internal_header_action"].Trim(); // Was this to hide or show the header? if ((internalHeaderAction == "hide") || (internalHeaderAction == "show")) { // Pull the current visibility from the session bool shown = !((HttpContext.Current.Session["internal_header"] != null) && (HttpContext.Current.Session["internal_header"].ToString() == "hidden")); if ((internalHeaderAction == "hide") && (shown)) { HttpContext.Current.Session["internal_header"] = "hidden"; currentMode.Redirect(); return; } if ((internalHeaderAction == "show") && (!shown)) { HttpContext.Current.Session["internal_header"] = "shown"; currentMode.Redirect(); return; } } } try { // Create the html sub writer now switch (Current_Mode.Mode) { case Display_Mode_Enum.Internal: subwriter = new Internal_HtmlSubwriter(iconList, currentUser, codeManager); break; case Display_Mode_Enum.Statistics: subwriter = new Statistics_HtmlSubwriter(searchHistory, codeManager, statsDateRange); break; case Display_Mode_Enum.Preferences: subwriter = new Preferences_HtmlSubwriter(currentMode); break; case Display_Mode_Enum.Error: subwriter = new Error_HtmlSubwriter(false); // Send the email now if (currentMode.Caught_Exception != null) { if (currentMode.Error_Message.Length == 0) currentMode.Error_Message = "Unknown exception caught"; Email_Information(currentMode.Error_Message, currentMode.Caught_Exception, Tracer, false); } break; case Display_Mode_Enum.Legacy_URL: subwriter = new LegacyUrl_HtmlSubwriter(); break; case Display_Mode_Enum.Item_Print: subwriter = new Print_Item_HtmlSubwriter(currentItem, codeManager, translator, currentMode); break; case Display_Mode_Enum.Contact: StringBuilder builder = new StringBuilder(); builder.Append("\n\nSUBMISSION INFORMATION\n"); builder.Append("\tDate:\t\t\t\t" + DateTime.Now.ToString() + "\n"); string lastMode = String.Empty; try { if (HttpContext.Current.Session["Last_Mode"] != null) lastMode = HttpContext.Current.Session["Last_Mode"].ToString(); builder.Append("\tIP Address:\t\t\t" + HttpContext.Current.Request.UserHostAddress + "\n"); builder.Append("\tHost Name:\t\t\t" + HttpContext.Current.Request.UserHostName + "\n"); builder.Append("\tBrowser:\t\t\t" + HttpContext.Current.Request.Browser.Browser + "\n"); builder.Append("\tBrowser Platform:\t\t" + HttpContext.Current.Request.Browser.Platform + "\n"); builder.Append("\tBrowser Version:\t\t" + HttpContext.Current.Request.Browser.Version + "\n"); builder.Append("\tBrowser Language:\t\t"); bool first = true; string[] languages = HttpContext.Current.Request.UserLanguages; if (languages != null) foreach (string thisLanguage in languages) { if (first) { builder.Append(thisLanguage); first = false; } else { builder.Append(", " + thisLanguage); } } builder.Append("\n\nHISTORY\n"); if (HttpContext.Current.Session["LastSearch"] != null) builder.Append("\tLast Search:\t\t" + HttpContext.Current.Session["LastSearch"] + "\n"); if (HttpContext.Current.Session["LastResults"] != null) builder.Append("\tLast Results:\t\t" + HttpContext.Current.Session["LastResults"] + "\n"); if (HttpContext.Current.Session["Last_Mode"] != null) builder.Append("\tLast Mode:\t\t\t" + HttpContext.Current.Session["Last_Mode"] + "\n"); builder.Append("\tURL:\t\t\t\t" + HttpContext.Current.Items["Original_URL"]); } catch { } subwriter = new Contact_HtmlSubwriter(lastMode, builder.ToString(), currentMode, hierarchyObject); break; case Display_Mode_Enum.Contact_Sent: subwriter = new Contact_HtmlSubwriter(String.Empty, String.Empty, currentMode, hierarchyObject); break; case Display_Mode_Enum.Simple_HTML_CMS: subwriter = new Web_Content_HtmlSubwriter(hierarchyObject, currentMode, htmlSkin, htmlBasedContent, siteMap); break; case Display_Mode_Enum.My_Sobek: subwriter = new MySobek_HtmlSubwriter(results_statistics, paged_results, codeManager, itemList, hierarchyObject, htmlSkin, translator, currentMode, currentItem, currentUser, iconList, statsDateRange, webSkins, Tracer); break; case Display_Mode_Enum.Administrative: subwriter = new Admin_HtmlSubwriter(codeManager, itemList, hierarchyObject, htmlSkin, translator, currentMode, aggregationAliases, webSkins, currentUser, ipRestrictionInfo, iconList, urlPortals, thematicHeadings, Tracer); break; case Display_Mode_Enum.Results: subwriter = new Search_Results_HtmlSubwriter(results_statistics, paged_results, codeManager, translator, itemList, currentUser); break; case Display_Mode_Enum.Public_Folder: subwriter = new Public_Folder_HtmlSubwriter(results_statistics, paged_results, codeManager, translator, itemList, currentUser, publicFolder); break; case Display_Mode_Enum.Search: case Display_Mode_Enum.Aggregation: subwriter = new Aggregation_HtmlSubwriter(hierarchyObject, currentMode, htmlSkin, translator, thisBrowseObject, results_statistics, paged_results, codeManager, itemList, thematicHeadings, currentUser, htmlBasedContent, Tracer); break; case Display_Mode_Enum.Item_Display: if ((!currentMode.Invalid_Item) && (currentItem != null)) { bool show_toc = false; if (HttpContext.Current.Session["Show TOC"] != null) { Boolean.TryParse(HttpContext.Current.Session["Show TOC"].ToString(), out show_toc); } // Check that this item is not checked out by another user bool itemCheckedOutByOtherUser = false; if (currentItem.Behaviors.CheckOut_Required) { if (!checkedItems.Check_Out(currentItem.Web.ItemID, HttpContext.Current.Request.UserHostAddress)) { itemCheckedOutByOtherUser = true; } } // Check to see if this is IP restricted string restriction_message = String.Empty; if (currentItem.Behaviors.IP_Restriction_Membership > 0) { if (HttpContext.Current != null) { int user_mask = (int)HttpContext.Current.Session["IP_Range_Membership"]; int comparison = currentItem.Behaviors.IP_Restriction_Membership & user_mask; if (comparison == 0) { int restriction = currentItem.Behaviors.IP_Restriction_Membership; int restriction_counter = 0; while (restriction % 2 != 1) { restriction = restriction >> 1; restriction_counter++; } restriction_message = ipRestrictionInfo[restriction_counter].Item_Restricted_Statement; } } } // Create the item viewer writer subwriter = new Item_HtmlSubwriter(currentItem, currentPage, currentUser, codeManager, translator, show_toc, (SobekCM_Library_Settings.JP2ServerUrl.Length > 0), currentMode, hierarchyObject, restriction_message, itemsInTitle, Tracer); ((Item_HtmlSubwriter)subwriter).Item_Checked_Out_By_Other_User = itemCheckedOutByOtherUser; } else { // Create the invalid item html subwrite and write the HTML subwriter = new Error_HtmlSubwriter(true); } break; } } catch (Exception ee) { // Send to the dashboard if ((HttpContext.Current.Request.UserHostAddress == "127.0.0.1") || (HttpContext.Current.Request.UserHostAddress == HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]) || (HttpContext.Current.Request.Url.ToString().IndexOf("localhost") >= 0)) { Tracer.Add_Trace("Html_MainWriter.Constructor", "Exception caught!", Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("Html_MainWriter.Constructor", ee.Message, Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("Html_MainWriter.Constructor", ee.StackTrace, Custom_Trace_Type_Enum.Error); // Wrap this into the SobekCM Exception SobekCM_Traced_Exception newException = new SobekCM_Traced_Exception("Exception caught while building the mode-specific HTML Subwriter", ee, Tracer); // Save this to the session state, and then forward to the dashboard HttpContext.Current.Session["Last_Exception"] = newException; HttpContext.Current.Response.Redirect("dashboard.aspx", false); Current_Mode.Request_Completed = true; return; } else { subwriter = new Error_HtmlSubwriter(false); } } if (subwriter != null) { subwriter.Mode = currentMode; subwriter.Skin = htmlSkin; subwriter.Current_Aggregation = hierarchyObject; } }
/// <summary> Parse the query and set the internal variables </summary> /// <param name="QueryString"> QueryString collection passed from the main page </param> /// <param name="Navigator"> Navigation object to hold the mode information </param> /// <param name="Base_URL">Requested base URL (without query string, etc..)</param> /// <param name="User_Languages"> Languages preferred by user, per their browser settings </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library</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 void Parse_Query(NameValueCollection QueryString, SobekCM_Navigation_Object Navigator, string Base_URL, string[] User_Languages, Aggregation_Code_Manager Code_Manager, Dictionary<string, string> Aggregation_Aliases, ref Item_Lookup_Object All_Items_Lookup, Portal_List URL_Portals, Custom_Tracer Tracer ) { // This is the legacy URL reader, so this is not optimized as well as the new one. // Just make sure the item list is loaded here SobekCM_Database.Verify_Item_Lookup_Object(true, ref All_Items_Lookup, Tracer); // Set default mode to error Navigator.Mode = Display_Mode_Enum.Error; // If this has 'verb' then this is an OAI-PMH request if ( QueryString["verb"] != null ) { Navigator.Writer_Type = Writer_Type_Enum.OAI; return; } // Is there a TOC state set? if (QueryString["toc"] != null) { if (QueryString["toc"] == "y") { Navigator.TOC_Display = TOC_Display_Type_Enum.Show; } else if ( QueryString["toc"] == "n" ) { Navigator.TOC_Display = TOC_Display_Type_Enum.Hide; } } // Is there a language defined? If so, load right into the navigator if ( QueryString["l"] != null ) { if (( QueryString["l"].ToUpper() == "ES" ) || ( QueryString["l"].ToUpper() == "SP" )) { Navigator.Language = Web_Language_Enum.Spanish; } if ( QueryString["l"].ToUpper() == "FR" ) { Navigator.Language = Web_Language_Enum.French; } } // If there is flag indicating to show the trace route, save it if (QueryString["trace"] != null) { Navigator.Trace_Flag = QueryString["trace"].ToUpper() == "NO" ? Trace_Flag_Type_Enum.No : Trace_Flag_Type_Enum.Explicit; } else { Navigator.Trace_Flag = Trace_Flag_Type_Enum.Unspecified; } // Collect all the values into the strings Collect_Strings( QueryString ); // Get the valid URL Portal Navigator.Default_Aggregation = "all"; Portal urlPortal = URL_Portals.Get_Valid_Portal(Base_URL); Navigator.SobekCM_Instance_Abbreviation = urlPortal.Abbreviation; if (urlPortal.Default_Aggregation.Length > 0) { Navigator.Default_Aggregation = urlPortal.Default_Aggregation; Navigator.Aggregation = urlPortal.Default_Aggregation; } if (urlPortal.Default_Web_Skin.Length > 0) { Navigator.Default_Skin = urlPortal.Default_Web_Skin; Navigator.Skin = urlPortal.Default_Web_Skin; Navigator.Skin_In_URL = false; } // Save the interface if (currSkin.Length > 0) { Navigator.Skin = currSkin.ToLower(); Navigator.Skin_In_URL = true; } // Get the return url if there was one if (return_url.Length > 0) { Navigator.Return_URL = HttpUtility.UrlDecode(return_url); } // If there are no values in the query string, the // current mode should be the default if (( QueryString.Keys.Count == 0 ) && ( aggregation.Length == 0 )) { Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Home; Navigator.Home_Type = Home_Type_Enum.List; return; } char default_html = 'h'; if (HttpContext.Current != null) { if ((HttpContext.Current.Session["user"] != null) || (HttpContext.Current.Request.Cookies["UfdcUser"] != null)) default_html = 'l'; } // If there is no mode listed, just set it to 'h' for home if (string.IsNullOrEmpty(mode)) { if ( search.Length > 0 ) { mode = default_html + "sb"; } else { if (( item.Length > 0 ) || ( bibid.Length > 0 )) { mode = default_html + "d"; } else { mode = default_html + "hl"; } } } // If the length is insufficient, try adding 'h' in front if ( mode.Length == 1 ) mode = default_html + mode; // Check for writer mode switch( mode[0] ) { case 'x': Navigator.Writer_Type = Writer_Type_Enum.XML; break; case 'd': Navigator.Writer_Type = Writer_Type_Enum.DataSet; break; case 't': Navigator.Writer_Type = Writer_Type_Enum.Text; break; case 'j': Navigator.Writer_Type = Writer_Type_Enum.JSON; break; case 'l': Navigator.Writer_Type = Writer_Type_Enum.HTML_LoggedIn; break; default: Navigator.Writer_Type = Writer_Type_Enum.HTML; break; } // Save the aggregation information Navigator.Aggregation = aggregation; Navigator.SubAggregation = subaggregation; // Perform switch, based on the mode switch ( mode[1] ) { case 'a': Admin_Block(Navigator); return; case 'b': Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Browse_Info; Browse_Info_Block( Navigator ); return; case 'c': if ((mode == "hcs") || ( mode == "lcs" )) { Navigator.Mode = Display_Mode_Enum.Contact_Sent; } else { Navigator.Mode = Display_Mode_Enum.Contact; Navigator.Error_Message = error_message; } Navigator.Aggregation = aggregation; return; case 'd': Item_Display_Block(Navigator); return; case 'e': Text_Display(Navigator); return; case 'f': Item_Print_Block(Navigator); return; case 'g': Public_Folder_Block(Navigator); break; case 'h': Home_Block( Navigator ); return; case 'i': Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Browse_Info; Browse_Info_Block(Navigator); return; case 'm': My_Sobek_Block(Navigator); return; case 'p': Navigator.Mode = Display_Mode_Enum.Preferences; return; case 'r': Results_Block(Navigator); return; case 's': // Performing a basic search Search_Block( Navigator ); return; case 't': Statistics_Block(Navigator); return; case 'z': Navigator.Mode = Display_Mode_Enum.Reset; return; default: Navigator.Mode = Display_Mode_Enum.Error; Navigator.Error_Message = "Unknown mode '" + mode + "'"; return; } }
/// <summary> Method adds aggregation codes to the pertinent element objects ( i.e., collections, subcollecctions, etc.. ) </summary> /// <param name="codeManager"> Code manager object with aggregation codes </param> internal void Add_Codes(Aggregation_Code_Manager codeManager) { // Go through each of the elements and prepare to save foreach (abstract_Element thisElement in templatePages.SelectMany(thisPage => thisPage.Panels.SelectMany(thisPanel => thisPanel.Elements))) { if (thisElement.Type == Element_Type.Aggregations) ((Aggregations_Element)thisElement).Add_Codes(codeManager); if ( thisElement.Type == Element_Type.Source ) ((Source_Element)thisElement).Add_Codes(codeManager); if (thisElement.Type == Element_Type.Holding) ((Holding_Element)thisElement).Add_Codes(codeManager); } }
/// <summary> Gets the item aggregation and search fields for the current item aggregation </summary> /// <param name="Current_Mode"> 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> /// <param name="Aggregation_Object"> [OUT] Fully-built object for the current aggregation object </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> This attempts to pull the objects from the cache. If unsuccessful, it builds the objects from the /// database and hands off to the <see cref="Cached_Data_Manager" /> to store in the cache. </remarks> public bool Get_Entire_Collection_Hierarchy(SobekCM_Navigation_Object Current_Mode, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer, out Item_Aggregation Aggregation_Object) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Entire_Collection_Hierarchy", String.Empty); } string languageCode = "en"; if (Current_Mode.Language == Web_Language_Enum.Spanish) languageCode = "es"; if (Current_Mode.Language == Web_Language_Enum.French) languageCode = "fr"; // If there is an aggregation listed, try to get that now if ((Current_Mode.Aggregation.Length > 0) && (Current_Mode.Aggregation != "all")) { // Try to pull the aggregation information Aggregation_Object = Get_Item_Aggregation(Current_Mode.Aggregation, languageCode, Current_Mode.Is_Robot, Tracer ); // Return if this was valid if (Aggregation_Object != null) { if ((Current_Mode.Skin_in_URL != true) && ( Aggregation_Object.Default_Skin.Length > 0 )) { Current_Mode.Skin = Aggregation_Object.Default_Skin.ToLower(); } return true; } Current_Mode.Error_Message = "Invalid item aggregation '" + Current_Mode.Aggregation + "' referenced."; return false; } // Get the collection group Aggregation_Object = Get_All_Collections(languageCode, Current_Mode.Is_Robot, Tracer ); // If this is null, just stop if (Aggregation_Object == null) { Current_Mode.Error_Message = "Unable to pull the item aggregation corresponding to all collection groups"; return false; } return true; }
/// <summary> Constructor for a new instance of the Internal_HtmlSubwriter class </summary> /// <param name="Icon_Dictionary"> Dictionary of information about every wordmark/icon in this digital library, used to build the wordmarks subpage </param> /// <param name="User"> Currently logged on user, which determines how some screens display (particularly the new items screen)</param> /// <param name="Code_Manager"> Code manager has all the aggregation codes and some of the hierarchy for all aggregations in this system </param> public Internal_HtmlSubwriter(Dictionary<string, Wordmark_Icon> Icon_Dictionary, User_Object User, Aggregation_Code_Manager Code_Manager ) { iconList = Icon_Dictionary; user = User; codeManager = Code_Manager; }
/// <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; }